summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--lib.c20
-rw-r--r--lib.h8
3 files changed, 24 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 3db0d797..f71577ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -48,6 +48,15 @@
* txr.1: Documented new regex operators.
+2009-12-17 Kaz Kylheku <kkylheku@gmail.com>
+
+ * lib.c (make_package, find_package): Eliminate declaration
+ in the middle of statement block.
+
+ * lib.h (TAG_MASK): Becomes type cnum rather than long.
+ (nao): Based off 1 rather than -1 to avoid left shift of
+ negative number.
+
2009-12-09 Kaz Kylheku <kkylheku@gmail.com>
* parser.l (YYINPUT): Fix signed/unsigned comparison.
diff --git a/lib.c b/lib.c
index b41a7cc5..55e961bf 100644
--- a/lib.c
+++ b/lib.c
@@ -1103,16 +1103,17 @@ val make_sym(val name)
val make_package(val name)
{
- if (find_package(name))
+ if (find_package(name)) {
uw_throwf(error_s, lit("make_package: ~a exists already"), name, nao);
+ } else {
+ val obj = make_obj();
+ obj->pk.type = PKG;
+ obj->pk.name = name;
+ obj->pk.symhash = make_hash(nil, nil);
- val obj = make_obj();
- obj->pk.type = PKG;
- obj->pk.name = name;
- obj->pk.symhash = make_hash(nil, nil);
-
- push(cons(name, obj), &packages);
- return obj;
+ push(cons(name, obj), &packages);
+ return obj;
+ }
}
val find_package(val name)
@@ -1123,6 +1124,7 @@ val find_package(val name)
val intern(val str, val package)
{
val new_p;
+ val *place;
if (nullp(package)) {
package = user_package;
@@ -1134,7 +1136,7 @@ val intern(val str, val package)
type_check (package, PKG);
- val *place = gethash_l(package->pk.symhash, str, &new_p);
+ place = gethash_l(package->pk.symhash, str, &new_p);
if (!new_p) {
return *place;
diff --git a/lib.h b/lib.h
index b50c1075..4afaa812 100644
--- a/lib.h
+++ b/lib.h
@@ -24,8 +24,10 @@
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+typedef int_ptr_t cnum;
+
#define TAG_SHIFT 2
-#define TAG_MASK ((1L << TAG_SHIFT) - 1)
+#define TAG_MASK (((cnum) 1 << TAG_SHIFT) - 1)
#define TAG_PTR 0
#define TAG_NUM 1
#define TAG_CHR 2
@@ -33,8 +35,6 @@
#define NUM_MAX (INT_PTR_MAX/4)
#define NUM_MIN (INT_PTR_MIN/4)
-typedef int_ptr_t cnum;
-
typedef enum type {
NUM = TAG_NUM, CHR = TAG_CHR, LIT = TAG_LIT, CONS,
STR, SYM, PKG, FUN, VEC, LCONS, LSTR, COBJ
@@ -379,7 +379,7 @@ val match(val spec, val data);
#define nil ((obj_t *) 0)
-#define nao ((obj_t *) (-1 << TAG_SHIFT)) /* "not an object" sentinel value. */
+#define nao ((obj_t *) (1 << TAG_SHIFT)) /* "not an object" sentinel value. */
#define eq(a, b) ((a) == (b) ? t : nil)