[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-patch-tracker] [patch #9912] (bug#57867):strrep:unexpected subst
From: |
Abdelrhman_Adel_Moawad |
Subject: |
[Octave-patch-tracker] [patch #9912] (bug#57867):strrep:unexpected substitution behavior of char array |
Date: |
Mon, 23 Mar 2020 14:49:27 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0 |
URL:
<https://savannah.gnu.org/patch/?9912>
Summary: (bug#57867):strrep:unexpected substitution behavior
of char array
Project: GNU Octave
Submitted by: abdelrhman_adel
Submitted on: Mon 23 Mar 2020 06:49:25 PM UTC
Category: Core : new feature
Priority: 5 - Normal
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
# HG change set patch
# User Abdelrhman Adel <address@hidden>
# 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)
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/patch/?9912>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-patch-tracker] [patch #9912] (bug#57867):strrep:unexpected substitution behavior of char array,
Abdelrhman_Adel_Moawad <=