Skip to content

Commit

Permalink
fixed condition evaluation bug
Browse files Browse the repository at this point in the history
- fixed a condition evaluation problem
- corrected some regexes
- made option parsing more robust
- made versioning more fine grained
- added more specific error messages
- added more test cases
- slight change of the background color
- fixed #68
  • Loading branch information
truj committed Apr 28, 2021
1 parent 9cc7145 commit d4c9df1
Show file tree
Hide file tree
Showing 26 changed files with 676 additions and 160 deletions.
15 changes: 11 additions & 4 deletions build_helper/precommit.pl
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,29 @@
my $branch_suffix = 'master' eq $branch ? '' : '-' . $branch;

# get OLD major and minor version number
my $major_version = undef;
my $minor_version = undef;
my $major_version = undef;
my $middle_version = undef;
my $minor_version = undef;
open my $fh, '<', $java_file or die "Cannot read $java_file: $!\n";
while (my $line = <$fh>) {
if ($line =~ /(\bint\s+VERSION_MAJOR\s*=)\s*(\d+)/) {
$major_version = $2;
}
elsif ($line =~ /(\bint\s+VERSION_MIDDLE\s*=)\s*(\d+)/) {
$middle_version = $2;
}
elsif ($line =~ /(\bint\s+VERSION_MINOR\s*=)\s*(\-?\d+)/) {
$minor_version = $2;
}
last if defined $major_version && defined $minor_version;
last if defined $major_version && defined $middle_version && defined $minor_version;
}
close $fh or die "Cannot close $java_file: $!\n";
if (! defined $major_version) {
die "Did not find major version in $java_file.\n";
}
if (! defined $middle_version) {
die "Did not find middle version in $java_file.\n";
}
if (! defined $minor_version) {
die "Did not find minor version in $java_file.\n";
}
Expand All @@ -123,7 +130,7 @@
$minor_version++;
}
my $commit_time = time();
my $version = $major_version . '.' . $minor_version . $branch_suffix;
my $version = $major_version . '.' . $middle_version . '.' . $minor_version . $branch_suffix;

# Build up the commands to replace VERSION_MINOR, BRANCH and COMMIT_TIME in Midica.java.
# 1. perl and options and opening single quote (') for the regex
Expand Down
Binary file modified midica.jar
Binary file not shown.
11 changes: 7 additions & 4 deletions src/org/midica/Midica.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,26 @@
public class Midica {

/** Major version number. This has to be incremented manually. */
public static final int VERSION_MAJOR = 1;
private static final int VERSION_MAJOR = 1;

/** Middle version number. This has to be incremented manually. */
private static final int VERSION_MIDDLE = 3;

/**
* Minor version number. This is intended to be incremented automatically by precommit.pl.
* After switching to a new major version, this has to be set to "-1" manually, so that
* precommit.pl starts with "0" again.
*/
public static final int VERSION_MINOR = 3;
private static final int VERSION_MINOR = 1;

/** UNIX timestamp of the last commit */
public static final int COMMIT_TIME = 1618087070;
public static final int COMMIT_TIME = 1619630078;

/** Branch name. Automatically changed by precommit.pl */
public static final String BRANCH = "master";

/** Full version string. */
public static final String VERSION = VERSION_MAJOR + "." + VERSION_MINOR + ("master".equals(BRANCH) ? "" : "-" + BRANCH);
public static final String VERSION = VERSION_MAJOR + "." + VERSION_MIDDLE + "." + VERSION_MINOR + ("master".equals(BRANCH) ? "" : "-" + BRANCH);

/** Author name */
public static final String AUTHOR = "Jan Trukenmüller";
Expand Down
4 changes: 4 additions & 0 deletions src/org/midica/config/Dict.java
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,7 @@ public class Dict {
public static final String ERROR_CHORD_CONTAINS_ALREADY = "error_chord_contains_already";
public static final String ERROR_CHORD_DEF_NOT_ALLOWED_HERE = "error_chord_def_not_allowed_here";
public static final String ERROR_CHORD_NUM_OF_ARGS = "error_chord_num_of_args";
public static final String ERROR_CHORD_REDUNDANT_SEP = "error_chord_redundant_sep";
public static final String ERROR_CONST_NUM_OF_ARGS = "error_const_num_of_args";
public static final String ERROR_CONST_ALREADY_DEFINED = "error_const_already_defined";
public static final String ERROR_CONST_NAME_EQ_VALUE = "error_const_name_eq_value";
Expand Down Expand Up @@ -1529,6 +1530,7 @@ public class Dict {
public static final String ERROR_PATTERN_INDEX_INVALID = "error_pattern_index_invalid";
public static final String ERROR_PATTERN_INDEX_TOO_HIGH = "error_pattern_index_too_high";
public static final String ERROR_PATTERN_RECURSION_DEPTH = "error_pattern_recursion_depth";
public static final String ERROR_PATTERN_UNDEFINED = "error_pattern_undefined";
public static final String ERROR_META_NUM_OF_ARGS = "error_meta_num_of_arts";
public static final String ERROR_META_UNKNOWN_CMD = "error_meta_unknown_cmd";
public static final String ERROR_SOFT_KARAOKE_UNKNOWN_CMD = "error_soft_karaoke_unknown_cmd";
Expand Down Expand Up @@ -3034,6 +3036,7 @@ private static void initLanguageEnglish() {
set( ERROR_CHORD_CONTAINS_ALREADY, "Note cannot be defined more than once in the same chord: " );
set( ERROR_CHORD_DEF_NOT_ALLOWED_HERE, "a chord definition is not allowed inside a block<br>maybe you forgot to close the block." );
set( ERROR_CHORD_NUM_OF_ARGS, "wrong number of arguments in CHORD command" );
set( ERROR_CHORD_REDUNDANT_SEP, "redundant separator in chord definition" );
set( ERROR_CONST_NUM_OF_ARGS, "wrong number of arguments in CONSTANT definition" );
set( ERROR_CONST_ALREADY_DEFINED, "constant already defined: " );
set( ERROR_CONST_NAME_EQ_VALUE, "constant name must be different from it's value: " );
Expand Down Expand Up @@ -3069,6 +3072,7 @@ private static void initLanguageEnglish() {
set( ERROR_PATTERN_INDEX_INVALID, "pattern index not a number: " );
set( ERROR_PATTERN_INDEX_TOO_HIGH, "pattern index too high: " );
set( ERROR_PATTERN_RECURSION_DEPTH, "Recursion depth in pattern too big." );
set( ERROR_PATTERN_UNDEFINED, "Pattern not defined: " );
set( ERROR_META_NUM_OF_ARGS, "no arguments allowed in meta command" );
set( ERROR_META_UNKNOWN_CMD, "unknown meta command: " );
set( ERROR_SOFT_KARAOKE_UNKNOWN_CMD, "unknown soft karaoke command: " );
Expand Down
2 changes: 1 addition & 1 deletion src/org/midica/config/Laf.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public class Laf {
public static final Color COLOR_BORDER = new Color( 23, 121, 186 );
private static final Color COLOR_BORDER_LIGHT = new Color( 148, 204, 242 );
private static final Color COLOR_ALERT = new Color( 255, 0, 0 );
public static final Color COLOR_PANEL = new Color( 238, 238, 238 );
public static final Color COLOR_PANEL = new Color( 243, 240, 233 );
private static final Color COLOR_WHITE = new Color( 255, 255, 255 );
private static final Color COLOR_BLACK = new Color( 0, 0, 0 );
private static final Color COLOR_INACTIVE = new Color( 228, 228, 228 );
Expand Down
Loading

0 comments on commit d4c9df1

Please sign in to comment.