summaryrefslogtreecommitdiff
path: root/srfi/srfi-14.c
diff options
context:
space:
mode:
authorGary Houston <ghouston@arglist.com>2001-07-22 22:01:50 +0000
committerGary Houston <ghouston@arglist.com>2001-07-22 22:01:50 +0000
commit42b54c05a9ba541cfe15eb071ad96b42de19d908 (patch)
treec383537ee952a6e4b81af9a8cda03292b0ff1470 /srfi/srfi-14.c
parentd1bc66027ef9081ab86bb7a1e5061700df022e87 (diff)
downloadguile-42b54c05a9ba541cfe15eb071ad96b42de19d908.tar.gz
(scm_char_set_xor): bug fix: characters should only be included if
they occur in exactly one argument, but were included if they occured an odd number of times >= 3, e.g, in (char-set-xor a a a) where a is (char-set #\a). fix it with a "mask" array.
Diffstat (limited to 'srfi/srfi-14.c')
-rw-r--r--srfi/srfi-14.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/srfi/srfi-14.c b/srfi/srfi-14.c
index 798f75bb5..8d628252a 100644
--- a/srfi/srfi-14.c
+++ b/srfi/srfi-14.c
@@ -1155,16 +1155,18 @@ SCM_DEFINE (scm_char_set_xor, "char-set-xor", 0, 0, 1,
{
long * p;
int argnum = 2;
+ long mask[LONGS_PER_CHARSET];
+ int k;
+ memset (mask, 0, sizeof mask);
res = scm_char_set_copy (SCM_CAR (rest));
p = (long *) SCM_SMOB_DATA (res);
rest = SCM_CDR (rest);
while (SCM_CONSP (rest))
{
- int k;
SCM cs = SCM_CAR (rest);
- long *cs_data;
+ long *cs_data;
SCM_VALIDATE_SMOB (argnum, cs, charset);
argnum++;
@@ -1172,8 +1174,14 @@ SCM_DEFINE (scm_char_set_xor, "char-set-xor", 0, 0, 1,
rest = SCM_CDR (rest);
for (k = 0; k < LONGS_PER_CHARSET; k++)
- p[k] ^= cs_data[k];
+ {
+ mask[k] |= p[k] & cs_data[k];
+ p[k] ^= cs_data[k];
+ }
}
+ /* avoid including characters that occur an odd number of times >= 3. */
+ for (k = 0; k < LONGS_PER_CHARSET; k++)
+ p[k] &= ~mask[k];
}
return res;
}