[Rcpp-commits] r3384 - in pkg/int64: . inst/include/int64 src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Nov 18 18:19:51 CET 2011


Author: romain
Date: 2011-11-18 18:19:51 +0100 (Fri, 18 Nov 2011)
New Revision: 3384

Modified:
   pkg/int64/DESCRIPTION
   pkg/int64/inst/include/int64/LongVector.h
   pkg/int64/inst/include/int64/arith.h
   pkg/int64/inst/include/int64/compare.h
   pkg/int64/inst/include/int64/math.h
   pkg/int64/inst/include/int64/summary.h
   pkg/int64/src/int64.cpp
Log:
minor issues

Modified: pkg/int64/DESCRIPTION
===================================================================
--- pkg/int64/DESCRIPTION	2011-11-18 14:20:12 UTC (rev 3383)
+++ pkg/int64/DESCRIPTION	2011-11-18 17:19:51 UTC (rev 3384)
@@ -11,3 +11,4 @@
 Depends: methods
 Suggests: RUnit
 
+

Modified: pkg/int64/inst/include/int64/LongVector.h
===================================================================
--- pkg/int64/inst/include/int64/LongVector.h	2011-11-18 14:20:12 UTC (rev 3383)
+++ pkg/int64/inst/include/int64/LongVector.h	2011-11-18 17:19:51 UTC (rev 3384)
@@ -121,7 +121,7 @@
                             int hb, lb ;
                             LONG tmp ;
                             for( int i=0; i<n; i++){
-                                if( !strcmp("NA", CHAR(STRING_ELT(x,i)) ) ){
+                                if( !strncmp("NA", CHAR(STRING_ELT(x,i)) , 2) ){
                                     SET_VECTOR_ELT( y, i, int64::internal::int2(
                                         na_hb(), na_lb()    
                                     ) ) ;

Modified: pkg/int64/inst/include/int64/arith.h
===================================================================
--- pkg/int64/inst/include/int64/arith.h	2011-11-18 14:20:12 UTC (rev 3383)
+++ pkg/int64/inst/include/int64/arith.h	2011-11-18 17:19:51 UTC (rev 3384)
@@ -131,19 +131,19 @@
 
     template <typename LONG>
     SEXP int64_arith__impl( const char* op, SEXP e1, SEXP e2){
-        if( ! strcmp(op, "+") ){
+        if( ! strncmp(op, "+", 1) ){
             return int64::internal::arith_long_long<LONG, int64::internal::plus<LONG> >( e1, e2) ;
-        } else if( ! strcmp( op, "-" ) ) {
+        } else if( ! strncmp( op, "-", 1 ) ) {
             return int64::internal::arith_long_long<LONG, int64::internal::minus<LONG> >( e1, e2) ;
-        } else if( ! strcmp( op, "*" ) ) {
+        } else if( ! strncmp( op, "*", 1) ) {
             return int64::internal::arith_long_long<LONG, int64::internal::times<LONG> >( e1, e2) ;
-        } else if( ! strcmp( op, "^" ) ) {
+        } else if( ! strncmp( op, "^", 1 ) ) {
              Rf_error( "pow not implemented for long type" ) ;
-        } else if( ! strcmp( op, "/" ) ) {
+        } else if( ! strncmp( op, "/", 1 ) ) {
             return int64::internal::arith_long_long<LONG, int64::internal::divide<LONG> >( e1, e2) ;
-        } else if( ! strcmp( op, "%%" ) ) {
+        } else if( ! strncmp( op, "%%", 2 ) ) {
             return int64::internal::arith_long_long<LONG, int64::internal::modulo<LONG> >( e1, e2) ;
-        } else if( ! strcmp( op, "%/%" ) ) {
+        } else if( ! strncmp( op, "%/%", 3 ) ) {
             return int64::internal::arith_long_long<LONG, int64::internal::int_div<LONG> >( e1, e2) ;
         } 
         Rf_error( "unknown operator" ) ;

Modified: pkg/int64/inst/include/int64/compare.h
===================================================================
--- pkg/int64/inst/include/int64/compare.h	2011-11-18 14:20:12 UTC (rev 3383)
+++ pkg/int64/inst/include/int64/compare.h	2011-11-18 17:19:51 UTC (rev 3384)
@@ -82,19 +82,19 @@
 
 template <typename LONG>
 SEXP int64_compare(const char* op, SEXP e1, SEXP e2){
-    if( ! strcmp(op, "==") ){
+    if( ! strncmp(op, "==", 2) ){
         return int64::internal::compare_long_long<LONG,  int64::internal::equals<LONG> >( e1, e2) ;
-    } else if( ! strcmp( op, "!=" ) ) {
+    } else if( ! strncmp( op, "!=", 2 ) ) {
         return int64::internal::compare_long_long<LONG,  int64::internal::not_equals<LONG> >( e1, e2) ;
-    } else if( ! strcmp( op, "<" ) ) {
+    } else if( ! strncmp( op, "<=", 2 ) ) {
+        return int64::internal::compare_long_long<LONG,  int64::internal::lower_than_or_equal<LONG> >( e1, e2) ;
+    } else if( ! strncmp( op, ">=", 2 ) ) {
+        return int64::internal::compare_long_long<LONG,  int64::internal::greater_than_or_equal<LONG> >( e1, e2) ;
+    } else if( ! strncmp( op, "<", 1 ) ) {
         return int64::internal::compare_long_long<LONG,  int64::internal::lower_than<LONG> >( e1, e2) ;
-    } else if( ! strcmp( op, ">" ) ) {
+    } else if( ! strncmp( op, ">", 1 ) ) {
          return int64::internal::compare_long_long<LONG,  int64::internal::greater_than<LONG> >( e1, e2) ;
-    } else if( ! strcmp( op, "<=" ) ) {
-        return int64::internal::compare_long_long<LONG,  int64::internal::lower_than_or_equal<LONG> >( e1, e2) ;
-    } else if( ! strcmp( op, ">=" ) ) {
-        return int64::internal::compare_long_long<LONG,  int64::internal::greater_than_or_equal<LONG> >( e1, e2) ;
-    } 
+    }
     Rf_error( "unknown operator" ) ;
     return R_NilValue ;
 }

Modified: pkg/int64/inst/include/int64/math.h
===================================================================
--- pkg/int64/inst/include/int64/math.h	2011-11-18 14:20:12 UTC (rev 3383)
+++ pkg/int64/inst/include/int64/math.h	2011-11-18 17:19:51 UTC (rev 3384)
@@ -144,21 +144,21 @@
 template <typename LONG>
 SEXP math( const char* op, SEXP x ){
     
-    if( !strcmp( op, "abs" ) ){
+    if( !strncmp( op, "abs", 3 ) ){
         return abs<LONG>(x) ;
-    } else if( !strcmp(op, "sign") ) {
+    } else if( !strncmp(op, "sign", 4) ) {
         return sign<LONG>(x) ;
-    } else if( !strcmp( op, "trunc" ) ){
+    } else if( !strncmp( op, "trunc", 5 ) ){
         return x ;
-    } else if( !strcmp( op, "floor" ) ){
+    } else if( !strncmp( op, "floor", 5) ){
         return x ;   
-    } else if( !strcmp( op, "cummax" ) ){
+    } else if( !strncmp( op, "cummax", 6 ) ){
         return cummax<LONG>( x ) ;
-    } else if( !strcmp( op, "cummin" ) ){
+    } else if( !strncmp( op, "cummin", 6 ) ){
         return cummin<LONG>( x ) ;
-    } else if( !strcmp( op, "cumprod" ) ){
+    } else if( !strncmp( op, "cumprod", 7 ) ){
         return cumprod<LONG>( x ) ;
-    } else if( !strcmp( op, "cumsum" ) ){
+    } else if( !strncmp( op, "cumsum", 6 ) ){
         return cumsum<LONG>( x ) ;   
     }
     

Modified: pkg/int64/inst/include/int64/summary.h
===================================================================
--- pkg/int64/inst/include/int64/summary.h	2011-11-18 14:20:12 UTC (rev 3383)
+++ pkg/int64/inst/include/int64/summary.h	2011-11-18 17:19:51 UTC (rev 3384)
@@ -166,19 +166,19 @@
 SEXP int64_summary(const char* op, SEXP x){
     int64::LongVector<LONG> data( x ) ;
     
-    if( ! strcmp(op, "min") ){
+    if( ! strncmp(op, "min", 3) ){
         return int64::internal::summary__min<LONG>( data ) ;
-    } else if( !strcmp(op, "max") ){
+    } else if( !strncmp(op, "max", 3) ){
         return int64::internal::summary__max<LONG>( data ) ;
-    } else if( !strcmp(op, "range" ) ){
+    } else if( !strncmp(op, "range", 5 ) ){
         return int64::internal::summary__range<LONG>( data ) ;
-    } else if( !strcmp(op, "prod") ){
+    } else if( !strncmp(op, "prod", 4) ){
         return int64::internal::summary__prod<LONG>( data ) ;
-    } else if( !strcmp(op, "sum" ) ) {
+    } else if( !strncmp(op, "sum", 3 ) ) {
         return int64::internal::summary__sum<LONG>( data ) ;
-    } else if( !strcmp(op, "any" ) ){
+    } else if( !strncmp(op, "any", 3 ) ){
         return int64::internal::summary__any<LONG>( data ) ;
-    } else if( !strcmp(op, "all") ){
+    } else if( !strncmp(op, "all", 3) ){
         return int64::internal::summary__all<LONG>( data ) ;
     }
     Rf_error( "unknown operator" ) ;

Modified: pkg/int64/src/int64.cpp
===================================================================
--- pkg/int64/src/int64.cpp	2011-11-18 14:20:12 UTC (rev 3383)
+++ pkg/int64/src/int64.cpp	2011-11-18 17:19:51 UTC (rev 3384)
@@ -130,18 +130,18 @@
 extern "C" SEXP int64_limits( SEXP type_ ){
     const char* type = CHAR(STRING_ELT(type_, 0) ) ;
     
-    if( !strcmp( type, "integer" ) ){                                      
+    if( !strncmp( type, "integer", 7 ) ){                                      
         SEXP res = PROTECT( Rf_allocVector(INTSXP, 2 ) ) ;
         INTEGER(res)[0] = std::numeric_limits<int>::min() + 1 ;
         INTEGER(res)[1] = std::numeric_limits<int>::max() ;
         UNPROTECT(1) ;
         return res ;
-    } else if( ! strcmp( type, "int64" ) ){
+    } else if( ! strncmp( type, "int64", 5 ) ){
         return int64::internal::new_long_2<int64_t>( 
             int64::internal::long_traits<int64_t>::min() , 
             int64::internal::long_traits<int64_t>::max() 
             ) ;
-    } else if( !strcmp( type, "uint64" ) ){
+    } else if( !strncmp( type, "uint64", 6 ) ){
         return int64::internal::new_long_2<uint64_t>( 
             int64::internal::long_traits<uint64_t>::min(), 
             int64::internal::long_traits<uint64_t>::max()
@@ -183,7 +183,7 @@
     
     SEXP res = PROTECT( Rf_allocVector( STRSXP, n ) ) ;
     for( int i=0; i<n; i++){
-        if( !strcmp( CHAR(STRING_ELT(s_, i)), "NA" ) || digits[i] > len[i] ){
+        if( !strncmp( CHAR(STRING_ELT(s_, i)), "NA", 2 ) || digits[i] > len[i] ){
             SET_STRING_ELT( res, i, STRING_ELT( s_, i ) ) ;    
         } else {
             s = CHAR(STRING_ELT(s_, i ));



More information about the Rcpp-commits mailing list