Skip to content

Commit

Permalink
(fix) lib: getPatternSizeInfo()
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-pelykh committed Jun 28, 2024
1 parent d6dc167 commit a897acc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/src/main/java/org/pcre4j/Pcre2Code.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,27 +186,27 @@ private int getPatternIntInfo(int info) {
* @return the size information as long
*/
private long getPatternSizeInfo(int info) {
final var infoSize = api.patternInfo(handle, IPcre2.INFO_FRAMESIZE);
final var infoSize = api.patternInfo(handle, info);

if (infoSize == 4) {
final var where = new int[1];
final var error = api.patternInfo(handle, IPcre2.INFO_FRAMESIZE, where);
final var error = api.patternInfo(handle, info, where);
if (error != 0) {
throw new IllegalStateException(Pcre4jUtils.getErrorMessage(api, error));
}

return where[0];
} else if (infoSize == 8) {
final var where = new long[1];
final var error = api.patternInfo(handle, IPcre2.INFO_FRAMESIZE, where);
final var error = api.patternInfo(handle, info, where);
if (error != 0) {
throw new IllegalStateException(Pcre4jUtils.getErrorMessage(api, error));
}

return where[0];
}

throw new Pcre2PatternInfoSizeError(Pcre2PatternInfo.valueOf(IPcre2.INFO_FRAMESIZE).orElseThrow(), infoSize);
throw new Pcre2PatternInfoSizeError(Pcre2PatternInfo.valueOf(info).orElseThrow(), infoSize);
}

/**
Expand Down

0 comments on commit a897acc

Please sign in to comment.