* strings.h, strings.c (scm_i_make_symbol): Added FLAGS parameter.
authorMarius Vollmer <mvo@zagadka.de>
Thu, 26 Aug 2004 15:40:13 +0000 (15:40 +0000)
committerMarius Vollmer <mvo@zagadka.de>
Thu, 26 Aug 2004 15:40:13 +0000 (15:40 +0000)
* symbols.h, symbols.c (SCM_I_F_SYMBOL_UNINTERNED,
scm_i_symbol_is_interned, scm_i_mem2symbol,
scm_i_mem2uninternedsymbol): Use it to store uninternedness flag.

libguile/strings.c
libguile/strings.h
libguile/symbols.c
libguile/symbols.h

index 614f4da..6feb017 100644 (file)
@@ -348,7 +348,8 @@ scm_i_string_stop_writing (void)
 #define SYMBOL_STRINGBUF SCM_CELL_OBJECT_1
 
 SCM
-scm_i_make_symbol (SCM name, unsigned long hash, SCM props)
+scm_i_make_symbol (SCM name, scm_t_bits flags,
+                  unsigned long hash, SCM props)
 {
   SCM buf;
   size_t start = STRING_START (name);
@@ -376,7 +377,7 @@ scm_i_make_symbol (SCM name, unsigned long hash, SCM props)
              STRINGBUF_CHARS (buf) + start, length);
       buf = new_buf;
     }
-  return scm_double_cell (scm_tc7_symbol, SCM_UNPACK (buf),
+  return scm_double_cell (scm_tc7_symbol | flags, SCM_UNPACK (buf),
                          (scm_t_bits) hash, SCM_UNPACK (props));
 }
 
index 9491262..edd6093 100644 (file)
@@ -120,7 +120,8 @@ SCM_API void scm_i_string_stop_writing (void);
 
 /* internal functions related to symbols. */
 
-SCM_API SCM scm_i_make_symbol (SCM name, unsigned long hash, SCM props);
+SCM_API SCM scm_i_make_symbol (SCM name, scm_t_bits flags, 
+                              unsigned long hash, SCM props);
 SCM_API const char *scm_i_symbol_chars (SCM sym);
 SCM_API size_t scm_i_symbol_length (SCM sym);
 SCM_API SCM scm_i_symbol_substring (SCM sym, size_t start, size_t end);
index 375ce8c..e8171eb 100644 (file)
@@ -90,7 +90,7 @@ scm_i_mem2symbol (SCM str)
   const char *name = scm_i_string_chars (str);
   size_t len = scm_i_string_length (str);
 
-  size_t raw_hash = scm_string_hash ((const unsigned char *) name, len) / 2;
+  size_t raw_hash = scm_string_hash ((const unsigned char *) name, len);
   size_t hash = raw_hash % SCM_HASHTABLE_N_BUCKETS (symbols);
 
   {
@@ -125,7 +125,7 @@ scm_i_mem2symbol (SCM str)
 
   {
     /* The symbol was not found - create it. */
-    SCM symbol = scm_i_make_symbol (str, raw_hash,
+    SCM symbol = scm_i_make_symbol (str, 0, raw_hash,
                                    scm_cons (SCM_BOOL_F, SCM_EOL));
 
     SCM slot = SCM_HASHTABLE_BUCKETS (symbols) [hash];
@@ -144,12 +144,10 @@ scm_i_mem2uninterned_symbol (SCM str)
 {
   const char *name = scm_i_string_chars (str);
   size_t len = scm_i_string_length (str);
+  size_t raw_hash = scm_string_hash ((const unsigned char *) name, len);
 
-  size_t raw_hash = (scm_string_hash ((const unsigned char *) name, len)/2
-                    + SCM_T_BITS_MAX/2 + 1);
-
-  return scm_i_make_symbol (str, raw_hash,
-                           scm_cons (SCM_BOOL_F, SCM_EOL));
+  return scm_i_make_symbol (str, SCM_I_F_SYMBOL_UNINTERNED, 
+                           raw_hash, scm_cons (SCM_BOOL_F, SCM_EOL));
 }
 
 SCM_DEFINE (scm_symbol_p, "symbol?", 1, 0, 0, 
index 84a8df1..357881d 100644 (file)
 #define scm_is_symbol(x)            (!SCM_IMP (x) \
                                      && (SCM_TYP7 (x) == scm_tc7_symbol))
 #define scm_i_symbol_hash(x)        ((unsigned long) SCM_CELL_WORD_2 (x))
-#define scm_i_symbol_is_interned(x) (scm_i_symbol_hash(x)<=(SCM_T_BITS_MAX/2))
+#define scm_i_symbol_is_interned(x) \
+  (!(SCM_CELL_WORD_0 (x) & SCM_I_F_SYMBOL_UNINTERNED))
+
+#define SCM_I_F_SYMBOL_UNINTERNED   0x100
 
 \f