Page 1 of 1
puss in a string bug?
Posted: Mon Jul 09, 2007 1:59 pm
by Dmi
Code: Select all
dmi@stone:~$ newlisp
newLISP v.9.1.7 on Linux, execute 'newlisp -h' for more info.
> (set 'a "abc")
"abc"
> (push "-" a -1)
"-"
> a
"abc-" ;right
> (set 'a "abc")
"abc"
> (push "-" a -2)
"-"
> a
"ab-c" ;right
> (set 'a "abc")
"abc"
> (push "-" a -3)
"-"
> (set 'a "abc")
"abc" ;wrong
> (set 'a "abcd")
"abcd"
> (push "-" a -3)
"-"
> a
"ab-cd" ;right
> > (set 'a "abc")
"abc"
> (push "-" a -4)
"-"
> a
"-abc" ;right
>
Locale is ru_RU.KOI8-R (single byte).
I suspect that that this is something like unicode tricks...
Re: puss in a string bug?
Posted: Mon Jul 09, 2007 2:22 pm
by rickyboy
Dmi wrote:Code: Select all
> (set 'a "abc")
"abc"
> (push "-" a -3)
"-"
> (set 'a "abc")
"abc" ;wrong
I don't see how this could be wrong. Maybe you are missing a step? Like showing the value of
a after
(push "-" a -3)?
Posted: Mon Jul 09, 2007 2:32 pm
by Dmi
:-) Yes, thanks Rick!
But now I have another issue:
Code: Select all
dmi@stone:~$ newlisp
newLISP v.9.1.7 on Linux, execute 'newlisp -h' for more info.
> (set 'a "abc")
"abc"
> (push "-" a -3)
"-"
> a
"-abc"
> (set 'a "abc")
"abc"
> (push "-" a -2)
"-"
> a
"ab-c" ; I think should be "a-bc"
>
Posted: Mon Jul 09, 2007 2:50 pm
by Lutz
-1 is for the last position, -2 for the scond last etc.
if the position is greater than the length of the string it will go always at the beginning:
Code: Select all
> (set 'a "abc") (push "-" a -1) a
"abc"
"-"
"abc-"
> (set 'a "abc") (push "-" a -2) a
"abc"
"-"
"ab-c"
> (set 'a "abc") (push "-" a -3) a
"abc"
"-"
"-abc"
> (set 'a "abc") (push "-" a -4) a
"abc"
"-"
"-abc"
>
only on arrays overshooting the index will given an error message, on strings it will just go to the first or last position.
See here:
http://newlisp.org/newlisp_manual.html#indexing
in the first paragraph
Lutz
Posted: Mon Jul 09, 2007 3:10 pm
by cormullion
It does look, though, as if one is missing: where is "a-bc" on the way up?
Code: Select all
(for (i -5 5 )
(set 'a "abc")
(push "-" a i)
(map print (list i "\t" a "\n")))
-5 -abc
-4 -abc
-3 -abc
-2 ab-c
-1 abc-
0 -abc
1 a-bc
2 ab-c
3 ab-c
4 ab-c
5 ab-c
Posted: Mon Jul 09, 2007 4:54 pm
by Lutz
yes, it should but it at the and if the index is greater or equal the length like in:
Code: Select all
(set 'a '(a b c))
(push '- a 3)
a => (a b c -)
its ok on lists but broken on strings
Lutz
Posted: Tue Jul 10, 2007 1:48 pm
by Dmi
Also the reverse situation exists:
Code: Select all
> (set 'a "abc")
"abc"
> (push "-" a 3)
"-"
> a
"ab-c"
> (set 'a "abc")
"abc"
> (push "-" a 1)
"-"
> a
"a-bc"
I.e. we can't push to the end of the string. But we can into a list...
Posted: Tue Jul 10, 2007 2:57 pm
by Lutz
Thanks Dmitry, I looked into it yesterday and its all fixed in 9.1.9.
If this is an urgent issue for you or anybody else than contact me with a private message and I make 9.1.9 available to you. I didn't make a development release yet because still want to integrate the GUI-server code into it, adapt the scripts for making binary releases and haven't done any testing of the new utf-8 file-and-directory name handling in Win32. So at the moment its only good for UNIX/Mac OX X. 9.1.9 will be ready either this weekend or coming week (including binary releases for Win32 and MacOS X.
Lutz
Posted: Tue Jul 10, 2007 10:05 pm
by Dmi
Thanks, Lutz!
This waits for me. My companion programmer has stuck onto it, but now we made a workaround.