With today's R 2.10.0(devel) I get:

> anyDuplicated(c(1,NA,3,NA,5), incomp=NA) # expect 0
Warning: stack imbalance in 'anyDuplicated', 20 then 21
Warning: stack imbalance in '.Internal', 19 then 20
Warning: stack imbalance in '{', 17 then 18
[1] 0
> anyDuplicated(c(1,NA,3,NA,3), incomp=NA) # expect 5
Warning: stack imbalance in 'anyDuplicated', 20 then 21
Warning: stack imbalance in '.Internal', 19 then 20
Warning: stack imbalance in '{', 17 then 18
[1] 0
> anyDuplicated(c(1,NA,3,NA,3), incomp=3) # expect 4
Warning: stack imbalance in 'anyDuplicated', 20 then 21
Warning: stack imbalance in '.Internal', 19 then 20
Warning: stack imbalance in '{', 17 then 18
[1] 0
> anyDuplicated(c(1,NA,3,NA,3), incomp=c(3,NA)) # exect 0
Warning: stack imbalance in 'anyDuplicated', 20 then 21
Warning: stack imbalance in '.Internal', 19 then 20
Warning: stack imbalance in '{', 17 then 18
[1] 0
> version$svn
[1] "48493"

After applying the attached patch I get

> anyDuplicated(c(1,NA,3,NA,5), incomp=NA)
[1] 0
> anyDuplicated(c(1,NA,3,NA,3), incomp=NA)
[1] 5
> anyDuplicated(c(1,NA,3,NA,3), incomp=3)
[1] 4
> anyDuplicated(c(1,NA,3,NA,3), incomp=c(3,NA))
[1] 0

Calls to UNPROTECT() were missing an a macro definition
did nothing because there were no backslashes at the ends
of lines.  I didn't check the results very carefully.

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com 

-------------------------------------------------------

Index: unique.c
===================================================================
--- unique.c    (revision 48503)
+++ unique.c    (working copy)
@@ -462,16 +462,18 @@
     for (i = 0; i < data.M; i++) h[i] = NIL;
     if(from_last)
        for (i = n-1; i >= 0; i--) {
-#define IS_DUPLICATED_CHECK
-           if(isDuplicated(x, i, &data)) {
-               Rboolean isDup = TRUE;
-               for(j = 0; j < m; j++)
-                   if(data.equal(x, i, incomp, j)) {
-                       isDup = FALSE; break;
-                   }
-               if(isDup)
-                   return ++i;
-               /* else continue */
+#define IS_DUPLICATED_CHECK \
+           if(isDuplicated(x, i, &data)) { \
+               Rboolean isDup = TRUE; \
+               for(j = 0; j < m; j++) \
+                   if(data.equal(x, i, incomp, j)) { \
+                       isDup = FALSE; break; \
+                   } \
+               if(isDup) { \
+                   UNPROTECT(1); \
+                   return ++i; \
+                } \
+               /* else continue */ \
            }
            IS_DUPLICATED_CHECK;
        }
@@ -480,6 +482,7 @@
             IS_DUPLICATED_CHECK;
     }

+    UNPROTECT(1) ;
     return 0;
 }

Index: unique.c
===================================================================
--- unique.c    (revision 48503)
+++ unique.c    (working copy)
@@ -462,16 +462,18 @@
     for (i = 0; i < data.M; i++) h[i] = NIL;
     if(from_last)
        for (i = n-1; i >= 0; i--) {
-#define IS_DUPLICATED_CHECK
-           if(isDuplicated(x, i, &data)) {
-               Rboolean isDup = TRUE;
-               for(j = 0; j < m; j++)
-                   if(data.equal(x, i, incomp, j)) {
-                       isDup = FALSE; break;
-                   }
-               if(isDup)
-                   return ++i;
-               /* else continue */
+#define IS_DUPLICATED_CHECK \
+           if(isDuplicated(x, i, &data)) { \
+               Rboolean isDup = TRUE; \
+               for(j = 0; j < m; j++) \
+                   if(data.equal(x, i, incomp, j)) { \
+                       isDup = FALSE; break; \
+                   } \
+               if(isDup) { \
+                   UNPROTECT(1); \
+                   return ++i; \
+                } \
+               /* else continue */ \
            }
            IS_DUPLICATED_CHECK;
        }
@@ -480,6 +482,7 @@
             IS_DUPLICATED_CHECK;
     }
 
+    UNPROTECT(1) ;
     return 0;
 }
 
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to