Compare commits

..

2 Commits

Author SHA1 Message Date
Seymour Shlien
504cbe93f7 2021.06.24 2021-06-24 14:37:48 -04:00
Seymour Shlien
1105ee0c8b 2021.05.25 2021-05-26 15:50:57 -04:00
9 changed files with 105 additions and 28 deletions

View File

@@ -1,2 +1,2 @@
2021 May 23 2021 2021 June 24 2021

View File

@@ -49,7 +49,7 @@ Matching:
#define VERSION "1.78 March 27 2021 abcmatch" #define VERSION "1.79 May 25 2021 abcmatch"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>

View File

@@ -14240,3 +14240,40 @@ to get these options working again.
May 25 2021
James Allwright added more security checks to stop the
parser from reading numbers beyond the largest integer. Changes
were made to parserabc.c and midi2abc.c
The abc2abc -s spacing function was modified to ignore certain
time signatures like M: none or M:7/8. The code for dealing with
3/2, 3/4, 3/8 ... time signatures was improved.
June 24 2021
abc2midi bug: in the following sample
X:1
T: octave
M: 2/4
L: 1/8
K: none octave=1
V:1
C4|
V:2
C4|
The octave=1 applies only to voice 1 and does not
act as global variable applying to both voices.
Analysis: event_octave either sets global.octaveshift or
v.octaveshift depending upon the variable pastheader. Pastheader
was set to 1 by headerprocess() in event_key() prior to calling
event_octave which prevented global.octaveshift from being set.
Fix: moved headerprocess(), getvoicecontext(), etc to after
calling event_octave().

View File

@@ -1,10 +1,10 @@
abcMIDI : abc <-> MIDI conversion utilities abcMIDI : abc <-> MIDI conversion utilities
midi2abc version 3.47 November 01 2020 midi2abc version 3.47 May 25 2021
abc2midi version 4.56 May 21 2021 abc2midi version 4.58 June 24 2021
abc2abc version 2.13 May 08 2021 abc2abc version 2.15 May 25 2021
yaps version 1.86 December 10 2020 yaps version 1.87 May 25 2021
abcmatch version 1.78 March 27 2021 abcmatch version 1.79 May 25 2021
midicopy version 1.37 October 10 2020 midicopy version 1.37 October 10 2020
24th January 2002 24th January 2002
@@ -14,7 +14,7 @@ J.R.Allwright@westminster.ac.uk
University of Westminster, University of Westminster,
London, UK London, UK
November 2020 June 2021
Seymour Shlien Seymour Shlien
Ottawa, Canada Ottawa, Canada

View File

@@ -45,8 +45,9 @@
* based on public domain 'midifilelib' package. * based on public domain 'midifilelib' package.
*/ */
#define VERSION "3.47 November 01 2020 midi2abc" #define VERSION "3.48 May 25 2021 midi2abc"
#include <limits.h>
/* Microsoft Visual C++ Version 6.0 or higher */ /* Microsoft Visual C++ Version 6.0 or higher */
#ifdef _MSC_VER #ifdef _MSC_VER
#define snprintf _snprintf #define snprintf _snprintf
@@ -3451,7 +3452,8 @@ char *num;
p = p + 1; p = p + 1;
neg = -1; neg = -1;
}; };
while (((int)*p >= '0') && ((int)*p <= '9')) { /* [JA] 2021-05-25 */
while (((int)*p >= '0') && ((int)*p <= '9') && (t < (INT_MAX-9)/10)) {
t = t * 10 + (int) *p - '0'; t = t * 10 + (int) *p - '0';
p = p + 1; p = p + 1;
}; };
@@ -3467,10 +3469,15 @@ char **p;
int t; int t;
t = 0; t = 0;
while (((int)**p >= '0') && ((int)**p <= '9')) { /* [JA] 2021-05-25 */
while (((int)**p >= '0') && ((int)**p <= '9') && (t < (INT_MAX-9)/10)) {
t = t * 10 + (int) **p - '0'; t = t * 10 + (int) **p - '0';
*p = *p + 1; *p = *p + 1;
}; };
/* advance over any spurious extra digits */
while (isdigit(**p)) {
*p = *p + 1;
}
return t; return t;
} }

View File

@@ -37,6 +37,7 @@
#include <stdlib.h> #include <stdlib.h>
/* [JM] 2018-02-22 to handle strncasecmp() */ /* [JM] 2018-02-22 to handle strncasecmp() */
#include <string.h> #include <string.h>
#include <limits.h>
/* #define SIZE_ABBREVIATIONS ('Z' - 'H' + 1) [SS] 2016-09-20 */ /* #define SIZE_ABBREVIATIONS ('Z' - 'H' + 1) [SS] 2016-09-20 */
#define SIZE_ABBREVIATIONS 58 #define SIZE_ABBREVIATIONS 58
@@ -348,11 +349,15 @@ readnumf (num)
event_error ("Missing Number"); event_error ("Missing Number");
}; };
t = 0; t = 0;
while (((int) *p >= '0') && ((int) *p <= '9')) /* [JA] 2021-05-25 */
while (((int) *p >= '0') && ((int) *p <= '9') && (t < (INT_MAX-9)/10))
{ {
t = t * 10 + (int) *p - '0'; t = t * 10 + (int) *p - '0';
p = p + 1; p = p + 1;
}; };
if (t >= (INT_MAX-9)/10) { /* [JA] 2021-05-25 */
event_error ("Number too big");
}
return (t); return (t);
} }
@@ -384,11 +389,16 @@ readnump (p)
int t; int t;
t = 0; t = 0;
while (((int) **p >= '0') && ((int) **p <= '9')) /* [JA] 2021-05-25 */
while (((int) **p >= '0') && ((int) **p <= '9') && (t < (INT_MAX-9)/10))
{ {
t = t * 10 + (int) **p - '0'; t = t * 10 + (int) **p - '0';
*p = *p + 1; *p = *p + 1;
}; }
/* advance over any spurious extra digits [JA] 2021-05-25 */
while (isdigit(**p)) {
*p = *p + 1;
}
return (t); return (t);
} }

17
store.c
View File

@@ -186,7 +186,7 @@ int main()
*/ */
#define VERSION "4.56 May 21 2021 abc2midi" #define VERSION "4.58 June 24 2021 abc2midi"
/* enables reading V: indication in header */ /* enables reading V: indication in header */
#define XTEN1 1 #define XTEN1 1
@@ -5957,11 +5957,13 @@ int explict;
copymap(&global); copymap(&global);
sf = sharps; sf = sharps;
mi = minor; mi = minor;
headerprocess();
v = getvoicecontext(1); /* [SS] 2021-06-24
if (!inbody) v1index = notes; /* save position in case of split voice */ ***headerprocess();
};
***v = getvoicecontext(1);
***if (!inbody) v1index = notes; /* save position in case of split voice */
if (gotclef) if (gotclef)
{ {
event_octave(clef->octave_offset, 0); event_octave(clef->octave_offset, 0);
@@ -5969,6 +5971,11 @@ int explict;
if (gotoctave) { if (gotoctave) {
event_octave(octave,0); event_octave(octave,0);
}; };
/* [SS] 2021-06-24 */
headerprocess();
v = getvoicecontext(1);
if (!inbody) v1index = notes; /* save position in case of split voice */
};
}; };
} }

26
toabc.c
View File

@@ -21,7 +21,7 @@
/* back-end for outputting (possibly modified) abc */ /* back-end for outputting (possibly modified) abc */
#define VERSION "2.14 May 09 2021 abc2abc" #define VERSION "2.15 May 25 2021 abc2abc"
/* for Microsoft Visual C++ 6.0 or higher */ /* for Microsoft Visual C++ 6.0 or higher */
#ifdef _MSC_VER #ifdef _MSC_VER
@@ -84,6 +84,7 @@ struct fract breakpoint; /* used to break bar into beamed sets of notes */
complex_barpoint_t master_bar_break; complex_barpoint_t master_bar_break;
int barno; /* number of bar within tune */ int barno; /* number of bar within tune */
int newspacing; /* was -s option selected ? */ int newspacing; /* was -s option selected ? */
int have_spacing_scheme; /* do we support spacing for time signature ? [JA] */
int barcheck; /* indicate -b and -r options selected */ int barcheck; /* indicate -b and -r options selected */
int echeck; /* was error-checking turned off ? (-e option) */ int echeck; /* was error-checking turned off ? (-e option) */
int newbreaks; /* was -n option selected ? */ int newbreaks; /* was -n option selected ? */
@@ -575,6 +576,7 @@ char** filename;
} else { } else {
newspacing = 1; newspacing = 1;
}; };
have_spacing_scheme = 0; /* [JA] 2021-05-25 */
narg = getarg("-X", argc, argv); narg = getarg("-X", argc, argv);
if (narg == -1) { if (narg == -1) {
newrefnos = 0; newrefnos = 0;
@@ -1414,6 +1416,7 @@ static void set_complex_barpoint(timesig_details_t *timesig,
void event_timesig (timesig) void event_timesig (timesig)
timesig_details_t *timesig; timesig_details_t *timesig;
{ {
have_spacing_scheme = 0; /* default to no new spacing */
emit_string ( "M:"); emit_string ( "M:");
switch (timesig->type) { switch (timesig->type) {
default: default:
@@ -1459,6 +1462,7 @@ void event_timesig (timesig)
set_complex_barpoint( set_complex_barpoint(
&current_voice->timesig, &toabc_voice->bar_break); &current_voice->timesig, &toabc_voice->bar_break);
} }
have_spacing_scheme = 1; /* [JA] 2021-05-25 */
} }
break; break;
} }
@@ -1470,16 +1474,28 @@ void event_timesig (timesig)
breakpoint.num = timesig->num; breakpoint.num = timesig->num;
breakpoint.denom = timesig->denom; breakpoint.denom = timesig->denom;
if (timesig->num == 3) { /* [JA] 2021-05-25 */
/* handles 3/2, 3/4, 3/8 */
breakpoint.num = timesig->num / 3;
breakpoint.denom = timesig->denom;
have_spacing_scheme = 1;
}
if ((timesig->num == 9) || (timesig->num == 6)) { if ((timesig->num == 9) || (timesig->num == 6)) {
breakpoint.num = 3; breakpoint.num = 3;
breakpoint.denom = barlen.denom; breakpoint.denom = barlen.denom;
have_spacing_scheme = 1;
}; };
if (timesig->num % 2 == 0) { if (timesig->num % 2 == 0) {
breakpoint.num = barlen.num / 2; breakpoint.num = barlen.num / 2;
breakpoint.denom = barlen.denom; breakpoint.denom = barlen.denom;
have_spacing_scheme = 1;
}; };
barend = timesig->num / breakpoint.num; barend = timesig->num / breakpoint.num;
} }
if (newspacing && !have_spacing_scheme) {
/* [JA] 2021-05-25 */
event_warning ("Do not know how to group notes in this time signature");
}
inmusic = 0; inmusic = 0;
} }
@@ -1874,7 +1890,7 @@ char* replist;
void event_space() void event_space()
{ {
if (!newspacing) { if (!(newspacing && have_spacing_scheme)) {
emit_string(" "); emit_string(" ");
}; };
} }
@@ -1929,7 +1945,7 @@ int n, q, r;
if (tuplenotes != 0) { if (tuplenotes != 0) {
event_error("tuple within tuple not allowed"); event_error("tuple within tuple not allowed");
}; };
if (newspacing) { if (newspacing && have_spacing_scheme) {
emit_char(' '); emit_char(' ');
} }
emit_int_sprintf("(%d", n); emit_int_sprintf("(%d", n);
@@ -2504,7 +2520,7 @@ int xoctave, n, m;
if ((!ingrace) && (!inchord)) { if ((!ingrace) && (!inchord)) {
addunits(n, m); addunits(n, m);
}; };
if (newspacing) { if (newspacing && have_spacing_scheme) {
consider_break_after_note(prev_tuplenotes); consider_break_after_note(prev_tuplenotes);
}; };
} }
@@ -2594,7 +2610,7 @@ int xoctave, n, m;
if ((!ingrace) && (!inchord)) { if ((!ingrace) && (!inchord)) {
addunits(n, m); addunits(n, m);
}; };
if (newspacing) { if (newspacing && have_spacing_scheme) {
barpoint.num = count.num * breakpoint.denom; barpoint.num = count.num * breakpoint.denom;
barpoint.denom = breakpoint.num * count.denom; barpoint.denom = breakpoint.num * count.denom;
reduce(&barpoint.num, &barpoint.denom); reduce(&barpoint.num, &barpoint.denom);

View File

@@ -22,7 +22,7 @@
/* yapstree.c - back-end for abc parser. */ /* yapstree.c - back-end for abc parser. */
/* generates a data structure suitable for typeset music */ /* generates a data structure suitable for typeset music */
#define VERSION "1.86 December 10 2020 yaps" #define VERSION "1.87 May 25 2021 yaps"
#include <stdio.h> #include <stdio.h>
#ifdef USE_INDEX #ifdef USE_INDEX
#define strchr index #define strchr index