On Friday 16 January 2009 19:46:49 Kevin Day wrote:
> The file: uClibc-0.9.30/extra/scripts/unifdef.c
> There is a bsd header: err.h and bsd code err() errx(), warnx() vwarnc(),
> etc..
>
> When the BSD options, namely UCLIBC_HAS_BSD_ERR, are disabled the
> unifdef.c script still tries to use them.
You're aware that the Linux kernel has a scripts/unifdef.c, right? Is any
effort being made to keep in sync with that?
Rob
P.S:
--- uClibc/extra/scripts/unifdef.c 2008-12-28 21:28:23.000000000 -0600
+++ linux/hg/scripts/unifdef.c 2008-11-22 19:09:23.000000000 -0600
@@ -296,7 +296,6 @@
input = stdin;
}
process();
- debug("bug at line %d", __LINE__);
abort(); /* bug */
}
@@ -439,10 +438,8 @@
static void
ignoreoff(void)
{
- if (depth == 0) {
- debug("bug at line %d", __LINE__);
+ if (depth == 0)
abort(); /* bug */
- }
ignoring[depth] = ignoring[depth-1];
}
static void
@@ -474,10 +471,8 @@
static void
unnest(void)
{
- if (depth == 0) {
- debug("bug at line %d", __LINE__);
+ if (depth == 0)
abort(); /* bug */
- }
depth -= 1;
}
static void
@@ -601,11 +596,8 @@
linestate = LS_DIRTY;
}
/* skipcomment should have changed the state */
-// Hmm hppens sometimes on valid files
-// if (linestate == LS_HASH) {
-// debug("bug at line %d", __LINE__);
-// abort(); /* bug */
-// }
+ if (linestate == LS_HASH)
+ abort(); /* bug */
}
if (linestate == LS_DIRTY) {
while (*cp != '\0')
@@ -657,31 +649,24 @@
eval_fn *inner;
struct op {
const char *str;
- int short_circuit_val;
int (*fn)(int, int);
} op[5];
} eval_ops[] = {
- { eval_table, { { "||", 1, op_or } } },
- { eval_table, { { "&&", 0, op_and } } },
- { eval_table, { { "==", -1, op_eq },
- { "!=", -1, op_ne } } },
- { eval_unary, { { "<=", -1, op_le },
- { ">=", -1, op_ge },
- { "<", -1, op_lt },
- { ">", -1, op_gt } } }
+ { eval_table, { { "||", op_or } } },
+ { eval_table, { { "&&", op_and } } },
+ { eval_table, { { "==", op_eq },
+ { "!=", op_ne } } },
+ { eval_unary, { { "<=", op_le },
+ { ">=", op_ge },
+ { "<", op_lt },
+ { ">", op_gt } } }
};
/*
- * Function for evaluating the innermost parts of expressions, viz.
- * "!expr", "(expr)", "defined(symbol)", "defined symbol", "symbol",
"number".
+ * Function for evaluating the innermost parts of expressions,
+ * viz. !expr (expr) defined(symbol) symbol number
* We reset the keepthis flag when we find a non-constant subexpression.
*/
-// TODO: we use LT_IF both as "I don't know whether it's false or true"
-// (example: "#if defined FOO") and when we see syntax error
-// (example: "#if (1 || 2" - no closing paren!), but this is wrong.
-// Binary && and || need to distinguish these cases in order to handle this:
-// "#if defined KNOWN_UNDEFINED && FOO" - discard
-// "#if defined KNOWN_UNDEFINED && (syntax_error_here" - do not discard!
static Linetype
eval_unary(const struct ops *ops, int *valp, const char **cpp)
{
@@ -693,60 +678,39 @@
if (*cp == '!') {
debug("eval%d !", ops - eval_ops);
cp++;
- if (eval_unary(ops, valp, &cp) == LT_IF) {
- *cpp = cp;
+ if (eval_unary(ops, valp, &cp) == LT_IF)
return (LT_IF);
- }
*valp = !*valp;
-
} else if (*cp == '(') {
- Linetype expr_res;
-
cp++;
- debug("eval%d (%s", ops - eval_ops, cp);
- expr_res = eval_table(eval_ops, valp, &cp);
+ debug("eval%d (", ops - eval_ops);
+ if (eval_table(eval_ops, valp, &cp) == LT_IF)
+ return (LT_IF);
cp = skipcomment(cp);
- *cpp = cp;
if (*cp++ != ')')
return (LT_IF);
- *cpp = cp;
- if (expr_res == LT_IF)
- return (LT_IF);
-
} else if (isdigit((unsigned char)*cp)) {
debug("eval%d number", ops - eval_ops);
*valp = strtol(cp, &ep, 0);
cp = skipsym(cp);
-
} else if (strncmp(cp, "defined", 7) == 0 && endsym(cp[7])) {
- bool parens;
-
cp = skipcomment(cp+7);
- debug("eval%d defined '%s'", ops - eval_ops, cp);
- parens = (*cp == '(');
- if (parens)
- cp = skipcomment(cp+1);
+ debug("eval%d defined", ops - eval_ops);
+ if (*cp++ != '(')
+ return (LT_IF);
+ cp = skipcomment(cp);
sym = findsym(cp);
+ if (sym < 0)
+ return (LT_IF);
+ *valp = (value[sym] != NULL);
cp = skipsym(cp);
cp = skipcomment(cp);
- if (parens) {
- if (*cp != ')')
- return (LT_IF);
- cp = skipcomment(cp+1);
- }
- *cpp = cp;
- if (sym < 0) {
- debug("sym not found, returning LT_IF");
+ if (*cp++ != ')')
return (LT_IF);
- }
- *valp = (value[sym] != NULL);
keepthis = false;
-
} else if (!endsym(*cp)) {
debug("eval%d symbol", ops - eval_ops);
sym = findsym(cp);
- cp = skipsym(cp);
- *cpp = cp;
if (sym < 0)
return (LT_IF);
if (value[sym] == NULL)
@@ -756,8 +720,8 @@
if (*ep != '\0' || ep == value[sym])
return (LT_IF);
}
+ cp = skipsym(cp);
keepthis = false;
-
} else {
debug("eval%d bad expr", ops - eval_ops);
return (LT_IF);
@@ -774,18 +738,15 @@
static Linetype
eval_table(const struct ops *ops, int *valp, const char **cpp)
{
- Linetype left_side;
const struct op *op;
const char *cp;
int val;
- debug("eval%d '%s'", ops - eval_ops, *cpp);
- left_side = ops->inner(ops+1, valp, cpp);
+ debug("eval%d", ops - eval_ops);
cp = *cpp;
-
+ if (ops->inner(ops+1, valp, &cp) == LT_IF)
+ return (LT_IF);
for (;;) {
- Linetype right_side;
-
cp = skipcomment(cp);
for (op = ops->op; op->str != NULL; op++)
if (strncmp(cp, op->str, strlen(op->str)) == 0)
@@ -793,37 +754,14 @@
if (op->str == NULL)
break;
cp += strlen(op->str);
- debug("eval%d '%s'", ops - eval_ops, op->str);
- right_side = ops->inner(ops+1, &val, &cp);
- *cpp = cp;
-
- /* If short_circuit_val is 0 or 1, we can ignore
- * right side if left size is known, and its value
- * (i.e., *valp) is 0 or !0, respectively */
- if (left_side != LT_IF && op->short_circuit_val == !!*valp) {
- debug("op->short_circuit_val:%d *valp:%d cp:'%s'",
- op->short_circuit_val, *valp, cp);
- *valp = !!*valp;
- break;
- }
- /* Same for the right side */
- if (right_side != LT_IF && op->short_circuit_val == !!val) {
- debug("op->short_circuit_val:%d val:%d cp:'%s'",
- op->short_circuit_val, val, cp);
- left_side = right_side;
- *valp = !!val;
- break;
- }
-
- if (left_side == LT_IF || right_side == LT_IF)
+ debug("eval%d %s", ops - eval_ops, op->str);
+ if (ops->inner(ops+1, &val, &cp) == LT_IF)
return (LT_IF);
*valp = op->fn(*valp, val);
- left_side = right_side;
}
- debug("eval%d = %d LT_IF:%d", ops - eval_ops, *valp, (left_side ==
LT_IF));
- if (left_side == LT_IF)
- return (LT_IF);
+ *cpp = cp;
+ debug("eval%d = %d", ops - eval_ops, *valp);
return (*valp ? LT_TRUE : LT_FALSE);
}
@@ -841,7 +779,7 @@
debug("eval %s", *cpp);
keepthis = killconsts ? false : true;
ret = eval_table(eval_ops, &val, cpp);
- debug("val:%d ret:%d keepthis:%d", val, ret, keepthis);
+ debug("eval = %d", val);
return (keepthis ? LT_IF : ret);
}
@@ -889,9 +827,8 @@
cp += 1;
} else if (strchr(" \t", *cp) != NULL) {
cp += 1;
- } else {
+ } else
return (cp);
- }
continue;
case CXX_COMMENT:
if (strncmp(cp, "\n", 1) == 0) {
@@ -949,7 +886,6 @@
incomment = C_COMMENT;
continue;
default:
- debug("bug at line %d", __LINE__);
abort(); /* bug */
}
return (cp);
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc