Skip to content

Commit 8064933

Browse files
bactgoneall
authored andcommitted
Add comments for "found"
Signed-off-by: Arthit Suriyawongkul <[email protected]>
1 parent 64ab092 commit 8064933

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/main/java/org/spdx/utility/compare/LicenseCompareHelper.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,9 @@ public static String locateOriginalText(String fullLicenseText, int startToken,
227227
/**
228228
* Check whether the given text contains only a single token
229229
* <p>
230-
* A single token string is a string that contains zero or one token as
231-
* identified by the {@link LicenseTextHelper#TOKEN_SPLIT_PATTERN}.
230+
* A single token string is a string that contains zero or one
231+
* non-whitspace token as identified by the
232+
* {@link LicenseTextHelper#TOKEN_SPLIT_PATTERN}.
232233
* </p>
233234
*
234235
* @param text The text to test.
@@ -240,16 +241,17 @@ public static boolean isSingleTokenString(@Nullable String text) {
240241
return true; // zero tokens is considered a single token string
241242
}
242243
Matcher m = LicenseTextHelper.TOKEN_SPLIT_PATTERN.matcher(text);
243-
int nonWhitespaceTokenCount = 0;
244+
boolean found = false;
244245
while (m.find()) {
245246
if (!m.group(1).trim().isEmpty()) {
246-
nonWhitespaceTokenCount++;
247-
if (nonWhitespaceTokenCount > 1) {
248-
return false; // more than one token
247+
if (found) {
248+
return false; // more than one token found
249+
} else {
250+
found = true; // first token found
249251
}
250252
}
251253
}
252-
return true; // either no tokens or one token
254+
return true; // either no tokens or only one token found
253255
}
254256

255257
/**

0 commit comments

Comments
 (0)