Bladeren bron

Fix a fencepost error in CommandArguments

Change-Id: I8030f2e887288e9409cafe027606c67ca5d8e92d
Reviewed-on: http://gerrit.dmdirc.com/925
Reviewed-by: Gregory Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
tags/0.6.3rc1
Chris Smith 14 jaren geleden
bovenliggende
commit
72cb83cb31
1 gewijzigde bestanden met toevoegingen van 5 en 3 verwijderingen
  1. 5
    3
      src/com/dmdirc/commandparser/CommandArguments.java

+ 5
- 3
src/com/dmdirc/commandparser/CommandArguments.java Bestand weergeven

@@ -159,7 +159,9 @@ public class CommandArguments {
159 159
      * @return A String representation of the requested words
160 160
      */
161 161
     public String getWordsAsString(final int start) {
162
-        return getWordsAsString(start, words.length);
162
+        parse();
163
+        
164
+        return getWordsAsString(start, words.length - 1);
163 165
     }
164 166
 
165 167
     /**
@@ -172,10 +174,10 @@ public class CommandArguments {
172 174
      */
173 175
     @Precondition("Start index is less than or equal to end index")
174 176
     public String getWordsAsString(final int start, final int end) {
175
-        Logger.assertTrue(start <= end);
177
+        Logger.assertTrue(start <= end + 1);
176 178
 
177 179
         final Pattern pattern = Pattern.compile("(\\S+\\s*){" + (start) + "}"
178
-                + "((\\S+\\s*){" + (end - start) + "}).*?");
180
+                + "((\\S+\\s*){" + Math.max(0, end - start) + "}\\S+).*?");
179 181
         final Matcher matcher = pattern.matcher(line);
180 182
 
181 183
         return matcher.matches() ? matcher.group(2) : "";

Laden…
Annuleren
Opslaan