[Snowball-discuss] SnowballProgram feature

From: Marios Sintichakis (mms@archetypon.com)
Date: Fri Jul 15 2005 - 14:52:41 BST


According to the manual,

insert S

"inserts the variable or literal S before c, moving c to the right of the insert".

Java and C runtime differ in the implementation of this command. Consider the
following program

stringescapes {}
externals (main)

define main as (
  repeat (
    not atlimit insert '-'

With the C runtime, input string 'testme' becomes 't-e-s-t-m-e'. With
the Java runtime however, the result is '-'. I guess that method

replace_s(int, int, String)

in class SnowballProgram mistakenly passes instance variables bra ([) and ket (])
instead of its arguments when calls current.replace(int, int, String).
Taking into account that method setCurrent(String) sets bra and ket to cursor
and limit respectivelly, the objerved behaviour is justified.
So, most probably the call

current.replace(bra, ket, s);

should be changed to

current.replace(c_bra, c_ket, s);

and additionally, method setCurrent(String) should perhaps initialize
both bra and ket to -1 in order to adhere to the manual: "For any
string, the slice ends should be assumed to be unset until they are set
with the two commands [, ]."

Best regards,

This archive was generated by hypermail 2.1.3 : Thu Sep 20 2007 - 12:02:47 BST