texlive[49653] Build/source/utils: autosp 2019-01-08

commits+kakuto at tug.org commits+kakuto at tug.org
Thu Jan 10 00:14:12 CET 2019


Revision: 49653
          http://tug.org/svn/texlive?view=revision&revision=49653
Author:   kakuto
Date:     2019-01-10 00:14:12 +0100 (Thu, 10 Jan 2019)
Log Message:
-----------
autosp 2019-01-08

Modified Paths:
--------------
    trunk/Build/source/utils/README
    trunk/Build/source/utils/autosp/ChangeLog
    trunk/Build/source/utils/autosp/Makefile.am
    trunk/Build/source/utils/autosp/Makefile.in
    trunk/Build/source/utils/autosp/TLpatches/ChangeLog
    trunk/Build/source/utils/autosp/TLpatches/patch-01-binary-write
    trunk/Build/source/utils/autosp/autosp-src/ChangeLog
    trunk/Build/source/utils/autosp/autosp-src/Makefile.am
    trunk/Build/source/utils/autosp/autosp-src/Makefile.in
    trunk/Build/source/utils/autosp/autosp-src/README
    trunk/Build/source/utils/autosp/autosp-src/autosp.1
    trunk/Build/source/utils/autosp/autosp-src/autosp.c
    trunk/Build/source/utils/autosp/autosp-src/compile
    trunk/Build/source/utils/autosp/autosp-src/configure
    trunk/Build/source/utils/autosp/autosp-src/configure.ac
    trunk/Build/source/utils/autosp/autosp-src/depcomp
    trunk/Build/source/utils/autosp/autosp-src/install-sh
    trunk/Build/source/utils/autosp/autosp-src/rebar.c
    trunk/Build/source/utils/autosp/autosp-src/tests/quod2.tex
    trunk/Build/source/utils/autosp/autosp-src/tests/quod4.aspc
    trunk/Build/source/utils/autosp/autosp-src/tex2aspc.1
    trunk/Build/source/utils/autosp/autosp-src/tex2aspc.c
    trunk/Build/source/utils/autosp/autosp-src/tex2aspc.test
    trunk/Build/source/utils/autosp/configure
    trunk/Build/source/utils/autosp/configure.ac

Added Paths:
-----------
    trunk/Build/source/utils/autosp/autosp-src/autosp.h
    trunk/Build/source/utils/autosp/autosp-src/process_command.c
    trunk/Build/source/utils/autosp/autosp-src/process_command.h
    trunk/Build/source/utils/autosp/autosp-src/process_score.c
    trunk/Build/source/utils/autosp/autosp-src/process_score.h
    trunk/Build/source/utils/autosp/autosp-src/spacing_note.c
    trunk/Build/source/utils/autosp/autosp-src/status.c
    trunk/Build/source/utils/autosp/autosp-src/tests/quod4.tex
    trunk/Build/source/utils/autosp/autosp-src/xtuplet.c

Modified: trunk/Build/source/utils/README
===================================================================
--- trunk/Build/source/utils/README	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/README	2019-01-09 23:14:12 UTC (rev 49653)
@@ -9,7 +9,7 @@
   see http://tug.org/texlive/build.html#asymptote
   and tlpkg/bin/tl-update-asy
 
-autosp 2018-02-23 - checked 23feb18
+autosp 2019-01-08 - checked 10Jan19
   http://ctan.org/pkg/autosp
 
 devnag - from devanagari package installed in texmf-dist.

Modified: trunk/Build/source/utils/autosp/ChangeLog
===================================================================
--- trunk/Build/source/utils/autosp/ChangeLog	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/ChangeLog	2019-01-09 23:14:12 UTC (rev 49653)
@@ -1,3 +1,8 @@
+2019-01-10  Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
+
+	* Import autosp-2019-01-08.
+	configure.ac, Makefile.am: Adapted.
+
 2018-03-12  Norbert Preining  <norbert at preining.info>
 
 	* autosp.c: Fix a potential bug in the usage of fprintf().

Modified: trunk/Build/source/utils/autosp/Makefile.am
===================================================================
--- trunk/Build/source/utils/autosp/Makefile.am	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/Makefile.am	2019-01-09 23:14:12 UTC (rev 49653)
@@ -21,7 +21,12 @@
 # must use @... here or subdir $(... (literally) is created for .deps.
 autosp_SOURCES = \
 	@AUTOSP_TREE@/autosp.c \
-	@AUTOSP_TREE@/utils.c
+	@AUTOSP_TREE@/utils.c \
+	@AUTOSP_TREE@/process_score.c \
+	@AUTOSP_TREE@/process_command.c \
+	@AUTOSP_TREE@/status.c \
+	@AUTOSP_TREE@/spacing_note.c \
+	@AUTOSP_TREE@/xtuplet.c
 
 tex2aspc_SOURCES = \
 	@AUTOSP_TREE@/tex2aspc.c \

Modified: trunk/Build/source/utils/autosp/Makefile.in
===================================================================
--- trunk/Build/source/utils/autosp/Makefile.in	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/Makefile.in	2019-01-09 23:14:12 UTC (rev 49653)
@@ -106,7 +106,12 @@
 PROGRAMS = $(bin_PROGRAMS)
 am__dirstamp = $(am__leading_dot)dirstamp
 am_autosp_OBJECTS = @AUTOSP_TREE@/autosp.$(OBJEXT) \
-	@AUTOSP_TREE@/utils.$(OBJEXT)
+	@AUTOSP_TREE@/utils.$(OBJEXT) \
+	@AUTOSP_TREE@/process_score.$(OBJEXT) \
+	@AUTOSP_TREE@/process_command.$(OBJEXT) \
+	@AUTOSP_TREE@/status.$(OBJEXT) \
+	@AUTOSP_TREE@/spacing_note.$(OBJEXT) \
+	@AUTOSP_TREE@/xtuplet.$(OBJEXT)
 autosp_OBJECTS = $(am_autosp_OBJECTS)
 autosp_LDADD = $(LDADD)
 am_tex2aspc_OBJECTS = @AUTOSP_TREE@/tex2aspc.$(OBJEXT) \
@@ -129,8 +134,13 @@
 depcomp = $(SHELL) $(top_srcdir)/../../build-aux/depcomp
 am__maybe_remake_depfiles = depfiles
 am__depfiles_remade = @AUTOSP_TREE@/$(DEPDIR)/autosp.Po \
+	@AUTOSP_TREE@/$(DEPDIR)/process_command.Po \
+	@AUTOSP_TREE@/$(DEPDIR)/process_score.Po \
+	@AUTOSP_TREE@/$(DEPDIR)/spacing_note.Po \
+	@AUTOSP_TREE@/$(DEPDIR)/status.Po \
 	@AUTOSP_TREE@/$(DEPDIR)/tex2aspc.Po \
-	@AUTOSP_TREE@/$(DEPDIR)/utils.Po
+	@AUTOSP_TREE@/$(DEPDIR)/utils.Po \
+	@AUTOSP_TREE@/$(DEPDIR)/xtuplet.Po
 am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -508,7 +518,12 @@
 # must use @... here or subdir $(... (literally) is created for .deps.
 autosp_SOURCES = \
 	@AUTOSP_TREE@/autosp.c \
-	@AUTOSP_TREE@/utils.c
+	@AUTOSP_TREE@/utils.c \
+	@AUTOSP_TREE@/process_score.c \
+	@AUTOSP_TREE@/process_command.c \
+	@AUTOSP_TREE@/status.c \
+	@AUTOSP_TREE@/spacing_note.c \
+	@AUTOSP_TREE@/xtuplet.c
 
 tex2aspc_SOURCES = \
 	@AUTOSP_TREE@/tex2aspc.c \
@@ -611,6 +626,17 @@
 	@AUTOSP_TREE@/$(DEPDIR)/$(am__dirstamp)
 @AUTOSP_TREE@/utils.$(OBJEXT): @AUTOSP_TREE@/$(am__dirstamp) \
 	@AUTOSP_TREE@/$(DEPDIR)/$(am__dirstamp)
+ at AUTOSP_TREE@/process_score.$(OBJEXT): @AUTOSP_TREE@/$(am__dirstamp) \
+	@AUTOSP_TREE@/$(DEPDIR)/$(am__dirstamp)
+ at AUTOSP_TREE@/process_command.$(OBJEXT):  \
+	@AUTOSP_TREE@/$(am__dirstamp) \
+	@AUTOSP_TREE@/$(DEPDIR)/$(am__dirstamp)
+ at AUTOSP_TREE@/status.$(OBJEXT): @AUTOSP_TREE@/$(am__dirstamp) \
+	@AUTOSP_TREE@/$(DEPDIR)/$(am__dirstamp)
+ at AUTOSP_TREE@/spacing_note.$(OBJEXT): @AUTOSP_TREE@/$(am__dirstamp) \
+	@AUTOSP_TREE@/$(DEPDIR)/$(am__dirstamp)
+ at AUTOSP_TREE@/xtuplet.$(OBJEXT): @AUTOSP_TREE@/$(am__dirstamp) \
+	@AUTOSP_TREE@/$(DEPDIR)/$(am__dirstamp)
 
 autosp$(EXEEXT): $(autosp_OBJECTS) $(autosp_DEPENDENCIES) $(EXTRA_autosp_DEPENDENCIES) 
 	@rm -f autosp$(EXEEXT)
@@ -630,8 +656,13 @@
 	-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@@AUTOSP_TREE@/$(DEPDIR)/autosp.Po at am__quote@ # am--include-marker
+ at AMDEP_TRUE@@am__include@ @am__quote@@AUTOSP_TREE@/$(DEPDIR)/process_command.Po at am__quote@ # am--include-marker
+ at AMDEP_TRUE@@am__include@ @am__quote@@AUTOSP_TREE@/$(DEPDIR)/process_score.Po at am__quote@ # am--include-marker
+ at AMDEP_TRUE@@am__include@ @am__quote@@AUTOSP_TREE@/$(DEPDIR)/spacing_note.Po at am__quote@ # am--include-marker
+ at AMDEP_TRUE@@am__include@ @am__quote@@AUTOSP_TREE@/$(DEPDIR)/status.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@@AUTOSP_TREE@/$(DEPDIR)/tex2aspc.Po at am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@@AUTOSP_TREE@/$(DEPDIR)/utils.Po at am__quote@ # am--include-marker
+ at AMDEP_TRUE@@am__include@ @am__quote@@AUTOSP_TREE@/$(DEPDIR)/xtuplet.Po at am__quote@ # am--include-marker
 
 $(am__depfiles_remade):
 	@$(MKDIR_P) $(@D)
@@ -1130,8 +1161,13 @@
 distclean: distclean-am
 	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
 		-rm -f @AUTOSP_TREE@/$(DEPDIR)/autosp.Po
+	-rm -f @AUTOSP_TREE@/$(DEPDIR)/process_command.Po
+	-rm -f @AUTOSP_TREE@/$(DEPDIR)/process_score.Po
+	-rm -f @AUTOSP_TREE@/$(DEPDIR)/spacing_note.Po
+	-rm -f @AUTOSP_TREE@/$(DEPDIR)/status.Po
 	-rm -f @AUTOSP_TREE@/$(DEPDIR)/tex2aspc.Po
 	-rm -f @AUTOSP_TREE@/$(DEPDIR)/utils.Po
+	-rm -f @AUTOSP_TREE@/$(DEPDIR)/xtuplet.Po
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-tags
@@ -1180,8 +1216,13 @@
 	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
 	-rm -rf $(top_srcdir)/autom4te.cache
 		-rm -f @AUTOSP_TREE@/$(DEPDIR)/autosp.Po
+	-rm -f @AUTOSP_TREE@/$(DEPDIR)/process_command.Po
+	-rm -f @AUTOSP_TREE@/$(DEPDIR)/process_score.Po
+	-rm -f @AUTOSP_TREE@/$(DEPDIR)/spacing_note.Po
+	-rm -f @AUTOSP_TREE@/$(DEPDIR)/status.Po
 	-rm -f @AUTOSP_TREE@/$(DEPDIR)/tex2aspc.Po
 	-rm -f @AUTOSP_TREE@/$(DEPDIR)/utils.Po
+	-rm -f @AUTOSP_TREE@/$(DEPDIR)/xtuplet.Po
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 

Modified: trunk/Build/source/utils/autosp/TLpatches/ChangeLog
===================================================================
--- trunk/Build/source/utils/autosp/TLpatches/ChangeLog	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/TLpatches/ChangeLog	2019-01-09 23:14:12 UTC (rev 49653)
@@ -1,3 +1,8 @@
+2019-01-10  Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
+
+	Import autosp-2019-01-08.
+	* patch-01-binary-write: Adapt.
+
 2018-03-12  Norbert Preining  <norbert at preining.info>
 
 	* patch-01-binary-write: Add two changes in autosp.c.

Modified: trunk/Build/source/utils/autosp/TLpatches/patch-01-binary-write
===================================================================
--- trunk/Build/source/utils/autosp/TLpatches/patch-01-binary-write	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/TLpatches/patch-01-binary-write	2019-01-09 23:14:12 UTC (rev 49653)
@@ -1,54 +1,8 @@
-diff -ur autosp-2018-02-23/autosp.c autosp-src/autosp.c
---- autosp-2018-02-23/autosp.c	Fri Feb 23 23:55:07 2018
-+++ autosp-src/autosp.c	Mon Mar 12 17:58:18 2018
-@@ -510,7 +510,7 @@
-     update_global_skip (n);
-       /* commas will be discarded by filter_output (i) */
-     if (*s == '.' && new_beaming == 0 && !dottedbeamnotes) 
--      spacing = spacing * 1.50; 
-+      spacing = (int)(spacing * 1.50); 
-     else if ( (*s == '^' || *s == '_' || *s == '=' || *s == '>') 
-               && !vspacing_active[i]  /* is additional spacing needed? */
-             )
-@@ -984,7 +984,7 @@
-    || prefix ("\\qbpp", s) 
-    || prefix ("\\dspp", s) 
-    || doubledotted  )
--  { spacing *= 1.75; doubledotted = false;}
-+  { spacing = (int)(spacing * 1.75); doubledotted = false;}
-   else 
-   if (prefix ("\\whp", s)
-    || prefix ("\\hup", s)
-@@ -1008,7 +1008,7 @@
-    || prefix ("\\qbp", s) 
-    || prefix ("\\dsp", s) 
-     || dotted  ) 
--  { spacing *= 1.5; dotted = false; }
-+  { spacing = (int)(spacing * 1.5); dotted = false; }
- 
-   t = strpbrk (s+1, "{\\&|$"); /* collective coding?  */
-   if (*t == '{')  /*  {...}  */
-@@ -2007,7 +2007,7 @@
-          || prefix ("\\end%", *ln) 
-          || prefix ("\\end{document}", *ln) )
-   {
--    fprintf (outfile, *ln);
-+    fprintf (outfile, "%s", *ln);
-     exit(0);
+diff -ur autosp-2019-01-08/autosp.c autosp-src/autosp.c
+--- autosp-2019-01-08/autosp.c	Tue Jan 08 22:27:17 2019
++++ autosp-src/autosp.c	Thu Jan 10 07:39:06 2019
+@@ -183,7 +183,7 @@
    }
- 
-@@ -2054,7 +2054,8 @@
-   while ( c != EOF )
-   {
-     ungetc (c, infile);
--    fgets(line, LINE_LEN, infile); 
-+    if (fgets(line, LINE_LEN, infile) == NULL)
-+      error ("Unexpected EOF.");
-     lineno++;
-     process_line ();
-     c = getc (infile);
-@@ -2153,7 +2154,7 @@
-   }
    else
    {
 -    outfile = fopen (outfilename, "w");
@@ -56,7 +10,7 @@
      if (outfile == NULL)
      { printf ("Can't open %s\n", outfilename);
        exit (EXIT_FAILURE);
-@@ -2171,7 +2172,7 @@
+@@ -201,7 +201,7 @@
    *logfilename_n = '\0';
    append (logfilename, &logfilename_n, "alog", sizeof (logfilename));
    if (debug)  
@@ -65,10 +19,10 @@
      if (logfile == NULL)
      { printf ("Can't open %s\n", logfilename);
        exit (EXIT_FAILURE);
-diff -ur autosp-2018-02-23/rebar.c autosp-src/rebar.c
---- autosp-2018-02-23/rebar.c	Thu Jun 15 03:08:12 2017
-+++ autosp-src/rebar.c	Sat Feb 24 08:08:28 2018
-@@ -262,7 +262,7 @@
+diff -ur autosp-2019-01-08/rebar.c autosp-src/rebar.c
+--- autosp-2019-01-08/rebar.c	Tue Jan 08 22:28:27 2019
++++ autosp-src/rebar.c	Thu Jan 10 07:39:23 2019
+@@ -264,7 +264,7 @@
        else
          append (outfilename, &outfilename_n, ".aspc", sizeof (outfilename));
      }
@@ -77,10 +31,10 @@
      if (outfile == NULL)
      { fprintf (stderr,"Can't open %s\n", outfilename);
        exit (EXIT_FAILURE);
-diff -ur autosp-2018-02-23/tex2aspc.c autosp-src/tex2aspc.c
---- autosp-2018-02-23/tex2aspc.c	Sat Dec 16 00:04:13 2017
-+++ autosp-src/tex2aspc.c	Sat Feb 24 08:08:56 2018
-@@ -337,7 +337,7 @@
+diff -ur autosp-2019-01-08/tex2aspc.c autosp-src/tex2aspc.c
+--- autosp-2019-01-08/tex2aspc.c	Tue Jan 08 22:28:57 2019
++++ autosp-src/tex2aspc.c	Thu Jan 10 07:39:45 2019
+@@ -342,7 +342,7 @@
      append (outfilename, &outfilename_n, ".aspc", sizeof (outfilename));
    }
  

Modified: trunk/Build/source/utils/autosp/autosp-src/ChangeLog
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/ChangeLog	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/autosp-src/ChangeLog	2019-01-09 23:14:12 UTC (rev 49653)
@@ -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... 

Modified: trunk/Build/source/utils/autosp/autosp-src/Makefile.am
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/Makefile.am	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/autosp-src/Makefile.am	2019-01-09 23:14:12 UTC (rev 49653)
@@ -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 += $(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.*
 

Modified: trunk/Build/source/utils/autosp/autosp-src/Makefile.in
===================================================================
(Binary files differ)

Modified: trunk/Build/source/utils/autosp/autosp-src/README
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/README	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/autosp-src/README	2019-01-09 23:14:12 UTC (rev 49653)
@@ -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

Modified: trunk/Build/source/utils/autosp/autosp-src/autosp.1
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/autosp.1	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/autosp-src/autosp.1	2019-01-09 23:14:12 UTC (rev 49653)
@@ -14,7 +14,7 @@
 .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 ...), 

Modified: trunk/Build/source/utils/autosp/autosp-src/autosp.c
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/autosp.c	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/autosp-src/autosp.c	2019-01-09 23:14:12 UTC (rev 49653)
@@ -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 at cs.queensu.ca
  *
  *  This program is free software; you can redistribute it
@@ -80,124 +80,9 @@
  *      
  */
 
-# 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 @@
 }
 
 
-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;
-}
+bool dottedbeamnotes = false;   /* dotted beam notes ignored?        */
+bool debug = false;
 
-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  */
-}     
-
 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 @@
      { 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 at cs.queensu.ca\n" );
@@ -2182,6 +211,7 @@
   printf ("\n\n");
 
   fprintf (outfile, "%%  Generated by autosp (%s).\n", version);
+
   process_score ();
   
   return 0;

Added: trunk/Build/source/utils/autosp/autosp-src/autosp.h
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/autosp.h	                        (rev 0)
+++ trunk/Build/source/utils/autosp/autosp-src/autosp.h	2019-01-09 23:14:12 UTC (rev 49653)
@@ -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 ();


Property changes on: trunk/Build/source/utils/autosp/autosp-src/autosp.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Modified: trunk/Build/source/utils/autosp/autosp-src/compile
===================================================================
(Binary files differ)

Modified: trunk/Build/source/utils/autosp/autosp-src/configure
===================================================================
(Binary files differ)

Modified: trunk/Build/source/utils/autosp/autosp-src/configure.ac
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/configure.ac	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/autosp-src/configure.ac	2019-01-09 23:14:12 UTC (rev 49653)
@@ -1,5 +1,5 @@
 AC_PREREQ(2.63)
-AC_INIT([autosp],[2018-02-23],[rdt at cs.queensu.ca])
+AC_INIT([autosp],[2019-01-08],[rdt at cs.queensu.ca])
 AC_CONFIG_AUX_DIR([.])
 AM_INIT_AUTOMAKE
 AC_CONFIG_HEADERS([config.h])

Modified: trunk/Build/source/utils/autosp/autosp-src/depcomp
===================================================================
(Binary files differ)

Modified: trunk/Build/source/utils/autosp/autosp-src/install-sh
===================================================================
(Binary files differ)

Added: trunk/Build/source/utils/autosp/autosp-src/process_command.c
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/process_command.c	                        (rev 0)
+++ trunk/Build/source/utils/autosp/autosp-src/process_command.c	2019-01-09 23:14:12 UTC (rev 49653)
@@ -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);
+  }
+}
+


Property changes on: trunk/Build/source/utils/autosp/autosp-src/process_command.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Added: trunk/Build/source/utils/autosp/autosp-src/process_command.h
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/process_command.h	                        (rev 0)
+++ trunk/Build/source/utils/autosp/autosp-src/process_command.h	2019-01-09 23:14:12 UTC (rev 49653)
@@ -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 ();


Property changes on: trunk/Build/source/utils/autosp/autosp-src/process_command.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Added: trunk/Build/source/utils/autosp/autosp-src/process_score.c
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/process_score.c	                        (rev 0)
+++ trunk/Build/source/utils/autosp/autosp-src/process_score.c	2019-01-09 23:14:12 UTC (rev 49653)
@@ -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  */
+}     
+


Property changes on: trunk/Build/source/utils/autosp/autosp-src/process_score.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Added: trunk/Build/source/utils/autosp/autosp-src/process_score.h
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/process_score.h	                        (rev 0)
+++ trunk/Build/source/utils/autosp/autosp-src/process_score.h	2019-01-09 23:14:12 UTC (rev 49653)
@@ -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);


Property changes on: trunk/Build/source/utils/autosp/autosp-src/process_score.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Modified: trunk/Build/source/utils/autosp/autosp-src/rebar.c
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/rebar.c	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/autosp-src/rebar.c	2019-01-09 23:14:12 UTC (rev 49653)
@@ -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 at cs.queensu.ca
  *
  *  This program is free software; you can redistribute it
@@ -178,8 +178,10 @@
   {
     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  */
 }     

Added: trunk/Build/source/utils/autosp/autosp-src/spacing_note.c
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/spacing_note.c	                        (rev 0)
+++ trunk/Build/source/utils/autosp/autosp-src/spacing_note.c	2019-01-09 23:14:12 UTC (rev 49653)
@@ -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;
+}


Property changes on: trunk/Build/source/utils/autosp/autosp-src/spacing_note.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Added: trunk/Build/source/utils/autosp/autosp-src/status.c
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/status.c	                        (rev 0)
+++ trunk/Build/source/utils/autosp/autosp-src/status.c	2019-01-09 23:14:12 UTC (rev 49653)
@@ -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])); }
+}


Property changes on: trunk/Build/source/utils/autosp/autosp-src/status.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Modified: trunk/Build/source/utils/autosp/autosp-src/tests/quod2.tex
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/tests/quod2.tex	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/autosp-src/tests/quod2.tex	2019-01-09 23:14:12 UTC (rev 49653)
@@ -1,4 +1,4 @@
-%  Generated by autosp (2018-02-23).
+%  Generated by autosp (2019-01-08).
 \input musixtex
 \input musixplt
 \input soul.sty

Modified: trunk/Build/source/utils/autosp/autosp-src/tests/quod4.aspc
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/tests/quod4.aspc	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/autosp-src/tests/quod4.aspc	2019-01-09 23:14:12 UTC (rev 49653)
@@ -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

Added: trunk/Build/source/utils/autosp/autosp-src/tests/quod4.tex
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/tests/quod4.tex	                        (rev 0)
+++ trunk/Build/source/utils/autosp/autosp-src/tests/quod4.tex	2019-01-09 23:14:12 UTC (rev 49653)
@@ -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

Modified: trunk/Build/source/utils/autosp/autosp-src/tex2aspc.1
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/tex2aspc.1	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/autosp-src/tex2aspc.1	2019-01-09 23:14:12 UTC (rev 49653)
@@ -16,6 +16,8 @@
 .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 

Modified: trunk/Build/source/utils/autosp/autosp-src/tex2aspc.c
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/tex2aspc.c	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/autosp-src/tex2aspc.c	2019-01-09 23:14:12 UTC (rev 49653)
@@ -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 at cs.queensu.ca
  *  
  *  This program is free software; you can redistribute it
@@ -101,6 +101,8 @@
       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 @@
   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);

Modified: trunk/Build/source/utils/autosp/autosp-src/tex2aspc.test
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/tex2aspc.test	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/autosp-src/tex2aspc.test	2019-01-09 23:14:12 UTC (rev 49653)
@@ -1,10 +1,13 @@
 #! /bin/sh -vx
 
+#! /bin/sh -vx
+
 # Copyright 2018 Karl Berry <tex-live at 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  (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
 

Added: trunk/Build/source/utils/autosp/autosp-src/xtuplet.c
===================================================================
--- trunk/Build/source/utils/autosp/autosp-src/xtuplet.c	                        (rev 0)
+++ trunk/Build/source/utils/autosp/autosp-src/xtuplet.c	2019-01-09 23:14:12 UTC (rev 49653)
@@ -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;
+}


Property changes on: trunk/Build/source/utils/autosp/autosp-src/xtuplet.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Modified: trunk/Build/source/utils/autosp/configure
===================================================================
(Binary files differ)

Modified: trunk/Build/source/utils/autosp/configure.ac
===================================================================
--- trunk/Build/source/utils/autosp/configure.ac	2019-01-09 22:56:43 UTC (rev 49652)
+++ trunk/Build/source/utils/autosp/configure.ac	2019-01-09 23:14:12 UTC (rev 49653)
@@ -7,7 +7,7 @@
 dnl   gives unlimited permission to copy and/or distribute it,
 dnl   with or without modifications, as long as this notice is preserved.
 dnl
-m4_define([autosp_version], [2018-02-23])[]dnl using unmodified autosp source
+m4_define([autosp_version], [2019-01-08])[]dnl using unmodified autosp source
 AC_INIT([autosp (TeX Live)], autosp_version, [tex-k at tug.org])
 AC_PREREQ([2.65])
 AC_CONFIG_SRCDIR([autosp-src/autosp.c])



More information about the tex-live-commits mailing list