[R] Strange behavior with saved character vectors containing a slash

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Thu Oct 4 13:22:25 CEST 2001


"David Kane  <David Kane" <a296180 at mica.fmr.com> writes:

> I am seeing some strange behavior using save on a character vector containing a
> slash. If this is a bug, I will happily submit it (as a single entry! ;-) ) to
> r-bugs. Here is an example involving "VIA\B".
> 

It's a bug alright. In saveload.c we have

        if (x[i] <= 32 || x[i] > 126) {
            switch(x[i]) {
            case '\n': fprintf(fp, "\\n");  break;
            case '\t': fprintf(fp, "\\t");  break;
            case '\v': fprintf(fp, "\\v");  break;
            case '\b': fprintf(fp, "\\b");  break;
            case '\r': fprintf(fp, "\\r");  break;
            case '\f': fprintf(fp, "\\f");  break;
            case '\a': fprintf(fp, "\\a");  break;
            case '\\': fprintf(fp, "\\\\"); break;
            case '\?': fprintf(fp, "\\?");  break;
            case '\'': fprintf(fp, "\\'");  break;
            case '\"': fprintf(fp, "\\\""); break;
                /* cannot print char in octal mode -> cast to unsigned
                   char first */
            default  : fprintf(fp, "\\%03o", (unsigned char) x[i]); break;
            }
        }

Which *looks* like it handles the backslash, but doesn't....
-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list