summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgbert Eich <eich@suse.de>2004-04-23 18:42:00 +0000
committerEgbert Eich <eich@suse.de>2004-04-23 18:42:00 +0000
commit25324cd43b4735cafa7b6900ad23356f44077bc6 (patch)
tree50d68cbb204a0b6fcdaa67396555ffaab8c9c917
parent97527faa1b2b9f66be7171454161f273b986ee46 (diff)
downloadxorg-util-makedepend-25324cd43b4735cafa7b6900ad23356f44077bc6.tar.gz
Merging XORG-CURRENT into trunkXACE-SELINUX-MERGE
-rw-r--r--cppsetup.c225
-rw-r--r--def.h89
-rw-r--r--ifparser.c144
-rw-r--r--ifparser.h49
-rw-r--r--imakemdep.h16
-rw-r--r--include.c2
-rw-r--r--main.c24
-rw-r--r--makedepend.man2
-rw-r--r--parse.c231
-rw-r--r--pr.c2
10 files changed, 240 insertions, 544 deletions
diff --git a/cppsetup.c b/cppsetup.c
index 3c0ddf2..c7ac256 100644
--- a/cppsetup.c
+++ b/cppsetup.c
@@ -24,7 +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.12 2004/03/05 16:02:58 tsi Exp $ */
+/* $XFree86: xc/config/makedepend/cppsetup.c,v 3.10 2001/12/14 19:53:20 dawes Exp $ */
#include "def.h"
@@ -86,8 +86,8 @@ cppsetup(char *line, struct filepointer *filep, struct inclist *inc)
pend = p;
ptrtab = slotab+COFF;
- *--inp = SALT;
- outp=inp;
+ *--inp = SALT;
+ outp=inp;
value = yyparse();
*p = savec;
return(value);
@@ -181,231 +181,26 @@ my_eval_defined (IfParser *ip, const char *var, int len)
return 0;
}
-
-int
-variable_has_args (IfParser *ip, const char *var, int len)
-{
- struct symtab **s = lookup_variable (ip, var, len);
-
- if (!s)
- return 0;
-
- if ((*s)->s_args)
- return 1;
- else
- return 0;
-}
-
-/*
- * this is tiny linked list implementation for temporarily storing
- * and retriving pairs of macro parameter names and passed in macro arguments.
- */
-typedef struct keyword_type_rec keyword_type;
-struct keyword_type_rec {
- keyword_type* pnext;
- char *name;
- char *value;
-};
-
-
-static keyword_type*
-build_keyword_list (const char* keys, const char* values)
-{
- keyword_type *phead = NULL, *pnew;
- const char *ptmp;
- int len;
-
- while (*keys)
- {
- /* alloc new member */
- pnew = malloc(sizeof(*pnew));
- if (!pnew)
- {
- fprintf(stderr, "out of memory in my_eval_variable\n");
- exit(1);
- }
-
- /* extract key */
- ptmp = keys;
- len = 0;
- while (*ptmp && (*ptmp != ','))
- ptmp++, len++;
- pnew->name = malloc(len+1);
- strncpy(pnew->name, keys, len);
- pnew->name[len] = '\0';
- keys = ptmp;
- if (*keys)
- keys++;
-
- /* extract arg */
- ptmp = values;
- len = 0;
- while (*ptmp && (*ptmp != ',') && (*ptmp != ')'))
- ptmp++, len++;
- pnew->value = malloc(len+1);
- strncpy(pnew->value, values, len);
- pnew->value[len] = '\0';
- values = ptmp;
- if (*values)
- values++;
-
- /* chain in this new member */
- pnew->pnext = phead;
- phead = pnew;
- }
-
- return phead;
-}
-
-
-static const keyword_type*
-get_keyword_entry (const keyword_type* phead, const char* keyname, const int keylen)
-{
- while (phead)
- {
- if (keylen == strlen(phead->name))
- if (strncmp(keyname, phead->name, keylen) == 0)
- return phead;
- phead = phead->pnext;
- }
-
- return phead;
-}
-
-
-static void
-free_keyword_list (keyword_type* phead)
-{
- keyword_type* pnext;
- while (phead)
- {
- pnext = phead->pnext;
- free(phead->name);
- free(phead->value);
- free(phead);
- phead = pnext;
- }
-}
-
-
#define isvarfirstletter(ccc) (isalpha(ccc) || (ccc) == '_')
static long
-my_eval_variable (IfParser *ip, const char *var, int len, const char *args)
+my_eval_variable (IfParser *ip, const char *var, int len)
{
long val;
- char *newline = NULL;
- int newline_len = 0, newline_offset = 0;
struct symtab **s;
s = lookup_variable (ip, var, len);
if (!s)
return 0;
-
- if ((*s)->s_args)
- {
- const char *psrc, *psrc_qualifier;
- char *pdst;
- const keyword_type *pkeyword;
- keyword_type *pkeylist;
-
- newline_len = 64; /* start with some buffer, might increase later */
- newline = malloc(newline_len);
- if (!newline)
- {
- fprintf(stderr, "out of memory in my_eval_variable\n");
- exit(1);
- }
-
- /* build up a list that pairs keywords and args */
- pkeylist = build_keyword_list((*s)->s_args,args);
-
- /* parse for keywords in macro content */
- psrc = (*s)->s_value;
- pdst = newline;
- while (*psrc)
- {
- /* parse for next qualifier */
- psrc_qualifier = psrc;
- while (isalnum(*psrc) || *psrc == '_')
- psrc++;
-
- /* check if qualifier is in parameter keywords listing of macro */
- pkeyword = get_keyword_entry(pkeylist,psrc_qualifier,psrc - psrc_qualifier);
- if (pkeyword)
- { /* convert from parameter keyword to given argument */
- const char *ptmp = pkeyword->value;
- while (*ptmp)
- {
- *pdst++ = *ptmp++;
- newline_offset++;
- if (newline_offset + 2 >= newline_len)
- {
- newline_len *= 2;
- newline = realloc(newline, newline_len);
- if (!newline)
- {
- fprintf(stderr, "out of memory in my_eval_variable\n");
- exit(1);
- }
- pdst = &newline[newline_offset];
- }
- }
- }
- else
- { /* perform post copy of qualifier that is not a parameter keyword */
- const char *ptmp = psrc_qualifier;
- while (ptmp < psrc)
- {
- *pdst++ = *ptmp++;
- newline_offset++;
- if (newline_offset + 2 >= newline_len)
- {
- newline_len *= 2;
- newline = realloc(newline, newline_len);
- if (!newline)
- {
- fprintf(stderr, "out of memory in my_eval_variable\n");
- exit(1);
- }
- pdst = &newline[newline_offset];
- }
- }
- }
-
- /* duplicate chars that are not qualifier chars */
- while (!(isalnum(*psrc) || *psrc == '_' || *psrc == '\0'))
- {
- *pdst++ = *psrc++;
- newline_offset++;
- if (newline_offset + 2 >= newline_len)
- {
- newline_len *= 2;
- newline = realloc(newline, newline_len);
- if (!newline)
- {
- fprintf(stderr, "out of memory in my_eval_variable\n");
- exit(1);
- }
- pdst = &newline[newline_offset];
- }
- }
- }
-
- *pdst = '\0';
- free_keyword_list(pkeylist);
- var = newline;
- }
- else
- {
- var = (*s)->s_value;
- }
+ do {
+ var = (*s)->s_value;
+ if (!isvarfirstletter(*var) || !strcmp((*s)->s_name, var))
+ break;
+ s = lookup_variable (ip, var, strlen(var));
+ } while (s);
var = ParseIfExpression(ip, var, &val);
if (var && *var) debug(4, ("extraneous: '%s'\n", var));
-
- if (newline) free(newline);
-
return val;
}
diff --git a/def.h b/def.h
index a105bfe..7a1be77 100644
--- a/def.h
+++ b/def.h
@@ -24,7 +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/def.h,v 3.15 2004/03/05 16:02:58 tsi Exp $ */
+/* $XFree86: xc/config/makedepend/def.h,v 3.13tsi Exp $ */
#include "Xos.h"
#include "Xfuncproto.h"
@@ -48,39 +48,39 @@ in this Software without prior written authorization from The Open Group.
#define MAXINCFILES 128 /* "-include" files */
#define MAXDIRS 64
#define SYMTABINC 10 /* must be > 1 for define() to work right */
-#define TRUE 1
-#define FALSE 0
+#define TRUE 1
+#define FALSE 0
/* the following must match the directives table in main.c */
-#define IF 0
-#define IFDEF 1
-#define IFNDEF 2
-#define ELSE 3
-#define ENDIF 4
-#define DEFINE 5
-#define UNDEF 6
-#define INCLUDE 7
-#define LINE 8
-#define PRAGMA 9
-#define ERROR 10
-#define IDENT 11
-#define SCCS 12
-#define ELIF 13
-#define EJECT 14
-#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 */
+#define IF 0
+#define IFDEF 1
+#define IFNDEF 2
+#define ELSE 3
+#define ENDIF 4
+#define DEFINE 5
+#define UNDEF 6
+#define INCLUDE 7
+#define LINE 8
+#define PRAGMA 9
+#define ERROR 10
+#define IDENT 11
+#define SCCS 12
+#define ELIF 13
+#define EJECT 14
+#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;
/*
* debug levels are:
- *
+ *
* 0 show ifn*(def)*,endif
* 1 trace defined/!defined
* 2 show #include
@@ -89,7 +89,7 @@ extern int _debugmask;
*/
#define debug(level,arg) { if (_debugmask & (1 << level)) warning arg; }
#else
-#define debug(level,arg) /**/
+#define debug(level,arg) /**/
#endif /* DEBUG */
typedef unsigned char boolean;
@@ -97,7 +97,6 @@ typedef unsigned char boolean;
struct symtab {
char *s_name;
char *s_value;
- char *s_args;
};
/* possible i_flag */
@@ -139,7 +138,7 @@ char *malloc(), *realloc();
#endif /* macII */
char *copy(char *str);
-int match(char *str, char **list);
+int match(char *str, char **list);
char *base_name(char *file);
char *getnextline(struct filepointer *fp);
struct symtab **slookup(char *symbol, struct inclist *file);
@@ -148,36 +147,36 @@ struct symtab **isdefined(char *symbol, struct inclist *file,
struct symtab **fdefined(char *symbol, struct inclist *file,
struct inclist **srcfile);
struct filepointer *getfile(char *file);
-void included_by(struct inclist *ip,
+void included_by(struct inclist *ip,
struct inclist *newfile);
struct inclist *newinclude(char *newfile, char *incstring);
-void inc_clean(void);
+void inc_clean (void);
struct inclist *inc_path(char *file, char *include, int type);
-void freefile(struct filepointer *fp);
+void freefile(struct filepointer *fp);
-void define2(char *name, char *args, 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,
+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,
+void recursive_pr_include(struct inclist *head,
char *file, char *base);
-void add_include(struct filepointer *filep,
- struct inclist *file,
- struct inclist *file_red,
+void add_include(struct filepointer *filep,
+ struct inclist *file,
+ struct inclist *file_red,
char *include, int type,
boolean failOK);
-int cppsetup(char *filename,
+int cppsetup(char *filename,
char *line,
struct filepointer *filep,
struct inclist *inc);
+
extern void fatalerr(char *, ...);
extern void warning(char *, ...);
extern void warning1(char *, ...);
diff --git a/ifparser.c b/ifparser.c
index 49dff21..aa51748 100644
--- a/ifparser.c
+++ b/ifparser.c
@@ -2,7 +2,7 @@
* $Xorg: ifparser.c,v 1.3 2000/08/17 19:41:50 cpqbld Exp $
*
* Copyright 1992 Network Computing Devices, Inc.
- *
+ *
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
@@ -12,7 +12,7 @@
* without specific, written prior permission. Network Computing Devices makes
* no representations about the suitability of this software for any purpose.
* It is provided ``as is'' without express or implied warranty.
- *
+ *
* NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
* IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,
@@ -20,47 +20,46 @@
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
- *
+ *
* Author: Jim Fulton
* Network Computing Devices, Inc.
- *
+ *
* Simple if statement processor
*
* This module can be used to evaluate string representations of C language
* if constructs. It accepts the following grammar:
- *
+ *
* EXPRESSION := VALUE
- * | VALUE BINOP EXPRESSION
+ * | VALUE BINOP EXPRESSION
* | VALUE '?' EXPRESSION ':' EXPRESSION
- *
+ *
* VALUE := '(' EXPRESSION ')'
- * | '!' VALUE
- * | '-' VALUE
- * | '+' VALUE
+ * | '!' VALUE
+ * | '-' VALUE
+ * | '+' VALUE
* | '~' VALUE
- * | 'defined' '(' variable_name ')'
- * | 'defined' variable_name
+ * | 'defined' '(' variable ')'
+ * | 'defined' variable
* | # variable '(' variable-list ')'
- * | variable(arglist)
- * | variable
- * | number
- *
+ * | variable
+ * | number
+ *
* BINOP := '*' | '/' | '%'
- * | '+' | '-'
- * | '<<' | '>>'
- * | '<' | '>' | '<=' | '>='
- * | '==' | '!='
- * | '&' | '^' | '|'
- * | '&&' | '||'
- *
+ * | '+' | '-'
+ * | '<<' | '>>'
+ * | '<' | '>' | '<=' | '>='
+ * | '==' | '!='
+ * | '&' | '^' | '|'
+ * | '&&' | '||'
+ *
* 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.12 2004/03/05 16:02:58 tsi Exp $ */
+/* $XFree86: xc/config/makedepend/ifparser.c,v 3.10tsi Exp $ */
#include "ifparser.h"
#include <ctype.h>
@@ -78,53 +77,16 @@
static const char *
-parse_variable_name (IfParser *g, const char *cp, const char **varp, int *varlenp)
-{
- *varlenp = 0;
-
- SKIPSPACE (cp);
-
- if (!isvarfirstletter(*cp))
- return CALLFUNC(g, handle_error) (g, cp, "variable name");
-
- *varp = cp;
- for (cp++; isalnum(*cp) || *cp == '_'; cp++) /* EMPTY */;
- *varlenp = cp - *varp;
-
- return cp;
-}
-
-
-static const char *
-parse_variable (IfParser *g, const char *cp, const char **varp, int *varlenp, const char **argsp)
+parse_variable (IfParser *g, const char *cp, const char **varp)
{
- *argsp = NULL;
- *varlenp = 0;
-
SKIPSPACE (cp);
- /* this error handling call might prevent us from merging with above code */
if (!isvarfirstletter (*cp))
return CALLFUNC(g, handle_error) (g, cp, "variable name");
*varp = cp;
- for (cp++; isalnum(*cp) || *cp == '_'; cp++) /* EMPTY */;
- *varlenp = cp - *varp;
-
- if (variable_has_args(g, *varp, *varlenp))
- {
- SKIPSPACE (cp);
- if (*cp != '(')
- {
- return CALLFUNC(g, handle_error) (g, cp, "argument list");
- }
- cp++;
-
- *argsp = cp;
- for (cp++; *cp != ')'; cp++) /* EMPTY */;
- cp++;
- }
-
+ /* EMPTY */
+ for (cp++; isalnum(*cp) || *cp == '_'; cp++) ;
return cp;
}
@@ -209,8 +171,7 @@ parse_character (IfParser *g, const char *cp, long *valp)
static const char *
parse_value (IfParser *g, const char *cp, long *valp)
{
- const char *var, *args;
- int varlen;
+ const char *var, *varend;
*valp = 0;
@@ -222,7 +183,7 @@ parse_value (IfParser *g, const char *cp, long *valp)
case '(':
DO (cp = ParseIfExpression (g, cp + 1, valp));
SKIPSPACE (cp);
- if (*cp != ')')
+ if (*cp != ')')
return CALLFUNC(g, handle_error) (g, cp, ")");
return cp + 1; /* skip the right paren */
@@ -247,12 +208,12 @@ parse_value (IfParser *g, const char *cp, long *valp)
return cp;
case '#':
- DO (cp = parse_variable (g, cp + 1, &var, &varlen, &args));
+ DO (cp = parse_variable (g, cp + 1, &var));
SKIPSPACE (cp);
if (*cp != '(')
return CALLFUNC(g, handle_error) (g, cp, "(");
do {
- DO (cp = parse_variable (g, cp + 1, &var, &varlen, &args));
+ DO (cp = parse_variable (g, cp + 1, &var));
SKIPSPACE (cp);
} while (*cp && *cp != ')');
if (*cp != ')')
@@ -269,6 +230,7 @@ parse_value (IfParser *g, const char *cp, long *valp)
case 'd':
if (strncmp (cp, "defined", 7) == 0 && !isalnum(cp[7])) {
int paren = 0;
+ int len;
cp += 7;
SKIPSPACE (cp);
@@ -276,31 +238,43 @@ parse_value (IfParser *g, const char *cp, long *valp)
paren = 1;
cp++;
}
- DO (cp = parse_variable_name (g, cp, &var, &varlen));
+ DO (cp = parse_variable (g, cp, &var));
+ len = cp - var;
SKIPSPACE (cp);
if (paren && *cp != ')')
return CALLFUNC(g, handle_error) (g, cp, ")");
- *valp = (*(g->funcs.eval_defined)) (g, var, varlen);
+ *valp = (*(g->funcs.eval_defined)) (g, var, len);
return cp + paren; /* skip the right paren */
}
/* fall out */
}
if (isdigit(*cp)) {
- /* determine the numeric value */
DO (cp = parse_number (g, cp, valp));
- } else if (isvarfirstletter(*cp)) {
- /* resolve the value of this macro.
- * (macro argument substitution will take place
- * and recursive macro resolvement will apply) */
- DO (cp = parse_variable (g, cp, &var, &varlen, &args));
- *valp = (*(g->funcs.eval_variable)) (g, var, varlen, args);
- }
- else {
- /* we finally got something that does not fit the syntax rules */
+ } else if (!isvarfirstletter(*cp))
return CALLFUNC(g, handle_error) (g, cp, "variable or number");
+ else {
+ DO (cp = parse_variable (g, 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;
}
diff --git a/ifparser.h b/ifparser.h
index e9ec9c3..398a3e4 100644
--- a/ifparser.h
+++ b/ifparser.h
@@ -2,7 +2,7 @@
* $Xorg: ifparser.h,v 1.3 2000/08/17 19:41:51 cpqbld Exp $
*
* Copyright 1992 Network Computing Devices, Inc.
- *
+ *
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
@@ -12,7 +12,7 @@
* without specific, written prior permission. Network Computing Devices makes
* no representations about the suitability of this software for any purpose.
* It is provided ``as is'' without express or implied warranty.
- *
+ *
* NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
* IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,
@@ -20,19 +20,44 @@
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
- *
+ *
* Author: Jim Fulton
* Network Computing Devices, Inc.
+ *
+ * Simple if statement processor
*
- * Simple if statement processor. Please see ifparser.c for the parsing tree.
- *
- *
+ * This module can be used to evaluate string representations of C language
+ * if constructs. It accepts the following grammar:
+ *
+ * EXPRESSION := VALUE
+ * | VALUE BINOP EXPRESSION
+ * | VALUE '?' EXPRESSION ':' EXPRESSION
+ *
+ * VALUE := '(' EXPRESSION ')'
+ * | '!' VALUE
+ * | '-' VALUE
+ * | '~' VALUE
+ * | 'defined' '(' variable ')'
+ * | variable
+ * | number
+ *
+ * BINOP := '*' | '/' | '%'
+ * | '+' | '-'
+ * | '<<' | '>>'
+ * | '<' | '>' | '<=' | '>='
+ * | '==' | '!='
+ * | '&' | '^' | '|'
+ * | '&&' | '||'
+ *
+ * The normal C order of precedence is supported.
+ *
+ *
* External Entry Points:
- *
+ *
* ParseIfExpression parse a string for #if
*/
-/* $XFree86: xc/config/makedepend/ifparser.h,v 3.6 2004/03/05 16:02:58 tsi Exp $ */
+/* $XFree86: xc/config/makedepend/ifparser.h,v 3.4 2001/01/17 16:38:58 dawes Exp $ */
#include <stdio.h>
@@ -44,17 +69,15 @@ typedef struct _if_parser {
struct { /* functions */
const char *(*handle_error) (struct _if_parser *, const char *,
const char *);
- long (*eval_variable) (struct _if_parser *, const char *, int,
- const char *);
+ long (*eval_variable) (struct _if_parser *, const char *, int);
int (*eval_defined) (struct _if_parser *, const char *, int);
} funcs;
char *data;
} IfParser;
const char *ParseIfExpression (
- IfParser *,
- const char *,
+ IfParser *,
+ const char *,
long *
);
-extern int variable_has_args(IfParser *ip, const char *var, int len);
diff --git a/imakemdep.h b/imakemdep.h
index f272429..38a6d95 100644
--- a/imakemdep.h
+++ b/imakemdep.h
@@ -24,7 +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/imake/imakemdep.h,v 3.72 2003/12/30 01:53:52 tsi Exp $ */
+/* $XFree86: xc/config/imake/imakemdep.h,v 3.71 2003/06/12 14:12:26 eich Exp $ */
/*
@@ -371,11 +371,11 @@ char *cpp_argv[ARGUMENTS] = {
# ifdef __ia64__
"-D__ia64__",
# endif
-# ifdef __AMD64__
- "-D__AMD64__",
+# ifdef __amd64__
+ "-D__amd64__",
# endif
# ifdef __x86_64__
- "-D__AMD64__",
+ "-D__amd64__",
# endif
# ifdef __s390__
"-D__s390__",
@@ -1264,12 +1264,12 @@ struct symtab predefs[] = {
# ifdef __ia64__
{"__ia64__", "1"},
# endif
-# if defined (AMD64) || defined (x86_64)
- {"AMD64", "1"},
+# if defined (amd64) || defined (x86_64)
+ {"amd64", "1"},
{"x86_64", "1"},
# endif
-# if defined (__AMD64__) || defined (__x86_64__)
- {"__AMD64__", "1"},
+# if defined (__amd64__) || defined (__x86_64__)
+ {"__amd64__", "1"},
{"__x86_64__", "1"},
# endif
# ifdef __i386
diff --git a/include.c b/include.c
index 4e32800..65ce783 100644
--- a/include.c
+++ b/include.c
@@ -24,7 +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 $ */
+/* $XFree86: xc/config/makedepend/include.c,v 3.6 2001/04/29 23:25:02 tsi Exp $ */
#include "def.h"
diff --git a/main.c b/main.c
index efdaceb..a6c4883 100644
--- a/main.c
+++ b/main.c
@@ -24,7 +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.33 2004/03/05 16:02:59 tsi Exp $ */
+/* $XFree86: xc/config/makedepend/main.c,v 3.31tsi Exp $ */
#include "def.h"
#ifdef hpux
@@ -112,7 +112,7 @@ boolean printed = FALSE;
boolean verbose = FALSE;
boolean show_where_not = FALSE;
/* Warn on multiple includes of same file */
-boolean warn_multiple = FALSE;
+boolean warn_multiple = FALSE;
static void setfile_cmdinc(struct filepointer *filep, long count, char **list);
static void redirect(char *line, char *makefile);
@@ -162,7 +162,7 @@ main(int argc, char *argv[])
while (psymp->s_name)
{
- define2(psymp->s_name, NULL, psymp->s_value, &maininclist);
+ define2(psymp->s_name, psymp->s_value, &maininclist);
psymp++;
}
if (argc == 2 && argv[1][0] == '@') {
@@ -213,7 +213,7 @@ main(int argc, char *argv[])
argv = nargv;
}
for(argc--, argv++; argc; argc--, argv++) {
- /* if looking for endmarker then check before parsing */
+ /* if looking for endmarker then check before parsing */
if (endmarker && strcmp (endmarker, *argv) == 0) {
endmarker = NULL;
continue;
@@ -331,7 +331,7 @@ main(int argc, char *argv[])
case 'm':
warn_multiple = TRUE;
break;
-
+
/* Ignore -O, -g so we can just pass ${CFLAGS} to
makedepend
*/
@@ -351,7 +351,7 @@ main(int argc, char *argv[])
buf = malloc(strlen(DASH_INC_PRE) +
strlen(argv[0]) +
strlen(DASH_INC_POST) + 1);
- if (!buf)
+ if(!buf)
fatalerr("out of memory at "
"-include string\n");
cmdinc_list[2 * cmdinc_count + 0] = argv[0];
@@ -388,7 +388,7 @@ main(int argc, char *argv[])
for (;;) {
end = (char*)strchr(beg,';');
if (end) *end = 0;
- if (incp >= includedirs + MAXDIRS)
+ if (incp >= includedirs + MAXDIRS)
fatalerr("Too many include dirs\n");
*incp++ = beg;
if (!end) break;
@@ -509,7 +509,7 @@ main(int argc, char *argv[])
/*
* eliminate \r chars from file
*/
-static int
+static int
elim_cr(char *buf, int sz)
{
int i,wp;
@@ -633,7 +633,7 @@ char *getnextline(struct filepointer *filep)
}
whitespace = TRUE;
}
-
+
if (*p == '/' && (p+1) < eof && *(p+1) == '*') {
/* Consume C comments */
*(p++) = ' ';
@@ -661,7 +661,7 @@ char *getnextline(struct filepointer *filep)
lineno++;
}
else if (*p == '?' && (p+3) < eof &&
- *(p+1) == '?' &&
+ *(p+1) == '?' &&
*(p+2) == '/' &&
*(p+3) == '\n') {
*(p++) = ' ';
@@ -697,7 +697,7 @@ char *getnextline(struct filepointer *filep)
*(p++) = '\0';
/* punt lines with just # (yacc generated) */
- for (cp = bol+1;
+ for (cp = bol+1;
*cp && (*cp == ' ' || *cp == '\t'); cp++);
if (*cp) goto done;
--p;
@@ -817,7 +817,7 @@ redirect(char *line, char *makefile)
#if defined(USGISH) || defined(_SEQUENT_) || defined(USE_CHMOD)
chmod(makefile, st.st_mode);
#else
- fchmod(fileno(fdout), st.st_mode);
+ fchmod(fileno(fdout), st.st_mode);
#endif /* USGISH */
}
diff --git a/makedepend.man b/makedepend.man
index 595c87e..ac67cc8 100644
--- a/makedepend.man
+++ b/makedepend.man
@@ -23,7 +23,7 @@
.\" dealing in this Software without prior written authorization from The
.\" Open Group.
.\"
-.\" $XFree86: xc/config/makedepend/mkdepend.man,v 1.7 2002/12/14 02:39:45 dawes Exp $
+.\" $XFree86: xc/config/makedepend/mkdepend.man,v 1.6 2001/12/17 20:52:22 dawes Exp $
.\"
.TH MAKEDEPEND 1 __xorgversion__
.UC 4
diff --git a/parse.c b/parse.c
index 66a4b6e..935c61d 100644
--- a/parse.c
+++ b/parse.c
@@ -24,7 +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/parse.c,v 1.14 2004/03/10 15:49:20 tsi Exp $ */
+/* $XFree86: xc/config/makedepend/parse.c,v 1.11 2001/12/17 20:52:22 dawes Exp $ */
#include "def.h"
@@ -61,7 +61,7 @@ gobble(struct filepointer *filep, struct inclist *file,
(type == ELIFGUESSFALSE))
type = gobble(filep, file, file_red);
if (type == ELSE)
- (void)gobble(filep, file, file_red);
+ (void)gobble(filep, file, file_red);
break;
case ELSE:
case ENDIF:
@@ -101,8 +101,8 @@ gobble(struct filepointer *filep, struct inclist *file,
/*
* Decide what type of # directive this line is.
*/
-static int
-deftype (char *line, struct filepointer *filep,
+static int
+deftype (char *line, struct filepointer *filep,
struct inclist *file_red, struct inclist *file, int parse_it)
{
register char *p;
@@ -202,7 +202,7 @@ deftype (char *line, struct filepointer *filep,
if (!*p || *p == '"' || *p == '<')
break;
- sym = isdefined(p, file_red, NULL);
+ sym = isdefined(p, file_red, NULL);
if (!sym)
break;
@@ -212,7 +212,7 @@ deftype (char *line, struct filepointer *filep,
(*sym) -> s_name,
(*sym) -> s_value));
/* mark file as having included a 'soft include' */
- file->i_flags |= INCLUDED_SYM;
+ file->i_flags |= INCLUDED_SYM;
}
/*
@@ -322,7 +322,7 @@ zero_value(char *filename,
}
void
-define2(char *name, char *args, char *val, struct inclist *file)
+define2(char *name, char *val, struct inclist *file)
{
int first, last, below;
register struct symtab **sp = NULL, **dest;
@@ -359,14 +359,14 @@ define2(char *name, char *args, char *val, struct inclist *file)
if (s2[-1] == '\0') break;
/* If exact match, set sp and break */
- if (*--s1 == *--s2)
+ if (*--s1 == *--s2)
{
sp = file->i_defs + middle;
break;
}
/* If name > i_defs[middle] ... */
- if (*s1 > *s2)
+ if (*s1 > *s2)
{
below = first;
first = middle + 1;
@@ -379,19 +379,11 @@ define2(char *name, char *args, char *val, struct inclist *file)
}
/* Search is done. If we found an exact match to the symbol name,
- just replace its s_args and s_value if they are changed */
+ 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));
-
- if ( (*sp)->s_args )
- free((*sp)->s_args);
- if (args)
- (*sp)->s_args = copy(args);
- else
- (*sp)->s_args = NULL;
-
free((*sp)->s_value);
(*sp)->s_value = copy(val);
return;
@@ -410,10 +402,6 @@ define2(char *name, char *args, char *val, struct inclist *file)
debug(1,("defining %s to %s in file %s\n", name, val, file->i_file));
stab->s_name = copy(name);
- if (args)
- stab->s_args = copy(args);
- else
- stab->s_args = NULL;
stab->s_value = copy(val);
*sp = stab;
}
@@ -421,99 +409,20 @@ define2(char *name, char *args, char *val, struct inclist *file)
void
define(char *def, struct inclist *file)
{
-#define S_ARGS_BUFLEN 1024 /* we dont expect too much macro parameters usage */
-static char args[S_ARGS_BUFLEN];
-
char *val;
- char *p_args = args;
- int fix_args = 0, var_args = 0, loop = 1;
- char *p_tmp;
-
- args[0] = '\0';
/* Separate symbol name and its value */
val = def;
while (isalnum(*val) || *val == '_')
val++;
-
- if (*val == '(') /* is this macro definition with parameters? */
- {
- *val++ = '\0';
-
- do /* parse the parametere list */
- {
- while (*val == ' ' || *val == '\t')
- val++;
-
- /* extract next parameter name */
- if (*val == '.')
- { /* it should be the var-args parameter: "..." */
- var_args++;
- p_tmp = p_args;
- while (*val == '.')
- {
- *p_args++ = *val++;
- if (p_args >= &args[S_ARGS_BUFLEN-1])
- fatalerr("args buffer full failure in insert_defn()\n");
- }
- *p_args = '\0';
- if (strcmp(p_tmp,"...")!=0)
- {
- fprintf(stderr, "unrecognized qualifier, should be \"...\" for-args\n");
- }
- }
- else
- { /* regular parameter name */
- fix_args++;
- while (isalnum(*val) || *val == '_')
- {
- *p_args++ = *val++;
- if (p_args >= &args[S_ARGS_BUFLEN-1])
- fatalerr("args buffer full failure in insert_defn()\n");
- }
- }
- while (*val == ' ' || *val == '\t')
- val++;
-
- if (*val == ',')
- {
- if (var_args)
- {
- fprintf(stderr, "there are more arguments after the first var-args qualifier\n");
- }
-
- *p_args++ = ','; /* we are using the , as a reserved char */
- if (p_args >= &args[S_ARGS_BUFLEN-1])
- fatalerr("args buffer full failure in insert_defn()\n");
- val++;
- }
- else
- if (*val == ')')
- {
- *p_args = '\0';
- val++;
- loop=0;
- }
- else
- {
- fprintf(stderr, "trailing ) on macro arguments missing\n");
- loop=0;
- }
- } while (loop);
- }
-
if (*val)
*val++ = '\0';
while (*val == ' ' || *val == '\t')
val++;
- if (!*val) /* define statements without a value will get a value of 1 */
+ if (!*val)
val = "1";
-
- if (args && (strlen(args)>0))
- define2(def, args, val, file);
- else
- define2(def, NULL, val, file);
+ define2(def, val, file);
}
struct symtab **
@@ -533,29 +442,29 @@ slookup(char *symbol, struct inclist *file)
s1 = symbol;
s2 = file->i_defs[middle]->s_name;
while (*s1++ == *s2++)
- if (s2[-1] == '\0') break;
+ if (s2[-1] == '\0') break;
/* If exact match, we're done */
- if (*--s1 == *--s2)
+ if (*--s1 == *--s2)
{
- return file->i_defs + middle;
+ return file->i_defs + middle;
}
/* If symbol > i_defs[middle] ... */
- if (*s1 > *s2)
+ if (*s1 > *s2)
{
- first = middle + 1;
+ first = middle + 1;
}
/* else ... */
else
{
- last = middle - 1;
+ last = middle - 1;
}
}
return(NULL);
}
-static int
+static int
merge2defines(struct inclist *file1, struct inclist *file2)
{
int i;
@@ -568,59 +477,59 @@ merge2defines(struct inclist *file1, struct inclist *file2)
if (file2->i_merged[i]==FALSE)
return 0;
- { /* local var encapsulation */
+ {
int first1 = 0;
int last1 = file1->i_ndefs - 1;
int first2 = 0;
int last2 = file2->i_ndefs - 1;
- int first=0;
- struct symtab** i_defs = NULL;
+ int first=0;
+ 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 */
- deflen += (SYMTABINC - deflen % SYMTABINC) % SYMTABINC;
- i_defs=(struct symtab**)
+ if (deflen>0)
+ {
+ /* make sure deflen % SYMTABINC == 0 is still true */
+ deflen += (SYMTABINC - deflen % SYMTABINC) % SYMTABINC;
+ i_defs=(struct symtab**)
malloc(deflen*sizeof(struct symtab*));
- if (i_defs==NULL) return 0;
- }
-
- while ((last1 >= first1) && (last2 >= first2))
- {
- char *s1=file1->i_defs[first1]->s_name;
- char *s2=file2->i_defs[first2]->s_name;
-
- if (strcmp(s1,s2) < 0)
- i_defs[first++]=file1->i_defs[first1++];
- else if (strcmp(s1,s2) > 0)
- i_defs[first++]=file2->i_defs[first2++];
- else /* equal */
- {
- i_defs[first++]=file2->i_defs[first2++];
- first1++;
- }
- }
- while (last1 >= first1)
- {
- i_defs[first++]=file1->i_defs[first1++];
- }
- while (last2 >= first2)
- {
- i_defs[first++]=file2->i_defs[first2++];
- }
-
- if (file1->i_defs) free(file1->i_defs);
- file1->i_defs=i_defs;
- file1->i_ndefs=first;
-
+ if (i_defs==NULL) return 0;
+ }
+
+ while ((last1 >= first1) && (last2 >= first2))
+ {
+ char *s1=file1->i_defs[first1]->s_name;
+ char *s2=file2->i_defs[first2]->s_name;
+
+ if (strcmp(s1,s2) < 0)
+ i_defs[first++]=file1->i_defs[first1++];
+ else if (strcmp(s1,s2) > 0)
+ i_defs[first++]=file2->i_defs[first2++];
+ else /* equal */
+ {
+ i_defs[first++]=file2->i_defs[first2++];
+ first1++;
+ }
+ }
+ while (last1 >= first1)
+ {
+ i_defs[first++]=file1->i_defs[first1++];
+ }
+ while (last2 >= first2)
+ {
+ i_defs[first++]=file2->i_defs[first2++];
+ }
+
+ if (file1->i_defs) free(file1->i_defs);
+ file1->i_defs=i_defs;
+ file1->i_ndefs=first;
+
return 1;
- }
+ }
}
void
@@ -637,7 +546,7 @@ undefine(char *symbol, struct inclist *file)
}
int
-find_includes(struct filepointer *filep, struct inclist *file,
+find_includes(struct filepointer *filep, struct inclist *file,
struct inclist *file_red, int recursion, boolean failOK)
{
struct inclist *inclistp;
@@ -678,11 +587,8 @@ find_includes(struct filepointer *filep, struct inclist *file,
break;
case IFDEF:
case IFNDEF:
- {
- int isdef = (isdefined(line, file_red, NULL) != NULL);
- if (type == IFNDEF) isdef = !isdef;
-
- if (isdef) {
+ if ((type == IFDEF && isdefined(line, file_red, NULL))
+ || (type == IFNDEF && !isdefined(line, file_red, NULL))) {
debug(1,(type == IFNDEF ?
"line %d: %s !def'd in %s via %s%s\n" : "",
filep->f_line, line,
@@ -704,12 +610,11 @@ find_includes(struct filepointer *filep, struct inclist *file,
find_includes(filep, file,
file_red, recursion+1, failOK);
else if (type == ELIF)
- goto doif;
+ goto doif;
else if (type == ELIFFALSE || type == ELIFGUESSFALSE)
- goto doiffalse;
+ goto doiffalse;
}
- }
- break;
+ break;
case ELSE:
case ELIFFALSE:
case ELIFGUESSFALSE:
@@ -747,13 +652,13 @@ find_includes(struct filepointer *filep, struct inclist *file,
break;
case ERROR:
case WARNING:
- warning("%s", file_red->i_file);
+ warning("%s", file_red->i_file);
if (file_red != file)
warning1(" (reading %s)", file->i_file);
warning1(", line %d: %s\n",
filep->f_line, line);
- break;
-
+ break;
+
case PRAGMA:
case IDENT:
case SCCS:
diff --git a/pr.c b/pr.c
index e864793..5d0e1c4 100644
--- a/pr.c
+++ b/pr.c
@@ -24,7 +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 $ */
+/* $XFree86: xc/config/makedepend/pr.c,v 1.4 2001/04/29 23:25:02 tsi Exp $ */
#include "def.h"