Procházet zdrojové kódy

Fix bug wrong interpretation of return value of string.find that return -1 when not found.

mingodad před 10 roky
rodič
revize
debc0f18a0
2 změnil soubory, kde provedl 4 přidání a 4 odebrání
  1. 2 2
      SquiLu/samples/csv2array.nut
  2. 2 2
      SquiLu/samples/test-replace.nut

+ 2 - 2
SquiLu/samples/csv2array.nut

@@ -13,13 +13,13 @@ function fromCSV (s){
 //print(f, f.replace("\"\"", "\""));
       t.push(f.replace("\"\"", "\""));
        local nextc = s.find(",", i);
-       if(!nextc) nextc=slen-1;
+       if(nextc < 0) nextc=slen-1;
       fieldstart = nextc + 1;
     }  
     else                // unquoted; find next comma
     {
       local nexti = s.find(",", fieldstart);
-      if(!nexti) nexti = slen-1;
+      if(nexti < 0) nexti = slen-1;
 //print("nn", fieldstart, nexti, s.slice(fieldstart, nexti))
       t.push(s.slice(fieldstart, nexti));
       fieldstart = nexti + 1;

+ 2 - 2
SquiLu/samples/test-replace.nut

@@ -31,13 +31,13 @@ function fromCSV (s){
 //print(f, f.replace("\"\"", "\""));
       t.push(f.replace("\"\"", "\""));
        local nextc = s.find(",", i);
-       if(!nextc) nextc=slen-1;
+       if(nextc < 0) nextc=slen-1;
       fieldstart = nextc + 1;
     }  
     else                // unquoted; find next comma
     {
       local nexti = s.find(",", fieldstart);
-      if(!nexti) nexti = slen-1;
+      if(nexti < 0) nexti = slen-1;
 //print("nn", fieldstart, nexti, s.slice(fieldstart, nexti))
       t.push(s.slice(fieldstart, nexti));
       fieldstart = nexti + 1;