abc2midi: allow %%MIDIdef macros to be defined anywhere (#23)

* abc2midi: allow %%MIDIdef macros to be defined anywhere

Fix also some lost CHANGES from previous commit.

abc2midi: allow %%MIDIdef macros to be defined anywhere, including before the first X: field (outside any tune). Previously %%MIDIdef was only handled inside event_specific() after the started_parsing check,so macros defined in the file header were silently ignored.
The %%MIDIdef handling has been moved before the started_parsing check in event_specific() in store.c since macro definitions are context-independent.

* Update the golden test files since X:, R: and C: are now emitted
This commit is contained in:
Ronan Keryell
2026-04-23 06:21:48 -07:00
committed by GitHub
parent 22ad87cd72
commit 6ecbbde0fd
7 changed files with 84 additions and 7 deletions

13
store.c
View File

@@ -2363,17 +2363,18 @@ void event_specific(char *package, char *s, int in_I)
char *p;
int done;
if (started_parsing == 0) {
event_specific_in_header(package,s);
return;
}
/* [SS] 2015-06-01 */
/* [SS] 2015-06-01 [RK] 2026-03-31 */
/* %%MIDIdef macros are context-independent and valid anywhere */
if (strcmp(package,"MIDIdef") == 0) {
parse_mididef(s);
return;
}
if (started_parsing == 0) {
event_specific_in_header(package,s);
return;
}
if (strcmp(package,"MIDIx") == 0) {
process_midix(s);
}