cvsuser     03/10/13 19:47:18

  Modified:    .        string.ops
               t/op     string.t
  Log:
    * Added the missing substr variant (as compared to the functionality of
      the perl substr(). See perldoc -f substr
  
  Revision  Changes    Path
  1.8       +11 -1     parrot/string.ops
  
  Index: string.ops
  ===================================================================
  RCS file: /cvs/public/parrot/string.ops,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -w -r1.7 -r1.8
  --- string.ops        6 Sep 2003 21:04:02 -0000       1.7
  +++ string.ops        14 Oct 2003 02:47:15 -0000      1.8
  @@ -196,6 +196,8 @@
   
   ########################################
   
  +=item B<substr>(out STR, in STR, in INT)
  +
   =item B<substr>(out STR, in STR, in INT, in INT)
   
   =item B<substr>(out STR, in STR, in INT, in INT, in STR)
  @@ -205,7 +207,8 @@
   =item B<substr>(out STR, in PMC, in INT, in INT)
   
   Set $1 to the portion of $2 starting at (zero-based) character position
  -$3 and having length $4.
  +$3 and having length $4. If no length ($4) is provided, it is equivalent to
  +passing in the length of $2.
   
   Optionally pass in string $5 for replacement. If the length of $5 is
   different from the length specified in $4, then $2 will grow or shrink
  @@ -226,6 +229,13 @@
   do not create a new string in the destination register.
   
   =cut
  +
  +inline op substr(out STR, in STR, in INT) {
  +  INTVAL len;
  +  len = string_length($2);
  +  $1 = string_substr(interpreter, $2, $3, len, &$1, 0);
  +  goto NEXT();
  +}
   
   inline op substr(out STR, in STR, in INT, in INT) {
     $1 = string_substr(interpreter, $2, $3, $4, &$1, 0);
  
  
  
  1.58      +7 -1      parrot/t/op/string.t
  
  Index: string.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/op/string.t,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -w -r1.57 -r1.58
  --- string.t  7 Oct 2003 15:46:11 -0000       1.57
  +++ string.t  14 Oct 2003 02:47:18 -0000      1.58
  @@ -1,6 +1,6 @@
   #! perl -w
   
  -use Parrot::Test tests => 120;
  +use Parrot::Test tests => 121;
   use Test::More;
   
   output_is( <<'CODE', <<OUTPUT, "set_s_s|sc" );
  @@ -480,6 +480,12 @@
   abcxyzghijk
   xyz
   OUTPUT
  +
  +output_is( <<'CODE', 'PH', "3-arg substr" );
  +  set S0, "JAPH"
  +  substr S1, S0, 2
  +  print S1
  +CODE
   
   output_is( <<'CODE', '<><', "concat_s_s|sc, null onto null" );
    print "<>"
  
  
  

Reply via email to