patchGNU Octave - Patches: patch #9912, (bug#57867):strrep:unexpected...

 
 

patch #9912: (bug#57867):strrep:unexpected substitution behavior of char array

Submitter:  Abdelrhman_Adel_Moawad <abdelrhman_adel>
Submitted:  Mon 23 Mar 2020 06:49:25 PM UTC
   
 
Category:  Core : new feature Priority:  5 - Normal
Status:  Duplicate Privacy:  Public
Assigned to:  None Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 23 Mar 2020 06:52:31 PM UTC, comment #1: 

Once again, you do not need to open a new patch tracker item, please just attach patches to the bug report. Closing as a duplicate.

Mike Miller <mtmiller>
Group Member
Mon 23 Mar 2020 06:49:25 PM UTC, original submission:  

# HG change set patch
# User Abdelrhman Adel <abduadell37@gmail.com>
# Date 1584986437 -7200
#      Mon Mar 23 20:00:37 2020 +0200
# Node ID 8b4e0a4e54bae11004b8e3fa49254bd9d17fc421
# Parent  965f92bb5b60efc7902b9de091d6375028166a60
(bug #57867):strrep:unexpected substitution behavior of character
strfind.cc:(strrep):modified to change char array to cell string


the changed part :

 if (argstr.is_string ())
      retval = qs_replace (argstr.char_array_value (), pat, rep,
                             table, overlaps);

to be :

 if (argstr.is_string ())
        {
          const Cell com = Fcellstr(argstr);
          const Cell argsc = com.cellstr_value ();
          Cell retc (argsc.dims ());
          octave_idx_type ns = argsc.numel ();

          for (octave_idx_type i = 0; i < ns; i++)
            {
              octave_value argse = argsc(i);
              if (argse.is_string ())
                retc(i) = qs_replace (argse.char_array_value (), pat, rep,table, overlaps);
              else
                error ("strrep: each element of S must be a string");
            }

          retval = retc;
        }

diff -r 965f92bb5b60 -r 8b4e0a4e54ba libinterp/corefcn/strfind.cc
--- a/libinterp/corefcn/strfind.cc      Mon Mar 23 08:36:03 2020 +0200
+++ b/libinterp/corefcn/strfind.cc      Mon Mar 23 20:00:37 2020 +0200
@@ -429,7 +429,7 @@ strrep ("This is a test string", "is", "
 
   octave_value retval;
 
   octave_value argstr = args(0);
   octave_value argpat = args(1);
   octave_value argrep = args(2);
 
@@ -441,9 +441,26 @@ strrep ("This is a test string", "is", "
       OCTAVE_LOCAL_BUFFER (octave_idx_type, table, TABSIZE);
       qs_preprocess (pat, table);
 
-if (argstr.is_string ())
-        retval = qs_replace (argstr.char_array_value (), pat, rep,
-                             table, overlaps);
+
+     if (argstr.is_string ())
+        {
+          const Cell com = Fcellstr(argstr);
+          const Cell argsc = com.cellstr_value ();
+          Cell retc (argsc.dims ());
+          octave_idx_type ns = argsc.numel ();
+
+          for (octave_idx_type i = 0; i < ns; i++)
+            {
+              octave_value argse = argsc(i);
+              if (argse.is_string ())
+                retc(i) = qs_replace (argse.char_array_value (), pat, rep,
+                                      table, overlaps);
+              else
+                error ("strrep: each element of S must be a string");
+            }
+
+          retval = retc;
+        }       
 
       else if (argstr.iscell ())
         {
(END)

Abdelrhman_Adel_Moawad <abdelrhman_adel>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Carbon-Copy List
  • -email is unavailable- added by abdelrhman_adel (Submitted the item)
  • -email is unavailable- added by abdelrhman_adel (I wish that's the required )
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-03-23 mtmiller StatusNone Duplicate
        Open/ClosedOpen Closed
        Dependencies- Depends on bugs #57867
        Dependencies- Depends on patch #9910
    2020-03-23 abdelrhman_adel Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code