OSSP CVS Repository

ossp - Check-in [1385]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1385
Date: 2001-Nov-20 16:46:35 (local)
2001-Nov-20 15:46:35 (UTC)
User:simons
Branch:
Comment: Changed semantics of the :o operation so that the specified end-offset is included in the result. Updated documentation and test cases appropriately.
Tickets:
Inspections:
Files:
ossp-pkg/var/var.c      1.35 -> 1.36     1 inserted, 4 deleted
ossp-pkg/var/var.pod      1.7 -> 1.8     7 inserted, 12 deleted
ossp-pkg/var/var_test.c      1.13 -> 1.14     4 inserted, 6 deleted

ossp-pkg/var/var.c 1.35 -> 1.36

--- var.c        2001/11/20 15:36:42     1.35
+++ var.c        2001/11/20 15:46:35     1.36
@@ -893,7 +893,6 @@
         if (!tokenbuf_assign(&res, p, data->end - p))
             return VAR_ERR_OUT_OF_MEMORY;
     } else {                    /* OK, then use num2. */
-
         if (isrange) {
             if ((p + num2) > data->end)
                 return VAR_ERR_RANGE_OUT_OF_BOUNDS;
@@ -904,9 +903,7 @@
                 return VAR_ERR_OFFSET_LOGIC;
             if ((data->begin + num2) > data->end)
                 return VAR_ERR_RANGE_OUT_OF_BOUNDS;
-            if (!tokenbuf_assign(&res, p, num2 - num1))
-//FIXME THL: I expect start-end *inclusive*
-//FIXME THL: I expect start,len len characters not len-1
+            if (!tokenbuf_assign(&res, p, num2 - num1 + 1))
                 return VAR_ERR_OUT_OF_MEMORY;
         }
     }


ossp-pkg/var/var.pod 1.7 -> 1.8

--- var.pod      2001/11/20 13:08:17     1.7
+++ var.pod      2001/11/20 15:46:35     1.8
@@ -531,22 +531,17 @@
 This operation will replace the contents of $name with "word" if $name
 is not empty. Otherwise, it will expand to the contents of $name.
 
-=item ${name:o<start>-<end>}
+=item ${name:o<start>,<end>}
 
 This operation will cut the string starting at position "start" to
 ending position "end" out of the contents of $name and return that.
-Please note that the character at position "end" is not included in
-the result, "end - 1" is the last character position returned.
-${name:o3,4}, for instance, will return the substring from position 3
-to position 4 -- that is exactly one character. Also, please note that
-start positions begin at zero (0)! If the "end" parameter is left out,
-as in ${name:o3,}, the operation will return the string starting at
-position 3 until the end.
+Please note that the character at position "end" is included in the
+result; ${name:o3,4} for instance, will return a two-character string.
+Also, please note that start positions begin at zero (0)! If the "end"
+parameter is left out, as in ${name:o3,}, the operation will return
+the string starting at position 3 until the end.
 
-//FIXME THL: I expect start-end *inclusive*
-//FIXME THL: I expect start,len len characters not len-1
-
-=item ${name:o<start>,<length>}
+=item ${name:o<start>-<length>}
 
 This operation will cut the range of "start" to "end" out of the
 contents of $name and return that. ${name:o3-4} means, for instance,


ossp-pkg/var/var_test.c 1.13 -> 1.14

--- var_test.c   2001/11/20 11:49:24     1.13
+++ var_test.c   2001/11/20 15:46:35     1.14
@@ -77,10 +77,10 @@
         {"${HOME:s/E/bla/ti}", "/hombla/regression-tests"},
         {"${HOME:s/E/bla/tig}", "/hombla/rblagrblassion-tblasts"},
         {"${HOME:o1-5}", "home/"},
-        {"${HOME:o1,5}", "home"},
+        {"${HOME:o1,5}", "home/"},
         {"${HOME:o5,}", "/regression-tests"},
         {"${HOME:o5-}", "/regression-tests"},
-        {"${HOME:o7,13}", "egress"},
+        {"${HOME:o7,13}", "egressi"},
         {"${HOME:y/a-z/A-YZ/}", "/HOME/REGRESSION-TESTS"},
         {"${HOME:y/e-g/a-c/}", "/homa/racrassion-tasts"},
         {"${FOO:p/15/../l}", "os............."},
@@ -94,10 +94,8 @@
         {"${HOME:s/g(res)s/x\\1x/g}", "/home/rexresxion-tests"},
         {"${HOME:s/(s+)/_\\1_/g}", "/home/regre_ss_ion-te_s_t_s_"},
         {"${HOME:s/\\x65/\\x45/g}", "/homE/rEgrEssion-tEsts"},
-        {"${HOME:s/(s*)/x\\1X/g}",
-         "xXxXxXxXxXxXxXxXxXxXxXxssXxXxXxXxXxXxXxsXxXxsX"},
-        {"${HOME:s/./\\\\/g}",
-         "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"}
+        {"${HOME:s/(s*)/x\\1X/g}", "xXxXxXxXxXxXxXxXxXxXxXxssXxXxXxXxXxXxXxsXxXxsX"},
+        {"${HOME:s/./\\\\/g}", "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"}
     };
     char *tmp;
     size_t tmp_len;

CVSTrac 2.0.1