Skip to content

Commit

Permalink
fix incorrect use of limit, convert check to assertions, enable asser…
Browse files Browse the repository at this point in the history
…tions when running tests
  • Loading branch information
rmuir committed Mar 27, 2024
1 parent 5e0bd45 commit d508f87
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ c_src_dir = src_c

JAVACFLAGS ?=
JAVAC ?= javac
JAVA ?= java
JAVA ?= java -ea
java_src_main_dir = java/org/tartarus/snowball
java_src_dir = $(java_src_main_dir)/ext

Expand Down
12 changes: 5 additions & 7 deletions java/org/tartarus/snowball/SnowballProgram.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void setCurrent(String value)
*/
public String getCurrent()
{
return new String(current, 0, limit);
return new String(current, 0, length);
}

/**
Expand Down Expand Up @@ -344,12 +344,10 @@ protected int replace_s(int c_bra, int c_ket, CharSequence s)

protected void slice_check()
{
if (bra < 0 ||
bra > ket ||
ket > limit)
{
throw new IllegalArgumentException("faulty slice operation: bra=" + bra + ",ket=" + ket + ",limit=" + limit);
}
assert bra >= 0 : "bra=" + bra;
assert bra <= ket : "bra=" + bra + ",ket=" + ket;
assert limit <= length : "limit=" + limit + ",length=" + length;
assert ket <= limit : "ket=" + ket + ",limit=" + limit;
}

protected void slice_from(CharSequence s)
Expand Down

0 comments on commit d508f87

Please sign in to comment.