diff --git a/midica.jar b/midica.jar index 8a77506..b56ae30 100644 Binary files a/midica.jar and b/midica.jar differ diff --git a/src/org/midica/Midica.java b/src/org/midica/Midica.java index f020526..efd610a 100644 --- a/src/org/midica/Midica.java +++ b/src/org/midica/Midica.java @@ -33,10 +33,10 @@ public class Midica { * After switching to a new major version, this has to be set to "-1" manually, so that * precommit.pl starts with "0" again. */ - private static final int VERSION_MINOR = 10; + private static final int VERSION_MINOR = 11; /** UNIX timestamp of the last commit */ - public static final int COMMIT_TIME = 1696410911; + public static final int COMMIT_TIME = 1696764269; /** Branch name. Automatically changed by precommit.pl */ public static final String BRANCH = "master"; diff --git a/src/org/midica/file/read/MidicaPLParser.java b/src/org/midica/file/read/MidicaPLParser.java index e881c05..d33191c 100644 --- a/src/org/midica/file/read/MidicaPLParser.java +++ b/src/org/midica/file/read/MidicaPLParser.java @@ -281,7 +281,6 @@ public class MidicaPLParser extends SequenceParser { private static Pattern varAssignPattern = null; private static Pattern chordSepPattern = null; private static Pattern compactChannelPattern = null; - private static Pattern compactOptPattern = null; private static Pattern invalidNoteIdxPattern = null; private static boolean isSoftKaraoke = false; public static boolean isPlayingTupletBlock = false; @@ -702,9 +701,6 @@ private void compilePatterns() { compactChannelPattern = Pattern.compile( "^(\\d{1,2}|" + Pattern.quote(P) + ")" + Pattern.quote(COMPACT_CHANNEL) + "$" ); - compactOptPattern = Pattern.compile( - "^" + Pattern.quote(COMPACT_OPT_OPEN) + "(.+)" + Pattern.quote(COMPACT_OPT_CLOSE) + "$" - ); // invalid note index inside of a block inside a pattern invalidNoteIdxPattern = Pattern.compile("^\\[\\d+\\]$"); @@ -2679,7 +2675,7 @@ else if (OPT_SHIFT.equals(optName)) { String compactElement = patLineTokens[j]; // option: (name=value)? - if (compactOptPattern.matcher(compactElement).matches()) + if (hasCompactOptions(compactElement)) continue; // bar line? @@ -3277,7 +3273,7 @@ public String[] addShift(String[] tokens, int shift) throws ParseException { String[] parts = compactElement.split(Pattern.quote(COMPACT_NOTE_SEP), 2); // rest or option? - leave unchanged - if (REST.equals(parts[0]) || compactOptPattern.matcher(compactElement).matches()) { + if (REST.equals(parts[0]) || hasCompactOptions(compactElement)) { shiftedNotes.add(compactElement); } else if (compactElement.startsWith(BAR_LINE)) { @@ -4815,8 +4811,7 @@ else if (currentDuration > tremolo) { */ public ArrayList parseCompactOptions(String compactElement, boolean isFake) throws ParseException { - Matcher optMatcher = compactOptPattern.matcher(compactElement); - if (optMatcher.matches()) { + if (hasCompactOptions(compactElement)) { String optStr = compactElement.replaceFirst("^" + Pattern.quote(COMPACT_OPT_OPEN), ""); optStr = optStr.replaceFirst(Pattern.quote(COMPACT_OPT_CLOSE) + "$", ""); return parseOptions(optStr, isFake); @@ -4825,6 +4820,17 @@ public ArrayList parseCompactOptions(String compactElement, boole return null; } + /** + * Determins if the given compact element contains compact options. + * That means, it starts with **(** and ends with **)**. + * + * @param compactElement the compact element to check + * @return **true** if the compact element contains compact options + */ + private boolean hasCompactOptions(String compactElement) { + return compactElement.startsWith(COMPACT_OPT_OPEN) && compactElement.endsWith(COMPACT_OPT_CLOSE); + } + /** * Parses the options part of a command. *