guile-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

guile/guile-core/srfi ChangeLog srfi-14.c srfi-...


From: Martin Grabmueller
Subject: guile/guile-core/srfi ChangeLog srfi-14.c srfi-...
Date: Mon, 16 Jul 2001 22:37:25 -0700

CVSROOT:        /cvs
Module name:    guile
Branch:         branch_release-1-6
Changes by:     Martin Grabmueller <address@hidden>     01/07/16 22:37:25

Modified files:
        guile-core/srfi: ChangeLog srfi-14.c srfi-14.h 

Log message:
        * srfi-14.c: Fix for bug caused by brain-malfunctioning on my
        side.  Bit sets were handled wrong because I couldn't tell bit
        counts from byte counts.  Also, the bit array should be 256 / 8
        bytes long.  Thank you, Gary!
        
        Removed unnecessary protoype for scm_char_set_copy.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/guile/guile-core/srfi/ChangeLog.diff?cvsroot=OldCVS&only_with_tag=branch_release-1-6&tr1=1.44.2.9&tr2=1.44.2.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/guile/guile-core/srfi/srfi-14.c.diff?cvsroot=OldCVS&only_with_tag=branch_release-1-6&tr1=1.9.2.7&tr2=1.9.2.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/guile/guile-core/srfi/srfi-14.h.diff?cvsroot=OldCVS&only_with_tag=branch_release-1-6&tr1=1.3.2.2&tr2=1.3.2.3&r1=text&r2=text

Patches:
Index: guile/guile-core/srfi/ChangeLog
diff -u guile/guile-core/srfi/ChangeLog:1.53 
guile/guile-core/srfi/ChangeLog:1.54
--- guile/guile-core/srfi/ChangeLog:1.53        Mon Jul 16 15:30:25 2001
+++ guile/guile-core/srfi/ChangeLog     Mon Jul 16 22:35:51 2001
@@ -1,3 +1,12 @@
+2001-07-17  Martin Grabmueller  <address@hidden>
+
+       * srfi-14.c: Fix for bug caused by brain-malfunctioning on my
+       side.  Bit sets were handled wrong because I couldn't tell bit
+       counts from byte counts.  Also, the bit array should be 256 / 8
+       bytes long.  Thank you, Gary!   
+
+       Removed unnecessary protoype for scm_char_set_copy.
+
 2001-07-16  Gary Houston  <address@hidden>
 
        * srfi-14.scm: export string->char-set!, not string-char-set!.
Index: guile/guile-core/srfi/srfi-14.c
diff -u guile/guile-core/srfi/srfi-14.c:1.16 
guile/guile-core/srfi/srfi-14.c:1.17
--- guile/guile-core/srfi/srfi-14.c:1.16        Mon Jul 16 15:30:25 2001
+++ guile/guile-core/srfi/srfi-14.c     Mon Jul 16 22:35:51 2001
@@ -50,10 +50,10 @@
 
 #include "srfi-14.h"
 
-#define SCM_CHARSET_SET(cs, idx) (((long *) SCM_SMOB_DATA (cs))[(idx) / sizeof 
(long)] |= (1 << ((idx) % sizeof (long))))
 
-SCM scm_char_set_copy (SCM cs);
+#define SCM_CHARSET_SET(cs, idx) (((long *) SCM_SMOB_DATA (cs))[(idx) / 
SCM_BITS_PER_LONG] |= (1 << ((idx) % SCM_BITS_PER_LONG)))
 
+
 /* Smob type code for character sets.  */
 int scm_tc16_charset = 0;
 
@@ -94,8 +94,8 @@
 {
   long * p;
   
-  p = scm_must_malloc (SCM_CHARSET_SIZE / sizeof (char), func_name);
-  memset (p, 0, SCM_CHARSET_SIZE / sizeof (char));
+  p = scm_must_malloc (SCM_CHARSET_SIZE / 8, func_name);
+  memset (p, 0, SCM_CHARSET_SIZE / 8);
   SCM_RETURN_NEWSMOB (scm_tc16_charset, p);
 }
 
@@ -131,8 +131,7 @@
       csi_data = (long *) SCM_SMOB_DATA (csi);
       if (cs1_data == NULL)
        cs1_data = csi_data;
-      else if (memcmp (cs1_data, csi_data,
-                      SCM_CHARSET_SIZE / sizeof (char)) != 0)
+      else if (memcmp (cs1_data, csi_data, SCM_CHARSET_SIZE / 8) != 0)
        return SCM_BOOL_F;
       char_sets = SCM_CDR (char_sets);
     }
@@ -476,7 +475,7 @@
       SCM_VALIDATE_CHAR_COPY (argnum, SCM_CAR (rest), c);
       argnum++;
       rest = SCM_CDR (rest);
-      p[c / sizeof (long)] |= 1 << (c % sizeof (long));
+      p[c / SCM_BITS_PER_LONG] |= 1 << (c % SCM_BITS_PER_LONG);
     }
   return cs;
 }
@@ -510,7 +509,7 @@
       SCM_VALIDATE_CHAR_COPY (0, chr, c);
       list = SCM_CDR (list);
 
-      p[c / sizeof (long)] |= 1 << (c % sizeof (long));
+      p[c / SCM_BITS_PER_LONG] |= 1 << (c % SCM_BITS_PER_LONG);
     }
   return cs;
 }
@@ -537,7 +536,7 @@
       SCM_VALIDATE_CHAR_COPY (0, chr, c);
       list = SCM_CDR (list);
 
-      p[c / sizeof (long)] |= 1 << (c % sizeof (long));
+      p[c / SCM_BITS_PER_LONG] |= 1 << (c % SCM_BITS_PER_LONG);
     }
   return base_cs;
 }
@@ -569,7 +568,7 @@
   while (k < SCM_STRING_LENGTH (str))
     {
       int c = s[k++];
-      p[c / sizeof (long)] |= 1 << (c % sizeof (long));
+      p[c / SCM_BITS_PER_LONG] |= 1 << (c % SCM_BITS_PER_LONG);
     }
   return cs;
 }
@@ -594,7 +593,7 @@
   while (k < SCM_STRING_LENGTH (str))
     {
       int c = s[k++];
-      p[c / sizeof (long)] |= 1 << (c % sizeof (long));
+      p[c / SCM_BITS_PER_LONG] |= 1 << (c % SCM_BITS_PER_LONG);
     }
   return base_cs;
 }
@@ -629,7 +628,7 @@
          SCM res = scm_call_1 (pred, SCM_MAKE_CHAR (k));
 
          if (!SCM_FALSEP (res))
-           p[k / sizeof (long)] |= 1 << (k % sizeof (long));
+           p[k / SCM_BITS_PER_LONG] |= 1 << (k % SCM_BITS_PER_LONG);
        }
     }
   return ret;
@@ -658,7 +657,7 @@
          SCM res = scm_call_1 (pred, SCM_MAKE_CHAR (k));
 
          if (!SCM_FALSEP (res))
-           p[k / sizeof (long)] |= 1 << (k % sizeof (long));
+           p[k / SCM_BITS_PER_LONG] |= 1 << (k % SCM_BITS_PER_LONG);
        }
     }
   return base_cs;
@@ -712,7 +711,7 @@
   p = (long *) SCM_SMOB_DATA (cs);
   while (clower < cupper)
     {
-      p[clower / sizeof (long)] |= 1 << (clower % sizeof (long));
+      p[clower / SCM_BITS_PER_LONG] |= 1 << (clower % SCM_BITS_PER_LONG);
       clower++;
     }
   return cs;
@@ -755,7 +754,7 @@
   p = (long *) SCM_SMOB_DATA (base_cs);
   while (clower < cupper)
     {
-      p[clower / sizeof (long)] |= 1 << (clower % sizeof (long));
+      p[clower / SCM_BITS_PER_LONG] |= 1 << (clower % SCM_BITS_PER_LONG);
       clower++;
     }
   return base_cs;
@@ -928,7 +927,7 @@
       SCM_VALIDATE_CHAR_COPY (1, chr, c);
       rest = SCM_CDR (rest);
 
-      p[c / sizeof (long)] |= 1 << (c % sizeof (long));
+      p[c / SCM_BITS_PER_LONG] |= 1 << (c % SCM_BITS_PER_LONG);
     }
   return cs;
 }
@@ -956,7 +955,7 @@
       SCM_VALIDATE_CHAR_COPY (1, chr, c);
       rest = SCM_CDR (rest);
 
-      p[c / sizeof (long)] &= ~(1 << (c % sizeof (long)));
+      p[c / SCM_BITS_PER_LONG] &= ~(1 << (c % SCM_BITS_PER_LONG));
     }
   return cs;
 }
@@ -983,7 +982,7 @@
       SCM_VALIDATE_CHAR_COPY (1, chr, c);
       rest = SCM_CDR (rest);
 
-      p[c / sizeof (long)] |= 1 << (c % sizeof (long));
+      p[c / SCM_BITS_PER_LONG] |= 1 << (c % SCM_BITS_PER_LONG);
     }
   return cs;
 }
@@ -1010,7 +1009,7 @@
       SCM_VALIDATE_CHAR_COPY (1, chr, c);
       rest = SCM_CDR (rest);
 
-      p[c / sizeof (long)] &= ~(1 << (c % sizeof (long)));
+      p[c / SCM_BITS_PER_LONG] &= ~(1 << (c % SCM_BITS_PER_LONG));
     }
   return cs;
 }
@@ -1129,7 +1128,7 @@
 
 SCM_DEFINE (scm_char_set_xor, "char-set-xor", 1, 0, 1,
            (SCM cs1, SCM rest),
-           "Return the exclusive--or of all argument character sets.")
+           "Return the exclusive-or of all argument character sets.")
 #define FUNC_NAME s_scm_char_set_xor
 {
   int c = 2;
@@ -1296,7 +1295,7 @@
 
 SCM_DEFINE (scm_char_set_xor_x, "char-set-xor!", 1, 0, 1,
            (SCM cs1, SCM rest),
-           "Return the exclusive--or of all argument character sets.")
+           "Return the exclusive-or of all argument character sets.")
 #define FUNC_NAME s_scm_char_set_xor_x
 {
   int c = 2;
@@ -1369,8 +1368,8 @@
 
   if (!initialized)
     {
-      scm_tc16_charset = scm_make_smob_type ("character-set", 
-                                            SCM_CHARSET_SIZE / sizeof (char));
+      scm_tc16_charset = scm_make_smob_type ("character-set",
+                                            SCM_CHARSET_SIZE / 8);
       scm_set_smob_free (scm_tc16_charset, charset_free);
       scm_set_smob_print (scm_tc16_charset, charset_print);
       initialized = 1;
Index: guile/guile-core/srfi/srfi-14.h
diff -u guile/guile-core/srfi/srfi-14.h:1.5 guile/guile-core/srfi/srfi-14.h:1.6
--- guile/guile-core/srfi/srfi-14.h:1.5 Wed Jul 11 15:00:52 2001
+++ guile/guile-core/srfi/srfi-14.h     Mon Jul 16 22:35:51 2001
@@ -48,8 +48,15 @@
 
 #define SCM_CHARSET_SIZE 256
 
+/* We expect 8-bit bytes here.  Shoule be no problem in the year
+   2001.  */
+#ifndef SCM_BITS_PER_LONG
+# define SCM_BITS_PER_LONG (sizeof (long) * 8)
+#endif
+
 #define SCM_CHARSET_GET(cs, idx) (((long *) SCM_SMOB_DATA (cs))\
-                     [(idx) / sizeof (long)] & (1 << ((idx) % sizeof (long))))
+                                  [(idx) / SCM_BITS_PER_LONG] &\
+                                  (1 << ((idx) % SCM_BITS_PER_LONG)))
 
 #define SCM_CHARSETP(x) (!SCM_IMP (x) && (SCM_TYP16 (x) == scm_tc16_charset))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]