You are not logged in.
Dear AB,
it seems that there is a bug in your recently added function "RenameInCSV": it does not rename the first item in the CSV list.
Short test code to reproduce this issue:
program TestRenameInCSV;
{$APPTYPE CONSOLE}
{$I Synopse.inc} // define HASINLINE USETYPEINFO CPU32 CPU64 OWNNORMTOUPPER
uses
SysUtils, SynCommons;
var
csv: RawUTF8;
begin
csv := 'old1,old2,old3';
writeln(csv,' 1 ',RenameInCSV('old1','new1',csv),' ',csv);
writeln(csv,' 2 ',RenameInCSV('old2','new2',csv),' ',csv);
writeln(csv,' 3 ',RenameInCSV('old3','new3',csv),' ',csv);
writeln(csv,' 3 ',RenameInCSV('old3','new3',csv),' ',csv);
writeln(csv,' 4 ',RenameInCSV('old4','new4',csv),' ',csv);
csv := '';
readln;
end.
The result is:
old1,old2,old3 1 FALSE old1,old2,old3
old1,old2,old3 2 TRUE old1,new2,old3
old1,new2,old3 3 TRUE old1,new2,new3
old1,new2,new3 3 FALSE old1,new2,new3
old1,new2,new3 4 FALSE old1,new2,new3
As you can see, the first item "old1" is not renamed as expected.
Edit: And if the csv list contains the same value more than once, only the first found value will be renamed.
Paul
Last edited by PBa (2018-01-05 13:44:52)
Offline
Corrected by https://synopse.info/fossil/info/3cb88e1ba2
Thanks for the quick catch!
And the value is expected to appear only once in the list, by definition.
Offline