Commit 0080e892 by Zack Weinberg Committed by Zack Weinberg

cppexp.c (LOGICAL): Delete macro.

	* cppexp.c (LOGICAL): Delete macro.
	(_cpp_parse_expr): Do not use UNARY for unary +.  Implement ||
	and && directly.

	* cpphash.c (HASHSIZE): Increase to 4096.
	(struct hashdummy): Add hash field.
	(eq_HASHNODE): Compare unreduced hashes, then lengths, then
	the string values using memcmp.
	(cpp_lookup): Set dummy.hash.

From-SVN: r34994
parent 50ceaae0
2000-07-12 Zack Weinberg <zack@wolery.cumb.org>
* cppexp.c (LOGICAL): Delete macro.
(_cpp_parse_expr): Do not use UNARY for unary +. Implement ||
and && directly.
* cpphash.c (HASHSIZE): Increase to 4096.
(struct hashdummy): Add hash field.
(eq_HASHNODE): Compare unreduced hashes, then lengths, then
the string values using memcmp.
(cpp_lookup): Set dummy.hash.
Wed Jul 12 13:15:16 2000 Marc Espie <espie@openbsd.org> Wed Jul 12 13:15:16 2000 Marc Espie <espie@openbsd.org>
* configure.in (m88k-openbsd): Express configuration using new fragment * configure.in (m88k-openbsd): Express configuration using new fragment
......
...@@ -706,10 +706,6 @@ op_to_prio[] = ...@@ -706,10 +706,6 @@ op_to_prio[] =
top->value = OP v2; \ top->value = OP v2; \
top->unsignedp = unsigned2; \ top->unsignedp = unsigned2; \
top->flags |= HAVE_VALUE; top->flags |= HAVE_VALUE;
#define LOGICAL(OP, NEG) \
top->value = v1 OP v2; \
top->unsignedp = 0; \
if (NEG v1) skip_evaluation--;
#define SHIFT(PSH, MSH) \ #define SHIFT(PSH, MSH) \
if (skip_evaluation) \ if (skip_evaluation) \
break; \ break; \
...@@ -834,15 +830,18 @@ _cpp_parse_expr (pfile) ...@@ -834,15 +830,18 @@ _cpp_parse_expr (pfile)
case CPP_AND: BITWISE(&); break; case CPP_AND: BITWISE(&); break;
case CPP_XOR: BITWISE(^); break; case CPP_XOR: BITWISE(^); break;
case CPP_OR: BITWISE(|); break; case CPP_OR: BITWISE(|); break;
case CPP_AND_AND: LOGICAL(&&,!); break;
case CPP_OR_OR: LOGICAL(||,); break;
case CPP_LSHIFT: SHIFT(left_shift, right_shift); break; case CPP_LSHIFT: SHIFT(left_shift, right_shift); break;
case CPP_RSHIFT: SHIFT(right_shift, left_shift); break; case CPP_RSHIFT: SHIFT(right_shift, left_shift); break;
case CPP_PLUS: case CPP_PLUS:
if (!(top->flags & HAVE_VALUE)) if (!(top->flags & HAVE_VALUE))
{ {
UNARY(/* + */); /* K+R C doesn't like unary + */ /* Can't use UNARY(+) because K+R C did not have unary
plus. Can't use UNARY() because some compilers object
to the empty argument. */
top->value = v2;
top->unsignedp = unsigned2;
top->flags |= HAVE_VALUE;
} }
else else
{ {
...@@ -908,6 +907,16 @@ _cpp_parse_expr (pfile) ...@@ -908,6 +907,16 @@ _cpp_parse_expr (pfile)
} }
break; break;
case CPP_OR_OR:
top->value = v1 || v2;
top->unsignedp = 0;
if (v1) skip_evaluation--;
break;
case CPP_AND_AND:
top->value = v1 && v2;
top->unsignedp = 0;
if (!v1) skip_evaluation--;
break;
case CPP_COMMA: case CPP_COMMA:
if (CPP_PEDANTIC (pfile)) if (CPP_PEDANTIC (pfile))
cpp_pedwarn (pfile, "comma operator in operand of #if"); cpp_pedwarn (pfile, "comma operator in operand of #if");
......
...@@ -37,6 +37,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -37,6 +37,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
struct hashdummy struct hashdummy
{ {
const U_CHAR *name; const U_CHAR *name;
unsigned int hash;
unsigned short length; unsigned short length;
}; };
...@@ -49,7 +50,7 @@ struct macro_info ...@@ -49,7 +50,7 @@ struct macro_info
}; };
/* Initial hash table size. (It can grow if necessary - see hashtab.c.) */ /* Initial hash table size. (It can grow if necessary - see hashtab.c.) */
#define HASHSIZE 500 #define HASHSIZE 4096
static unsigned int hash_HASHNODE PARAMS ((const void *)); static unsigned int hash_HASHNODE PARAMS ((const void *));
static int eq_HASHNODE PARAMS ((const void *, const void *)); static int eq_HASHNODE PARAMS ((const void *, const void *));
...@@ -104,7 +105,7 @@ hash_HASHNODE (x) ...@@ -104,7 +105,7 @@ hash_HASHNODE (x)
rule that the existing entry is the first argument, the potential rule that the existing entry is the first argument, the potential
entry the second. It also relies on the comparison function never entry the second. It also relies on the comparison function never
being called except as a direct consequence of a call to being called except as a direct consequence of a call to
htab_find(_slot)_with_hash. */ the htab_find routines. */
static int static int
eq_HASHNODE (x, y) eq_HASHNODE (x, y)
const void *x; const void *x;
...@@ -113,8 +114,9 @@ eq_HASHNODE (x, y) ...@@ -113,8 +114,9 @@ eq_HASHNODE (x, y)
const cpp_hashnode *a = (const cpp_hashnode *)x; const cpp_hashnode *a = (const cpp_hashnode *)x;
const struct hashdummy *b = (const struct hashdummy *)y; const struct hashdummy *b = (const struct hashdummy *)y;
return (a->length == b->length return (a->hash == b->hash
&& !ustrncmp (a->name, b->name, a->length)); && a->length == b->length
&& !memcmp (a->name, b->name, a->length));
} }
/* Find the hash node for name "name", of length LEN. */ /* Find the hash node for name "name", of length LEN. */
...@@ -132,7 +134,7 @@ cpp_lookup (pfile, name, len) ...@@ -132,7 +134,7 @@ cpp_lookup (pfile, name, len)
dummy.name = name; dummy.name = name;
dummy.length = len; dummy.length = len;
hash = _cpp_calc_hash (name, len); dummy.hash = hash = _cpp_calc_hash (name, len);
slot = (cpp_hashnode **) slot = (cpp_hashnode **)
htab_find_slot_with_hash (pfile->hashtab, (void *)&dummy, hash, INSERT); htab_find_slot_with_hash (pfile->hashtab, (void *)&dummy, hash, INSERT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment