Update to latest XFree86 mkdepend source to fix hangs generating dependencies with mingw builds (bug 220875). rs=cls.
git-svn-id: svn://10.0.0.236/trunk@147494 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
67d9f64891
commit
24fd8bca5d
@ -24,6 +24,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
/* $XFree86: xc/config/makedepend/cppsetup.c,v 3.11 2001/12/17 20:52:22 dawes Exp $ */
|
||||
|
||||
#include "def.h"
|
||||
|
||||
@ -39,7 +40,7 @@ in this Software without prior written authorization from The Open Group.
|
||||
#define QB 16
|
||||
#define WB 32
|
||||
#define SALT '#'
|
||||
#if pdp11 | vax | ns16000 | mc68000 | ibm032
|
||||
#if defined(pdp11) || defined(vax) || defined(ns16000) || defined(mc68000) || defined(ibm032)
|
||||
#define COFF 128
|
||||
#else
|
||||
#define COFF 0
|
||||
@ -58,12 +59,10 @@ extern char slotab[];
|
||||
struct filepointer *currentfile;
|
||||
struct inclist *currentinc;
|
||||
|
||||
cppsetup(line, filep, inc)
|
||||
register char *line;
|
||||
register struct filepointer *filep;
|
||||
register struct inclist *inc;
|
||||
int
|
||||
cppsetup(char *line, struct filepointer *filep, struct inclist *inc)
|
||||
{
|
||||
register char *p, savec;
|
||||
char *p, savec;
|
||||
static boolean setupdone = FALSE;
|
||||
boolean value;
|
||||
|
||||
@ -132,10 +131,7 @@ struct _parse_data {
|
||||
};
|
||||
|
||||
static const char *
|
||||
my_if_errors (ip, cp, expecting)
|
||||
IfParser *ip;
|
||||
const char *cp;
|
||||
const char *expecting;
|
||||
my_if_errors (IfParser *ip, const char *cp, const char *expecting)
|
||||
{
|
||||
struct _parse_data *pd = (struct _parse_data *) ip->data;
|
||||
int lineno = pd->filep->f_line;
|
||||
@ -162,10 +158,7 @@ my_if_errors (ip, cp, expecting)
|
||||
#define MAXNAMELEN 256
|
||||
|
||||
static struct symtab **
|
||||
lookup_variable (ip, var, len)
|
||||
IfParser *ip;
|
||||
const char *var;
|
||||
int len;
|
||||
lookup_variable (IfParser *ip, const char *var, int len)
|
||||
{
|
||||
char tmpbuf[MAXNAMELEN + 1];
|
||||
struct _parse_data *pd = (struct _parse_data *) ip->data;
|
||||
@ -180,10 +173,7 @@ lookup_variable (ip, var, len)
|
||||
|
||||
|
||||
static int
|
||||
my_eval_defined (ip, var, len)
|
||||
IfParser *ip;
|
||||
const char *var;
|
||||
int len;
|
||||
my_eval_defined (IfParser *ip, const char *var, int len)
|
||||
{
|
||||
if (lookup_variable (ip, var, len))
|
||||
return 1;
|
||||
@ -194,11 +184,9 @@ my_eval_defined (ip, var, len)
|
||||
#define isvarfirstletter(ccc) (isalpha(ccc) || (ccc) == '_')
|
||||
|
||||
static long
|
||||
my_eval_variable (ip, var, len)
|
||||
IfParser *ip;
|
||||
const char *var;
|
||||
int len;
|
||||
my_eval_variable (IfParser *ip, const char *var, int len)
|
||||
{
|
||||
long val;
|
||||
struct symtab **s;
|
||||
|
||||
s = lookup_variable (ip, var, len);
|
||||
@ -206,20 +194,21 @@ my_eval_variable (ip, var, len)
|
||||
return 0;
|
||||
do {
|
||||
var = (*s)->s_value;
|
||||
if (!isvarfirstletter(*var))
|
||||
if (!isvarfirstletter(*var) || !strcmp((*s)->s_name, var))
|
||||
break;
|
||||
s = lookup_variable (ip, var, strlen(var));
|
||||
} while (s);
|
||||
|
||||
return strtol(var, NULL, 0);
|
||||
var = ParseIfExpression(ip, var, &val);
|
||||
if (var && *var) debug(4, ("extraneous: '%s'\n", var));
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
cppsetup(filename, line, filep, inc)
|
||||
register char *filename;
|
||||
register char *line;
|
||||
register struct filepointer *filep;
|
||||
register struct inclist *inc;
|
||||
int
|
||||
cppsetup(char *filename,
|
||||
char *line,
|
||||
struct filepointer *filep,
|
||||
struct inclist *inc)
|
||||
{
|
||||
IfParser ip;
|
||||
struct _parse_data pd;
|
||||
|
||||
@ -24,24 +24,30 @@ used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
/* $XFree86: xc/config/makedepend/def.h,v 3.14 2003/01/17 17:09:49 tsi Exp $ */
|
||||
|
||||
#ifndef NO_X11
|
||||
#include <X11/Xos.h>
|
||||
#include <X11/Xfuncproto.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#if 0
|
||||
#ifndef X_NOT_POSIX
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define _POSIX_SOURCE
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define MAXDEFINES 512
|
||||
#define MAXFILES 1024
|
||||
#define MAXINCFILES 128 /* "-include" files */
|
||||
#define MAXDIRS 64
|
||||
#define SYMTABINC 10 /* must be > 1 for define() to work right */
|
||||
#define TRUE 1
|
||||
@ -63,12 +69,14 @@ in this Software without prior written authorization from The Open Group.
|
||||
#define SCCS 12
|
||||
#define ELIF 13
|
||||
#define EJECT 14
|
||||
#define WARNING 15
|
||||
#define IFFALSE 16 /* pseudo value --- never matched */
|
||||
#define ELIFFALSE 17 /* pseudo value --- never matched */
|
||||
#define INCLUDEDOT 18 /* pseudo value --- never matched */
|
||||
#define IFGUESSFALSE 19 /* pseudo value --- never matched */
|
||||
#define ELIFGUESSFALSE 20 /* pseudo value --- never matched */
|
||||
#define WARNING 15
|
||||
#define INCLUDENEXT 16
|
||||
#define IFFALSE 17 /* pseudo value --- never matched */
|
||||
#define ELIFFALSE 18 /* pseudo value --- never matched */
|
||||
#define INCLUDEDOT 19 /* pseudo value --- never matched */
|
||||
#define IFGUESSFALSE 20 /* pseudo value --- never matched */
|
||||
#define ELIFGUESSFALSE 21 /* pseudo value --- never matched */
|
||||
#define INCLUDENEXTDOT 22 /* pseudo value --- never matched */
|
||||
|
||||
#ifdef DEBUG
|
||||
extern int _debugmask;
|
||||
@ -115,35 +123,62 @@ struct inclist {
|
||||
};
|
||||
|
||||
struct filepointer {
|
||||
char *f_name;
|
||||
char *f_p;
|
||||
char *f_base;
|
||||
char *f_end;
|
||||
long f_len;
|
||||
long f_line;
|
||||
long cmdinc_count;
|
||||
char **cmdinc_list;
|
||||
long cmdinc_line;
|
||||
};
|
||||
|
||||
#ifndef X_NOT_STDC_ENV
|
||||
#include <stdlib.h>
|
||||
#if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */
|
||||
char *malloc(), *realloc();
|
||||
#endif /* macII */
|
||||
#else
|
||||
char *malloc();
|
||||
char *realloc();
|
||||
#endif
|
||||
|
||||
char *copy();
|
||||
char *base_name();
|
||||
char *getline();
|
||||
struct symtab **slookup();
|
||||
struct symtab **isdefined();
|
||||
struct symtab **fdefined();
|
||||
struct filepointer *getfile();
|
||||
struct inclist *newinclude();
|
||||
struct inclist *inc_path();
|
||||
char *copy(char *str);
|
||||
int match(char *str, char **list);
|
||||
char *base_name(char *file);
|
||||
char *getnextline(struct filepointer *fp);
|
||||
struct symtab **slookup(char *symbol, struct inclist *file);
|
||||
struct symtab **isdefined(char *symbol, struct inclist *file,
|
||||
struct inclist **srcfile);
|
||||
struct symtab **fdefined(char *symbol, struct inclist *file,
|
||||
struct inclist **srcfile);
|
||||
struct filepointer *getfile(char *file);
|
||||
void included_by(struct inclist *ip,
|
||||
struct inclist *newfile);
|
||||
struct inclist *newinclude(char *newfile, char *incstring);
|
||||
void inc_clean (void);
|
||||
struct inclist *inc_path(char *file, char *include, int type);
|
||||
|
||||
void freefile(struct filepointer *fp);
|
||||
|
||||
void define2(char *name, char *val, struct inclist *file);
|
||||
void define(char *def, struct inclist *file);
|
||||
void undefine(char *symbol, struct inclist *file);
|
||||
int find_includes(struct filepointer *filep,
|
||||
struct inclist *file,
|
||||
struct inclist *file_red,
|
||||
int recursion, boolean failOK);
|
||||
|
||||
void recursive_pr_include(struct inclist *head,
|
||||
char *file, char *base);
|
||||
void add_include(struct filepointer *filep,
|
||||
struct inclist *file,
|
||||
struct inclist *file_red,
|
||||
char *include, int type,
|
||||
boolean failOK);
|
||||
|
||||
int cppsetup(char *filename,
|
||||
char *line,
|
||||
struct filepointer *filep,
|
||||
struct inclist *inc);
|
||||
|
||||
|
||||
#if NeedVarargsPrototypes
|
||||
extern void fatalerr(char *, ...);
|
||||
extern void warning(char *, ...);
|
||||
extern void warning1(char *, ...);
|
||||
#endif
|
||||
|
||||
@ -31,10 +31,13 @@
|
||||
*
|
||||
* EXPRESSION := VALUE
|
||||
* | VALUE BINOP EXPRESSION
|
||||
* | VALUE '?' EXPRESSION ':' EXPRESSION
|
||||
*
|
||||
* VALUE := '(' EXPRESSION ')'
|
||||
* | '!' VALUE
|
||||
* | '-' VALUE
|
||||
* | '+' VALUE
|
||||
* | '~' VALUE
|
||||
* | 'defined' '(' variable ')'
|
||||
* | 'defined' variable
|
||||
* | # variable '(' variable-list ')'
|
||||
@ -46,19 +49,22 @@
|
||||
* | '<<' | '>>'
|
||||
* | '<' | '>' | '<=' | '>='
|
||||
* | '==' | '!='
|
||||
* | '&' | '|'
|
||||
* | '&' | '^' | '|'
|
||||
* | '&&' | '||'
|
||||
*
|
||||
* The normal C order of precidence is supported.
|
||||
* The normal C order of precedence is supported.
|
||||
*
|
||||
*
|
||||
* External Entry Points:
|
||||
*
|
||||
* ParseIfExpression parse a string for #if
|
||||
*/
|
||||
/* $XFree86: xc/config/makedepend/ifparser.c,v 3.11 2002/09/23 01:48:08 tsi Exp $ */
|
||||
|
||||
#include "ifparser.h"
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/****************************************************************************
|
||||
Internal Macros and Utilities for Parser
|
||||
@ -71,10 +77,7 @@
|
||||
|
||||
|
||||
static const char *
|
||||
parse_variable (g, cp, varp)
|
||||
IfParser *g;
|
||||
const char *cp;
|
||||
const char **varp;
|
||||
parse_variable (IfParser *g, const char *cp, const char **varp)
|
||||
{
|
||||
SKIPSPACE (cp);
|
||||
|
||||
@ -89,32 +92,55 @@ parse_variable (g, cp, varp)
|
||||
|
||||
|
||||
static const char *
|
||||
parse_number (g, cp, valp)
|
||||
IfParser *g;
|
||||
const char *cp;
|
||||
long *valp;
|
||||
parse_number (IfParser *g, const char *cp, long *valp)
|
||||
{
|
||||
long base = 10;
|
||||
SKIPSPACE (cp);
|
||||
|
||||
if (!isdigit(*cp))
|
||||
return CALLFUNC(g, handle_error) (g, cp, "number");
|
||||
|
||||
*valp = strtol(cp, &cp, 0);
|
||||
/* skip trailing qualifiers */
|
||||
*valp = 0;
|
||||
|
||||
if (*cp == '0') {
|
||||
cp++;
|
||||
if ((*cp == 'x') || (*cp == 'X')) {
|
||||
base = 16;
|
||||
cp++;
|
||||
} else {
|
||||
base = 8;
|
||||
}
|
||||
}
|
||||
|
||||
/* Ignore overflows and assume ASCII, what source is usually written in */
|
||||
while (1) {
|
||||
int increment = -1;
|
||||
if (base == 8) {
|
||||
if ((*cp >= '0') && (*cp <= '7'))
|
||||
increment = *cp++ - '0';
|
||||
} else if (base == 16) {
|
||||
if ((*cp >= '0') && (*cp <= '9'))
|
||||
increment = *cp++ - '0';
|
||||
else if ((*cp >= 'A') && (*cp <= 'F'))
|
||||
increment = *cp++ - ('A' - 10);
|
||||
else if ((*cp >= 'a') && (*cp <= 'f'))
|
||||
increment = *cp++ - ('a' - 10);
|
||||
} else { /* Decimal */
|
||||
if ((*cp >= '0') && (*cp <= '9'))
|
||||
increment = *cp++ - '0';
|
||||
}
|
||||
if (increment < 0)
|
||||
break;
|
||||
*valp = (*valp * base) + increment;
|
||||
}
|
||||
|
||||
/* Skip trailing qualifiers */
|
||||
while (*cp == 'U' || *cp == 'u' || *cp == 'L' || *cp == 'l') cp++;
|
||||
#if 0
|
||||
*valp = atoi (cp);
|
||||
/* EMPTY */
|
||||
for (cp++; isdigit(*cp); cp++) ;
|
||||
#endif
|
||||
return cp;
|
||||
}
|
||||
|
||||
static const char *
|
||||
parse_character (g, cp, valp)
|
||||
IfParser *g;
|
||||
const char *cp;
|
||||
long *valp;
|
||||
parse_character (IfParser *g, const char *cp, long *valp)
|
||||
{
|
||||
char val;
|
||||
|
||||
@ -143,12 +169,9 @@ parse_character (g, cp, valp)
|
||||
}
|
||||
|
||||
static const char *
|
||||
parse_value (g, cp, valp)
|
||||
IfParser *g;
|
||||
const char *cp;
|
||||
long *valp;
|
||||
parse_value (IfParser *g, const char *cp, long *valp)
|
||||
{
|
||||
const char *var;
|
||||
const char *var, *varend;
|
||||
|
||||
*valp = 0;
|
||||
|
||||
@ -175,6 +198,15 @@ parse_value (g, cp, valp)
|
||||
*valp = -(*valp);
|
||||
return cp;
|
||||
|
||||
case '+':
|
||||
DO (cp = parse_value (g, cp + 1, valp));
|
||||
return cp;
|
||||
|
||||
case '~':
|
||||
DO (cp = parse_value (g, cp + 1, valp));
|
||||
*valp = ~(*valp);
|
||||
return cp;
|
||||
|
||||
case '#':
|
||||
DO (cp = parse_variable (g, cp + 1, &var));
|
||||
SKIPSPACE (cp);
|
||||
@ -223,7 +255,24 @@ parse_value (g, cp, valp)
|
||||
return CALLFUNC(g, handle_error) (g, cp, "variable or number");
|
||||
else {
|
||||
DO (cp = parse_variable (g, cp, &var));
|
||||
*valp = (*(g->funcs.eval_variable)) (g, var, cp - var);
|
||||
varend = cp;
|
||||
SKIPSPACE(cp);
|
||||
if (*cp != '(') {
|
||||
*valp = (*(g->funcs.eval_variable)) (g, var, varend - var);
|
||||
} else {
|
||||
do {
|
||||
long dummy;
|
||||
DO (cp = ParseIfExpression (g, cp + 1, &dummy));
|
||||
SKIPSPACE(cp);
|
||||
if (*cp == ')')
|
||||
break;
|
||||
if (*cp != ',')
|
||||
return CALLFUNC(g, handle_error) (g, cp, ",");
|
||||
} while (1);
|
||||
|
||||
*valp = 1; /* XXX */
|
||||
cp++;
|
||||
}
|
||||
}
|
||||
|
||||
return cp;
|
||||
@ -232,10 +281,7 @@ parse_value (g, cp, valp)
|
||||
|
||||
|
||||
static const char *
|
||||
parse_product (g, cp, valp)
|
||||
IfParser *g;
|
||||
const char *cp;
|
||||
long *valp;
|
||||
parse_product (IfParser *g, const char *cp, long *valp)
|
||||
{
|
||||
long rightval;
|
||||
|
||||
@ -263,10 +309,7 @@ parse_product (g, cp, valp)
|
||||
|
||||
|
||||
static const char *
|
||||
parse_sum (g, cp, valp)
|
||||
IfParser *g;
|
||||
const char *cp;
|
||||
long *valp;
|
||||
parse_sum (IfParser *g, const char *cp, long *valp)
|
||||
{
|
||||
long rightval;
|
||||
|
||||
@ -289,10 +332,7 @@ parse_sum (g, cp, valp)
|
||||
|
||||
|
||||
static const char *
|
||||
parse_shift (g, cp, valp)
|
||||
IfParser *g;
|
||||
const char *cp;
|
||||
long *valp;
|
||||
parse_shift (IfParser *g, const char *cp, long *valp)
|
||||
{
|
||||
long rightval;
|
||||
|
||||
@ -319,10 +359,7 @@ parse_shift (g, cp, valp)
|
||||
|
||||
|
||||
static const char *
|
||||
parse_inequality (g, cp, valp)
|
||||
IfParser *g;
|
||||
const char *cp;
|
||||
long *valp;
|
||||
parse_inequality (IfParser *g, const char *cp, long *valp)
|
||||
{
|
||||
long rightval;
|
||||
|
||||
@ -355,10 +392,7 @@ parse_inequality (g, cp, valp)
|
||||
|
||||
|
||||
static const char *
|
||||
parse_equality (g, cp, valp)
|
||||
IfParser *g;
|
||||
const char *cp;
|
||||
long *valp;
|
||||
parse_equality (IfParser *g, const char *cp, long *valp)
|
||||
{
|
||||
long rightval;
|
||||
|
||||
@ -385,10 +419,7 @@ parse_equality (g, cp, valp)
|
||||
|
||||
|
||||
static const char *
|
||||
parse_band (g, cp, valp)
|
||||
IfParser *g;
|
||||
const char *cp;
|
||||
long *valp;
|
||||
parse_band (IfParser *g, const char *cp, long *valp)
|
||||
{
|
||||
long rightval;
|
||||
|
||||
@ -408,16 +439,31 @@ parse_band (g, cp, valp)
|
||||
|
||||
|
||||
static const char *
|
||||
parse_bor (g, cp, valp)
|
||||
IfParser *g;
|
||||
const char *cp;
|
||||
long *valp;
|
||||
parse_bxor (IfParser *g, const char *cp, long *valp)
|
||||
{
|
||||
long rightval;
|
||||
|
||||
DO (cp = parse_band (g, cp, valp));
|
||||
SKIPSPACE (cp);
|
||||
|
||||
switch (*cp) {
|
||||
case '^':
|
||||
DO (cp = parse_bxor (g, cp + 1, &rightval));
|
||||
*valp = (*valp ^ rightval);
|
||||
break;
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
parse_bor (IfParser *g, const char *cp, long *valp)
|
||||
{
|
||||
long rightval;
|
||||
|
||||
DO (cp = parse_bxor (g, cp, valp));
|
||||
SKIPSPACE (cp);
|
||||
|
||||
switch (*cp) {
|
||||
case '|':
|
||||
if (cp[1] != '|') {
|
||||
@ -431,10 +477,7 @@ parse_bor (g, cp, valp)
|
||||
|
||||
|
||||
static const char *
|
||||
parse_land (g, cp, valp)
|
||||
IfParser *g;
|
||||
const char *cp;
|
||||
long *valp;
|
||||
parse_land (IfParser *g, const char *cp, long *valp)
|
||||
{
|
||||
long rightval;
|
||||
|
||||
@ -454,10 +497,7 @@ parse_land (g, cp, valp)
|
||||
|
||||
|
||||
static const char *
|
||||
parse_lor (g, cp, valp)
|
||||
IfParser *g;
|
||||
const char *cp;
|
||||
long *valp;
|
||||
parse_lor (IfParser *g, const char *cp, long *valp)
|
||||
{
|
||||
long rightval;
|
||||
|
||||
@ -476,17 +516,34 @@ parse_lor (g, cp, valp)
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
parse_cond(IfParser *g, const char *cp, long *valp)
|
||||
{
|
||||
long trueval, falseval;
|
||||
|
||||
DO (cp = parse_lor (g, cp, valp));
|
||||
SKIPSPACE (cp);
|
||||
|
||||
switch (*cp) {
|
||||
case '?':
|
||||
DO (cp = parse_cond (g, cp + 1, &trueval));
|
||||
SKIPSPACE (cp);
|
||||
if (*cp != ':')
|
||||
return CALLFUNC(g, handle_error) (g, cp, ":");
|
||||
DO (cp = parse_cond (g, cp + 1, &falseval));
|
||||
*valp = (*valp ? trueval : falseval);
|
||||
break;
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
External Entry Points
|
||||
****************************************************************************/
|
||||
|
||||
const char *
|
||||
ParseIfExpression (g, cp, valp)
|
||||
IfParser *g;
|
||||
const char *cp;
|
||||
long *valp;
|
||||
ParseIfExpression (IfParser *g, const char *cp, long *valp)
|
||||
{
|
||||
return parse_lor (g, cp, valp);
|
||||
return parse_cond (g, cp, valp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -31,10 +31,12 @@
|
||||
*
|
||||
* EXPRESSION := VALUE
|
||||
* | VALUE BINOP EXPRESSION
|
||||
* | VALUE '?' EXPRESSION ':' EXPRESSION
|
||||
*
|
||||
* VALUE := '(' EXPRESSION ')'
|
||||
* | '!' VALUE
|
||||
* | '-' VALUE
|
||||
* | '~' VALUE
|
||||
* | 'defined' '(' variable ')'
|
||||
* | variable
|
||||
* | number
|
||||
@ -44,10 +46,10 @@
|
||||
* | '<<' | '>>'
|
||||
* | '<' | '>' | '<=' | '>='
|
||||
* | '==' | '!='
|
||||
* | '&' | '|'
|
||||
* | '&' | '^' | '|'
|
||||
* | '&&' | '||'
|
||||
*
|
||||
* The normal C order of precidence is supported.
|
||||
* The normal C order of precedence is supported.
|
||||
*
|
||||
*
|
||||
* External Entry Points:
|
||||
@ -55,28 +57,27 @@
|
||||
* ParseIfExpression parse a string for #if
|
||||
*/
|
||||
|
||||
/* $XFree86: xc/config/makedepend/ifparser.h,v 3.5 2001/07/25 15:04:40 dawes Exp $ */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define const /**/
|
||||
typedef int Bool;
|
||||
#define False 0
|
||||
#define True 1
|
||||
|
||||
typedef struct _if_parser {
|
||||
struct { /* functions */
|
||||
char *(*handle_error) (/* struct _if_parser *, const char *,
|
||||
const char * */);
|
||||
long (*eval_variable) (/* struct _if_parser *, const char *, int */);
|
||||
int (*eval_defined) (/* struct _if_parser *, const char *, int */);
|
||||
const char *(*handle_error) (struct _if_parser *, const char *,
|
||||
const char *);
|
||||
long (*eval_variable) (struct _if_parser *, const char *, int);
|
||||
int (*eval_defined) (struct _if_parser *, const char *, int);
|
||||
} funcs;
|
||||
char *data;
|
||||
} IfParser;
|
||||
|
||||
char *ParseIfExpression (
|
||||
#ifdef __STDC__
|
||||
const char *ParseIfExpression (
|
||||
IfParser *,
|
||||
const char *,
|
||||
long *
|
||||
#endif
|
||||
);
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
/* $XFree86: xc/config/makedepend/include.c,v 3.7 2001/12/14 19:53:20 dawes Exp $ */
|
||||
|
||||
|
||||
#include "def.h"
|
||||
@ -33,33 +34,31 @@ in this Software without prior written authorization from The Open Group.
|
||||
#endif
|
||||
|
||||
extern struct inclist inclist[ MAXFILES ],
|
||||
*inclistp;
|
||||
extern char *includedirs[ ];
|
||||
*inclistp, *inclistnext;
|
||||
extern char *includedirs[ ],
|
||||
**includedirsnext;
|
||||
extern char *notdotdot[ ];
|
||||
extern boolean show_where_not;
|
||||
extern boolean warn_multiple;
|
||||
|
||||
boolean
|
||||
isdot(p)
|
||||
register char *p;
|
||||
static boolean
|
||||
isdot(char *p)
|
||||
{
|
||||
if(p && *p++ == '.' && *p++ == '\0')
|
||||
return(TRUE);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
boolean
|
||||
isdotdot(p)
|
||||
register char *p;
|
||||
static boolean
|
||||
isdotdot(char *p)
|
||||
{
|
||||
if(p && *p++ == '.' && *p++ == '.' && *p++ == '\0')
|
||||
return(TRUE);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
boolean
|
||||
issymbolic(dir, component)
|
||||
register char *dir, *component;
|
||||
static boolean
|
||||
issymbolic(char *dir, char *component)
|
||||
{
|
||||
#ifdef S_IFLNK
|
||||
struct stat st;
|
||||
@ -85,9 +84,8 @@ issymbolic(dir, component)
|
||||
* Any of the 'x/..' sequences within the name can be eliminated.
|
||||
* (but only if 'x' is not a symbolic link!!)
|
||||
*/
|
||||
void
|
||||
remove_dotdot(path)
|
||||
char *path;
|
||||
static void
|
||||
remove_dotdot(char *path)
|
||||
{
|
||||
register char *end, *from, *to, **cp;
|
||||
char *components[ MAXFILES ],
|
||||
@ -158,8 +156,8 @@ remove_dotdot(path)
|
||||
/*
|
||||
* Add an include file to the list of those included by 'file'.
|
||||
*/
|
||||
struct inclist *newinclude(newfile, incstring)
|
||||
register char *newfile, *incstring;
|
||||
struct inclist *
|
||||
newinclude(char *newfile, char *incstring)
|
||||
{
|
||||
register struct inclist *ip;
|
||||
|
||||
@ -176,12 +174,12 @@ struct inclist *newinclude(newfile, incstring)
|
||||
else
|
||||
ip->i_incstring = copy(incstring);
|
||||
|
||||
inclistnext = inclistp;
|
||||
return(ip);
|
||||
}
|
||||
|
||||
void
|
||||
included_by(ip, newfile)
|
||||
register struct inclist *ip, *newfile;
|
||||
included_by(struct inclist *ip, struct inclist *newfile)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@ -231,7 +229,7 @@ included_by(ip, newfile)
|
||||
}
|
||||
|
||||
void
|
||||
inc_clean ()
|
||||
inc_clean (void)
|
||||
{
|
||||
register struct inclist *ip;
|
||||
|
||||
@ -240,84 +238,85 @@ inc_clean ()
|
||||
}
|
||||
}
|
||||
|
||||
struct inclist *inc_path(file, include, dot)
|
||||
register char *file,
|
||||
*include;
|
||||
boolean dot;
|
||||
struct inclist *
|
||||
inc_path(char *file, char *include, int type)
|
||||
{
|
||||
static char path[ BUFSIZ ];
|
||||
static char path[ BUFSIZ ];
|
||||
register char **pp, *p;
|
||||
register struct inclist *ip;
|
||||
struct stat st;
|
||||
boolean found = FALSE;
|
||||
struct stat st;
|
||||
|
||||
/*
|
||||
* Check all previously found include files for a path that
|
||||
* has already been expanded.
|
||||
*/
|
||||
for (ip = inclist; ip->i_file; ip++)
|
||||
if ((strcmp(ip->i_incstring, include) == 0) &&
|
||||
!(ip->i_flags & INCLUDED_SYM))
|
||||
{
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
if ((type == INCLUDE) || (type == INCLUDEDOT))
|
||||
inclistnext = inclist;
|
||||
ip = inclistnext;
|
||||
|
||||
/*
|
||||
* If the path was surrounded by "" or is an absolute path,
|
||||
* then check the exact path provided.
|
||||
*/
|
||||
if (!found && (dot || *include == '/')) {
|
||||
if (stat(include, &st) == 0 && !S_ISDIR(st.st_mode)) {
|
||||
ip = newinclude(include, include);
|
||||
found = TRUE;
|
||||
for (; ip->i_file; ip++) {
|
||||
if ((strcmp(ip->i_incstring, include) == 0) &&
|
||||
!(ip->i_flags & INCLUDED_SYM)) {
|
||||
inclistnext = ip + 1;
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
|
||||
if (inclistnext == inclist) {
|
||||
/*
|
||||
* If the path was surrounded by "" or is an absolute path,
|
||||
* then check the exact path provided.
|
||||
*/
|
||||
if ((type == INCLUDEDOT) ||
|
||||
(type == INCLUDENEXTDOT) ||
|
||||
(*include == '/')) {
|
||||
if (stat(include, &st) == 0 && !S_ISDIR(st.st_mode))
|
||||
return newinclude(include, include);
|
||||
if (show_where_not)
|
||||
warning1("\tnot in %s\n", include);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the path was surrounded by "" see if this include file is
|
||||
* in the directory of the file being parsed.
|
||||
*/
|
||||
if ((type == INCLUDEDOT) || (type == INCLUDENEXTDOT)) {
|
||||
for (p=file+strlen(file); p>file; p--)
|
||||
if (*p == '/')
|
||||
break;
|
||||
if (p == file) {
|
||||
strcpy(path, include);
|
||||
} else {
|
||||
strncpy(path, file, (p-file) + 1);
|
||||
path[ (p-file) + 1 ] = '\0';
|
||||
strcpy(path + (p-file) + 1, include);
|
||||
}
|
||||
remove_dotdot(path);
|
||||
if (stat(path, &st) == 0 && !S_ISDIR(st.st_mode))
|
||||
return newinclude(path, include);
|
||||
if (show_where_not)
|
||||
warning1("\tnot in %s\n", path);
|
||||
}
|
||||
else if (show_where_not)
|
||||
warning1("\tnot in %s\n", include);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the path was surrounded by "" see if this include file is in the
|
||||
* directory of the file being parsed.
|
||||
* Check the include directories specified. Standard include dirs
|
||||
* should be at the end.
|
||||
*/
|
||||
if (!found && dot) {
|
||||
for (p=file+strlen(file); p>file; p--)
|
||||
if (*p == '/')
|
||||
break;
|
||||
if (p == file)
|
||||
strcpy(path, include);
|
||||
else {
|
||||
strncpy(path, file, (p-file) + 1);
|
||||
path[ (p-file) + 1 ] = '\0';
|
||||
strcpy(path + (p-file) + 1, include);
|
||||
}
|
||||
if ((type == INCLUDE) || (type == INCLUDEDOT))
|
||||
includedirsnext = includedirs;
|
||||
pp = includedirsnext;
|
||||
|
||||
for (; *pp; pp++) {
|
||||
sprintf(path, "%s/%s", *pp, include);
|
||||
remove_dotdot(path);
|
||||
if (stat(path, &st) == 0 && !S_ISDIR(st.st_mode)) {
|
||||
ip = newinclude(path, include);
|
||||
found = TRUE;
|
||||
includedirsnext = pp + 1;
|
||||
return newinclude(path, include);
|
||||
}
|
||||
else if (show_where_not)
|
||||
if (show_where_not)
|
||||
warning1("\tnot in %s\n", path);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the include directories specified. (standard include dir
|
||||
* should be at the end.)
|
||||
*/
|
||||
if (!found)
|
||||
for (pp = includedirs; *pp; pp++) {
|
||||
sprintf(path, "%s/%s", *pp, include);
|
||||
remove_dotdot(path);
|
||||
if (stat(path, &st) == 0 && !S_ISDIR(st.st_mode)) {
|
||||
ip = newinclude(path, include);
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
else if (show_where_not)
|
||||
warning1("\tnot in %s\n", path);
|
||||
}
|
||||
|
||||
if (!found)
|
||||
ip = NULL;
|
||||
return(ip);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
/* $XFree86: xc/config/makedepend/main.c,v 3.32 2003/03/26 20:43:48 tsi Exp $ */
|
||||
|
||||
#include "def.h"
|
||||
#ifdef hpux
|
||||
@ -44,18 +45,26 @@ in this Software without prior written authorization from The Open Group.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if NeedVarargsPrototypes
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#ifdef XP_OS2
|
||||
#include <io.h>
|
||||
#ifdef MINIX
|
||||
#define USE_CHMOD 1
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
int _debugmask;
|
||||
#endif
|
||||
|
||||
/* #define DEBUG_DUMP */
|
||||
#ifdef DEBUG_DUMP
|
||||
#define DBG_PRINT(file, fmt, args) fprintf(file, fmt, args)
|
||||
#else
|
||||
#define DBG_PRINT(file, fmt, args) /* empty */
|
||||
#endif
|
||||
|
||||
#define DASH_INC_PRE "#include \""
|
||||
#define DASH_INC_POST "\""
|
||||
|
||||
char *ProgramName;
|
||||
|
||||
char *directives[] = {
|
||||
@ -75,6 +84,7 @@ char *directives[] = {
|
||||
"elif",
|
||||
"eject",
|
||||
"warning",
|
||||
"include_next",
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -84,28 +94,28 @@ char *directives[] = {
|
||||
|
||||
struct inclist inclist[ MAXFILES ],
|
||||
*inclistp = inclist,
|
||||
*inclistnext = inclist,
|
||||
maininclist;
|
||||
|
||||
char *filelist[ MAXFILES ];
|
||||
char *includedirs[ MAXDIRS + 1 ];
|
||||
char *notdotdot[ MAXDIRS ];
|
||||
char *objprefix = "";
|
||||
char *objsuffix = OBJSUFFIX;
|
||||
char *startat = "# DO NOT DELETE";
|
||||
int width = 78;
|
||||
boolean append = FALSE;
|
||||
boolean printed = FALSE;
|
||||
boolean verbose = FALSE;
|
||||
boolean show_where_not = FALSE;
|
||||
boolean warn_multiple = FALSE; /* Warn on multiple includes of same file */
|
||||
static char *filelist[ MAXFILES ];
|
||||
char *includedirs[ MAXDIRS + 1 ],
|
||||
**includedirsnext = includedirs;
|
||||
char *notdotdot[ MAXDIRS ];
|
||||
static int cmdinc_count = 0;
|
||||
static char *cmdinc_list[ 2 * MAXINCFILES ];
|
||||
char *objprefix = "";
|
||||
char *objsuffix = OBJSUFFIX;
|
||||
static char *startat = "# DO NOT DELETE";
|
||||
int width = 78;
|
||||
static boolean append = FALSE;
|
||||
boolean printed = FALSE;
|
||||
boolean verbose = FALSE;
|
||||
boolean show_where_not = FALSE;
|
||||
/* Warn on multiple includes of same file */
|
||||
boolean warn_multiple = FALSE;
|
||||
|
||||
void freefile();
|
||||
void redirect();
|
||||
#if !NeedVarargsPrototypes
|
||||
void fatalerr();
|
||||
void warning();
|
||||
void warning1();
|
||||
#endif
|
||||
static void setfile_cmdinc(struct filepointer *filep, long count, char **list);
|
||||
static void redirect(char *line, char *makefile);
|
||||
|
||||
static
|
||||
#ifdef SIGNALRETURNSINT
|
||||
@ -113,19 +123,18 @@ int
|
||||
#else
|
||||
void
|
||||
#endif
|
||||
catch (sig)
|
||||
int sig;
|
||||
catch (int sig)
|
||||
{
|
||||
fflush (stdout);
|
||||
fatalerr ("got signal %d\n", sig);
|
||||
}
|
||||
|
||||
#if defined(USG) || (defined(i386) && defined(SYSV)) || defined(WIN32) || defined(XP_OS2)
|
||||
#if defined(USG) || (defined(i386) && defined(SYSV)) || defined(WIN32) || defined(__UNIXOS2__) || defined(Lynx_22) || defined(__CYGWIN__)
|
||||
#define USGISH
|
||||
#endif
|
||||
|
||||
#ifndef USGISH
|
||||
#ifndef _POSIX_SOURCE
|
||||
#ifdef X_NOT_POSIX
|
||||
#define sigaction sigvec
|
||||
#define sa_handler sv_handler
|
||||
#define sa_mask sv_mask
|
||||
@ -134,19 +143,20 @@ catch (sig)
|
||||
struct sigaction sig_act;
|
||||
#endif /* USGISH */
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
register char **fp = filelist;
|
||||
register char **incp = includedirs;
|
||||
register char *p;
|
||||
register struct inclist *ip;
|
||||
char **fp = filelist;
|
||||
char **incp = includedirs;
|
||||
char *p;
|
||||
struct inclist *ip;
|
||||
char *makefile = NULL;
|
||||
struct filepointer *filecontent;
|
||||
struct symtab *psymp = predefs;
|
||||
char *endmarker = NULL;
|
||||
char *defincdir = NULL;
|
||||
char **undeflist = NULL;
|
||||
int numundefs = 0, i;
|
||||
|
||||
ProgramName = argv[0];
|
||||
|
||||
@ -241,6 +251,20 @@ main(argc, argv)
|
||||
argc--;
|
||||
}
|
||||
break;
|
||||
case 'U':
|
||||
/* Undef's override all -D's so save them up */
|
||||
numundefs++;
|
||||
if (numundefs == 1)
|
||||
undeflist = malloc(sizeof(char *));
|
||||
else
|
||||
undeflist = realloc(undeflist,
|
||||
numundefs * sizeof(char *));
|
||||
if (argv[0][2] == '\0') {
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
undeflist[numundefs - 1] = argv[0] + 2;
|
||||
break;
|
||||
case 'Y':
|
||||
defincdir = argv[0]+2;
|
||||
break;
|
||||
@ -314,21 +338,76 @@ main(argc, argv)
|
||||
case 'O':
|
||||
case 'g':
|
||||
break;
|
||||
case 'i':
|
||||
if (strcmp(&argv[0][1],"include") == 0) {
|
||||
char *buf;
|
||||
if (argc<2)
|
||||
fatalerr("option -include is a "
|
||||
"missing its parameter\n");
|
||||
if (cmdinc_count >= MAXINCFILES)
|
||||
fatalerr("Too many -include flags.\n");
|
||||
argc--;
|
||||
argv++;
|
||||
buf = malloc(strlen(DASH_INC_PRE) +
|
||||
strlen(argv[0]) +
|
||||
strlen(DASH_INC_POST) + 1);
|
||||
if(!buf)
|
||||
fatalerr("out of memory at "
|
||||
"-include string\n");
|
||||
cmdinc_list[2 * cmdinc_count + 0] = argv[0];
|
||||
cmdinc_list[2 * cmdinc_count + 1] = buf;
|
||||
cmdinc_count++;
|
||||
break;
|
||||
}
|
||||
/* intentional fall through */
|
||||
default:
|
||||
if (endmarker) break;
|
||||
/* fatalerr("unknown opt = %s\n", argv[0]); */
|
||||
warning("ignoring option %s\n", argv[0]);
|
||||
}
|
||||
}
|
||||
/* Now do the undefs from the command line */
|
||||
for (i = 0; i < numundefs; i++)
|
||||
undefine(undeflist[i], &maininclist);
|
||||
if (numundefs > 0)
|
||||
free(undeflist);
|
||||
|
||||
if (!defincdir) {
|
||||
#ifdef PREINCDIR
|
||||
if (incp >= includedirs + MAXDIRS)
|
||||
fatalerr("Too many -I flags.\n");
|
||||
*incp++ = PREINCDIR;
|
||||
#endif
|
||||
#ifdef __UNIXOS2__
|
||||
{
|
||||
char *emxinc = getenv("C_INCLUDE_PATH");
|
||||
/* can have more than one component */
|
||||
if (emxinc) {
|
||||
char *beg, *end;
|
||||
beg= (char*)strdup(emxinc);
|
||||
for (;;) {
|
||||
end = (char*)strchr(beg,';');
|
||||
if (end) *end = 0;
|
||||
if (incp >= includedirs + MAXDIRS)
|
||||
fatalerr("Too many include dirs\n");
|
||||
*incp++ = beg;
|
||||
if (!end) break;
|
||||
beg = end+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else /* !__UNIXOS2__, does not use INCLUDEDIR at all */
|
||||
if (incp >= includedirs + MAXDIRS)
|
||||
fatalerr("Too many -I flags.\n");
|
||||
*incp++ = INCLUDEDIR;
|
||||
#endif
|
||||
|
||||
#ifdef EXTRAINCDIR
|
||||
if (incp >= includedirs + MAXDIRS)
|
||||
fatalerr("Too many -I flags.\n");
|
||||
*incp++ = EXTRAINCDIR;
|
||||
#endif
|
||||
|
||||
#ifdef POSTINCDIR
|
||||
if (incp >= includedirs + MAXDIRS)
|
||||
fatalerr("Too many -I flags.\n");
|
||||
@ -364,7 +443,7 @@ main(argc, argv)
|
||||
#endif
|
||||
#else
|
||||
sig_act.sa_handler = catch;
|
||||
#ifdef _POSIX_SOURCE
|
||||
#if defined(_POSIX_SOURCE) || !defined(X_NOT_POSIX)
|
||||
sigemptyset(&sig_act.sa_mask);
|
||||
sigaddset(&sig_act.sa_mask, SIGINT);
|
||||
sigaddset(&sig_act.sa_mask, SIGQUIT);
|
||||
@ -411,7 +490,9 @@ main(argc, argv)
|
||||
* now peruse through the list of files.
|
||||
*/
|
||||
for(fp=filelist; *fp; fp++) {
|
||||
DBG_PRINT(stderr,"file: %s\n",*fp);
|
||||
filecontent = getfile(*fp);
|
||||
setfile_cmdinc(filecontent, cmdinc_count, cmdinc_list);
|
||||
ip = newinclude(*fp, (char *)NULL);
|
||||
|
||||
find_includes(filecontent, ip, ip, 0, FALSE);
|
||||
@ -421,17 +502,34 @@ main(argc, argv)
|
||||
}
|
||||
if (printed)
|
||||
printf("\n");
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct filepointer *getfile(file)
|
||||
char *file;
|
||||
#ifdef __UNIXOS2__
|
||||
/*
|
||||
* eliminate \r chars from file
|
||||
*/
|
||||
static int
|
||||
elim_cr(char *buf, int sz)
|
||||
{
|
||||
register int fd;
|
||||
int i,wp;
|
||||
for (i= wp = 0; i<sz; i++) {
|
||||
if (buf[i] != '\r')
|
||||
buf[wp++] = buf[i];
|
||||
}
|
||||
return wp;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct filepointer *
|
||||
getfile(char *file)
|
||||
{
|
||||
int fd;
|
||||
struct filepointer *content;
|
||||
struct stat st;
|
||||
|
||||
content = (struct filepointer *)malloc(sizeof(struct filepointer));
|
||||
content->f_name = file;
|
||||
if ((fd = open(file, O_RDONLY)) < 0) {
|
||||
warning("cannot open \"%s\"\n", file);
|
||||
content->f_p = content->f_base = content->f_end = (char *)malloc(1);
|
||||
@ -444,36 +542,48 @@ struct filepointer *getfile(file)
|
||||
fatalerr("cannot allocate mem\n");
|
||||
if ((st.st_size = read(fd, content->f_base, st.st_size)) < 0)
|
||||
fatalerr("failed to read %s\n", file);
|
||||
#ifdef __UNIXOS2__
|
||||
st.st_size = elim_cr(content->f_base,st.st_size);
|
||||
#endif
|
||||
close(fd);
|
||||
content->f_len = st.st_size+1;
|
||||
content->f_p = content->f_base;
|
||||
content->f_end = content->f_base + st.st_size;
|
||||
*content->f_end = '\0';
|
||||
content->f_line = 0;
|
||||
content->cmdinc_count = 0;
|
||||
content->cmdinc_list = NULL;
|
||||
content->cmdinc_line = 0;
|
||||
return(content);
|
||||
}
|
||||
|
||||
void
|
||||
freefile(fp)
|
||||
struct filepointer *fp;
|
||||
setfile_cmdinc(struct filepointer* filep, long count, char** list)
|
||||
{
|
||||
filep->cmdinc_count = count;
|
||||
filep->cmdinc_list = list;
|
||||
filep->cmdinc_line = 0;
|
||||
}
|
||||
|
||||
void
|
||||
freefile(struct filepointer *fp)
|
||||
{
|
||||
free(fp->f_base);
|
||||
free(fp);
|
||||
}
|
||||
|
||||
char *copy(str)
|
||||
register char *str;
|
||||
char *copy(char *str)
|
||||
{
|
||||
register char *p = (char *)malloc(strlen(str) + 1);
|
||||
char *p = (char *)malloc(strlen(str) + 1);
|
||||
|
||||
strcpy(p, str);
|
||||
return(p);
|
||||
}
|
||||
|
||||
match(str, list)
|
||||
register char *str, **list;
|
||||
int
|
||||
match(char *str, char **list)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
for (i=0; *list; i++, list++)
|
||||
if (strcmp(str, *list) == 0)
|
||||
@ -485,13 +595,26 @@ match(str, list)
|
||||
* Get the next line. We only return lines beginning with '#' since that
|
||||
* is all this program is ever interested in.
|
||||
*/
|
||||
char *getline(filep)
|
||||
register struct filepointer *filep;
|
||||
char *getnextline(struct filepointer *filep)
|
||||
{
|
||||
register char *p, /* walking pointer */
|
||||
*eof, /* end of file pointer */
|
||||
*bol; /* beginning of line pointer */
|
||||
register int lineno; /* line number */
|
||||
char *p, /* walking pointer */
|
||||
*eof, /* end of file pointer */
|
||||
*bol; /* beginning of line pointer */
|
||||
int lineno; /* line number */
|
||||
boolean whitespace = FALSE;
|
||||
|
||||
/*
|
||||
* Fake the "-include" line files in form of #include to the
|
||||
* start of each file.
|
||||
*/
|
||||
if (filep->cmdinc_line < filep->cmdinc_count) {
|
||||
char *inc = filep->cmdinc_list[2 * filep->cmdinc_line + 0];
|
||||
char *buf = filep->cmdinc_list[2 * filep->cmdinc_line + 1];
|
||||
filep->cmdinc_line++;
|
||||
sprintf(buf,"%s%s%s",DASH_INC_PRE,inc,DASH_INC_POST);
|
||||
DBG_PRINT(stderr,"%s\n",buf);
|
||||
return(buf);
|
||||
}
|
||||
|
||||
p = filep->f_p;
|
||||
eof = filep->f_end;
|
||||
@ -499,86 +622,103 @@ char *getline(filep)
|
||||
return((char *)NULL);
|
||||
lineno = filep->f_line;
|
||||
|
||||
for(bol = p--; ++p < eof; ) {
|
||||
if (*p == '/' && *(p+1) == '*') { /* consume comments */
|
||||
*p++ = ' ', *p++ = ' ';
|
||||
while (*p) {
|
||||
if (*p == '*' && *(p+1) == '/') {
|
||||
*p++ = ' ', *p = ' ';
|
||||
for (bol = p--; ++p < eof; ) {
|
||||
if ((bol == p) && ((*p == ' ') || (*p == '\t')))
|
||||
{
|
||||
/* Consume leading white-spaces for this line */
|
||||
while (((p+1) < eof) && ((*p == ' ') || (*p == '\t')))
|
||||
{
|
||||
p++;
|
||||
bol++;
|
||||
}
|
||||
whitespace = TRUE;
|
||||
}
|
||||
|
||||
if (*p == '/' && (p+1) < eof && *(p+1) == '*') {
|
||||
/* Consume C comments */
|
||||
*(p++) = ' ';
|
||||
*(p++) = ' ';
|
||||
while (p < eof && *p) {
|
||||
if (*p == '*' && (p+1) < eof && *(p+1) == '/') {
|
||||
*(p++) = ' ';
|
||||
*(p++) = ' ';
|
||||
break;
|
||||
}
|
||||
if (*p == '\n')
|
||||
lineno++;
|
||||
*(p++) = ' ';
|
||||
}
|
||||
--p;
|
||||
}
|
||||
else if (*p == '/' && (p+1) < eof && *(p+1) == '/') {
|
||||
/* Consume C++ comments */
|
||||
*(p++) = ' ';
|
||||
*(p++) = ' ';
|
||||
while (p < eof && *p) {
|
||||
if (*p == '\\' && (p+1) < eof &&
|
||||
*(p+1) == '\n') {
|
||||
*(p++) = ' ';
|
||||
lineno++;
|
||||
}
|
||||
else if (*p == '?' && (p+3) < eof &&
|
||||
*(p+1) == '?' &&
|
||||
*(p+2) == '/' &&
|
||||
*(p+3) == '\n') {
|
||||
*(p++) = ' ';
|
||||
*(p++) = ' ';
|
||||
*(p++) = ' ';
|
||||
lineno++;
|
||||
}
|
||||
else if (*p == '\n')
|
||||
lineno++;
|
||||
*p++ = ' ';
|
||||
break; /* to process end of line */
|
||||
*(p++) = ' ';
|
||||
}
|
||||
continue;
|
||||
--p;
|
||||
}
|
||||
else if (*p == '/' && *(p+1) == '/') { /* consume comments */
|
||||
*p++ = ' ', *p++ = ' ';
|
||||
|
||||
while (*p)
|
||||
{
|
||||
/* Comment continues on next line. */
|
||||
if (*p == '\\' && *(p+1) == '\n')
|
||||
{
|
||||
*(p++) = ' ';
|
||||
*(p++) = ' ';
|
||||
lineno++;
|
||||
}
|
||||
else
|
||||
if (*p == '\n')
|
||||
{
|
||||
/*
|
||||
* Decrement so that the next iteration
|
||||
* of the outter "for loop" will handle
|
||||
* the case of "*p == '\n'".
|
||||
*/
|
||||
--p;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p++ = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
#if defined(WIN32) || defined(XP_OS2)
|
||||
else if (*p == '/' && *(p+1) == '/') { /* consume comments */
|
||||
*p++ = ' ', *p++ = ' ';
|
||||
while (*p && *p != '\n')
|
||||
*p++ = ' ';
|
||||
else if (*p == '\\' && (p+1) < eof && *(p+1) == '\n') {
|
||||
/* Consume backslash line terminations */
|
||||
*(p++) = ' ';
|
||||
*p = ' ';
|
||||
lineno++;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
else if (*p == '\\') {
|
||||
if (*(p+1) == '\n') {
|
||||
*p = ' ';
|
||||
*(p+1) = ' ';
|
||||
lineno++;
|
||||
}
|
||||
else if (*p == '?' && (p+3) < eof &&
|
||||
*(p+1) == '?' && *(p+2) == '/' && *(p+3) == '\n') {
|
||||
/* Consume trigraph'ed backslash line terminations */
|
||||
*(p++) = ' ';
|
||||
*(p++) = ' ';
|
||||
*(p++) = ' ';
|
||||
*p = ' ';
|
||||
lineno++;
|
||||
}
|
||||
else if (*p == '\n') {
|
||||
lineno++;
|
||||
if (*bol == '#') {
|
||||
register char *cp;
|
||||
char *cp;
|
||||
|
||||
*p++ = '\0';
|
||||
*(p++) = '\0';
|
||||
/* punt lines with just # (yacc generated) */
|
||||
for (cp = bol+1;
|
||||
*cp && (*cp == ' ' || *cp == '\t'); cp++);
|
||||
if (*cp) goto done;
|
||||
--p;
|
||||
}
|
||||
bol = p+1;
|
||||
whitespace = FALSE;
|
||||
}
|
||||
}
|
||||
if (*bol != '#')
|
||||
bol = NULL;
|
||||
done:
|
||||
if (bol && whitespace) {
|
||||
warning("%s: non-portable whitespace encountered at line %d\n",
|
||||
filep->f_name, lineno);
|
||||
}
|
||||
filep->f_p = p;
|
||||
filep->f_line = lineno;
|
||||
#ifdef DEBUG_DUMP
|
||||
if (bol)
|
||||
DBG_PRINT(stderr,"%s\n",bol);
|
||||
#endif
|
||||
return(bol);
|
||||
}
|
||||
|
||||
@ -586,10 +726,9 @@ done:
|
||||
* Strip the file name down to what we want to see in the Makefile.
|
||||
* It will have objprefix and objsuffix around it.
|
||||
*/
|
||||
char *base_name(file)
|
||||
register char *file;
|
||||
char *base_name(char *file)
|
||||
{
|
||||
register char *p;
|
||||
char *p;
|
||||
|
||||
file = copy(file);
|
||||
for(p=file+strlen(file); p>file && *p != '.'; p--) ;
|
||||
@ -599,9 +738,8 @@ char *base_name(file)
|
||||
return(file);
|
||||
}
|
||||
|
||||
#if defined(USG) && !defined(CRAY) && !defined(SVR4)
|
||||
int rename (from, to)
|
||||
char *from, *to;
|
||||
#if defined(USG) && !defined(CRAY) && !defined(SVR4) && !defined(__UNIXOS2__) && !defined(clipper) && !defined(__clipper__)
|
||||
int rename (char *from, char *to)
|
||||
{
|
||||
(void) unlink (to);
|
||||
if (link (from, to) == 0) {
|
||||
@ -614,9 +752,7 @@ int rename (from, to)
|
||||
#endif /* USGISH */
|
||||
|
||||
void
|
||||
redirect(line, makefile)
|
||||
char *line,
|
||||
*makefile;
|
||||
redirect(char *line, char *makefile)
|
||||
{
|
||||
struct stat st;
|
||||
FILE *fdin, *fdout;
|
||||
@ -650,12 +786,12 @@ redirect(line, makefile)
|
||||
fatalerr("cannot open \"%s\"\n", makefile);
|
||||
sprintf(backup, "%s.bak", makefile);
|
||||
unlink(backup);
|
||||
#if defined(WIN32) || defined(XP_OS2)
|
||||
#if defined(WIN32) || defined(__UNIXOS2__) || defined(__CYGWIN__)
|
||||
fclose(fdin);
|
||||
#endif
|
||||
if (rename(makefile, backup) < 0)
|
||||
fatalerr("cannot rename %s to %s\n", makefile, backup);
|
||||
#if defined(WIN32) || defined(XP_OS2)
|
||||
#if defined(WIN32) || defined(__UNIXOS2__) || defined(__CYGWIN__)
|
||||
if ((fdin = fopen(backup, "r")) == NULL)
|
||||
fatalerr("cannot open \"%s\"\n", backup);
|
||||
#endif
|
||||
@ -678,7 +814,7 @@ redirect(line, makefile)
|
||||
}
|
||||
}
|
||||
fflush(fdout);
|
||||
#if defined(USGISH) || defined(_SEQUENT_)
|
||||
#if defined(USGISH) || defined(_SEQUENT_) || defined(USE_CHMOD)
|
||||
chmod(makefile, st.st_mode);
|
||||
#else
|
||||
fchmod(fileno(fdout), st.st_mode);
|
||||
@ -686,65 +822,31 @@ redirect(line, makefile)
|
||||
}
|
||||
|
||||
void
|
||||
#if NeedVarargsPrototypes
|
||||
fatalerr(char *msg, ...)
|
||||
#else
|
||||
/*VARARGS*/
|
||||
fatalerr(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
|
||||
char *msg;
|
||||
#endif
|
||||
{
|
||||
#if NeedVarargsPrototypes
|
||||
va_list args;
|
||||
#endif
|
||||
fprintf(stderr, "%s: error: ", ProgramName);
|
||||
#if NeedVarargsPrototypes
|
||||
va_start(args, msg);
|
||||
vfprintf(stderr, msg, args);
|
||||
va_end(args);
|
||||
#else
|
||||
fprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);
|
||||
#endif
|
||||
exit (1);
|
||||
}
|
||||
|
||||
void
|
||||
#if NeedVarargsPrototypes
|
||||
warning(char *msg, ...)
|
||||
#else
|
||||
/*VARARGS0*/
|
||||
warning(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
|
||||
char *msg;
|
||||
#endif
|
||||
{
|
||||
#if NeedVarargsPrototypes
|
||||
va_list args;
|
||||
#endif
|
||||
fprintf(stderr, "%s: warning: ", ProgramName);
|
||||
#if NeedVarargsPrototypes
|
||||
va_start(args, msg);
|
||||
vfprintf(stderr, msg, args);
|
||||
va_end(args);
|
||||
#else
|
||||
fprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
#if NeedVarargsPrototypes
|
||||
warning1(char *msg, ...)
|
||||
#else
|
||||
/*VARARGS0*/
|
||||
warning1(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)
|
||||
char *msg;
|
||||
#endif
|
||||
{
|
||||
#if NeedVarargsPrototypes
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
vfprintf(stderr, msg, args);
|
||||
va_end(args);
|
||||
#else
|
||||
fprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -22,7 +22,10 @@
|
||||
.\" be used in advertising or otherwise to promote the sale, use or other
|
||||
.\" dealing in this Software without prior written authorization from The
|
||||
.\" Open Group.
|
||||
.TH MAKEDEPEND 1 "Release 6.4" "X Version 11"
|
||||
.\"
|
||||
.\" $XFree86: xc/config/makedepend/mkdepend.man,v 1.7 2002/12/14 02:39:45 dawes Exp $
|
||||
.\"
|
||||
.TH MAKEDEPEND 1 __xorgversion__
|
||||
.UC 4
|
||||
.SH NAME
|
||||
makedepend \- create dependencies in makefiles
|
||||
@ -41,6 +44,8 @@ makedepend \- create dependencies in makefiles
|
||||
] [
|
||||
.BI \-f makefile
|
||||
] [
|
||||
.BI \-include \ file
|
||||
] [
|
||||
.BI \-o objsuffix
|
||||
] [
|
||||
.BI \-p objprefix
|
||||
@ -111,7 +116,7 @@ option.
|
||||
It first searches the makefile for
|
||||
the line
|
||||
.sp
|
||||
# DO NOT DELETE THIS LINE \-\^\- make depend depends on it.
|
||||
\& # DO NOT DELETE THIS LINE \-\^\- make depend depends on it.
|
||||
.sp
|
||||
or one provided with the
|
||||
.B \-s
|
||||
@ -199,6 +204,12 @@ can place its output.
|
||||
Specifying ``\-'' as the file name (i.e., \fB\-f\-\fP) sends the
|
||||
output to standard output instead of modifying an existing file.
|
||||
.TP 5
|
||||
.B \-include \fIfile\fP
|
||||
Process file as input, and include all the resulting output
|
||||
before processing the regular input file. This has the same
|
||||
affect as if the specified file is an include statement that
|
||||
appears before the very first line of the regular input file.
|
||||
.TP 5
|
||||
.B \-o\fIobjsuffix\fP
|
||||
Object file suffix.
|
||||
Some systems may have object files whose suffix is something other
|
||||
@ -342,9 +353,8 @@ to the list of dependencies for
|
||||
cc(1), make(1)
|
||||
.SH BUGS
|
||||
.B makedepend
|
||||
parses, but does not currently evaluate, the SVR4
|
||||
#predicate(token-list) preprocessor expression;
|
||||
such expressions are simply assumed to be true.
|
||||
parses, but does not currently evaluate, the SVR4 #predicate(token-list)
|
||||
preprocessor expression; such expressions are simply assumed to be true.
|
||||
This may cause the wrong
|
||||
.I #include
|
||||
directives to be evaluated.
|
||||
|
||||
@ -24,21 +24,32 @@ used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
/* $XFree86: xc/config/makedepend/parse.c,v 1.12 2002/02/26 05:09:10 tsi Exp $ */
|
||||
|
||||
#include "def.h"
|
||||
|
||||
extern char *directives[];
|
||||
extern struct inclist maininclist;
|
||||
extern struct inclist inclist[ MAXFILES ],
|
||||
*inclistnext,
|
||||
maininclist;
|
||||
extern char *includedirs[ ],
|
||||
**includedirsnext;
|
||||
|
||||
int
|
||||
gobble(filep, file, file_red)
|
||||
register struct filepointer *filep;
|
||||
struct inclist *file, *file_red;
|
||||
static int deftype (char *line, struct filepointer *filep,
|
||||
struct inclist *file_red, struct inclist *file,
|
||||
int parse_it);
|
||||
static int zero_value(char *filename, char *exp, struct filepointer *filep,
|
||||
struct inclist *file_red);
|
||||
static int merge2defines(struct inclist *file1, struct inclist *file2);
|
||||
|
||||
static int
|
||||
gobble(struct filepointer *filep, struct inclist *file,
|
||||
struct inclist *file_red)
|
||||
{
|
||||
register char *line;
|
||||
register int type;
|
||||
char *line;
|
||||
int type;
|
||||
|
||||
while ((line = getline(filep))) {
|
||||
while ((line = getnextline(filep))) {
|
||||
switch(type = deftype(line, filep, file_red, file, FALSE)) {
|
||||
case IF:
|
||||
case IFFALSE:
|
||||
@ -68,6 +79,8 @@ gobble(filep, file, file_red)
|
||||
case SCCS:
|
||||
case EJECT:
|
||||
case WARNING:
|
||||
case INCLUDENEXT:
|
||||
case INCLUDENEXTDOT:
|
||||
break;
|
||||
case ELIF:
|
||||
case ELIFFALSE:
|
||||
@ -88,14 +101,12 @@ gobble(filep, file, file_red)
|
||||
/*
|
||||
* Decide what type of # directive this line is.
|
||||
*/
|
||||
int deftype (line, filep, file_red, file, parse_it)
|
||||
register char *line;
|
||||
register struct filepointer *filep;
|
||||
register struct inclist *file_red, *file;
|
||||
int parse_it;
|
||||
static int
|
||||
deftype (char *line, struct filepointer *filep,
|
||||
struct inclist *file_red, struct inclist *file, int parse_it)
|
||||
{
|
||||
register char *p;
|
||||
char *directive, savechar;
|
||||
char *directive, savechar, *q;
|
||||
register int ret;
|
||||
|
||||
/*
|
||||
@ -106,7 +117,7 @@ int deftype (line, filep, file_red, file, parse_it)
|
||||
directive++;
|
||||
|
||||
p = directive;
|
||||
while (*p >= 'a' && *p <= 'z')
|
||||
while ((*p == '_') || (*p >= 'a' && *p <= 'z'))
|
||||
p++;
|
||||
savechar = *p;
|
||||
*p = '\0';
|
||||
@ -152,6 +163,11 @@ int deftype (line, filep, file_red, file, parse_it)
|
||||
*/
|
||||
while (*p == ' ' || *p == '\t')
|
||||
p++;
|
||||
q = p + strlen(p);
|
||||
do {
|
||||
q--;
|
||||
} while (*q == ' ' || *q == '\t');
|
||||
q[1] = '\0';
|
||||
switch (ret) {
|
||||
case IF:
|
||||
/*
|
||||
@ -174,13 +190,22 @@ int deftype (line, filep, file_red, file, parse_it)
|
||||
*line = '\0';
|
||||
break;
|
||||
case INCLUDE:
|
||||
debug(2,("%s, line %d: #include %s\n",
|
||||
file->i_file, filep->f_line, p));
|
||||
case INCLUDENEXT:
|
||||
debug(2,("%s, line %d: #include%s %s\n",
|
||||
file->i_file, filep->f_line,
|
||||
(ret == INCLUDE) ? "" : "_next", p));
|
||||
|
||||
/* Support ANSI macro substitution */
|
||||
{
|
||||
struct symtab **sym = isdefined(p, file_red, NULL);
|
||||
while (sym) {
|
||||
while (1) {
|
||||
struct symtab **sym;
|
||||
|
||||
if (!*p || *p == '"' || *p == '<')
|
||||
break;
|
||||
|
||||
sym = isdefined(p, file_red, NULL);
|
||||
if (!sym)
|
||||
break;
|
||||
|
||||
p = (*sym)->s_value;
|
||||
debug(3,("%s : #includes SYMBOL %s = %s\n",
|
||||
file->i_incstring,
|
||||
@ -188,8 +213,6 @@ int deftype (line, filep, file_red, file, parse_it)
|
||||
(*sym) -> s_value));
|
||||
/* mark file as having included a 'soft include' */
|
||||
file->i_flags |= INCLUDED_SYM;
|
||||
sym = isdefined(p, file_red, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -200,7 +223,10 @@ int deftype (line, filep, file_red, file, parse_it)
|
||||
if (! *p)
|
||||
return(-2);
|
||||
if (*p++ == '"') {
|
||||
ret = INCLUDEDOT;
|
||||
if (ret == INCLUDE)
|
||||
ret = INCLUDEDOT;
|
||||
else
|
||||
ret = INCLUDENEXTDOT;
|
||||
while (*p && *p != '"')
|
||||
*line++ = *p++;
|
||||
} else
|
||||
@ -222,6 +248,7 @@ int deftype (line, filep, file_red, file, parse_it)
|
||||
case IDENT:
|
||||
case SCCS:
|
||||
case EJECT:
|
||||
case WARNING:
|
||||
debug(0,("%s, line %d: #%s\n",
|
||||
file->i_file, filep->f_line, directives[ret]));
|
||||
/*
|
||||
@ -232,34 +259,30 @@ int deftype (line, filep, file_red, file, parse_it)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
struct symtab **fdefined(symbol, file, srcfile)
|
||||
register char *symbol;
|
||||
struct inclist *file;
|
||||
struct inclist **srcfile;
|
||||
struct symtab **
|
||||
fdefined(char *symbol, struct inclist *file, struct inclist **srcfile)
|
||||
{
|
||||
register struct inclist **ip;
|
||||
register struct symtab **val;
|
||||
register int i;
|
||||
struct inclist **ip;
|
||||
struct symtab **val;
|
||||
int i;
|
||||
static int recurse_lvl = 0;
|
||||
|
||||
if (file->i_flags & DEFCHECKED)
|
||||
return(NULL);
|
||||
debug(2,("Looking for %s in %s\n", symbol, file->i_file));
|
||||
file->i_flags |= DEFCHECKED;
|
||||
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)
|
||||
{
|
||||
{
|
||||
for (ip = file->i_list, i=0; i < file->i_listlen; i++, ip++)
|
||||
if (file->i_merged[i]==FALSE) {
|
||||
val = fdefined(symbol, *ip, srcfile);
|
||||
if ((*ip)->i_flags & FINISHED) {
|
||||
merge2defines(file,*ip);
|
||||
file->i_merged[i]=TRUE;
|
||||
}
|
||||
file->i_merged[i]=merge2defines(file,*ip);
|
||||
if (val!=NULL) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (val != NULL && srcfile != NULL) *srcfile = file;
|
||||
recurse_lvl--;
|
||||
file->i_flags &= ~DEFCHECKED;
|
||||
@ -267,12 +290,10 @@ struct symtab **fdefined(symbol, file, srcfile)
|
||||
return(val);
|
||||
}
|
||||
|
||||
struct symtab **isdefined(symbol, file, srcfile)
|
||||
register char *symbol;
|
||||
struct inclist *file;
|
||||
struct inclist **srcfile;
|
||||
struct symtab **
|
||||
isdefined(char *symbol, struct inclist *file, struct inclist **srcfile)
|
||||
{
|
||||
register struct symtab **val;
|
||||
struct symtab **val;
|
||||
|
||||
if ((val = slookup(symbol, &maininclist))) {
|
||||
debug(1,("%s defined on command line\n", symbol));
|
||||
@ -288,12 +309,11 @@ struct symtab **isdefined(symbol, file, srcfile)
|
||||
/*
|
||||
* Return type based on if the #if expression evaluates to 0
|
||||
*/
|
||||
int
|
||||
zero_value(filename, exp, filep, file_red)
|
||||
register char *filename;
|
||||
register char *exp;
|
||||
register struct filepointer *filep;
|
||||
register struct inclist *file_red;
|
||||
static int
|
||||
zero_value(char *filename,
|
||||
char *exp,
|
||||
struct filepointer *filep,
|
||||
struct inclist *file_red)
|
||||
{
|
||||
if (cppsetup(filename, exp, filep, file_red))
|
||||
return(IFFALSE);
|
||||
@ -302,9 +322,7 @@ zero_value(filename, exp, filep, file_red)
|
||||
}
|
||||
|
||||
void
|
||||
define2(name, val, file)
|
||||
char *name, *val;
|
||||
struct inclist *file;
|
||||
define2(char *name, char *val, struct inclist *file)
|
||||
{
|
||||
int first, last, below;
|
||||
register struct symtab **sp = NULL, **dest;
|
||||
@ -364,6 +382,8 @@ define2(name, val, file)
|
||||
just replace its s_value */
|
||||
if (sp != NULL)
|
||||
{
|
||||
debug(1,("redefining %s from %s to %s in file %s\n",
|
||||
name, (*sp)->s_value, val, file->i_file));
|
||||
free((*sp)->s_value);
|
||||
(*sp)->s_value = copy(val);
|
||||
return;
|
||||
@ -380,15 +400,14 @@ define2(name, val, file)
|
||||
if (stab == NULL)
|
||||
fatalerr("malloc()/realloc() failure in insert_defn()\n");
|
||||
|
||||
debug(1,("defining %s to %s in file %s\n", name, val, file->i_file));
|
||||
stab->s_name = copy(name);
|
||||
stab->s_value = copy(val);
|
||||
*sp = stab;
|
||||
}
|
||||
|
||||
void
|
||||
define(def, file)
|
||||
char *def;
|
||||
struct inclist *file;
|
||||
define(char *def, struct inclist *file)
|
||||
{
|
||||
char *val;
|
||||
|
||||
@ -406,9 +425,8 @@ define(def, file)
|
||||
define2(def, val, file);
|
||||
}
|
||||
|
||||
struct symtab **slookup(symbol, file)
|
||||
register char *symbol;
|
||||
register struct inclist *file;
|
||||
struct symtab **
|
||||
slookup(char *symbol, struct inclist *file)
|
||||
{
|
||||
register int first = 0;
|
||||
register int last = file->i_ndefs - 1;
|
||||
@ -446,12 +464,20 @@ struct symtab **slookup(symbol, file)
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
int merge2defines(file1, file2)
|
||||
struct inclist *file1;
|
||||
struct inclist *file2;
|
||||
static int
|
||||
merge2defines(struct inclist *file1, struct inclist *file2)
|
||||
{
|
||||
if ((file1!=NULL) && (file2!=NULL))
|
||||
{
|
||||
int i;
|
||||
|
||||
if ((file1==NULL) || (file2==NULL) ||
|
||||
!(file2->i_flags & FINISHED))
|
||||
return 0;
|
||||
|
||||
for (i=0; i < file2->i_listlen; i++)
|
||||
if (file2->i_merged[i]==FALSE)
|
||||
return 0;
|
||||
|
||||
{
|
||||
int first1 = 0;
|
||||
int last1 = file1->i_ndefs - 1;
|
||||
|
||||
@ -462,6 +488,9 @@ int merge2defines(file1, file2)
|
||||
struct symtab** i_defs = NULL;
|
||||
int deflen=file1->i_ndefs+file2->i_ndefs;
|
||||
|
||||
debug(2,("merging %s into %s\n",
|
||||
file2->i_file, file1->i_file));
|
||||
|
||||
if (deflen>0)
|
||||
{
|
||||
/* make sure deflen % SYMTABINC == 0 is still true */
|
||||
@ -501,13 +530,10 @@ int merge2defines(file1, file2)
|
||||
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
undefine(symbol, file)
|
||||
char *symbol;
|
||||
register struct inclist *file;
|
||||
undefine(char *symbol, struct inclist *file)
|
||||
{
|
||||
register struct symtab **ptr;
|
||||
struct inclist *srcfile;
|
||||
@ -520,17 +546,16 @@ undefine(symbol, file)
|
||||
}
|
||||
|
||||
int
|
||||
find_includes(filep, file, file_red, recursion, failOK)
|
||||
struct filepointer *filep;
|
||||
struct inclist *file, *file_red;
|
||||
int recursion;
|
||||
boolean failOK;
|
||||
find_includes(struct filepointer *filep, struct inclist *file,
|
||||
struct inclist *file_red, int recursion, boolean failOK)
|
||||
{
|
||||
struct inclist *inclistp;
|
||||
char **includedirsp;
|
||||
register char *line;
|
||||
register int type;
|
||||
boolean recfailOK;
|
||||
|
||||
while ((line = getline(filep))) {
|
||||
while ((line = getnextline(filep))) {
|
||||
switch(type = deftype(line, filep, file_red, file, TRUE)) {
|
||||
case IF:
|
||||
doif:
|
||||
@ -614,12 +639,19 @@ find_includes(filep, file, file_red, recursion, failOK)
|
||||
undefine(line, file_red);
|
||||
break;
|
||||
case INCLUDE:
|
||||
add_include(filep, file, file_red, line, FALSE, failOK);
|
||||
break;
|
||||
case INCLUDEDOT:
|
||||
add_include(filep, file, file_red, line, TRUE, failOK);
|
||||
case INCLUDENEXT:
|
||||
case INCLUDENEXTDOT:
|
||||
inclistp = inclistnext;
|
||||
includedirsp = includedirsnext;
|
||||
debug(2,("%s, reading %s, includes %s\n",
|
||||
file_red->i_file, file->i_file, line));
|
||||
add_include(filep, file, file_red, line, type, failOK);
|
||||
inclistnext = inclistp;
|
||||
includedirsnext = includedirsp;
|
||||
break;
|
||||
case ERROR:
|
||||
case WARNING:
|
||||
warning("%s", file_red->i_file);
|
||||
if (file_red != file)
|
||||
warning1(" (reading %s)", file->i_file);
|
||||
@ -649,5 +681,6 @@ find_includes(filep, file, file_red, recursion, failOK)
|
||||
}
|
||||
}
|
||||
file->i_flags |= FINISHED;
|
||||
debug(2,("finished with %s\n", file->i_file));
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
*/
|
||||
/* $XFree86: xc/config/makedepend/pr.c,v 1.5 2001/12/14 19:53:21 dawes Exp $ */
|
||||
|
||||
#include "def.h"
|
||||
|
||||
@ -37,11 +38,9 @@ extern boolean verbose;
|
||||
extern boolean show_where_not;
|
||||
|
||||
void
|
||||
add_include(filep, file, file_red, include, dot, failOK)
|
||||
struct filepointer *filep;
|
||||
struct inclist *file, *file_red;
|
||||
char *include;
|
||||
boolean dot;
|
||||
add_include(struct filepointer *filep, struct inclist *file,
|
||||
struct inclist *file_red, char *include, int type,
|
||||
boolean failOK)
|
||||
{
|
||||
register struct inclist *newfile;
|
||||
register struct filepointer *content;
|
||||
@ -49,7 +48,7 @@ add_include(filep, file, file_red, include, dot, failOK)
|
||||
/*
|
||||
* First decide what the pathname of this include file really is.
|
||||
*/
|
||||
newfile = inc_path(file->i_file, include, dot);
|
||||
newfile = inc_path(file->i_file, include, type);
|
||||
if (newfile == NULL) {
|
||||
if (failOK)
|
||||
return;
|
||||
@ -60,7 +59,7 @@ add_include(filep, file, file_red, include, dot, failOK)
|
||||
warning("%s, line %d: ", file->i_file, filep->f_line);
|
||||
warning1("cannot find include file \"%s\"\n", include);
|
||||
show_where_not = TRUE;
|
||||
newfile = inc_path(file->i_file, include, dot);
|
||||
newfile = inc_path(file->i_file, include, type);
|
||||
show_where_not = FALSE;
|
||||
}
|
||||
|
||||
@ -75,10 +74,8 @@ add_include(filep, file, file_red, include, dot, failOK)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pr(ip, file, base)
|
||||
register struct inclist *ip;
|
||||
char *file, *base;
|
||||
static void
|
||||
pr(struct inclist *ip, char *file, char *base)
|
||||
{
|
||||
static char *lastfile;
|
||||
static int current_len;
|
||||
@ -113,11 +110,9 @@ pr(ip, file, base)
|
||||
}
|
||||
|
||||
void
|
||||
recursive_pr_include(head, file, base)
|
||||
register struct inclist *head;
|
||||
register char *file, *base;
|
||||
recursive_pr_include(struct inclist *head, char *file, char *base)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
if (head->i_flags & MARKED)
|
||||
return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user