diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2019-01-09 23:14:12 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2019-01-09 23:14:12 +0000 |
commit | b8b72a0740514b41b570cda48d26ef3999463023 (patch) | |
tree | fe06e6fc8c5f58ea50dad8854bceb652df64c7af /Build/source/utils/autosp/autosp-src | |
parent | 9823a3300cfc8502e141583168741e3d8f757537 (diff) |
autosp 2019-01-08
git-svn-id: svn://tug.org/texlive/trunk@49653 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/autosp/autosp-src')
26 files changed, 2485 insertions, 2214 deletions
diff --git a/Build/source/utils/autosp/autosp-src/ChangeLog b/Build/source/utils/autosp/autosp-src/ChangeLog index 79aa95597a2..2fae8e507ac 100644 --- a/Build/source/utils/autosp/autosp-src/ChangeLog +++ b/Build/source/utils/autosp/autosp-src/ChangeLog @@ -1,5 +1,13 @@ AUTOSP +2019-01-08 + + adjust cspacing for new beaming after first collective beam note + beaming[i] = 0 for \tqq and \tqqq (but not \nqq \nqqq) + checking for EOF after fgets, missing output format + output_rests for conventional notes commands + refactor source code + 2018-02-23 Avoid aborting for \endvolta... diff --git a/Build/source/utils/autosp/autosp-src/Makefile.am b/Build/source/utils/autosp/autosp-src/Makefile.am index c00b15cfb94..d79642d21d8 100644 --- a/Build/source/utils/autosp/autosp-src/Makefile.am +++ b/Build/source/utils/autosp/autosp-src/Makefile.am @@ -1,8 +1,9 @@ bin_PROGRAMS = autosp rebar tex2aspc -autosp_SOURCES = utils.h utils.c autosp.c +autosp_SOURCES = utils.h utils.c autosp.h autosp.c process_score.h process_score.c \ + process_command.h process_command.c status.c spacing_note.c xtuplet.c rebar_SOURCES = utils.h utils.c rebar.c tex2aspc_SOURCES = utils.h utils.c tex2aspc.c -AM_CFLAGS = -O4 -ansi -Wall -Wextra -pedantic-errors +AM_CFLAGS = -O4 -ansi -Wall -Wextra -pedantic-errors -Werror dist_man_MANS = autosp.1 rebar.1 tex2aspc.1 ## Tests ## @@ -12,6 +13,6 @@ EXTRA_DIST = EXTRA_DIST += $(TESTS) DISTCLEANFILES = -EXTRA_DIST += tests/quod2.aspc tests/quod2.tex tests/quod3.aspc tests/quod4.aspc +EXTRA_DIST += tests/quod2.aspc tests/quod2.tex tests/quod3.aspc tests/quod4.tex tests/quod4.aspc DISTCLEANFILES += quod2.* quod3.* quod4.* diff --git a/Build/source/utils/autosp/autosp-src/Makefile.in b/Build/source/utils/autosp/autosp-src/Makefile.in index b08e3cb8495..10d1eede27b 100644 --- a/Build/source/utils/autosp/autosp-src/Makefile.in +++ b/Build/source/utils/autosp/autosp-src/Makefile.in @@ -95,7 +95,9 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" PROGRAMS = $(bin_PROGRAMS) -am_autosp_OBJECTS = utils.$(OBJEXT) autosp.$(OBJEXT) +am_autosp_OBJECTS = utils.$(OBJEXT) autosp.$(OBJEXT) \ + process_score.$(OBJEXT) process_command.$(OBJEXT) \ + status.$(OBJEXT) spacing_note.$(OBJEXT) xtuplet.$(OBJEXT) autosp_OBJECTS = $(am_autosp_OBJECTS) autosp_LDADD = $(LDADD) am_rebar_OBJECTS = utils.$(OBJEXT) rebar.$(OBJEXT) @@ -469,14 +471,16 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -autosp_SOURCES = utils.h utils.c autosp.c +autosp_SOURCES = utils.h utils.c autosp.h autosp.c process_score.h process_score.c \ + process_command.h process_command.c status.c spacing_note.c xtuplet.c + rebar_SOURCES = utils.h utils.c rebar.c tex2aspc_SOURCES = utils.h utils.c tex2aspc.c -AM_CFLAGS = -O4 -ansi -Wall -Wextra -pedantic-errors +AM_CFLAGS = -O4 -ansi -Wall -Wextra -pedantic-errors -Werror dist_man_MANS = autosp.1 rebar.1 tex2aspc.1 TESTS = autosp.test rebar.test tex2aspc.test EXTRA_DIST = $(TESTS) tests/quod2.aspc tests/quod2.tex \ - tests/quod3.aspc tests/quod4.aspc + tests/quod3.aspc tests/quod4.tex tests/quod4.aspc DISTCLEANFILES = quod2.* quod3.* quod4.* all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am @@ -594,9 +598,14 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/autosp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/process_command.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/process_score.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rebar.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spacing_note.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/status.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tex2aspc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xtuplet.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< diff --git a/Build/source/utils/autosp/autosp-src/README b/Build/source/utils/autosp/autosp-src/README index ea1b5218811..e9abdc25d56 100644 --- a/Build/source/utils/autosp/autosp-src/README +++ b/Build/source/utils/autosp/autosp-src/README @@ -1,5 +1,5 @@ This is the README for the autosp package, -version 2018-02-23. +version 2019-01-08. autosp is a preprocessor that generates note-spacing commands for MusiXTeX scores. It simplifies the creation diff --git a/Build/source/utils/autosp/autosp-src/autosp.1 b/Build/source/utils/autosp/autosp-src/autosp.1 index 3d51ccd5947..547933a96d6 100644 --- a/Build/source/utils/autosp/autosp-src/autosp.1 +++ b/Build/source/utils/autosp/autosp-src/autosp.1 @@ -14,7 +14,7 @@ autosp \- preprocessor to generate note-spacing commands for MusiXTeX scores .IR infile [\fR.aspc\fP] .RI [ outfile [ \fR.tex\fP ]] - +.SH DESCRIPTION This program makes it easier to create MusiXTeX scores by converting (non-standard) commands of the form \\anotes ... \\en into one or more conventional note-spacing commands (\\notes \\Notes \\NOtes ...), diff --git a/Build/source/utils/autosp/autosp-src/autosp.c b/Build/source/utils/autosp/autosp-src/autosp.c index 65dd02546c4..8737eb1259e 100644 --- a/Build/source/utils/autosp/autosp-src/autosp.c +++ b/Build/source/utils/autosp/autosp-src/autosp.c @@ -1,6 +1,6 @@ -char version[12] = "2018-02-23"; +char version[12] = "2019-01-08"; -/* Copyright (C) 2014-18 R. D. Tennent School of Computing, +/* Copyright (C) 2014-19 R. D. Tennent School of Computing, * Queen's University, rdt@cs.queensu.ca * * This program is free software; you can redistribute it @@ -80,123 +80,8 @@ char version[12] = "2018-02-23"; * */ -# include "utils.h" +# include "autosp.h" -#ifdef HAVE_CONFIG_H /* for TeXLive */ -#include <config.h> -#endif - -# ifdef KPATHSEA -# include <kpathsea/getopt.h> -# else -# include <getopt.h> -# endif - -# ifdef HAVE_STDBOOL_H -# include <stdbool.h> -# else -# ifndef HAVE__BOOL -# define _Bool signed char -# endif -# define bool _Bool -# define true 1 -# define false 0 -# endif - -# define PRIVATE static - -# define SHORT_LEN 256 -# define MAX_STAFFS 9 - -# define SMALL_NOTE 512 -# define SP(note) (SMALL_NOTE/note) -/* note = { 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 } */ -# define MAX_SPACING 2*SP(1) -# define APPOGG_SPACING SP(64)+SP(256) /* not a legitimate spacing */ -# define notespp "\\vnotes2.95\\elemskip" -# define Notespp "\\vnotes3.95\\elemskip" -# define NOtespp "\\vnotes4.95\\elemskip" -# define NOTespp "\\vnotes6.95\\elemskip" -# define NOTEsp "\\vnotes9.52\\elemskip" -# define APPOGG_NOTES "\\vnotes1.45\\elemskip" - -PRIVATE bool debug = false; -PRIVATE char infilename[SHORT_LEN]; -PRIVATE char *infilename_n = infilename; -PRIVATE char outfilename[SHORT_LEN]; -PRIVATE char *outfilename_n = outfilename; -PRIVATE char logfilename[SHORT_LEN]; -PRIVATE char *logfilename_n = logfilename; - - -PRIVATE FILE *infile, *outfile, *logfile; - -PRIVATE char line[LINE_LEN]; /* line of input */ - -PRIVATE int ninstr = 1; /* number of instruments */ -PRIVATE int staffs[MAX_STAFFS] = {0,1}; /* number of staffs for ith instrument*/ -PRIVATE int nstaffs = 1; /* number of staffs */ -PRIVATE int nastaffs = 1; /* number of active staffs; */ -PRIVATE char terminator[MAX_STAFFS]; /* one of '&' "|', '$' */ -PRIVATE bool active[MAX_STAFFS]; /* is staff i active? */ - -PRIVATE char *notes[MAX_STAFFS]; /* note segment for ith staff */ -PRIVATE char *current[MAX_STAFFS]; - -PRIVATE int spacings[MAX_STAFFS]; /* spacing for ith staff */ -PRIVATE int spacing = MAX_SPACING; /* spacing for current notes */ -PRIVATE int old_spacing = MAX_SPACING; - -PRIVATE int vspacing[MAX_STAFFS]; /* virtual-note (skip) spacing */ -PRIVATE bool vspacing_active[MAX_STAFFS]; /* virtual-note spacing active? */ - /* used to preclude unnecessary pre-accidental skips */ - -PRIVATE bool nonvirtual_notes; - /* used to preclude output of *only* virtual notes */ - -PRIVATE int cspacing[MAX_STAFFS]; /* nominal collective-note spacing */ -PRIVATE char collective[MAX_STAFFS][SHORT_LEN]; - /* prefixes for collective note sequences */ -PRIVATE bool first_collective[MAX_STAFFS]; - -PRIVATE int restbars = 0; -PRIVATE char deferred_bar[SHORT_LEN]; /* deferred \bar (or \endpiece etc.) */ -PRIVATE bool Changeclefs = false; /* output \Changeclefs after \def\atnextbar */ - -PRIVATE int beaming[MAX_STAFFS]; /* spacing for beamed notes */ -PRIVATE int new_beaming; -PRIVATE int semiauto_beam_notes[MAX_STAFFS]; /* semi-automatic beam notes */ - -/* save-restore state for a staff; used in process_xtuplet */ -PRIVATE int beamingi; -PRIVATE char *currenti; -PRIVATE int cspacingi; -PRIVATE int vspacingi; -PRIVATE char collectivei[SHORT_LEN]; -PRIVATE bool first_collectivei; - -PRIVATE int xtuplet[MAX_STAFFS]; /* x for xtuplet in staff i */ - -PRIVATE bool appoggiatura; -PRIVATE bool dottedbeamnotes = false; /* dotted beam notes ignored? */ - -PRIVATE bool bar_rest[MAX_STAFFS]; - -PRIVATE char outstrings[MAX_STAFFS][LINE_LEN]; - /* accumulate commands to be output */ -PRIVATE char *n_outstrings[MAX_STAFFS]; - -PRIVATE int global_skip; - /* = 1, 2, 3, or 4 for (non-standard) commands \QQsk \HQsk \TQsk \Qsk */ - /* = 5 for five commas and double-flat accidental spacing */ - /* = 6 for six commas */ -PRIVATE char global_skip_str[7][16] -= { "","\\qqsk","\\hqsk","\\tqsk","\\qsk","\\qsk\\qqsk","\\qsk\\hqsk" }; - /* all based on \elemskip, not \noteskip */ - -PRIVATE char TransformNotes2[SHORT_LEN] = {'\0'}; - /* 2nd argument of \TransformNotes */ -PRIVATE bool TransformNotesDefined = false; PRIVATE void usage () @@ -207,1866 +92,12 @@ usage () } -PRIVATE -char *ps(int spacing) -/* convert spacing value to note value(s) */ -{ char *s = malloc(SHORT_LEN); - char *s_n; - if (s == NULL) error ("Not enough memory"); - s_n = s; - *s = '\0'; - if (spacing == MAX_SPACING) - sprintf(s, "MAX_SPACING"); - else if (spacing == 0) - sprintf(s, "0"); - else - { int n = 1; - while (true) - { if (spacing >= SMALL_NOTE/n) - { s_n = s_n + sprintf (s_n, "SP(%d)", n); - spacing = spacing - SMALL_NOTE/n; - if (spacing > 0) - s_n = s_n + sprintf (s_n, "+"); - else break; - } - n = 2*n; - } - } - return s; -} - -PRIVATE void -note_segment (char *s) -{ char *t; - t = strpbrk (s, "|&$"); - if (t == NULL) t = s + strlen (s); - while (s < t) - { fputc (*s, logfile); s++; } - fputc ('\n', logfile); -} - -PRIVATE void -status (int i) -{ - if (active[i]) - { fprintf (logfile, "notes[%d]=", i); note_segment (notes[i]); - fprintf (logfile, "current[%d]=", i); note_segment (current[i]); - fprintf (logfile, "spacings[%d]=%s\n", i, ps(spacings[i])); - fprintf (logfile, "vspacing[%d]=%s\n", i, ps(vspacing[i])); - fprintf (logfile, "outstrings[%d]=%s\n", i, outstrings[i]); - if (xtuplet[i] > 1) - fprintf (logfile, "xtuplet[%d]=%d\n", i, xtuplet[i]); - - } -} - -PRIVATE void -status_spacing (void) -{ - fprintf (logfile, "spacing=%s\n", ps(spacing)); - fprintf (logfile, "old_spacing=%s\n", ps(old_spacing)); -} - -PRIVATE void -status_all (void) -{ int i; - for (i=1; i <= nstaffs; i++) - if (active[i]) status (i); - status_spacing (); - fprintf (logfile, "nastaffs=%d\n", nastaffs); - if (dottedbeamnotes) - fprintf (logfile, "dottedbeamnotes == true\n"); -} - -PRIVATE void -status_collective (int i) -{ - if (active[i]) - { fprintf (logfile, "cspacing[%d]=%s\n", i, ps(cspacing[i])); - fprintf (logfile, "collective[%d]=%s\n", i, collective[i]); - fprintf (logfile, "first_collective[%d]=%d\n", i, first_collective[i]); - } -} - -PRIVATE void -status_beam (int i) -{ - if (active[i]) - { fprintf (logfile, "beaming[%d]=%s\n", i, ps(beaming[i])); } -} - -PRIVATE -void analyze_notes (char **ln) -/* divide material from *ln to \en into notes[i] segments - and initialize terminator[i] etc. */ -{ - int i; char *s; char *t; - int newlines = 0; - s = *ln+1; /* skip "/" */ - while (isalpha(*s)) {s++;} /* skip rest of the initial command */ - while (true) - { /* look for \en */ - t = strstr(s, "\\en"); - if (t != NULL) break; - /* replace EOL by a blank and append another line of input */ - { char new_line[LINE_LEN]; - char *nl; - if (fgets (new_line, LINE_LEN, infile) == NULL) - error ("Unexpected EOF."); - nl = new_line; - while (*nl == ' ') nl++; /* avoid spaces */ - t = strpbrk (s, "\n%"); - if (t == NULL) error ("Missing EOL."); - if (*t == '\n') - { *t = ' '; t++;} - *t = '\0'; - if (append (line, &t, nl, LINE_LEN) >= LINE_LEN) - error ("Line too long."); - newlines++; - } - } - /* t -> "\en" */ - if ( prefix("\\enotes", t) ) *ln = t+7; - else *ln = t+3; - *t = '$'; /* replace '\' by '$' (a distinctive terminating character) */ - for (i=1; i <= nstaffs; i++) - { char *tt; - while (*s == ' ') s++; /* skip spaces */ - if (active[i]) - { notes[i] = s; - current[i] = s; - } - tt = strpbrk (s, "|&$"); - if (tt == NULL) error ("can't parse note-spacing command."); - s = tt; - terminator[i] = *s; - if (*s != '$') s++; - } - lineno = lineno + newlines; - - /* initialize: */ - spacing = MAX_SPACING; - old_spacing = MAX_SPACING; - appoggiatura = false; - global_skip = 0; - for (i=1; i <= nstaffs; i++) - { - if (active[i]) - { n_outstrings[i] = outstrings[i]; - *n_outstrings[i] = '\0'; - vspacing[i] = 0; - vspacing_active[i] = false; - collective[i][0] = '\0'; - cspacing[i] = MAX_SPACING; - first_collective[i] = false; - xtuplet[i] = 1; - } - } - if (debug) - { fprintf (logfile, "\nAfter analyze_notes:\n"); - status_all (); - } -} - -PRIVATE -void checkc (char *s, char c) -{ if (*s != c) - { - printf ("Error on line %d: Expected %c but found %d:\n%s\n", lineno, c, *s, line); - exit (EXIT_FAILURE); - } -} - -PRIVATE -void checkn (char *s) -{ if (strpbrk (s, "0123456789") != s) - { - printf ("Error on line %d: Expected digit but found %c:\n%s\n", lineno, *s, line); - exit (EXIT_FAILURE); - } -} - -PRIVATE -void filter_output (int i) -{ /* discard \sk \bsk \Qsk \TQsk \HQsk \QQsk and \Cpause */ - char *s = notes[i]; - while (s < current[i]) - { char *t; - t = strpbrk (s+1, "\\&|$"); - if (t == NULL || t > current[i]) t = current[i]; - if (!prefix ("\\sk", s) - && !prefix ("\\bsk", s) - && !prefix ("\\Cpause", s) - && !prefix ("\\Qsk", s) - && !prefix ("\\HQsk", s) - && !prefix ("\\TQsk", s) - && !prefix ("\\QQsk", s) - && !prefix ("\\Triolet", s) - && !prefix ("\\Xtuplet", s) ) - { - while (s < t) - { while (*s == ',') s++; /* global skips */ - *n_outstrings[i] = *s; - n_outstrings[i]++; s++; - } - *(n_outstrings[i]) = '\0'; - } - s = t; - } - notes[i] = s; -} - -PRIVATE -void output_notes (int i) -/* append from notes[i] up to current[i] to outstrings[i] */ -{ if (debug) - { fprintf (logfile, "\nEntering output_notes:\n"); - status (i); - } - if (debug) - { - fprintf (logfile, "\nAppending %s for global_skip=%i\n", global_skip_str[global_skip], global_skip); - } - append (outstrings[i], &(n_outstrings[i]), global_skip_str[global_skip], LINE_LEN); - if (vspacing[i] > 0) - { - if (nonvirtual_notes) - append (outstrings[i], &(n_outstrings[i]), "\\sk", LINE_LEN); - vspacing[i] = vspacing[i] - spacing; - } - else if (collective[i][0]) - { - if (debug) - { fprintf (logfile, "\nBefore outputting collective note:\n"); - status (i); - status_collective (i); - } - if (!first_collective[i]) - append (outstrings[i], &(n_outstrings[i]), collective[i], LINE_LEN); - first_collective[i] = false; - filter_output (i); - append (outstrings[i], &(n_outstrings[i]), "}", LINE_LEN); - if (*notes[i] == '}') - { collective[i][0] = '\0'; - cspacing[i] = 0; - notes[i]++; - } - if (*notes[i] == '}') /* close of {\tinynotesize..{}}? */ - { append (outstrings[i], &(n_outstrings[i]), "}", LINE_LEN); - notes[i]++; - } - if (debug) - { fprintf (logfile, "\nAfter outputting collective note:\n"); - status (i); - status_collective (i); - } - } - else - filter_output (i); - if (debug) - { fprintf (logfile, "\nAfter output_notes:\n"); - status (i); - status_spacing (); - } -} - -PRIVATE -void pseudo_output_notes (int i) -{ /* process notes like output_notes but without outputting */ - if (vspacing[i] > 0) - vspacing[i] = vspacing[i] - spacing; - else if (collective[i][0]) - { - first_collective[i] = false; - if (*current[i] == '}') - { collective[i][0] = '\0'; - current[i]++; - } - } -} - -PRIVATE -void update_global_skip (int n) -/* global skips may be used in more than one staff */ -{ - if (n>6) - { warning ("Too many commas."); n = 6; } - if (global_skip < n) global_skip = n; -} - -PRIVATE -int collective_note (int i) -{ char *s = current[i]; - int spacing = cspacing[i]; - if (debug) - { fprintf (logfile, "\nEntering collective_note:\n"); - status (i); - status_collective (i); - } - while (true) /* search for alphabetic or numeric note (or asterisk) */ - { int n = 0; - while (*s == ',') - { n++; s++; } /* global skips */ - update_global_skip (n); - /* commas will be discarded by filter_output (i) */ - if (*s == '.' && new_beaming == 0 && !dottedbeamnotes) - spacing = (int)(spacing * 1.50); - else if ( (*s == '^' || *s == '_' || *s == '=' || *s == '>') - && !vspacing_active[i] /* is additional spacing needed? */ - ) - /* leave space for normal accidentals */ - { update_global_skip (3) ; - if (debug) - { fprintf (logfile, "\nLeave space for accidental\n"); - status (i); - status_beam (i); - status_collective (i); - } - } - else if ( (*s == '<') /* double-flat */ - && !vspacing_active[i] /* is additional spacing needed? */ - ) - { update_global_skip (5); - if (debug) - { fprintf (logfile, "\nLeave space for double-flat\n"); - status (i); - status_beam (i); - status_collective (i); - } - } - else if (isalnum (*s) || *s == '*') - { - s++; - while (*s == '\'' || *s == '`' || *s == '!') - /* transposition characters */ - s++; - current[i] = s; - if (debug) - { fprintf (logfile, "\nAfter collective_note:\n"); - status (i); - status_collective (i); - } - vspacing_active[i] = false; - return spacing; - } - s++; - } -} - -PRIVATE -void beam_initiation (char *s, int i) -{ - if ( prefix ("\\ibbbbbb", s) - || prefix ("\\Ibbbbbb", s) - || prefix ("\\nbbbbbb", s) ) - beaming[i] = SP(256); - else if ( prefix ("\\ibbbbb", s) - || prefix ("\\Ibbbbb", s) - || prefix ("\\nbbbbb", s) ) - beaming[i] = SP(128); - else if ( prefix ("\\ibbbb", s) - || prefix ("\\Ibbbb", s) - || prefix ("\\nbbbb", s) ) - beaming[i] = SP(64); - else if ( prefix ("\\ibbb", s) - || prefix ("\\Ibbb", s) - || prefix ("\\nbbb", s) ) - beaming[i] = SP(32); - else if ( prefix ("\\ibb", s) - || prefix ("\\Ibb", s) - || prefix ("\\nbb", s) ) - beaming[i] = SP(16); - else if ( prefix ("\\ib", s) - || prefix ("\\Ib", s) ) - beaming[i] = SP(8); - if (debug) - { fprintf (logfile, "\nAfter beam_initiation:\n"); - status (i); - status_beam (i); - } -} - -PRIVATE -void beam_termination (char *s, int i) -{ - if (debug) - { fprintf (logfile, "\nEntering beam_termination:\n"); - status (i); - status_beam (i); - } - if ( prefix ("\\tbbbbbb", s) ) - { - new_beaming = SP(128); - if (beaming[i] > SP(256)) - beaming[i] = SP(256); - } - else if ( prefix ("\\tbbbbb", s) ) - { - new_beaming = SP(64); - if (beaming[i] > SP(128)) - beaming[i] = SP(128); - } - else if ( prefix ("\\tbbbb", s) ) - { - new_beaming = SP(32); - if (beaming[i] > SP(64)) - beaming[i] = SP(64); - } - else if ( prefix ("\\tbbb", s) ) - { - new_beaming = SP(16); - if (beaming[i] > SP(32)) - beaming[i] = SP(32); - } - else if ( prefix ("\\tbb", s) ) - { - new_beaming = SP(8); - if (beaming[i] > SP(16)) - beaming[i] = SP(16); - } - else if ( prefix ("\\tb", s) ) - { - new_beaming = 0; - } - if (debug) - { fprintf (logfile, "\nAfter beam_termination:\n"); - status (i); - status_beam (i); - } -} - -PRIVATE -char *skip_balanced_text (char *s) -{ - char *t; - do - { - t = strpbrk (s, "{}"); - if (t == NULL) error ("Expected '}'"); - if (*t == '{') t = skip_balanced_text (t+1); - } - while (*t != '}'); - return t+1; -} - -PRIVATE -char *skip_arg (char *s) -{ - while (*s == ' ') s++; - if (*s == '{') - { s++; - skip_balanced_text (s); - } - else - s++; - return s; -} - -PRIVATE -int spacing_note (int i) -/* Search from current[i] for the next spacing note in the ith staff. - * Returns the spacing value and updates current[i]. - */ -{ - int spacing = MAX_SPACING; - char *s, *t; - bool tinynotesize = false; - bool doubledotted = false; - bool dotted = false; - new_beaming = 0; - if (!active[i]) return spacing; - if (vspacing[i] > 0) - { /* virtual note (i.e., a skip) */ - return vspacing[i]; - } - if (collective[i][0]) - { - nonvirtual_notes = true; - return collective_note (i); - } - if (semiauto_beam_notes[i] > 0) - { if (debug) - fprintf (logfile, "\nsemiauto_beam_notes reduced\n"); - semiauto_beam_notes[i]--; - current[i]++; - if (debug) status (i); - nonvirtual_notes = true; - return beaming[i]; - } - s = strpbrk (current[i], "\\&|$"); - if (*s != '\\') - { return spacing; } - if (debug) - { fprintf (logfile, "\nIn spacing_note:\n"); - status (i); - } - while (true) - { - if ( prefix ("\\wh", s) - || prefix ("\\breve", s) - || prefix ("\\pause", s) - || prefix ("\\wq", s) ) - { spacing = SP(1); break; } - - if ( prefix ("\\ha", s) - || (prefix ("\\hl", s) && !prefix ( "\\hloff", s) ) - - || prefix ("\\hu", s) - || prefix ("\\hp", s) - || prefix ("\\hpause", s) ) - { spacing = SP(2); break;} - - if ( prefix ("\\qa", s) - || prefix ("\\ql", s) - || prefix ("\\qu", s) - || prefix ("\\qp", s) ) - { spacing = SP(4); break; } - - if ( ( prefix ("\\ca", s) - || prefix ("\\cl", s) - || prefix ("\\cu", s) ) - && !prefix ("\\caesura", s ) ) - { spacing = SP(8); break; } - - if ( prefix ("\\ds", s ) - && !prefix ("\\dsh", s) ) - { spacing = SP(8); break; } - - if ( prefix ("\\cccc", s) ) - { spacing = SP(64); break; } - - if ( prefix ("\\ccc", s) ) - { spacing = SP(32); break; } - - if ( prefix ("\\cc", s) - && !prefix ("\\ccn", s) - && !prefix ("\\cchar", s) ) - { spacing = SP(16); break; } - - if ( prefix ("\\qs", s) - && !prefix ("\\qsk", s) - && !prefix ("\\qspace", s) ) - { spacing = SP(16); break; } - - if ( prefix ("\\hs", s) - && !prefix ("\\hsk", s) - && !prefix ("\\hsp", s) ) - { spacing = SP(32); break;} - - if ( prefix ("\\qqs", s ) - && !prefix ("\\qqsk", s) ) - { spacing = SP(64); break; } - - if ( prefix ("\\qb", s)) /* beam note */ - { spacing = beaming[i]; - if (new_beaming != 0) /* set by preceding \tb... */ - { beaming[i] = new_beaming; - new_beaming = 0; - } - if (debug) - { fprintf (logfile, "\nBeam note:\n"); - status (i); - status_beam (i); - } - break; - } - - if ( prefix ("\\Cpause", s) ) - { /* bar-centered rest */ - bar_rest[i] = true; - spacing = MAX_SPACING; - break; - } - - if (prefix("\\tqqq", s) || - prefix("\\nqqq", s) ) - { if (beaming[i] > SP(32)) - beaming[i] = SP(32); - spacing = beaming[i]; - beaming[i] = SP(16); - new_beaming = 0; - if (debug) - { fprintf (logfile, "\nAfter beam completion:\n"); - status (i); - status_beam (i); - } - break; - } - - if (prefix("\\tqq", s) || - prefix("\\nqq", s) ) - { if (beaming[i] > SP(16)) - beaming[i] = SP(16); - spacing = beaming[i]; - beaming[i] = SP(8); - new_beaming = 0; - if (debug) - { fprintf (logfile, "\nAfter beam completion:\n"); - status (i); - status_beam (i); - } - break; - } - if ( prefix("\\tq", s) - && !prefix("\\tqsk", s) ) - { spacing = beaming[i]; - new_beaming = 0; - if (debug) - { fprintf (logfile, "\nAfter beam completion:\n"); - status (i); - status_beam (i); - } - break; - } - - -/* non-spacing commands: */ - - if ( prefix ("\\ib", s) - || prefix ("\\Ib", s) - || prefix ("\\nb", s) ) - beam_initiation (s, i); - - else if ( prefix("\\tb", s) ) - beam_termination (s, i); - - else if ( prefix("\\ztq", s) ) - /* non-spacing beam termination */ - new_beaming = 0; - - else if ( prefix("\\xtuplet", s) || - prefix("\\xxtuplet", s)|| - prefix("\\Xtuplet", s) ) - { char *t = s+1; - while (!isdigit(*t)) t++; - xtuplet[i] = atoi(t); - } - else - if ( prefix("\\triolet", s) - || prefix("\\Triolet", s) - || prefix("\\uptrio", s) - || prefix("\\downtrio", s) - || prefix("\\uptuplet", s) - || prefix("\\downtuplet", s) ) - { - xtuplet[i] = 3; - } - - else if ( prefix("\\zchar", s) - || prefix("\\lchar", s) - || prefix("\\cchar", s) - || prefix("\\zcn", s) - || prefix("\\lcn", s) - || prefix("\\ccn", s) ) - { /* need to skip two arguments, possibly with embedded commands */ - char *t; - t = strpbrk (s+1, " {"); - if (t == NULL) error ("Argument expected"); - t = skip_arg (t); - t = skip_arg (t); - } - - else if ( prefix("\\tinynotesize", s) ) - { - tinynotesize = true; - appoggiatura = true; - } - - else if (prefix("\\ppt", s) - || prefix("\\pppt", s) ) - { - doubledotted = true; /* triple-dotted spaced as double-dotted */ - } - else if (prefix("\\pt", s) && !prefix("\\ptr", s)) - { - dotted = true; - } - else if ( prefix ("\\Dqbb", s) ) - { semiauto_beam_notes[i] = 1; - beaming[i] = SP(16); - current[i] = current[i] + 8; - nonvirtual_notes = true; - return beaming[i]; - } - else if ( prefix ("\\Dqb", s) ) - { if (debug) fprintf (logfile, "\nFound \\Dqb\n"); - semiauto_beam_notes[i] = 1; - beaming[i] = SP(8); - current[i] = current[i] + 7; - nonvirtual_notes = true; - if (debug) status (i); - return beaming[i]; - } - else if ( prefix ("\\Tqbb", s) ) - { semiauto_beam_notes[i] = 2; - beaming[i] = SP(16); - current[i] = current[i] + 8; - nonvirtual_notes = true; - return beaming[i]; - } - else if ( prefix ("\\Tqb", s) ) - { semiauto_beam_notes[i] = 2; - beaming[i] = SP(8); - current[i] = current[i] + 7; - nonvirtual_notes = true; - return beaming[i]; - } - else if ( prefix ("\\Qqbb", s) ) - { semiauto_beam_notes[i] = 3; - beaming[i] = SP(16); - current[i] = current[i] + 8; - nonvirtual_notes = true; - return beaming[i]; - } - else if ( prefix ("\\Qqb", s) ) - { semiauto_beam_notes[i] = 3; - beaming[i] = SP(8); - current[i] = current[i] + 7; - nonvirtual_notes = true; - return beaming[i]; - } - else if (prefix ("\\rlap", s) ) - /* skip the argument, as it must be regarded as non-spacing */ - { char *t; - t = strpbrk (s+1, " {\\"); - if (t == NULL) error ("Argument expected"); - if (*t == '\\') - s = t+1; - else - s = skip_arg(t); - } - else if (prefix ("\\Hsk", s) ) - update_global_skip (5); - else if (prefix ("\\Qsk", s) ) - update_global_skip (4); - else if (prefix ("\\TQsk", s) ) - update_global_skip (3); - else if (prefix ("\\HQsk", s) ) - update_global_skip (2); - else if (prefix ("\\QQsk", s) ) - update_global_skip (1); - - /* Command is non-spacing. */ - /* Skip ahead to the next command. */ - s = strpbrk (s+1, "\\&|$"); - - if ( *s != '\\') - { current[i] = s; - if (debug) - { fprintf (logfile, "\nAfter spacing_note:\n"); - status (i); - } - return spacing; - } - } /* end of while (true) loop */ - - if (spacing < MAX_SPACING) - nonvirtual_notes = true; - if (prefix ("\\whpp", s) - || prefix ("\\hupp", s) - || prefix ("\\hlpp", s) - || prefix ("\\happ", s) - || prefix ("\\hspp", s) - || prefix ("\\hppp", s) - || prefix ("\\hpausepp", s) - || prefix ("\\qupp", s) - || prefix ("\\qlpp", s) - || prefix ("\\qapp", s) - || prefix ("\\qspp", s) - || prefix ("\\qppp", s) - || prefix ("\\qqspp", s) - || prefix ("\\cupp", s) - || prefix ("\\clpp", s) - || prefix ("\\ccupp", s) - || prefix ("\\cclpp", s) - || prefix ("\\cccupp", s) - || prefix ("\\ccclpp", s) - || prefix ("\\qbpp", s) - || prefix ("\\dspp", s) - || doubledotted ) - { spacing = (int)(spacing * 1.75); doubledotted = false;} - else - if (prefix ("\\whp", s) - || prefix ("\\hup", s) - || prefix ("\\hlp", s) - || prefix ("\\hap", s) - || prefix ("\\hsp", s) - || prefix ("\\hpp", s) - || prefix ("\\hpausep", s) - || prefix ("\\qup", s) - || prefix ("\\qlp", s) - || prefix ("\\qap", s) - || prefix ("\\qsp", s) - || prefix ("\\qqsp", s) - || prefix ("\\qpp", s) - || prefix ("\\cup", s) - || prefix ("\\clp", s) - || prefix ("\\ccup", s) - || prefix ("\\cclp", s) - || prefix ("\\cccup", s) - || prefix ("\\ccclp", s) - || prefix ("\\qbp", s) - || prefix ("\\dsp", s) - || dotted ) - { spacing = (int)(spacing * 1.5); dotted = false; } - - t = strpbrk (s+1, "{\\&|$"); /* collective coding? */ - if (*t == '{') /* {...} */ - { /* Save prefix in collective[i]. - * It will be output for every note in the collective */ - char *ss = s; - char *tt = collective[i]; - while (ss <= t) - { *tt = *ss; tt++, ss++; } - *tt = '\0'; - current[i] = t+1; - if (tinynotesize) spacing = APPOGG_SPACING; - cspacing[i] = spacing; - first_collective[i] = true; - return collective_note (i); - } - if (tinynotesize) spacing = APPOGG_SPACING; - current[i] = strpbrk (s+1, "\\&|$"); - if (debug) - { fprintf (logfile, "\nAfter spacing_note:\n"); - status (i); - } - vspacing_active[i] = false; - return spacing; -} - -PRIVATE void -output_rests (void) -{ /* outputs a multi-bar rest and the deferred_bar command */ - int i; - fprintf ( outfile, "\\NOTes\\sk\\en%%\n" ); - fprintf (outfile, "\\def\\atnextbar{\\znotes"); - if (restbars == 1) - fprintf ( outfile, "\\centerpause" ); - else - fprintf ( outfile, "\\centerHpause{%d}", restbars ); - fprintf (outfile, "\\en}%%\n"); - if (Changeclefs) /* \Changeclefs has to be output after \def\atnextbar... */ - { - fprintf ( outfile, "\\Changeclefs%%\n"); - Changeclefs = false; - } - if (restbars > 1) - fprintf ( outfile, "\\advance\\barno%d%%\n", restbars-1 ); - restbars = 0; - for (i=1; i <= nstaffs; i++) bar_rest[i] = false; - fprintf ( outfile, "%s%%\n", deferred_bar); - deferred_bar[0] = '\0'; -} - -void initialize_notes () -{ int i; - if (debug) - { fprintf (logfile, "\nEntering initialize_notes\n"); - status_all (); - } - if ( nastaffs == 1 && spacing != MAX_SPACING && restbars > 0) - output_rests (); - - if (spacing == MAX_SPACING) - fprintf (outfile, "\\znotes"); - else if (spacing == SP(1)+SP(2) || spacing == SP(1)+SP(2)+SP(4)) - fprintf (outfile, NOTEsp); - else if (spacing == SP(1)) - fprintf (outfile, "\\NOTEs"); - else if (spacing == SP(2)+SP(4)+SP(8)) - fprintf (outfile, "%s", NOTespp); - else if (spacing == SP(2)+SP(4) ) - fprintf (outfile, "\\NOTesp"); - else if (spacing == SP(2)) - fprintf (outfile, "\\NOTes"); - else if (spacing == SP(4)+SP(8) ) - fprintf (outfile, "\\NOtesp"); - else if (spacing == SP(4)+SP(8)+SP(16) ) - fprintf (outfile, "%s", NOtespp); - else if (spacing == SP(4)) - fprintf (outfile, "\\NOtes"); - else if (spacing == SP(8)+SP(16) ) - fprintf (outfile, "\\Notesp"); - else if (spacing == SP(8)+SP(16)+SP(32)) - fprintf (outfile, "%s", Notespp); - else if (spacing == SP(8)) - fprintf (outfile, "\\Notes"); - else if (spacing == SP(16)+SP(32)+SP(64)) - fprintf (outfile, notespp); - else if (spacing == SP(16)+SP(32) ) - fprintf (outfile, "\\notesp"); - else if (spacing == SP(16) || spacing == SP(32)+SP(64) || spacing == SP(32)+SP(64)+SP(128)) - fprintf (outfile, "\\notes"); - else if (spacing == SP(32) || spacing == SP(64)+SP(128) || spacing == SP(64)+SP(128)+SP(256)) - fprintf (outfile, "\\nnotes"); - else if (spacing == SP(64) ) - fprintf (outfile, "\\nnnotes"); - else if (spacing == APPOGG_SPACING) - fprintf (outfile, "%s", APPOGG_NOTES); - else - { printf ("Error on line %d: spacing %s not recognized.\n", lineno, ps(spacing)); - exit (EXIT_FAILURE); - } - if (debug) - { fprintf (logfile, "\noutputting \\Notes command for spacing=%s.\n", ps(spacing)); - status_all(); - } - for (i=1; i <= nstaffs; i++) - { if (active[i]) - { n_outstrings[i] = outstrings[i]; - *n_outstrings[i] = '\0'; - } - } -} - -PRIVATE -void terminate_notes () -{ int i; - char *s, *t; - if (debug) - { fprintf (logfile, "\nEntering terminate_notes:\n"); - status_all (); - } - t = TransformNotes2; - while (true) - { s = strchr (t, '#'); - if (s == NULL) - break; - while (t < s) /* output any initial \transpose etc. */ - { putc (*t, outfile); t++; } - t++; /* skip # */ - i = atoi (t) -1; t++; - if (spacing == MAX_SPACING) - { /* output any commands left in notes[i] */ - filter_output (i); - } - fprintf (outfile, "%s", outstrings[i]); - if (debug) fprintf (logfile, "\noutputting %s from outstrings[%d].\n", outstrings[i], i); - outstrings[i][0] = '\0'; - n_outstrings[i] = outstrings[i]; - if (spacing < MAX_SPACING && spacing > 2 * old_spacing) - { /* add extra space *before* much longer notes */ - fprintf (outfile, "\\hqsk"); - if (debug) fprintf (logfile, "\nExtra half-notehead space before longer notes.\n"); - } - if (*t != '\0') - { putc (*t, outfile); t++; } /* terminator */ - } - if (spacing == MAX_SPACING && old_spacing < SP(8) ) - { /* add extra space before \en */ - fprintf (outfile, "\\hqsk"); - if (debug) fprintf (logfile, "\nExtra half-notehead space before \\en.\n"); - } - fprintf (outfile, "\\en"); - if (debug) - { fprintf (logfile, "\noutputting \\en\n"); - fprintf (logfile, "\nAfter terminate_notes:\n"); - status_all (); - } -} - -PRIVATE -void process_appogg (void) -{ int i; - if (debug) - { fprintf (logfile, "\nEntering process_appogg:\n"); - status_all(); - } - - if (old_spacing < MAX_SPACING) - { char *s, *t; - if (debug) fprintf (logfile, "Terminate current notes command:\n"); - t = TransformNotes2; - while (true) - { s = strchr (t, '#'); - if (s == NULL) break; - while (t < s) /* output any initial \transpose etc. */ - { putc (*t, outfile); t++; } - t++; /* skip # */ - i = atoi (t) - 1; t++; - fprintf (outfile, "%s", outstrings[i]); - if (debug) fprintf (logfile, "\noutputting %s from outstrings[%d].\n", outstrings[i], i); - outstrings[i][0] = '\0'; - n_outstrings[i] = outstrings[i]; - if (*t != '\0') - { putc (*t, outfile); t++; } /* terminator */ - } - fprintf (outfile, "\\en"); - if (debug) - { fprintf (logfile, "\\en"); - fprintf (logfile, "\nAfter termination of notes command:\n"); - status_all (); - } - } - - if (debug) fprintf (logfile, "\nCreate a new notes command for the appoggiatura:\n"); - spacing = APPOGG_SPACING; - initialize_notes (); - spacing = MAX_SPACING; - for (i=1; i <= nstaffs; i++) - if (active[i]) - { - if (spacings[i] == APPOGG_SPACING ) - { - output_notes (i); - spacings[i] = spacing_note (i); - } - if (spacings[i] < spacing) - spacing = spacings[i]; - } - appoggiatura = false; - nonvirtual_notes = true; - old_spacing = APPOGG_SPACING; - if (debug) - { fprintf (logfile, "\nAfter process_appogg:\n"); - status_all (); - } - return; -} - -PRIVATE -void save_state (int i) -/* used in process_xtuplet */ -{ - beamingi = beaming[i]; - currenti = current[i]; - cspacingi = cspacing[i]; - vspacingi = vspacing[i]; - first_collectivei = first_collective[i]; - collectivei[0] = '\0'; - append (collectivei, NULL, collective[i], SHORT_LEN); -} - -PRIVATE -void restore_state (int i) -/* used in process_xtuplet */ -{ - beaming[i] = beamingi; - current[i] = currenti; - cspacing[i] = cspacingi; - vspacing[i] = vspacingi; - first_collective[i] = first_collectivei; - collective[i][0] = '\0'; - append (collective[i], NULL, collectivei, SHORT_LEN); -} - - -PRIVATE -void process_xtuplet (void) -{ - int i, xi=0; - int xspacing = MAX_SPACING; /* xtuplet total spacing */ - int normalized_xspacing; /* (xspacing / xtuplet) * (xtuplet - 1); */ - int xsp; - double multnoteskip; - - if (debug) - { fprintf (logfile, "\nEntering process_xtuplet:\n"); - for (i=1; i <= nstaffs; i++) - fprintf (logfile, "i=%d xtuplet[i]=%d\n", i, xtuplet[i]); - } - - if (old_spacing < MAX_SPACING) - { char *s, *t; - if (debug) fprintf (logfile, "Terminate current notes command:\n"); - t = TransformNotes2; - while (true) - { s = strchr (t, '#'); - if (s == NULL) break; - while (t < s) /* output any initial \transpose etc. */ - { putc (*t, outfile); t++; } - t++; /* skip # */ - i = atoi (t) - 1; t++; - fprintf (outfile, "%s", outstrings[i]); - if (debug) fprintf (logfile, "\noutputting %s from outstrings[%d].\n", outstrings[i], i); - outstrings[i][0] = '\0'; - n_outstrings[i] = outstrings[i]; - if (*t != '\0') - { putc (*t, outfile); t++; } /* terminator */ - } - fprintf (outfile, "\\en"); - if (debug) - { fprintf (logfile, "\\en"); - fprintf (logfile, "\nAfter termination of notes command:\n"); - status_all (); - } - } - - if (debug) - { fprintf (logfile, "\nDetermine xtuplet duration:\n"); - fflush (logfile); - } - for (i=1; i <= nstaffs; i++) - if (xtuplet[i] > 1) - { - xi = i; - save_state (xi); - pseudo_output_notes (xi); - xspacing = spacings[xi]; - while (xspacing % xtuplet[xi] != 0) - { - xspacing += spacing_note (xi); - pseudo_output_notes (xi); - if (xspacing >= MAX_SPACING) - error ("Can't determine xtuplet duration."); - } - restore_state (xi); - break; - } - if (debug) fprintf (logfile, "\nxspacing=%s\n", ps(xspacing)); - if (debug) fprintf (logfile, "xi=%d xtuplet[xi]=%d\n", xi, xtuplet[xi]); - normalized_xspacing = (xspacing / xtuplet[xi]) * (xtuplet[xi] - 1); - if (debug) - { fprintf (logfile, "normalized_xspacing=%s\n", ps(normalized_xspacing)); - } - spacing = xspacing / xtuplet[xi]; - if (debug) - { - fprintf (logfile, "\nDetermine minimal spacing over all active staffs:\n"); - } - for (i=1; i <= nstaffs; i++) - if (active[i] && xtuplet[i] == 1) - { save_state (i); - pseudo_output_notes (i); - xsp = spacings[i]; - if (spacings[i] < spacing) - spacing = spacings[i]; - while (xsp < normalized_xspacing) - { int spi = spacing_note (i); - pseudo_output_notes (i); - xsp += spi; - if (spi < spacing) - { spacing = spi; - if (debug) fprintf (logfile, "for i=%d spi=%s\n", i, ps(spi)); - } - } - restore_state (i); - } - if (debug) fprintf (logfile, "\nxspacing=%s\n", ps(spacing)); - - if (debug) fprintf (logfile, "\nCreate a new notes command for the xtuplet:\n"); - initialize_notes (); - - - if (debug) fprintf (logfile, "\nProcess non-xtuplet staffs:\n"); - for (i=1; i <= nstaffs; i++) - vspacing[i] = 0; - xsp = 0; - while (true) - { - for (i=1; i <= nstaffs; i++) - if (active[i] && xtuplet[i] == 1) - output_notes (i); - xsp += spacing; - for (i=1; i <= nstaffs; i++) - { - /* virtual notes needed? */ - if (active[i] && xtuplet[i] == 1 && spacings[i] != 0 && spacings[i] != spacing && vspacing[i] == 0) - { - vspacing[i] = spacings[i] - spacing; - } - } - if (xsp >= normalized_xspacing) break; - global_skip = 0; - for (i=1; i <= nstaffs; i++) - if (active[i] && xtuplet[i] == 1) - spacings[i] = spacing_note(i); - } - if (debug) - { fprintf (logfile, "\nAfter processing non-xtuplet staffs:\n"); - status_all (); - } - if (debug) - { - fprintf (logfile, "Generate \\multnoteskip factors.\n"); - fprintf (logfile, "xi=%d xtuplet[xi]=%d\n", xi, xtuplet[xi]); - } - multnoteskip = (double) (xtuplet[xi] - 1) / xtuplet[xi]; - for (i=1; i <= nstaffs; i++) - if (xtuplet[i] > 1) - { - n_outstrings[i] += sprintf (n_outstrings[i], "\\multnoteskip{%5.3f}", multnoteskip); - if (debug) - { fprintf (logfile, "\noutstrings[%d]=", i); - note_segment (outstrings[i]); - } - } - if (debug) fprintf (logfile, "\nRe-process xtuplet staffs:\n"); - for (i=1; i <= nstaffs; i++) - if (xtuplet[i] > 1) - { - xsp = 0; - while (true) - { output_notes (i); - xsp += spacing; - if (spacings[i] != spacing && vspacing[i] == 0) - vspacing[i] = spacings[i] - spacing; - if (xsp >= xspacing) break; - global_skip = 0; - spacings[i] = spacing_note (i); - } - } - - /* Restore normal \noteskip in the xtuplet staffs. */ - if (debug) - { - fprintf (logfile, "Restore \\multnoteskip factors.\n"); - fprintf (logfile, "xi=%d xtuplet[xi]=%d\n", xi, xtuplet[xi]); - } - multnoteskip = (double) xtuplet[xi] / (xtuplet[xi]-1); - for (i=1; i <= nstaffs; i++) - if (xtuplet[i] > 1) - { - n_outstrings[i] += sprintf (n_outstrings[i], "\\multnoteskip{%5.3f}", multnoteskip); - xtuplet[i] = 1; - } - nonvirtual_notes = true; - if (debug) - { fprintf (logfile, "\nAfter process_xtuplet:\n"); - status_all (); - } - return; -} - -PRIVATE -void generate_notes () -{ int i; - bool xtuplet_flag; - while (true) - { old_spacing = spacing; - spacing = MAX_SPACING; - global_skip = 0; - nonvirtual_notes = false; - if (debug) - { fprintf (logfile, "\nIn generate_notes:\n"); - status_all (); - } - for (i=1; i <= nstaffs; i++) - if (active[i]) - { - spacings[i] = spacing_note (i); - if (spacings[i] < spacing) - spacing = spacings[i]; - } - if (appoggiatura) - { - process_appogg (); - } - xtuplet_flag = false; - for (i=1; i <= nstaffs; i++) - if (xtuplet[i] > 1) xtuplet_flag = true; - if (xtuplet_flag) - { - process_xtuplet (); - continue; - } - if (spacing != old_spacing || spacing == MAX_SPACING) - { if (old_spacing < MAX_SPACING) - terminate_notes (); - if (spacing == MAX_SPACING || nonvirtual_notes == false) - { - if (debug) - { fprintf (logfile, "\nAfter generate_notes:\n"); - status_all (); - } - return; - } - if (old_spacing < MAX_SPACING) putc ('\n', outfile); - - initialize_notes (); - } - - for (i=1; i <= nstaffs; i++) /* append current notes to outstrings */ - if (active[i]) - output_notes (i); - for (i=1; i <= nstaffs; i++) - { - /* virtual notes needed? */ - if (active[i] && spacings[i] != MAX_SPACING && spacings[i] != spacing && vspacing[i] == 0 ) - { - vspacing[i] = spacings[i]; - vspacing_active[i] = true; - vspacing[i] = vspacing[i] - spacing; - if (debug) - { fprintf (logfile, "\nAfter vspacing initialization:\n"); - status (i); - } - } - } - } -} - - -PRIVATE -void process_command (char **ln) -{ char *s, *t; - if (debug) - { fprintf (logfile, "\nProcessing command:%s\n", *ln); - fflush (logfile); - } - if ( prefix("\\instrumentnumber", *ln) ) - { - s = strpbrk (*ln, "123456789"); - if ( s == NULL ) error ("\\instrumentnumber command unreadable."); - ninstr = atoi (s); - while (*ln <= s) { putc (**ln, outfile); (*ln)++;} - } - - if ( prefix("\\def\\nbinstrument", *ln) ) - { - s = strpbrk (*ln, "123456789"); - if ( s == NULL ) error ("\\def\\nbinstrument command unreadable."); - ninstr = atoi (s); - while (*ln <= s) { putc (**ln, outfile); (*ln)++;} - } - - else if ( prefix("\\setstaffs", *ln) ) - { /* for now, just record in staffs[i] */ - int n, p; - s = strpbrk (*ln, "123456789"); - if ( s == NULL ) error ("\\setstaffs command unreadable."); - n = (int)(*s) - (int)('0'); /* instrument number */ - s = strpbrk (s+1, "123456789"); - if ( s == NULL ) error ("\\setstaffs command unreadable."); - p = (int)(*s) - (int)('0'); /* number of staffs */ - staffs[n] = p; - while (*ln <= s) { putc (**ln, outfile); (*ln)++;} - } - - else if ( prefix("\\startpiece", *ln) ) - { - if (!TransformNotesDefined) /* create default TransformNotes2: */ - { int i, j; - t = TransformNotes2; - nstaffs = 1; - sprintf (t, "#%1i", nstaffs+1); t = t+2; - for (j=2; j <= staffs[1]; j++) - { nstaffs++; sprintf (t, "|#%1i", nstaffs+1); t = t+3; - active[nstaffs] = true; - } - for (i=2; i <= ninstr; i++) - { nstaffs++; sprintf (t, "&#%1i", nstaffs+1); t = t+3; - for (j=2; j <= staffs[i]; j++) - { nstaffs++; sprintf (t, "|#%1i", nstaffs+1); t = t+3; - active[nstaffs] = true; - } - } - nastaffs = nstaffs; - if (debug) - fprintf (logfile, "default TransformNotes2=%s\n", TransformNotes2); - } - if (nstaffs == 1) fprintf (outfile, "\\nostartrule\n"); - if (debug) - { - int j; - fprintf (logfile, "ninstr=%d nstaffs=%d nastaffs=%d\n", ninstr, nstaffs, nastaffs); - for (j=1; j <= nstaffs; j++) - fprintf (logfile, "active[%d]=%d\n", j, active[j]); - } - fprintf (outfile, "\\startpiece"); - t = strpbrk (*ln+1, "\\%\n"); - *ln = t; - } - - else if ( prefix("\\startextract", *ln) ) - { - if (!TransformNotesDefined) /* create default TransformNotes2: */ - { int i, j; - t = TransformNotes2; - nstaffs = 1; - sprintf (t, "#%1i", nstaffs+1); t = t+2; - for (j=2; j <= staffs[1]; j++) - { nstaffs++; sprintf (t, "|#%1i", nstaffs+1); t = t+3; - active[nstaffs] = true; - } - for (i=2; i <= ninstr; i++) - { nstaffs++; sprintf (t, "&#%1i", nstaffs+1); t = t+3; - for (j=2; j <= staffs[i]; j++) - { nstaffs++; sprintf (t, "|#%1i", nstaffs+1); t = t+3; - active[nstaffs] = true; - } - } - nastaffs = nstaffs; - if (debug) - fprintf (logfile, "default TransformNotes2=%s\n", TransformNotes2); - } - if (nstaffs == 1) fprintf (outfile, "\\nostartrule\n"); - fprintf (outfile, "\\startextract"); - t = strpbrk (*ln+1, "\\%\n"); - *ln = t; - } - - else if ( prefix("\\TransformNotes", *ln) ) - { /* determine ninstr, nstaffs, nastaffs, staffs[i], and active[i] */ - int i; - s = *ln + 16; /* first parameter */ - ninstr = 0; - nstaffs = 0; - while (true) - { ninstr++; nstaffs++; - staffs[ninstr] = 1; - checkc (s, '#'); s++; - checkn (s); s++; - while (*s == '|') - { staffs[ninstr]++; nstaffs++; - s++; - checkc (s, '#'); s++; - checkn (s); s++; - } - if (*s != '&') break; - s++; - } - checkc (s, '}'); s++; - s = strchr (s, '{'); - if (s == NULL) error ("Can't parse \\TransformNotes"); - s++; - /* determine TransformNotes2: */ - t = TransformNotes2; - do { *t = *s; t++; s++; } - while (*s != '}'); - *t = '\0'; /* terminate TransformNotes2 */ - TransformNotesDefined = true; - if (debug) - fprintf (logfile, "defined TransformNotes2=%s\n", TransformNotes2); - - /* determine active staffs: */ - for (i=1; i <= nstaffs; i++) active[i] = false; - nastaffs = 0; - t = strpbrk (TransformNotes2, "#}"); /* may have \transpose etc. before # */ - if (t == NULL) error ("Can't parse second argument of \\TransformNotes"); - while (*t == '#') - { if (sscanf (t, "#%d", &i) != 1) - error ("sscanf for argument number fails"); - active[i-1] = true; /* parameters start at 2 */ - nastaffs++; - t = strpbrk (t+1, "#}"); - if (t == NULL) break; - } - if (debug) - { - int j; - fprintf (logfile, "ninstr=%d nstaffs=%d nastaffs=%d\n", ninstr, nstaffs, nastaffs); - for (j=1; j <= nstaffs; j++) - fprintf (logfile, "active[%d]=%d\n", j, active[j]); - } - - /* output \TransformNotes... as a comment: */ - putc ('%', outfile); - while (*ln <= s) - { putc (**ln, outfile); (*ln)++; } - } - - else if (prefix("\\def\\atnextbar{\\znotes", *ln)) - { /* whole-bar or multi-bar rest? */ - int i; - bool centerpause = false; - *ln = *ln + 15; /* skip "\def\atnextbar{" */ - analyze_notes(ln); - for (i=1; i <= nstaffs; i++) - { - if (active[i]) - { char *t; - char *s; - t = strpbrk (notes[i], "&|$"); - if (t == NULL) t = notes[i] + strlen (notes[i]); - s = strstr (notes[i], "\\centerpause"); - if (s != NULL && s < t && nastaffs == 1) - { - bar_rest[i] = true; - centerpause = true; - } - break; - } - } - if (!centerpause) /* generate transformed \znotes ... \en */ - { - fprintf ( outfile, "\\def\\atnextbar{\\znotes"); - t = TransformNotes2; - while (true) - { - /* output TransformNotes2 prefix (\transpose etc.): */ - s = strchr (t, '#'); - if (s == NULL) break; - while (t < s) - { putc (*t, outfile); t++; } - t++; /* skip '#' */ - /* output notes: */ - i = atoi (t) - 1; t++; - s = notes[i]; - while (*s != '&' && *s != '|' && *s != '$') - { putc (*s, outfile); s++; } - if (*t != '\0') - { putc (*t, outfile); t++; } /* output terminator */ - } - fprintf (outfile, "\\en}%%\n"); - } - t = strchr (*ln, '}'); - if (t == NULL) error ("Can't find }."); - *ln = t+1; - t = strpbrk (*ln, "%\\"); - if (t == NULL ) t = *ln + strlen(*ln); - *ln = t; - } - - else if ( prefix("\\def", *ln) ) /* copy to output */ - { t = *ln + strlen(*ln); - while (*ln < t) - { fputc (**ln, outfile); - (*ln)++; - } - } - - else if ( prefix("\\anotes", *ln) ) - { if (debug) - { fprintf (logfile, "\nProcessing %s", *ln); - fprintf (logfile, "lineno=%d\n", lineno); - fflush (logfile); - } - analyze_notes (ln); - if (debug) - { fprintf (logfile, "\nBefore generate_notes *ln=%s\n", *ln); - fflush (logfile); - } - generate_notes (); - if (debug) - { fprintf (logfile, "\nAfter generate_notes *ln=%s\n", *ln); - fflush (logfile); - } - t = strpbrk (*ln, "%\\\n"); - if (t == NULL) t = *ln + strlen (*ln); - if (*t == '\n') putc ('%', outfile); - *ln = t; - } - else if ( prefix("\\nnnotes", *ln) || - prefix("\\nnnotes", *ln) || - prefix("\\nnotes", *ln) || - prefix("\\notes", *ln) || - prefix("\\Notes", *ln) || - prefix("\\NOtes", *ln) || - prefix("\\NOTes", *ln) || - prefix("\\NOTEs", *ln) || - prefix("\\znotes", *ln) ) - { - char *s, *t; - int nstaff; - if (debug) - { fprintf (logfile, "\nProcessing %s", *ln); - fprintf (logfile, "lineno=%d\n", lineno); - fflush (logfile); - } - t = *ln+1; - while ( isalpha (*t) ) t++; - s = *ln; - while (s < t) { putc (*s, outfile); s++; } - - analyze_notes (ln); - - t = TransformNotes2; - while (true) - { - /* output TransformNotes2 prefix (\transpose etc.): */ - s = strchr (t, '#'); - if (s == NULL) break; - while (t < s) - { putc (*t, outfile); t++; } - - t++; /* skip '#' */ - - /* output notes: */ - nstaff = atoi (t) - 1; t++; - s = notes[nstaff]; - while (*s != '&' && *s != '|' && *s != '$') - { putc (*s, outfile); s++; } - if (*t != '\0') - { putc (*t, outfile); t++; } /* output terminator */ - } - fprintf (outfile, "\\en\n"); - - t = strpbrk (*ln, "%\\\n"); - if (t == NULL) t = *ln + strlen (*ln); - if (*t == '\n') putc ('%', outfile); - *ln = t; - } - - else if (prefix("\\vnotes", *ln) ) - { - char *s, *t; - int nstaff; - if (debug) - { fprintf (logfile, "\nProcessing %s", *ln); - fprintf (logfile, "lineno=%d\n", lineno); - fflush (logfile); - } - s = *ln; - t = strchr (*ln+1, '\\'); /* find \elemskip */ - *ln = t; - t = t + 9; - while (s < t) { putc (*s, outfile); s++; } - - - analyze_notes (ln); - - t = TransformNotes2; - while (true) - { - /* output TransformNotes2 prefix (\transpose etc.): */ - s = strchr (t, '#'); - if (s == NULL) break; - while (t < s) - { putc (*t, outfile); t++; } - - t++; /* skip '#' */ - - /* output notes: */ - nstaff = atoi (t) - 1; t++; - s = notes[nstaff]; - while (*s != '&' && *s != '|' && *s != '$') - { putc (*s, outfile); s++; } - if (*t != '\0') - { putc (*t, outfile); t++; } /* output terminator */ - } - fprintf (outfile, "\\en\n"); - - t = strpbrk (*ln, "%\\\n"); - if (t == NULL) t = *ln + strlen (*ln); - if (*t == '\n') putc ('%', outfile); - *ln = t; - } - - else if ( prefix ("\\bar", *ln) && !prefix ("\\barno", *ln)) - { int i; - char *s, *t; - bool atnextbar = false; - for (i=1; i <= nstaffs; i++) - if (active[i] && bar_rest[i]) - { atnextbar = true; break; } - if (nastaffs == 1 && atnextbar) - { restbars++; - sprintf (deferred_bar, "\\bar"); - if (debug) fprintf (logfile, "\nrestbars increased to %d\n", restbars); - for (i=1; i<= nstaffs; i++) - bar_rest[i] = false; - *ln = *ln+4; - t = strpbrk (*ln, "\\\n"); - if (t == NULL) t = *ln + strlen (*ln); - if (*t == '\n') putc ('%', outfile); - *ln = t; - } - else - { if (atnextbar) - { fprintf (outfile, "\\def\\atnextbar{\\znotes"); - t = TransformNotes2; - while (true) - { - s = strchr (t, '#'); - if (s == NULL) - break; - while (t < s) /* output any initial \transpose etc. */ - { putc (*t, outfile); t++; } - t++; /* skip # */ - i = atoi (t) -1; t++; - if (active[i]) - { - if (bar_rest[i]) - fprintf (outfile, "\\centerpause"); - bar_rest[i] = false; - } - if (*t != '\0') - { putc (*t, outfile); t++; } /* terminator */ - } - fprintf (outfile, "\\en}%%\n"); - } - if (Changeclefs) /* \Changeclefs has to be output after \def\atnextbar... */ - { - fprintf ( outfile, "\\Changeclefs%%\n"); - Changeclefs = false; - } - t = strpbrk (*ln+1, "%\\\n"); - while (*ln < t) - { fputc (**ln, outfile); - (*ln)++; - } - if (*t == '\n') putc ('%', outfile); - *ln = t; - } - if (debug) - { fprintf (logfile, "\nAfter \\bar processing, *ln=%s\n", *ln); - fflush (logfile); - } - } - - else if ( prefix ("\\endpiece", *ln) - || prefix ("\\Endpiece", *ln) - || prefix ("\\endextract", *ln) - || prefix ("\\stoppiece", *ln) - || prefix ("\\raggedstoppiece", *ln) - || prefix ("\\rightrepeat", *ln) - || prefix ("\\leftrepeat", *ln) - || prefix ("\\alaligne", *ln) - || prefix ("\\alapage", *ln) - || prefix ("\\changecontext", *ln) - || prefix ("\\Changecontext", *ln) - || prefix ("\\zchangecontext", *ln) - || prefix ("\\zalaligne", *ln) - || prefix ("\\zalapage", *ln) ) - { int i; - bool atnextbar = false; - for (i=1; i <= nstaffs; i++) - if (active[i] && bar_rest[i]) - { atnextbar = true; break; } - if (nastaffs == 1 && atnextbar) - { restbars++; - sprintf (deferred_bar, "%s", *ln); - output_rests (); - t = strpbrk (*ln+1, "%\\\n"); - if (*t == '\n') putc ('%', outfile); - *ln = t; - } - else if (atnextbar) - { - fprintf (outfile, "\\def\\atnextbar{\\znotes"); - for (i=1; i <= nstaffs; i++) - { - if (active[i]) - { - if (bar_rest[i]) - fprintf (outfile, "\\centerpause"); - bar_rest[i] = false; - } - if ( terminator[i] != '$') putc (terminator[i], outfile); - } - fprintf (outfile, "\\en}%%\n"); - if (Changeclefs) /* \Changeclefs has to be output after \def\atnextbar... */ - { - fprintf ( outfile, "\\Changeclefs%%\n"); - Changeclefs = false; - } - t = strpbrk (*ln+1, "%\\\n"); - while (*ln < t) - { fputc (**ln, outfile); - (*ln)++; - } - if (*t == '\n') putc ('%', outfile); - *ln = t; - } - else - { if (nastaffs == 1 && restbars > 0) - output_rests (); - t = strpbrk (*ln+1, "%\\\n"); - while (*ln < t) - { fputc (**ln, outfile); - (*ln)++; - } - if (*t == '\n') putc ('%', outfile); - *ln = t; - } - if (debug) - { fprintf (logfile, "\nAfter \\bar processing, *ln=%s\n", *ln); - fflush (logfile); - } - } - - else if ( prefix ("\\znotes", *ln) ) - { - if (nastaffs == 1 && restbars > 0) - output_rests (); - fputs (*ln, outfile); - *ln = *ln + strlen(*ln); - } - - else if ( prefix ("\\Changeclefs", *ln) ) - { /* defer till after \def\atnextbar ... */ - Changeclefs = true; - *ln = *ln + strlen(*ln); - } - - else if ( prefix ("\\documentclass", *ln) ) - { - - if ( suffix( ".tex", outfilename) ) - { char newoutfilename[SHORT_LEN]; - char *newoutfilename_n = newoutfilename; - append (newoutfilename, &newoutfilename_n, infilename, sizeof (newoutfilename)); - newoutfilename_n -= 4; - *newoutfilename_n = '\0'; - append (newoutfilename, &newoutfilename_n, "ltx", sizeof (newoutfilename)); - if (rename ( outfilename, newoutfilename) > 0) - { printf ("Can't rename %s as %s\n", outfilename, newoutfilename); - exit (EXIT_FAILURE); - } - printf ("\\documentclass detected; now writing to %s.", newoutfilename); - printf ("\n\n"); - - } - fputs (*ln, outfile); - *ln = *ln + strlen(*ln); - } - - else if ( prefix ("\\end ", *ln) - || prefix ("\\end%", *ln) - || prefix ("\\end{document}", *ln) ) - { - fprintf (outfile, "%s", *ln); - exit(0); - } - - - else /* everything else */ - { - fputs (*ln, outfile); - *ln = *ln + strlen(*ln); - } -} - -PRIVATE -void process_line () -{ - char *ln; - ln = &line[0]; - while ( *ln != '\0') - { - while (*ln == ' ') { ln++; fputc (' ', outfile); } - if (*ln == '%') { - fprintf (outfile, "%s", ln); - return; - } - process_command (&ln); - } -} - -PRIVATE -void process_score () -/* process .tex file */ -{ - int c; int i; - lineno = 0; - for (i=1; i < MAX_STAFFS; i++) - { - staffs[i] = 1; - active[i] = true; - bar_rest[i] = false; - } - spacing = MAX_SPACING; - restbars = 0; - - c = getc (infile); - while ( c != EOF ) - { - ungetc (c, infile); - if (fgets(line, LINE_LEN, infile) == NULL) - error ("Unexpected EOF."); - lineno++; - process_line (); - c = getc (infile); - } /* c == EOF */ -} +bool dottedbeamnotes = false; /* dotted beam notes ignored? */ +bool debug = false; int main (int argc, char *argv[]) { int c; - char today[12]; - time_t mytime; # define NOPTS 5 struct option longopts[NOPTS] = { { "help", 0, NULL, 'h'}, @@ -2076,8 +107,6 @@ int main (int argc, char *argv[]) { NULL, 0, NULL, 0} }; - time (&mytime); - strftime (today, 11, "%Y-%m-%d", localtime (&mytime) ); printf ("This is autosp, version %s.\n", version); printf ("Copyright (C) 2014-18 R. D. Tennent\n" ); printf ("School of Computing, Queen's University, rdt@cs.queensu.ca\n" ); @@ -2182,6 +211,7 @@ int main (int argc, char *argv[]) printf ("\n\n"); fprintf (outfile, "%% Generated by autosp (%s).\n", version); + process_score (); return 0; diff --git a/Build/source/utils/autosp/autosp-src/autosp.h b/Build/source/utils/autosp/autosp-src/autosp.h new file mode 100644 index 00000000000..c8247c7eafa --- /dev/null +++ b/Build/source/utils/autosp/autosp-src/autosp.h @@ -0,0 +1,40 @@ +# include "utils.h" + +#ifdef HAVE_CONFIG_H /* for TeXLive */ +#include <config.h> +#endif + +# ifdef KPATHSEA +# include <kpathsea/getopt.h> +# else +# include <getopt.h> +# endif + +# ifdef HAVE_STDBOOL_H +# include <stdbool.h> +# else +# ifndef HAVE__BOOL +# define _Bool signed char +# endif +# define bool _Bool +# define true 1 +# define false 0 +# endif + +# define PRIVATE static + +# define SHORT_LEN 256 + +bool debug; +bool dottedbeamnotes; /* dotted beam notes ignored? */ + +char infilename[SHORT_LEN]; +char *infilename_n; +char outfilename[SHORT_LEN]; +char *outfilename_n; +char logfilename[SHORT_LEN]; +char *logfilename_n; +FILE *infile, *outfile, *logfile; + + +void process_score (); diff --git a/Build/source/utils/autosp/autosp-src/compile b/Build/source/utils/autosp/autosp-src/compile index 99e50524b3b..531136b068e 100755 --- a/Build/source/utils/autosp/autosp-src/compile +++ b/Build/source/utils/autosp/autosp-src/compile @@ -1,9 +1,9 @@ #! /bin/sh # Wrapper for compilers which do not understand '-c -o'. -scriptversion=2018-03-07.03; # UTC +scriptversion=2012-10-14.11; # UTC -# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Copyright (C) 1999-2013 Free Software Foundation, Inc. # Written by Tom Tromey <tromey@cygnus.com>. # # This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ scriptversion=2018-03-07.03; # UTC # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see <https://www.gnu.org/licenses/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -255,8 +255,7 @@ EOF echo "compile $scriptversion" exit $? ;; - cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ - icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac @@ -340,9 +339,9 @@ exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'before-save-hook 'time-stamp) +# eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" +# time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: diff --git a/Build/source/utils/autosp/autosp-src/configure b/Build/source/utils/autosp/autosp-src/configure index 182a6b718ac..92a4971a8c4 100755 --- a/Build/source/utils/autosp/autosp-src/configure +++ b/Build/source/utils/autosp/autosp-src/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for autosp 2018-02-23. +# Generated by GNU Autoconf 2.69 for autosp 2019-01-08. # # Report bugs to <rdt@cs.queensu.ca>. # @@ -580,8 +580,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='autosp' PACKAGE_TARNAME='autosp' -PACKAGE_VERSION='2018-02-23' -PACKAGE_STRING='autosp 2018-02-23' +PACKAGE_VERSION='2019-01-08' +PACKAGE_STRING='autosp 2019-01-08' PACKAGE_BUGREPORT='rdt@cs.queensu.ca' PACKAGE_URL='' @@ -1265,7 +1265,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures autosp 2018-02-23 to adapt to many kinds of systems. +\`configure' configures autosp 2019-01-08 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1331,7 +1331,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of autosp 2018-02-23:";; + short | recursive ) echo "Configuration of autosp 2019-01-08:";; esac cat <<\_ACEOF @@ -1422,7 +1422,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -autosp configure 2018-02-23 +autosp configure 2019-01-08 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1845,7 +1845,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by autosp $as_me 2018-02-23, which was +It was created by autosp $as_me 2019-01-08, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2708,7 +2708,7 @@ fi # Define the identity of the package. PACKAGE='autosp' - VERSION='2018-02-23' + VERSION='2019-01-08' cat >>confdefs.h <<_ACEOF @@ -4974,7 +4974,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by autosp $as_me 2018-02-23, which was +This file was extended by autosp $as_me 2019-01-08, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5040,7 +5040,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -autosp config.status 2018-02-23 +autosp config.status 2019-01-08 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/Build/source/utils/autosp/autosp-src/configure.ac b/Build/source/utils/autosp/autosp-src/configure.ac index 0b7a9adf82d..c6e7d91fce5 100644 --- a/Build/source/utils/autosp/autosp-src/configure.ac +++ b/Build/source/utils/autosp/autosp-src/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ(2.63) -AC_INIT([autosp],[2018-02-23],[rdt@cs.queensu.ca]) +AC_INIT([autosp],[2019-01-08],[rdt@cs.queensu.ca]) AC_CONFIG_AUX_DIR([.]) AM_INIT_AUTOMAKE AC_CONFIG_HEADERS([config.h]) diff --git a/Build/source/utils/autosp/autosp-src/depcomp b/Build/source/utils/autosp/autosp-src/depcomp index 65cbf7093a1..4ebd5b3a2f2 100755 --- a/Build/source/utils/autosp/autosp-src/depcomp +++ b/Build/source/utils/autosp/autosp-src/depcomp @@ -1,9 +1,9 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2018-03-07.03; # UTC +scriptversion=2013-05-30.07; # UTC -# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Copyright (C) 1999-2013 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ scriptversion=2018-03-07.03; # UTC # GNU General Public License for more details. # You should have received a copy of the GNU General Public License -# along with this program. If not, see <https://www.gnu.org/licenses/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -783,9 +783,9 @@ exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'before-save-hook 'time-stamp) +# eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" +# time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: diff --git a/Build/source/utils/autosp/autosp-src/install-sh b/Build/source/utils/autosp/autosp-src/install-sh index 8175c640fe6..377bb8687ff 100755 --- a/Build/source/utils/autosp/autosp-src/install-sh +++ b/Build/source/utils/autosp/autosp-src/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2018-03-11.20; # UTC +scriptversion=2011-11-20.07; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -41,15 +41,19 @@ scriptversion=2018-03-11.20; # UTC # This script is compatible with the BSD install script, but was written # from scratch. -tab=' ' nl=' ' -IFS=" $tab$nl" +IFS=" "" $nl" -# Set DOITPROG to "echo" to test this script. +# set DOITPROG to echo to test this script +# Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} -doit_exec=${doit:-exec} +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi # Put in absolute file names if you don't have them in your path; # or use environment vars. @@ -64,6 +68,17 @@ mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' + posix_mkdir= # Desired mode of installed file. @@ -82,7 +97,7 @@ dir_arg= dst_arg= copy_on_change=false -is_target_a_directory=possibly +no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE @@ -122,57 +137,46 @@ while test $# -ne 0; do -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" - shift;; + shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 - case $mode in - *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; -o) chowncmd="$chownprog $2" - shift;; + shift;; -s) stripcmd=$stripprog;; - -t) - is_target_a_directory=always - dst_arg=$2 - # Protect names problematic for 'test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - shift;; + -t) dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; - -T) is_target_a_directory=never;; + -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; - --) shift - break;; + --) shift + break;; - -*) echo "$0: invalid option: $1" >&2 - exit 1;; + -*) echo "$0: invalid option: $1" >&2 + exit 1;; *) break;; esac shift done -# We allow the use of options -d and -T together, by making -d -# take the precedence; this is for compatibility with GNU install. - -if test -n "$dir_arg"; then - if test -n "$dst_arg"; then - echo "$0: target directory not allowed when installing a directory." >&2 - exit 1 - fi -fi - if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. @@ -204,15 +208,6 @@ if test $# -eq 0; then fi if test -z "$dir_arg"; then - if test $# -gt 1 || test "$is_target_a_directory" = always; then - if test ! -d "$dst_arg"; then - echo "$0: $dst_arg: Is not a directory." >&2 - exit 1 - fi - fi -fi - -if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 @@ -228,16 +223,16 @@ if test -z "$dir_arg"; then *[0-7]) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw='% 200' + u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw=,u+rw + u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac @@ -271,113 +266,122 @@ do fi dst=$dst_arg - # If destination is a directory, append the input filename. + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. if test -d "$dst"; then - if test "$is_target_a_directory" = never; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 fi dstdir=$dst - dstbase=`basename "$src"` - case $dst in - */) dst=$dst$dstbase;; - *) dst=$dst/$dstbase;; - esac + dst=$dstdir/`basename "$src"` dstdir_status=0 else - dstdir=`dirname "$dst"` + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + test -d "$dstdir" dstdir_status=$? fi fi - case $dstdir in - */) dstdirslash=$dstdir;; - *) dstdirslash=$dstdir/;; - esac - obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac - - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - # Note that $RANDOM variable is not portable (e.g. dash); Use it - # here however when possible just to lower collision chance. - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - - trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 - - # Because "mkdir -p" follows existing symlinks and we likely work - # directly in world-writeable /tmp, make sure that the '$tmpdir' - # directory is successfully created first before we actually test - # 'mkdir -p' feature. - if (umask $mkdir_umask && - $mkdirprog $mkdir_mode "$tmpdir" && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - test_tmpdir="$tmpdir/a" - ls_ld_tmpdir=`ls -ld "$test_tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null - fi - trap '' 0;; - esac;; + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; esac if $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else @@ -387,51 +391,53 @@ do # directory the slow way, step by step, checking for races as we go. case $dstdir in - /*) prefix='/';; - [-=\(\)!]*) prefix='./';; - *) prefix='';; + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; esac + eval "$initialize_posix_glob" + oIFS=$IFS IFS=/ - set -f + $posix_glob set -f set fnord $dstdir shift - set +f + $posix_glob set +f IFS=$oIFS prefixes= for d do - test X"$d" = X && continue - - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ + test X"$d" = X && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ done if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true fi fi fi @@ -444,8 +450,8 @@ do else # Make a couple of temp file names in the proper directory. - dsttmp=${dstdirslash}_inst.$$_ - rmtmp=${dstdirslash}_rm.$$_ + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 @@ -466,12 +472,15 @@ do # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - set -f && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && - set +f && + $posix_glob set +f && + test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then @@ -484,24 +493,24 @@ do # to itself, or perhaps because mv is so ancient that it does not # support -f. { - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 @@ -510,9 +519,9 @@ do done # Local variables: -# eval: (add-hook 'before-save-hook 'time-stamp) +# eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" +# time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: diff --git a/Build/source/utils/autosp/autosp-src/process_command.c b/Build/source/utils/autosp/autosp-src/process_command.c new file mode 100644 index 00000000000..9f1711ba24d --- /dev/null +++ b/Build/source/utils/autosp/autosp-src/process_command.c @@ -0,0 +1,972 @@ +# include "process_command.h" + + +void process_xtuplet (void); + +int i; + +PRIVATE +void analyze_notes (char **ln) +/* divide material from *ln to \en into notes[i] segments + and initialize terminator[i] etc. */ +{ + int i; char *s; char *t; + int newlines = 0; + s = *ln+1; /* skip "/" */ + while (isalpha(*s)) {s++;} /* skip rest of the initial command */ + while (true) + { /* look for \en */ + t = strstr(s, "\\en"); + if (t != NULL) break; + /* replace EOL by a blank and append another line of input */ + { char new_line[LINE_LEN]; + char *nl; + if (fgets (new_line, LINE_LEN, infile) == NULL) + error ("Unexpected EOF."); + if (strlen (new_line) == LINE_LEN-1) + error ("Line too long."); + nl = new_line; + while (*nl == ' ') nl++; /* avoid spaces */ + t = strpbrk (s, "\n%"); + if (t == NULL) error ("Missing EOL."); + if (*t == '\n') + { *t = ' '; t++;} + *t = '\0'; + if (append (line, &t, nl, LINE_LEN) >= LINE_LEN) + error ("Line too long."); + newlines++; + } + } + /* t -> "\en" */ + if ( prefix("\\enotes", t) ) *ln = t+7; + else *ln = t+3; + *t = '$'; /* replace '\' by '$' (a distinctive terminating character) */ + for (i=1; i <= nstaffs; i++) + { char *tt; + while (*s == ' ') s++; /* skip spaces */ + if (active[i]) + { notes[i] = s; + current[i] = s; + } + tt = strpbrk (s, "|&$"); + if (tt == NULL) error ("can't parse note-spacing command."); + s = tt; + terminator[i] = *s; + if (*s != '$') s++; + } + lineno = lineno + newlines; + + /* initialize: */ + spacing = MAX_SPACING; + old_spacing = MAX_SPACING; + appoggiatura = false; + global_skip = 0; + for (i=1; i <= nstaffs; i++) + { + if (active[i]) + { n_outstrings[i] = outstrings[i]; + *n_outstrings[i] = '\0'; + vspacing[i] = 0; + vspacing_active[i] = false; + collective[i][0] = '\0'; + cspacing[i] = MAX_SPACING; + first_collective[i] = false; + xtuplet[i] = 1; + } + } + if (debug) + { fprintf (logfile, "\nAfter analyze_notes:\n"); + status_all (); + } +} + +PRIVATE +void checkc (char *s, char c) +{ if (*s != c) + { + printf ("Error on line %d: Expected %c but found %d:\n%s\n", lineno, c, *s, line); + exit (EXIT_FAILURE); + } +} + +PRIVATE +void checkn (char *s) +{ if (strpbrk (s, "0123456789") != s) + { + printf ("Error on line %d: Expected digit but found %c:\n%s\n", lineno, *s, line); + exit (EXIT_FAILURE); + } +} + +PRIVATE +void filter_output (int i) +{ /* discard \sk \bsk \Qsk \TQsk \HQsk \QQsk and \Cpause */ + char *s = notes[i]; + while (s < current[i]) + { char *t; + t = strpbrk (s+1, "\\&|$"); + if (t == NULL || t > current[i]) t = current[i]; + if (!prefix ("\\sk", s) + && !prefix ("\\bsk", s) + && !prefix ("\\Cpause", s) + && !prefix ("\\Qsk", s) + && !prefix ("\\HQsk", s) + && !prefix ("\\TQsk", s) + && !prefix ("\\QQsk", s) + && !prefix ("\\Triolet", s) + && !prefix ("\\Xtuplet", s) ) + { + while (s < t) + { while (*s == ',') s++; /* global skips */ + *n_outstrings[i] = *s; + n_outstrings[i]++; s++; + } + *(n_outstrings[i]) = '\0'; + } + s = t; + } + notes[i] = s; +} + +void output_notes (int i) +/* append from notes[i] up to current[i] to outstrings[i] */ +{ if (debug) + { fprintf (logfile, "\nEntering output_notes:\n"); + status (i); + } + if (debug) + { + fprintf (logfile, "\nAppending %s for global_skip=%i\n", global_skip_str[global_skip], global_skip); + } + append (outstrings[i], &(n_outstrings[i]), global_skip_str[global_skip], LINE_LEN); + if (vspacing[i] > 0) + { + if (nonvirtual_notes) + append (outstrings[i], &(n_outstrings[i]), "\\sk", LINE_LEN); + vspacing[i] = vspacing[i] - spacing; + } + else if (collective[i][0]) + { + if (debug) + { fprintf (logfile, "\nBefore outputting collective note:\n"); + status (i); + status_collective (i); + } + if (!first_collective[i]) + append (outstrings[i], &(n_outstrings[i]), collective[i], LINE_LEN); + first_collective[i] = false; + filter_output (i); + append (outstrings[i], &(n_outstrings[i]), "}", LINE_LEN); + if (*notes[i] == '}') + { collective[i][0] = '\0'; + cspacing[i] = 0; + notes[i]++; + } + if (*notes[i] == '}') /* close of {\tinynotesize..{}}? */ + { append (outstrings[i], &(n_outstrings[i]), "}", LINE_LEN); + notes[i]++; + } + if (debug) + { fprintf (logfile, "\nAfter outputting collective note:\n"); + status (i); + status_collective (i); + } + } + else + filter_output (i); + if (debug) + { fprintf (logfile, "\nAfter output_notes:\n"); + status (i); + status_spacing (); + } +} + + +int spacing_note (int i); +/* Search from current[i] for the next spacing note in the ith staff. + * Returns the spacing value and updates current[i]. + */ + +PRIVATE void +output_rests (void) +{ /* outputs a multi-bar rest and the deferred_bar command */ + int i; + fprintf ( outfile, "\\NOTes\\sk\\en%%\n" ); + fprintf (outfile, "\\def\\atnextbar{\\znotes"); + if (restbars == 1) + fprintf ( outfile, "\\centerpause" ); + else + fprintf ( outfile, "\\centerHpause{%d}", restbars ); + fprintf (outfile, "\\en}%%\n"); + if (Changeclefs) /* \Changeclefs has to be output after \def\atnextbar... */ + { + fprintf ( outfile, "\\Changeclefs%%\n"); + Changeclefs = false; + } + if (restbars > 1) + fprintf ( outfile, "\\advance\\barno%d%%\n", restbars-1 ); + restbars = 0; + for (i=1; i <= nstaffs; i++) bar_rest[i] = false; + fprintf ( outfile, "%s%%\n", deferred_bar); + deferred_bar[0] = '\0'; +} + +void initialize_notes () +{ int i; + if (debug) + { fprintf (logfile, "\nEntering initialize_notes\n"); + status_all (); + } + if ( nastaffs == 1 && spacing != MAX_SPACING && restbars > 0) + output_rests (); + + if (spacing == MAX_SPACING) + fprintf (outfile, "\\znotes"); + else if (spacing == SP(1)+SP(2) || spacing == SP(1)+SP(2)+SP(4)) + fprintf (outfile, NOTEsp); + else if (spacing == SP(1)) + fprintf (outfile, "\\NOTEs"); + else if (spacing == SP(2)+SP(4)+SP(8)) + fprintf (outfile, "%s", NOTespp); + else if (spacing == SP(2)+SP(4) ) + fprintf (outfile, "\\NOTesp"); + else if (spacing == SP(2)) + fprintf (outfile, "\\NOTes"); + else if (spacing == SP(4)+SP(8) ) + fprintf (outfile, "\\NOtesp"); + else if (spacing == SP(4)+SP(8)+SP(16) ) + fprintf (outfile, "%s", NOtespp); + else if (spacing == SP(4)) + fprintf (outfile, "\\NOtes"); + else if (spacing == SP(8)+SP(16) ) + fprintf (outfile, "\\Notesp"); + else if (spacing == SP(8)+SP(16)+SP(32)) + fprintf (outfile, "%s", Notespp); + else if (spacing == SP(8)) + fprintf (outfile, "\\Notes"); + else if (spacing == SP(16)+SP(32)+SP(64)) + fprintf (outfile, notespp); + else if (spacing == SP(16)+SP(32) ) + fprintf (outfile, "\\notesp"); + else if (spacing == SP(16) || spacing == SP(32)+SP(64) || spacing == SP(32)+SP(64)+SP(128)) + fprintf (outfile, "\\notes"); + else if (spacing == SP(32) || spacing == SP(64)+SP(128) || spacing == SP(64)+SP(128)+SP(256)) + fprintf (outfile, "\\nnotes"); + else if (spacing == SP(64) ) + fprintf (outfile, "\\nnnotes"); + else if (spacing == APPOGG_SPACING) + fprintf (outfile, "%s", APPOGG_NOTES); + else + { printf ("Error on line %d: spacing %s not recognized.\n", lineno, ps(spacing)); + exit (EXIT_FAILURE); + } + if (debug) + { fprintf (logfile, "\noutputting \\Notes command for spacing=%s.\n", ps(spacing)); + status_all(); + } + for (i=1; i <= nstaffs; i++) + { if (active[i]) + { n_outstrings[i] = outstrings[i]; + *n_outstrings[i] = '\0'; + } + } +} + +PRIVATE +void terminate_notes () +{ int i; + char *s, *t; + if (debug) + { fprintf (logfile, "\nEntering terminate_notes:\n"); + status_all (); + } + t = TransformNotes2; + while (true) + { s = strchr (t, '#'); + if (s == NULL) + break; + while (t < s) /* output any initial \transpose etc. */ + { putc (*t, outfile); t++; } + t++; /* skip # */ + i = atoi (t) -1; t++; + if (spacing == MAX_SPACING) + { /* output any commands left in notes[i] */ + filter_output (i); + } + fprintf (outfile, "%s", outstrings[i]); + if (debug) fprintf (logfile, "\noutputting %s from outstrings[%d].\n", outstrings[i], i); + outstrings[i][0] = '\0'; + n_outstrings[i] = outstrings[i]; + if (spacing < MAX_SPACING && spacing > 2 * old_spacing) + { /* add extra space *before* much longer notes */ + fprintf (outfile, "\\hqsk"); + if (debug) fprintf (logfile, "\nExtra half-notehead space before longer notes.\n"); + } + if (*t != '\0') + { putc (*t, outfile); t++; } /* terminator */ + } + if (spacing == MAX_SPACING && old_spacing < SP(8) ) + { /* add extra space before \en */ + fprintf (outfile, "\\hqsk"); + if (debug) fprintf (logfile, "\nExtra half-notehead space before \\en.\n"); + } + fprintf (outfile, "\\en"); + if (debug) + { fprintf (logfile, "\noutputting \\en\n"); + fprintf (logfile, "\nAfter terminate_notes:\n"); + status_all (); + } +} + +PRIVATE +void process_appogg (void) +{ int i; + if (debug) + { fprintf (logfile, "\nEntering process_appogg:\n"); + status_all(); + } + + if (old_spacing < MAX_SPACING) + { char *s, *t; + if (debug) fprintf (logfile, "Terminate current notes command:\n"); + t = TransformNotes2; + while (true) + { s = strchr (t, '#'); + if (s == NULL) break; + while (t < s) /* output any initial \transpose etc. */ + { putc (*t, outfile); t++; } + t++; /* skip # */ + i = atoi (t) - 1; t++; + fprintf (outfile, "%s", outstrings[i]); + if (debug) fprintf (logfile, "\noutputting %s from outstrings[%d].\n", outstrings[i], i); + outstrings[i][0] = '\0'; + n_outstrings[i] = outstrings[i]; + if (*t != '\0') + { putc (*t, outfile); t++; } /* terminator */ + } + fprintf (outfile, "\\en"); + if (debug) + { fprintf (logfile, "\\en"); + fprintf (logfile, "\nAfter termination of notes command:\n"); + status_all (); + } + } + + if (debug) fprintf (logfile, "\nCreate a new notes command for the appoggiatura:\n"); + spacing = APPOGG_SPACING; + initialize_notes (); + spacing = MAX_SPACING; + for (i=1; i <= nstaffs; i++) + if (active[i]) + { + if (spacings[i] == APPOGG_SPACING ) + { + output_notes (i); + spacings[i] = spacing_note (i); + } + if (spacings[i] < spacing) + spacing = spacings[i]; + } + appoggiatura = false; + nonvirtual_notes = true; + old_spacing = APPOGG_SPACING; + if (debug) + { fprintf (logfile, "\nAfter process_appogg:\n"); + status_all (); + } + return; +} + + +PRIVATE +void generate_notes () +{ int i; + bool xtuplet_flag; + while (true) + { old_spacing = spacing; + spacing = MAX_SPACING; + global_skip = 0; + nonvirtual_notes = false; + if (debug) + { fprintf (logfile, "\nIn generate_notes:\n"); + status_all (); + } + for (i=1; i <= nstaffs; i++) + if (active[i]) + { + spacings[i] = spacing_note (i); + if (spacings[i] < spacing) + spacing = spacings[i]; + } + if (appoggiatura) + { + process_appogg (); + } + xtuplet_flag = false; + for (i=1; i <= nstaffs; i++) + if (xtuplet[i] > 1) xtuplet_flag = true; + if (xtuplet_flag) + { + process_xtuplet (); + continue; + } + if (spacing != old_spacing || spacing == MAX_SPACING) + { if (old_spacing < MAX_SPACING) + terminate_notes (); + if (spacing == MAX_SPACING || nonvirtual_notes == false) + { + if (debug) + { fprintf (logfile, "\nAfter generate_notes:\n"); + status_all (); + } + return; + } + if (old_spacing < MAX_SPACING) putc ('\n', outfile); + + initialize_notes (); + } + + for (i=1; i <= nstaffs; i++) /* append current notes to outstrings */ + if (active[i]) + output_notes (i); + for (i=1; i <= nstaffs; i++) + { + /* virtual notes needed? */ + if (active[i] && spacings[i] != MAX_SPACING && spacings[i] != spacing && vspacing[i] == 0 ) + { + vspacing[i] = spacings[i]; + vspacing_active[i] = true; + vspacing[i] = vspacing[i] - spacing; + if (debug) + { fprintf (logfile, "\nAfter vspacing initialization:\n"); + status (i); + } + } + } + } +} + + +void process_command (char **ln) +{ char *s, *t; + + if (debug) + { fprintf (logfile, "\nProcessing command:%s\n", *ln); + fflush (logfile); + } + if ( prefix("\\instrumentnumber", *ln) ) + { + s = strpbrk (*ln, "123456789"); + if ( s == NULL ) error ("\\instrumentnumber command unreadable."); + ninstr = atoi (s); + while (*ln <= s) { putc (**ln, outfile); (*ln)++;} + } + + if ( prefix("\\def\\nbinstrument", *ln) ) + { + s = strpbrk (*ln, "123456789"); + if ( s == NULL ) error ("\\def\\nbinstrument command unreadable."); + ninstr = atoi (s); + while (*ln <= s) { putc (**ln, outfile); (*ln)++;} + } + + else if ( prefix("\\setstaffs", *ln) ) + { /* for now, just record in staffs[i] */ + int n, p; + s = strpbrk (*ln, "123456789"); + if ( s == NULL ) error ("\\setstaffs command unreadable."); + n = (int)(*s) - (int)('0'); /* instrument number */ + s = strpbrk (s+1, "123456789"); + if ( s == NULL ) error ("\\setstaffs command unreadable."); + p = (int)(*s) - (int)('0'); /* number of staffs */ + staffs[n] = p; + while (*ln <= s) { putc (**ln, outfile); (*ln)++;} + } + + else if ( prefix("\\startpiece", *ln) ) + { + if (!TransformNotesDefined) /* create default TransformNotes2: */ + { int i, j; + t = TransformNotes2; + nstaffs = 1; + sprintf (t, "#%1i", nstaffs+1); t = t+2; + for (j=2; j <= staffs[1]; j++) + { nstaffs++; sprintf (t, "|#%1i", nstaffs+1); t = t+3; + active[nstaffs] = true; + } + for (i=2; i <= ninstr; i++) + { nstaffs++; sprintf (t, "&#%1i", nstaffs+1); t = t+3; + for (j=2; j <= staffs[i]; j++) + { nstaffs++; sprintf (t, "|#%1i", nstaffs+1); t = t+3; + active[nstaffs] = true; + } + } + nastaffs = nstaffs; + if (debug) + fprintf (logfile, "default TransformNotes2=%s\n", TransformNotes2); + } + if (nstaffs == 1) fprintf (outfile, "\\nostartrule\n"); + if (debug) + { + int j; + fprintf (logfile, "ninstr=%d nstaffs=%d nastaffs=%d\n", ninstr, nstaffs, nastaffs); + for (j=1; j <= nstaffs; j++) + fprintf (logfile, "active[%d]=%d\n", j, active[j]); + } + fprintf (outfile, "\\startpiece"); + t = strpbrk (*ln+1, "\\%\n"); + *ln = t; + } + + else if ( prefix("\\startextract", *ln) ) + { + if (!TransformNotesDefined) /* create default TransformNotes2: */ + { int i, j; + t = TransformNotes2; + nstaffs = 1; + sprintf (t, "#%1i", nstaffs+1); t = t+2; + for (j=2; j <= staffs[1]; j++) + { nstaffs++; sprintf (t, "|#%1i", nstaffs+1); t = t+3; + active[nstaffs] = true; + } + for (i=2; i <= ninstr; i++) + { nstaffs++; sprintf (t, "&#%1i", nstaffs+1); t = t+3; + for (j=2; j <= staffs[i]; j++) + { nstaffs++; sprintf (t, "|#%1i", nstaffs+1); t = t+3; + active[nstaffs] = true; + } + } + nastaffs = nstaffs; + if (debug) + fprintf (logfile, "default TransformNotes2=%s\n", TransformNotes2); + } + if (nstaffs == 1) fprintf (outfile, "\\nostartrule\n"); + fprintf (outfile, "\\startextract"); + t = strpbrk (*ln+1, "\\%\n"); + *ln = t; + } + + else if ( prefix("\\TransformNotes", *ln) ) + { /* determine ninstr, nstaffs, nastaffs, staffs[i], and active[i] */ + int i; + s = *ln + 16; /* first parameter */ + ninstr = 0; + nstaffs = 0; + while (true) + { ninstr++; nstaffs++; + staffs[ninstr] = 1; + checkc (s, '#'); s++; + checkn (s); s++; + while (*s == '|') + { staffs[ninstr]++; nstaffs++; + s++; + checkc (s, '#'); s++; + checkn (s); s++; + } + if (*s != '&') break; + s++; + } + checkc (s, '}'); s++; + s = strchr (s, '{'); + if (s == NULL) error ("Can't parse \\TransformNotes"); + s++; + /* determine TransformNotes2: */ + t = TransformNotes2; + do { *t = *s; t++; s++; } + while (*s != '}'); + *t = '\0'; /* terminate TransformNotes2 */ + TransformNotesDefined = true; + if (debug) + fprintf (logfile, "defined TransformNotes2=%s\n", TransformNotes2); + + /* determine active staffs: */ + for (i=1; i <= nstaffs; i++) active[i] = false; + nastaffs = 0; + t = strpbrk (TransformNotes2, "#}"); /* may have \transpose etc. before # */ + if (t == NULL) error ("Can't parse second argument of \\TransformNotes"); + while (*t == '#') + { if (sscanf (t, "#%d", &i) != 1) + error ("sscanf for argument number fails"); + active[i-1] = true; /* parameters start at 2 */ + nastaffs++; + t = strpbrk (t+1, "#}"); + if (t == NULL) break; + } + if (debug) + { + int j; + fprintf (logfile, "ninstr=%d nstaffs=%d nastaffs=%d\n", ninstr, nstaffs, nastaffs); + for (j=1; j <= nstaffs; j++) + fprintf (logfile, "active[%d]=%d\n", j, active[j]); + } + + /* output \TransformNotes... as a comment: */ + putc ('%', outfile); + while (*ln <= s) + { putc (**ln, outfile); (*ln)++; } + } + + else if (prefix("\\def\\atnextbar{\\znotes", *ln)) + { /* whole-bar or multi-bar rest? */ + int i; + bool centerpause = false; + *ln = *ln + 15; /* skip "\def\atnextbar{" */ + analyze_notes(ln); + for (i=1; i <= nstaffs; i++) + { + if (active[i]) + { char *t; + char *s; + t = strpbrk (notes[i], "&|$"); + if (t == NULL) t = notes[i] + strlen (notes[i]); + s = strstr (notes[i], "\\centerpause"); + if (s != NULL && s < t && nastaffs == 1) + { + bar_rest[i] = true; + centerpause = true; + } + break; + } + } + if (!centerpause) /* generate transformed \znotes ... \en */ + { + fprintf ( outfile, "\\def\\atnextbar{\\znotes"); + t = TransformNotes2; + while (true) + { + /* output TransformNotes2 prefix (\transpose etc.): */ + s = strchr (t, '#'); + if (s == NULL) break; + while (t < s) + { putc (*t, outfile); t++; } + t++; /* skip '#' */ + /* output notes: */ + i = atoi (t) - 1; t++; + s = notes[i]; + while (*s != '&' && *s != '|' && *s != '$') + { putc (*s, outfile); s++; } + if (*t != '\0') + { putc (*t, outfile); t++; } /* output terminator */ + } + fprintf (outfile, "\\en}%%\n"); + } + t = strchr (*ln, '}'); + if (t == NULL) error ("Can't find }."); + *ln = t+1; + t = strpbrk (*ln, "%\\"); + if (t == NULL ) t = *ln + strlen(*ln); + *ln = t; + } + + else if ( prefix("\\def", *ln) ) /* copy to output */ + { t = *ln + strlen(*ln); + while (*ln < t) + { fputc (**ln, outfile); + (*ln)++; + } + } + + else if ( prefix("\\anotes", *ln) ) + { if (debug) + { fprintf (logfile, "\nProcessing %s", *ln); + fprintf (logfile, "lineno=%d\n", lineno); + fflush (logfile); + } + analyze_notes (ln); + if (debug) + { fprintf (logfile, "\nBefore generate_notes *ln=%s\n", *ln); + fflush (logfile); + } + generate_notes (); + if (debug) + { fprintf (logfile, "\nAfter generate_notes *ln=%s\n", *ln); + fflush (logfile); + } + t = strpbrk (*ln, "%\\\n"); + if (t == NULL) t = *ln + strlen (*ln); + if (*t == '\n') putc ('%', outfile); + *ln = t; + } + else if ( prefix("\\nnnotes", *ln) || + prefix("\\nnnotes", *ln) || + prefix("\\nnotes", *ln) || + prefix("\\notes", *ln) || + prefix("\\Notes", *ln) || + prefix("\\NOtes", *ln) || + prefix("\\NOTes", *ln) || + prefix("\\NOTEs", *ln) || + prefix("\\znotes", *ln) ) + { + char *s, *t; + int nstaff; + if (debug) + { fprintf (logfile, "\nProcessing %s", *ln); + fprintf (logfile, "lineno=%d\n", lineno); + fflush (logfile); + } + if (nastaffs == 1 && restbars > 0) + output_rests (); + t = *ln+1; + while ( isalpha (*t) ) t++; + s = *ln; + while (s < t) { putc (*s, outfile); s++; } + + analyze_notes (ln); + + t = TransformNotes2; + while (true) + { + /* output TransformNotes2 prefix (\transpose etc.): */ + s = strchr (t, '#'); + if (s == NULL) break; + while (t < s) + { putc (*t, outfile); t++; } + + t++; /* skip '#' */ + + /* output notes: */ + nstaff = atoi (t) - 1; t++; + s = notes[nstaff]; + while (*s != '&' && *s != '|' && *s != '$') + { putc (*s, outfile); s++; } + if (*t != '\0') + { putc (*t, outfile); t++; } /* output terminator */ + } + fprintf (outfile, "\\en\n"); + + t = strpbrk (*ln, "%\\\n"); + if (t == NULL) t = *ln + strlen (*ln); + if (*t == '\n') putc ('%', outfile); + *ln = t; + } + + else if (prefix("\\vnotes", *ln) ) + { + char *s, *t; + int nstaff; + if (debug) + { fprintf (logfile, "\nProcessing %s", *ln); + fprintf (logfile, "lineno=%d\n", lineno); + fflush (logfile); + } + s = *ln; + t = strchr (*ln+1, '\\'); /* find \elemskip */ + *ln = t; + t = t + 9; + while (s < t) { putc (*s, outfile); s++; } + + + analyze_notes (ln); + + t = TransformNotes2; + while (true) + { + /* output TransformNotes2 prefix (\transpose etc.): */ + s = strchr (t, '#'); + if (s == NULL) break; + while (t < s) + { putc (*t, outfile); t++; } + + t++; /* skip '#' */ + + /* output notes: */ + nstaff = atoi (t) - 1; t++; + s = notes[nstaff]; + while (*s != '&' && *s != '|' && *s != '$') + { putc (*s, outfile); s++; } + if (*t != '\0') + { putc (*t, outfile); t++; } /* output terminator */ + } + fprintf (outfile, "\\en\n"); + + t = strpbrk (*ln, "%\\\n"); + if (t == NULL) t = *ln + strlen (*ln); + if (*t == '\n') putc ('%', outfile); + *ln = t; + } + + else if ( prefix ("\\bar", *ln) && !prefix ("\\barno", *ln)) + { int i; + char *s, *t; + bool atnextbar = false; + for (i=1; i <= nstaffs; i++) + if (active[i] && bar_rest[i]) + { atnextbar = true; break; } + if (nastaffs == 1 && atnextbar) + { restbars++; + sprintf (deferred_bar, "\\bar"); + if (debug) fprintf (logfile, "\nrestbars increased to %d\n", restbars); + for (i=1; i<= nstaffs; i++) + bar_rest[i] = false; + *ln = *ln+4; + t = strpbrk (*ln, "\\\n"); + if (t == NULL) t = *ln + strlen (*ln); + if (*t == '\n') putc ('%', outfile); + *ln = t; + } + else + { if (atnextbar) + { fprintf (outfile, "\\def\\atnextbar{\\znotes"); + t = TransformNotes2; + while (true) + { + s = strchr (t, '#'); + if (s == NULL) + break; + while (t < s) /* output any initial \transpose etc. */ + { putc (*t, outfile); t++; } + t++; /* skip # */ + i = atoi (t) -1; t++; + if (active[i]) + { + if (bar_rest[i]) + fprintf (outfile, "\\centerpause"); + bar_rest[i] = false; + } + if (*t != '\0') + { putc (*t, outfile); t++; } /* terminator */ + } + fprintf (outfile, "\\en}%%\n"); + } + if (Changeclefs) /* \Changeclefs has to be output after \def\atnextbar... */ + { + fprintf ( outfile, "\\Changeclefs%%\n"); + Changeclefs = false; + } + t = strpbrk (*ln+1, "%\\\n"); + while (*ln < t) + { fputc (**ln, outfile); + (*ln)++; + } + if (*t == '\n') putc ('%', outfile); + *ln = t; + } + if (debug) + { fprintf (logfile, "\nAfter \\bar processing, *ln=%s\n", *ln); + fflush (logfile); + } + } + + else if ( prefix ("\\endpiece", *ln) + || prefix ("\\Endpiece", *ln) + || prefix ("\\endextract", *ln) + || prefix ("\\stoppiece", *ln) + || prefix ("\\raggedstoppiece", *ln) + || prefix ("\\rightrepeat", *ln) + || prefix ("\\leftrepeat", *ln) + || prefix ("\\alaligne", *ln) + || prefix ("\\alapage", *ln) + || prefix ("\\changecontext", *ln) + || prefix ("\\Changecontext", *ln) + || prefix ("\\zchangecontext", *ln) + || prefix ("\\zalaligne", *ln) + || prefix ("\\zalapage", *ln) ) + { int i; + bool atnextbar = false; + for (i=1; i <= nstaffs; i++) + if (active[i] && bar_rest[i]) + { atnextbar = true; break; } + if (nastaffs == 1 && atnextbar) + { restbars++; + sprintf (deferred_bar, "%s", *ln); + output_rests (); + t = strpbrk (*ln+1, "%\\\n"); + if (*t == '\n') putc ('%', outfile); + *ln = t; + } + else if (atnextbar) + { + fprintf (outfile, "\\def\\atnextbar{\\znotes"); + for (i=1; i <= nstaffs; i++) + { + if (active[i]) + { + if (bar_rest[i]) + fprintf (outfile, "\\centerpause"); + bar_rest[i] = false; + } + if ( terminator[i] != '$') putc (terminator[i], outfile); + } + fprintf (outfile, "\\en}%%\n"); + if (Changeclefs) /* \Changeclefs has to be output after \def\atnextbar... */ + { + fprintf ( outfile, "\\Changeclefs%%\n"); + Changeclefs = false; + } + t = strpbrk (*ln+1, "%\\\n"); + while (*ln < t) + { fputc (**ln, outfile); + (*ln)++; + } + if (*t == '\n') putc ('%', outfile); + *ln = t; + } + else + { if (nastaffs == 1 && restbars > 0) + output_rests (); + t = strpbrk (*ln+1, "%\\\n"); + while (*ln < t) + { fputc (**ln, outfile); + (*ln)++; + } + if (*t == '\n') putc ('%', outfile); + *ln = t; + } + if (debug) + { fprintf (logfile, "\nAfter \\bar processing, *ln=%s\n", *ln); + fflush (logfile); + } + } + + else if ( prefix ("\\znotes", *ln) ) + { + if (nastaffs == 1 && restbars > 0) + output_rests (); + fputs (*ln, outfile); + *ln = *ln + strlen(*ln); + } + + else if ( prefix ("\\Changeclefs", *ln) ) + { /* defer till after \def\atnextbar ... */ + Changeclefs = true; + *ln = *ln + strlen(*ln); + } + + else if ( prefix ("\\documentclass", *ln) ) + { + + if ( suffix( ".tex", outfilename) ) + { char newoutfilename[SHORT_LEN]; + char *newoutfilename_n = newoutfilename; + append (newoutfilename, &newoutfilename_n, infilename, sizeof (newoutfilename)); + newoutfilename_n -= 4; + *newoutfilename_n = '\0'; + append (newoutfilename, &newoutfilename_n, "ltx", sizeof (newoutfilename)); + if (rename ( outfilename, newoutfilename) > 0) + { printf ("Can't rename %s as %s\n", outfilename, newoutfilename); + exit (EXIT_FAILURE); + } + printf ("\\documentclass detected; now writing to %s.", newoutfilename); + printf ("\n\n"); + + } + fputs (*ln, outfile); + *ln = *ln + strlen(*ln); + } + + else if ( prefix ("\\end ", *ln) + || prefix ("\\end%", *ln) + || prefix ("\\end{document}", *ln) ) + { + fprintf (outfile, "%s", *ln); + exit(0); + } + + + else /* everything else */ + { + fputs (*ln, outfile); + *ln = *ln + strlen(*ln); + } +} + diff --git a/Build/source/utils/autosp/autosp-src/process_command.h b/Build/source/utils/autosp/autosp-src/process_command.h new file mode 100644 index 00000000000..2ee44262c8f --- /dev/null +++ b/Build/source/utils/autosp/autosp-src/process_command.h @@ -0,0 +1,68 @@ +# include "process_score.h" + +# define APPOGG_SPACING SP(64)+SP(256) /* not a legitimate spacing */ +# define notespp "\\vnotes2.95\\elemskip" +# define Notespp "\\vnotes3.95\\elemskip" +# define NOtespp "\\vnotes4.95\\elemskip" +# define NOTespp "\\vnotes6.95\\elemskip" +# define NOTEsp "\\vnotes9.52\\elemskip" +# define APPOGG_NOTES "\\vnotes1.45\\elemskip" + +char terminator[MAX_STAFFS]; /* one of '&' "|', '$' */ + +char *notes[MAX_STAFFS]; /* note segment for ith staff */ +char *current[MAX_STAFFS]; + +int spacings[MAX_STAFFS]; /* spacing for ith staff */ + +int vspacing[MAX_STAFFS]; /* virtual-note (skip) spacing */ +bool vspacing_active[MAX_STAFFS]; /* virtual-note spacing active? */ + /* used to preclude unnecessary pre-accidental skips */ + +bool nonvirtual_notes; /* used to preclude output of *only* virtual notes */ + +int cspacing[MAX_STAFFS]; /* nominal collective-note spacing */ +char collective[MAX_STAFFS][SHORT_LEN]; + /* prefixes for collective note sequences */ +bool first_collective[MAX_STAFFS]; + +char deferred_bar[SHORT_LEN]; /* deferred \bar (or \endpiece etc.) */ + +int beaming[MAX_STAFFS]; /* spacing for beamed notes */ +int new_beaming; +int semiauto_beam_notes[MAX_STAFFS]; /* semi-automatic beam notes */ + +/* save-restore state for a staff; used in process_xtuplet */ +int beamingi; +char *currenti; +int cspacingi; +int vspacingi; +char collectivei[SHORT_LEN]; +bool first_collectivei; + +int xtuplet[MAX_STAFFS]; /* x for xtuplet in staff i */ + +bool appoggiatura; + +char outstrings[MAX_STAFFS][LINE_LEN]; + /* accumulate commands to be output */ +char *n_outstrings[MAX_STAFFS]; + +int global_skip; + /* = 1, 2, 3, or 4 for (non-standard) commands \QQsk \HQsk \TQsk \Qsk */ + /* = 5 for five commas and double-flat accidental spacing */ + /* = 6 for six commas */ + + +char *ps(int spacing); +void note_segment (char *s); +void status (int i); +void status_spacing (void); +void status_all (void); +void status_collective (int i); +void status_beam (int i); + + +int spacing_note (int i); +void output_notes (int i); +void initialize_notes (); diff --git a/Build/source/utils/autosp/autosp-src/process_score.c b/Build/source/utils/autosp/autosp-src/process_score.c new file mode 100644 index 00000000000..845e39022b1 --- /dev/null +++ b/Build/source/utils/autosp/autosp-src/process_score.c @@ -0,0 +1,60 @@ +# include "process_score.h" + +void process_line () +{ + char *ln; + ln = &line[0]; + while ( *ln != '\0') + { + while (*ln == ' ') { ln++; fputc (' ', outfile); } + if (*ln == '%') { + fprintf (outfile, "%s", ln); + return; + } + process_command (&ln); + } +} +void process_score () +/* process .aspc file */ +{ + int c; int i; + lineno = 0; + for (i=1; i < MAX_STAFFS; i++) + { + staffs[i] = 1; + active[i] = true; + bar_rest[i] = false; + } + spacing = MAX_SPACING; + restbars = 0; + ninstr = 1; /* number of instruments */ + nstaffs = 1; /* number of staffs */ + nastaffs = 1; /* number of active staffs; */ + old_spacing = MAX_SPACING; + Changeclefs = false; /* output \Changeclefs after \def\atnextbar */ + + TransformNotes2[0] = '\0'; + TransformNotesDefined = false; + + append (global_skip_str[0], NULL, "", 16); + append (global_skip_str[1], NULL, "\\qqsk", 16); + append (global_skip_str[2], NULL, "\\hqsk", 16); + append (global_skip_str[3], NULL, "\\tqsk", 16); + append (global_skip_str[4], NULL, "\\qsk", 16); + append (global_skip_str[5], NULL, "\\qsk\\qqsk", 16); + append (global_skip_str[6], NULL, "\\qsk\\hqsk", 16); + + c = getc (infile); + while ( c != EOF ) + { + ungetc (c, infile); + if (fgets(line, LINE_LEN, infile) == NULL) + error ("Unexpected EOF."); + if (strlen (line) == LINE_LEN-1) + error ("Line too long."); + lineno++; + process_line (); + c = getc (infile); + } /* c == EOF */ +} + diff --git a/Build/source/utils/autosp/autosp-src/process_score.h b/Build/source/utils/autosp/autosp-src/process_score.h new file mode 100644 index 00000000000..35043c62719 --- /dev/null +++ b/Build/source/utils/autosp/autosp-src/process_score.h @@ -0,0 +1,27 @@ +# include "autosp.h" + +# define MAX_STAFFS 9 + +# define SMALL_NOTE 512 +# define SP(note) (SMALL_NOTE/note) +/* note = { 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 } */ +# define MAX_SPACING 2*SP(1) +int staffs[MAX_STAFFS]; /* number of staffs for ith instrument*/ +bool active[MAX_STAFFS]; /* is staff i active? */ +bool bar_rest[MAX_STAFFS]; +int spacing; /* spacing for current notes */ +int restbars; +char global_skip_str[7][16]; +int ninstr; /* number of instruments */ +int nstaffs; /* number of staffs */ +int nastaffs; /* number of active staffs; */ +int old_spacing; +bool Changeclefs; /* output \Changeclefs after \def\atnextbar */ +char TransformNotes2[SHORT_LEN]; /* 2nd argument of \TransformNotes */ +bool TransformNotesDefined; + +char line[LINE_LEN]; /* line of input */ + +void process_line (); + +void process_command (char **ln); diff --git a/Build/source/utils/autosp/autosp-src/rebar.c b/Build/source/utils/autosp/autosp-src/rebar.c index ea7b6f556e0..cd1f78520d3 100644 --- a/Build/source/utils/autosp/autosp-src/rebar.c +++ b/Build/source/utils/autosp/autosp-src/rebar.c @@ -1,6 +1,6 @@ -char version[12] = "2016-01-30"; +char version[12] = "2019-01-08"; -/* Copyright (C) 2015-16 R. D. Tennent School of Computing, +/* Copyright (C) 2015-19 R. D. Tennent School of Computing, * Queen's University, rdt@cs.queensu.ca * * This program is free software; you can redistribute it @@ -178,8 +178,10 @@ process_score (void) { ungetc (c, infile); lineno++; - if ( fgets(line, LINE_LEN, infile) == NULL) error_at("IO error"); - if (strlen (line) == LINE_LEN-1) error_at("Line too long."); + if ( fgets(line, LINE_LEN, infile) == NULL) + error_at("Unexpected EOF."); + if (strlen (line) == LINE_LEN-1) + error_at("Line too long."); process_line (); } /* c == EOF */ } diff --git a/Build/source/utils/autosp/autosp-src/spacing_note.c b/Build/source/utils/autosp/autosp-src/spacing_note.c new file mode 100644 index 00000000000..eaa377538fd --- /dev/null +++ b/Build/source/utils/autosp/autosp-src/spacing_note.c @@ -0,0 +1,584 @@ +# include "process_command.h" + +PRIVATE +void update_global_skip (int n) +/* global skips may be used in more than one staff */ +{ + if (n>6) + { warning ("Too many commas."); n = 6; } + if (global_skip < n) global_skip = n; +} + +PRIVATE +int collective_note (int i) +{ char *s = current[i]; + int spacing = cspacing[i]; + if (debug) + { fprintf (logfile, "\nEntering collective_note:\n"); + status (i); + status_beam (i); + status_collective (i); + } + if (beaming[i] > 0 && spacing != beaming[i]) + { /* adjust cspacing for new beaming */ + cspacing[i] = beaming[i]; + } + while (true) /* search for alphabetic or numeric note (or asterisk) */ + { int n = 0; + while (*s == ',') + { n++; s++; } /* global skips */ + update_global_skip (n); + /* commas will be discarded by filter_output (i) */ + if (*s == '.' && new_beaming == 0 && !dottedbeamnotes) + spacing = spacing * 1.50; + else if ( (*s == '^' || *s == '_' || *s == '=' || *s == '>') + && !vspacing_active[i] /* is additional spacing needed? */ + ) + /* leave space for normal accidentals */ + { update_global_skip (3) ; + if (debug) + { fprintf (logfile, "\nLeave space for accidental\n"); + status (i); + status_beam (i); + status_collective (i); + } + } + else if ( (*s == '<') /* double-flat */ + && !vspacing_active[i] /* is additional spacing needed? */ + ) + { update_global_skip (5); + if (debug) + { fprintf (logfile, "\nLeave space for double-flat\n"); + status (i); + status_beam (i); + status_collective (i); + } + } + else if (isalnum (*s) || *s == '*') + { + s++; + while (*s == '\'' || *s == '`' || *s == '!') + /* transposition characters */ + s++; + current[i] = s; + if (debug) + { fprintf (logfile, "\nAfter collective_note:\n"); + status (i); + status_collective (i); + } + vspacing_active[i] = false; + return spacing; + } + s++; + } +} + + +PRIVATE +void beam_initiation (char *s, int i) +{ + if ( prefix ("\\ibbbbbb", s) + || prefix ("\\Ibbbbbb", s) + || prefix ("\\nbbbbbb", s) ) + beaming[i] = SP(256); + else if ( prefix ("\\ibbbbb", s) + || prefix ("\\Ibbbbb", s) + || prefix ("\\nbbbbb", s) ) + beaming[i] = SP(128); + else if ( prefix ("\\ibbbb", s) + || prefix ("\\Ibbbb", s) + || prefix ("\\nbbbb", s) ) + beaming[i] = SP(64); + else if ( prefix ("\\ibbb", s) + || prefix ("\\Ibbb", s) + || prefix ("\\nbbb", s) ) + beaming[i] = SP(32); + else if ( prefix ("\\ibb", s) + || prefix ("\\Ibb", s) + || prefix ("\\nbb", s) ) + beaming[i] = SP(16); + else if ( prefix ("\\ib", s) + || prefix ("\\Ib", s) ) + beaming[i] = SP(8); + if (debug) + { fprintf (logfile, "\nAfter beam_initiation:\n"); + status (i); + status_beam (i); + } +} + +PRIVATE +void beam_termination (char *s, int i) +{ + if (debug) + { fprintf (logfile, "\nEntering beam_termination:\n"); + status (i); + status_beam (i); + } + if ( prefix ("\\tbbbbbb", s) ) + { + new_beaming = SP(128); + if (beaming[i] > SP(256)) + beaming[i] = SP(256); + } + else if ( prefix ("\\tbbbbb", s) ) + { + new_beaming = SP(64); + if (beaming[i] > SP(128)) + beaming[i] = SP(128); + } + else if ( prefix ("\\tbbbb", s) ) + { + new_beaming = SP(32); + if (beaming[i] > SP(64)) + beaming[i] = SP(64); + } + else if ( prefix ("\\tbbb", s) ) + { + new_beaming = SP(16); + if (beaming[i] > SP(32)) + beaming[i] = SP(32); + } + else if ( prefix ("\\tbb", s) ) + { + new_beaming = SP(8); + if (beaming[i] > SP(16)) + beaming[i] = SP(16); + } + else if ( prefix ("\\tb", s) ) + { + new_beaming = 0; + } + if (debug) + { fprintf (logfile, "\nAfter beam_termination:\n"); + status (i); + status_beam (i); + } +} + +PRIVATE +char *skip_balanced_text (char *s) +{ + char *t; + do + { + t = strpbrk (s, "{}"); + if (t == NULL) error ("Expected '}'"); + if (*t == '{') t = skip_balanced_text (t+1); + } + while (*t != '}'); + return t+1; +} + +PRIVATE +char *skip_arg (char *s) +{ + while (*s == ' ') s++; + if (*s == '{') + { s++; + skip_balanced_text (s); + } + else + s++; + return s; +} + +int spacing_note (int i) +/* Search from current[i] for the next spacing note in the ith staff. + * Returns the spacing value and updates current[i]. + */ +{ + int spacing = MAX_SPACING; + char *s, *t; + bool tinynotesize = false; + bool doubledotted = false; + bool dotted = false; + new_beaming = 0; + if (!active[i]) return spacing; + if (vspacing[i] > 0) + { /* virtual note (i.e., a skip) */ + return vspacing[i]; + } + if (collective[i][0]) + { + nonvirtual_notes = true; + return collective_note (i); + } + if (semiauto_beam_notes[i] > 0) + { if (debug) + fprintf (logfile, "\nsemiauto_beam_notes reduced\n"); + semiauto_beam_notes[i]--; + current[i]++; + if (debug) status (i); + nonvirtual_notes = true; + return beaming[i]; + } + s = strpbrk (current[i], "\\&|$"); + if (*s != '\\') + { return spacing; } + if (debug) + { fprintf (logfile, "\nIn spacing_note:\n"); + status (i); + } + while (true) + { + if ( prefix ("\\wh", s) + || prefix ("\\breve", s) + || prefix ("\\pause", s) + || prefix ("\\wq", s) ) + { spacing = SP(1); break; } + + if ( prefix ("\\ha", s) + || (prefix ("\\hl", s) && !prefix ( "\\hloff", s) ) + + || prefix ("\\hu", s) + || prefix ("\\hp", s) + || prefix ("\\hpause", s) ) + { spacing = SP(2); break;} + + if ( prefix ("\\qa", s) + || prefix ("\\ql", s) + || prefix ("\\qu", s) + || prefix ("\\qp", s) ) + { spacing = SP(4); break; } + + if ( ( prefix ("\\ca", s) + || prefix ("\\cl", s) + || prefix ("\\cu", s) ) + && !prefix ("\\caesura", s ) ) + { spacing = SP(8); break; } + + if ( prefix ("\\ds", s ) + && !prefix ("\\dsh", s) ) + { spacing = SP(8); break; } + + if ( prefix ("\\cccc", s) ) + { spacing = SP(64); break; } + + if ( prefix ("\\ccc", s) ) + { spacing = SP(32); break; } + + if ( prefix ("\\cc", s) + && !prefix ("\\ccn", s) + && !prefix ("\\cchar", s) ) + { spacing = SP(16); break; } + + if ( prefix ("\\qs", s) + && !prefix ("\\qsk", s) + && !prefix ("\\qspace", s) ) + { spacing = SP(16); break; } + + if ( prefix ("\\hs", s) + && !prefix ("\\hsk", s) + && !prefix ("\\hsp", s) ) + { spacing = SP(32); break;} + + if ( prefix ("\\qqs", s ) + && !prefix ("\\qqsk", s) ) + { spacing = SP(64); break; } + + if ( prefix ("\\qb", s)) /* beam note */ + { spacing = beaming[i]; + if (new_beaming != 0) /* set by preceding \tb... */ + { beaming[i] = new_beaming; + new_beaming = 0; + } + if (debug) + { fprintf (logfile, "\nBeam note:\n"); + status (i); + status_beam (i); + } + break; + } + + if ( prefix ("\\Cpause", s) ) + { /* bar-centered rest */ + bar_rest[i] = true; + spacing = MAX_SPACING; + break; + } + + if (prefix("\\tqqq", s) ) + { if (beaming[i] > SP(32)) + beaming[i] = SP(32); + spacing = beaming[i]; + beaming[i] = 0; + new_beaming = 0; + if (debug) + { fprintf (logfile, "\nAfter beam completion:\n"); + status (i); + status_beam (i); + } + break; + } + + if (prefix("\\nqqq", s) ) + { if (beaming[i] > SP(32)) + beaming[i] = SP(32); + spacing = beaming[i]; + beaming[i] = SP(16); + new_beaming = 0; + if (debug) + { fprintf (logfile, "\nAfter beam completion:\n"); + status (i); + status_beam (i); + } + break; + } + + if (prefix("\\tqq", s) ) + { if (beaming[i] > SP(16)) + beaming[i] = SP(16); + spacing = beaming[i]; + beaming[i] = 0; + new_beaming = 0; + if (debug) + { fprintf (logfile, "\nAfter beam completion:\n"); + status (i); + status_beam (i); + } + break; + } + + if (prefix("\\nqq", s) ) + { if (beaming[i] > SP(16)) + beaming[i] = SP(16); + spacing = beaming[i]; + beaming[i] = SP(8); + new_beaming = 0; + if (debug) + { fprintf (logfile, "\nAfter beam completion:\n"); + status (i); + status_beam (i); + } + break; + } + + if ( prefix("\\tq", s) + && !prefix("\\tqsk", s) ) + { spacing = beaming[i]; + beaming[i] = 0; + new_beaming = 0; + if (debug) + { fprintf (logfile, "\nAfter beam completion:\n"); + status (i); + status_beam (i); + } + break; + } + + +/* non-spacing commands: */ + + if ( prefix ("\\ib", s) + || prefix ("\\Ib", s) + || prefix ("\\nb", s) ) + beam_initiation (s, i); + + else if ( prefix("\\tb", s) ) + beam_termination (s, i); + + else if ( prefix("\\ztq", s) ) + /* non-spacing beam termination */ + new_beaming = 0; + + else if ( prefix("\\xtuplet", s) || + prefix("\\xxtuplet", s)|| + prefix("\\Xtuplet", s) ) + { char *t = s+1; + while (!isdigit(*t)) t++; + xtuplet[i] = atoi(t); + } + else + if ( prefix("\\triolet", s) + || prefix("\\Triolet", s) + || prefix("\\uptrio", s) + || prefix("\\downtrio", s) + || prefix("\\uptuplet", s) + || prefix("\\downtuplet", s) ) + { + xtuplet[i] = 3; + } + + else if ( prefix("\\zchar", s) + || prefix("\\lchar", s) + || prefix("\\cchar", s) + || prefix("\\zcn", s) + || prefix("\\lcn", s) + || prefix("\\ccn", s) ) + { /* need to skip two arguments, possibly with embedded commands */ + char *t; + t = strpbrk (s+1, " {"); + if (t == NULL) error ("Argument expected"); + t = skip_arg (t); + t = skip_arg (t); + } + + else if ( prefix("\\tinynotesize", s) ) + { + tinynotesize = true; + appoggiatura = true; + } + + else if (prefix("\\ppt", s) + || prefix("\\pppt", s) ) + { + doubledotted = true; /* triple-dotted spaced as double-dotted */ + } + else if (prefix("\\pt", s) && !prefix("\\ptr", s)) + { + dotted = true; + } + else if ( prefix ("\\Dqbb", s) ) + { semiauto_beam_notes[i] = 1; + beaming[i] = SP(16); + current[i] = current[i] + 8; + nonvirtual_notes = true; + return beaming[i]; + } + else if ( prefix ("\\Dqb", s) ) + { if (debug) fprintf (logfile, "\nFound \\Dqb\n"); + semiauto_beam_notes[i] = 1; + beaming[i] = SP(8); + current[i] = current[i] + 7; + nonvirtual_notes = true; + if (debug) status (i); + return beaming[i]; + } + else if ( prefix ("\\Tqbb", s) ) + { semiauto_beam_notes[i] = 2; + beaming[i] = SP(16); + current[i] = current[i] + 8; + nonvirtual_notes = true; + return beaming[i]; + } + else if ( prefix ("\\Tqb", s) ) + { semiauto_beam_notes[i] = 2; + beaming[i] = SP(8); + current[i] = current[i] + 7; + nonvirtual_notes = true; + return beaming[i]; + } + else if ( prefix ("\\Qqbb", s) ) + { semiauto_beam_notes[i] = 3; + beaming[i] = SP(16); + current[i] = current[i] + 8; + nonvirtual_notes = true; + return beaming[i]; + } + else if ( prefix ("\\Qqb", s) ) + { semiauto_beam_notes[i] = 3; + beaming[i] = SP(8); + current[i] = current[i] + 7; + nonvirtual_notes = true; + return beaming[i]; + } + else if (prefix ("\\rlap", s) ) + /* skip the argument, as it must be regarded as non-spacing */ + { char *t; + t = strpbrk (s+1, " {\\"); + if (t == NULL) error ("Argument expected"); + if (*t == '\\') + s = t+1; + else + s = skip_arg(t); + } + else if (prefix ("\\Hsk", s) ) + update_global_skip (5); + else if (prefix ("\\Qsk", s) ) + update_global_skip (4); + else if (prefix ("\\TQsk", s) ) + update_global_skip (3); + else if (prefix ("\\HQsk", s) ) + update_global_skip (2); + else if (prefix ("\\QQsk", s) ) + update_global_skip (1); + + /* Command is non-spacing. */ + /* Skip ahead to the next command. */ + s = strpbrk (s+1, "\\&|$"); + + if ( *s != '\\') + { current[i] = s; + if (debug) + { fprintf (logfile, "\nAfter spacing_note:\n"); + status (i); + } + return spacing; + } + } /* end of while (true) loop */ + + if (spacing < MAX_SPACING) + nonvirtual_notes = true; + if (prefix ("\\whpp", s) + || prefix ("\\hupp", s) + || prefix ("\\hlpp", s) + || prefix ("\\happ", s) + || prefix ("\\hspp", s) + || prefix ("\\hppp", s) + || prefix ("\\hpausepp", s) + || prefix ("\\qupp", s) + || prefix ("\\qlpp", s) + || prefix ("\\qapp", s) + || prefix ("\\qspp", s) + || prefix ("\\qppp", s) + || prefix ("\\qqspp", s) + || prefix ("\\cupp", s) + || prefix ("\\clpp", s) + || prefix ("\\ccupp", s) + || prefix ("\\cclpp", s) + || prefix ("\\cccupp", s) + || prefix ("\\ccclpp", s) + || prefix ("\\qbpp", s) + || prefix ("\\dspp", s) + || doubledotted ) + { spacing *= 1.75; doubledotted = false;} + else + if (prefix ("\\whp", s) + || prefix ("\\hup", s) + || prefix ("\\hlp", s) + || prefix ("\\hap", s) + || prefix ("\\hsp", s) + || prefix ("\\hpp", s) + || prefix ("\\hpausep", s) + || prefix ("\\qup", s) + || prefix ("\\qlp", s) + || prefix ("\\qap", s) + || prefix ("\\qsp", s) + || prefix ("\\qqsp", s) + || prefix ("\\qpp", s) + || prefix ("\\cup", s) + || prefix ("\\clp", s) + || prefix ("\\ccup", s) + || prefix ("\\cclp", s) + || prefix ("\\cccup", s) + || prefix ("\\ccclp", s) + || prefix ("\\qbp", s) + || prefix ("\\dsp", s) + || dotted ) + { spacing *= 1.5; dotted = false; } + + t = strpbrk (s+1, "{\\&|$"); /* collective coding? */ + if (*t == '{') /* {...} */ + { /* Save prefix in collective[i]. + * It will be output for every note in the collective */ + char *ss = s; + char *tt = collective[i]; + while (ss <= t) + { *tt = *ss; tt++, ss++; } + *tt = '\0'; + current[i] = t+1; + if (tinynotesize) spacing = APPOGG_SPACING; + cspacing[i] = spacing; + first_collective[i] = true; + return collective_note (i); + } + if (tinynotesize) spacing = APPOGG_SPACING; + current[i] = strpbrk (s+1, "\\&|$"); + if (debug) + { fprintf (logfile, "\nAfter spacing_note:\n"); + status (i); + } + vspacing_active[i] = false; + return spacing; +} diff --git a/Build/source/utils/autosp/autosp-src/status.c b/Build/source/utils/autosp/autosp-src/status.c new file mode 100644 index 00000000000..400c14188b3 --- /dev/null +++ b/Build/source/utils/autosp/autosp-src/status.c @@ -0,0 +1,88 @@ +# include "process_command.h" + +char *ps(int spacing) +/* convert spacing value to note value(s) */ +{ char *s = malloc(SHORT_LEN); + char *s_n; + if (s == NULL) error ("Not enough memory"); + s_n = s; + *s = '\0'; + if (spacing == MAX_SPACING) + sprintf(s, "MAX_SPACING"); + else if (spacing == 0) + sprintf(s, "0"); + else + { int n = 1; + while (true) + { if (spacing >= SMALL_NOTE/n) + { s_n = s_n + sprintf (s_n, "SP(%d)", n); + spacing = spacing - SMALL_NOTE/n; + if (spacing > 0) + s_n = s_n + sprintf (s_n, "+"); + else break; + } + n = 2*n; + } + } + return s; +} + +void +note_segment (char *s) +{ char *t; + t = strpbrk (s, "|&$"); + if (t == NULL) t = s + strlen (s); + while (s < t) + { fputc (*s, logfile); s++; } + fputc ('\n', logfile); +} + +void +status (int i) +{ + if (active[i]) + { fprintf (logfile, "notes[%d]=", i); note_segment (notes[i]); + fprintf (logfile, "current[%d]=", i); note_segment (current[i]); + fprintf (logfile, "spacings[%d]=%s\n", i, ps(spacings[i])); + fprintf (logfile, "vspacing[%d]=%s\n", i, ps(vspacing[i])); + fprintf (logfile, "outstrings[%d]=%s\n", i, outstrings[i]); + if (xtuplet[i] > 1) + fprintf (logfile, "xtuplet[%d]=%d\n", i, xtuplet[i]); + + } +} + +void +status_spacing (void) +{ + fprintf (logfile, "spacing=%s\n", ps(spacing)); + fprintf (logfile, "old_spacing=%s\n", ps(old_spacing)); +} + +void +status_all (void) +{ int i; + for (i=1; i <= nstaffs; i++) + if (active[i]) status (i); + status_spacing (); + fprintf (logfile, "nastaffs=%d\n", nastaffs); + if (dottedbeamnotes) + fprintf (logfile, "dottedbeamnotes == true\n"); +} + +void +status_collective (int i) +{ + if (active[i]) + { fprintf (logfile, "cspacing[%d]=%s\n", i, ps(cspacing[i])); + fprintf (logfile, "collective[%d]=%s\n", i, collective[i]); + fprintf (logfile, "first_collective[%d]=%d\n", i, first_collective[i]); + } +} + +void +status_beam (int i) +{ + if (active[i]) + { fprintf (logfile, "beaming[%d]=%s\n", i, ps(beaming[i])); } +} diff --git a/Build/source/utils/autosp/autosp-src/tests/quod2.tex b/Build/source/utils/autosp/autosp-src/tests/quod2.tex index 775ae9ee1a5..28d41ede85e 100644 --- a/Build/source/utils/autosp/autosp-src/tests/quod2.tex +++ b/Build/source/utils/autosp/autosp-src/tests/quod2.tex @@ -1,4 +1,4 @@ -% Generated by autosp (2018-02-23). +% Generated by autosp (2019-01-08). \input musixtex \input musixplt \input soul.sty diff --git a/Build/source/utils/autosp/autosp-src/tests/quod4.aspc b/Build/source/utils/autosp/autosp-src/tests/quod4.aspc index 7dbfa3c3afb..b3d4e367582 100644 --- a/Build/source/utils/autosp/autosp-src/tests/quod4.aspc +++ b/Build/source/utils/autosp/autosp-src/tests/quod4.aspc @@ -1,5 +1,4 @@ -% Generated by tex2aspc (2017-12-15). -% Generated by autosp (2018-02-23). +% Generated by tex2aspc (2019-01-08). \input musixtex \input musixplt \input soul.sty diff --git a/Build/source/utils/autosp/autosp-src/tests/quod4.tex b/Build/source/utils/autosp/autosp-src/tests/quod4.tex new file mode 100644 index 00000000000..bcc4457c491 --- /dev/null +++ b/Build/source/utils/autosp/autosp-src/tests/quod4.tex @@ -0,0 +1,147 @@ +\input musixtex +\input musixplt +\input soul.sty +\sodef{\so}{}{0.15em}{0.5em}{0.5em} +\input musixsty +\input musixps +\nohalfties +\def\pstiehgt{0.5} +\def\psslurhgt{0.5} +\vsize9.75in +\voffset-0.5in +\hsize7.0in +\hoffset-0.25in +\smallmusicsize +\bigaccid +\advance\parindent by 10pt +\def\raisebarno{7\internote}% +\nobarnumbers +\relativeaccid +\geometricskipscale +\instrumentnumber4 +\setclef1\bass\setbassclefsymbol1\bassoct +\setclef4\treble\settrebleclefsymbol4\trebleoct +\generalsignature{+1} +\generalmeter\meterC +\setname1{B} +\setname2{T} +\setname3{A} +\setname4{S} +\songtop4\songbottom1 +\fulltitle{\sc\so{Quodlibet}} +\subtitle{\it Variation 30 of the Goldberg Variations for Clavier} +\title{\it Quodlibet} +\author{J. S. Bach (1685--1750)} +\shortauthor{\it J. S. Bach} +\othermention{Arranged for Recorders by R. D. Tennent} +\maketitle +\startbarno=0 +\nobarnumbers +\stafftopmarg=3.0\Interligne% +\staffbotmarg=3.0\Interligne% +\startpiece\addspace\afterruleskip% +\systemnumbers% +\Notes\ds&\cu d&\ds&\ds\en% +\bar%1 +\Notes\ha N\sk\sk\sk&\ibu1g2\qb1{g}\qb1{h}\qb1{i}\tqh1j&&\hp\sk\sk\sk\en% +\Notes\ha M&\ibl1k{-2}\qb1k&&\qp\en +\notes\sk\sk&\nbbl1\qb1j\tqb1i&&\sk\sk\en +\Notes\sk&\ibu1h0\qb1h&&\ds\en +\notes\sk\sk&\nbbu1\qb1g\tqh1h&&\cu d\sk\hqsk\en% +\def\atnextbar{\znotes&&\centerpause&\en}% +\bar%2 +\Notes\ha L\sk\sk\sk&\ibu1i{-2}\qb1i\tqh1h\itied1g\qa g\sk&\qa{n}\sk\qa{n}\sk&\ibu3g2\qb3{g}\qb3{h}\qb3{i}\tqh3j\en% +\Notes\qa{.K}&\ttie1\qa g&\qa o&\ibl3k{-2}\qb3k\en +\notes\sk\sk&\sk\sk&\sk\sk&\nbbl3\qb3j\tqb3i\en +\Notes\sk&\ibu1f0\shake{n}\qb1f&\cl o&\cu h\en +\notes\cu J\sk&\nbbu1\qb1e\tqh1f&\ds\sk&\ds\sk\hqsk\en% +\bar%3 +\Notes\hu I\sk\sk\tqsk\sk&\qa g\sk\ds\tqsk\cl k&\ibl2n{-1}\qb2{n}\qb2{o}\qb2{n}\tqsk\tqb2{=m}&\qa{k}\sk\qa{k}\tqsk\sk\en% +\Notes\hu J\sk\sk\sk&\ibu1j{-2}\qb1{j}\qb1{i}\qb1h\tqh1g&\ibl2j{0}\qb2{l}\qb2{k}\qb2j\tqb2p&\qa{l}\sk\qa{l}\sk\en% +\bar%4 +\Notes\ha K\sk&\itied1f\shake{n}\qa f\sk&\ibl2o{-1}\qb2{o}\qb2{n}&\ibl3k{-1}\qb3{k}\qb3{l}\en +\notes\sk\sk&\ttie1\ibbu1e{-2}\qb1f\tbbu1\qb1e&\qb2{o}\sk&\qb3{k}\sk\en +\Notes\sk&\itied1d\tqh1d&\tqb2m&\tqb3j\en% +\Notes\qa G\sk\ds&\ttie1\qa d\sk\qp&\ibl2n{-2}\qb2n\tqb2m\ibl2n{-5}\qb2n&\ibu3h{-2}\shake{p}\qb3i\tqh3h\qa g\en +\notes\ibbl0b{-1}\qb0b\tqb0a&\sk\sk&\tqb2k\sk&\sk\sk\hqsk\en% +\bar%5 +\Notes\ibl0M0\qb0N&\qa{n}&\ibl2n2\qb2{n}&\hp\en +\notes\nbbl0\qb0M\tqb0N&\sk\sk&\qb2{o}\sk&\sk\sk\en +\Notes\ibl0K0\qb0L&\qa{n}&\qb2{p}&\sk\en +\notes\nbbl0\qb0K\tqb0L&\sk\sk&\tqb2q\sk&\sk\sk\hqsk\en% +\Notes\qa{.M}&\qa{o}&\ibl2r{-2}\qb2r&\qp\en +\notes\sk\sk&\sk\sk&\nbbl2\qb2q\tqb2p&\sk\sk\en +\Notes\sk\cu I&\qa{o}\sk&\ibl2o6\qb2o\itieu2r\tqb2r&\ds\cl k\en% +\bar%6 +\Notes\qa{.L}\sk\sk&\ibl1n{-1}\qb1{n}\qb1{o}\qb1{n}&\ttie2\ibl2r{-2}\qb2r\tqb2q\qa p&\ibl3n{-2}\qb3{n}\qb3{m}\qb3{l}\en +\notes\ibbl0M2\qb0M\tqb0N&\tqb1m\sk&\sk\sk&\tqb3k\sk\hqsk\en% +\Notes\tqsk\itieu0a\qa a&\tqsk\ibl1l{-2}\qb1l&\tqsk\qa{.o}&\tqsk\shake{n}\ibl3i0\qb3{^j}\en +\notes\sk\sk\ttie0\ibbl0a{-2}\qb0{a}\qb0{N}\qb0{M}\tqsk\tqb0L&\tqb1k\sk\cl{^j}\sk\ds\tqsk\sk&\sk\sk\sk\sk\ibbl2i2\qb2i\tqsk\tqb2{^j}&\nbbl3\qb3i\tqb3j\cu h\sk\ds\tqsk\sk\hqsk\en% +\bar%7 +\Notes\qa{M}\sk\qa{K}\sk&\ibu1g0\qb1{f}\qb1{g}\qb1{h}\tqh1f&\ibl2k0\qb2{k}\qb2{l}\qb2{m}\tqb2k&\qa{h}\sk\qa{h}\sk\en% +\Notes\qa{N}\sk\qa{G}\sk&\ibu1g{-2}\qb1{g}\qb1{f}\qb1{e}\tqh1d&\ibl2i4\qb2{i}\qb2{k}\qb2{n}\tqb2m&\qa{i}\sk\qa{i}\sk\en% +\bar%8 +\nspace +\Notes\tqsk\qu{.H}&\tqsk\ibu1c4\qb1{^c}&\tqsk\ibl2l{-1}\qb2{.l}&\tqsk\ibu3h{0}\qb3{h}\en +\notes\sk\sk\sk\tqsk\sk&\qb1{d}\sk\qb1{e}\tqsk\sk&\sk\itieu2k\tbbl2\tqb2k\ttie2\ibbl2j0\qb2k\tqsk\tbbl2\qb2{^j}&\qb3{i}\sk\qb3{h}\tqsk\sk\en +\Notes\cu{^J}&\itied1h\tqh1h&\itieu2l\tqb2l&\tqh3g\en% +\notes\ql K\sk\sk\sk&\ttie1\ibu1h{-2}\qb1h\sk\tqh1g\sk&\ttie2\ibbl2l{-1}\qb2{l}\qb2{k}\qb2{l}\tqb2j&\ibu3f{-1}\qb3f\sk\tqh3e\sk\en +\Notes\cl K&\cu f&\cl k&\cu d\en% +\leftrightrepeat +\advance\barno-1% +\Notes\ds&\cl m&\ds&\cl o\en% +\bar%9 +\Notes\qa{d}\sk\qa{c}\sk&\ibl1k0\qb1{k}\qb1{m}\qb1{k}\tqb1{m}&\qa{o}\sk\qa{o}\sk&\ibl3m0\qb3{m}\qb3{o}\qb3{m}\tqb3o\en% +\Notes\qa{b}&\ibl1k0\qb1{n}&\qa{p}&\ibl3k2\qb3k\en +\notes\sk\sk&\qb1{k}\sk&\sk\sk&\nbbl3\qb3l\tqb3m\en +\Notes\qa{N}\sk&\qb1{k}\tqb1n&\qa{p}\sk&\ibl3n{-4}\qb3n\tqb3l\en% +\bar%10 +\Notes\ibl0b{-1}\qb0{c}\qb0{b}\qb0{c}\tqb0a&\cl l\ds\qp\sk&\ibl2o{-1}\qb2{o}\qb2{p}\qb2{o}\tqb2n&\ibl3o{-2}\qb3{o}\qb3{n}\qb3{m}\tqb3l\en% +\Notes\tqsk\qa{.b}&\tqsk\qa{m}&\tqsk\ibl2m{-2}\qb2m&\tqsk\ibl3j0\shake n\qb3{^k}\en +\notes\tqsk\sk\sk&\tqsk\sk\sk&\tqsk\tqb2l\sk&\tqsk\nbbl3\qb3{^j}\tqb3k\en +\Notes\sk\cl{^a}&\qa{m}\sk&\cl{^k}\ds&\ibl3i8\qb3i\tqb3{p}\en% +\bar%11 +\Notes\qa{N}\sk\qa{N}\sk&\ibl1l0\qb1{n}\qb1{l}\qb1{n}\tqb1l&\qa{p}\sk\qa{p}\sk&\ibl3m0\qb3{l}\qb3{p}\qb3{l}\tqb3{p}\en% +\notes\tqsk\qa{.a}\sk\sk\sk&\tqsk\ibl1m{-1}\qb1{m}\sk\qb1{n}\sk&\tqsk\qa{q}\sk\sk\sk&\tqsk\ibbl3k2\qb3{^k}\qb3{l}\qb3{m}\tqb3n\en +\Notes\sk&\qb1{m}&\qa{q}&\ibl3o{-2}\qb3o\en +\notes\cl{^a}\sk&\tqb1l\sk&\sk\sk&\nbbl3\qb3n\tqb3m\hqsk\en% +\bar%12 +\nspace +\Notes\tqsk\qa b&\tqsk\ibl1k2\qb1{^k}&\tqsk\ibl2o{-1}\qb2p&\tqsk\ibl3n{-2}\qb3n\en +\notes\sk\sk\tqsk\qa I\sk\sk\sk&\nbbl1\qb1l\tqb1m\tqsk\itied1i\qu i\sk\sk\sk&\qb2q\sk\tqsk\qb2p\sk\tqb2o\sk&\nbbl3\qb3m\tqb3l\tqsk\ibbl3k0\qb3{^k}\qb3{l}\qb3m\tqb3k\hqsk\en% +\Notes\qa{.L}&\ttie1\ibu1i0\qb1i&\ibl2n0\qb2n&\itieu3l\ha l\en +\notes\sk\sk&\nbbu1\qb1h\tqh1i&\nbbl2\qb2m\tqb2n&\sk\sk\en +\Notes\sk&\ibu1g2\qb1g&\cl l&\sk\en +\notes\cl{=K}\sk&\nbbu1\qb1h\tqh1i&\ds\sk&\sk\sk\hqsk\en% +\bar%13 +\notes\qa{J}\sk\sk\sk\qa{c}\sk&\ibl1j2\qb1{j}\sk\qb1{k}\sk\qb1{l}\sk&\hp\sk\sk\sk\sk\sk&\ttie3\ibbl3k1\slur lku1\qb3{l}\qb3{k}\slur mlu1\qb3m\tqb3l\ibbl3m1\isluru3n\qb3n\tbbl3\tslur3m\qb3m\en +\Notes\sk&\tqb1m&\sk&\tqb3o\en% +\Notes\qa{.b}&\ibl1n{-1}\qb1n&\qa n&\qa{.k}\en +\notes\sk\sk&\nbbl1\qb1m\tqb1l&\sk\sk&\sk\sk\en +\Notes\sk&\cl k&\ibl2i{-5}\qb2n&\sk\en +\notes\ibbu0J{-2}\qb0J\tqh0I&\ds\sk&\tqb2g\sk&\ibbl3j2\qb3j\tqb3k\hqsk\en% +\bar%14 +\Notes\qa{.H}&\ds&\ibl2j1\qb2{.j}&\ibl3l2\qb3l\en +\notes\sk\sk&\cu h\sk&\sk\tbbl2\tqb2k&\nbbl3\qb3m\tqb3n\en +\Notes\sk&\ibu1e0\qb1e&\ibl2j{-2}\qb2j&\ibl3o{-2}\qb3o\en +\notes\ibbu0I2\qb0I\tqh0J&\nbbu1\qb1d\tqh1e&\tqb2i\sk&\tqb3n\sk\hqsk\en% +\notes\qa{.K}\sk&\ibu1g1\qb1f\sk&\ibu2h1\qb2h\sk&\ibbl3m{-2}\shake{o}\qb3m\tbbl3\qb3l\en +\Notes\sk\sk&\itied1g\tqh1g\ttie1\ibu1g{-1}\qb1g&\tqh2i\ibl2j2\qb2j&\tqb3k\ibu3i{-6}\qb3j\en +\notes\ibbu0J2\qb0J\tqh0K&\tqh1f\sk&\tqb2k\sk&\tqh3d\sk\hqsk\en% +\bar%15 +\Notes\ibu0I0\qb0{G}&\qa{d}&\ibu2i0\qb2i&\ibl3i0\qb3{i}\en +\notes\qb0{H}\sk&\sk\sk&\nbbu2\qb2h\tqh2i&\qb3{j}\sk\en +\Notes\qb0{I}\tqh0G&\qa{d}\sk&\cu g\ds&\qb3{k}\tqb3i\en% +\Notes\qa{.J}&\qa{e}&\ds&\ibu3j{-2}\qb3{j}\en +\notes\sk\sk&\sk\sk&\ibbl2l{-2}\qb2l\tqb2k&\qb3{i}\sk\en +\Notes\sk\cu{^J}&\qa{e}\sk&\ibl2j4\qb2j\tqb2l&\qb3{h}\tqh3g\en% +\bar%16 +\notes\qa{K}\sk\sk\sk\qa{K}\sk&\ibu1g{1}\qb1{d}\sk\qb1{e}\sk\qb1{d}\sk&\ibbl2h1\qb2{h}\qb2{k}\qb2{j}\tqb2i\ibbl2j0\qb2j\tbbl2\qb2h&\ibu3f2\qb3f\sk\tqh3g\sk\ibu3h{-4}\qb3h\sk\en +\Notes\sk&\tqh1j&\itieu2k\tqb2k&\tqh3f\en% +\Notes\qa N&\ibu1i{-2}\qb1i&\ttie2\ibl2j0\qb2k&\qa g\en +\notes\sk\sk&\tqh1h\sk&\nbbl2\qb2j\tqb2k&\sk\sk\en +\Notes\cu G&\cu g&\cl i&\cu g\en% +\setrightrepeat +\endpiece% +\eject +\end diff --git a/Build/source/utils/autosp/autosp-src/tex2aspc.1 b/Build/source/utils/autosp/autosp-src/tex2aspc.1 index 5fa7e3c5b82..7f860d491dc 100644 --- a/Build/source/utils/autosp/autosp-src/tex2aspc.1 +++ b/Build/source/utils/autosp/autosp-src/tex2aspc.1 @@ -16,6 +16,8 @@ for processing by .IR infile [\fR.tex\fP] .RI [ outfile [ \fR.aspc\fP ]] +.SH DESCRIPTION + This program re-factors (sequences of) conventional note-spacing commands (\\notes \\Notes \\NOtes ...) in a measure diff --git a/Build/source/utils/autosp/autosp-src/tex2aspc.c b/Build/source/utils/autosp/autosp-src/tex2aspc.c index 98c64842038..23fd0907641 100644 --- a/Build/source/utils/autosp/autosp-src/tex2aspc.c +++ b/Build/source/utils/autosp/autosp-src/tex2aspc.c @@ -1,6 +1,6 @@ -char version[12] = "2017-12-15"; +char version[12] = "2019-01-08"; -/* Copyright (C) 2017 R. D. Tennent School of Computing, +/* Copyright (C) 2017-19 R. D. Tennent School of Computing, * Queen's University, rdt@cs.queensu.ca * * This program is free software; you can redistribute it @@ -101,6 +101,8 @@ void analyze_notes (char **ln) char *nl; if (fgets (new_line, LINE_LEN, infile) == NULL) error ("Unexpected EOF."); + if (strlen (new_line) == LINE_LEN-1) + error ("Line too long."); nl = new_line; while (*nl == ' ') nl++; /* avoid spaces */ t = strpbrk (s, "\n%"); @@ -246,7 +248,10 @@ void process_score () while ( c != EOF ) { ungetc (c, infile); - fgets(line, LINE_LEN, infile); + if ( fgets(line, LINE_LEN, infile) == NULL) + error ("Unexpected EOF."); + if (strlen (line) == LINE_LEN-1) + error ("Line too long."); lineno++; process_line (); c = getc (infile); diff --git a/Build/source/utils/autosp/autosp-src/tex2aspc.test b/Build/source/utils/autosp/autosp-src/tex2aspc.test index 45943206bf5..6d9f73ddd20 100755 --- a/Build/source/utils/autosp/autosp-src/tex2aspc.test +++ b/Build/source/utils/autosp/autosp-src/tex2aspc.test @@ -1,10 +1,13 @@ #! /bin/sh -vx +#! /bin/sh -vx + # Copyright 2018 Karl Berry <tex-live@tug.org> # You may freely use, modify and/or distribute this file. LC_ALL=C; export LC_ALL; LANGUAGE=C; export LANGUAGE + if test -z "$test_srcdir"; then # If not set, then we are not running from `make check'. test_srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'` # == dirname $0 @@ -21,8 +24,8 @@ echo && echo "*** tex2aspc --version" echo && echo "*** tex2aspc (missing infile)" ./tex2aspc && exit 1 -echo && echo "*** tex2aspc quod2.tex quod4.aspc" -cp "$test_srcdir"/tests/quod2.tex quod4.tex +echo && echo "*** tex2aspc quod4.tex quod4.aspc" +cp "$test_srcdir"/tests/quod4.tex quod4.tex rm -f quod4.aspc ./tex2aspc quod4.tex quod4.aspc || exit 1 diff --git a/Build/source/utils/autosp/autosp-src/xtuplet.c b/Build/source/utils/autosp/autosp-src/xtuplet.c new file mode 100644 index 00000000000..59a5e482740 --- /dev/null +++ b/Build/source/utils/autosp/autosp-src/xtuplet.c @@ -0,0 +1,218 @@ +# include "process_command.h" + +PRIVATE +void save_state (int i) +/* used in process_xtuplet */ +{ + beamingi = beaming[i]; + currenti = current[i]; + cspacingi = cspacing[i]; + vspacingi = vspacing[i]; + first_collectivei = first_collective[i]; + collectivei[0] = '\0'; + append (collectivei, NULL, collective[i], SHORT_LEN); +} + +PRIVATE +void restore_state (int i) +/* used in process_xtuplet */ +{ + beaming[i] = beamingi; + current[i] = currenti; + cspacing[i] = cspacingi; + vspacing[i] = vspacingi; + first_collective[i] = first_collectivei; + collective[i][0] = '\0'; + append (collective[i], NULL, collectivei, SHORT_LEN); +} + +PRIVATE +void pseudo_output_notes (int i) +{ /* process notes like output_notes but without outputting */ + if (vspacing[i] > 0) + vspacing[i] = vspacing[i] - spacing; + else if (collective[i][0]) + { + first_collective[i] = false; + if (*current[i] == '}') + { collective[i][0] = '\0'; + current[i]++; + } + } +} + +void process_xtuplet (void) +{ + int i, xi=0; + int xspacing = MAX_SPACING; /* xtuplet total spacing */ + int normalized_xspacing; /* (xspacing / xtuplet) * (xtuplet - 1); */ + int xsp; + double multnoteskip; + + if (debug) + { fprintf (logfile, "\nEntering process_xtuplet:\n"); + for (i=1; i <= nstaffs; i++) + fprintf (logfile, "i=%d xtuplet[i]=%d\n", i, xtuplet[i]); + } + + if (old_spacing < MAX_SPACING) + { char *s, *t; + if (debug) fprintf (logfile, "Terminate current notes command:\n"); + t = TransformNotes2; + while (true) + { s = strchr (t, '#'); + if (s == NULL) break; + while (t < s) /* output any initial \transpose etc. */ + { putc (*t, outfile); t++; } + t++; /* skip # */ + i = atoi (t) - 1; t++; + fprintf (outfile, "%s", outstrings[i]); + if (debug) fprintf (logfile, "\noutputting %s from outstrings[%d].\n", outstrings[i], i); + outstrings[i][0] = '\0'; + n_outstrings[i] = outstrings[i]; + if (*t != '\0') + { putc (*t, outfile); t++; } /* terminator */ + } + fprintf (outfile, "\\en"); + if (debug) + { fprintf (logfile, "\\en"); + fprintf (logfile, "\nAfter termination of notes command:\n"); + status_all (); + } + } + + if (debug) + { fprintf (logfile, "\nDetermine xtuplet duration:\n"); + fflush (logfile); + } + for (i=1; i <= nstaffs; i++) + if (xtuplet[i] > 1) + { + xi = i; + save_state (xi); + pseudo_output_notes (xi); + xspacing = spacings[xi]; + while (xspacing % xtuplet[xi] != 0) + { + xspacing += spacing_note (xi); + pseudo_output_notes (xi); + if (xspacing >= MAX_SPACING) + error ("Can't determine xtuplet duration."); + } + restore_state (xi); + break; + } + if (debug) fprintf (logfile, "\nxspacing=%s\n", ps(xspacing)); + if (debug) fprintf (logfile, "xi=%d xtuplet[xi]=%d\n", xi, xtuplet[xi]); + normalized_xspacing = (xspacing / xtuplet[xi]) * (xtuplet[xi] - 1); + if (debug) + { fprintf (logfile, "normalized_xspacing=%s\n", ps(normalized_xspacing)); + } + spacing = xspacing / xtuplet[xi]; + if (debug) + { + fprintf (logfile, "\nDetermine minimal spacing over all active staffs:\n"); + } + for (i=1; i <= nstaffs; i++) + if (active[i] && xtuplet[i] == 1) + { save_state (i); + pseudo_output_notes (i); + xsp = spacings[i]; + if (spacings[i] < spacing) + spacing = spacings[i]; + while (xsp < normalized_xspacing) + { int spi = spacing_note (i); + pseudo_output_notes (i); + xsp += spi; + if (spi < spacing) + { spacing = spi; + if (debug) fprintf (logfile, "for i=%d spi=%s\n", i, ps(spi)); + } + } + restore_state (i); + } + if (debug) fprintf (logfile, "\nxspacing=%s\n", ps(spacing)); + + if (debug) fprintf (logfile, "\nCreate a new notes command for the xtuplet:\n"); + initialize_notes (); + + + if (debug) fprintf (logfile, "\nProcess non-xtuplet staffs:\n"); + for (i=1; i <= nstaffs; i++) + vspacing[i] = 0; + xsp = 0; + while (true) + { + for (i=1; i <= nstaffs; i++) + if (active[i] && xtuplet[i] == 1) + output_notes (i); + xsp += spacing; + for (i=1; i <= nstaffs; i++) + { + /* virtual notes needed? */ + if (active[i] && xtuplet[i] == 1 && spacings[i] != 0 && spacings[i] != spacing && vspacing[i] == 0) + { + vspacing[i] = spacings[i] - spacing; + } + } + if (xsp >= normalized_xspacing) break; + global_skip = 0; + for (i=1; i <= nstaffs; i++) + if (active[i] && xtuplet[i] == 1) + spacings[i] = spacing_note(i); + } + if (debug) + { fprintf (logfile, "\nAfter processing non-xtuplet staffs:\n"); + status_all (); + } + if (debug) + { + fprintf (logfile, "Generate \\multnoteskip factors.\n"); + fprintf (logfile, "xi=%d xtuplet[xi]=%d\n", xi, xtuplet[xi]); + } + multnoteskip = (double) (xtuplet[xi] - 1) / xtuplet[xi]; + for (i=1; i <= nstaffs; i++) + if (xtuplet[i] > 1) + { + n_outstrings[i] += sprintf (n_outstrings[i], "\\multnoteskip{%5.3f}", multnoteskip); + if (debug) + { fprintf (logfile, "\noutstrings[%d]=", i); + note_segment (outstrings[i]); + } + } + if (debug) fprintf (logfile, "\nRe-process xtuplet staffs:\n"); + for (i=1; i <= nstaffs; i++) + if (xtuplet[i] > 1) + { + xsp = 0; + while (true) + { output_notes (i); + xsp += spacing; + if (spacings[i] != spacing && vspacing[i] == 0) + vspacing[i] = spacings[i] - spacing; + if (xsp >= xspacing) break; + global_skip = 0; + spacings[i] = spacing_note (i); + } + } + + /* Restore normal \noteskip in the xtuplet staffs. */ + if (debug) + { + fprintf (logfile, "Restore \\multnoteskip factors.\n"); + fprintf (logfile, "xi=%d xtuplet[xi]=%d\n", xi, xtuplet[xi]); + } + multnoteskip = (double) xtuplet[xi] / (xtuplet[xi]-1); + for (i=1; i <= nstaffs; i++) + if (xtuplet[i] > 1) + { + n_outstrings[i] += sprintf (n_outstrings[i], "\\multnoteskip{%5.3f}", multnoteskip); + xtuplet[i] = 1; + } + nonvirtual_notes = true; + if (debug) + { fprintf (logfile, "\nAfter process_xtuplet:\n"); + status_all (); + } + return; +} |