From e9a36cc6881400a904315a15065650046643bb3d Mon Sep 17 00:00:00 2001 From: Seymour Shlien Date: Sun, 4 Oct 2020 06:39:45 -0400 Subject: [PATCH] 2020.10.01 --- abcmatch.c | 2 +- doc/CHANGES | 48 ++++++++++++++ doc/readme.txt | 8 +-- drawtune.c | 2 +- makefile | 174 +++++++++++++++++++++++++++++++++++++++++++++++++ matchsup.c | 2 +- parseabc.c | 85 ++++++++++++++---------- store.c | 2 +- stresspat.c | 2 + toabc.c | 4 +- yapstree.c | 4 +- 11 files changed, 287 insertions(+), 46 deletions(-) create mode 100755 makefile diff --git a/abcmatch.c b/abcmatch.c index 6e419eb..9785bb9 100644 --- a/abcmatch.c +++ b/abcmatch.c @@ -49,7 +49,7 @@ Matching: -#define VERSION "1.74 June 04 2020 abcmatch" +#define VERSION "1.75 October 01 2020 abcmatch" #include #include #include diff --git a/doc/CHANGES b/doc/CHANGES index 027f748..d45ff49 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -13802,3 +13802,51 @@ queues.c file. Presently, I am using a factor of 4 (not configurable). Bendstringex limited to 64 or less increments. +September 30 2020 + +James Allwright has reported several problems with the abcMIDI code +and proposed some fixes and improvements. + +There is a bug in parsekey resulting in an extraneous warning for +the following file. + +X: 1 +T: parsekey() test +M:4/4 +L:1/8 +Q:1/4=127 +K: D phr ^f +| =C^C =D^D =E =F ^F =G | + +abc2midi parsekey.abc +4.41 August 09 2020 abc2midi +Warning in line-char 6-0 : Ignoring string '^f' in K: field +writing MIDI file parsekey1.mid + +Despite the warning the output file is still correct. + +abc2abc and other applications depending on parseabc.c also produce +similar warnings. + +Analysis: the problem originates in the function parsekey() in +parseabc.c. The fix consists two small changes shown here. + +/* shortcuts such as ^/4G instead of ^1/4G not allowed here */ +/* parsed =0; [SS] 2020-09-30 */ + + + /* if (parsed ==1) { [SS] 2020-09-30 */ + if (success > 0) { /* [SS] 2020-09-30 */ + + + +drawtune.c in read_boolean increased dimension of char p[] +to allow for null termination. -- suggested by James Allwright. + +stresspat.c in custom_stress_file() added fclose(inhandle) +to close the open input file. -- suggested by James Allwright. + +matchsup.c, yapstree.c, and toabc.c: event_temperament declared as +event_temperament(*line) instead of event_temperament(**line). + +parsekey() was split into two functions, parsekey() and process_microtones(). diff --git a/doc/readme.txt b/doc/readme.txt index 85bd211..0baaa6f 100644 --- a/doc/readme.txt +++ b/doc/readme.txt @@ -1,10 +1,10 @@ abcMIDI : abc <-> MIDI conversion utilities midi2abc version 3.46 June 22 2020 -abc2midi version 4.41 August 09 2020 -abc2abc version 2.08 June 04 2020 -yaps version 1.78 June 14 2020 -abcmatch version 1.73 June 04 2020 +abc2midi version 4.42 October 01 2020 +abc2abc version 2.09 October 01 2020 +yaps version 1.79 October 01 2020 +abcmatch version 1.74 October 01 2020 midicopy version 1.36 June 04 2019 24th January 2002 diff --git a/drawtune.c b/drawtune.c index 3d6729e..e696728 100644 --- a/drawtune.c +++ b/drawtune.c @@ -1980,7 +1980,7 @@ char *s; /* set logical parameter from %%command */ /* part of the handling for event_specific */ { - char p[10]; + char p[12]; /* [JA] 2020-09-30 */ int result; p[0] = '\0'; diff --git a/makefile b/makefile new file mode 100755 index 0000000..5438eaf --- /dev/null +++ b/makefile @@ -0,0 +1,174 @@ +# Generic unix/gcc Makefile for abcMIDI package +# +# +# compilation #ifdefs - you need to compile with these defined to get +# the code to compile with PCC. +# +# NOFTELL in midifile.c and genmidi.c selects a version of the file-writing +# code which doesn't use file seeking. +# +# PCCFIX in mftext.c midifile.c midi2abc.c +# comments out various things that aren't available in PCC +# +# ANSILIBS includes some ANSI header files (which gcc can live without, +# but other compilers may want). +# +# USE_INDEX causes index() to be used instead of strchr(). This is needed +# by some pre-ANSI C compilers. +# +# ASCTIME causes asctime() to be used instead of strftime() in pslib.c. +# If ANSILIBS is not set, neither routine is used. +# +# KANDR selects functions prototypes without argument prototypes. +# currently yaps will only compile in ANSI mode. +# +# +# On running make, you may get the mysterious message : +# +# ', needed by `parseabc.o'. Stop `abc.h +# +# This means you are using GNU make and this file is in DOS text format. To +# cure the problem, change this file from using PC-style end-of-line (carriage +# return and line feed) to unix style end-of-line (line feed). + +VERSION = @VERSION@ + +CC = gcc +INSTALL = /usr/bin/install -c +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} + +CFLAGS = -DANSILIBS -O2 +CPPFLAGS = -DHAVE_CONFIG_H -I. +LDFLAGS = -lm + +prefix = /usr/local +exec_prefix = ${prefix} + +srcdir = . +VPATH = . +bindir = ${exec_prefix}/bin +libdir = ${exec_prefix}/lib +datadir = ${prefix}/share +docdir = ${prefix}/share/doc/abcmidi +mandir = ${prefix}/share/man/man1 + +binaries=abc2midi midi2abc abc2abc mftext yaps midicopy abcmatch + +all : abc2midi midi2abc abc2abc mftext yaps midicopy abcmatch + +OBJECTS_ABC2MIDI=parseabc.o store.o genmidi.o midifile.o queues.o parser2.o stresspat.o +abc2midi : $(OBJECTS_ABC2MIDI) + $(CC) $(CFLAGS) -o abc2midi $(OBJECTS_ABC2MIDI) $(LDFLAGS) -lm +$(OBJECTS_ABC2MIDI): abc.h parseabc.h config.h Makefile + +OBJECTS_ABC2ABC=parseabc.o toabc.o +abc2abc : $(OBJECTS_ABC2ABC) + $(CC) $(CFLAGS) -o abc2abc $(OBJECTS_ABC2ABC) $(LDFLAGS) +$(OBJECTS_ABC2ABC): abc.h parseabc.h config.h Makefile + +OBJECTS_MIDI2ABC=midifile.o midi2abc.o +midi2abc : $(OBJECTS_MIDI2ABC) + $(CC) $(CFLAGS) -o midi2abc $(OBJECTS_MIDI2ABC) $(LDFLAGS) +$(OBJECTS_MIDI2ABC): abc.h midifile.h config.h Makefile + +OBJECTS_MFTEXT=midifile.o mftext.o crack.o +mftext : $(OBJECTS_MFTEXT) + $(CC) $(CFLAGS) -o mftext $(OBJECTS_MFTEXT) $(LDFLAGS) +$(OBJECTS_MFTEXT): abc.h midifile.h config.h Makefile + +OBJECTS_YAPS=parseabc.o yapstree.o drawtune.o debug.o pslib.o position.o parser2.o +yaps : $(OBJECTS_YAPS) + $(CC) $(CFLAGS) -o yaps $(OBJECTS_YAPS) $(LDFLAGS) +$(OBJECTS_YAPS): abc.h midifile.h config.h Makefile + +OBJECTS_MIDICOPY=midicopy.o +midicopy : $(OBJECTS_MIDICOPY) + $(CC) $(CFLAGS) -o midicopy $(OBJECTS_MIDICOPY) $(LDFLAGS) +$(OBJECTS_MIDICOPY): abc.h midifile.h midicopy.h config.h Makefile + +OBJECTS_ABCMATCH=abcmatch.o matchsup.o parseabc.o +abcmatch : $(OBJECTS_ABCMATCH) + $(CC) $(CFLAGS) -o abcmatch $(OBJECTS_ABCMATCH) $(LDFLAGS) +$(OBJECTS_ABCMATCH): abc.h midifile.h config.h Makefile + +parseabc.o : parseabc.c abc.h parseabc.h + +parser2.o : parser2.c abc.h parseabc.h parser2.h + +toabc.o : toabc.c abc.h parseabc.h + +# could use -DNOFTELL here +genmidi.o : genmidi.c abc.h midifile.h genmidi.h + +stresspat.o : stresspat.c + +store.o : store.c abc.h parseabc.h midifile.h genmidi.h + +queues.o : queues.c genmidi.h + +# could use -DNOFTELL here +midifile.o : midifile.c midifile.h + +midi2abc.o : midi2abc.c midifile.h + +midicopy.o : midicopy.c midicopy.h + +abcmatch.o: abcmatch.c abc.h + +crack.o : crack.c + +mftext.o : mftext.c midifile.h + +# objects needed by yaps +# +yapstree.o: yapstree.c abc.h parseabc.h structs.h drawtune.h + +drawtune.o: drawtune.c structs.h sizes.h abc.h drawtune.h + +pslib.o: pslib.c drawtune.h + +position.o: position.c abc.h structs.h sizes.h + +debug.o: debug.c structs.h abc.h + +#objects for abcmatch +# +matchsup.o : matchsup.c abc.h parseabc.h parser2.h + +clean : + rm *.o ${binaries} + +install: abc2midi midi2abc abc2abc mftext midicopy yaps abcmatch + $(INSTALL) -d $(DESTDIR)$(bindir) + $(INSTALL) -m 755 ${binaries} $(DESTDIR)$(bindir) + + # install documentation + $(INSTALL) -d $(DESTDIR)${docdir} + $(INSTALL) -m 644 doc/*.txt $(DESTDIR)$(docdir) + $(INSTALL) -m 644 doc/AUTHORS $(DESTDIR)$(docdir) + $(INSTALL) -m 644 doc/CHANGES $(DESTDIR)$(docdir) + $(INSTALL) -m 644 VERSION $(DESTDIR)$(docdir) + + # install manpages + $(INSTALL) -d $(DESTDIR)${mandir} + $(INSTALL) -m 644 doc/*.1 $(DESTDIR)$(mandir) + + +uninstall: + echo "uninstalling..."; + #rm -f $(DESTDIR)$(bindir)/$(binaries) + rm -f $(DESTDIR)$(bindir)/abc2midi + rm -f $(DESTDIR)$(bindir)/abc2abc + rm -f $(DESTDIR)$(bindir)/yaps + rm -f $(DESTDIR)$(bindir)/midi2abc + rm -f $(DESTDIR)$(bindir)/mftext + rm -f $(DESTDIR)$(bindir)/abcmatch + rm -f $(DESTDIR)$(bindir)/midicopy + rm -f $(DESTDIR)$(docdir)/*.txt + rm -f $(DESTDIR)$(docdir)/AUTHORS + rm -f $(DESTDIR)$(docdir)/CHANGES + rm -f $(DESTDIR)$(docdir)/VERSION + rm -f $(DESTDIR)$(mandir)/*.1 + rmdir $(DESTDIR)$(docdir) + diff --git a/matchsup.c b/matchsup.c index d4a0e2f..66166eb 100644 --- a/matchsup.c +++ b/matchsup.c @@ -1407,7 +1407,7 @@ void event_microtone(int dir, int a, int b) { } -void event_temperament(char **line) { +void event_temperament(char *line) { } diff --git a/parseabc.c b/parseabc.c index 258a6a0..01d517b 100644 --- a/parseabc.c +++ b/parseabc.c @@ -1133,6 +1133,51 @@ parseother (s, word, gotother, other, maxsize) /* [SS] 2011-04-18 */ return 0; } + +static void process_microtones (int *parsed, char word[], + char modmap[], int modmul[], struct fraction modmicrotone[]) +{ + int a, b; /* for microtones [SS] 2014-01-06 */ + char c; + int j; + int success; + + /* shortcuts such as ^/4G instead of ^1/4G not allowed here */ + + success = sscanf (&word[1], "%d/%d%c", &a, &b, &c); + if (success == 3) /* [SS] 2016-04-10 */ + { + *parsed = 1; + j = (int) c - 'A'; + if (j > 7) j = (int) c - 'a'; + if (j > 7 || j < 0) {printf("invalid j = %d\n",j); exit(-1);} + if (word[0] == '_') a = -a; + /* printf("%s fraction microtone %d/%d for %c\n",word,a,b,c); */ + } else { + success = sscanf (&word[1], "%d%c", &a, &c); /* [SS] 2020-06-25 */ + if (success == 2) + { + b = 0; + /* printf("%s integer microtone %d%c\n",word,a,c); */ + if (temperament != 1) { /* [SS] 2020-06-25 2020-07-05 */ + event_warning("do not use integer microtone without calling %%MIDI temperamentequal"); + } + *parsed = 1; + } + } + /* if (parsed ==1) [SS] 2020-09-30 */ + if (success > 0) { + j = (int) c - 'A'; + if (j > 7) j = (int) c - 'a'; + if (j > 7 || j < 0) {printf("invalid j = %d\n",j); exit(-1);} + if (word[0] == '_') a = -a; + modmap[j] = word[0]; + modmicrotone[j].num = a; + modmicrotone[j].denom = b; + /* printf("%c microtone = %d/%d\n",modmap[j],modmicrotone[j].num,modmicrotone[j].denom); */ + } + } /* finished ^ = _ */ + int parsekey (str) /* parse contents of K: field */ @@ -1379,42 +1424,14 @@ parsekey (str) modmul[j] = 2; parsed = 1; }; + } /* microtone? */ /* shortcuts such as ^/4G instead of ^1/4G not allowed here */ - parsed =0; - success = sscanf (&word[1], "%d/%d%c", &a, &b, &c); - if (success == 3) /* [SS] 2016-04-10 */ - { - parsed = 1; - j = (int) c - 'A'; - if (j > 7) j = (int) c - 'a'; - if (j > 7 || j < 0) {printf("invalid j = %d\n",j); exit(-1);} - if (word[0] == '_') a = -a; - /* printf("%s fraction microtone %d/%d for %c\n",word,a,b,c); */ - } else { - success = sscanf (&word[1], "%d%c", &a, &c); /* [SS] 2020-06-25 */ - if (success == 2) - { - b = 0; - /* printf("%s integer microtone %d%c\n",word,a,c); */ - if (temperament != 1) { /* [SS] 2020-06-25 2020-07-05 */ - event_warning("do not use integer microtone without calling %%MIDI temperamentequal"); - } - parsed = 1; - } - } - if (parsed ==1) { - j = (int) c - 'A'; - if (j > 7) j = (int) c - 'a'; - if (j > 7 || j < 0) {printf("invalid j = %d\n",j); exit(-1);} - if (word[0] == '_') a = -a; - modmap[j] = word[0]; - modmicrotone[j].num = a; - modmicrotone[j].denom = b; - /* printf("%c microtone = %d/%d\n",modmap[j],modmicrotone[j].num,modmicrotone[j].denom); */ - } - } /* finished ^ = _ */ - } + /* parsed =0; [SS] 2020-09-30 */ + process_microtones (&parsed, word, + modmap, modmul, modmicrotone); + } + if ((parsed == 0) && (strlen (word) > 0)) { sprintf (msg, "Ignoring string '%s' in K: field", word); diff --git a/store.c b/store.c index d70f00b..c7a1915 100644 --- a/store.c +++ b/store.c @@ -185,7 +185,7 @@ int main() */ -#define VERSION "4.41 August 09 2020 abc2midi" +#define VERSION "4.42 Ocober 01 2020 abc2midi" /* enables reading V: indication in header */ #define XTEN1 1 diff --git a/stresspat.c b/stresspat.c index 187af2e..f0888af 100644 --- a/stresspat.c +++ b/stresspat.c @@ -538,6 +538,7 @@ read_custom_stress_file (char *filename) if (index > 47) { printf ("used up all available space for stress models\n"); + fclose(inhandle); /* [JA] 2020-09-30 */ return; } nmodels++; @@ -563,4 +564,5 @@ read_custom_stress_file (char *filename) } if (fgets (str, 3, inhandle) == NULL) break; /* [SDG] 2020-06-03 */ } + fclose(inhandle); /* [JA] 2020-09-30 */ } diff --git a/toabc.c b/toabc.c index b5ec69f..02118fb 100644 --- a/toabc.c +++ b/toabc.c @@ -21,7 +21,7 @@ /* back-end for outputting (possibly modified) abc */ -#define VERSION "2.08 June 04 2020 abc2abc" +#define VERSION "2.09 October 01 2020 abc2abc" /* for Microsoft Visual C++ 6.0 or higher */ #ifdef _MSC_VER @@ -2395,7 +2395,7 @@ void event_microtone(int dir, int a, int b) { } -void event_temperament(char **line) { +void event_temperament(char *line) { } void event_normal_tone() diff --git a/yapstree.c b/yapstree.c index 01252b9..bc0b959 100644 --- a/yapstree.c +++ b/yapstree.c @@ -22,7 +22,7 @@ /* yapstree.c - back-end for abc parser. */ /* generates a data structure suitable for typeset music */ -#define VERSION "1.78 July 14 2020 yaps" +#define VERSION "1.79 October 01 2020 yaps" #include #ifdef USE_INDEX #define strchr index @@ -2969,7 +2969,7 @@ void event_microtone(int dir, int a, int b) { } -void event_temperament(char **line) { +void event_temperament(char *line) { }