From 643f37f986567ca5af6baab87421f8ef22b23403 Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Thu, 17 Dec 2015 07:20:42 +0000 Subject: Import m-tx 0.61 git-svn-id: svn://tug.org/texlive/trunk@39128 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/utils/m-tx/ChangeLog | 4 + Build/source/utils/m-tx/configure | 24 +- Build/source/utils/m-tx/configure.ac | 4 +- .../source/utils/m-tx/mtx-0.60d-PATCHES/ChangeLog | 17 - .../source/utils/m-tx/mtx-0.60d-PATCHES/TL-Changes | 12 - .../m-tx/mtx-0.60d-PATCHES/patch-01-write-bin | 27 - .../utils/m-tx/mtx-0.60d-PATCHES/patch-02-malloc | 24 - .../m-tx/mtx-0.60d-PATCHES/patch-03-different-size | 16 - Build/source/utils/m-tx/mtx-0.60d/AUTHORS | 1 - Build/source/utils/m-tx/mtx-0.60d/Bugs | 5 - Build/source/utils/m-tx/mtx-0.60d/COPYING | 340 ------ Build/source/utils/m-tx/mtx-0.60d/ChangeLog | 180 --- Build/source/utils/m-tx/mtx-0.60d/INSTALL | 365 ------ Build/source/utils/m-tx/mtx-0.60d/Makefile.am | 13 - Build/source/utils/m-tx/mtx-0.60d/Makefile.orig | 40 - Build/source/utils/m-tx/mtx-0.60d/NEWS | 5 - Build/source/utils/m-tx/mtx-0.60d/README | 164 --- Build/source/utils/m-tx/mtx-0.60d/README.060d | 8 - Build/source/utils/m-tx/mtx-0.60d/analyze.c | 333 ------ Build/source/utils/m-tx/mtx-0.60d/analyze.h | 33 - Build/source/utils/m-tx/mtx-0.60d/analyze.pas | 181 --- Build/source/utils/m-tx/mtx-0.60d/cfuncs.c | 91 -- Build/source/utils/m-tx/mtx-0.60d/cfuncs.h | 72 -- Build/source/utils/m-tx/mtx-0.60d/config.h | 90 -- Build/source/utils/m-tx/mtx-0.60d/config.h.in | 89 -- Build/source/utils/m-tx/mtx-0.60d/configure.ac | 33 - Build/source/utils/m-tx/mtx-0.60d/control.c | 274 ----- Build/source/utils/m-tx/mtx-0.60d/control.h | 52 - Build/source/utils/m-tx/mtx-0.60d/control.pas | 198 ---- Build/source/utils/m-tx/mtx-0.60d/files.c | 379 ------- Build/source/utils/m-tx/mtx-0.60d/files.h | 38 - Build/source/utils/m-tx/mtx-0.60d/files.pas | 196 ---- Build/source/utils/m-tx/mtx-0.60d/globals.c | 348 ------ Build/source/utils/m-tx/mtx-0.60d/globals.h | 154 --- Build/source/utils/m-tx/mtx-0.60d/globals.pas | 247 ---- Build/source/utils/m-tx/mtx-0.60d/libp2c/COPYING | 339 ------ Build/source/utils/m-tx/mtx-0.60d/libp2c/ChangeLog | 390 ------- .../source/utils/m-tx/mtx-0.60d/libp2c/Makefile.am | 2 - Build/source/utils/m-tx/mtx-0.60d/libp2c/README | 31 - Build/source/utils/m-tx/mtx-0.60d/libp2c/p2c.h | 533 --------- Build/source/utils/m-tx/mtx-0.60d/libp2c/p2clib.c | 1117 ------------------ Build/source/utils/m-tx/mtx-0.60d/lyrics.c | 869 -------------- Build/source/utils/m-tx/mtx-0.60d/lyrics.h | 37 - Build/source/utils/m-tx/mtx-0.60d/lyrics.pas | 455 -------- Build/source/utils/m-tx/mtx-0.60d/mtx.c | 505 --------- Build/source/utils/m-tx/mtx-0.60d/mtx.h | 30 - Build/source/utils/m-tx/mtx-0.60d/mtx.pas | 280 ----- Build/source/utils/m-tx/mtx-0.60d/mtxline.c | 844 -------------- Build/source/utils/m-tx/mtx-0.60d/mtxline.h | 83 -- Build/source/utils/m-tx/mtx-0.60d/mtxline.pas | 447 -------- Build/source/utils/m-tx/mtx-0.60d/multfile.c | 235 ---- Build/source/utils/m-tx/mtx-0.60d/multfile.h | 87 -- Build/source/utils/m-tx/mtx-0.60d/multfile.pas | 196 ---- Build/source/utils/m-tx/mtx-0.60d/notes.c | 547 --------- Build/source/utils/m-tx/mtx-0.60d/notes.h | 34 - Build/source/utils/m-tx/mtx-0.60d/notes.pas | 280 ----- Build/source/utils/m-tx/mtx-0.60d/preamble.c | 1134 ------------------- Build/source/utils/m-tx/mtx-0.60d/preamble.h | 42 - Build/source/utils/m-tx/mtx-0.60d/preamble.pas | 624 ---------- Build/source/utils/m-tx/mtx-0.60d/prepmx.c | 887 --------------- Build/source/utils/m-tx/mtx-0.60d/prepmx.pas | 444 -------- Build/source/utils/m-tx/mtx-0.60d/status.c | 649 ----------- Build/source/utils/m-tx/mtx-0.60d/status.h | 57 - Build/source/utils/m-tx/mtx-0.60d/status.pas | 348 ------ Build/source/utils/m-tx/mtx-0.60d/strings.h | 34 - Build/source/utils/m-tx/mtx-0.60d/uptext.c | 277 ----- Build/source/utils/m-tx/mtx-0.60d/uptext.h | 25 - Build/source/utils/m-tx/mtx-0.60d/uptext.pas | 119 -- Build/source/utils/m-tx/mtx-0.60d/utility.c | 393 ------- Build/source/utils/m-tx/mtx-0.60d/utility.h | 41 - Build/source/utils/m-tx/mtx-0.60d/utility.pas | 194 ---- Build/source/utils/m-tx/mtx-src-PATCHES/ChangeLog | 22 + Build/source/utils/m-tx/mtx-src-PATCHES/TL-Changes | 13 + .../utils/m-tx/mtx-src-PATCHES/patch-01-write-bin | 11 + .../utils/m-tx/mtx-src-PATCHES/patch-02-malloc | 11 + .../m-tx/mtx-src-PATCHES/patch-03-different-size | 15 + Build/source/utils/m-tx/mtx-src/AUTHORS | 1 + Build/source/utils/m-tx/mtx-src/Bugs | 9 + Build/source/utils/m-tx/mtx-src/COPYING | 340 ++++++ Build/source/utils/m-tx/mtx-src/ChangeLog | 187 +++ Build/source/utils/m-tx/mtx-src/ChangeLog.C | 4 + Build/source/utils/m-tx/mtx-src/Corrections | 208 ++++ Build/source/utils/m-tx/mtx-src/INSTALL | 365 ++++++ Build/source/utils/m-tx/mtx-src/Makefile.am | 78 ++ Build/source/utils/m-tx/mtx-src/Makefile.orig | 47 + Build/source/utils/m-tx/mtx-src/NEWS | 15 + Build/source/utils/m-tx/mtx-src/README | 35 + Build/source/utils/m-tx/mtx-src/analyze.c | 326 ++++++ Build/source/utils/m-tx/mtx-src/analyze.h | 33 + Build/source/utils/m-tx/mtx-src/analyze.pas | 184 +++ Build/source/utils/m-tx/mtx-src/cfuncs.c | 107 ++ Build/source/utils/m-tx/mtx-src/cfuncs.h | 73 ++ Build/source/utils/m-tx/mtx-src/configure.ac | 39 + Build/source/utils/m-tx/mtx-src/control.c | 269 +++++ Build/source/utils/m-tx/mtx-src/control.h | 52 + Build/source/utils/m-tx/mtx-src/control.pas | 198 ++++ Build/source/utils/m-tx/mtx-src/files.c | 390 +++++++ Build/source/utils/m-tx/mtx-src/files.h | 38 + Build/source/utils/m-tx/mtx-src/files.pas | 208 ++++ Build/source/utils/m-tx/mtx-src/globals.c | 329 ++++++ Build/source/utils/m-tx/mtx-src/globals.h | 153 +++ Build/source/utils/m-tx/mtx-src/globals.pas | 275 +++++ Build/source/utils/m-tx/mtx-src/libp2c/p2c.h | 533 +++++++++ Build/source/utils/m-tx/mtx-src/libp2c/p2clib.c | 1117 ++++++++++++++++++ Build/source/utils/m-tx/mtx-src/lyrics.c | 830 ++++++++++++++ Build/source/utils/m-tx/mtx-src/lyrics.h | 37 + Build/source/utils/m-tx/mtx-src/lyrics.pas | 456 ++++++++ Build/source/utils/m-tx/mtx-src/mtx.c | 481 ++++++++ Build/source/utils/m-tx/mtx-src/mtx.h | 30 + Build/source/utils/m-tx/mtx-src/mtx.pas | 282 +++++ Build/source/utils/m-tx/mtx-src/mtx.test | 16 + Build/source/utils/m-tx/mtx-src/mtxline.c | 851 ++++++++++++++ Build/source/utils/m-tx/mtx-src/mtxline.h | 83 ++ Build/source/utils/m-tx/mtx-src/mtxline.pas | 457 ++++++++ Build/source/utils/m-tx/mtx-src/multfile.c | 235 ++++ Build/source/utils/m-tx/mtx-src/multfile.h | 87 ++ Build/source/utils/m-tx/mtx-src/multfile.pas | 196 ++++ Build/source/utils/m-tx/mtx-src/notes.c | 511 +++++++++ Build/source/utils/m-tx/mtx-src/notes.h | 36 + Build/source/utils/m-tx/mtx-src/notes.pas | 281 +++++ Build/source/utils/m-tx/mtx-src/preamble.c | 1195 ++++++++++++++++++++ Build/source/utils/m-tx/mtx-src/preamble.h | 42 + Build/source/utils/m-tx/mtx-src/preamble.pas | 688 +++++++++++ Build/source/utils/m-tx/mtx-src/prepmx.c | 861 ++++++++++++++ Build/source/utils/m-tx/mtx-src/prepmx.pas | 449 ++++++++ Build/source/utils/m-tx/mtx-src/status.c | 664 +++++++++++ Build/source/utils/m-tx/mtx-src/status.h | 59 + Build/source/utils/m-tx/mtx-src/status.pas | 396 +++++++ Build/source/utils/m-tx/mtx-src/strings.h | 36 + Build/source/utils/m-tx/mtx-src/strings.pas | 109 ++ Build/source/utils/m-tx/mtx-src/uptext.c | 270 +++++ Build/source/utils/m-tx/mtx-src/uptext.h | 25 + Build/source/utils/m-tx/mtx-src/uptext.pas | 119 ++ Build/source/utils/m-tx/mtx-src/utility.c | 364 ++++++ Build/source/utils/m-tx/mtx-src/utility.h | 41 + Build/source/utils/m-tx/mtx-src/utility.pas | 194 ++++ Build/source/utils/m-tx/mtx-src/version.ac | 11 + Build/source/utils/m-tx/prepmx.1 | 55 +- Build/source/utils/m-tx/version.ac | 2 +- 139 files changed, 16126 insertions(+), 16674 deletions(-) delete mode 100644 Build/source/utils/m-tx/mtx-0.60d-PATCHES/ChangeLog delete mode 100644 Build/source/utils/m-tx/mtx-0.60d-PATCHES/TL-Changes delete mode 100644 Build/source/utils/m-tx/mtx-0.60d-PATCHES/patch-01-write-bin delete mode 100644 Build/source/utils/m-tx/mtx-0.60d-PATCHES/patch-02-malloc delete mode 100644 Build/source/utils/m-tx/mtx-0.60d-PATCHES/patch-03-different-size delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/AUTHORS delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/Bugs delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/COPYING delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/ChangeLog delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/INSTALL delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/Makefile.am delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/Makefile.orig delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/NEWS delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/README delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/README.060d delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/analyze.c delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/analyze.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/analyze.pas delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/cfuncs.c delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/cfuncs.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/config.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/config.h.in delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/configure.ac delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/control.c delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/control.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/control.pas delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/files.c delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/files.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/files.pas delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/globals.c delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/globals.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/globals.pas delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/libp2c/COPYING delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/libp2c/ChangeLog delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/libp2c/Makefile.am delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/libp2c/README delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/libp2c/p2c.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/libp2c/p2clib.c delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/lyrics.c delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/lyrics.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/lyrics.pas delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/mtx.c delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/mtx.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/mtx.pas delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/mtxline.c delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/mtxline.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/mtxline.pas delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/multfile.c delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/multfile.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/multfile.pas delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/notes.c delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/notes.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/notes.pas delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/preamble.c delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/preamble.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/preamble.pas delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/prepmx.c delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/prepmx.pas delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/status.c delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/status.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/status.pas delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/strings.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/uptext.c delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/uptext.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/uptext.pas delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/utility.c delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/utility.h delete mode 100644 Build/source/utils/m-tx/mtx-0.60d/utility.pas create mode 100644 Build/source/utils/m-tx/mtx-src-PATCHES/ChangeLog create mode 100644 Build/source/utils/m-tx/mtx-src-PATCHES/TL-Changes create mode 100644 Build/source/utils/m-tx/mtx-src-PATCHES/patch-01-write-bin create mode 100644 Build/source/utils/m-tx/mtx-src-PATCHES/patch-02-malloc create mode 100644 Build/source/utils/m-tx/mtx-src-PATCHES/patch-03-different-size create mode 100644 Build/source/utils/m-tx/mtx-src/AUTHORS create mode 100644 Build/source/utils/m-tx/mtx-src/Bugs create mode 100644 Build/source/utils/m-tx/mtx-src/COPYING create mode 100644 Build/source/utils/m-tx/mtx-src/ChangeLog create mode 100644 Build/source/utils/m-tx/mtx-src/ChangeLog.C create mode 100644 Build/source/utils/m-tx/mtx-src/Corrections create mode 100644 Build/source/utils/m-tx/mtx-src/INSTALL create mode 100644 Build/source/utils/m-tx/mtx-src/Makefile.am create mode 100644 Build/source/utils/m-tx/mtx-src/Makefile.orig create mode 100644 Build/source/utils/m-tx/mtx-src/NEWS create mode 100644 Build/source/utils/m-tx/mtx-src/README create mode 100644 Build/source/utils/m-tx/mtx-src/analyze.c create mode 100644 Build/source/utils/m-tx/mtx-src/analyze.h create mode 100644 Build/source/utils/m-tx/mtx-src/analyze.pas create mode 100644 Build/source/utils/m-tx/mtx-src/cfuncs.c create mode 100644 Build/source/utils/m-tx/mtx-src/cfuncs.h create mode 100644 Build/source/utils/m-tx/mtx-src/configure.ac create mode 100644 Build/source/utils/m-tx/mtx-src/control.c create mode 100644 Build/source/utils/m-tx/mtx-src/control.h create mode 100644 Build/source/utils/m-tx/mtx-src/control.pas create mode 100644 Build/source/utils/m-tx/mtx-src/files.c create mode 100644 Build/source/utils/m-tx/mtx-src/files.h create mode 100644 Build/source/utils/m-tx/mtx-src/files.pas create mode 100644 Build/source/utils/m-tx/mtx-src/globals.c create mode 100644 Build/source/utils/m-tx/mtx-src/globals.h create mode 100644 Build/source/utils/m-tx/mtx-src/globals.pas create mode 100644 Build/source/utils/m-tx/mtx-src/libp2c/p2c.h create mode 100644 Build/source/utils/m-tx/mtx-src/libp2c/p2clib.c create mode 100644 Build/source/utils/m-tx/mtx-src/lyrics.c create mode 100644 Build/source/utils/m-tx/mtx-src/lyrics.h create mode 100644 Build/source/utils/m-tx/mtx-src/lyrics.pas create mode 100644 Build/source/utils/m-tx/mtx-src/mtx.c create mode 100644 Build/source/utils/m-tx/mtx-src/mtx.h create mode 100644 Build/source/utils/m-tx/mtx-src/mtx.pas create mode 100644 Build/source/utils/m-tx/mtx-src/mtx.test create mode 100644 Build/source/utils/m-tx/mtx-src/mtxline.c create mode 100644 Build/source/utils/m-tx/mtx-src/mtxline.h create mode 100644 Build/source/utils/m-tx/mtx-src/mtxline.pas create mode 100644 Build/source/utils/m-tx/mtx-src/multfile.c create mode 100644 Build/source/utils/m-tx/mtx-src/multfile.h create mode 100644 Build/source/utils/m-tx/mtx-src/multfile.pas create mode 100644 Build/source/utils/m-tx/mtx-src/notes.c create mode 100644 Build/source/utils/m-tx/mtx-src/notes.h create mode 100644 Build/source/utils/m-tx/mtx-src/notes.pas create mode 100644 Build/source/utils/m-tx/mtx-src/preamble.c create mode 100644 Build/source/utils/m-tx/mtx-src/preamble.h create mode 100644 Build/source/utils/m-tx/mtx-src/preamble.pas create mode 100644 Build/source/utils/m-tx/mtx-src/prepmx.c create mode 100644 Build/source/utils/m-tx/mtx-src/prepmx.pas create mode 100644 Build/source/utils/m-tx/mtx-src/status.c create mode 100644 Build/source/utils/m-tx/mtx-src/status.h create mode 100644 Build/source/utils/m-tx/mtx-src/status.pas create mode 100644 Build/source/utils/m-tx/mtx-src/strings.h create mode 100644 Build/source/utils/m-tx/mtx-src/strings.pas create mode 100644 Build/source/utils/m-tx/mtx-src/uptext.c create mode 100644 Build/source/utils/m-tx/mtx-src/uptext.h create mode 100644 Build/source/utils/m-tx/mtx-src/uptext.pas create mode 100644 Build/source/utils/m-tx/mtx-src/utility.c create mode 100644 Build/source/utils/m-tx/mtx-src/utility.h create mode 100644 Build/source/utils/m-tx/mtx-src/utility.pas create mode 100644 Build/source/utils/m-tx/mtx-src/version.ac (limited to 'Build/source/utils') diff --git a/Build/source/utils/m-tx/ChangeLog b/Build/source/utils/m-tx/ChangeLog index 57ea63fe0f8..1f72e004d07 100644 --- a/Build/source/utils/m-tx/ChangeLog +++ b/Build/source/utils/m-tx/ChangeLog @@ -1,3 +1,7 @@ +2015-12-17 Akira Kakuto + + * Import m-tx 0.61. + 2015-07-07 Peter Breitenlohner * Makefile.am: Better dependencies for 'make check'. diff --git a/Build/source/utils/m-tx/configure b/Build/source/utils/m-tx/configure index 9e432ea2fff..b3a5ce9df9d 100755 --- a/Build/source/utils/m-tx/configure +++ b/Build/source/utils/m-tx/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for m-tx (TeX Live) 0.60d. +# Generated by GNU Autoconf 2.69 for m-tx (TeX Live) 0.61. # # Report bugs to . # @@ -580,12 +580,12 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='m-tx (TeX Live)' PACKAGE_TARNAME='m-tx--tex-live-' -PACKAGE_VERSION='0.60d' -PACKAGE_STRING='m-tx (TeX Live) 0.60d' +PACKAGE_VERSION='0.61' +PACKAGE_STRING='m-tx (TeX Live) 0.61' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' -ac_unique_file="mtx-0.60d/analyze.c" +ac_unique_file="mtx-src/analyze.c" # Factoring default headers for most tests. ac_includes_default="\ #include @@ -1275,7 +1275,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures m-tx (TeX Live) 0.60d to adapt to many kinds of systems. +\`configure' configures m-tx (TeX Live) 0.61 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1341,7 +1341,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of m-tx (TeX Live) 0.60d:";; + short | recursive ) echo "Configuration of m-tx (TeX Live) 0.61:";; esac cat <<\_ACEOF @@ -1438,7 +1438,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -m-tx (TeX Live) configure 0.60d +m-tx (TeX Live) configure 0.61 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1861,7 +1861,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by m-tx (TeX Live) $as_me 0.60d, which was +It was created by m-tx (TeX Live) $as_me 0.61, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3784,7 +3784,7 @@ fi # Define the identity of the package. PACKAGE='m-tx--tex-live-' - VERSION='0.60d' + VERSION='0.61' cat >>confdefs.h <<_ACEOF @@ -5289,7 +5289,7 @@ fi done -MTX_TREE=mtx-0.60d +MTX_TREE=mtx-src ac_config_files="$ac_config_files Makefile" @@ -5868,7 +5868,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by m-tx (TeX Live) $as_me 0.60d, which was +This file was extended by m-tx (TeX Live) $as_me 0.61, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5925,7 +5925,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -m-tx (TeX Live) config.status 0.60d +m-tx (TeX Live) config.status 0.61 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/Build/source/utils/m-tx/configure.ac b/Build/source/utils/m-tx/configure.ac index bc2257495e4..8936d60eb10 100644 --- a/Build/source/utils/m-tx/configure.ac +++ b/Build/source/utils/m-tx/configure.ac @@ -9,7 +9,7 @@ dnl m4_include([version.ac])[] dnl define mtx_version AC_INIT([m-tx (TeX Live)], mtx_version, [tex-k@tug.org]) AC_PREREQ([2.65]) -AC_CONFIG_SRCDIR([mtx-]mtx_version[/analyze.c]) +AC_CONFIG_SRCDIR([mtx-src/analyze.c]) AC_CONFIG_AUX_DIR([../../build-aux]) AC_CONFIG_MACRO_DIR([../../m4]) @@ -35,7 +35,7 @@ AC_TYPE_SIZE_T # Checks for library functions. AC_CHECK_FUNCS([memchr memmove memset strchr strrchr strtol]) -AC_SUBST([MTX_TREE], [mtx-]mtx_version) +AC_SUBST([MTX_TREE], [mtx-src]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/Build/source/utils/m-tx/mtx-0.60d-PATCHES/ChangeLog b/Build/source/utils/m-tx/mtx-0.60d-PATCHES/ChangeLog deleted file mode 100644 index 8ca2124cef6..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d-PATCHES/ChangeLog +++ /dev/null @@ -1,17 +0,0 @@ -2013-04-10 Peter Breitenlohner - - * patch-03-different-size: Avoid 'cast to pointer from integer of - different size' when sizeof(int) is less than sizeof(void *). - -2012-10-04 Peter Breitenlohner - - * patch-02-malloc (new): Check value returned by malloc(), i.e., - undo action of sed from Makefile.orig. Do not use libp2c.a. - -2012-05-16 Peter Breitenlohner - - * patch-01-write-bin (new): Use binary mode for output files. - From Akira Kakuto (W32TeX). - -Copyright (C) 2012 Peter Breitenlohner -You may freely use, modify and/or distribute this file. diff --git a/Build/source/utils/m-tx/mtx-0.60d-PATCHES/TL-Changes b/Build/source/utils/m-tx/mtx-0.60d-PATCHES/TL-Changes deleted file mode 100644 index a24ef1965c0..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d-PATCHES/TL-Changes +++ /dev/null @@ -1,12 +0,0 @@ -Changes applied to the mtx-0.60d tree as obtained from: - http://www.ctan.org/tex-archive/support/m-tx/ - -Remove: - Makefile.in - aclocal.m4 - configure - depcomp - install-sh - missing - libp2c/Makefile.in - diff --git a/Build/source/utils/m-tx/mtx-0.60d-PATCHES/patch-01-write-bin b/Build/source/utils/m-tx/mtx-0.60d-PATCHES/patch-01-write-bin deleted file mode 100644 index a513d56fc3c..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d-PATCHES/patch-01-write-bin +++ /dev/null @@ -1,27 +0,0 @@ -diff -ur mtx-0.60d.orig/files.c mtx-0.60d/files.c ---- mtx-0.60d.orig/files.c 2012-04-05 14:46:38.000000000 +0200 -+++ mtx-0.60d/files.c 2012-06-16 17:39:37.000000000 +0200 -@@ -275,9 +275,9 @@ - pushFile(infilename); - strcpy(outfile_NAME, outfilename); - if (outfile != NULL) -- outfile = freopen(outfile_NAME, "w", outfile); -+ outfile = freopen(outfile_NAME, "wb", outfile); - else -- outfile = fopen(outfile_NAME, "w"); -+ outfile = fopen(outfile_NAME, "wb"); - _SETIO(outfile != NULL, FileNotFound); - strcpy(stylefile_NAME, stylefilename); - if (stylefile != NULL) -diff -ur mtx-0.60d.orig/globals.c mtx-0.60d/globals.c ---- mtx-0.60d.orig/globals.c 2012-04-05 14:41:42.000000000 +0200 -+++ mtx-0.60d/globals.c 2012-06-16 17:39:40.000000000 +0200 -@@ -237,7 +237,7 @@ - if (outfile != NULL) - fclose(outfile); - outfile = NULL; -- outfile = fopen(outfile_NAME, "w"); -+ outfile = fopen(outfile_NAME, "wb"); - if (outfile == NULL) - _EscIO2(FileNotFound, outfile_NAME); - fclose(outfile); diff --git a/Build/source/utils/m-tx/mtx-0.60d-PATCHES/patch-02-malloc b/Build/source/utils/m-tx/mtx-0.60d-PATCHES/patch-02-malloc deleted file mode 100644 index 071cdd5f833..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d-PATCHES/patch-02-malloc +++ /dev/null @@ -1,24 +0,0 @@ -diff -ur mtx-0.60d.orig/cfuncs.c mtx-0.60d/cfuncs.c ---- mtx-0.60d.orig/cfuncs.c 2012-04-05 13:05:08.000000000 +0200 -+++ mtx-0.60d/cfuncs.c 2012-10-04 13:27:57.000000000 +0200 -@@ -18,6 +18,8 @@ - if (x==EOF) return 1; - ungetc(x,infile); return 0; - } -+void *__MallocTemp__; -+int _OutMem(void) { fprintf(stderr,"Out of memory\n"); exit(-2); return -2; } - void PASCAL_MAIN (int npars, char ** pars) - { P_argc = npars; P_argv = pars; } - -diff -ur mtx-0.60d.orig/multfile.c mtx-0.60d/multfile.c ---- mtx-0.60d.orig/multfile.c 2012-04-05 14:47:20.000000000 +0200 -+++ mtx-0.60d/multfile.c 2012-10-04 11:56:59.000000000 +0200 -@@ -60,7 +60,7 @@ - printf("===! Ignoring recursive include of file %s\n", filename); - return; - } -- newnode = malloc(sizeof(filenode)); -+ newnode = Malloc(sizeof(filenode)); - newnode->actualfile = NULL; - strcpy(newnode->name, filename); - newnode->prev = current; diff --git a/Build/source/utils/m-tx/mtx-0.60d-PATCHES/patch-03-different-size b/Build/source/utils/m-tx/mtx-0.60d-PATCHES/patch-03-different-size deleted file mode 100644 index 050f564dc87..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d-PATCHES/patch-03-different-size +++ /dev/null @@ -1,16 +0,0 @@ -diff -ur mtx-0.60d.orig/libp2c/p2c.h mtx-0.60d/libp2c/p2c.h ---- mtx-0.60d.orig/libp2c/p2c.h 1999-03-16 16:28:20.000000000 +0100 -+++ mtx-0.60d/libp2c/p2c.h 2013-04-10 17:40:36.000000000 +0200 -@@ -428,10 +428,10 @@ - - /* Memory allocation */ - #ifdef __GCC__ --# define Malloc(n) (malloc(n) ?: (Anyptr)_OutMem()) -+# define Malloc(n) (malloc(n) ?: (Anyptr)(size_t)_OutMem()) - #else - extern Anyptr __MallocTemp__; --# define Malloc(n) ((__MallocTemp__ = malloc(n)) ? __MallocTemp__ : (Anyptr)_OutMem()) -+# define Malloc(n) ((__MallocTemp__ = malloc(n)) ? __MallocTemp__ : (Anyptr)(size_t)_OutMem()) - #endif - #define FreeR(p) (free((Anyptr)(p))) /* used if arg is an rvalue */ - #define Free(p) (free((Anyptr)(p)), (p)=NULL) diff --git a/Build/source/utils/m-tx/mtx-0.60d/AUTHORS b/Build/source/utils/m-tx/mtx-0.60d/AUTHORS deleted file mode 100644 index 9fdff1fe9d3..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Dirk Laurie (dpl@sun.ac.za) diff --git a/Build/source/utils/m-tx/mtx-0.60d/Bugs b/Build/source/utils/m-tx/mtx-0.60d/Bugs deleted file mode 100644 index 1703eee92a2..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/Bugs +++ /dev/null @@ -1,5 +0,0 @@ -Lyrics lines when not from same paragraph don't join neatly. -Problem has been discussed on mailing list and Rainer gave -a solution. - -Rest in dot and comma shortcuts gives error at PMX stage. diff --git a/Build/source/utils/m-tx/mtx-0.60d/COPYING b/Build/source/utils/m-tx/mtx-0.60d/COPYING deleted file mode 100644 index 623b6258a13..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/Build/source/utils/m-tx/mtx-0.60d/ChangeLog b/Build/source/utils/m-tx/mtx-0.60d/ChangeLog deleted file mode 100644 index c6191aa7874..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/ChangeLog +++ /dev/null @@ -1,180 +0,0 @@ - Corrections and enhancements to M-Tx starting from 0.53 - Newest items at top - -Version 0.60d - Replaced space character tie label by no label, - status.pas: procedure labelSlur, call procedure insertchar only for slurs. - -Version 0.60c - Added facility for prefixing music words with '_' for handling in PMX. - Prefix is stripped in output file. - mtxline.pas: type music_word, const bind_left, array name, - procedure GetNextMusWord. - -Version 0.60b - Fixed bug in doPMXpreamble causing errors with printed meters. - -Version 0.60a - Fix for music size 13 in preamble.pas. - Convert M-Tx denominators '1', '16', '32' and '64' - to PMX meter denominator syntax '0', '1', '3' and '6'. - {} ties don't get PMX label T attached in order to support MIDI ties. - -Planned for the near future - Accepts detached shortcut. - -Version 0.55h (not released) - Traces pitch including z-words; warns if unreal. Disable checkPitch - to bypass this. - -Version 0.55g (not released) - Corrects another bug in notes.pas, introduced at 0.55d. - Features: countMacro, expandMacro. - -Version 0.55f (not released) - Corrects bugs, mainly in notes.pas, introduced at 0.55d. - Help via command line. - -Version 0.55e (not released) - Chord ties. E.g. C: {ce cf ties the c. No close-tie symbol. - -Version 0.55d (not released) - Mainly code cleanup. Should be transparent to most users. - -Version 0.55c - Corrects continuation slur bug. - -Version 0.55b - Bug correction, but including a substantial rewrite of the lyrics melisma handling. - -Version 0.55 - Basically the same as 0.54k. - -Version 0.54k (not released) - DPL: Slurs are no longer translated to s and t, but to ( and {. This requires - PMX 2.502. Labels are inserted into slurs. - -Version 0.54j (not released) - DPL: "Enable" and "Disable" directives for more flexible handling of optional - features. No further development of "Options:" will be made. - -Version 0.54h (not released) - Certain parts of the unwieldy "globals" unit moved to a new "utility" unit. - Affects programming, not functionality. - -Version 0.54g (released only to beta testers) - DPL: Corrected bug in multfile.pas (end-of-input not properly recognized). - -Version 0.54f (released only to beta testers) - DPL: Cleaning up of files.pas to take full advantage of the new - multifile.pas unit. Corrected some obscure bugs. - -Version 0.54e (not released) - -2004-03-07 - DPL: Added the "Include: filename" directive. This may appear anywhere, - and diverts the input stream to the new filename. This may in turn - include other files, etc. A file may be included more than once, but - do not try recursive includes! When the end of an included file is - reached, the stream reverts to the previous file. End-of-file is - treated seamlessly and does not act as a paragraph separator. - -Version 0.54d (not released) - -2004-02-15 - DPL: {...} gives st slurs, }{ works, -t option to retain old behaviour, - some cleaning up of unused pieces of code. - Affects files.pas, globals.pas, mtxline.pas, preamble.pas, prepmx.pas, - status.pas - -Version 0.54c - -2003-08-14 - Hiroaki Morimoto: - mtx.pas: allow PMX style absolute octave assignment - -Version 0.54b - -2003-08-05 - Christian Mondrup: - mtx.tex: changed \def\mtxLyrlink{\lowlyrlink} to \def\mtxLowLyrlink{\lowlyrlink} - -2003-06-03 - Christian Mondrup: - Correct bug in procedure respace: test on 'nspace[ninstr]' rather than on - nspace[nstaves] in concluding if statement. - -Version 0.54a - -2002-01-29 - Recognizes PMX words D s t as binding to the left. - Uptext also on multi-bar rests. - -Version 0.53j - -2001-12-06 - mtx.tex tuning improvements only - -Version 0.53i - -2001-11-27 - Correct bug in verse numbers when bar starts with rests - (reported by Christian Mondrup) - -Version 0.53h - -2001-11-20 - Correct bug in decrescendo (reported by Christian Mondrup) - -- involves mtx.tex and uptext.* - 100 lines per paragraph - -Version 0.53g - -2001-10-30 - Restore midi accidental capability (lost by mistake from 0.53c to - 0.53f) - -Version 0.53f - -2001-08-29 - xtuplet may start with rest - -Version 0.53e - -2001-06-22 - Recognizes 'D' in xtuplet notes. - -Version 0.53d - -2001-06-21 - Always uses full instrument/stave format, even if there is just - one stave per instrument. - -Version 0.53c - -2001-06-18 - Improved handling of Composer, Poet and Title lines. - procedure selectVoices added (maybe one day we'll support - movement changes) - Braces around \mtxFlat and \mtxSharp - Does not translate '_' in lyrics if - (1) at end of word - (2) followed by another '_' - (3) followed by a digit - -Version 0.53b - -2001-06-02 - Improvements to mtx.tex, including nicer sharps and flats in uptext - -Version 0.53a - -2001-05-29 - Looks for 'i' anywhere in note (except in shortcut and xtuplet parts) - and moves it to follow accidental. - -2001-05-28 - From Christian Mondrup - preamble.pas: added trailing backslash to \mtxTenorClef - mtx.tex: changed \mtxmtxNormalSize to \mtxNormalSize - diff --git a/Build/source/utils/m-tx/mtx-0.60d/INSTALL b/Build/source/utils/m-tx/mtx-0.60d/INSTALL deleted file mode 100644 index 7d1c323beae..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/INSTALL +++ /dev/null @@ -1,365 +0,0 @@ -Installation Instructions -************************* - -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, -2006, 2007, 2008, 2009 Free Software Foundation, Inc. - - Copying and distribution of this file, with or without modification, -are permitted in any medium without royalty provided the copyright -notice and this notice are preserved. This file is offered as-is, -without warranty of any kind. - -Basic Installation -================== - - Briefly, the shell commands `./configure; make; make install' should -configure, build, and install this package. The following -more-detailed instructions are generic; see the `README' file for -instructions specific to this package. Some packages provide this -`INSTALL' file but do not implement all of the features documented -below. The lack of an optional feature in a given package is not -necessarily a bug. More recommendations for GNU packages can be found -in *note Makefile Conventions: (standards)Makefile Conventions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. Caching is -disabled by default to prevent problems with accidental use of stale -cache files. - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You need `configure.ac' if -you want to change it or regenerate `configure' using a newer version -of `autoconf'. - - The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. - - Running `configure' might take a while. While running, it prints - some messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package, generally using the just-built uninstalled binaries. - - 4. Type `make install' to install the programs and any data files and - documentation. When installing into a prefix owned by root, it is - recommended that the package be configured and built as a regular - user, and only the `make install' phase executed with root - privileges. - - 5. Optionally, type `make installcheck' to repeat any self-tests, but - this time using the binaries in their final installed location. - This target does not install anything. Running this target as a - regular user, particularly if the prior `make install' required - root privileges, verifies that the installation completed - correctly. - - 6. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - - 7. Often, you can also type `make uninstall' to remove the installed - files again. In practice, not all packages have tested that - uninstallation works correctly, even though it is required by the - GNU Coding Standards. - - 8. Some packages, particularly those that use Automake, provide `make - distcheck', which can by used by developers to test that all other - targets like `make install' and `make uninstall' work correctly. - This target is generally not run by end users. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. Run `./configure --help' -for details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c99 CFLAGS=-g LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you can use GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. This -is known as a "VPATH" build. - - With a non-GNU `make', it is safer to compile the package for one -architecture at a time in the source code directory. After you have -installed the package for one architecture, use `make distclean' before -reconfiguring for another architecture. - - On MacOS X 10.5 and later systems, you can create libraries and -executables that work on multiple system types--known as "fat" or -"universal" binaries--by specifying multiple `-arch' options to the -compiler but only a single `-arch' option to the preprocessor. Like -this: - - ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ - CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ - CPP="gcc -E" CXXCPP="g++ -E" - - This is not guaranteed to produce working output in all cases, you -may have to build one architecture at a time and combine the results -using the `lipo' tool if you have problems. - -Installation Names -================== - - By default, `make install' installs the package's commands under -`/usr/local/bin', include files under `/usr/local/include', etc. You -can specify an installation prefix other than `/usr/local' by giving -`configure' the option `--prefix=PREFIX', where PREFIX must be an -absolute file name. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -pass the option `--exec-prefix=PREFIX' to `configure', the package uses -PREFIX as the prefix for installing programs and libraries. -Documentation and other data files still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. In general, the -default for these options is expressed in terms of `${prefix}', so that -specifying just `--prefix' will affect all of the other directory -specifications that were not explicitly provided. - - The most portable way to affect installation locations is to pass the -correct locations to `configure'; however, many packages provide one or -both of the following shortcuts of passing variable assignments to the -`make install' command line to change installation locations without -having to reconfigure or recompile. - - The first method involves providing an override variable for each -affected directory. For example, `make install -prefix=/alternate/directory' will choose an alternate location for all -directory configuration variables that were expressed in terms of -`${prefix}'. Any directories that were specified during `configure', -but not in terms of `${prefix}', must each be overridden at install -time for the entire installation to be relocated. The approach of -makefile variable overrides for each directory variable is required by -the GNU Coding Standards, and ideally causes no recompilation. -However, some platforms have known limitations with the semantics of -shared libraries that end up requiring recompilation when using this -method, particularly noticeable in packages that use GNU Libtool. - - The second method involves providing the `DESTDIR' variable. For -example, `make install DESTDIR=/alternate/directory' will prepend -`/alternate/directory' before all installation names. The approach of -`DESTDIR' overrides is not required by the GNU Coding Standards, and -does not work on platforms that have drive letters. On the other hand, -it does better at avoiding recompilation issues, and works well even -when some directory options were not specified in terms of `${prefix}' -at `configure' time. - -Optional Features -================= - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - - Some packages offer the ability to configure how verbose the -execution of `make' will be. For these packages, running `./configure ---enable-silent-rules' sets the default to minimal output, which can be -overridden with `make V=1'; while running `./configure ---disable-silent-rules' sets the default to verbose, which can be -overridden with `make V=0'. - -Particular systems -================== - - On HP-UX, the default C compiler is not ANSI C compatible. If GNU -CC is not installed, it is recommended to use the following options in -order to use an ANSI C compiler: - - ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" - -and if that doesn't work, install pre-built binaries of GCC for HP-UX. - - On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot -parse its `' header file. The option `-nodtk' can be used as -a workaround. If GNU CC is not installed, it is therefore recommended -to try - - ./configure CC="cc" - -and if that doesn't work, try - - ./configure CC="cc -nodtk" - - On Solaris, don't put `/usr/ucb' early in your `PATH'. This -directory contains several dysfunctional programs; working variants of -these programs are available in `/usr/bin'. So, if you need `/usr/ucb' -in your `PATH', put it _after_ `/usr/bin'. - - On Haiku, software installed for all users goes in `/boot/common', -not `/usr/local'. It is recommended to use the following options: - - ./configure --prefix=/boot/common - -Specifying the System Type -========================== - - There may be some features `configure' cannot figure out -automatically, but needs to determine by the type of machine the package -will run on. Usually, assuming the package is built to be run on the -_same_ architectures, `configure' can figure that out, but if it prints -a message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS - KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the option `--target=TYPE' to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - - Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -causes the specified `gcc' to be used as the C compiler (unless it is -overridden in the site shell script). - -Unfortunately, this technique does not work for `CONFIG_SHELL' due to -an Autoconf bug. Until the bug is fixed you can use this workaround: - - CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash - -`configure' Invocation -====================== - - `configure' recognizes the following options to control how it -operates. - -`--help' -`-h' - Print a summary of all of the options to `configure', and exit. - -`--help=short' -`--help=recursive' - Print a summary of the options unique to this package's - `configure', and exit. The `short' variant lists options used - only in the top level, while the `recursive' variant lists options - also present in any nested packages. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--prefix=DIR' - Use DIR as the installation prefix. *note Installation Names:: - for more details, including other options available for fine-tuning - the installation locations. - -`--no-create' -`-n' - Run the configure checks, but stop before creating any output - files. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. - diff --git a/Build/source/utils/m-tx/mtx-0.60d/Makefile.am b/Build/source/utils/m-tx/mtx-0.60d/Makefile.am deleted file mode 100644 index 1fc037408fa..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -SUBDIRS = libp2c -DIST_SUBDIRS = libp2c -bin_PROGRAMS = prepmx -INCLUDES = -I$(srcdir)/libp2c -prepmx_SOURCES = analyze.h cfuncs.h config.h control.h files.h globals.h lyrics.h\ - mtx.h mtxline.h multfile.h notes.h preamble.h status.h strings.h uptext.h utility.h\ - globals.c mtx.c preamble.c lyrics.c analyze.c mtxline.c\ - status.c uptext.c files.c notes.c prepmx.c cfuncs.c multfile.c utility.c control.c -prepmx_LDADD = libp2c/libp2c.a -EXTRA_DIST = globals.pas mtx.pas preamble.pas lyrics.pas analyze.pas mtxline.pas\ - status.pas uptext.pas prepmx.pas files.pas notes.pas multfile.pas utility.pas control.pas\ - Makefile.orig Bugs README.060d - diff --git a/Build/source/utils/m-tx/mtx-0.60d/Makefile.orig b/Build/source/utils/m-tx/mtx-0.60d/Makefile.orig deleted file mode 100644 index 60cf037cbba..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/Makefile.orig +++ /dev/null @@ -1,40 +0,0 @@ -pasfiles = globals.pas mtx.pas preamble.pas lyrics.pas analyze.pas mtxline.pas\ - status.pas uptext.pas prepmx.pas files.pas notes.pas multfile.pas \ - strings.pas utility.pas control.pas -cfiles = globals.c mtx.c preamble.c lyrics.c analyze.c mtxline.c\ - status.c uptext.c prepmx.c files.c notes.c multfile.c utility.c control.c -native = cfuncs.c cfuncs.h -hfiles = globals.h mtx.h preamble.h lyrics.h analyze.h mtxline.h \ - status.h uptext.h files.h notes.h multfile.h utility.h control.h -ofiles = globals.o mtx.o preamble.o lyrics.o analyze.o mtxline.o \ - status.o uptext.o files.o notes.o prepmx.o cfuncs.o multfile.o utility.o \ - control.o - -prepmx: $(pasfiles) - fpc -g -B -vnh -So prepmx - -prepmxc: $(cfiles) $(ofiles) - cc $(ofiles) -o prepmx - -multfile.c: multfile.pas - p2c -a -LTurbo multfile.pas -o temp.c - sed -e "s/Malloc/malloc/" < temp.c > multfile.c - rm temp.c - -%.c: %.pas - p2c -a -LTurbo $*.pas - -clean: - - rm *.o *~ *~ core *.pmx *.pml *.log *.dvi - -bare: clean - - rm $(cfiles) $(hfiles) prepmx *.ppu - -Pzip: - zip -ju mtxP`./version` version $(pasfiles) pmxword.pas mtx.tex $(native) \ - Makefile Corrections Bugs README - -Czip: $(cfiles) - zip -ju mtxC`./version` version $(cfiles) $(native) $(hfiles) mtx.tex Makefile \ - Bugs Corrections README - diff --git a/Build/source/utils/m-tx/mtx-0.60d/NEWS b/Build/source/utils/m-tx/mtx-0.60d/NEWS deleted file mode 100644 index 1703eee92a2..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/NEWS +++ /dev/null @@ -1,5 +0,0 @@ -Lyrics lines when not from same paragraph don't join neatly. -Problem has been discussed on mailing list and Rainer gave -a solution. - -Rest in dot and comma shortcuts gives error at PMX stage. diff --git a/Build/source/utils/m-tx/mtx-0.60d/README b/Build/source/utils/m-tx/mtx-0.60d/README deleted file mode 100644 index 55e006035bf..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/README +++ /dev/null @@ -1,164 +0,0 @@ - M-Tx Preprocessor Source Code - - -This is a development version of "prepmx", the M-Tx Preprocessor. -It contains the file "mtx.tex" and all the sources for generating the -binary executable file ("prepmx", "prepmx.exe", etc., depending on your -operating system). There is no documentation: find the latest available -mtxD????.zip and read the Corrections file. There are no examples: find -the latest available mtxX????.zip. Or stay with the most recent stable -release for those. - -The development version is provided for those who need more recent features -than the most recent stable release has, in the hope that they will be -willing to report bugs and maybe even suggest how those can be fixed. -Send e-mail to Dirk Laurie . - -You will have found this README in a file called something like mtxP054f.zip -(which containes Pascal code) or mtxC054f.zip (which contains C code). -I will refer to that file as mtxP????.zip or mtxC????.zip. - -You need one of the following compilers. A later version than specified -should also work, but an earlier one probably will not. - 1. Free Pascal 1.0.10 (for mtxP????.zip) - 2. Borland Pascal 7.0 (for mtxP????.zip) - 3. Any ANSI-compliant C compiler (for mtxC????.zip) - 4. The p2c package plus any ANSI-compliant C compiler (for mtxP????.zip) -The first of these is recommended, since that is the compiler I use. -I try to stay compatible with the other three, but this may not always -be possible. - -"GNU System" means any system on which standard GNU utilities such as "bash" -and "make" is available. Typical GNU systems are (a) Linux (b) Windows with -the Cygwin package installed (c) other systems on which an appropriate -package has been installed. You do not need a GNU system to use M-Tx, -but it is easier to make the executable on a GNU system. - -Read Section 1 below, and, depending on which compiler you have, -one of the other sections. If you have no appropriate compiler, -visit http://www.freepascal.org/ to see whether there is a Free Pascal -compiler for your system (at present, MacOS is the only popular operating -system not available); if not, get an ANSI compliant C compiler and read -Section 6. - - - Contents - -1. Text file format and unzipping -2. Compiling with Free Pascal -3. Compiling with Borland Pascal 7.0 -4. Compiling with p2c -5. Compiling with a C compiler on a GNU system -6. Compiling with a C compiler on a non-GNU system -7. For experts only - - 1. Text file format and unzipping - -Change to some empty directory and unzip the distribution file. YOU MUST -UNZIP THE FILES USING AN UNZIPPER THAT CAN CONVERT TEXT FILES TO YOUR -SYSTEM'S FORMAT. Some things may work even if you don't (maybe even -everything, if your system happens to use the same text format as the -system on which the zipfile was made) but then any later errors will -only be more mysterious because of that. It may be necessary to set -special options in your unzipper to achieve this. On a GNU system, -the command is - unzip -a mtxP????.zip - - - 2. Compiling with Free Pascal - -Free Pascal is available from for most current operating systems, including -Linux, SunOS and Windows. - -If your system has GNU Make, simply type - - make - -Otherwise, type - - fpc -B -So prepmx - -to make the executable. - - - 3. Compiling with Borland Pascal 7.0 - -This compiler is a 16-bit compiler specific to MSDOS, even though it -runs under Windows and under DOS emulators on other 32-bit systems. -It cannot handle very large code and data segments, and unfortunately -it is necessary to cripple M-Tx somewhat to make it fit in, as follows: - -3.1 Edit the file "globals.pas" and change the lines - - lines_in_paragraph = 100; - max_words = 128; - max_notes = 128; - - to - - lines_in_paragraph = 50; - max_words = 64; - max_notes = 64; - -3.2 Type - - bpc -b prepmx - - to make prepmx.exe. - - - 4. Compiling with p2c - -This route is only available if you have a GNU system with a C compiler -and the package p2c (on old Red Hat systems, both p2c and p2c-devel). Type - - make prepmxc - -to make prepmx. On this system only, you can make the mtxC????.zip file -that corresponds to your mtxP????.zip file with - - make Czip - - - 5. Compiling with a C compiler on a GNU system - -Just type - - make prepmxc - -to make prepmx. - - - 6. Compiling with a C compiler on a non-GNU system - -Your C compiler must be ANSI compliant (sorry, Visual C++ 6.0 is not -such, but Turbo C++ is). Then issue a command that will compile and -link all the .c files to produce an appropriately named executable. -The command line will depend on your system; for example - - cc *.c -o prepmx - -should work on non-GNU Un?x systems. - - - 7. For experts only - -You can modify the source code as you wish -- this is open source software -and the copyright is GPL. If you wish to redistribute your modified version, -please augment the name so that there is no risk of confusion: e.g. if you -are Johannes Brahms and you have made changes to mtxC054f.zip, call it -mtxC054f-brahms.zip. - -Even better, send me an e-mail with your changes so that I can insert them -into the current development version. - -The primary source is the Pascal version; the C version is made with p2c as -described in Section 4. Therefore, any change made to the C code is volatile; -only changes made to the Pascal version become permanent. - -If you make both Pascal and C executables, it is your responsibilty to -move or rename the first executable, otherwise it will be overwritten. -Moreover, it is possible to confuse the Makefile, since object files -from Pascal and C compilations may well have the same name; you will -then get numerous error messages. The safe thing is to "make clean" -before switching languages. diff --git a/Build/source/utils/m-tx/mtx-0.60d/README.060d b/Build/source/utils/m-tx/mtx-0.60d/README.060d deleted file mode 100644 index abc347bfd0e..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/README.060d +++ /dev/null @@ -1,8 +0,0 @@ -M-Tx 0.60d is a test version of M-Tx 0.60. Please try it out and report any -error observations to Christian Mondrup, reccmo@daimi.au.dk and -Dirk Laurie, dpl@sun.ac.za - -Changes: -======== - -- Fixed a bug with non-labeled ties diff --git a/Build/source/utils/m-tx/mtx-0.60d/analyze.c b/Build/source/utils/m-tx/mtx-0.60d/analyze.c deleted file mode 100644 index 3003eeb9723..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/analyze.c +++ /dev/null @@ -1,333 +0,0 @@ -/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ -/* From input file "analyze.pas" */ - - -#include "p2c.h" - - -#define ANALYZE_G -#include "analyze.h" - - -#ifndef MTX_H -#include "mtx.h" -#endif - -#ifndef STRINGS_H -#include "strings.h" -#endif - -#ifndef LYRICS_H -#include "lyrics.h" -#endif - -#ifndef MTXLINE_H -#include "mtxline.h" -#endif - -#ifndef UPTEXT_H -#include "uptext.h" -#endif - -#ifndef PREAMBLE_H -#include "preamble.h" -#endif - -#ifndef UTILITY_H -#include "utility.h" -#endif - - -Void includeStartString() -{ - voice_index voice; - paragraph_index0 mus; - voice_index FORLIM; - Char STR1[256]; - Char STR2[256]; - - FORLIM = nvoices; - for (voice = 1; voice <= FORLIM; voice++) { - mus = musicLineNo(voice); - if (mus > 0) { - sprintf(STR2, "%s%s", startString(STR1, voice), P[mus-1]); - strcpy(P[mus-1], STR2); - } - } -} - - -Static Char *describe(Result, nbar, extra) -Char *Result; -short nbar, extra; -{ - Char STR1[256]; - Char STR3[256]; - Char STR4[256]; - - sprintf(Result, "%s bar%s + %s/64 notes", - toString(STR1, nbar), plural(STR3, nbar), toString(STR4, extra)); - return Result; -} - - -Void testParagraph() -{ - voice_index0 voice; - voice_index0 leader = 0, nv = 0; - paragraph_index0 mus; - short extra, l, nbar; - voice_index0 FORLIM; - Char STR2[256]; - Char STR3[256]; - - nbars = 0; - pickup = 0; - nleft = 0; - if (top > bottom) - return; - pickup = 0; - multi_bar_rest = false; - FORLIM = bottom; - for (voice = top; voice <= FORLIM; voice++) { - mus = musicLineNo(voice); - if (mus > 0) { /** -------------- Voice is present ---- */ - nv++; - line_no = orig_line_no[mus-1]; - scanMusic(voice, &l); - if (multi_bar_rest && nv > 1) - error("Multi-bar rest allows only one voice", print); - if (!pmx_preamble_done) { - if (voice == top) - pickup = l; - else if (pickup != l) - error3(voice, "The same pickup must appear in all voices"); - } - nbar = numberOfBars(voice); - extra = ExtraLength(voice); - if (multi_bar_rest && (nbar > 0 || extra > 0)) - error3(voice, "Multi-bar rest allows no other rests or notes"); - if (nbar > nbars || nbar == nbars && extra > nleft) { - nbars = nbar; - nleft = extra; - leader = voice; - } - if (!final_paragraph && meternum > 0 && extra > 0) { - printf("Line has %s\n", describe(STR2, nbar, extra)); - error(" Line does not end at complete bar", print); - } - if (pmx_preamble_done && l > 0 && meternum > 0) - error3(voice, "Short bar with no meter change"); - } - } - if (!pmx_preamble_done) { - xmtrnum0 = (double)pickup / one_beat; /* Don't want an integer result */ - if (beVerbose()) - printf("Pickup = %d/64\n", pickup); - } - if (leader <= 0) - return; - FORLIM = bottom; - for (voice = top; voice <= FORLIM; voice++) { - if (musicLineNo(voice) > 0) { - if (voice != leader) { - mus = musicLineNo(voice); - line_no = orig_line_no[mus-1]; - if (numberOfBars(voice) != numberOfBars(leader) || - ExtraLength(voice) != ExtraLength(leader)) { - printf("Following line has %s\n", - describe(STR3, numberOfBars(voice), ExtraLength(voice))); - puts(musicLine(STR3, voice)); - printf("Longest line has %s\n", - describe(STR2, numberOfBars(leader), ExtraLength(leader))); - puts(musicLine(STR2, leader)); - error("Line duration anomaly", print); - } - } - } - } -} - - -Void describeParagraph() -{ - voice_index0 voice; - Char STR2[256]; - voice_index0 FORLIM; - - printf("---- Paragraph %d starting at line %d bar %d\n", - paragraph_no, orig_line_no[0], bar_no); - FORLIM = bottom; - for (voice = top; voice <= FORLIM; voice++) - describeVoice(voice, lyricsReport(STR2, voice)); -} - - -/* Local variables for paragraphSetup: */ -struct LOC_paragraphSetup { - voice_index0 *voice; - short l; - voice_index0 k; - Char P_keep[256], w[256]; - boolean is_labelled; -} ; - -Local Void maybeUptext(i, LINK) -short i; -struct LOC_paragraphSetup *LINK; -{ - if (!doUptext()) - return; - if (strlen(LINK->w) == 1) { - if (*LINK->voice == nvoices) - warning("Uptext line below bottom voice should be labelled", print); - } - if (strlen(LINK->w) == 1) { /** Standard chord line ------ */ - LINK->k = *LINK->voice + 1; - if (LINK->k > nvoices) - LINK->k--; - setUptextLineNo(LINK->k, i); - /** Labelled chord line ---- */ - return; - } - predelete(LINK->w, 1); - LINK->k = findVoice(LINK->w); - if (LINK->k == 0) - error("Uptext line belongs to unknown voice", print); - else - setUptextLineNo(LINK->k, i); -} - -Local Void maybeChords(i, LINK) -short i; -struct LOC_paragraphSetup *LINK; -{ - if (!doChords()) - return; - if (strlen(LINK->w) == 1 && *LINK->voice == 0 && pedanticWarnings()) - warning("Chord line above top voice should be labelled", print); - if (strlen(LINK->w) == 1) { /** Standard chord line ------ */ - LINK->k = *LINK->voice; - if (LINK->k == 0) - LINK->k = 1; - setChordLineNo(LINK->k, i); - /** Labelled chord line ---- */ - return; - } - predelete(LINK->w, 1); - LINK->k = findVoice(LINK->w); - if (LINK->k == 0) - error("Chord line belongs to unknown voice", print); - else - setChordLineNo(LINK->k, i); -} - -Local Void analyzeParagraph(LINK) -struct LOC_paragraphSetup *LINK; -{ - paragraph_index i, FORLIM; - - *LINK->voice = 0; - bottom = 0; - top = nvoices + 1; - clearLabels(); - clearTags(); - clearUptext(); - FORLIM = para_len; - for (i = 1; i <= FORLIM; i++) - { /* ----- Paragraph analysis main loop ----- */ - if (*P[i-1] != '\0' && P[i-1][0] != comment) { - NextWord(LINK->w, P[i-1], blank, colon); - line_no = orig_line_no[i-1]; - LINK->l = strlen(LINK->w); - LINK->is_labelled = (LINK->w[LINK->l-1] == colon && - LINK->w[LINK->l-2] != barsym); - if (LINK->is_labelled) { - strcpy(LINK->P_keep, P[i-1]); - predelete(P[i-1], LINK->l); - shorten(LINK->w, LINK->l - 1); - LINK->k = findVoice(LINK->w); /* First look for a voice label */ - if (LINK->k > 0) { - *LINK->voice = LINK->k; - setMusicLineNo(*LINK->voice, i); - } else if (LINK->w[0] == 'L') - maybeLyrics(*LINK->voice, i, LINK->w); - else if (LINK->w[0] == 'C') - maybeChords(i, LINK); - else if (LINK->w[0] == 'U') - maybeUptext(i, LINK); - else { - if (startsWithIgnoreCase(LINK->w, "SPACE")) { - setSpace(P[i-1]); - must_respace = true; - } else { - if (startsWithIgnoreCase(LINK->w, "VOICES")) { - selectVoices(P[i-1]); - must_restyle = true; - } else { - strcpy(P[i-1], LINK->P_keep); - LINK->is_labelled = false; - if (!isNoteOrRest(LINK->w)) { - error("Unknown line label", print); - /** ------------ Maybe Space command ------------ */ - /** ------------ Maybe Voices command ------------ */ - /** Could be sticky attribute **/ - } - } - } - } - } - if (!LINK->is_labelled) { - (*LINK->voice)++; - setMusicLineNo(*LINK->voice, i); - } - if (*LINK->voice > bottom) - bottom = *LINK->voice; - if (*LINK->voice > 0 && *LINK->voice < top) - top = *LINK->voice; - } - } -} - -Local Void obliterate(LINK) -struct LOC_paragraphSetup *LINK; -{ - paragraph_index i; - Char new_only[256]; - paragraph_index FORLIM; - - *new_only = '\0'; - FORLIM = para_len; - for (i = 0; i <= FORLIM - 1; i++) { - if (startsWithIgnoreCase(P[i], "only:")) { - strcpy(new_only, P[i]); - strcpy(P[i], "%"); - } - } - if (*new_only != '\0') { - setOnly(new_only); - return; - } - FORLIM = para_len; - for (i = 1; i <= FORLIM; i++) { - if (omitLine(i)) - strcpy(P[i-1], "%"); - } -} - - -Void paragraphSetup(voice_) -voice_index0 *voice_; -{ - struct LOC_paragraphSetup V; - - V.voice = voice_; - obliterate(&V); - analyzeParagraph(&V); - reviseLyrics(); -} - - - - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/analyze.h b/Build/source/utils/m-tx/mtx-0.60d/analyze.h deleted file mode 100644 index e05b846ebb5..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/analyze.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Header for module analyze, generated by p2c 1.21alpha-07.Dec.93 */ -#ifndef ANALYZE_H -#define ANALYZE_H - - -/* Decide which lines of paragraphs go where; test total duration of lines. */ - -#ifndef CONTROL_H -#include "control.h" -#endif - -#ifndef GLOBALS_H -#include "globals.h" -#endif - - -#ifdef ANALYZE_G -# define vextern -#else -# define vextern extern -#endif - -extern Void testParagraph PV(); -extern Void describeParagraph PV(); -extern Void paragraphSetup PP((voice_index0 *voice)); -extern Void includeStartString PV(); - - -#undef vextern - -#endif /*ANALYZE_H*/ - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/analyze.pas b/Build/source/utils/m-tx/mtx-0.60d/analyze.pas deleted file mode 100644 index 310c5887854..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/analyze.pas +++ /dev/null @@ -1,181 +0,0 @@ -unit analyze; - -{ Decide which lines of paragraphs go where; test total duration of lines. } - -interface uses control, globals; - -procedure testParagraph; -procedure describeParagraph; -procedure paragraphSetup (var voice: voice_index0); -procedure includeStartString; - -implementation uses mtx, strings, lyrics, mtxline, uptext, - preamble, utility; - -procedure includeStartString; - var voice: voice_index; - mus: paragraph_index0; -begin for voice:=1 to nvoices do - begin mus:=musicLineNo(voice); if mus>0 then - P[mus]:=startString(voice)+P[mus]; - end; -end; - -function describe(nbar,extra: integer): string; -begin describe:=toString(nbar)+' bar'+plural(nbar)+' + '+ - toString(extra)+'/64 notes'; -end; - -procedure testParagraph; - var voice, leader, nv: voice_index0; - mus: paragraph_index0; - extra, l, nbar: integer; -begin - nbars:=0; pickup:=0; nleft:=0; if top>bottom then exit; - pickup:=0; nv:=0; leader:=0; multi_bar_rest := false; - for voice:=top to bottom do - begin mus:=musicLineNo(voice); - if mus>0 then {* -------------- Voice is present ---- } - begin inc(nv); line_no:=orig_line_no[mus]; - scanMusic(voice,l); - if multi_bar_rest and (nv>1) then error( - 'Multi-bar rest allows only one voice',print); - if not pmx_preamble_done then - if voice=top then pickup:=l - else if pickup<>l then - error3(voice,'The same pickup must appear in all voices'); - nbar := numberOfBars(voice); extra := extraLength(voice); - if multi_bar_rest and ((nbar>0) or (extra>0)) then error3(voice, - 'Multi-bar rest allows no other rests or notes'); - if (nbar>nbars) or (nbar=nbars) and (extra>nleft) then - begin nbars:=nbar; nleft:=extra; leader:=voice; end; - if not final_paragraph and (meternum>0) and (extra>0) then - begin writeln('Line has ', describe(nbar,extra)); - error(' Line does not end at complete bar',print); - end; - if pmx_preamble_done and (l>0) and (meternum>0) then - error3(voice,'Short bar with no meter change'); - end - end; - if not pmx_preamble_done then - begin - xmtrnum0 := pickup/one_beat; { Don't want an integer result } - if beVerbose then writeln ('Pickup = ', pickup, '/64'); - end; - if leader>0 then - for voice:=top to bottom do if musicLineNo(voice)>0 then - if voice<>leader then - begin mus:=musicLineNo(voice); - line_no:=orig_line_no[mus]; - if (numberOfBars(voice)<>numberOfBars(leader)) - or (extraLength(voice)<>extraLength(leader)) then - begin - writeln('Following line has ', - describe(numberOfBars(voice), extraLength(voice))); - writeln(musicLine(voice)); - writeln('Longest line has ', - describe(numberOfBars(leader), extraLength(leader))); - writeln(musicLine(leader)); - error('Line duration anomaly',print); - end; - end; -end; - -procedure describeParagraph; - var voice: voice_index0; - begin writeln('---- Paragraph ',paragraph_no, - ' starting at line ', orig_line_no[1], ' bar ', bar_no); - for voice:=top to bottom do describeVoice(voice,lyricsReport(voice)); - end; - -procedure paragraphSetup (var voice: voice_index0); - var l: integer; - k: voice_index0; - P_keep, w: string; - is_labelled: boolean; - - procedure maybeUptext(i: integer); - begin if not doUptext then exit; - if (length(w)=1) then if (voice=nvoices) then - warning('Uptext line below bottom voice should be labelled',print); - if length(w)=1 then {* Standard chord line ------ } - begin k:=voice+1; if k>nvoices then dec(k); - setUptextLineNo(k,i); - end - else {* Labelled chord line ---- } - begin predelete(w,1); k:=findVoice(w); - if k=0 then error('Uptext line belongs to unknown voice',print) - else setUptextLineNo(k,i); - end - end; - - procedure maybeChords(i: integer); - begin if not doChords then exit; - if (length(w)=1) and (voice=0) and pedanticWarnings then - warning('Chord line above top voice should be labelled',print); - if length(w)=1 then {* Standard chord line ------ } - begin k:=voice; if k=0 then k:=1; - setChordLineNo(k,i); - end - else {* Labelled chord line ---- } - begin predelete(w,1); k:=findVoice(w); - if k=0 then error('Chord line belongs to unknown voice',print) - else setChordLineNo(k,i); - end - end; - - procedure analyzeParagraph; - var i: paragraph_index; - begin voice:=0; bottom:=0; top:=nvoices+1; - clearLabels; clearTags; clearUptext; - for i:=1 to para_len do { ----- Paragraph analysis main loop ----- } - if (P[i]<>'') and (P[i,1]<>comment) then - begin - w:=NextWord(P[i],blank,colon); line_no := orig_line_no[i]; - l:=length(w); - is_labelled := (w[l]=colon) and (w[l-1]<>barsym); - if is_labelled then - begin P_keep := P[i]; predelete(P[i],l); shorten(w,l-1); - k:=findVoice(w); { First look for a voice label } - if k>0 then - begin voice:=k; setMusicLineNo(voice,i); - end - else if w[1]='L' then maybeLyrics(voice,i,w) - else if w[1]='C' then maybeChords(i) - else if w[1]='U' then maybeUptext(i) - else begin {* ------------ Maybe Space command ------------ } - if startsWithIgnoreCase(w,'SPACE') then - begin setSpace(P[i]); must_respace:=true; - end - else {* ------------ Maybe Voices command ------------ } - if startsWithIgnoreCase(w,'VOICES') then - begin selectVoices(P[i]); must_restyle:=true; - end - else begin {* Could be sticky attribute *} - P[i] := P_keep; is_labelled := false; - if not isNoteOrRest(w) then error('Unknown line label',print); - end - end - end; - if not is_labelled then - begin inc(voice); setMusicLineNo(voice,i); - end; - if voice>bottom then bottom:=voice; - if (voice>0) and (voice'' then setOnly(new_only) - else for i:=1 to para_len do if omitLine(i) then P[i]:='%'; - end; - -begin obliterate; analyzeParagraph; reviseLyrics; -end; - -end. diff --git a/Build/source/utils/m-tx/mtx-0.60d/cfuncs.c b/Build/source/utils/m-tx/mtx-0.60d/cfuncs.c deleted file mode 100644 index d7d5b81987b..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/cfuncs.c +++ /dev/null @@ -1,91 +0,0 @@ -# define CFUNCS_C -#include "cfuncs.h" - -int P_argc; -char **P_argv; -int P_ioresult; -int _EscIO2 (int errorcode, char* filename) -{ fprintf(stderr,"Input file %s not found\n",filename); - exit(errorcode); return errorcode; } -int _EscIO (int errorcode){ return _EscIO2(errorcode,""); } -int _Escape (int exitcode) -{ exit(exitcode); return exitcode; } -int _SETIO (int OK, int errorcode){ return P_ioresult = OK ? 0 : errorcode; } -int P_eof (FILE * infile) -{ int x; - if (feof(infile)) return 1; - x = fgetc(infile); - if (x==EOF) return 1; - ungetc(x,infile); return 0; - } -void *__MallocTemp__; -int _OutMem(void) { fprintf(stderr,"Out of memory\n"); exit(-2); return -2; } -void PASCAL_MAIN (int npars, char ** pars) -{ P_argc = npars; P_argv = pars; } - -void scan1(char *s, short p, short *n) -{ sscanf(s+p-1,"%hd",n); -} - -short pos1(char c, char *s) -{ char *t = strchr(s,c); - if (t) return (short) (t-s+1); else return 0; -} - -void delete1(char *s, short p) -{ char *t = (s+=p); s=t-1; - while (*s) *s++ = *t++; -} - -void predelete(char *s, short l) -{ char *t = s+l; - while (*t) *s++ = *t++; - *s = *t; -} - -void shorten(char *s, short new_length) -{ s[new_length] = '\0'; -} - -short posNot(char c, char *s) -{ char *t = s; - while (*t == c) t++; - if (*t) return t-s+1; - else return 0; -} - -void getNum(char *line, short *k) -{ int j=sscanf(line,"%hd",k); - if (j<1) *k=0; -} - - -void getTwoNums(char *line, short *k1, short *k2) -{ int param = sscanf(line,"%hd/%hd",k1,k2); - if (param<2) *k2 = 0; -} - -void toUpper(char *s) -{ while (*s) { *s = toupper(*s); s++; } -} - -boolean startsWith(char *s1, char *s2) -{ while (*s2) { if (*s1++ != *s2++) return false; } - return true; -} - -void insertChar(char c, char *s, short p) -{ char x; - s += p-1; - do { x=c; c=*s; *s++=x; } while (x); -} - -char *substr_(char *Result, char *s, short start, short count) -{ char *R = Result; - s += start-1; - while (count--) *R++ = *s++; - *R = '\0'; - return Result; -} - -# undef CFUNCS_C diff --git a/Build/source/utils/m-tx/mtx-0.60d/cfuncs.h b/Build/source/utils/m-tx/mtx-0.60d/cfuncs.h deleted file mode 100644 index 5dc1c829fe7..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/cfuncs.h +++ /dev/null @@ -1,72 +0,0 @@ -/* cfuncs.h DPL 1997-03-31, 2001-12-22 */ - -#ifndef CFUNCS_H -# define CFUNCS_H - -#define STRINGS_H -typedef char Char; -typedef void Void; -#define Static static -#define Local static -#define SHORT_MAX 65535 - -# define FileNotFound 10 -# define FileWriteError 38 -#ifndef STDIO_H -# include -#endif -#ifndef CTYPE_H -# include -#endif -#ifndef STRING_H -# include -#endif -#ifndef STDLIB_H -# include -#endif -#ifndef _FNSIZE -# define _FNSIZE 120 -#endif - -typedef unsigned boolean; -#define false 0 -#define true 1 - -extern int _EscIO (int); -extern int _EscIO2 (int errorcode, char* filename); -extern int _Escape (int); -extern int P_eof (FILE *); -extern int _SETIO (int, int); - -extern void PASCAL_MAIN (int, char **); -extern int P_argc; -extern int P_ioresult; -extern char **P_argv; - -#ifdef CFUNCS_C -# define vextern -#else -# define vextern extern -#endif -/* String handling primitives. */ - -extern void scan1(char *s, short p, short *n); -/* Read an integer at position p of s */ -extern boolean startsWith(char *s1, char *s2); -/* True if s1 starts with s2 */ -extern short pos1(char c, char *s); -extern short posNot(char c, char *s); -extern void insertChar(char c, char *s, short p); -extern char *substr_(char *Result, char *s, short start, short count); -extern void getNum(char *line, short *k); -extern void getTwoNums(char *line, short *k1, short *k2); -extern void toUpper(char *s); -extern void delete1(char *s, short p); -extern void predelete(char *s, short l); -extern void shorten(char *s, short new_length); - - -#undef vextern - -#endif /*CFUNCS_H*/ - diff --git a/Build/source/utils/m-tx/mtx-0.60d/config.h b/Build/source/utils/m-tx/mtx-0.60d/config.h deleted file mode 100644 index 2ce758e1759..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/config.h +++ /dev/null @@ -1,90 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if your system has a GNU libc compatible `malloc' function, and - to 0 otherwise. */ -#define HAVE_MALLOC 1 - -/* Define to 1 if you have the `memchr' function. */ -#define HAVE_MEMCHR 1 - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `memset' function. */ -#define HAVE_MEMSET 1 - -/* Define to 1 if stdbool.h conforms to C99. */ -#define HAVE_STDBOOL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strrchr' function. */ -#define HAVE_STRRCHR 1 - -/* Define to 1 if you have the `strtol' function. */ -#define HAVE_STRTOL 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if the system has the type `_Bool'. */ -#define HAVE__BOOL 1 - -/* Name of package */ -#define PACKAGE "mtx" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "dpl@sun.ac.za" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "mtx" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "mtx 0.60d" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "mtx" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "0.60d" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "0.60d" - -/* Define to rpl_malloc if the replacement function should be used. */ -/* #undef malloc */ - -/* Define to `unsigned int' if does not define. */ -/* #undef size_t */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/config.h.in b/Build/source/utils/m-tx/mtx-0.60d/config.h.in deleted file mode 100644 index 88cd015fb76..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/config.h.in +++ /dev/null @@ -1,89 +0,0 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if your system has a GNU libc compatible `malloc' function, and - to 0 otherwise. */ -#undef HAVE_MALLOC - -/* Define to 1 if you have the `memchr' function. */ -#undef HAVE_MEMCHR - -/* Define to 1 if you have the `memmove' function. */ -#undef HAVE_MEMMOVE - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `memset' function. */ -#undef HAVE_MEMSET - -/* Define to 1 if stdbool.h conforms to C99. */ -#undef HAVE_STDBOOL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDDEF_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the `strchr' function. */ -#undef HAVE_STRCHR - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the `strrchr' function. */ -#undef HAVE_STRRCHR - -/* Define to 1 if you have the `strtol' function. */ -#undef HAVE_STRTOL - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if the system has the type `_Bool'. */ -#undef HAVE__BOOL - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Version number of package */ -#undef VERSION - -/* Define to rpl_malloc if the replacement function should be used. */ -#undef malloc - -/* Define to `unsigned int' if does not define. */ -#undef size_t diff --git a/Build/source/utils/m-tx/mtx-0.60d/configure.ac b/Build/source/utils/m-tx/mtx-0.60d/configure.ac deleted file mode 100644 index a5c59e86466..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/configure.ac +++ /dev/null @@ -1,33 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ([2.63]) -AC_INIT([mtx], [0.60d], [dpl@sun.ac.za]) -AC_CONFIG_SRCDIR([analyze.c]) -AC_CONFIG_HEADERS([config.h]) -AM_INIT_AUTOMAKE(mtx,0.60d) - -# Checks for programs. -AC_PROG_CC -AC_PROG_INSTALL -AC_PROG_MAKE_SET -AC_PROG_RANLIB - -# Checks for libraries. - -# Checks for header files. -AC_CHECK_HEADERS([memory.h stddef.h stdlib.h string.h strings.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_HEADER_STDBOOL -AC_TYPE_SIZE_T - -# Checks for library functions. -AC_FUNC_ERROR_AT_LINE -AC_FUNC_MALLOC -AC_FUNC_STRTOD -AC_CHECK_FUNCS([memchr memmove memset strchr strrchr strtol]) - -AC_CONFIG_FILES([Makefile - libp2c/Makefile]) -AC_OUTPUT diff --git a/Build/source/utils/m-tx/mtx-0.60d/control.c b/Build/source/utils/m-tx/mtx-0.60d/control.c deleted file mode 100644 index 9dbb2dae1da..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/control.c +++ /dev/null @@ -1,274 +0,0 @@ -/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ -/* From input file "control.pas" */ - - -#include "p2c.h" - - -#define CONTROL_G -#include "control.h" - - -#ifndef UTILITY_H -#include "utility.h" -#endif - - -/* enables Include: directive */ -/* one-word shortcut is treated by simply inserting a blank */ -/* detached form of shortcut allowed */ -/* C: lines are taken into account */ -/* U: lines are taken into account */ -/* L: lines are taken into account */ -/* non-melismatic eighth and shorter notes in vocal lines are unbeamed */ -/* blind slurs are hidden */ -/* U: lines synchronize with words and rests */ -/* always insert duration into notes */ -/* include macros in the count */ -/* literally expand macros */ -/* keep track of pitch and warn if unreal */ -/* transform note words to canical form */ -/* use solfa note names */ -/* issue warnings even when default action is likely to be correct */ -/* ignore all errors except fatal errors */ -/* set instrument names */ -/* report what is being done */ -/* write all possible infomative messages */ -typedef enum { - noSuchFeature, FmultiFile, FsplitShortcut, FnewWordShortcut, FdoChords, - FdoUptext, FdoLyrics, FunbeamVocal, FhideBlindSlurs, FuptextOnRests, - FinsertDuration, FcountMacro, FexpandMacro, FcheckPitch, FrearrangeNote, - FsolfaNoteNames, FpedanticWarnings, FignoreErrors, FinstrumentNames, - FbeVerbose, FdebugMode -} feature; - -typedef struct Tfeature { - Char tag[31]; - boolean active, changed; -} Tfeature; - - -#define firstFeature FmultiFile -#define lastFeature FdebugMode - - -Static Tfeature feat[21] = { - { "", false, false }, - { "multiFile", true, false }, - { "splitShortcut", true, false }, - { "newWordShortcut", true, false }, - { "doChords", true, false }, - { "doUptext", true, false }, - { "doLyrics", true, false }, - { "unbeamVocal", true, false }, - { "hideBlindSlurs", true, false }, - { "uptextOnRests", true, false }, - { "insertDuration", true, false }, - { "countMacro", false, false }, - { "expandMacro", false, false }, - { "checkPitch", true, false }, - { "rearrangeNote", true, false }, - { "solfaNoteNames", false, false }, - { "pedanticWarnings", false, false }, - { "ignoreErrors", false, false }, - { "instrumentNames", false, false }, - { "beVerbose", false, false }, - { "debugMode", false, false } -}; - - -Void printFeatures(anyway) -boolean anyway; -{ - feature i; - Tfeature *WITH; - - for (i = firstFeature; (long)i <= (long)lastFeature; i = (feature)((long)i + 1)) { - WITH = &feat[(long)i]; - if (WITH->changed || anyway) - printf("%s = %s\n", WITH->tag, WITH->active ? " TRUE" : "FALSE"); - } -} - - -Static feature featureNamed(s) -Char *s; -{ - feature i; - - for (i = firstFeature; (long)i <= (long)lastFeature; i = (feature)((long)i + 1)) { - if (equalsIgnoreCase(s, feat[(long)i].tag)) - return i; - } - return noSuchFeature; -} - - -boolean setFeature(which, val) -Char *which; -boolean val; -{ - boolean Result = false; - feature f; - Tfeature *WITH; - - f = featureNamed(which); - if (f != noSuchFeature) { - WITH = &feat[(long)f]; - WITH->active = val; - WITH->changed = true; - Result = true; - } - if (f == FdebugMode && val) - feat[(long)FbeVerbose].active = true; - if (f == FbeVerbose && !val) - feat[(long)FdebugMode].active = false; - return Result; -} - - -Void mtxLevel(level) -Char *level; -{ - if (strcmp(level, "0.57") < 0) { - setFeature("splitShortcut", false); - setFeature("newWordShortcut", false); - } -} - - -/* Feature functions. To add a new feature "newFeature": - 1. Insert a new value "FnewFeature" in the declaration of type "feature". - 2. Insert an entry for it in array "feat". - 3. Copy the template below and change "FEATURE" into "newFeature". - 4. Copy the function header to the interface section. - 5. (Optional) Insert code into "mtxLevel" to enable/disable the feature. - -function FEATURE: boolean; -begin FEATURE := feat[FFEATURE].active end; -*/ - -boolean checkPitch() -{ - return (feat[(long)FcheckPitch].active); -} - - -boolean countMacro() -{ - return (feat[(long)FcountMacro].active); -} - - -boolean expandMacro() -{ - return (feat[(long)FexpandMacro].active); -} - - -boolean insertDuration() -{ - return (feat[(long)FinsertDuration].active); -} - - -boolean rearrangeNote() -{ - return (feat[(long)FrearrangeNote].active); -} - - -boolean beVerbose() -{ - return (feat[(long)FbeVerbose].active); -} - - -boolean debugMode() -{ - return (feat[(long)FdebugMode].active); -} - - -boolean instrumentNames() -{ - return (feat[(long)FinstrumentNames].active); -} - - -boolean hideBlindSlurs() -{ - return (feat[(long)FhideBlindSlurs].active); -} - - -boolean doLyrics() -{ - return (feat[(long)FdoLyrics].active); -} - - -boolean ignoreErrors() -{ - return (feat[(long)FignoreErrors].active); -} - - -boolean pedanticWarnings() -{ - return (feat[(long)FpedanticWarnings].active); -} - - -boolean solfaNoteNames() -{ - return (feat[(long)FsolfaNoteNames].active); -} - - -boolean uptextOnRests() -{ - return (feat[(long)FuptextOnRests].active); -} - - -boolean unbeamVocal() -{ - return (feat[(long)FunbeamVocal].active); -} - - -boolean doChords() -{ - return (feat[(long)FdoChords].active); -} - - -boolean doUptext() -{ - return (feat[(long)FdoUptext].active); -} - - -boolean newWordShortcut() -{ - return (feat[(long)FnewWordShortcut].active); -} - - -boolean splitShortcut() -{ - return (feat[(long)FsplitShortcut].active); -} - - -boolean multiFile() -{ - return (feat[(long)FmultiFile].active); -} - - - - - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/control.h b/Build/source/utils/m-tx/mtx-0.60d/control.h deleted file mode 100644 index 91ce2c2dfef..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/control.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Header for module control, generated by p2c 1.21alpha-07.Dec.93 */ -#ifndef CONTROL_H -#define CONTROL_H - - -#ifdef CONTROL_G -# define vextern -#else -# define vextern extern -#endif -/* DPL 2004-03-21 */ -/* Controls which M-Tx features are enabled. - The interface allows one to interrogate the feature state, to set - features according to the M-Tx level, and to override features given - the feature name as a character string. -*/ - - -extern Void mtxLevel PP((Char *level)); -extern boolean setFeature PP((Char *which, int val)); -/* return TRUE means OK, return FALSE means there is no such feature */ -extern Void printFeatures PP((int anyway)); -/* anyway TRUE means print all feature settings, FALSE means only those - that were set via setFeature */ - -extern boolean multiFile PV(); -extern boolean splitShortcut PV(); -extern boolean newWordShortcut PV(); -extern boolean doChords PV(); -extern boolean doUptext PV(); -extern boolean doLyrics PV(); -extern boolean unbeamVocal PV(); -extern boolean uptextOnRests PV(); -extern boolean solfaNoteNames PV(); -extern boolean pedanticWarnings PV(); -extern boolean ignoreErrors PV(); -extern boolean hideBlindSlurs PV(); -extern boolean instrumentNames PV(); -extern boolean beVerbose PV(); -extern boolean debugMode PV(); -extern boolean insertDuration PV(); -extern boolean rearrangeNote PV(); -extern boolean countMacro PV(); -extern boolean expandMacro PV(); -extern boolean checkPitch PV(); - - -#undef vextern - -#endif /*CONTROL_H*/ - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/control.pas b/Build/source/utils/m-tx/mtx-0.60d/control.pas deleted file mode 100644 index fbe224658a8..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/control.pas +++ /dev/null @@ -1,198 +0,0 @@ -unit control; { DPL 2004-03-21 } -{ Controls which M-Tx features are enabled. - The interface allows one to interrogate the feature state, to set - features according to the M-Tx level, and to override features given - the feature name as a character string. -} - -interface - -procedure mtxLevel(level: string); -function setFeature(which: string; val: boolean): boolean; - { return TRUE means OK, return FALSE means there is no such feature } -procedure printFeatures(anyway: boolean); - { anyway TRUE means print all feature settings, FALSE means only those - that were set via setFeature } - -function multiFile: boolean; -function splitShortcut: boolean; -function newWordShortcut: boolean; -function doChords: boolean; -function doUptext: boolean; -function doLyrics: boolean; -function unbeamVocal: boolean; -function uptextOnRests: boolean; -function solfaNoteNames: boolean; -function pedanticWarnings: boolean; -function ignoreErrors: boolean; -function hideBlindSlurs: boolean; -function instrumentNames: boolean; -function beVerbose: boolean; -function debugMode: boolean; -function insertDuration: boolean; -function rearrangeNote: boolean; -function countMacro: boolean; -function expandMacro: boolean; -function checkPitch: boolean; - -implementation uses utility; - -type feature = (noSuchFeature, - FmultiFile, { enables Include: directive } - FsplitShortcut, { one-word shortcut is treated by simply inserting a blank } - FnewWordShortcut, { detached form of shortcut allowed } - FdoChords, { C: lines are taken into account } - FdoUptext, { U: lines are taken into account } - FdoLyrics, { L: lines are taken into account } - FunbeamVocal, { non-melismatic eighth and shorter notes in vocal lines are unbeamed } - FhideBlindSlurs, { blind slurs are hidden } - FuptextOnRests, { U: lines synchronize with words and rests } - FinsertDuration, { always insert duration into notes } - FcountMacro, { include macros in the count } - FexpandMacro, { literally expand macros } - FcheckPitch, { keep track of pitch and warn if unreal } - FrearrangeNote, { transform note words to canical form } - FsolfaNoteNames, { use solfa note names } - FpedanticWarnings, { issue warnings even when default action is likely to be correct } - FignoreErrors, { ignore all errors except fatal errors } - FinstrumentNames, { set instrument names } - FbeVerbose, { report what is being done } - FdebugMode { write all possible infomative messages } ); - - Tfeature = record - tag: string[30]; - active, changed: boolean - end; - -const - firstFeature = FmultiFile; - lastFeature = FdebugMode; - - feat: array[feature] of Tfeature = ( - ( tag: ''; active: false; changed: false), - ( tag: 'multiFile'; active: true; changed: false), - ( tag: 'splitShortcut'; active: true; changed: false), - ( tag: 'newWordShortcut'; active: true; changed: false), - ( tag: 'doChords'; active: true; changed: false), - ( tag: 'doUptext'; active: true; changed: false), - ( tag: 'doLyrics'; active: true; changed: false), - ( tag: 'unbeamVocal'; active: true; changed: false), - ( tag: 'hideBlindSlurs'; active: true; changed: false), - ( tag: 'uptextOnRests'; active: true; changed: false), - ( tag: 'insertDuration'; active: true; changed: false), - ( tag: 'countMacro'; active: false; changed: false), - ( tag: 'expandMacro'; active: false; changed: false), - ( tag: 'checkPitch'; active: true; changed: false), - ( tag: 'rearrangeNote'; active: true; changed: false), - ( tag: 'solfaNoteNames'; active: false; changed: false), - ( tag: 'pedanticWarnings'; active: false; changed: false), - ( tag: 'ignoreErrors'; active: false; changed: false), - ( tag: 'instrumentNames'; active: false; changed: false), - ( tag: 'beVerbose'; active: false; changed: false), - ( tag: 'debugMode'; active: false; changed: false) - ); - -procedure printFeatures(anyway: boolean); - var i: feature; -begin for i:=firstFeature to lastFeature do with feat[i] do - if changed or anyway then writeln(tag, ' = ', active) -end; - -function featureNamed(s: string): feature; - var i: feature; -begin for i:=firstFeature to lastFeature do - if equalsIgnoreCase(s,feat[i].tag) then begin featureNamed := i; exit end; - featureNamed := noSuchFeature -end; - -function setFeature(which: string; val: boolean): boolean; - var f: feature; -begin setFeature := false; f := featureNamed(which); - if f <> noSuchFeature then with feat[f] do - begin active := val; changed := true; setFeature := true end; - if (f=FdebugMode) and val then feat[FbeVerbose].active := true; - if (f=FbeVerbose) and not val then feat[FdebugMode].active := false; -end; - -procedure mtxLevel(level: string); -begin - if level<'0.57' then - begin - setFeature('splitShortcut',false); - setFeature('newWordShortcut',false); - end -end; - -{ Feature functions. To add a new feature "newFeature": - 1. Insert a new value "FnewFeature" in the declaration of type "feature". - 2. Insert an entry for it in array "feat". - 3. Copy the template below and change "FEATURE" into "newFeature". - 4. Copy the function header to the interface section. - 5. (Optional) Insert code into "mtxLevel" to enable/disable the feature. - -function FEATURE: boolean; -begin FEATURE := feat[FFEATURE].active end; -} - -function checkPitch: boolean; -begin checkPitch := feat[FcheckPitch].active end; - -function countMacro: boolean; -begin countMacro := feat[FcountMacro].active end; - -function expandMacro: boolean; -begin expandMacro := feat[FexpandMacro].active end; - -function insertDuration: boolean; -begin insertDuration := feat[FinsertDuration].active end; - -function rearrangeNote: boolean; -begin rearrangeNote := feat[FrearrangeNote].active end; - -function beVerbose: boolean; -begin beVerbose := feat[FbeVerbose].active end; - -function debugMode: boolean; -begin debugMode := feat[FdebugMode].active end; - -function instrumentNames: boolean; -begin instrumentNames := feat[FinstrumentNames].active end; - -function hideBlindSlurs: boolean; -begin hideBlindSlurs := feat[FhideBlindSlurs].active end; - -function doLyrics: boolean; -begin doLyrics := feat[FdoLyrics].active end; - -function ignoreErrors: boolean; -begin ignoreErrors := feat[FignoreErrors].active end; - -function pedanticWarnings: boolean; -begin pedanticWarnings := feat[FpedanticWarnings].active end; - -function solfaNoteNames: boolean; -begin solfaNoteNames := feat[FsolfaNoteNames].active end; - -function uptextOnRests: boolean; -begin uptextOnRests := feat[FuptextOnRests].active end; - -function unbeamVocal: boolean; -begin unbeamVocal := feat[FunbeamVocal].active end; - -function doChords: boolean; -begin doChords := feat[FdoChords].active end; - -function doUptext: boolean; -begin doUptext := feat[FdoUptext].active end; - -function newWordShortcut: boolean; -begin newWordShortcut := feat[FnewWordShortcut].active end; - -function splitShortcut: boolean; -begin splitShortcut := feat[FsplitShortcut].active end; - -function multiFile: boolean; -begin multiFile := feat[FmultiFile].active end; - -end. - diff --git a/Build/source/utils/m-tx/mtx-0.60d/files.c b/Build/source/utils/m-tx/mtx-0.60d/files.c deleted file mode 100644 index 48aacc7aae7..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/files.c +++ /dev/null @@ -1,379 +0,0 @@ -/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ -/* From input file "files.pas" */ - - -#include "p2c.h" - - -#define FILES_G -#include "files.h" - - -#ifndef CONTROL_H -#include "control.h" -#endif - -#ifndef STRINGS_H -#include "strings.h" -#endif - -#ifndef UTILITY_H -#include "utility.h" -#endif - - -#define param_leader '-' - - -Static Char stylefilename[256] = "mtxstyle.txt"; - -Static short teststyle; - - -boolean endOfInfile() -{ - return (eofAll()); -} - - -Void tex3(s) -Char *s; -{ - Char STR1[256], STR2[256]; - - if (!pmx_preamble_done) { - putLine(s); - return; - } - if (s[0] == '%') { - putLine(s); - return; - } - if (first_paragraph) { - sprintf(STR2, "\\%s\\", s); - putLine(STR2); - } else { - sprintf(STR1, "\\\\%s\\", s); - putLine(STR1); - } -} - - -Void putLine(line) -Char *line; -{ - if (outlen + strlen(line) >= PMXlinelength) - putc('\n', outfile); - fprintf(outfile, "%s\n", line); - outlen = 0; -} - - -Void put(line_, putspace_) -Char *line_; -boolean putspace_; -{ - Char line[256]; - short l; - Char STR1[256]; - - strcpy(line, line_); - l = strlen(line); - if (l > PMXlinelength) - error("Item longer than PMX line length", print); - if (outlen + l >= PMXlinelength) { - putLine(""); - put(line, false); - return; - } - if (putspace_ && outlen > 0 && line[0] != ' ') - sprintf(line, " %s", strcpy(STR1, line)); - fputs(line, outfile); - outlen += l; -} - - -boolean styleFileFound() -{ - return (teststyle != 0); -} - - -Static Void helpmessage() -{ - printf("Usage: prepmx [-bcfnhimtuvwDH0123456789] MTXFILE [TEXDIR] [STYLEFILE]\n"); -} - - -Static Void bighelpmessage() -{ - helpmessage(); - printf("\nMTXFILE: name of .mtx file without its extension\n"); - printf("TEXDIR: directory where the TeX file made by PMX goes, default is ./\n"); - printf("STYLEFILE: name of a file containing style definitions. Default is\n"); - printf(" mtxstyle.txt. This feature is now deprecated; use Include: STYLEFILE\n"); - printf(" in the preamble of the .mtx file instead.\n"); - printf("Options: (can also be entered separately: -b -c ...)\n"); - printf(" -b: disable unbeamVocal\n"); - printf(" -c: disable doChords\n"); - printf(" -f: enable solfaNoteNames\n"); - printf(" -h: display this message and quit\n"); - printf(" -i: enable ignoreErrors\n"); - printf(" -m: disable doLyrics\n"); - printf(" -n: enable instrumentNames\n"); - printf(" -t: disable doUptext\n"); - printf(" -u: disable uptextOnRests\n"); - printf(" -v: enable beVerbose\n"); - printf(" -w: enable pedanticWarnings\n"); - printf(" -D: enable debugMode\n"); - printf(" -0123456789: select Case\n"); - printf(" -H: print enabled status of all options\n"); - printf("All the above, and some other, options can be enabled or disabled\n"); - printf(" in the preamble. What you do there overrides what you do here.\n"); -} - - -Void processOption(j) -Char j; -{ - switch (j) { - - case 'b': - setFeature("unbeamVocal", false); - break; - - case 'c': - setFeature("doChords", false); - break; - - case 'f': - setFeature("solfaNoteNames", true); - break; - - case 'h': - bighelpmessage(); - _Escape(255); - break; - - case 'i': - setFeature("ignoreErrors", true); - break; - - case 'm': - setFeature("doLyrics", false); - break; - - case 'n': - setFeature("instrumentNames", true); - break; - - case 't': - setFeature("doUptext", false); - break; - - case 'u': - setFeature("uptextOnRests", false); - break; - - case 'v': - setFeature("beVerbose", true); - break; - - case 'w': - setFeature("pedanticWarnings", true); - break; - - case 'D': - setFeature("debugMode", true); - break; - - case 'H': - printFeatures(true); - break; - - default: - if (isdigit(j)) - choice = j; - else { - putchar(j); - error(": invalid option", !print); - } - break; - } -} - - -/* Local variables for OpenFiles: */ -struct LOC_OpenFiles { - short testin; - Char basename[256]; -} ; - -Local Void checkExistingFile(LINK) -struct LOC_OpenFiles *LINK; -{ - FILE *tryfile; - Char tryfile_NAME[_FNSIZE]; - - strcpy(tryfile_NAME, LINK->basename); - tryfile = fopen(tryfile_NAME, "r+b"); - _SETIO(tryfile != NULL, FileNotFound); - LINK->testin = P_ioresult; - if (LINK->testin != 0) - return; - if (tryfile != NULL) - fclose(tryfile); - printf("There exists a file named %s. I am treating this\n", - LINK->basename); - error(" as a fatal error unless you specify -i", !print); -} - - -Void OpenFiles() -{ - struct LOC_OpenFiles V; - short i, j, l; - short fileid = 0; - Char infilename[256], outfilename[256], param[256], ext[256]; - short FORLIM1; - Char STR3[256]; - - line_no = 0; - paragraph_no = 0; - for (i = 1; i <= P_argc - 1; i++) { - strcpy(param, P_argv[i]); - if (param[0] == param_leader) { - FORLIM1 = strlen(param); - for (j = 1; j <= FORLIM1 - 1; j++) - processOption(param[j]); - } else if (fileid == 0) - fileid = i; - else if (*texdir == '\0') - strcpy(texdir, param); - else - strcpy(stylefilename, param); - } - if (fileid == 0) { - helpmessage(); - printf("Try \"prepmx -h\" for more information.\n"); - _Escape(255); - } - strcpy(V.basename, P_argv[fileid]); - l = strlen(V.basename); - if (l > 4 && V.basename[l-4] == '.') { - substr_(ext, V.basename, l - 2, 3); - toUpper(ext); - if (!strcmp(ext, "MTX")) { - warning(".mtx extension deleted from basename", !print); - shorten(V.basename, l - 4); - } - } - if (pos1('.', V.basename) > 0) - checkExistingFile(&V); - sprintf(infilename, "%s.mtx", V.basename); - sprintf(outfilename, "%s.pmx", V.basename); - pushFile(infilename); - strcpy(outfile_NAME, outfilename); - if (outfile != NULL) - outfile = freopen(outfile_NAME, "wb", outfile); - else - outfile = fopen(outfile_NAME, "wb"); - _SETIO(outfile != NULL, FileNotFound); - strcpy(stylefile_NAME, stylefilename); - if (stylefile != NULL) - stylefile = freopen(stylefile_NAME, "r", stylefile); - else - stylefile = fopen(stylefile_NAME, "r"); - _SETIO(stylefile != NULL, FileNotFound); - teststyle = P_ioresult; - if (teststyle != 0 && strcmp(stylefilename, "mtxstyle.txt")) - _SETIO(printf("Can't read %s\n", stylefilename) >= 0, FileWriteError); - if (fileError()) { - sprintf(STR3, "Input file %s not found", infilename); - fatalerror(STR3); - } - outfile_open = true; - printf("Writing to %s.pmx\n", V.basename); -} - - -Void CloseFiles() -{ - if (outfile != NULL) - fclose(outfile); - outfile = NULL; - closeAll(); - if (teststyle != 0) - return; - if (stylefile != NULL) - fclose(stylefile); - stylefile = NULL; -} - - -Void readParagraph(P, no, L) -Char (*P)[256]; -short *no; -paragraph_index0 *L; -{ - boolean another; - Char filename[256], buffer[256]; - Char STR1[256], STR3[256]; - - *L = 0; - readData(buffer); - line_no = currentLineNo(); - if (isEmpty(buffer)) - return; - if (debugMode()) - printf(">>>> %s\n", buffer); - paragraph_no++; - /* Handle directives affecting the processing of the input file */ - do { - another = false; - if (startsWithIgnoreCase(buffer, "SUSPEND")) { - ignore_input = true; - another = true; - if (beVerbose()) - printf("-->> Suspending input file %s at line %d\n", - currentFilename(STR3), line_no); - } - if (startsWithIgnoreCase(buffer, "RESUME")) { - ignore_input = false; - another = true; - if (beVerbose()) - printf("-->> Resuming input file %s at line %d\n", - currentFilename(STR1), line_no); - } - if (startsWithIgnoreCase(buffer, "INCLUDE:")) { - predelete(buffer, 8); - NextWord(filename, buffer, ' ', ' '); - pushFile(filename); - another = true; - } - if (another) { - readLine(buffer); - line_no = currentLineNo(); - } - } while (another); - /* Normal paragraph input*/ - do { - if (*L < lines_in_paragraph) { - (*L)++; - strcpy(P[*L - 1], buffer); - *buffer = '\0'; - no[*L - 1] = line_no; - } else - warning("Paragraph too long: skipping line", !print); - readLine(buffer); - line_no = currentLineNo(); - if (debugMode()) - printf("%d >> %s\n", line_no, buffer); - } while (!isEmpty(buffer)); - skipBlanks(); /* needed to identify final paragraph */ -} - - - - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/files.h b/Build/source/utils/m-tx/mtx-0.60d/files.h deleted file mode 100644 index 66e978f78ca..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/files.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Header for module files, generated by p2c 1.21alpha-07.Dec.93 */ -#ifndef FILES_H -#define FILES_H - - -/* Open and close files, interpret command line, do input, do most output*/ - -#ifndef GLOBALS_H -#include "globals.h" -#endif - -#ifndef MULTFILE_H -#include "multfile.h" -#endif - - -#ifdef FILES_G -# define vextern -#else -# define vextern extern -#endif - -extern Void readParagraph PP((Char (*P)[256], short *no, paragraph_index0 *L)); -extern boolean styleFileFound PV(); -extern Void processOption PP((int j)); -extern Void OpenFiles PV(); -extern Void CloseFiles PV(); -extern Void putLine PP((Char *line)); -extern Void put PP((Char *line, int putspace_)); -extern Void tex3 PP((Char *s)); -extern boolean endOfInfile PV(); - - -#undef vextern - -#endif /*FILES_H*/ - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/files.pas b/Build/source/utils/m-tx/mtx-0.60d/files.pas deleted file mode 100644 index 8762f7e6e2d..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/files.pas +++ /dev/null @@ -1,196 +0,0 @@ -unit files; -{ Open and close files, interpret command line, do input, do most output} - -interface uses globals, multfile; - -procedure readParagraph (var P: paragraph; var no: line_nos; - var L: paragraph_index0); -function styleFileFound: boolean; -procedure processOption(j: char); -procedure OpenFiles; -procedure CloseFiles; -procedure putLine (line: string); -procedure put(line: string; putspace: boolean); -procedure tex3 (s: string); -function endOfInfile: boolean; - -implementation uses control, strings, utility; - -const param_leader = '-'; - stylefilename: string = 'mtxstyle.txt'; - -var teststyle: integer; - -function endOfInfile: boolean; - begin endOfInfile:=eofAll; end; - -procedure tex3 (s: string); - begin - if pmx_preamble_done then - if s[1]='%' then putLine(s) - else if first_paragraph then putLine('\'+s+'\') - else putLine('\\'+s+'\') - else putLine(s); - end; - -procedure putLine (line: string); - begin if outlen+length(line) > pmxlinelength-1 then writeln(outfile); - writeln(outfile,line); outlen:=0; - end; - -procedure put(line: string; putspace: boolean); - var l: integer; - begin l:=length(line); - if l>pmxlinelength then error('Item longer than PMX line length',print); - if outlen+l > pmxlinelength-1 then - begin putLine(''); put(line,false) end - else begin if putspace and (outlen>0) and (line[1]<>' ') then - line:=' '+line; - write(outfile,line); inc(outlen,l); - end - end; - -function styleFileFound: boolean; -begin styleFileFound := teststyle<>0; end; - -procedure helpmessage; -begin - writeln('Usage: prepmx [-bcfnhimtuvwDH0123456789] MTXFILE [TEXDIR] [STYLEFILE]') -end; - -procedure bighelpmessage; -begin helpmessage; writeln; - writeln('MTXFILE: name of .mtx file without its extension'); - writeln('TEXDIR: directory where the TeX file made by PMX goes, default is ./'); - writeln('STYLEFILE: name of a file containing style definitions. Default is'); - writeln(' mtxstyle.txt. This feature is now deprecated; use Include: STYLEFILE'); - writeln(' in the preamble of the .mtx file instead.'); - writeln('Options: (can also be entered separately: -b -c ...)'); - writeln(' -b: disable unbeamVocal'); - writeln(' -c: disable doChords'); - writeln(' -f: enable solfaNoteNames'); - writeln(' -h: display this message and quit'); - writeln(' -i: enable ignoreErrors'); - writeln(' -m: disable doLyrics'); - writeln(' -n: enable instrumentNames'); - writeln(' -t: disable doUptext'); - writeln(' -u: disable uptextOnRests'); - writeln(' -v: enable beVerbose'); - writeln(' -w: enable pedanticWarnings'); - writeln(' -D: enable debugMode'); - writeln(' -0123456789: select Case'); - writeln(' -H: print enabled status of all options'); - writeln('All the above, and some other, options can be enabled or disabled'); - writeln(' in the preamble. What you do there overrides what you do here.') -end; - -procedure processOption(j: char); - begin case j of - 'b': setFeature('unbeamVocal',false); - 'c': setFeature('doChords',false); - 'f': setFeature('solfaNoteNames',true); - 'h': begin bighelpmessage; halt(255) end; - 'i': setFeature('ignoreErrors',true); - 'm': setFeature('doLyrics',false); - 'n': setFeature('instrumentNames',true); - 't': setFeature('doUptext',false); - 'u': setFeature('uptextOnRests',false); - 'v': setFeature('beVerbose',true); - 'w': setFeature('pedanticWarnings',true); - 'D': setFeature('debugMode',true); - '0'..'9': choice:=j; - 'H': printFeatures(true); - else write(j); error(': invalid option',not print); - end; -end; - -procedure OpenFiles; -var i, j, l, fileid, testin: integer; - infilename, outfilename, basename, param, ext: string; - procedure checkExistingFile; - var tryfile: file; - begin -{$I-} - assign(tryfile,basename); reset(tryfile); testin := ioresult; -{$I+} - if testin<>0 then exit else close(tryfile); - writeln('There exists a file named ',basename,'. I am treating this'); - error(' as a fatal error unless you specify -i',not print); - end; -begin - fileid:=0; line_no:=0; paragraph_no:=0; - for i:=1 to ParamCount do - begin param:=ParamStr(i); - if param[1]=param_leader then - for j:=2 to length(param) do processOption(param[j]) - else if fileid=0 then fileid:=i - else if texdir='' then texdir:=param - else stylefilename:=param; - end; - if fileid=0 then - begin helpmessage; writeln('Try "prepmx -h" for more information.'); halt(255) end - else basename:=paramstr(fileid); - l:=length(basename); - if (l>4) and (basename[l-3]='.') then - begin ext:=substr(basename,l-2,3); toUpper(ext); if ext='MTX' then - begin warning('.mtx extension deleted from basename',not print); - shorten(basename,l-4); - end; - end; - if pos1('.',basename)>0 then checkExistingFile; - infilename := basename+'.mtx'; outfilename := basename+'.pmx'; -{$I-} - pushFile(infilename); - assign(outfile,outfilename); rewrite(outfile); - assign(stylefile,stylefilename); reset(stylefile); teststyle := ioresult; - if (teststyle<>0) and (stylefilename<>'mtxstyle.txt') then - writeln('Can''t read ',stylefilename); -{$I+} - if fileError then fatalError('Input file '+infilename+' not found'); - outfile_open := true; writeln('Writing to ',basename,'.pmx'); -end; - -procedure CloseFiles; -begin close(outfile); closeAll; if teststyle=0 then close(stylefile); -end; - -procedure readParagraph (var P: paragraph; var no: line_nos; - var L: paragraph_index0); - var another: boolean; - filename, buffer: string; -begin - L:=0; buffer:=readData; line_no:=currentLineNo; - if isEmpty(buffer) then exit; - if debugMode then writeln('>>>> ',buffer); - inc(paragraph_no); -{ Handle directives affecting the processing of the input file } - repeat another:=false; - if startsWithIgnoreCase(buffer,'SUSPEND') then - begin ignore_input:=true; another:=true; if beVerbose then - writeln('-->> Suspending input file ',currentFilename, - ' at line ', line_no); - end; - if startsWithIgnoreCase(buffer,'RESUME') then - begin ignore_input:=false; another:=true; if beVerbose then - writeln('-->> Resuming input file ',currentFilename, - ' at line ', line_no); - end; - if startsWithIgnoreCase(buffer,'INCLUDE:') then - begin predelete(buffer,8); filename:=nextWord(buffer,' ',' '); - pushfile(filename); another:=true; - end; - if another then begin buffer:=readLine; line_no:=currentLineNo; end; - until not another; -{ Normal paragraph input} - repeat - if L> ', buffer); - until isEmpty(buffer); - skipBlanks; { needed to identify final paragraph } -end; - -end. diff --git a/Build/source/utils/m-tx/mtx-0.60d/globals.c b/Build/source/utils/m-tx/mtx-0.60d/globals.c deleted file mode 100644 index eba3ab3e00d..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/globals.c +++ /dev/null @@ -1,348 +0,0 @@ -/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ -/* From input file "globals.pas" */ - - -#include "p2c.h" - - -#define GLOBALS_G -#include "globals.h" - - -Char double_comment[3] = "%%"; -Char durations[ndurs + 1] = "90248136"; -Char terminators[256] = ".x"; -Char has_duration[9] = "abcdefgr"; -Char solfa_names[8] = "drmfslt"; -Char choice = ' '; -boolean outfile_open = false; -Char texdir[256] = ""; -Char old_meter_word[256] = ""; -short outlen = 0; -boolean ignore_input = false; - -#ifndef STRINGS_H -#include "strings.h" -#endif - -#ifndef CONTROL_H -#include "control.h" -#endif - -#ifndef UTILITY_H -#include "utility.h" -#endif - - -boolean isNoteOrRest(w) -Char *w; -{ - return (pos1(w[0], has_duration) > 0); -} - - -boolean isPause(note) -Char *note; -{ - return (startsWith(note, pause)); -} - - -Void cancel(num, denom, lowest) -short *num, *denom, lowest; -{ - while (((*num) & 1) == 0 && *denom > lowest) { - *num /= 2; - *denom /= 2; - } -} - - -Char *meterWord(Result, num, denom, pnum, pdenom) -Char *Result; -short num, denom, pnum, pdenom; -{ - Char STR1[256], STR2[256], STR4[256], STR5[256]; - - sprintf(Result, "m%s/%s/%s/%s", - toString(STR1, num), toString(STR2, denom), toString(STR4, pnum), - toString(STR5, pdenom)); - return Result; -} - - -Char *meterChange(Result, n1, n2, blind) -Char *Result; -short n1, n2; -boolean blind; -{ - short f = 64; - short l; - - if (!blind) - return (meterWord(Result, n1, PMXmeterdenom(n2), 0, 0)); - /* CMO: process denominator value with function PMXmeterdenom */ - l = n1 * (64 / n2); - cancel(&l, &f, meterdenom); - /* CMO: process denominator value with function PMXmeterdenom */ - meterWord(Result, l, PMXmeterdenom(f), 0, 0); - if (meternum > 0) - printf("Blind meter change to %d/%d on line %d\n", l, f, line_no); - return Result; -} - - -Void setSpace(line_) -Char *line_; -{ - Char line[256]; - short i = 0; - Char word[256]; - - strcpy(line, line_); - while (i < ninstr) { - GetNextWord(word, line, blank, dummy); - if (*word == '\0') - return; - i++; - getNum(word, &nspace[i-1]); - } -} - - -Static Void onumber(s, j, n1) -Char *s; -short *j, *n1; -{ - if (s[*j - 1] == 'o') - *n1 = 1; - else if (s[*j - 1] == '1') { - *n1 = digit(s[*j]) + 10; - (*j)++; - } else - *n1 = digit(s[*j - 1]); - (*j)++; -} - - -Static Void extractNumber(s, k) -Char *s; -short *k; -{ - Char w[256]; - - GetNextWord(w, s, '/', dummy); - getNum(w, k); -} - - -Static Void readMeter(meter_, meternum, meterdenom, pmnum, pmdenom) -Char *meter_; -short *meternum, *meterdenom, *pmnum, *pmdenom; -{ - Char meter[256]; - short j; - - strcpy(meter, meter_); - if (meter[0] == 'm') { - if (pos1('/', meter) == 0) { - j = 2; - onumber(meter, &j, meternum); - onumber(meter, &j, meterdenom); - onumber(meter, &j, pmnum); - onumber(meter, &j, pmdenom); - return; - } - predelete(meter, 1); - extractNumber(meter, meternum); - extractNumber(meter, meterdenom); - extractNumber(meter, pmnum); - extractNumber(meter, pmdenom); - return; - } - getTwoNums(meter, meternum, meterdenom); - *pmnum = *meternum; - *pmdenom = *meterdenom; -} - - -Void getMeter(line_, meternum, meterdenom, pmnum, pmdenom) -Char *line_; -short *meternum, *meterdenom, *pmnum, *pmdenom; -{ - Char line[256]; - Char meter[256]; - Char STR1[256]; - - strcpy(line, line_); - GetNextWord(meter, line, blank, dummy); - if (!strcmp(meter, "C/") || !strcmp(meter, "mC/")) { - *meternum = 2; - *meterdenom = 2; - *pmdenom = 5; - *pmnum = 0; - } else if (!strcmp(meter, "C") || !strcmp(meter, "mC")) { - *meternum = 4; - *meterdenom = 4; - *pmdenom = 6; - *pmnum = 0; - } else - readMeter(meter, meternum, meterdenom, pmnum, pmdenom); - if (*meterdenom == 0) { - sprintf(STR1, "%s: Meter denominator must be nonzero", meter); - error(STR1, print); - } - /* CMO: Convert PMX syntax meter denominator '0' to '1' to be used for - prepmx duration checks */ - /* if meterdenom=0 then meterdenom:=1; */ -} - - -Static short whereInParagraph(l) -short l; -{ - short Result = 0; - short j, FORLIM; - - FORLIM = para_len; - for (j = 1; j <= FORLIM; j++) { - if (orig_line_no[j-1] == l) - return j; - } - return Result; -} - - -Void fatalerror(message) -Char *message; -{ - setFeature("ignoreErrors", false); - error(message, !print); -} - - -Void error(message, printLine) -Char *message; -boolean printLine; -{ - short j; - - printf("%s: ERROR on line %d\n", message, line_no); - j = whereInParagraph(line_no); - if (j > 0 && printLine) - puts(P[j-1]); - if (ignoreErrors()) - return; - if (outfile_open) { - if (outfile != NULL) - fclose(outfile); - outfile = NULL; - outfile = fopen(outfile_NAME, "wb"); - if (outfile == NULL) - _EscIO2(FileNotFound, outfile_NAME); - fclose(outfile); - outfile = NULL; - } - if (line_no == 0) - line_no = 10000; - _Escape(line_no); -} - - -Void warning(message, printLine) -Char *message; -boolean printLine; -{ - short j; - - if (line_no <= 0) { - printf("%s: WARNING in preamble\n", message); - return; - } - printf("%s: WARNING on line %d\n", message, line_no); - if (!printLine) - return; - j = whereInParagraph(line_no); - if (j > 0) - puts(P[j-1]); -} - - -short PMXinstr(stave) -short stave; -{ - return (ninstr - instr[stave-1] + 1); -} - - -Void setDefaultDuration(meterdenom) -short meterdenom; -{ - switch (meterdenom) { - - case 1: - default_duration = '0'; - break; - - case 2: - default_duration = '2'; - break; - - case 4: - default_duration = '4'; - break; - - case 8: - default_duration = '8'; - break; - - case 16: - default_duration = '1'; - break; - - case 32: - default_duration = '3'; - break; - - case 64: - default_duration = '6'; - break; - } -} - - -short PMXmeterdenom(denom) -short denom; -{ - short Result; - - /* CMO: Convert M-Tx meter denominators to PMX syntax */ - switch (denom) { - - case 1: - Result = 0; - break; - - case 16: - Result = 1; - break; - - case 32: - Result = 3; - break; - - case 64: - Result = 6; - break; - - default: - Result = denom; - break; - } - return Result; -} - - - - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/globals.h b/Build/source/utils/m-tx/mtx-0.60d/globals.h deleted file mode 100644 index 1e0988edf25..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/globals.h +++ /dev/null @@ -1,154 +0,0 @@ -/* Header for module globals, generated by p2c 1.21alpha-07.Dec.93 */ -#ifndef GLOBALS_H -#define GLOBALS_H - - -#ifdef GLOBALS_G -# define vextern -#else -# define vextern extern -#endif - - -/* 1. All global variables. - 2. Miscellaneous other procedures required by several Units. -*/ - -/* CMO: addition/change by Christian Mondrup */ - - -#define PMXlinelength 128 -/* !!! One or more of the following constants should be reduced if this - program is to be compiled by a 16-bit compiler (e.g. Turbo Pascal), - otherwise you get a "Data segment too large" error */ -#define lines_in_paragraph 100 -#define max_words 128 -#define max_notes 128 -/* Christian Mondrup's suggestion to reduce data segment size: - lines_in_paragraph = 50; - max_words = 64; - max_notes = 64; -*/ -#define max_bars 16 -#define maxstaves 15 -#define maxvoices 15 -#define maxgroups 3 -#define standardPMXvoices 12 - -#define max_lyrics_line_length (PMXlinelength - 4) - -#define inf 32000 -#define unspec 1000 -#define default_size 20 - -#define start_beam '[' -#define stop_beam ']' -#define rest 'r' - -#define pause "rp" - -#define dotcode 'd' -#define grace_group 'G' -#define multi_group 'x' -#define barsym '|' -#define comment '%' -#define blank ' ' -#define dot '.' -#define comma ',' -#define colon ':' -#define tilde '~' -#define atsign '@' -#define dummy '\0' - -#define ndurs 8 - -#define unspecified '5' /* Not a valid duration */ - -#define whole 2 /* position of '0' in durations */ - -#define digits "123456789" -#define digitsdot "0123456789." - -#define putspace true -#define nospace false -#define print true - - -typedef char paragraph_index; - -typedef char voice_index; - -typedef char stave_index; - -typedef char bar_index0; - -typedef uchar word_index0; - -typedef char paragraph_index0; - -typedef char voice_index0; - -typedef char stave_index0; - -typedef Char paragraph[lines_in_paragraph][256]; -typedef short line_nos[lines_in_paragraph]; - - -extern Char double_comment[3]; -extern Char durations[ndurs + 1]; -extern Char terminators[256]; -extern Char has_duration[9]; -extern Char solfa_names[8]; - -extern Char choice; -extern boolean outfile_open; -extern Char texdir[256]; -extern Char old_meter_word[256]; -extern short outlen; -extern boolean ignore_input; -vextern Char voice_label[maxvoices][256]; -vextern Char clef[maxstaves]; -vextern voice_index0 instr[maxstaves], stave[maxstaves], - first_on_stave[maxstaves], number_on_stave[maxstaves]; -vextern short nspace[maxstaves], stave_size[maxstaves]; -vextern voice_index0 nvoices, nstaves, ninstr, bottom, top; -vextern short one_beat, full_bar, line_no, short_note, musicsize, meternum, - meterdenom, pmnum, pmdenom, paragraph_no, bar_no, pickup, nbars, - nleft; -vextern paragraph_index0 para_len; -vextern double xmtrnum0; -vextern paragraph P; -vextern line_nos orig_line_no; -vextern FILE *infile, *outfile, *stylefile; -vextern Char default_duration; -vextern Char fracindent[256], this_version[256], this_version_date[256]; -vextern boolean pmx_preamble_done, first_paragraph, final_paragraph, - must_respace, must_restyle, multi_bar_rest, some_vocal; -vextern Char infile_NAME[_FNSIZE]; -vextern Char outfile_NAME[_FNSIZE]; -vextern Char stylefile_NAME[_FNSIZE]; - - -extern Void error PP((Char *message, int printLine)); -extern Void fatalerror PP((Char *message)); -extern Void warning PP((Char *message, int printLine)); -extern short PMXinstr PP((int stave)); -extern Void setDefaultDuration PP((int meterdenom)); -extern Void getMeter PP((Char *line, short *meternum, short *meterdenom, - short *pmnum, short *pmdenom)); -extern Void setSpace PP((Char *line)); -extern Char *meterChange PP((Char *Result, int n1, int n2, int blind)); -extern Char *meterWord PP((Char *Result, int num, int denom, int pnum, - int pdenom)); -extern Void cancel PP((short *num, short *denom, int lowest)); -extern boolean isNoteOrRest PP((Char *w)); -extern boolean isPause PP((Char *note)); -/* CMO: */ -extern short PMXmeterdenom PP((int denom)); - - -#undef vextern - -#endif /*GLOBALS_H*/ - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/globals.pas b/Build/source/utils/m-tx/mtx-0.60d/globals.pas deleted file mode 100644 index ad53376438f..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/globals.pas +++ /dev/null @@ -1,247 +0,0 @@ -unit globals; - -{ 1. All global variables. - 2. Miscellaneous other procedures required by several Units. -} - -interface - -const PMXlinelength = 128; -{ !!! One or more of the following constants should be reduced if this - program is to be compiled by a 16-bit compiler (e.g. Turbo Pascal), - otherwise you get a "Data segment too large" error } - lines_in_paragraph = 100; - max_words = 128; - max_notes = 128; -{ Christian Mondrup's suggestion to reduce data segment size: - lines_in_paragraph = 50; - max_words = 64; - max_notes = 64; -} - max_bars = 16; - maxstaves = 15; - maxvoices = 15; - maxgroups = 3; - standardPMXvoices = 12; - max_lyrics_line_length = PMXlinelength-4; - inf = 32000; - unspec = 1000; - default_size = 20; - - start_beam = '['; - stop_beam = ']'; - rest = 'r'; - pause = 'rp'; - dotcode = 'd'; - grace_group = 'G'; - multi_group = 'x'; - barsym = '|'; - comment = '%'; - double_comment: string[2] = '%%'; - blank = ' '; - dot = '.'; - comma = ','; - colon = ':'; - tilde = '~'; - atsign = '@'; - dummy = #0; - - ndurs = 8; - durations: string[ndurs] = '90248136'; - unspecified = '5'; { Not a valid duration } - whole = 2; { position of '0' in durations } - terminators: string = '.x'; - digits = '123456789'; - digitsdot = '0123456789.'; - has_duration: string[8] = 'abcdefgr'; - solfa_names: string[7] = 'drmfslt'; - - choice: char = ' '; - outfile_open: boolean = false; - texdir: string = ''; - old_meter_word: string = ''; - outlen: integer = 0; - putspace = true; - nospace = false; - ignore_input: boolean = false; - print = true; - -type - paragraph_index = 1..lines_in_paragraph; - voice_index = 1..maxvoices; - stave_index = 1..maxstaves; - bar_index0 = 0..max_bars; - word_index0 = 0..max_words; - paragraph_index0 = 0..lines_in_paragraph; - voice_index0 = 0..maxvoices; - stave_index0 = 0..maxstaves; - paragraph = array[paragraph_index] of string; - line_nos = array[paragraph_index] of integer; - -var voice_label: array[voice_index] of string; - clef: array[stave_index] of char; - instr, stave, first_on_stave, number_on_stave: - array[stave_index] of voice_index0; - nspace, stave_size: array[stave_index] of integer; - nvoices, nstaves, ninstr, bottom, top: voice_index0; - one_beat, full_bar, line_no, short_note, musicsize, - meternum, meterdenom, pmnum, pmdenom, paragraph_no, - bar_no, pickup, nbars, nleft: integer; - para_len: paragraph_index0; - xmtrnum0: real; - P: paragraph; - orig_line_no: line_nos; - infile, outfile, stylefile: text; - default_duration: char; - fracindent, this_version, this_version_date: string; - pmx_preamble_done, first_paragraph, final_paragraph, must_respace, - must_restyle, multi_bar_rest, some_vocal: boolean; - -procedure error(message: string; printLine: boolean); -procedure fatalerror(message: string); -procedure warning(message: string; printLine: boolean); -function PMXinstr (stave: integer): integer; -procedure setDefaultDuration(meterdenom: integer); -procedure getMeter(line: string; - var meternum, meterdenom, pmnum, pmdenom: integer); -procedure setSpace(line: string); -function meterChange(n1, n2: integer; blind: boolean): string; -function meterWord (num, denom, pnum, pdenom: integer): string; -procedure cancel(var num,denom: integer; lowest: integer); -function isNoteOrRest(w: string): boolean; -function isPause(note: string): boolean; - -implementation uses strings, control, utility; - -function isNoteOrRest(w: string): boolean; -begin isNoteOrRest := pos1(w[1],has_duration)>0; end; - -function isPause(note: string): boolean; -begin isPause:=startsWith(note,pause); end; - -procedure cancel(var num,denom: integer; lowest: integer); -begin while (num mod 2 = 0) and (denom>lowest) do - begin num:=num div 2; denom:=denom div 2; end; -end; - -function meterWord (num,denom,pnum,pdenom: integer): string; -begin meterWord := 'm' + toString(num) + '/' + toString(denom) + - '/' + toString(pnum) + '/' + toString(pdenom); -end; - -function meterChange(n1, n2: integer; blind: boolean): string; - var f, l: integer; -begin - if blind then - begin f:=64; l:=n1 * (64 div n2); - cancel(l,f,meterdenom); meterChange := meterWord (l,f,0,0); - if meternum>0 then - writeln('Blind meter change to ', l, '/', f, ' on line ', line_no); - end - else meterChange := meterWord(n1,n2,0,0); -end; - -procedure setSpace(line: string); - var i: integer; - word: string; - begin i:=0; - while i0) and printline then writeln(P[j]); - if not ignoreErrors then - begin if outfile_open then - begin close(outfile); rewrite(outfile); close(outfile); end; - if line_no=0 then line_no:=10000; - halt(line_no); - end; -end; - -procedure warning(message: string; printline: boolean); - var j: integer; -begin - if line_no>0 then - begin writeln (message, ': WARNING on line ', line_no); - if not printline then exit; - j:=whereInParagraph(line_no); if j>0 then writeln(P[j]) - end - else writeln (message, ': WARNING in preamble'); -end; - -function PMXinstr (stave: integer): integer; -begin PMXinstr := ninstr + 1 - instr[stave]; end; - -procedure setDefaultDuration(meterdenom: integer); -begin - case meterdenom of - 1: default_duration:='0'; - 2: default_duration:='2'; - 4: default_duration:='4'; - 8: default_duration:='8'; - 16: default_duration:='1'; - 32: default_duration:='3'; - 64: default_duration:='6'; - end; -end; - -end. diff --git a/Build/source/utils/m-tx/mtx-0.60d/libp2c/COPYING b/Build/source/utils/m-tx/mtx-0.60d/libp2c/COPYING deleted file mode 100644 index e77696ae8dd..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/libp2c/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/Build/source/utils/m-tx/mtx-0.60d/libp2c/ChangeLog b/Build/source/utils/m-tx/mtx-0.60d/libp2c/ChangeLog deleted file mode 100644 index 17e4bc2dbc5..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/libp2c/ChangeLog +++ /dev/null @@ -1,390 +0,0 @@ -Wed Mar 10 15:03:20 1999 Alexander L. Belikoff - - * src/p2c.h: DOUBLE defined as double - -Tue Mar 31 14:57:26 1998 Alexander L. Belikoff - - * src/trans.h: - Magic limits (MININT, MAXINT), causing random p2c bugs on the Alpha replaced - with LONG-MIN/MAX from limits.h (integers in Pascal include longs in C, - according to p2c) - -Tue Sep 23 09:14:22 1997 Harvey J. Stein - - * src/p2c.proto, src/funcs.c, src/p2c.hdrs: - Adjustments to get pad to work correctly. - -Thu Jul 3 20:41:55 1997 Harvey J. Stein - - * src/p2c.proto, src/sys.p2crc, src/trans.h, src/expr.c, src/funcs.c, src/p2c.hdrs: - Bug: Consider: - - procedure foo(x: array[i..j : integer] of varying[k] of char); - ... - var z : array[3..12] of varying[20] of char; - ... - foo(z); - - This should become something like: - - foo(int i, int j, int k, char x[j-i+1][k]) - ... - char z[10][20]; - ... - foo(3, 12, 20, z); - - Instead, it was generating: - - foo(3, 12, 255, z); - - which totally screws up accessing z. - - Analysis: To do this correctly, p2c has to keep dereferencing z as it - processes the hidden arguments i, j, & k so that it's working on an - expression of the appropriate type each time it tries to find either - the size of the string or the start & end points of arrays. Instead, - it just wasn't. - - Fix done: I couldn't figure out exactly how to do the above. But, p2c - calls strmax_func to get the length of the character string. I just - built some additional dereferencing into it so that it gets the - correct length in the above sort of situation. So, changed - strmax_func in expr.c. - - - Bug: Index(x,y) is a common pascal extension for finding a substring - in a string. p2c handles it but it wasn't working right on Dec code. - - Analysis: Some dialects of pascal consider x to be the string and y - to be the substring. Others switch x & y. p2c supports (substring, - string), and Dec pascal supports the opposite. - - Fix: There was some support for switching index argument order, but it - was tightly coupled to HP compiler directive support. I added a - comment switch ("IndexOrder") for additional control of this feature. - Changed func_strpos in funcs.c, and added the switch in trans.h. - -Fri Jun 13 07:22:26 1997 Harvey J. Stein - - * src/p2c.hdrs, src/p2c.proto, src/pexpr.c, src/decl.c, src/funcs.c: - Fixed bug in [truncate] handling - I didn't clear the new Meaning - fields (fakenumargs & truncated) at meaning creation time, so they - were sometimes showing up on non-truncated variables. Changed - initmeaning (decl.c). - - Moved hidden number_of_args from beginning to end of arg list. At the - beginning it was interfering with the return hidden variable, - causing return to not be generated. Changes were in p_funcdecl - (decl.c), func_present (funcs.c), and p_funcarglist (pexpr.c). Added - has_truncate function to pexpr.c to check whether an arg list has the - truncated attribute. - - Argument variables were sometimes getting shadowed just because - they're initialized. Problem was in var_reference, which clones - Meanings that have constdefns. But arg variables don't need to be - cloned since the constants are handled by p_funcarglist. So skipped - cloning if Meaning's kind is MK_PARAM or MK_VARPARAM. Previous fix of - always cloning, but only copying meanings if not MK_PARAM seems to - have been incorrect. - -Sun Jun 1 13:15:06 1997 Harvey J. Stein - - * src/sys.p2crc, src/trans.h, src/pexpr.c, src/parse.c, src/lex.c, src/p2c.hdrs, src/p2c.proto, src/funcs.c, src/decl.c: - Enhancements: - - Added support for [truncate]. This involved: - 1. Added a truncated flag & a fakenumargs flag to the Meaning - structure. - 2. In p_funcdecl (decl.c), recognizing the [truncate] attribute in - argument lists. If it's seen, the argument's truncated flag is - set, and it and all arguments following are given default values - (assuming that they don't already have default values). The - default values gets p2c to automatically generate the correct - number of arguments for calling the subroutine when some are - left out. - 3. In p_funcdecl (decl.c), if any of the args are tagged with - [truncate], then add a hidden argument to the front of the - argument list - number_of_args. Flag it with fakenumargs. - 4. In p_funcarglist (pexpr.c), when the fcn has a fakenumargs - parameter as the first parameter, (and truncateisdefalt is zero) - compute the index of the last argument supplied, and pass it as - the first argument in the call. - 5. In funcs.c, added func_present to handle the PRESENT(x) calls. - It parses the call, figures out the index of the argument in the - fcns calling sequence (say n), and generates an expression - (number_of_args >= n) to be the output for the PRESENT(x) call. - 6. Added new config parameter - TruncateIsDefault to turn off - PRESENT support (in case one doesn't want the extra arg to be - generated). - - Added support for CONTINUE & BREAK. Just had to basically declare - them as keywords in lex.c, and recognize them in parse.c, and declare - their tokens in trans.h (since p2c already supported them internally). - - Added descriptions for SkipReIncludes, NoOutput, and TruncateIsDefault - to sys.p2crc. - - Bug fixes: - - Bug: args with default values which are also used in local functions - lose their default values. - - Attempted fix: in var_reference (pexpr.c), don't zero out the - constdefn when the arg is cloned if the arg is a parameter. - - Problems: This works, but it sometimes causes bogus declarations of - the old variable to be output. - -Wed May 14 14:27:32 1997 Harvey J. Stein - - * src/stuff.c, src/p2c.hdrs, src/p2c.proto, src/out.c, src/expr.c, p2c.patch: - (Updated p2c.patch for last set of changes) - - Bug: p2c was seg faulting when given expressions such as: - there := - '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' + - '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' + - '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' + - '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' + - '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; - - and: - - there := - '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' + - '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' + - '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' + - '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' + where; - - when there is VARYING [XXX] OF CHAR; - - Analysis: There seem to be all sorts of fixed length character arrays - around the code. It seems that especially long expressions and/or - character strings can cause them to overflow. - - Fix: I upped some of the limits, which at least avoided core dumps on - the code I'm currently processing, but really one needs to go through - and properly keep track of the amount copied into strings so as to - avoid buffer overruns. But, this is a real pain in the ass because of - the shitty semantics of the standard C library. - - Basically, the stack allocated ones that I noticed in expr.c and out.c - I upped to length 2000, and in stuff.c, I upped the size of the - strings in formatbuf[] to 4000. - -Tue May 13 19:27:00 1997 Harvey J. Stein - - * src/lex.c, src/p2c.hdrs, src/p2c.proto, src/trans.c, src/Makefile, src/decl.c, src/expr.c, src/funcs.c: - Minor fixes/changes: - -Was calling close in handle_include (lex.c) when it should have - been fclose. - -Modified src/Makefile to allow for using insure on the source code - (to catch memory bugs). - - - Major fixes: - - Bug: p2c occasionally was freeing memory that was already freed. - - Analysis: This seems to occur sometimes on constant string - definitions because mp->val.s might point to the same string as - mp->constdefn->val.s, and forget_ctx tries to free them both. - - Fix: In decl.c, in forget_ctx: After calling free_value(&mp->val) when - mp->kind == MK_CONST, instead of always calling - freexpr(mp->constdefn), only call it when mp->kind != MK_CONST, - or when mp->constdefn->val.s != mp->val.s. - - I also tried to fix this by copying mp->val.s in p_constdecl when - creating mp->constdefn->val.s, but never got this to work - correctly, so I commented it out. - - - Bug: p2c core dumped on: - - readv(data, short_string); - - when data is a packed array[1..7] of char, and - short_string is a packed array[1..3] of char. - - Analysis: What was happening was that in handleread_text (funcs.c), - when the readv argument is an array, it was checking - ord_range(ex->val.type->indextype, ...), and ex was NULL. - - Fix: It seems like this was a typo, so I change it to check - var->... instead of ex->... - - - Bug: p2c core dumped on: - - WRITELN('%SQLMOD ', msg); - - when msg was of type varying[x] of char. - - Analysis: Some part of the code was converting the above string to - "%%SQLMOD %s". It seems that cleansprintf (from expr.c) didn't - realize that % is escaped by %%, so it thought that there should - be 2 arguments (maybe 3?) for the above printf string instead of - one, and thus was going off of the end of the args list (i.e. - - ex->args[j] out of range). - - Fix: Inside the for loop, if the next character is also a %, then - skip arg processing, and skip the next character (just copy it - into fmtbuf). - - - Bug: p2c core dumps on: - - readv(c, i); - - when c is a char and i is an integer. - - Analysis: In funcs.c, in handleread_text, var is never getting - initialized - it's getting passed in as NULL, and it only gets - set if isstrread is true. Since c is a char, fex->val.type->kind - is TK_CHAR, not TK_STRING, so isstrread is false, so var fails to - get initialized. - - Fix: After the case that var is set when isstrread is true, if it's - still NULL, we set it to p_expr(NULL). This prevents the core - dump, but produces incorrect code! It outputs: - - fscanf(c, "%ld", &i); - - when it should more likely be something along the lines of - sscanf(&c, ...) (but safer). - -Mon May 5 15:23:04 1997 Harvey J. Stein - - * src/out.c, src/p2c.hdrs, src/p2c.proto, src/trans.h, src/decl.c, src/lex.c, p2c.patch: - New features (out.c, trans.h): - New parameter NoOutput - setting it to 1 stops p2c from generating - output. Useful when trying to simulate Dec style modules via - include files - just convert INHERIT to %include, and put - {*NoOutput=1} at the top of each include file, and p2c does the - right thing. This was done by not pushing characters into the - output stream when nooutput is 1. The real code changes occur in - out.c, in putc_outf, and puts_outf. Accumulating the output, but - turning off writes (i.e. - wiring it into flush_outfilebuf) failed - because of timing differences btw when comment directives are - processed and when output occurs. - - Bug fixes: - - Bug: Some variable declarations weren't getting output. Most - noticable were the automatically generated Return variables. - - Analysis: When using the {INTF-ONLY} directive in include files - then the fwd declaration of fcns was being interpreted as the fcn - definition, and so the variables generated when the declaration was - seen were marked as "wasdeclared". Then, when the code for the - function was being generated, these variables weren't getting - output because "wasdeclared" was 1. This was most visible from the - automatically generated Return variable, but occasionally happened - to other variables. - - Fix: in decl.c:activatemeaning - added resetting of "wasdeclared" - if we can identify that the variable is the autogenerated return - variable. Detected them by snarfing code from isretvar. But this - was a lousy fix because as mentioned above, there are other - variables which are occasionally affected. And, it's no longer - needed because of the new NoOutput feature, so I commented out the - change, but left the code there as a reminder of the problem. - - - Bug: Comments weren't getting output in the correct places. This - is a serious problem when using {EMBED comments to insert C code - into the output stream. Sometimes code from the {EMBED comment - given in an include file showed up in the includer. Sometimes the - code didn't get emitted at all because of mistiming against - {nooutput} directives. - - Analysis: p2c builds up a comment string structure as it parses - the code, and hangs it off of the code's internal representation. - Presumably this is so that when doing code transformations, the - comments are output in the correct places. However, this seems to - sometimes fail when using %include files. It seems that the - comments weren't getting processed & output until the current block - was finished. Included files don't start a new block because one - could conceivably include random snippets of code anywhere you want - (inside of RECORD declarations, for example). Thus, sometimes - comments from inside the include file don't get processed & output - until well after the include file itself is finished being - processed. - - Fix: Added the call flushcomments(NULL, -1, -1) to both push_input - and pop_input (in lex.c). This seems to have fixed it with no - noticable side effects. - -Tue Apr 29 18:36:51 1997 Harvey J. Stein - - * src/p2c.hdrs, src/p2c.proto, src/lex.c: - Added recognition of AND_THEN and OR_ELSE. - - * src/trans.h, src/lex.c, src/p2c.hdrs, src/p2c.proto: - Added tracking of files that have been included so that they can - optionally be ignored the second time they're seen. This is needed - because a module (say X) can inherit from two other modules (say Y and - Z), both of whom inherit from a fourth module (say Z). Converting the - inherits to includes thus gets Z included twice. If it's not ignored, - it causes p2c to start renaming procedures so as to avoid name - clashes. - - Added an rc file parameter (skipreincludes) for controling the above - action. - - * src/decl.c, src/p2c.hdrs, src/p2c.proto, src/parse.c: - Various adjustments & bug fixes suggested by Dave Gillespie: - - decl.c: Call format_s so that we work with a copy of the string - when removing dollar signs - a little more robust. - - Missing ! on strcicmp caused bogus externs to be emitted on - some variable declarations. - - parse.c: Sprinkle afew p_attributes around p_block so that p2c - properly parses attributes in front of declaration blocks. - In particular, this fixes the problem where p2c was choking - on [hidden] followed by TYPE, which appears in analytic.pas. - -Wed Apr 23 12:17:08 1997 Harvey J. Stein - - * src/p2c.proto, src/decl.c, src/p2c.hdrs: - Modified addfield so that it removes dollar signs from record field - identifiers. This is more consistent with the handling of other - identifiers, and also needed by much of the Pascal code. - -Mon Apr 21 10:41:53 1997 Harvey J. Stein - - * p2c.patch: Submitted new patch to Dave G. - - * src/p2c.proto, src/lex.c, src/p2c.cat, src/p2c.hdrs, src/Makefile: - Changed VALUE from a keyword to a possible keyword when working with - Dec Pascal code. Original code set it to be a keyword for Dec, and a - possible keyword otherwise. However, if it's a keyword, then p2c - doesn't accept it the name of a slot in a record. Since Dec accepts - this usage, I figured that VALUE should always be a possible keyword - instead of a keyword. - -Thu Apr 17 11:33:22 1997 Harvey J. Stein - - * p2c.patch: patches generated & mailed to Dave Gillespie - -Wed Apr 16 16:26:07 1997 Harvey J. Stein - - * src/p2c.hdrs, src/p2c.proto, .cvsignore, examples/.cvsignore, src/.cvsignore, src/decl.c, src/p2c.cat: - Parser didn't expect a ( after the OTHERWISE keyword. Modified - decl.c to expect it. - - * src/INSTALL, src/citmods.c, src/comment.c, src/decl.c, src/dir.c, src/expr.c, src/funcs.c, src/hpmods.c, src/lex.c, src/loc.p2clib.c, src/loc.p2crc, src/makeproto.c, src/out.c, src/p2c.cat, src/p2c.h, src/p2c.hdrs, src/p2c.proto, src/p2cc.cat, src/p2cc.man, src/p2cc.perl, src/p2clib.c, src/parse.c, src/pexpr.c, src/string.pas, src/system.imp, src/system.m2, src/trans.h, src/turbo.imp: - Import of p2c 1.21alpha2 - - * src/INSTALL, src/citmods.c, src/comment.c, src/decl.c, src/dir.c, src/expr.c, src/funcs.c, src/hpmods.c, src/lex.c, src/loc.p2clib.c, src/loc.p2crc, src/makeproto.c, src/out.c, src/p2c.cat, src/p2c.h, src/p2c.hdrs, src/p2c.proto, src/p2cc.cat, src/p2cc.man, src/p2cc.perl, src/p2clib.c, src/parse.c, src/pexpr.c, src/string.pas, src/system.imp, src/system.m2, src/trans.h, src/turbo.imp: - Initial revision - - * HP/import/asm.imp, HP/import/fs.imp, HP/import/general_0.imp, HP/import/general_1.imp, HP/import/general_2.imp, HP/import/general_3.imp, HP/import/general_4.imp, HP/import/hpib_0.imp, HP/import/hpib_1.imp, HP/import/hpib_2.imp, HP/import/hpib_3.imp, HP/import/iodecl.imp, HP/import/misc.imp, HP/import/rnd.imp, HP/import/sysdevs.imp, HP/import/sysglobals.imp, HP/include/asm.h, HP/include/fs.h, HP/include/general_0.h, HP/include/general_1.h, HP/include/general_2.h, HP/include/general_3.h, HP/include/general_4.h, HP/include/hpib_0.h, HP/include/hpib_1.h, HP/include/hpib_2.h, HP/include/hpib_3.h, HP/include/iodecl.h, HP/include/misc.h, HP/include/rnd.h, HP/include/sysdevs.h, HP/include/sysglobals.h, Makefile, README, examples/Makefile, examples/README, examples/basic.doc, examples/basic.p, examples/c/basic.c, examples/c/cref.c, examples/c/e.c, examples/c/fact.c, examples/c/self.c, examples/cref.p, examples/e.p, examples/fact.p, examples/p2crc, examples/self.p, ftp.README, src/COPYING, src/HISTORY, src/Makefile, src/NOTES, src/README, src/p2c.man, src/stuff.c, src/sys.p2crc, src/trans.c: - Import of p2c 1.21alpha2 - - * HP/import/asm.imp, HP/import/fs.imp, HP/import/general_0.imp, HP/import/general_1.imp, HP/import/general_2.imp, HP/import/general_3.imp, HP/import/general_4.imp, HP/import/hpib_0.imp, HP/import/hpib_1.imp, HP/import/hpib_2.imp, HP/import/hpib_3.imp, HP/import/iodecl.imp, HP/import/misc.imp, HP/import/rnd.imp, HP/import/sysdevs.imp, HP/import/sysglobals.imp, HP/include/asm.h, HP/include/fs.h, HP/include/general_0.h, HP/include/general_1.h, HP/include/general_2.h, HP/include/general_3.h, HP/include/general_4.h, HP/include/hpib_0.h, HP/include/hpib_1.h, HP/include/hpib_2.h, HP/include/hpib_3.h, HP/include/iodecl.h, HP/include/misc.h, HP/include/rnd.h, HP/include/sysdevs.h, HP/include/sysglobals.h, Makefile, README, examples/Makefile, examples/README, examples/basic.doc, examples/basic.p, examples/c/basic.c, examples/c/cref.c, examples/c/e.c, examples/c/fact.c, examples/c/self.c, examples/cref.p, examples/e.p, examples/fact.p, examples/p2crc, examples/self.p, ftp.README, src/COPYING, src/HISTORY, src/Makefile, src/NOTES, src/README, src/p2c.man, src/stuff.c, src/sys.p2crc, src/trans.c: - Initial revision - diff --git a/Build/source/utils/m-tx/mtx-0.60d/libp2c/Makefile.am b/Build/source/utils/m-tx/mtx-0.60d/libp2c/Makefile.am deleted file mode 100644 index fd208029eef..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/libp2c/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -noinst_LIBRARIES = libp2c.a -libp2c_a_SOURCES = p2c.h p2clib.c diff --git a/Build/source/utils/m-tx/mtx-0.60d/libp2c/README b/Build/source/utils/m-tx/mtx-0.60d/libp2c/README deleted file mode 100644 index 47a102c88d2..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/libp2c/README +++ /dev/null @@ -1,31 +0,0 @@ - -This directory contains "p2c", a Pascal to C translator. - -"p2c" Copyright 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. - -Written and maintained by: Dave Gillespie - c/o Synaptics, Inc. - 2698 Orchard Parkway - San Jose CA 95134 - daveg@synaptics.com, uunet!synaptx!daveg - - -This program is distributed under the terms of the GNU License Agreement. -See the file src/COPYING for details. - -The GNU License Agreement restrictions do _not_ apply to code generated -by p2c, nor to the p2c run-time files "p2clib.c" and "p2c.h". - -NO WARRANTY: - The program in this directory was developed for internal use at - Caltech and thus absolutely no guarantee is made that the program - will compile or run on other systems or that it will produce correct - code. P2c is _not_ a compiler, it is a translator; it strives to - produce correct code but reserves the right to sacrifice correctness - in extreme cases for readability in the general case. P2c is designed - to be extended (see funcs.c, hpmods.c and citmods.c for examples), but - some of the main code is pretty messy since the translator has grown - considerably beyond its original planned scale. Bug reports are - welcome at daveg@synaptics.com, but I may not have time to respond - to them immediately. Suggestions are welcome, too! - diff --git a/Build/source/utils/m-tx/mtx-0.60d/libp2c/p2c.h b/Build/source/utils/m-tx/mtx-0.60d/libp2c/p2c.h deleted file mode 100644 index 03b95201794..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/libp2c/p2c.h +++ /dev/null @@ -1,533 +0,0 @@ -#ifndef P2C_H -#define P2C_H - - -/* Header file for code generated by "p2c", the Pascal-to-C translator */ - -/* "p2c" Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation. - * By Dave Gillespie, daveg@synaptics.com. Version 1.21alpha-07.Dec.93. - * This file may be copied, modified, etc. in any way. It is not restricted - * by the licence agreement accompanying p2c itself. - */ - - -#include - -#define DOUBLE double - - - -/* If the following heuristic fails, compile -DBSD=0 for non-BSD systems, - or -DBSD=1 for BSD systems. */ - -#ifdef M_XENIX -# define BSD 0 -#endif - -#ifdef vms -# define BSD 0 -# ifndef __STDC__ -# define __STDC__ 1 -# endif -#endif - -#ifdef __TURBOC__ -# define MSDOS 1 -#endif - -#ifdef MSDOS -# define BSD 0 -#endif - -#ifdef FILE /* a #define in BSD, a typedef in SYSV (hp-ux, at least) */ -# ifndef BSD /* (a convenient, but horrible kludge!) */ -# define BSD 1 -# endif -#endif - -#ifdef BSD -# if !BSD -# undef BSD -# endif -#endif - - -#if (defined(__STDC__) && !defined(M_XENIX)) || defined(__TURBOC__) -# include -# include -# define HAS_STDLIB -# if defined(vms) || defined(__TURBOC__) -# define NON_ANSI_CAT -# endif -#else -# ifndef BSD -# ifndef __TURBOC__ -# include -# endif -# endif -# ifdef hpux -# ifdef _INCLUDE__STDC__ -# include -# include -# define HAS_STDLIB -# endif -# endif -# include -# if !defined(MSDOS) || defined(__TURBOC__) -# define NON_ANSI_CAT -# endif -#endif - -#if defined(NON_ANSI_CAT) && !defined(ANSI_CAT) -# ifdef NON_ANSI_CAT_ALTERNATE -# define __CAT__(a,b)a/**/b -# else -# define __ID__(a)a -# define __CAT__(a,b)__ID__(a)b -# endif -#else -# define __CAT__(a,b)a##b -#endif - - -#ifdef BSD -# include -# define memcpy(a,b,n) (bcopy(b,a,n),a) -# define memcmp(a,b,n) bcmp(a,b,n) -# define strchr(s,c) index(s,c) -# define strrchr(s,c) rindex(s,c) -#else -# include -#endif - -#include -#include -#include -#include - - -#ifndef NO_LACK -#ifdef vms - -#define LACK_LABS -#define LACK_MEMMOVE -#define LACK_MEMCPY - -#else - -#define LACK_LABS /* Undefine these if your library has these */ -#define LACK_MEMMOVE - -#endif -#endif - - -typedef struct __p2c_jmp_buf { - struct __p2c_jmp_buf *next; - jmp_buf jbuf; -} __p2c_jmp_buf; - - -/* Warning: The following will not work if setjmp is used simultaneously. - This also violates the ANSI restriction about using vars after longjmp, - but a typical implementation of longjmp will get it right anyway. */ - -#ifndef FAKE_TRY -# define TRY(x) do { __p2c_jmp_buf __try_jb; \ - __try_jb.next = __top_jb; \ - if (!setjmp((__top_jb = &__try_jb)->jbuf)) { -# define RECOVER(x) __top_jb = __try_jb.next; } else { -# define RECOVER2(x,L) __top_jb = __try_jb.next; } else { \ - if (0) { L: __top_jb = __try_jb.next; } -# define ENDTRY(x) } } while (0) -#else -# define TRY(x) if (1) { -# define RECOVER(x) } else do { -# define RECOVER2(x,L) } else do { L: ; -# define ENDTRY(x) } while (0) -#endif - - - -#ifdef M_XENIX /* avoid compiler bug */ -# define SHORT_MAX (32767) -# define SHORT_MIN (-32768) -#endif - - -/* The following definitions work only on twos-complement machines */ -#ifndef SHORT_MAX -# define SHORT_MAX ((short)(((unsigned short) -1) >> 1)) -# define SHORT_MIN (~SHORT_MAX) -#endif - -#ifndef INT_MAX -# define INT_MAX ((int)(((unsigned int) -1) >> 1)) -# define INT_MIN (~INT_MAX) -#endif - -#ifndef LONG_MAX -# define LONG_MAX ((long)(((unsigned long) -1) >> 1)) -# define LONG_MIN (~LONG_MAX) -#endif - -#ifndef SEEK_SET -# define SEEK_SET 0 -# define SEEK_CUR 1 -# define SEEK_END 2 -#endif - -#ifndef EXIT_SUCCESS -# ifdef vms -# define EXIT_SUCCESS 1 -# define EXIT_FAILURE (02000000000L) -# else -# define EXIT_SUCCESS 0 -# define EXIT_FAILURE 1 -# endif -#endif - - -#define SETBITS 32 - - -#if defined(__STDC__) || defined(__TURBOC__) -# if !defined(vms) && !defined(M_LINT) -# define Signed signed -# else -# define Signed -# endif -# define Void void /* Void f() = procedure */ -# ifndef Const -# define Const const -# endif -# ifndef Volatile -# define Volatile volatile -# endif -# ifdef M_LINT -# define PP(x) () -# define PV() () -typedef char *Anyptr; -# else -# define PP(x) x /* function prototype */ -# define PV() (void) /* null function prototype */ -typedef void *Anyptr; -# endif -#else -# define Signed -# define Void void -# ifndef Const -# define Const -# endif -# ifndef Volatile -# define Volatile -# endif -# define PP(x) () -# define PV() () -typedef char *Anyptr; -#endif - -#ifdef __GNUC__ -# define Inline inline -#else -# define Inline -#endif - -#define Register register /* Register variables */ -#define Char char /* Characters (not bytes) */ - -#ifndef Static -# define Static static /* Private global funcs and vars */ -#endif - -#ifndef Local -# define Local static /* Nested functions */ -#endif - -typedef Signed char schar; -typedef unsigned char uchar; -typedef unsigned char boolean; - -#ifndef NO_DECLARE_ALFA -typedef Char alfa[10]; -#endif - -#ifndef true -# define true 1 -# define false 0 -#endif - -#ifndef TRUE -# define TRUE 1 -# define FALSE 0 -#endif - - -typedef struct { - Anyptr proc, link; -} _PROCEDURE; - -#ifndef _FNSIZE -# define _FNSIZE 120 -#endif - - -extern Void PASCAL_MAIN PP( (int, Char **) ); -extern Char **P_argv; -extern int P_argc; -extern short P_escapecode; -extern int P_ioresult; -extern __p2c_jmp_buf *__top_jb; - - -#ifdef P2C_H_PROTO /* if you have Ansi C but non-prototyped header files */ -extern Char *strcat PP( (Char *, Const Char *) ); -extern Char *strchr PP( (Const Char *, int) ); -extern int strcmp PP( (Const Char *, Const Char *) ); -extern Char *strcpy PP( (Char *, Const Char *) ); -extern size_t strlen PP( (Const Char *) ); -extern Char *strncat PP( (Char *, Const Char *, size_t) ); -extern int strncmp PP( (Const Char *, Const Char *, size_t) ); -extern Char *strncpy PP( (Char *, Const Char *, size_t) ); -extern Char *strrchr PP( (Const Char *, int) ); - -extern Anyptr memchr PP( (Const Anyptr, int, size_t) ); -extern Anyptr memmove PP( (Anyptr, Const Anyptr, size_t) ); -extern Anyptr memset PP( (Anyptr, int, size_t) ); -#ifndef memcpy -extern Anyptr memcpy PP( (Anyptr, Const Anyptr, size_t) ); -extern int memcmp PP( (Const Anyptr, Const Anyptr, size_t) ); -#endif - -extern int atoi PP( (Const Char *) ); -extern double atof PP( (Const Char *) ); -extern long atol PP( (Const Char *) ); -extern double strtod PP( (Const Char *, Char **) ); -extern long strtol PP( (Const Char *, Char **, int) ); -#endif /*P2C_H_PROTO*/ - -#ifndef HAS_STDLIB -#ifndef NO_DECLARE_MALLOC -extern Anyptr malloc PP( (size_t) ); -extern Void free PP( (Anyptr) ); -#endif -#endif - -extern int _OutMem PV(); -extern int _CaseCheck PV(); -extern int _NilCheck PV(); -extern int _Escape PP( (int) ); -extern int _EscIO PP( (int) ); -extern int _EscIO2 PP( (int, Char *) ); - -extern long ipow PP( (long, long) ); -extern long P_imax PP( (long, long) ); -extern long P_imin PP( (long, long) ); -extern double P_rmax PP( (double, double) ); -extern double P_rmin PP( (double, double) ); -extern Char *strsub PP( (Char *, Char *, int, int) ); -extern Char *strltrim PP( (Char *) ); -extern Char *strrtrim PP( (Char *) ); -extern Char *strrpt PP( (Char *, Char *, int) ); -extern Char *strpad PP( (Char *, Char *, int, int) ); -extern int strpos2 PP( (Char *, Char *, int) ); -extern long memavail PV(); -extern int P_peek PP( (FILE *) ); -extern int P_eof PP( (FILE *) ); -extern int P_eoln PP( (FILE *) ); -extern Void P_readpaoc PP( (FILE *, Char *, int) ); -extern Void P_readlnpaoc PP( (FILE *, Char *, int) ); -extern long P_maxpos PP( (FILE *) ); -extern Char *P_trimname PP( (Char *, int) ); -extern long *P_setunion PP( (long *, long *, long *) ); -extern long *P_setint PP( (long *, long *, long *) ); -extern long *P_setdiff PP( (long *, long *, long *) ); -extern long *P_setxor PP( (long *, long *, long *) ); -extern int P_inset PP( (unsigned, long *) ); -extern int P_setequal PP( (long *, long *) ); -extern int P_subset PP( (long *, long *) ); -extern long *P_addset PP( (long *, unsigned) ); -extern long *P_addsetr PP( (long *, unsigned, unsigned) ); -extern long *P_remset PP( (long *, unsigned) ); -extern long *P_setcpy PP( (long *, long *) ); -extern long *P_expset PP( (long *, long) ); -extern long P_packset PP( (long *) ); -extern int P_getcmdline PP( (int, int, Char *) ); -extern Void TimeStamp PP( (int *, int *, int *, - int *, int *, int *) ); -extern Void P_sun_argv PP( (char *, int, int) ); -extern FILE *_skipspaces PP( (FILE *) ); -extern FILE *_skipnlspaces PP( (FILE *) ); - - -/* I/O error handling */ -#define _CHKIO(cond,ior,val,def) ((cond) ? P_ioresult=0,(val) \ - : P_ioresult=(ior),(def)) -#define _SETIO(cond,ior) (P_ioresult = (cond) ? 0 : (ior)) - -/* Following defines are suitable for the HP Pascal operating system */ -#define FileNotFound 10 -#define FileNotOpen 13 -#define FileWriteError 38 -#define BadInputFormat 14 -#define EndOfFile 30 - -#define FILENOTFOUND 10 -#define FILENOTOPEN 13 -#define FILEWRITEERROR 38 -#define BADINPUTFORMAT 14 -#define ENDOFFILE 30 - -/* Creating temporary files */ -#if (defined(BSD) || defined(NO_TMPFILE)) && !defined(HAVE_TMPFILE) -# define tmpfile() (fopen(tmpnam(NULL), "w+")) -#endif - -/* File buffers */ -#define FILEBUF(f,sc,type) sc int __CAT__(f,_BFLAGS); \ - sc type __CAT__(f,_BUFFER) -#define FILEBUFNC(f,type) int __CAT__(f,_BFLAGS); \ - type __CAT__(f,_BUFFER) - -#define RESETBUF(f,type) (__CAT__(f,_BFLAGS) = 1) -#define SETUPBUF(f,type) (__CAT__(f,_BFLAGS) = 0) - -#define GETFBUF(f,type) (*((__CAT__(f,_BFLAGS) == 1 && \ - ((__CAT__(f,_BFLAGS) = 2), \ - fread(&__CAT__(f,_BUFFER), \ - sizeof(type),1,(f)))),\ - &__CAT__(f,_BUFFER))) -#define AGETFBUF(f,type) ((__CAT__(f,_BFLAGS) == 1 && \ - ((__CAT__(f,_BFLAGS) = 2), \ - fread(__CAT__(f,_BUFFER), \ - sizeof(type),1,(f)))),\ - __CAT__(f,_BUFFER)) - -#define PUTFBUF(f,type,v) (GETFBUF(f,type) = (v)) -#define CPUTFBUF(f,v) (PUTFBUF(f,char,v)) -#define APUTFBUF(f,type,v) (memcpy(AGETFBUF(f,type), (v), \ - sizeof(__CAT__(f,_BUFFER)))) - -#define GET(f,type) (__CAT__(f,_BFLAGS) == 1 ? \ - fread(&__CAT__(f,_BUFFER),sizeof(type),1,(f)) : \ - (__CAT__(f,_BFLAGS) = 1)) - -#define PUT(f,type) (fwrite(&__CAT__(f,_BUFFER),sizeof(type),1,(f)), \ - (__CAT__(f,_BFLAGS) = 0)) -#define CPUT(f) (PUT(f,char)) - -#define BUFEOF(f) (__CAT__(f,_BFLAGS) != 2 && P_eof(f)) -#define BUFFPOS(f) (ftell(f) - (__CAT__(f,_BFLAGS) == 2)) - -typedef struct { - FILE *f; - int f_BFLAGS; /* FILEBUFNC(f,Char); */ - Char f_BUFFER; - Char name[_FNSIZE]; -} _TEXT; - -/* Memory allocation */ -#ifdef __GCC__ -# define Malloc(n) (malloc(n) ?: (Anyptr)(size_t)_OutMem()) -#else -extern Anyptr __MallocTemp__; -# define Malloc(n) ((__MallocTemp__ = malloc(n)) ? __MallocTemp__ : (Anyptr)(size_t)_OutMem()) -#endif -#define FreeR(p) (free((Anyptr)(p))) /* used if arg is an rvalue */ -#define Free(p) (free((Anyptr)(p)), (p)=NULL) - -/* sign extension */ -#define SEXT(x,n) ((x) | -(((x) & (1L<<((n)-1))) << 1)) - -/* packed arrays */ /* BEWARE: these are untested! */ -#define P_getbits_UB(a,i,n,L) ((int)((a)[(i)>>(L)-(n)] >> \ - (((~(i))&((1<<(L)-(n))-1)) << (n)) & \ - (1<<(1<<(n)))-1)) - -#define P_getbits_SB(a,i,n,L) ((int)((a)[(i)>>(L)-(n)] << \ - (16 - ((((~(i))&((1<<(L)-(n))-1))+1) <<\ - (n)) >> (16-(1<<(n)))))) - -#define P_putbits_UB(a,i,x,n,L) ((a)[(i)>>(L)-(n)] |= \ - (x) << (((~(i))&((1<<(L)-(n))-1)) << (n))) - -#define P_putbits_SB(a,i,x,n,L) ((a)[(i)>>(L)-(n)] |= \ - ((x) & (1<<(1<<(n)))-1) << \ - (((~(i))&((1<<(L)-(n))-1)) << (n))) - -#define P_clrbits_B(a,i,n,L) ((a)[(i)>>(L)-(n)] &= \ - ~( ((1<<(1<<(n)))-1) << \ - (((~(i))&((1<<(L)-(n))-1)) << (n))) ) - -/* small packed arrays */ -#define P_getbits_US(v,i,n) ((int)((v) >> ((i)<<(n)) & (1<<(1<<(n)))-1)) -#define P_getbits_SS(v,i,n) ((int)((long)(v) << (SETBITS - (((i)+1) << (n))) >> (SETBITS-(1<<(n))))) -#define P_putbits_US(v,i,x,n) ((v) |= (x) << ((i) << (n))) -#define P_putbits_SS(v,i,x,n) ((v) |= ((x) & (1<<(1<<(n)))-1) << ((i)<<(n))) -#define P_clrbits_S(v,i,n) ((v) &= ~( ((1<<(1<<(n)))-1) << ((i)<<(n)) )) - -#define P_max(a,b) ((a) > (b) ? (a) : (b)) -#define P_min(a,b) ((a) < (b) ? (a) : (b)) - - -/* Fix ANSI-isms */ - -#ifdef LACK_LABS -# ifndef labs -# define labs my_labs - extern long my_labs PP( (long) ); -# endif -#endif - -#ifdef LACK_MEMMOVE -# ifndef memmove -# define memmove my_memmove - extern Anyptr my_memmove PP( (Anyptr, Const Anyptr, size_t) ); -# endif -#endif - -#ifdef LACK_MEMCPY -# ifndef memcpy -# define memcpy my_memcpy - extern Anyptr my_memcpy PP( (Anyptr, Const Anyptr, size_t) ); -# endif -# ifndef memcmp -# define memcmp my_memcmp - extern int my_memcmp PP( (Const Anyptr, Const Anyptr, size_t) ); -# endif -# ifndef memset -# define memset my_memset - extern Anyptr my_memset PP( (Anyptr, int, size_t) ); -# endif -#endif - -/* Fix toupper/tolower on Suns and other stupid BSD systems */ -#ifdef toupper -# undef toupper -# undef tolower -# define toupper(c) my_toupper(c) -# define tolower(c) my_tolower(c) -#endif - -#ifndef _toupper -# if 'A' == 65 && 'a' == 97 -# define _toupper(c) ((c)-'a'+'A') -# define _tolower(c) ((c)-'A'+'a') -# else -# ifdef toupper -# undef toupper /* hope these are shadowing real functions, */ -# undef tolower /* because my_toupper calls _toupper! */ -# endif -# define _toupper(c) toupper(c) -# define _tolower(c) tolower(c) -# endif -#endif - - -#endif /* P2C_H */ - - - -/* End. */ - - diff --git a/Build/source/utils/m-tx/mtx-0.60d/libp2c/p2clib.c b/Build/source/utils/m-tx/mtx-0.60d/libp2c/p2clib.c deleted file mode 100644 index 98a00edf41b..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/libp2c/p2clib.c +++ /dev/null @@ -1,1117 +0,0 @@ - -/* Run-time library for use with "p2c", the Pascal to C translator */ - -/* "p2c" Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation. - * By Dave Gillespie, daveg@synaptics.com. Version --VERSION--. - * This file may be copied, modified, etc. in any way. It is not restricted - * by the licence agreement accompanying p2c itself. - */ - - - -#include "p2c.h" - - -#ifndef NO_TIME -# include -#endif - - -#define Isspace(c) isspace(c) /* or "((c) == ' ')" if preferred */ - - - - -int P_argc; -char **P_argv; - -short P_escapecode; -int P_ioresult; - -long EXCP_LINE; /* Used by Pascal workstation system */ - -Anyptr __MallocTemp__; - -__p2c_jmp_buf *__top_jb; - - - - -void PASCAL_MAIN(argc, argv) -int argc; -char **argv; -{ - P_argc = argc; - P_argv = argv; - __top_jb = NULL; - -#ifdef LOCAL_INIT - LOCAL_INIT(); -#endif -} - - - - - -/* In case your system lacks these... */ - -long my_labs(x) -long x; -{ - return((x > 0) ? x : -x); -} - - -#ifdef __STDC__ -Anyptr my_memmove(Anyptr d, Const Anyptr s, size_t n) -#else -Anyptr my_memmove(d, s, n) -Anyptr d, s; -register int n; -#endif -{ - register char *dd = (char *)d, *ss = (char *)s; - if (dd < ss || dd - ss >= n) { -#if defined(bcopy) && defined(memcpy) - my_memcpy(dd, ss, n); -#else - memcpy(dd, ss, n); -#endif - } else if (n > 0) { - dd += n; - ss += n; - while (n-- > 0) - *--dd = *--ss; - } - return d; -} - - -#ifdef __STDC__ -Anyptr my_memcpy(Anyptr d, Const Anyptr s, size_t n) -#else -Anyptr my_memcpy(d, s, n) -Anyptr d, s; -register int n; -#endif -{ - register char *ss = (char *)s, *dd = (char *)d; - while (n-- > 0) - *dd++ = *ss++; - return d; -} - -#ifdef __STDC__ -int my_memcmp(Const Anyptr s1, Const Anyptr s2, size_t n) -#else -int my_memcmp(s1, s2, n) -Anyptr s1, s2; -register int n; -#endif -{ - register char *a = (char *)s1, *b = (char *)s2; - register int i; - while (n-- > 0) - if ((i = (*a++) - (*b++)) != 0) - return i; - return 0; -} - -#ifdef __STDC__ -Anyptr my_memset(Anyptr d, int c, size_t n) -#else -Anyptr my_memset(d, c, n) -Anyptr d; -register int c; -register int n; -#endif -{ - register char *dd = (char *)d; - while (n-- > 0) - *dd++ = c; - return d; -} - - -int my_toupper(c) -int c; -{ - if (islower(c)) - return _toupper(c); - else - return c; -} - - -int my_tolower(c) -int c; -{ - if (isupper(c)) - return _tolower(c); - else - return c; -} - - - - -long ipow(a, b) -long a, b; -{ - long v; - - if (a == 0 || a == 1) - return a; - if (a == -1) - return (b & 1) ? -1 : 1; - if (b < 0) - return 0; - if (a == 2) - return 1L << b; - v = (b & 1) ? a : 1; - while ((b >>= 1) > 0) { - a *= a; - if (b & 1) - v *= a; - } - return v; -} - - -long P_imax(a, b) -long a, b; -{ - if (a > b) - return a; - else - return b; -} - -long P_imin(a, b) -long a, b; -{ - if (a < b) - return a; - else - return b; -} - - -double P_rmax(a, b) -double a, b; -{ - if (a > b) - return a; - else - return b; -} - -double P_rmin(a, b) -double a, b; -{ - if (a < b) - return a; - else - return b; -} - - - - -/* Common string functions: */ - -/* Store in "ret" the substring of length "len" starting from "pos" (1-based). - Store a shorter or null string if out-of-range. Return "ret". */ - -char *strsub(ret, s, pos, len) -register char *ret, *s; -register int pos, len; -{ - register char *s2; - - if (--pos < 0 || len <= 0) { - *ret = 0; - return ret; - } - while (pos > 0) { - if (!*s++) { - *ret = 0; - return ret; - } - pos--; - } - s2 = ret; - while (--len >= 0) { - if (!(*s2++ = *s++)) - return ret; - } - *s2 = 0; - return ret; -} - - -/* Return the index of the first occurrence of "pat" as a substring of "s", - starting at index "pos" (1-based). Result is 1-based, 0 if not found. */ - -int strpos2(s, pat, pos) -char *s; -register char *pat; -register int pos; -{ - register char *cp, ch; - register int slen; - - if (--pos < 0) - return 0; - slen = strlen(s) - pos; - cp = s + pos; - if (!(ch = *pat++)) - return 0; - pos = strlen(pat); - slen -= pos; - while (--slen >= 0) { - if (*cp++ == ch && !strncmp(cp, pat, pos)) - return cp - s; - } - return 0; -} - - -/* Case-insensitive version of strcmp. */ - -int strcicmp(s1, s2) -register char *s1, *s2; -{ - register unsigned char c1, c2; - - while (*s1) { - if (*s1++ != *s2++) { - if (!s2[-1]) - return 1; - c1 = toupper(s1[-1]); - c2 = toupper(s2[-1]); - if (c1 != c2) - return c1 - c2; - } - } - if (*s2) - return -1; - return 0; -} - - - - -/* HP and Turbo Pascal string functions: */ - -/* Trim blanks at left end of string. */ - -char *strltrim(s) -register char *s; -{ - while (Isspace(*s++)) ; - return s - 1; -} - - -/* Trim blanks at right end of string. */ - -char *strrtrim(s) -register char *s; -{ - register char *s2 = s; - - if (!*s) - return s; - while (*++s2) ; - while (s2 > s && Isspace(*--s2)) - *s2 = 0; - return s; -} - - -/* Store in "ret" "num" copies of string "s". Return "ret". */ - -char *strrpt(ret, s, num) -char *ret; -register char *s; -register int num; -{ - register char *s2 = ret; - register char *s1; - - while (--num >= 0) { - s1 = s; - while ((*s2++ = *s1++)) ; - s2--; - } - return ret; -} - - -/* Store in "ret" string "s" with enough pad chars added to reach "size". */ - -char *strpad(ret, s, padchar, num) -char *ret; -register char *s; -register int padchar, num; -{ - register char *d = ret; - - if (s == d) { - while (*d++) ; - } else { - while ((*d++ = *s++)) ; - } - num -= (--d - ret); - while (--num >= 0) - *d++ = padchar; - *d = 0; - return ret; -} - - -/* Copy the substring of length "len" from index "spos" of "s" (1-based) - to index "dpos" of "d", lengthening "d" if necessary. Length and - indices must be in-range. */ - -void strmove(len, s, spos, d, dpos) -register char *s, *d; -register int len, spos, dpos; -{ - s += spos - 1; - d += dpos - 1; - while (*d && --len >= 0) - *d++ = *s++; - if (len > 0) { - while (--len >= 0) - *d++ = *s++; - *d = 0; - } -} - - -/* Delete the substring of length "len" at index "pos" from "s". - Delete less if out-of-range. */ - -void strdelete(s, pos, len) -register char *s; -register int pos, len; -{ - register int slen; - - if (--pos < 0) - return; - slen = strlen(s) - pos; - if (slen <= 0) - return; - s += pos; - if (slen <= len) { - *s = 0; - return; - } - while ((*s = s[len])) s++; -} - - -/* Insert string "src" at index "pos" of "dst". */ - -void strinsert(src, dst, pos) -register char *src, *dst; -register int pos; -{ - register int slen, dlen; - - if (--pos < 0) - return; - dlen = strlen(dst); - dst += dlen; - dlen -= pos; - if (dlen <= 0) { - strcpy(dst, src); - return; - } - slen = strlen(src); - do { - dst[slen] = *dst; - --dst; - } while (--dlen >= 0); - dst++; - while (--slen >= 0) - *dst++ = *src++; -} - - - - -/* File functions */ - -/* Peek at next character of input stream; return EOF at end-of-file. */ - -int P_peek(f) -FILE *f; -{ - int ch; - - ch = getc(f); - if (ch == EOF) - return EOF; - ungetc(ch, f); - return (ch == '\n') ? ' ' : ch; -} - - -/* Check if at end of file, using Pascal "eof" semantics. End-of-file for - stdin is broken; remove the special case for it to be broken in a - different way. */ - -int P_eof(f) -FILE *f; -{ - register int ch; - - if (feof(f)) - return 1; -#ifdef HAVE_ISATTY - if (isatty(fileno(f))) -#else - if (f == stdin) -#endif - return 0; /* not safe to look-ahead on the keyboard! */ - ch = getc(f); - if (ch == EOF) - return 1; - ungetc(ch, f); - return 0; -} - - -/* Check if at end of line (or end of entire file). */ - -int P_eoln(f) -FILE *f; -{ - register int ch; - - ch = getc(f); - if (ch == EOF) - return 1; - ungetc(ch, f); - return (ch == '\n'); -} - - -/* Skip whitespace (including newlines) in a file. */ - -FILE *_skipnlspaces(f) -FILE *f; -{ - register int ch; - - do { - ch = getc(f); - } while (ch == ' ' || ch == '\t' || ch == '\n'); - if (ch != EOF) - ungetc(ch, f); - return f; -} - - -/* Skip whitespace (not including newlines) in a file. */ - -FILE *_skipspaces(f) -FILE *f; -{ - register int ch; - - do { - ch = getc(f); - } while (ch == ' ' || ch == '\t'); - if (ch != EOF) - ungetc(ch, f); - return f; -} - - -/* Read a packed array of characters from a file. */ - -Void P_readpaoc(f, s, len) -FILE *f; -char *s; -int len; -{ - int ch; - - for (;;) { - if (len <= 0) - return; - ch = getc(f); - if (ch == EOF || ch == '\n') - break; - *s++ = ch; - --len; - } - while (--len >= 0) - *s++ = ' '; - if (ch != EOF) - ungetc(ch, f); -} - -Void P_readlnpaoc(f, s, len) -FILE *f; -char *s; -int len; -{ - int ch; - - for (;;) { - ch = getc(f); - if (ch == EOF || ch == '\n') - break; - if (len > 0) { - *s++ = ch; - --len; - } - } - while (--len >= 0) - *s++ = ' '; -} - - -/* Compute maximum legal "seek" index in file (0-based). */ - -long P_maxpos(f) -FILE *f; -{ - long savepos = ftell(f); - long val; - - if (fseek(f, 0L, SEEK_END)) - return -1; - val = ftell(f); - if (fseek(f, savepos, SEEK_SET)) - return -1; - return val; -} - - -/* Use packed array of char for a file name. */ - -Char *P_trimname(fn, len) -register Char *fn; -register int len; -{ - static Char fnbuf[256]; - register Char *cp = fnbuf; - - while (--len >= 0 && *fn && !isspace(*fn)) - *cp++ = *fn++; - *cp = 0; - return fnbuf; -} - - - - -/* Pascal's "memavail" doesn't make much sense in Unix with virtual memory. - We fix memory size as 10Meg as a reasonable compromise. */ - -long memavail() -{ - return 10000000; /* worry about this later! */ -} - -long maxavail() -{ - return memavail(); -} - - - - -/* Sets are stored as an array of longs. S[0] is the size of the set; - S[N] is the N'th 32-bit chunk of the set. S[0] equals the maximum - I such that S[I] is nonzero. S[0] is zero for an empty set. Within - each long, bits are packed from lsb to msb. The first bit of the - set is the element with ordinal value 0. (Thus, for a "set of 5..99", - the lowest five bits of the first long are unused and always zero.) */ - -/* (Sets with 32 or fewer elements are normally stored as plain longs.) */ - -long *P_setunion(d, s1, s2) /* d := s1 + s2 */ -register long *d, *s1, *s2; -{ - long *dbase = d++; - register int sz1 = *s1++, sz2 = *s2++; - while (sz1 > 0 && sz2 > 0) { - *d++ = *s1++ | *s2++; - sz1--, sz2--; - } - while (--sz1 >= 0) - *d++ = *s1++; - while (--sz2 >= 0) - *d++ = *s2++; - *dbase = d - dbase - 1; - return dbase; -} - - -long *P_setint(d, s1, s2) /* d := s1 * s2 */ -register long *d, *s1, *s2; -{ - long *dbase = d++; - register int sz1 = *s1++, sz2 = *s2++; - while (--sz1 >= 0 && --sz2 >= 0) - *d++ = *s1++ & *s2++; - while (--d > dbase && !*d) ; - *dbase = d - dbase; - return dbase; -} - - -long *P_setdiff(d, s1, s2) /* d := s1 - s2 */ -register long *d, *s1, *s2; -{ - long *dbase = d++; - register int sz1 = *s1++, sz2 = *s2++; - while (--sz1 >= 0 && --sz2 >= 0) - *d++ = *s1++ & ~*s2++; - if (sz1 >= 0) { - while (sz1-- >= 0) - *d++ = *s1++; - } - while (--d > dbase && !*d) ; - *dbase = d - dbase; - return dbase; -} - - -long *P_setxor(d, s1, s2) /* d := s1 / s2 */ -register long *d, *s1, *s2; -{ - long *dbase = d++; - register int sz1 = *s1++, sz2 = *s2++; - while (sz1 > 0 && sz2 > 0) { - *d++ = *s1++ ^ *s2++; - sz1--, sz2--; - } - while (--sz1 >= 0) - *d++ = *s1++; - while (--sz2 >= 0) - *d++ = *s2++; - while (--d > dbase && !*d) ; - *dbase = d - dbase; - return dbase; -} - - -int P_inset(val, s) /* val IN s */ -register unsigned val; -register long *s; -{ - register int bit; - bit = val % SETBITS; - val /= SETBITS; - if (val < *s++ && ((1L< size) { - s += size; - while (val > size) - *++s = 0, size++; - *sbase = size; - } else - s += val; - *s |= 1L< (int)v2) - return sbase; - b1 = v1 % SETBITS; - v1 /= SETBITS; - b2 = v2 % SETBITS; - v2 /= SETBITS; - size = *s; - v1++; - if (++v2 > size) { - while (v2 > size) - s[++size] = 0; - s[v2] = 0; - *s = v2; - } - s += v1; - if (v1 == v2) { - *s |= (~((-2L)<<(b2-b1))) << b1; - } else { - *s++ |= (-1L) << b1; - while (++v1 < v2) - *s++ = -1; - *s |= ~((-2L) << b2); - } - return sbase; -} - - -long *P_remset(s, val) /* s := s - [val] */ -register long *s; -register unsigned val; -{ - register int bit; - bit = val % SETBITS; - val /= SETBITS; - if (++val <= *s) { - if (!(s[val] &= ~(1L<= 0) { - if (*s1++ != *s2++) - return 0; - } - return 1; -} - - -int P_subset(s1, s2) /* s1 <= s2 */ -register long *s1, *s2; -{ - register int sz1 = *s1++, sz2 = *s2++; - if (sz1 > sz2) - return 0; - while (--sz1 >= 0) { - if (*s1++ & ~*s2++) - return 0; - } - return 1; -} - - -long *P_setcpy(d, s) /* d := s */ -register long *d, *s; -{ - register long *save_d = d; - -#ifdef SETCPY_MEMCPY - memcpy(d, s, (*s + 1) * sizeof(long)); -#else - register int i = *s + 1; - while (--i >= 0) - *d++ = *s++; -#endif - return save_d; -} - - -/* s is a "smallset", i.e., a 32-bit or less set stored - directly in a long. */ - -long *P_expset(d, s) /* d := s */ -register long *d; -register long s; -{ - if (s) { - d[1] = s; - *d = 1; - } else - *d = 0; - return d; -} - - -long P_packset(s) /* convert s to a small-set */ -register long *s; -{ - if (*s++) - return *s; - else - return 0; -} - - - - - -/* Oregon Software Pascal extensions, courtesy of William Bader */ - -int P_getcmdline(l, h, line) -int l, h; -Char *line; -{ - int i, len; - char *s; - - h = h - l + 1; - len = 0; - for(i = 1; i < P_argc; i++) { - s = P_argv[i]; - while (*s) { - if (len >= h) return len; - line[len++] = *s++; - } - if (len >= h) return len; - line[len++] = ' '; - } - return len; -} - -Void TimeStamp(Day, Month, Year, Hour, Min, Sec) -int *Day, *Month, *Year, *Hour, *Min, *Sec; -{ -#ifndef NO_TIME - struct tm *tm; - long clock; - - time(&clock); - tm = localtime(&clock); - *Day = tm->tm_mday; - *Month = tm->tm_mon + 1; /* Jan = 0 */ - *Year = tm->tm_year; - if (*Year < 1900) - *Year += 1900; /* year since 1900 */ - *Hour = tm->tm_hour; - *Min = tm->tm_min; - *Sec = tm->tm_sec; -#endif -} - -Void VAXdate(s) -char *s; -{ - long clock; - char *c; - int i; - static int where[] = {8, 9, 0, 4, 5, 6, 0, 20, 21, 22, 23}; - - time(&clock); - c = ctime(&clock); - for (i = 0; i < 11; i++) - s[i] = my_toupper(c[where[i]]); - s[2] = '-'; - s[6] = '-'; -} - -Void VAXtime(s) -char *s; -{ - long clock; - char *c; - int i; - - time(&clock); - c = ctime(&clock); - for (i = 0; i < 8; i++) - s[i] = c[i+11]; - s[8] = '.'; - s[9] = '0'; - s[10] = '0'; -} - - - - -/* SUN Berkeley Pascal extensions */ - -Void P_sun_argv(s, len, n) -register char *s; -register int len, n; -{ - register char *cp; - - if ((unsigned)n < P_argc) - cp = P_argv[n]; - else - cp = ""; - while (*cp && --len >= 0) - *s++ = *cp++; - while (--len >= 0) - *s++ = ' '; -} - - - - -int _OutMem() -{ - return _Escape(-2); -} - -int _CaseCheck() -{ - return _Escape(-9); -} - -int _NilCheck() -{ - return _Escape(-3); -} - - - - - -/* The following is suitable for the HP Pascal operating system. - It might want to be revised when emulating another system. */ - -char *_ShowEscape(buf, code, ior, prefix) -char *buf, *prefix; -int code, ior; -{ - char *bufp; - - if (prefix && *prefix) { - strcpy(buf, prefix); - strcat(buf, ": "); - bufp = buf + strlen(buf); - } else { - bufp = buf; - } - if (code == -10) { - sprintf(bufp, "Pascal system I/O error %d", ior); - switch (ior) { - case 3: - strcat(buf, " (illegal I/O request)"); - break; - case 7: - strcat(buf, " (bad file name)"); - break; - case FileNotFound: /*10*/ - strcat(buf, " (file not found)"); - break; - case FileNotOpen: /*13*/ - strcat(buf, " (file not open)"); - break; - case BadInputFormat: /*14*/ - strcat(buf, " (bad input format)"); - break; - case 24: - strcat(buf, " (not open for reading)"); - break; - case 25: - strcat(buf, " (not open for writing)"); - break; - case 26: - strcat(buf, " (not open for direct access)"); - break; - case 28: - strcat(buf, " (string subscript out of range)"); - break; - case EndOfFile: /*30*/ - strcat(buf, " (end-of-file)"); - break; - case FileWriteError: /*38*/ - strcat(buf, " (file write error)"); - break; - } - } else { - sprintf(bufp, "Pascal system error %d", code); - switch (code) { - case -2: - strcat(buf, " (out of memory)"); - break; - case -3: - strcat(buf, " (reference to NIL pointer)"); - break; - case -4: - strcat(buf, " (integer overflow)"); - break; - case -5: - strcat(buf, " (divide by zero)"); - break; - case -6: - strcat(buf, " (real math overflow)"); - break; - case -8: - strcat(buf, " (value range error)"); - break; - case -9: - strcat(buf, " (CASE value range error)"); - break; - case -12: - strcat(buf, " (bus error)"); - break; - case -20: - strcat(buf, " (stopped by user)"); - break; - } - } - return buf; -} - - -int _Escape(code) -int code; -{ - char buf[100]; - - P_escapecode = code; - if (__top_jb) { - __p2c_jmp_buf *jb = __top_jb; - __top_jb = jb->next; - longjmp(jb->jbuf, 1); - } - if (code == 0) - exit(EXIT_SUCCESS); - if (code == -1) - exit(EXIT_FAILURE); - fprintf(stderr, "%s\n", _ShowEscape(buf, P_escapecode, P_ioresult, "")); - exit(EXIT_FAILURE); -} - -int _EscIO(code) -int code; -{ - P_ioresult = code; - return _Escape(-10); -} - -int _EscIO2(code, name) -int code; -char *name; -{ - P_ioresult = code; - if (!__top_jb && name && *name) { - char buf[100]; - fprintf(stderr, "%s: %s\n", - name, _ShowEscape(buf, P_escapecode, P_ioresult, "")); - exit(EXIT_FAILURE); - } - return _Escape(-10); -} - - - -/* End. */ - - - diff --git a/Build/source/utils/m-tx/mtx-0.60d/lyrics.c b/Build/source/utils/m-tx/mtx-0.60d/lyrics.c deleted file mode 100644 index c38cdeffddf..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/lyrics.c +++ /dev/null @@ -1,869 +0,0 @@ -/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ -/* From input file "lyrics.pas" */ - - -#include "p2c.h" - - -#define LYRICS_G -#include "lyrics.h" - - -#ifndef CONTROL_H -#include "control.h" -#endif - -#ifndef STRINGS_H -#include "strings.h" -#endif - -#ifndef MTXLINE_H -#include "mtxline.h" -#endif - -#ifndef STATUS_H -#include "status.h" -#endif - -#ifndef MULTFILE_H -#include "multfile.h" -#endif - -#ifndef FILES_H -#include "files.h" -#endif - -#ifndef UTILITY_H -#include "utility.h" -#endif - - -/* Symbols used in strings of melismatype */ - -#define beam_melisma '[' -#define inhibit_beam_melisma '<' -#define slur_melisma '(' -#define inhibit_slur_melisma '{' - - -typedef char other_index; - -typedef char other_index0; - -typedef Char melismatype[256]; - -typedef enum { - nolyr, haslyr -} haslyrtype; -typedef enum { - normal, aux -} auxtype; -typedef enum { - asbefore, newassign -} assigntype; -typedef enum { - virgin, active -} inittype; - -typedef struct lyrinfotype { - short lyr_adjust, slur_level, slur_change, beam_level, beam_change; - melismatype melisma; - boolean numbered; -} lyrinfotype; - -typedef enum { - none_given, global_lyrics, local_lyrics -} lyrlinetype; - -typedef struct lyrtagtype { - lyrlinetype lyrsource; - haslyrtype has_lyrics; - auxtype auxiliary; - assigntype new_assign; - inittype initialized; - short linecount; - Char tags[256]; -} lyrtagtype; - - -#define maxLyrNums 64 -#define lyrtaglength 40 - - -#define lyr_adjust_undef (-12345) -#define interstave 24 - - -Static short LyrNum = 0; - -Static boolean lyrmodealter[maxstaves], oldlyrmodealter[maxstaves]; -Static lyrtagtype tag[maxvoices], oldtag[maxvoices]; -Static lyrinfotype lyrinfo[maxvoices]; -Static Char numberedParagraph[maxLyrNums][lyrtaglength + 1]; - - -/* Information flow for verse numbers: at the SetLyrics stage, the first -line of each lyrics paragraph is checked for a verse number, and if -found, the paragraph tag is remembered. At the AssignLyrics stage, -the first time that paragraph is encountered, the particular voice -is marked in lyrinfo as being numbered. When that voice is later processed, -the mark in lyrinfo is interrogated and turned off: if it was on, the -mtxVerse pre-TeX string is put into the output. */ - -boolean hasVerseNumber(voice) -voice_index voice; -{ - boolean Result; - - Result = lyrinfo[voice-1].numbered; - lyrinfo[voice-1].numbered = false; - return Result; -} - - -Static boolean isNumberedLyricsParagraph(tag) -Char *tag; -{ - short i, FORLIM; - - FORLIM = LyrNum; - for (i = 0; i <= FORLIM - 1; i++) { - if (!strcmp(tag, numberedParagraph[i])) - return true; - } - return false; -} - - -Static boolean anyTagNumbered(tags_) -Char *tags_; -{ - boolean Result; - Char tags[256]; - Char s[256]; - - strcpy(tags, tags_); -/* p2c: lyrics.pas: Note: Eliminated unused assignment statement [338] */ - if (curtail(tags, '}') > 0) - delete1(tags, 1); - do { - GetNextWord(s, tags, ',', dummy); - if (*s == '\0') - return false; - if (isNumberedLyricsParagraph(s)) - return true; - } while (true); - return false; -} - - -/* Save the tag in the numberedParagraph list, stripping off braces if any */ -Static Void markNumbered(tag_) -Char *tag_; -{ - Char tag[256]; - - strcpy(tag, tag_); - if (LyrNum >= maxLyrNums) { - error("Too many numbered lines in the lyrics", !print); - return; - } - LyrNum++; - if (curtail(tag, '}') > 0) - delete1(tag, 1); - strcpy(numberedParagraph[LyrNum-1], tag); -/* p2c: lyrics.pas, line 104: - * Note: Possible string truncation in assignment [145] */ -} - - -/* --- end of procedures to keep track of verse numbering --- */ - -Void lyricsParagraph() -{ - Char first[256], w[256]; - paragraph_index0 l, line; - other_index0 i; - other_index0 nother = 0; - Char other_[10][lyrtaglength + 1]; - boolean numbered; - Char STR1[256], STR3[256]; - paragraph_index0 FORLIM; - Char STR4[256]; - Char STR5[256]; - - if (!doLyrics()) - return; - NextWord(w, P[0], blank, dummy); - l = strlen(w); - line_no = orig_line_no[0]; - if (w[l-1] != '}') - strcat(w, "}"); - GetNextWord(first, w, dummy, '}'); - while (*w != '\0') { - if (w[0] == '=') - predelete(w, 1); - if (w[0] != '{') - sprintf(w, "{%s", strcpy(STR1, w)); - nother++; - GetNextWord(other_[nother-1], w, dummy, '}'); -/* p2c: lyrics.pas, line 122: - * Note: Possible string truncation in assignment [145] */ - } - if (beVerbose()) { - printf("---- Paragraph %d starting at line %d has lyrics headed %s", - paragraph_no, line_no, first); - for (i = 0; i <= nother - 1; i++) - printf("=%s", other_[i]); - putchar('\n'); - } - sprintf(STR5, "%c Paragraph %s line %s bar %s", - comment, toString(STR1, paragraph_no), toString(STR3, line_no), - toString(STR4, bar_no)); - tex3(STR5); - sprintf(STR3, "\\mtxSetLyrics%s{%%", first); - tex3(STR3); - FORLIM = para_len; - for (line = 2; line <= FORLIM; line++) { - lyrTranslate(P[line-1], &numbered); - if (numbered) { - if (line > 2) - warning("Verse number not in first line of paragraph treated as lyrics", - print); - else { - markNumbered(first); - for (i = 0; i <= nother - 1; i++) - markNumbered(other_[i]); - } - } - line_no = orig_line_no[line-1]; - if (strlen(P[line-1]) > max_lyrics_line_length && pmx_preamble_done) - error("Lyrics line too long", print); - if (pmx_preamble_done) { - if (line == 2) { - sprintf(STR3, "\\\\\\:%s", P[line-1]); - put(STR3, putspace); - } else { - sprintf(STR3, "\\\\\\ %s", P[line-1]); - put(STR3, putspace); - } - } else - put(P[line-1], putspace); - if (line < para_len) { - if (pmx_preamble_done) - putLine(" %\\"); - else - putLine(" %"); - } else if (pmx_preamble_done) - putLine("}\\"); - else - putLine("}"); - } - for (i = 0; i <= nother - 1; i++) { - sprintf(STR1, "\\mtxCopyLyrics%s%s", first, other_[i]); - tex3(STR1); - } -} - - -Static Char *songraise(Result, voice) -Char *Result; -voice_index voice; -{ - Char s[256]; - lyrtagtype *WITH; - lyrinfotype *WITH1; - Char STR1[256], STR3[256]; - - WITH = &tag[voice-1]; - WITH1 = &lyrinfo[voice-1]; - if (WITH->initialized == virgin && WITH1->lyr_adjust == 0) - return strcpy(Result, ""); - else { - if (WITH->auxiliary == aux) - strcpy(s, "Aux"); - else - *s = '\0'; - sprintf(Result, "\\mtx%sLyricsAdjust{%s}{%s}", - s, toString(STR1, PMXinstr(voiceStave(voice))), - toString(STR3, WITH1->lyr_adjust)); - return Result; - } -} - - -Char *lyricsReport(Result, voice) -Char *Result; -voice_index voice; -{ - Char l[256]; - lyrtagtype *WITH; - - WITH = &tag[voice-1]; - if (WITH->has_lyrics == nolyr || - WITH->lyrsource == none_given && *WITH->tags == '\0') - return strcpy(Result, " but has no own lyrics"); - else { - strcpy(l, " with "); - if (WITH->auxiliary == aux) - strcat(l, "auxiliary "); - strcat(l, "lyrics "); - if (WITH->lyrsource == local_lyrics) - strcat(l, "locally defined as \""); - else - strcat(l, "labelled \""); - sprintf(l + strlen(l), "%s\"", WITH->tags); - if (anyTagNumbered(WITH->tags)) - strcat(l, " with verse numbers"); - return strcpy(Result, l); - } -} - - -Void initLyrics() -{ - /* at the start only */ - stave_index stave; - voice_index voice, FORLIM; - lyrinfotype *WITH; - lyrtagtype *WITH1; - stave_index FORLIM1; - - FORLIM = nvoices; - for (voice = 0; voice <= FORLIM - 1; voice++) { - WITH = &lyrinfo[voice]; - WITH1 = &tag[voice]; - WITH1->has_lyrics = nolyr; - WITH->lyr_adjust = lyr_adjust_undef; - *WITH->melisma = '\0'; - WITH->slur_level = 0; - WITH->beam_level = 0; - WITH1->auxiliary = aux; - WITH1->lyrsource = none_given; - WITH1->new_assign = asbefore; - WITH1->initialized = virgin; - } - FORLIM1 = nstaves; - for (stave = 0; stave <= FORLIM1 - 1; stave++) - oldlyrmodealter[stave] = false; -} - - -Static Void registerLyrics(voice, w) -voice_index voice; -Char *w; -{ - lyrtagtype *WITH; - - WITH = &tag[voice-1]; - strcpy(oldtag[voice-1].tags, WITH->tags); - oldtag[voice-1].lyrsource = WITH->lyrsource; - WITH->lyrsource = global_lyrics; - switch (strlen(w)) { - - case 0: - *WITH->tags = '\0'; - break; - - case 1: - fatalerror("M-Tx system error in registerLyrics"); - break; - - default: - strcpy(WITH->tags, w); - break; - } -} - - -Void extractLyrtag(voice, note) -voice_index voice; -Char *note; -{ - /* inline lyrics change */ - lyrtagtype *WITH; - Char STR1[256], STR2[256]; - - WITH = &tag[voice-1]; - if (WITH->has_lyrics == nolyr) { - error3(voice, "Inline lyrics change on no-lyrics line"); - return; - } - registerLyrics(voice, note); /* was: ''); */ - sprintf(note, "\\mtxAssignLyrics{%s}%s", - toString(STR1, PMXinstr(voiceStave(voice))), strcpy(STR2, note)); - if (WITH->auxiliary == aux) - sprintf(note, "\\mtxAuxLyr{%s}\\", strcpy(STR2, note)); - else - strcat(note, "\\"); -} - - -Void clearTags() -{ - /* at start of paragraph analyis */ - voice_index voice, FORLIM; - lyrtagtype *WITH; - - memcpy(oldtag, tag, maxvoices * sizeof(lyrtagtype)); - FORLIM = nvoices; - for (voice = 0; voice <= FORLIM - 1; voice++) { - WITH = &tag[voice]; - WITH->lyrsource = none_given; - *WITH->tags = '\0'; - WITH->linecount = 0; - } -} - - -#define maxlyrlen (PMXlinelength - 15) - - -Local Void convertlyrics(lyn, voice, mx) -Char *lyn; -voice_index voice; -auxtype mx; -{ - static Char setlyr[256] = "%%\\\\\\mtxSetLyrics"; - Char btag[256], thistag[256], w[256]; - boolean numbered; - Char STR1[256]; - lyrtagtype *WITH; - Char STR2[256]; - - NextWord(w, lyn, blank, dummy); - WITH = &tag[voice-1]; - if (*w == '\0') { - *WITH->tags = '\0'; - return; - } - WITH->has_lyrics = haslyr; - WITH->auxiliary = mx; - if (w[0] == '{') { - registerLyrics(voice, w); - return; - } - WITH->lyrsource = local_lyrics; - WITH->linecount++; - toString(thistag, voice * 10 + WITH->linecount); - sprintf(btag, "{%s}", thistag); - if (*WITH->tags == '\0') - strcpy(WITH->tags, btag); - else { - WITH->tags[strlen(WITH->tags) - 1] = ','; - sprintf(WITH->tags + strlen(WITH->tags), "%s}", thistag); - } - trim(lyn); - lyrTranslate(lyn, &numbered); - if (numbered) - markNumbered(thistag); - if (strlen(lyn) + strlen(btag) > maxlyrlen) - sprintf(lyn, "%s%s{\\\n\\\\\\:%s}\\", setlyr, btag, strcpy(STR2, lyn)); - else - sprintf(lyn, "%s%s{%s}\\", setlyr, btag, strcpy(STR1, lyn)); -} - -#undef maxlyrlen - - -Void maybeLyrics(voice, parline, w_) -voice_index voice; -paragraph_index parline; -Char *w_; -{ - /* during paragraph analysis, parline had L:, already stripped */ - Char w[256]; - voice_index0 k; - - /** Labelled lyrics line -- */ - strcpy(w, w_); - if (!doLyrics()) - return; - if (strlen(w) == 1 && voice == 0) - warning("Lyrics line above top voice should be labelled", print); - if (strlen(w) == 1) { /** Standard lyrics line -------- */ - k = voice; - if (k == 0) - k = 1; - convertlyrics(P[parline-1], k, normal); - return; - } - predelete(w, 1); - k = findVoice(w); - if (k == 0) - error("Lyrics line belongs to unknown voice", print); - else - convertlyrics(P[parline-1], k, aux); -} - - -Void reviseLyrics() -{ - /* after paragraph analysis */ - voice_index voice; - stave_index stave; - voice_index FORLIM; - lyrtagtype *WITH; - stave_index FORLIM1; - - FORLIM = nvoices; - for (voice = 0; voice <= FORLIM - 1; voice++) { - WITH = &tag[voice]; - if (oldtag[voice].lyrsource == global_lyrics && - WITH->lyrsource == none_given) { - strcpy(WITH->tags, oldtag[voice].tags); - WITH->lyrsource = global_lyrics; - } - WITH->new_assign = (assigntype)(WITH->has_lyrics == haslyr && - strcmp(WITH->tags, oldtag[voice].tags)); - if (*WITH->tags == '\0') - WITH->has_lyrics = nolyr; - strcpy(oldtag[voice].tags, WITH->tags); - oldtag[voice].lyrsource = WITH->lyrsource; - } - FORLIM1 = nstaves; - for (stave = 1; stave <= FORLIM1; stave++) { - WITH = &tag[first_on_stave[stave-1] - 1]; - lyrmodealter[stave-1] = (!aloneOnStave(stave) && - WITH->has_lyrics == haslyr && - WITH->auxiliary == normal); - } -} - - -Void assignLyrics(stave, lyrassign) -stave_index stave; -Char *lyrassign; -{ - /* at start of new block */ - Char atag[256], instr[256], l[256]; - voice_index v1, v2, voice; - lyrtagtype *WITH; - Char STR2[256]; - lyrinfotype *WITH1; - - *lyrassign = '\0'; - toString(instr, PMXinstr(stave)); - v1 = first_on_stave[stave-1]; - v2 = v1 + number_on_stave[stave-1] - 1; - /* don't reassign if other voice takes over */ - if (tag[v1-1].auxiliary == tag[v2-1].auxiliary && - tag[v1-1].has_lyrics != tag[v2-1].has_lyrics) { - for (voice = v1 - 1; voice <= v2 - 1; voice++) { - WITH = &tag[voice]; - if (WITH->new_assign == newassign) - WITH->new_assign = (assigntype)WITH->has_lyrics; - } - } - for (voice = v1 - 1; voice <= v2 - 1; voice++) - lyrinfo[voice].numbered = false; - for (voice = v1; voice <= v2; voice++) { - WITH = &tag[voice-1]; - if (WITH->new_assign == newassign) { - strcpy(atag, WITH->tags); - if (*atag == '\0') - strcpy(atag, "{}"); - sprintf(l, "\\mtxAssignLyrics{%s}%s", instr, atag); - if (WITH->auxiliary == aux) - sprintf(l, "\\mtxAuxLyr{%s}", strcpy(STR2, l)); - strcat(lyrassign, l); - if (*WITH->tags == '\0') - WITH->has_lyrics = nolyr; - if (WITH->has_lyrics == haslyr && WITH->initialized == virgin) { - WITH1 = &lyrinfo[voice-1]; - if (WITH->auxiliary == aux && upper(voice)) - WITH1->lyr_adjust = interstave; - else - WITH1->lyr_adjust = 0; - strcat(lyrassign, songraise(STR2, voice)); - WITH->initialized = active; - } - if (anyTagNumbered(atag)) - lyrinfo[voice-1].numbered = true; - } - } - if (lyrmodealter[stave-1] == oldlyrmodealter[stave-1]) - return; - if (lyrmodealter[stave-1]) - sprintf(lyrassign + strlen(lyrassign), "\\mtxLyrModeAlter{%s}", instr); - else - sprintf(lyrassign + strlen(lyrassign), "\\mtxLyrModeNormal{%s}", instr); - oldlyrmodealter[stave-1] = lyrmodealter[stave-1]; -} - - -Void lyricsAdjust(voice, note) -voice_index voice; -Char *note; -{ - /* inline at-word */ - short adj; - boolean force, put_above, put_below; - lyrinfotype *WITH; - lyrtagtype *WITH1; - Char STR2[256]; - - WITH = &lyrinfo[voice-1]; - WITH1 = &tag[voice-1]; - predelete(note, 1); - force = (note[0] == '='); - if (force) - predelete(note, 1); - put_above = (note[0] == '^'); - if (put_above) - predelete(note, 1); - put_below = (note[0] == 'v'); - if (put_below) - predelete(note, 1); - if (*note != '\0') - getNum(note, &adj); - else - adj = 0; - if (WITH1->has_lyrics == nolyr) { - *note = '\0'; - return; - } - if (put_above) - WITH->lyr_adjust = interstave; - else if (put_below) - WITH->lyr_adjust = 0; - if (force) - WITH->lyr_adjust = adj; - else - WITH->lyr_adjust += adj; - songraise(note, voice); - if (*note != '\0') - sprintf(note, "\\\\%s\\", strcpy(STR2, note)); -} - - -Void lyrTranslate(P, numbered) -Char *P; -boolean *numbered; -{ /* Test for starting number */ - short k, l, number; - Char Q[256], w[256]; - - NextWord(w, P, blank, dummy); - *numbered = false; - if (endsWith(w, ".")) { - getNum(w, &number); - *numbered = (number != 0); - } - /*Translate lyrics link */ - *Q = '\0'; - l = strlen(P); - for (k = 1; k <= l - 1; k++) { - if (P[k-1] != '_' || P[k] == '_' || P[k] == ' ' || pos1(P[k], digits) > 0) - sprintf(Q + strlen(Q), "%c", P[k-1]); - else if (k > 1 && P[k-2] == '\\') - strcat(Q, "mtxLowLyrlink "); - else - strcat(Q, "\\mtxLyrlink "); - } - sprintf(Q + strlen(Q), "%c", P[l-1]); - strcpy(P, Q); -} - - -typedef enum { - beam, slur -} melismaEnd; - - -Static Char removeLast(s, t) -Char *s; -Char *t; -{ - Char Result; - short i, l; - - l = strlen(s); - for (i = l; i >= 1; i--) { - if (pos1(s[i-1], t) > 0) { - Result = s[i-1]; - delete1(s, i); - return Result; - } - } - return dummy; -} - - -Static boolean OpenMelisma(s) -Char *s; -{ - return (pos1(slur_melisma, s) > 0 || pos1(beam_melisma, s) > 0); -} - - -/* Local variables for getSyllable: */ -struct LOC_getSyllable { - voice_index voice; - boolean BM, EM; -} ; - -Local Void startMelismas(t, LINK) -Char *t; -struct LOC_getSyllable *LINK; -{ - boolean open_before, open_now; - short i, k; - lyrinfotype *WITH; - - k = strlen(t); - for (i = 0; i <= k - 1; i++) { - WITH = &lyrinfo[LINK->voice-1]; - open_before = OpenMelisma(WITH->melisma); - sprintf(WITH->melisma + strlen(WITH->melisma), "%c", t[i]); - open_now = OpenMelisma(WITH->melisma); - LINK->BM = (LINK->BM || open_now && !open_before); - } -} - -Local boolean endMelisma(voice, LINK) -short voice; -struct LOC_getSyllable *LINK; -{ - Char found; - short i; - short count[2]; - melismaEnd t; - short FORLIM1; - lyrinfotype *WITH; - Char STR1[4]; - - LINK->EM = false; - count[(long)slur] = -lyrinfo[voice-1].slur_change; - count[(long)beam] = -lyrinfo[voice-1].beam_change; - for (t = beam; (long)t <= (long)slur; t = (melismaEnd)((long)t + 1)) { - FORLIM1 = count[(long)t]; - for (i = 1; i <= FORLIM1; i++) { - WITH = &lyrinfo[voice-1]; - switch (t) { - - case slur: - sprintf(STR1, "%c%c", slur_melisma, inhibit_slur_melisma); - found = removeLast(WITH->melisma, STR1); - break; - - case beam: - sprintf(STR1, "%c%c", beam_melisma, inhibit_beam_melisma); - found = removeLast(WITH->melisma, STR1); - break; - } - if (found == dummy) - error3(voice, "Ending a melisma that was never started"); - LINK->EM = (LINK->EM || - (!OpenMelisma(WITH->melisma) && - pos1(found, (sprintf(STR1, "%c%c", slur_melisma, beam_melisma), - STR1)) > 0)); - } - } - return LINK->EM; -} - -Local Void startSlurMelisma(voice, LINK) -voice_index voice; -struct LOC_getSyllable *LINK; -{ - static Char start[2] = { - slur_melisma, inhibit_slur_melisma - }; - - Char slurs[256]; - short k, FORLIM; - Char STR1[256]; - - *slurs = '\0'; - FORLIM = lyrinfo[voice-1].slur_change; - for (k = 1; k <= FORLIM; k++) - sprintf(slurs, "%c%s", - start[noSlurMelisma(voice, 1 - k)], strcpy(STR1, slurs)); - startMelismas(slurs, LINK); -} - -Local Void startBeamMelisma(voice, LINK) -voice_index voice; -struct LOC_getSyllable *LINK; -{ - static Char start[2] = { - beam_melisma, inhibit_beam_melisma - }; - - Char beams[256]; - short k, FORLIM; - Char STR1[256]; - - *beams = '\0'; - FORLIM = lyrinfo[voice-1].beam_change; - for (k = 1; k <= FORLIM; k++) - sprintf(beams, "%c%s", start[noBeamMelisma(voice)], strcpy(STR1, beams)); - startMelismas(beams, LINK); -} - -Local boolean startMelisma(voice, LINK) -short voice; -struct LOC_getSyllable *LINK; -{ - LINK->BM = false; - startSlurMelisma(voice, LINK); - startBeamMelisma(voice, LINK); - return LINK->BM; -} - - -/* Append mtxBM or mtxEM to pretex when appropriate */ -Void getSyllable(voice_, pretex) -voice_index voice_; -Char *pretex; -{ - struct LOC_getSyllable V; - short t; - lyrtagtype *WITH; - lyrinfotype *WITH1; - - V.voice = voice_; - WITH = &tag[V.voice-1]; - WITH1 = &lyrinfo[V.voice-1]; - if (WITH->has_lyrics != haslyr) - return; - t = WITH1->slur_level; - WITH1->slur_level = slurLevel(V.voice); - WITH1->slur_change = WITH1->slur_level - t; - t = WITH1->beam_level; - WITH1->beam_level = beamLevel(V.voice); - WITH1->beam_change = WITH1->beam_level - t; - if (startMelisma(V.voice, &V)) { - if (WITH->auxiliary == aux) - strcat(pretex, "\\mtxAuxBM"); - else - strcat(pretex, "\\mtxBM"); - } - if (!endMelisma(V.voice, &V)) - return; - if (WITH->auxiliary == aux) - strcat(pretex, "\\mtxAuxEM"); - else - strcat(pretex, "\\mtxEM"); -} - - -Static Void getSyllable1(voice, pretex) -voice_index voice; -Char *pretex; -{ - lyrinfotype *WITH; - - WITH = &lyrinfo[voice-1]; - printf("voice=%d, slurchange=%d, melisma=%s, beamchange=%d\n", - voice, WITH->slur_change, WITH->melisma, WITH->beam_change); - getSyllable1(voice, pretex); - if (*pretex != '\0') - printf("pretex = %s\n", pretex); -} - - - - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/lyrics.h b/Build/source/utils/m-tx/mtx-0.60d/lyrics.h deleted file mode 100644 index f225cb0d760..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/lyrics.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Header for module lyrics, generated by p2c 1.21alpha-07.Dec.93 */ -#ifndef LYRICS_H -#define LYRICS_H - - -/* Everything related to lyrics */ - -#ifndef GLOBALS_H -#include "globals.h" -#endif - - -#ifdef LYRICS_G -# define vextern -#else -# define vextern extern -#endif - -extern Void initLyrics PV(); -extern Void clearTags PV(); -extern Void reviseLyrics PV(); -extern Void lyrTranslate PP((Char *P, boolean *numbered)); -extern Void getSyllable PP((int voice, Char *pretex)); -extern Char *lyricsReport PP((Char *Result, int voice)); -extern Void maybeLyrics PP((int voice, int parline, Char *w)); -extern Void extractLyrtag PP((int voice, Char *note)); -extern Void lyricsAdjust PP((int voice, Char *note)); -extern Void assignLyrics PP((int stave, Char *lyrassign)); -extern Void lyricsParagraph PV(); -extern boolean hasVerseNumber PP((int voice)); - - -#undef vextern - -#endif /*LYRICS_H*/ - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/lyrics.pas b/Build/source/utils/m-tx/mtx-0.60d/lyrics.pas deleted file mode 100644 index 14d7f5046eb..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/lyrics.pas +++ /dev/null @@ -1,455 +0,0 @@ -unit lyrics; -{ Everything related to lyrics } - -interface uses globals; - -procedure initLyrics; -procedure clearTags; -procedure reviseLyrics; -procedure lyrTranslate(var P: string; var numbered: boolean); -procedure getSyllable(voice: voice_index; var pretex: string); -function lyricsReport (voice: voice_index): string; -procedure maybeLyrics (voice: voice_index; parline: paragraph_index; - w: string); -procedure extractLyrtag (voice: voice_index; var note: string); -procedure lyricsAdjust (voice: voice_index; var note: string); -procedure assignLyrics(stave: stave_index; var lyrassign: string); -procedure lyricsParagraph; -function hasVerseNumber(voice: voice_index): boolean; - -implementation uses control, strings, mtxline, status, files, utility; - -{ Symbols used in strings of melismatype } -const - beam_melisma = '['; - inhibit_beam_melisma = '<'; - slur_melisma = '('; - inhibit_slur_melisma = '{'; - -type - other_index = 1..10; - other_index0 = 0..10; - melismatype = string; - haslyrtype = (nolyr, haslyr); - auxtype= (normal, aux); - assigntype = (asbefore, newassign); - inittype = (virgin,active); - lyrinfotype = record - lyr_adjust, slur_level, slur_change, beam_level, beam_change: integer; - melisma: melismatype; - numbered: boolean; - end; - - lyrlinetype = (none_given, global_lyrics, local_lyrics); - lyrtagtype = record - lyrsource: lyrlinetype; - has_lyrics: haslyrtype; - auxiliary: auxtype; - new_assign: assigntype; - initialized: inittype; - linecount: integer; - tags: string; - end; - -const maxLyrNums=64; - lyrtaglength=40; - LyrNum: integer=0; - -var lyrmodealter, oldlyrmodealter: array[stave_index] of boolean; - tag, oldtag: array[voice_index] of lyrtagtype; - lyrinfo: array[voice_index] of lyrinfotype; - numberedParagraph: array[1..maxLyrNums] of string[lyrtaglength]; - -const lyr_adjust_undef = -12345; - interstave = 24; - -{ Information flow for verse numbers: at the SetLyrics stage, the first -line of each lyrics paragraph is checked for a verse number, and if -found, the paragraph tag is remembered. At the AssignLyrics stage, -the first time that paragraph is encountered, the particular voice -is marked in lyrinfo as being numbered. When that voice is later processed, -the mark in lyrinfo is interrogated and turned off: if it was on, the -mtxVerse pre-TeX string is put into the output. } - -function hasVerseNumber(voice: voice_index): boolean; -begin hasVerseNumber:=lyrinfo[voice].numbered; - lyrinfo[voice].numbered:=false; -end; - -function isNumberedLyricsParagraph(tag: string): boolean; - var i: integer; -begin - for i:=1 to LyrNum do if tag=numberedParagraph[i] then - begin isNumberedLyricsParagraph:=true; exit; end; - isNumberedLyricsParagraph:=false; -end; - -function anyTagNumbered(tags: string): boolean; - var s: string; -begin anyTagNumbered:=false; - if curtail(tags,'}')>0 then delete1(tags,1); - repeat s:=getNextWord(tags,',',dummy); - if s='' then exit; - if isNumberedLyricsParagraph(s) then - begin anyTagNumbered:=true; exit; end; - until false; -end; - -{ Save the tag in the numberedParagraph list, stripping off braces if any } -procedure markNumbered(tag: string); -begin if LyrNum >= maxLyrNums then - begin error('Too many numbered lines in the lyrics',not print); exit; end; - inc(LyrNum); - if curtail(tag,'}')>0 then delete1(tag,1); - numberedParagraph[LyrNum] := tag; -end; - -{ --- end of procedures to keep track of verse numbering --- } - -procedure lyricsParagraph; - var first, w: string; - l, line: paragraph_index0; - i, nother: other_index0; - other: array[other_index] of string[lyrtaglength]; - numbered: boolean; -begin if not doLyrics then exit; - w:=NextWord(P[1],blank,dummy); l:=length(w); line_no := orig_line_no[1]; - if w[l]<>'}' then w:=w+'}'; - first:=GetNextWord(w,dummy,'}'); nother:=0; - while w<>'' do - begin if w[1]='=' then predelete(w,1); - if w[1]<>'{' then w:='{'+w; - inc(nother); other[nother]:=GetNextWord(w,dummy,'}'); - end; - if beVerbose then - begin write('---- Paragraph ', paragraph_no, ' starting at line ', line_no, - ' has lyrics headed ',first); - for i:=1 to nother do write('=',other[i]); writeln; - end; - tex3(comment+' Paragraph '+toString(paragraph_no)+' line '+ - toString(line_no)+' bar '+toString(bar_no)); - tex3('\mtxSetLyrics'+first+'{%'); - for line:=2 to para_len do - begin lyrTranslate(P[line],numbered); - if numbered then if (line>2) then warning( - 'Verse number not in first line of paragraph treated as lyrics',print) - else - begin markNumbered(first); for i:=1 to nother do markNumbered(other[i]); - end; - line_no:=orig_line_no[line]; - if (length(P[line])>max_lyrics_line_length) and pmx_preamble_done - then error('Lyrics line too long',print); - if pmx_preamble_done then - if line=2 then put('\\\:'+P[line],putspace) - else put('\\\ ' + P[line],putspace) - else put(P[line],putspace); - if linemaxlyrlen then - lyn := setlyr + btag + '{\'^J'\\\:' + lyn +'}\' - else lyn:= setlyr + btag + '{' + lyn +'}\'; - end; - end; - end; - end; -begin if not dolyrics then exit; - if (length(w)=1) and (voice=0) then - warning('Lyrics line above top voice should be labelled',print); - if length(w)=1 then {* Standard lyrics line -------- } - begin k:=voice; if k=0 then k:=1; convertlyrics(P[parline],k,normal); - end - else {* Labelled lyrics line -- } - begin predelete(w,1); k:=findVoice(w); - if k=0 then error('Lyrics line belongs to unknown voice',print) - else convertlyrics(P[parline],k,aux); - end; -end; - -procedure reviseLyrics; { after paragraph analysis } - var voice : voice_index; - stave : stave_index; -begin - for voice:=1 to nvoices do with tag[voice] do - begin if (oldtag[voice].lyrsource=global_lyrics) and - (lyrsource=none_given) then - begin tags:=oldtag[voice].tags; lyrsource:=global_lyrics; end; - new_assign := - assigntype(ord((has_lyrics=haslyr) and (tags<>oldtag[voice].tags))); - if tags='' then has_lyrics := nolyr; - oldtag[voice].tags := tags; - oldtag[voice].lyrsource := lyrsource; - end; - for stave:=1 to nstaves do with tag[first_on_stave[stave]] do - lyrmodealter[stave] := not aloneOnStave(stave) and - (has_lyrics=haslyr) and (auxiliary=normal); -end; - -procedure assignLyrics(stave: stave_index; var lyrassign: string); - { at start of new block } - var atag, instr, l: string; - v1, v2, voice: voice_index; - begin lyrassign:=''; instr := toString(pmxinstr(stave)); - v1:=first_on_stave[stave]; v2:=v1+number_on_stave[stave]-1; - if v1tag[v2].has_lyrics) then - for voice:=v1 to v2 do with tag[voice] do - if new_assign=newassign then new_assign:=assigntype(has_lyrics); - for voice:=v1 to v2 do lyrinfo[voice].numbered:=false; - for voice:=v1 to v2 do - with tag[voice] do if new_assign=newassign then - begin atag:=tags; if atag='' then atag:='{}'; - l := '\mtxAssignLyrics{' + instr + '}' + atag; - if auxiliary=aux then l:='\mtxAuxLyr{' + l + '}'; - lyrassign := lyrassign + l; - if tags='' then has_lyrics:=nolyr; - if (has_lyrics=haslyr) and (initialized=virgin) then - with lyrinfo[voice] do - begin if (auxiliary=aux) and upper(voice) then - lyr_adjust:=interstave else lyr_adjust:=0; - lyrassign := lyrassign + songraise(voice); - initialized := active; - end; - if anyTagNumbered(atag) then lyrinfo[voice].numbered:=true; - end; - if lyrmodealter[stave]<>oldlyrmodealter[stave] then - begin if lyrmodealter[stave] then - lyrassign := lyrassign + '\mtxLyrModeAlter{' + instr + '}' - else lyrassign := lyrassign + '\mtxLyrModeNormal{' + instr + '}'; - oldlyrmodealter[stave] := lyrmodealter[stave]; - end; - end; - -procedure lyricsAdjust (voice: voice_index; var note: string); - { inline at-word } - var adj: integer; - force, put_above, put_below: boolean; -begin with lyrinfo[voice] do with tag[voice] do - begin predelete(note,1); - force:=note[1]='='; if force then predelete(note,1); - put_above:=note[1]='^'; if put_above then predelete(note,1); - put_below:=note[1]='v'; if put_below then predelete(note,1); - if note<>'' then getNum(note,adj) else adj:=0; - if has_lyrics=nolyr then begin note:=''; exit; end; - if put_above then lyr_adjust:=interstave - else if put_below then lyr_adjust:=0; - if force then lyr_adjust:=adj else inc(lyr_adjust,adj); - note:=songraise(voice); if note<>'' then note:='\\'+note+'\'; - end -end; - -procedure lyrTranslate(var P: string; var numbered: boolean); - var k, l, number: integer; - Q, w: string; -begin { Test for starting number } w:=NextWord(P,blank,dummy); - numbered:=false; - if endsWith(w,'.') then begin getNum(w,number); numbered:=number<>0 end; - {Translate lyrics link } Q := ''; l:=length(P); - for k:=1 to l-1 do - if (P[k]<>'_') or (P[k+1]='_') or (P[k+1]=' ') or (pos1(P[k+1],digits)>0) - then Q := Q+P[k] - else if (k>1) and (P[k-1]='\') then Q := Q+'mtxLowLyrlink ' - else Q := Q+'\mtxLyrlink '; - Q:=Q+P[l]; - P := Q; -end; - -type melismaEnd = (beam, slur); - -function removeLast(var s: string; t: string): char; - var i,l: integer; -begin l:=length(s); - for i:=l downto 1 do if pos1(s[i],t)>0 then - begin removeLast:=s[i]; delete1(s,i); exit; end; - removeLast := dummy; -end; - -function OpenMelisma(s: string): boolean; -begin OpenMelisma := (pos1(slur_melisma,s)>0) or (pos1(beam_melisma,s)>0); -end; - -{ Append mtxBM or mtxEM to pretex when appropriate } -procedure getSyllable(voice: voice_index; var pretex: string); - var BM, EM: boolean; - procedure startMelismas (t: string); - var open_before, open_now: boolean; - i, k: integer; - begin k:=length(t); - for i:=1 to k do with lyrinfo[voice] do - begin open_before := OpenMelisma(melisma); - melisma := melisma + t[i]; - open_now := OpenMelisma(melisma); - BM := BM or (open_now and not open_before) - end; - end; - function endMelisma(voice: integer): boolean; - var found: char; - i: integer; - count: array[melismaEnd] of integer; - t: melismaEnd; - begin EM := false; - count[slur] := -lyrinfo[voice].slur_change; - count[beam] := -lyrinfo[voice].beam_change; - for t:=beam to slur do for i:=1 to count[t] do with lyrinfo[voice] do - begin - case t of - slur: found := removeLast(melisma,slur_melisma+inhibit_slur_melisma); - beam: found := removeLast(melisma,beam_melisma+inhibit_beam_melisma); - end; - if found=dummy then - error3(voice,'Ending a melisma that was never started'); - EM := EM or (not openMelisma(melisma) - and (pos1(found,slur_melisma+beam_melisma)>0)) - end; - endMelisma := EM - end; - procedure startSlurMelisma(voice: voice_index); - const start: array[boolean] of char = (slur_melisma,inhibit_slur_melisma); - var slurs: string; - k: integer; - begin slurs:=''; - for k:=1 to lyrinfo[voice].slur_change do - slurs:=start[noSlurMelisma(voice,1-k)]+slurs; - startMelismas(slurs) - end; - procedure startBeamMelisma(voice: voice_index); - const start: array[boolean] of char = (beam_melisma,inhibit_beam_melisma); - var beams: string; - k: integer; - begin beams:=''; - for k:=1 to lyrinfo[voice].beam_change do - beams:=start[noBeamMelisma(voice)]+beams; - startMelismas(beams) - end; - function startMelisma(voice: integer): boolean; - begin BM:=false; startSlurMelisma(voice); startBeamMelisma(voice); - startMelisma := BM - end; - var t: integer; -begin with tag[voice] do with lyrinfo[voice] do - begin if has_lyrics<>haslyr then exit; - t:=slur_level; slur_level:=slurLevel(voice); slur_change:=slur_level-t; - t:=beam_level; beam_level:=beamLevel(voice); beam_change:=beam_level-t; - if startMelisma(voice) then if auxiliary=aux - then pretex:=pretex+'\mtxAuxBM' else pretex:=pretex+'\mtxBM'; - if endMelisma(voice) then if auxiliary=aux - then pretex:=pretex+'\mtxAuxEM' else pretex:=pretex+'\mtxEM' - end -end; - -procedure getSyllable1(voice: voice_index; var pretex: string); -begin with lyrinfo[voice] do - begin - writeln('voice=',voice, ', slurchange=',slur_change, - ', melisma=',melisma, ', beamchange=', beam_change) - end; - getSyllable1(voice,pretex); - if pretex<>'' then writeln('pretex = ',pretex) -end; - -end. diff --git a/Build/source/utils/m-tx/mtx-0.60d/mtx.c b/Build/source/utils/m-tx/mtx-0.60d/mtx.c deleted file mode 100644 index f4a85564092..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/mtx.c +++ /dev/null @@ -1,505 +0,0 @@ -/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ -/* From input file "mtx.pas" */ - - -#include "p2c.h" - - -#define MTX_G -#include "mtx.h" - - -#ifndef CONTROL_H -#include "control.h" -#endif - -#ifndef MTXLINE_H -#include "mtxline.h" -#endif - -#ifndef STRINGS_H -#include "strings.h" -#endif - -#ifndef STATUS_H -#include "status.h" -#endif - -#ifndef NOTES_H -#include "notes.h" -#endif - - -#define flagged "8136" - - -typedef boolean sticky['z' + 1 - 'a']; - - -Static sticky note_attrib[maxvoices], rest_attrib[maxvoices]; - - -Static short logTwo(denom) -short denom; -{ - short l = 0; - - while (denom > 1) { - l++; - denom /= 2; - } - return l; -} - - -Local boolean dotted(n) -short n; -{ - boolean Result; - -/* p2c: mtx.pas: Note: Eliminated unused assignment statement [338] */ - if (n == 0) - return false; - if (n != n / 3 * 3) - return false; - n /= 3; - while ((n & 1) == 0) - n /= 2; - return (n == 1); -} - - -/* RESTS should have a third parameter OFFSET. At present we in effect - assume OFFSET+LENGTH to be a multiple of METERDENOM. */ -Char *rests(Result, len, meterdenom, blind) -Char *Result; -short len, meterdenom; -boolean blind; -{ - Char r[256], bl[256]; - Char STR1[256]; - - if (blind) - strcpy(bl, "b"); - else - *bl = '\0'; - if (len == 0) - return strcpy(Result, ""); - else { - if (len == meterdenom * 128) { - sprintf(Result, "r9%s ", bl); - return Result; - } else { - if (dotted(len)) { - rests(r, len - len / 3, meterdenom, false); - r[2] = 'd'; - sprintf(Result, "%s%s ", r, bl); - return Result; - } else if (len >= 64 / meterdenom) { - sprintf(Result, "%sr%c%s ", - rests(STR1, len - 64 / meterdenom, meterdenom, blind), - durations[whole + logTwo(meterdenom) - 1], bl); - return Result; - } else - return (rests(Result, len, meterdenom * 2, blind)); - } - } -} - - -Local Char *attribs(Result, note) -Char *Result; -Char *note; -{ - Char a[256]; - short i = 2; - short l; - Char n; - - *a = '\0'; - l = strlen(note); - while (i <= l) { - n = note[i-1]; - if (n == 'x') - i = l; - else if (islower(n)) - sprintf(a + strlen(a), "%c", n); - i++; - } - return strcpy(Result, a); -} - - -Static Void checkSticky(note, attrib) -Char *note; -boolean *attrib; -{ - short i = 2; - short l; - Char c; - Char a[256]; - - if (*note == '\0') - return; - l = strlen(note); - while (i <= l) { - c = note[i-1]; - if (islower(c)) { - if (i < l && note[i] == ':') { - delete1(note, i + 1); - l--; - attrib[c - 'a'] = !attrib[c - 'a']; - } else - attrib[c - 'a'] = false; - } - i++; - } - attribs(a, note); - for (c = 'z'; c >= 'a'; c--) { - if (attrib[c - 'a'] && pos1(c, a) == 0) - insertChar(c, note, 3); - } -} - - -/* Routine was patched by Hiroaki Morimoto, revised 2003/08/15. - Rewritten by DPL 2004/05/16 to be more understandable. - octaveCode returns octave adjustments in the order - [absolute or =],[relative] */ -Void checkOctave(voice, note) -voice_index voice; -Char *note; -{ - Char code; - - code = octaveCode(note); - if (code == '=') { - setOctave(voice); - removeOctaveCode(code, note); - } - if (octave(voice) == blank) - return; - code = octaveCode(note); - if (isdigit(code)) { - resetOctave(voice); - return; - } - while (code == '+' || code == '-') { - newOctave(voice, code); - removeOctaveCode(code, note); - code = octaveCode(note); - } - if (code != ' ') - error3(voice, "You may have only one absolute octave assignment"); - insertOctaveCode(octave(voice), note); - resetOctave(voice); -} - - -Void markDebeamed(voice, note) -voice_index voice; -Char *note; -{ - if (isVocal(voice) && afterSlur(voice) == 0 && unbeamVocal() && - pos1(duration(voice), flagged) > 0) - insertChar('a', note, 2); -} - - -Static short barLength(meter) -Char *meter; -{ - short n1, n2, pn1, pn2; - - getMeter(meter, &n1, &n2, &pn1, &pn2); - return (n1 * (64 / n2)); -} - - -Static boolean isMultiBarRest(rest_) -Char *rest_; -{ - boolean Result; - -/* p2c: mtx.pas: Note: Eliminated unused assignment statement [338] */ - if (strlen(rest_) < 3) - return false; - if (rest_[1] != 'm') - return false; - if (multi_bar_rest) - error("Only one multibar rest allowed per line", print); - multi_bar_rest = true; - return true; -} - - -/* Double-length in xtuplet detected by a brute search for D anywhere. - Could be more elegant. */ - -Static short macro_length[20]; - -Static Char macro_ID[20][3] = { - "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", - "15", "16", "17", "18", "19", "20" -}; - - -/* Local variables for scanMusic: */ -struct LOC_scanMusic { - voice_index voice; - Char note[256]; - boolean doublex, store_macro; - short bar, old_length, bar_length, count, l, mlen, ngrace, nmulti, macroID, - playID; - Char macro_type; -} ; - -Local Void decmulti(LINK) -struct LOC_scanMusic *LINK; -{ - if (LINK->doublex) - LINK->nmulti -= 2; - else - LINK->nmulti--; -} - -/* Local variables for countIt: */ -struct LOC_countIt { - struct LOC_scanMusic *LINK; -} ; - -Local Void incbar(nl, LINK) -short nl; -struct LOC_countIt *LINK; -{ - LINK->LINK->bar_length += nl; - if (LINK->LINK->bar_length > LINK->LINK->bar && meternum > 0) - error3(LINK->LINK->voice, "Bar end occurs in mid-note"); -} - -Local Void countIt(LINK) -struct LOC_scanMusic *LINK; -{ - struct LOC_countIt V; - - V.LINK = LINK; - if (LINK->ngrace > 0) { - LINK->ngrace--; - return; - } - if (LINK->nmulti > 0) { - decmulti(LINK); - return; - } - if (LINK->count % 3 != 0 && - (LINK->note[0] != rest && note_attrib[LINK->voice-1]['d' - 'a'] || - LINK->note[0] == rest && rest_attrib[LINK->voice-1]['d' - 'a'])) - LINK->count += LINK->count / 2; -/* p2c: mtx.pas, line 148: - * Note: Using % for possibly-negative arguments [317] */ - incbar(LINK->count, &V); - LINK->l = pos1(multi_group, LINK->note); - if (LINK->l <= 0) - return; - predelete(LINK->note, LINK->l); - getNum(LINK->note, &LINK->nmulti); - decmulti(LINK); -} - -Local Void maybeGroup(LINK) -struct LOC_scanMusic *LINK; -{ - if (LINK->note[0] != grace_group) - return; - if (strlen(LINK->note) == 1) - LINK->ngrace = 1; - else - LINK->ngrace = pos1(LINK->note[1], digits); - /* bug if ngrace>9 */ - if (LINK->ngrace > 0) - LINK->ngrace--; -} - -Local short identifyMacro(s_, LINK) -Char *s_; -struct LOC_scanMusic *LINK; -{ - Char s[256]; - short k; - - strcpy(s, s_); - predelete(s, 2); - for (k = 1; k <= 20; k++) { - if (!strcmp(s, macro_ID[k-1])) - return k; - } - return 0; -} - -Local Void examineMacro(LINK) -struct LOC_scanMusic *LINK; -{ - if (!countMacro()) - return; - if (debugMode()) - printf("%s: ", LINK->note); - if (strlen(LINK->note) == 1) { - LINK->mlen = LINK->bar_length - LINK->old_length; - if (LINK->macroID < 1 || LINK->macroID > 20) - error3(LINK->voice, "Invalid macro ID"); - macro_length[LINK->macroID-1] = LINK->mlen; - if (debugMode()) - printf("Ending macro %d of type %c, length=%d\n", - LINK->macroID, LINK->macro_type, LINK->mlen); - if (LINK->macro_type == 'S') - LINK->bar_length = LINK->old_length; - LINK->store_macro = false; - return; - } - LINK->playID = identifyMacro(LINK->note, LINK); - if (LINK->playID < 1 || LINK->playID > 20) - error3(LINK->voice, "Invalid macro ID"); - if (LINK->note[1] == 'P') { - if (debugMode()) - printf("Playing macro %d of length %d\n", - LINK->playID, macro_length[LINK->playID-1]); - LINK->bar_length += macro_length[LINK->playID-1]; - return; - } - if (pos1(LINK->note[1], "SR") <= 0) - return; - LINK->old_length = LINK->bar_length; - LINK->macro_type = LINK->note[1]; - LINK->macroID = LINK->playID; - LINK->store_macro = true; - if (debugMode()) - printf("Defining macro %d of type %c\n", LINK->macroID, LINK->note[1]); -} - - -Void scanMusic(voice_, left_over) -voice_index voice_; -short *left_over; -{ - struct LOC_scanMusic V; - Char buf[256], enote[256], xnote[256]; - boolean has_next = false, done = false; - Char dur1, lastdur; - music_word nscan; - Char STR1[256]; - - V.voice = voice_; - strcpy(terminators, "d.x"); - resetInfo(V.voice, buf); - *left_over = 0; - V.store_macro = false; - V.bar = full_bar; - V.bar_length = 0; - V.ngrace = 0; - V.nmulti = 0; - if (meternum == 0) - V.bar = 32000; - dur1 = duration(V.voice); - lastdur = dur1; - do { - getNextMusWord(buf, V.note, &nscan); - if (*V.note == '\0') - break; - V.count = 0; - /* if isNoteOrRest(note) and not (isPause(note) or isMultibarRest(note)) - then note:=toStandard(note); */ - V.doublex = (pos1('D', V.note) > 0); - if (nscan == mword) { - if (*V.note == '\0') - error3(V.voice, "You may not end a line with a meter change"); - if (V.bar_length > 0) - error3(V.voice, "Meter change only allowed at start of bar"); - else - V.bar = barLength(V.note); - } else if (nscan == rword) { - if (!(isPause(V.note) || isMultiBarRest(V.note))) { - processNote(V.note, xnote, dur1, &lastdur, &V.count); - checkSticky(V.note, rest_attrib[V.voice-1]); - } - } - if (*V.note != '\0') - appendNote(V.voice, nscan); - strcpy(enote, V.note); - if (nscan == macro || nscan == endmacro) - examineMacro(&V); - if (nscan == abcdefg) { - if (!multi_bar_rest && V.ngrace + V.nmulti == 0) { - processNote(enote, xnote, dur1, &lastdur, &V.count); - if (*xnote != '\0') { - checkSticky(enote, note_attrib[V.voice-1]); - appendToLine(V.voice, enote); - appendNote(V.voice, nscan); - strcpy(enote, xnote); - } - checkSticky(enote, note_attrib[V.voice-1]); - } - } - appendToLine(V.voice, enote); - if (*V.note == '\0') /* !!! else word_bound[here]:=length(line); */ - done = true; - sprintf(STR1, "%c", barsym); - if (!strcmp(V.note, STR1)) { - if (meternum == 0) - error3(V.voice, "You may not use bar lines in barless music"); - else if (V.bar_length == 0) - markBar(V.voice); - else if (numberOfBars(V.voice) == 0 && V.bar_length < V.bar) { - if (has_next) - has_next = false; /*Should check whether pickups are equal*/ - else if (*left_over > 0) - error3(V.voice, "Bar is too short"); - *left_over = V.bar_length; - V.bar_length = 0; - } - } - if (nscan == nextvoice) { - if (V.bar_length > 0) - error3(V.voice, "Next voice before bar is full"); - else - barForward(V.voice, -1); - has_next = true; - } else if (isPause(V.note)) - V.bar_length += V.bar; - else if (!multi_bar_rest) { /*do nothing*/ - if (!done && isNoteOrRest(V.note)) - countIt(&V); - else - maybeGroup(&V); - } - dur1 = lastdur; - if (V.bar_length >= V.bar && V.ngrace + V.nmulti == 0 && !V.store_macro) { - if (debugMode()) - printf("%d %d\n", V.voice, V.bar_length); - barForward(V.voice, V.bar_length / V.bar); - V.bar_length %= V.bar; -/* p2c: mtx.pas, line 266: - * Note: Using % for possibly-negative arguments [317] */ - } - } while (!done); - setExtraLength(V.voice, V.bar_length); - resetDuration(V.voice, dur1); - regroup(V.voice); -} - - -Void initMTX() -{ - voice_index i; - Char j; - - for (i = 0; i <= maxvoices - 1; i++) { - for (j = 'a'; j <= 'z'; j++) - note_attrib[i][j - 'a'] = false; - } - memcpy(rest_attrib, note_attrib, maxvoices * sizeof(sticky)); -} - - - - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/mtx.h b/Build/source/utils/m-tx/mtx-0.60d/mtx.h deleted file mode 100644 index 9c4a9811883..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/mtx.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Header for module mtx, generated by p2c 1.21alpha-07.Dec.93 */ -#ifndef MTX_H -#define MTX_H - - -/* Details of M-Tx -> PMX translation */ - -#ifndef GLOBALS_H -#include "globals.h" -#endif - - -#ifdef MTX_G -# define vextern -#else -# define vextern extern -#endif - -extern Void scanMusic PP((int voice, short *left_over)); -extern Void markDebeamed PP((int voice, Char *note)); -extern Void checkOctave PP((int voice, Char *note)); -extern Char *rests PP((Char *Result, int len, int meterdenom, int blind)); -extern Void initMTX PV(); - - -#undef vextern - -#endif /*MTX_H*/ - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/mtx.pas b/Build/source/utils/m-tx/mtx-0.60d/mtx.pas deleted file mode 100644 index 474b24521a3..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/mtx.pas +++ /dev/null @@ -1,280 +0,0 @@ -unit mtx; -{ Details of M-Tx -> PMX translation } - -interface uses globals; - -procedure scanMusic(voice: voice_index; var left_over: integer); -procedure markDebeamed(voice: voice_index; var note: string); -procedure checkOctave(voice: voice_index; var note: string); -function rests (len, meterdenom: integer; blind: boolean): string; -procedure initMTX; - -implementation uses control, mtxline, strings, status, notes; - -const flagged = '8136'; - -type sticky = array['a'..'z'] of boolean; - -var note_attrib, rest_attrib: array[voice_index] of sticky; - -function logTwo(denom: integer): integer; - var l: integer; -begin l:=0; while denom>1 do begin inc(l); denom:=denom div 2; end; - logtwo:=l; -end; - -{ RESTS should have a third parameter OFFSET. At present we in effect - assume OFFSET+LENGTH to be a multiple of METERDENOM. } -function rests (len, meterdenom: integer; blind: boolean): string; - var r, bl: string; - function dotted(n: integer): boolean; - begin dotted:=false; if n=0 then exit; - if n<>3*(n div 3) then exit; - n:=n div 3; while n mod 2 = 0 do n:=n div 2; - dotted := n=1; - end; - begin if blind then bl:='b' else bl:=''; - if len=0 then rests:='' else - if len=128*meterdenom then rests:='r9'+bl+' ' else - if dotted(len) then - begin r:=rests(len-len div 3,meterdenom,false); - r[3]:='d'; rests:=r+bl+' '; - end - else if len>=64 div meterdenom then - rests:=rests(len-64 div meterdenom,meterdenom,blind)+'r' - +durations[whole+logtwo(meterdenom)]+bl+' ' - else rests:=rests(len,meterdenom*2,blind); - end; - -procedure checkSticky(var note: string; var attrib: sticky); - var i,l: integer; - c: char; - a: string; - function attribs(note: string): string; - var a: string; - i,l: integer; - n: char; - begin a:=''; i:=2; l:=length(note); - while i<=l do - begin n:=note[i]; - if n='x' then i:=l else if (n>='a') and (n<='z') then a:=a+n; - inc(i); - end; - attribs:=a; - end; -begin if note='' then exit; - l:=length(note); i:=2; - while i<=l do - begin c:=note[i]; - if (c>='a') and (c<='z') then - if (i='0') and (code<='9') then begin resetOctave(voice); exit end; - while (code='+') or (code='-') do - begin - newOctave(voice,code); removeOctaveCode(code,note); code:=octaveCode(note) - end; - if code<>' ' then error3(voice,'You may have only one absolute octave assignment'); - insertOctaveCode(octave(voice),note); resetOctave(voice) -end; - -procedure markDebeamed(voice: voice_index; var note: string); -begin - if isVocal(voice) and (afterSlur(voice)=0) and unbeamVocal - and (pos1(duration(voice),flagged)>0) then insertchar('a',note,2); -end; - -function barLength (meter: string): integer; - var n1, n2, pn1, pn2: integer; -begin - getMeter(meter,n1,n2,pn1,pn2); barLength := n1*(64 div n2); -end; - -function isMultiBarRest(rest: string): boolean; -begin isMultibarRest:=false; if length(rest)<3 then exit; - if rest[2]<>'m' then exit; - if multi_bar_rest then error( - 'Only one multibar rest allowed per line',print); - multi_bar_rest := true; isMultibarRest:=true; -end; - -{ Double-length in xtuplet detected by a brute search for D anywhere. - Could be more elegant. } - -var macro_length: array[1..20] of integer; -const macro_ID: array[1..20] of string[2]=('1','2','3','4','5','6','7','8', - '9','10','11','12','13','14','15','16','17','18','19','20'); - -procedure scanMusic(voice: voice_index; var left_over: integer); - var buf, note, enote, xnote: string; - has_next, done, doublex, store_macro: boolean; - bar, old_length, bar_length, count, l, mlen, ngrace, nmulti, - macroID, playID: integer; - dur1, lastdur, macro_type: char; - nscan: music_word; - - procedure decmulti; - begin if doublex then dec(nmulti,2) else dec(nmulti) - end; - - procedure countIt; - procedure incbar(nl: integer); - begin inc(bar_length,nl); - if (bar_length>bar) and (meternum>0) - then error3(voice,'Bar end occurs in mid-note'); - end; - begin - if ngrace>0 then dec(ngrace) else - if nmulti>0 then decmulti else - begin if (count mod 3<>0) and ( - (note[1]<>rest) and note_attrib[voice,'d'] or - (note[1]=rest) and rest_attrib[voice,'d']) then - inc(count,count div 2); - incbar(count); - l := pos1(multi_group,note); - if l>0 then - begin predelete(note,l); getNum(note,nmulti); decmulti; - end; - end - end; - - procedure maybeGroup; - begin if note[1]=grace_group then - begin if length(note)=1 then ngrace:=1 - else ngrace := pos1(note[2],digits); (* bug if ngrace>9 *) - if ngrace>0 then dec(ngrace); - end; - end; - - function identifyMacro(s: string): integer; - var k: integer; - begin predelete(s,2); for k:=1 to 20 do if s=macro_ID[k] then - begin identifyMacro:=k; exit end; - identifyMacro:=0 - end; - - procedure examineMacro; - begin if not countMacro then exit; - if debugMode then write(note,': '); if length(note)=1 then - begin - mlen:=bar_length-old_length; - if (macroID<1) or (macroID>20) then error3(voice,'Invalid macro ID'); - macro_length[macroID]:=mlen; - if debugMode then - writeln('Ending macro ',macroID,' of type ',macro_type,', length=', mlen); - if macro_type='S' then bar_length:=old_length; store_macro:=false - end - else begin playID:=identifyMacro(note); - if (playID<1) or (playID>20) then error3(voice,'Invalid macro ID'); - if note[2]='P' then - begin if debugMode then - writeln('Playing macro ',playID,' of length ', - macro_length[playID]); - inc(bar_length,macro_length[playID]) - end - else if pos1(note[2],'SR')>0 then - begin old_length:=bar_length; macro_type:=note[2]; macroID:=playID; - store_macro:=true; - if debugMode then writeln('Defining macro ',macroID,' of type ',note[2]) - end - end - end; - -begin - terminators:='d.x'; - resetInfo(voice, buf); has_next := false; left_over:=0; store_macro:=false; - bar:=full_bar; bar_length:=0; ngrace:=0; nmulti:=0; - if meternum=0 then bar:=32000; - dur1:=duration(voice); lastdur:=dur1; - done:=false; - repeat GetNextMusWord(buf,note,nscan); if length(note)=0 then break; count:=0; -{ if isNoteOrRest(note) and not (isPause(note) or isMultibarRest(note)) - then note:=toStandard(note); } - doublex := pos1('D',note)>0; - if nscan=mword then - begin - if length(note)=0 then - Error3(voice,'You may not end a line with a meter change'); - if bar_length>0 then - error3(voice,'Meter change only allowed at start of bar') - else bar:=barLength(note); - end - else if nscan=rword then - if not (isPause(note) or isMultiBarRest(note)) then - begin - processNote(note,xnote,dur1,lastdur,count); - checkSticky(note,rest_attrib[voice]); - end; - if note<>'' then appendNote(voice,nscan); - enote := note; - if (nscan=macro) or (nscan=endMacro) then examineMacro; - if nscan=abcdefg then - if (not multi_bar_rest) and (ngrace + nmulti = 0) then - begin - processNote(enote,xnote,dur1,lastdur,count); - if xnote<>'' then - begin - checkSticky(enote,note_attrib[voice]); - appendToLine(voice,enote); - appendNote(voice,nscan); enote := xnote; - end; - checkSticky(enote,note_attrib[voice]); - end; - appendToLine(voice,enote); - if note='' then done:=true; { !!! else word_bound[here]:=length(line); } - if (note=barsym) then - if meternum=0 then - error3(voice,'You may not use bar lines in barless music') - else if bar_length=0 then markBar(voice) - else if (numberOfBars(voice)=0) and (bar_length0 then error3(voice,'Bar is too short'); - left_over:=bar_length; bar_length := 0; - end; - if nscan=nextvoice then - begin if bar_length>0 then error3(voice, 'Next voice before bar is full') - else barForward(voice,-1); has_next := true; - end - else if isPause(note) then inc(bar_length,bar) - else if multi_bar_rest then {do nothing} - else if not done and isNoteOrRest(note) then countIt - else maybeGroup; - dur1:=lastdur; - if (bar_length>=bar) and (ngrace+nmulti=0) and not store_macro then - begin if debugMode then writeln(voice,' ',bar_length); - barForward(voice,bar_length div bar); bar_length:=bar_length mod bar - end; - until done; - setExtraLength(voice,bar_length); - resetDuration(voice,dur1); - regroup(voice) -end; - -procedure initMTX; - var i: voice_index; j: char; -begin for i:=1 to maxvoices do for j:='a' to 'z' do - note_attrib[i,j] := false; - rest_attrib := note_attrib; -end; - -end. diff --git a/Build/source/utils/m-tx/mtx-0.60d/mtxline.c b/Build/source/utils/m-tx/mtx-0.60d/mtxline.c deleted file mode 100644 index f61cee0e24d..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/mtxline.c +++ /dev/null @@ -1,844 +0,0 @@ -/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ -/* From input file "mtxline.pas" */ - - -#include "p2c.h" - - -#define MTXLINE_G -#include "mtxline.h" - - -boolean bind_left[22] = { - false, false, true, false, false, true, true, false, true, true, true, - false, true, false, true, false, true, false, false, false, false, false -}; - -#ifndef STRINGS_H -#include "strings.h" -#endif - -#ifndef CONTROL_H -#include "control.h" -#endif - -#ifndef NOTES_H -#include "notes.h" -#endif - -#ifndef UTILITY_H -#include "utility.h" -#endif - - -typedef music_word word_scan[max_words]; - -typedef struct line_info { - word_index0 here, nword; - bar_index0 nbar; - paragraph_index0 voice_pos, voice_stave, mus, chord; - short extra; - boolean vocal; - word_index0 bar_bound[max_bars + 1]; - short word_bound[max_words + 1]; - word_scan scan; -} line_info; - - -Static Char name[22][10] = { - "?", "note", "znote", "lyricsTag", "(", ")", ")(", "[", "]", "_", "PMX<", - "macro", "endMacro", "meter", "ornament", "rest", "//", "BAR", "TeX", "@", - "firstonly", "ERROR" -}; - -Static line_info info[maxvoices]; - - -/* ------------------------------------------------------------- */ - -short beatsPerLine(void) -{ - short Result; - voice_index voice, FORLIM; - line_info *WITH; - - FORLIM = nvoices; - for (voice = 1; voice <= FORLIM; voice++) { - WITH = &info[voice-1]; - if (WITH->nbar > 0 || WITH->extra > 0) { - if (WITH->extra % one_beat > 0) { -/* p2c: mtxline.pas, line 99: - * Note: Using % for possibly-negative arguments [317] */ - error3(voice, "Line length not an integer number of beats"); - } - Result = WITH->nbar * meternum + WITH->extra / one_beat; - } - } - return Result; -} - - -void skipChordBar(voice_index voice) -{ - line_info *WITH; - Char STR1[256]; - - WITH = &info[voice-1]; - if (WITH->chord > 0) { - sprintf(STR1, "%c", barsym); - if (!strcmp(P[WITH->chord - 1], STR1)) - predelete(P[WITH->chord - 1], 1); - } -} - - -Char *getBar(Char *Result, voice_index voice, short bar) -{ - line_info *WITH; - - WITH = &info[voice-1]; - return (substr_(Result, P[WITH->mus - 1], - WITH->word_bound[WITH->bar_bound[bar-1]] + 1, - WITH->word_bound[WITH->bar_bound[bar]] - - WITH->word_bound[WITH->bar_bound[bar-1]])); -} - - -Char *musicLine(Char *Result, voice_index voice) -{ - return strcpy(Result, P[musicLineNo(voice) - 1]); -} - - -paragraph_index0 musicLineNo(voice_index voice) -{ - return (info[voice-1].mus); -} - - -void setMusicLineNo(voice_index voice, paragraph_index lno) -{ - info[voice-1].mus = lno; -} - - -paragraph_index0 chordLineNo(voice_index voice) -{ - return (info[voice-1].chord); -} - - -void setChordLineNo(voice_index voice, paragraph_index lno) -{ - info[voice-1].chord = lno; -} - - -void setVocal(voice_index voice, boolean voc) -{ - info[voice-1].vocal = voc; -} - - -boolean isVocal(voice_index voice) -{ - return (info[voice-1].vocal); -} - - -void setStavePos(voice_index voice, stave_index stave, stave_index pos) -{ - line_info *WITH; - - WITH = &info[voice-1]; - WITH->voice_pos = pos; - WITH->voice_stave = stave; -} - - -stave_index voiceStave(voice_index voice) -{ - return (info[voice-1].voice_stave); -} - - -stave_index voicePos(voice_index voice) -{ - return (info[voice-1].voice_pos); -} - - -voice_index companion(voice_index voice) -{ - short s; - - s = info[voice-1].voice_stave; - if (number_on_stave[s-1] == 1) - return voice; - else if (info[voice-1].voice_pos == 1) - return (voice + 1); - else - return (voice - 1); -} - - -void regroup(voice_index voice) -{ - word_index0 i, j; - word_index0 j2 = 0; - line_info *WITH; - word_index0 FORLIM; - - WITH = &info[voice-1]; - if (debugMode()) - printf("Voice %d has %d bars at ", voice, WITH->nbar); - if (debugMode()) { - FORLIM = WITH->nbar + 1; - for (i = 1; i <= FORLIM; i++) - printf("%d ", WITH->bar_bound[i]); - } - FORLIM = WITH->nbar; - for (i = 1; i <= FORLIM; i++) { - j2 = WITH->bar_bound[i]; - j = j2 + 1; - while (j <= WITH->here && - (bind_left[(long)WITH->scan[j-1]] || WITH->scan[j-1] == barword)) { - WITH->bar_bound[i]++; - j++; - } - } - if (WITH->extra > 0) - WITH->bar_bound[WITH->nbar + 1] = WITH->here; - if (debugMode()) { - printf(" regrouped to "); - FORLIM = WITH->nbar + 1; - for (i = 1; i <= FORLIM; i++) - printf("%d ", WITH->bar_bound[i]); - } - if (debugMode()) - putchar('\n'); - WITH->nword = WITH->here; -} - - -void resetInfo(voice_index voice, Char *buf) -{ - line_info *WITH; - - WITH = &info[voice-1]; - strcpy(buf, P[WITH->mus - 1]); - *P[WITH->mus - 1] = '\0'; - WITH->bar_bound[0] = 0; - WITH->word_bound[0] = 0; - WITH->nbar = 0; - WITH->here = 0; -} - - -void clearLabels(void) -{ - voice_index voice, FORLIM; - line_info *WITH; - - FORLIM = nvoices; - for (voice = 0; voice <= FORLIM - 1; voice++) { - WITH = &info[voice]; - WITH->chord = 0; - WITH->mus = 0; - } -} - - -void appendNote(voice_index voice, music_word nscan) -{ - line_info *WITH; - - WITH = &info[voice-1]; - WITH->here++; - if (WITH->here > max_words) - error3(voice, "Words per line limit exceeded"); - WITH->scan[WITH->here - 1] = nscan; -} - - -void appendToLine(voice_index voice, Char *note) -{ - line_info *WITH; - - if (*note == '\0') - return; - WITH = &info[voice-1]; - sprintf(P[WITH->mus - 1] + strlen(P[WITH->mus - 1]), "%s%c", note, blank); - WITH->word_bound[WITH->here] = strlen(P[WITH->mus - 1]); -} - - -void markBar(voice_index voice) -{ - line_info *WITH; - - WITH = &info[voice-1]; - if (WITH->nbar == 0) - error3(voice, "Empty bar"); - else - WITH->bar_bound[WITH->nbar] = WITH->here; -} - - -short numberOfBars(voice_index voice) -{ - return (info[voice-1].nbar); -} - - -void barForward(voice_index voice, short nbars) -{ - line_info *WITH; - - WITH = &info[voice-1]; - if (WITH->nbar + nbars < 0) - error3(voice, "Next voice before bar is full"); - WITH->nbar += nbars; - if (WITH->nbar > max_bars) - error3(voice, "Bars per line limit exceeded"); - if (nbars > 0) - WITH->bar_bound[WITH->nbar] = WITH->here; -} - - -void setExtraLength(voice_index voice, short ext) -{ - line_info *WITH; - - WITH = &info[voice-1]; - WITH->extra = ext; - WITH->scan[WITH->here] = other; -} - - -short ExtraLength(voice_index voice) -{ - return (info[voice-1].extra); -} - - -voice_index0 findVoice(Char *w_) -{ - voice_index0 Result = 0; - Char w[256]; - short i, FORLIM; - - strcpy(w, w_); - curtail(w, ':'); - FORLIM = nvoices; - for (i = 1; i <= FORLIM; i++) { - if (!strcmp(w, voice_label[i-1])) - return i; - } - getNum(w, &i); - if (i == 0) - return Result; - if (i > 0 && i <= nvoices) - return i; - error("Numeric label outside range 1..nvoices", print); - return Result; -} - - -Static void info3(voice_index voice) -{ - line_info *WITH; - - WITH = &info[voice-1]; - printf("In voice \"%s\" near word %d:\n", voice_label[voice-1], WITH->here); - printf("%*cV\n", WITH->word_bound[WITH->here], ' '); -} - - -void error3(voice_index voice, Char *message) -{ - Char STR1[256]; - - info3(voice); - sprintf(STR1, " %s", message); - error(STR1, print); -} - - -void warning3(voice_index voice, Char *message) -{ - Char STR1[256]; - - info3(voice); - sprintf(STR1, " %s", message); - warning(STR1, print); -} - - -Char *nextMusicWord(Char *Result, voice_index voice) -{ - return (MusicWord(Result, voice, info[voice-1].here)); -} - - -Char *MusicWord(Char *Result, short voice, short n) -{ - line_info *WITH; - - WITH = &info[voice-1]; - if (n > 0 && n <= WITH->nword) - return (substr_(Result, P[WITH->mus - 1], WITH->word_bound[n-1] + 1, - WITH->word_bound[n] - WITH->word_bound[n-1] - 1)); - else - return strcpy(Result, ""); -} - - -music_word thisNote(voice_index voice) -{ - line_info *WITH; - - WITH = &info[voice-1]; - return (WITH->scan[WITH->here - 2]); -} - - -music_word nextNote(voice_index voice) -{ - line_info *WITH; - - WITH = &info[voice-1]; - return (WITH->scan[WITH->here - 1]); -} - - -boolean endOfBar(voice_index voice, short bar_no) -{ - line_info *WITH; - - WITH = &info[voice-1]; - return (WITH->here > WITH->bar_bound[bar_no]); -} - - -void gotoBar(voice_index voice, short bar_no) -{ - line_info *WITH; - - WITH = &info[voice-1]; - WITH->here = WITH->bar_bound[bar_no-1] + 1; -} - - -Char *getMusicWord(Char *Result, voice_index voice) -{ - line_info *WITH; - - WITH = &info[voice-1]; - line_no = orig_line_no[WITH->mus - 1]; - MusicWord(Result, voice, WITH->here); - WITH->here++; - return Result; -} - - -boolean maybeMusicLine(Char *l_) -{ - Char l[256]; - Char w[256]; - music_word nscan; - - strcpy(l, l_); - GetNextWord(w, l, blank, dummy); -/* p2c: mtxline.pas: Note: Eliminated unused assignment statement [338] */ - if (pos1(w[0], "abcdefgr()[]{}CMm") == 0) - return false; - if (pos1(':', w) == 0) - return true; - getNextMusWord(w, l, &nscan); - return (nscan == abcdefg); -} - - -#define nmacros 99 - - -Static boolean macro_initialized = false; -Static Char macro_text[nmacros][256]; - - -Static void macroInit(void) -{ - short i; - - if (macro_initialized) - return; - macro_initialized = true; - for (i = 0; i <= nmacros - 1; i++) - *macro_text[i] = '\0'; -} - - -Static short identifyMacro(Char *s_) -{ - Char s[256]; - short k; - - strcpy(s, s_); - predelete(s, 2); - getNum(s, &k); - return k; -} - - -/* Local variables for getNextMusWord: */ -struct LOC_getNextMusWord { - Char *buf, *note; -} ; - -Local void expandThisMacro(struct LOC_getNextMusWord *LINK) -{ - Char playtag[11]; - short playID; - Char w[256]; - Char STR1[72]; - Char STR2[42]; - Char STR3[68]; - Char STR4[54]; - Char STR5[256], STR7[256]; - - macroInit(); - if (strlen(LINK->note) == 1) - error("Can't terminate a macro that has not been started", print); - playID = identifyMacro(LINK->note); - toString(playtag, playID); -/* p2c: mtxline.pas, line 310: - * Note: Possible string truncation in assignment [145] */ - if (playID < 1 || playID > 99) { - sprintf(STR2, "Macro ID %s is not in range 1..99", playtag); - error(STR2, print); - } - if (LINK->note[1] == 'P') { - if (*macro_text[playID-1] == '\0') { - sprintf(STR3, - "Macro %s inserts empty text: did you define it before use?", - playtag); - warning(STR3, print); - } - if (strlen(macro_text[playID-1]) + strlen(LINK->buf) <= 255) { - if (debugMode()) - printf("Inserting macro %s text \"%s\"\n", - playtag, macro_text[playID-1]); - printf("Buffer before insert: %s\n", LINK->buf); - sprintf(LINK->buf, "%s%s", - macro_text[playID-1], strcpy(STR5, LINK->buf)); - return; - } - sprintf(STR4, "Expansion of macro %s causes buffer overflow", playtag); - error(STR4, print); - } - if (pos1(LINK->note[1], "SR") == 0) { - sprintf(STR4, "Second character %c of macro word should be in \"PRS\"", - LINK->note[1]); - error(STR4, print); - } - *macro_text[playID-1] = '\0'; - do { - GetNextWord(w, LINK->buf, blank, dummy); - if (*w == '\0') { - sprintf(STR1, - "Macro definition %s should be terminated on the same input line", - playtag); - error(STR1, print); - } - if (!strcmp(w, "M")) { - if (debugMode()) - printf("Macro %s is: %s\n", playtag, macro_text[playID-1]); - break; - } - if (w[0] == 'M' && strlen(w) > 1) { - if (w[1] != 'P' || identifyMacro(w) == playID) { - sprintf(STR7, "%s not allowed inside macro definition %s", w, playtag); - error(STR7, print); - } - } - sprintf(macro_text[playID-1] + strlen(macro_text[playID-1]), "%s ", w); - } while (true); - if (LINK->note[1] == 'R') { - LINK->note[1] = 'P'; - sprintf(LINK->buf, "%s %s", LINK->note, strcpy(STR7, LINK->buf)); - } -} - - -void getNextMusWord(Char *buf_, Char *note_, music_word *nscan) -{ - struct LOC_getNextMusWord V; - Char maybe_error[256]; - Char STR2[256]; - - V.buf = buf_; - V.note = note_; - GetNextWord(V.note, V.buf, blank, dummy); - if (*V.note == '\0') - return; - if (V.note[0] == 'M' && expandMacro()) { - expandThisMacro(&V); - getNextMusWord(V.buf, V.note, nscan); - return; - } - if (V.note[0] == '\\') { - *maybe_error = '\0'; - if (V.note[strlen(V.note) - 1] != '\\') - strcpy(maybe_error, V.note); - while (*V.buf != '\0' && V.note[strlen(V.note) - 1] != '\\') - sprintf(V.note + strlen(V.note), " %s", - GetNextWord(STR2, V.buf, blank, dummy)); - if (V.note[strlen(V.note) - 1] != '\\') - error("Unterminated TeX literal", print); - *nscan = texword; - if (*maybe_error != '\0') { - sprintf(STR2, "Possible unterminated TeX literal: %s", maybe_error); - warning(STR2, print); - } - return; - } - if (solfaNoteNames()) { - translateSolfa(V.note); - if (V.note[0] == '"') - predelete(V.note, 1); - } - switch (V.note[0]) { - - case '_': - *nscan = pmxprefix; - delete1(V.note, 1); - break; - - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - *nscan = abcdefg; - break; - - case 'z': - *nscan = zword; - break; - - case '(': - *nscan = lparen; - break; - - case '{': - if (V.note[strlen(V.note) - 1] == '}') - *nscan = lyrtag; - else - *nscan = lparen; - break; - - case ')': - if (pos1('(', V.note) == 0) - *nscan = rparen; - else - *nscan = rlparen; - break; - - case '}': - if (pos1('{', V.note) == 0) - *nscan = rparen; - else - *nscan = rlparen; - break; - - case '[': - *nscan = lbrac; - break; - - case ']': - *nscan = rbrac; - break; - - case '@': - *nscan = atword; - break; - - case 'm': - *nscan = mword; - break; - - case 'r': - *nscan = rword; - break; - - case '#': - case '-': - case 'n': - case 'x': - case '?': - case 's': - case 't': - case 'D': - *nscan = pmxl; - break; - - case 'M': - if (!strcmp(V.note, "M")) - *nscan = endmacro; - else - *nscan = macro; - break; - - case 'G': - if (pos1('A', V.note) > 0) - *nscan = pmxl; - else - *nscan = other; - break; - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (pos1('/', V.note) > 0) - *nscan = mword; - else - *nscan = pmxl; - break; - - case 'o': - *nscan = oword; - break; - - case 'A': - case 'V': - *nscan = FirstOnly; - break; - - case '/': - if (!strcmp(V.note, "//")) - *nscan = nextvoice; - else if (!strcmp(V.note, "/")) { - strcpy(V.note, "//"); - warning("/ changed to //", print); - *nscan = nextvoice; - } else { - error("Word starts with /: do you mean \\?", print); - *nscan = err; - } - break; - - default: - if (pos1('|', V.note) > 0) - *nscan = barword; - else - *nscan = other; - break; - } -} - - -boolean upper(voice_index voice) -{ - line_info *WITH; - - WITH = &info[voice-1]; - if (WITH->voice_pos == 1 && voice < nvoices) - return (WITH->voice_stave == info[voice].voice_stave); - else - return false; -} - - -void describeVoice(voice_index voice, Char *describe_lyr) -{ - short bar, w; - line_info *WITH; - Char STR1[256]; - line_info *WITH1; - short FORLIM; - - WITH = &info[voice-1]; - printf("Voice `%s' is on line %d", voice_label[voice-1], WITH->mus); - if (WITH->vocal) { - printf(", is vocal"); - puts(describe_lyr); - } else { - if (WITH->chord > 0) - printf(" and has chords on line %d", WITH->chord); - putchar('\n'); - } - if (!debugMode()) - return; - WITH1 = &info[voice-1]; - printf("Line has %d bars", WITH1->nbar); - if (WITH1->extra > 0) - printf(" + %d/64 notes\n", WITH1->extra); - else - putchar('\n'); - printf("Bars:"); - FORLIM = WITH1->nbar; - for (bar = 1; bar <= FORLIM; bar++) - printf(" %s ", getBar(STR1, voice, bar)); - printf("\nWord types:"); - FORLIM = WITH1->nword; - for (w = 0; w <= FORLIM - 1; w++) - printf(" %s", name[(long)WITH1->scan[w]]); - putchar('\n'); -} - - -boolean aloneOnStave(stave_index stave) -{ - voice_index v; - - if (number_on_stave[stave-1] != 2) - return true; - else { - v = first_on_stave[stave-1]; - return (info[v-1].mus == 0 || info[v].mus == 0); - } -} - - -void selectVoices(Char *line_) -{ - Char line[256]; - short i = 0; - short k; - Char word[256]; - short FORLIM; - - strcpy(line, line_); - FORLIM = nvoices; - for (k = 0; k <= FORLIM - 1; k++) - selected[k] = false; - printf("Voice change to: %s = ", line); - while (i < nvoices) { - GetNextWord(word, line, blank, dummy); - if (*word == '\0') { - putchar('\n'); - return; - } - i++; - printf("%s ", word); - k = findVoice(word); - if (k == 0) - error("This voice is not in the style", print); - selected[k-1] = true; - } - putchar('\n'); -} - - - - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/mtxline.h b/Build/source/utils/m-tx/mtx-0.60d/mtxline.h deleted file mode 100644 index 23fc05be32c..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/mtxline.h +++ /dev/null @@ -1,83 +0,0 @@ -/* Header for module mtxline, generated by p2c 1.21alpha-07.Dec.93 */ -#ifndef MTXLINE_H -#define MTXLINE_H - - -/* Break input up into words, classify them. Supply words and - information about them. */ - -#ifndef GLOBALS_H -#include "globals.h" -#endif - - -#ifdef MTXLINE_G -# define vextern -#else -# define vextern extern -#endif - - -typedef enum { - other, abcdefg, zword, lyrtag, lparen, rparen, rlparen, lbrac, rbrac, - pmxprefix, pmxl, macro, endmacro, mword, oword, rword, nextvoice, barword, - texword, atword, FirstOnly, err -} music_word; - - -extern boolean bind_left[22]; - -/* changed bind_left[barword] to false */ - -vextern boolean selected[maxvoices]; - - -extern void error3(voice_index voice, Char *message); -extern void warning3(voice_index voice, Char *message); -extern void getNextMusWord(Char *buf, Char *note, music_word *nscan); -extern Char *MusicWord(Char *Result, short voice, short n); -extern Char *nextMusicWord(Char *Result, voice_index voice); -extern music_word thisNote(voice_index voice); -extern music_word nextNote(voice_index voice); -extern Char *getMusicWord(Char *Result, voice_index voice); -extern void gotoBar(voice_index voice, short bar_no); -extern boolean endOfBar(voice_index voice, short bar_no); -extern Char *getBar(Char *Result, voice_index voice, short bar); -extern boolean upper(voice_index voice); -extern void clearLabels(void); -extern voice_index0 findVoice(Char *w); -extern void selectVoices(Char *line); -extern void resetInfo(voice_index voice, Char *buf); -extern void setVocal(voice_index voice, boolean voc); -extern boolean isVocal(voice_index voice); -extern void setStavePos(voice_index voice, stave_index stave, stave_index pos); -extern stave_index voiceStave(voice_index voice); -extern stave_index voicePos(voice_index voice); -extern boolean aloneOnStave(stave_index stave); -extern voice_index companion(voice_index voice); -extern void appendNote(voice_index voice, music_word nscan); -extern void appendToLine(voice_index voice, Char *note); -extern void markBar(voice_index voice); -extern short numberOfBars(voice_index voice); -extern void barForward(voice_index voice, short nbars); -extern void regroup(voice_index voice); - -extern short beatsPerLine(void); -extern void setExtraLength(voice_index voice, short ext); -extern short ExtraLength(voice_index voice); -extern paragraph_index0 musicLineNo(voice_index voice); -extern void setMusicLineNo(voice_index voice, paragraph_index lno); -extern paragraph_index0 chordLineNo(voice_index voice); -extern void setChordLineNo(voice_index voice, paragraph_index lno); -extern void skipChordBar(voice_index voice); - -extern void describeVoice(voice_index voice, Char *describe_lyr); -extern boolean maybeMusicLine(Char *l); -extern Char *musicLine(Char *Result, voice_index voice); - - -#undef vextern - -#endif /*MTXLINE_H*/ - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/mtxline.pas b/Build/source/utils/m-tx/mtx-0.60d/mtxline.pas deleted file mode 100644 index cd3e0b27bcc..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/mtxline.pas +++ /dev/null @@ -1,447 +0,0 @@ -unit mtxline; -{ Break input up into words, classify them. Supply words and - information about them. } - -interface uses globals; - -type - music_word = (other, abcdefg, zword, lyrtag, - lparen, rparen, rlparen, lbrac, rbrac, - pmxl, macro, endmacro, mword, oword, rword, nextvoice, - barword, texword, atword, FirstOnly, err ); - -const - bind_left: array[music_word] of boolean = ( - false, false, true, false, - false, true, true, false, true, - true, false, true, false, true, false, true, - false, false, false, false, false ); -{ changed bind_left[barword] to false } - -var selected: array[voice_index] of boolean; - -procedure error3(voice: voice_index; message: string ); -procedure warning3(voice: voice_index; message: string ); -procedure getNextMusWord (var buf, note: string; var nscan: music_word); -function MusicWord(voice, n: integer): string; -function nextMusicWord(voice: voice_index): string; -function thisNote(voice: voice_index): music_word; -function nextNote(voice: voice_index): music_word; -function getMusicWord(voice: voice_index): string; -procedure gotoBar(voice: voice_index; bar_no: integer); -function endOfBar(voice: voice_index; bar_no: integer): boolean; -function getBar(voice:voice_index; bar: integer): string; -function upper(voice: voice_index): boolean; -procedure clearLabels; -function findVoice(w: string): voice_index0; -procedure selectVoices(line: string); -procedure resetInfo(voice: voice_index; var buf: string); -procedure setVocal(voice: voice_index; voc: boolean); -function isVocal(voice: voice_index): boolean; -procedure setStavePos(voice: voice_index; stave, pos: stave_index); -function voiceStave(voice: voice_index): stave_index; -function voicePos(voice: voice_index): stave_index; -function aloneOnStave(stave: stave_index): boolean; -function companion(voice: voice_index): voice_index; -procedure appendNote(voice: voice_index; nscan: music_word); -procedure appendToLine(voice: voice_index; note: string); -procedure markBar(voice: voice_index); -function numberOfBars(voice: voice_index): integer; -procedure barForward(voice: voice_index; nbars: integer); -procedure regroup(voice: voice_index); - -function beatsPerLine: integer; -procedure setExtraLength(voice: voice_index; ext: integer); -function ExtraLength(voice: voice_index): integer; -function musicLineNo(voice: voice_index): paragraph_index0; -procedure setMusicLineNo(voice: voice_index; lno: paragraph_index); -function chordLineNo(voice: voice_index): paragraph_index0; -procedure setChordLineNo(voice: voice_index; lno: paragraph_index); -procedure skipChordBar(voice: voice_index); - -procedure describeVoice(voice: voice_index; describe_lyr: string); -function maybeMusicLine(l: string): boolean; -function musicLine(voice: voice_index): string; - -implementation uses strings, notes, control, utility; - -const - - name: array[music_word] of string[9] = ( - '?', 'note', 'znote', 'lyricsTag', - '(', ')', ')(', '[', ']', - 'PMX<', 'macro', 'endMacro', 'meter', 'ornament', 'rest', '//', - 'BAR', 'TeX', '@', 'firstonly', 'ERROR'); - -type - word_scan = array[1..max_words] of music_word; - - line_info = record - here, nword: word_index0; - nbar: bar_index0; - voice_pos, voice_stave, mus, chord: paragraph_index0; - extra: integer; - vocal: boolean; - bar_bound: array[bar_index0] of word_index0; - word_bound: array[word_index0] of integer; - scan: word_scan; - end; - -var info: array[voice_index] of line_info; - -{ ------------------------------------------------------------- } - -function beatsPerLine: integer; - var voice: voice_index; -begin for voice:=1 to nvoices do with info[voice] do - if (nbar>0) or (extra>0) then - begin - if extra mod one_beat > 0 - then error3(voice,'Line length not an integer number of beats'); - beatsPerLine := nbar*meternum + extra div one_beat; - end; -end; - -procedure skipChordBar(voice: voice_index); -begin with info[voice] do - if chord>0 then if P[chord]=barsym then predelete(P[chord],1); -end; - -function getBar(voice: voice_index; bar: integer): string; -begin with info[voice] do - getBar := substr(P[mus],word_bound[bar_bound[bar-1]]+1, - word_bound[bar_bound[bar]]-word_bound[bar_bound[bar-1]]); -end; - -function musicLine(voice: voice_index): string; -begin musicLine:=P[musicLineNo(voice)]; end; - -function musicLineNo(voice: voice_index): paragraph_index0; -begin musicLineNo := info[voice].mus; end; - -procedure setMusicLineNo(voice: voice_index; lno: paragraph_index); -begin info[voice].mus := lno; end; - -function chordLineNo(voice: voice_index): paragraph_index0; -begin chordLineNo := info[voice].chord; end; - -procedure setChordLineNo(voice: voice_index; lno: paragraph_index); -begin info[voice].chord := lno; end; - -procedure setVocal(voice: voice_index; voc: boolean); -begin info[voice].vocal:=voc; end; - -function isVocal(voice: voice_index): boolean; -begin isVocal := info[voice].vocal; end; - -procedure setStavePos(voice: voice_index; stave, pos: stave_index); -begin with info[voice] do begin voice_pos:=pos; voice_stave:=stave; end; -end; - -function voiceStave(voice: voice_index): stave_index; -begin voiceStave:=info[voice].voice_stave; end; - -function voicePos(voice: voice_index): stave_index; -begin voicePos:=info[voice].voice_pos; end; - -function companion(voice: voice_index): voice_index; - var s: integer; -begin s:=info[voice].voice_stave; - if number_on_stave[s]=1 then companion:=voice - else if info[voice].voice_pos=1 then companion:=voice+1 - else companion:=voice-1; -end; - -procedure regroup(voice: voice_index); - var i, j, j2: word_index0; -begin j2 := 0; with info[voice] do - begin if debugMode then write('Voice ',voice,' has ',nbar,' bars at '); - if debugMode then for i:=1 to nbar+1 do write(bar_bound[i],' '); - for i:=1 to nbar do - begin j2:=bar_bound[i]; j:=j2+1; - while (j<=here) and (bind_left[scan[j]] or (scan[j]=barword)) do - begin inc(bar_bound[i]); inc(j) end; - end; - if extra>0 then bar_bound[nbar+1]:=here; - if debugMode then - begin write(' regrouped to '); - for i:=1 to nbar+1 do write(bar_bound[i],' ') - end; - if debugMode then writeln; - nword := here - end; -end; - -procedure resetInfo(voice: voice_index; var buf: string); -begin with info[voice] do - begin buf := P[mus]; P[mus]:=''; - bar_bound[0]:=0; word_bound[0]:=0; nbar:=0; here := 0; - end; -end; - -procedure clearLabels; - var voice: voice_index; -begin for voice:=1 to nvoices do with info[voice] do - begin chord:=0; mus:=0; end; -end; - -procedure appendNote(voice: voice_index; nscan: music_word); -begin with info[voice] do - begin inc(here); if here>max_words then - error3(voice,'Words per line limit exceeded'); - scan[here]:=nscan; end; -end; - -procedure appendToLine(voice: voice_index; note: string); -begin if note<>'' then with info[voice] do - begin P[mus]:=P[mus]+note+blank; word_bound[here]:=length(P[mus]); end; -end; - -procedure markBar(voice: voice_index); -begin with info[voice] do - if nbar=0 then error3(voice,'Empty bar') else bar_bound[nbar]:=here -end; - -function numberOfBars(voice: voice_index): integer; -begin numberOfBars := info[voice].nbar; end; - -procedure barForward(voice: voice_index; nbars: integer); -begin with info[voice] do - begin - if (nbar+nbars<0) then error3(voice, 'Next voice before bar is full'); - inc(nbar,nbars); - if nbar>max_bars then error3(voice,'Bars per line limit exceeded'); - if nbars>0 then bar_bound[nbar]:=here; - end; -end; - -procedure setExtraLength(voice: voice_index; ext: integer); -begin with info[voice] do begin extra:=ext; scan[here+1]:=other; end; -end; - -function ExtraLength(voice: voice_index): integer; -begin ExtraLength := info[voice].extra; end; - -function findVoice(w: string): voice_index0; - var i: integer; -begin curtail(w,':'); findVoice:=0; - for i:=1 to nvoices do - if w=voice_label[i] then begin findVoice:=i; exit end; - getNum(w,i); if i=0 then exit; - if (i>0) and (i<=nvoices) then findVoice:=i - else error('Numeric label outside range 1..nvoices',print); -end; - -procedure info3(voice: voice_index); -begin with info[voice] do - begin - writeln ('In voice "', voice_label[voice], '" near word ', here, ':'); - writeln(' ':word_bound[here],'V') - end -end; - -procedure error3(voice: voice_index; message: string ); -begin info3(voice); error(' '+message,print) end; - -procedure warning3(voice: voice_index; message: string ); -begin info3(voice); warning(' '+message,print) end; - -function nextMusicWord(voice: voice_index): string; -begin nextMusicWord := MusicWord(voice,info[voice].here); end; - -function MusicWord(voice, n: integer): string; - begin with info[voice] do if (n>0) and (n<=nword) then - MusicWord := substr(P[mus],word_bound[n-1]+1, - word_bound[n]-word_bound[n-1]-1) - else MusicWord := ''; - end; - -function thisNote(voice: voice_index): music_word; -begin with info[voice] do thisNote := scan[here-1]; end; - -function nextNote(voice: voice_index): music_word; -begin with info[voice] do nextNote := scan[here]; end; - -function endOfBar(voice: voice_index; bar_no: integer): boolean; -begin with info[voice] do endOfBar := here > bar_bound[bar_no]; end; - -procedure gotoBar(voice: voice_index; bar_no: integer); -begin with info[voice] do here := bar_bound[bar_no-1]+1; end; - -function getMusicWord(voice: voice_index): string; -begin with info[voice] do - begin line_no := orig_line_no[mus]; - GetMusicWord := MusicWord(voice,here); inc(here); - end -end; - -function maybeMusicLine(l: string): boolean; - var w: string; - nscan: music_word; -begin w:=GetNextWord(l,blank,dummy); maybeMusicLine := false; - if pos1(w[1],'abcdefgr()[]{}CMm')=0 then begin maybeMusicLine := false; exit end; - if pos1(':',w)=0 then begin maybeMusicLine := true; exit end; - GetNextMusWord(w,l,nscan); maybeMusicLine := nscan=abcdefg; -end; - -const macro_initialized: boolean=false; - nmacros = 99; -var macro_text: array[1..nmacros] of string; -procedure macroInit; - var i: integer; -begin if macro_initialized then exit else macro_initialized:=true; - for i:=1 to nmacros do macro_text[i]:='' -end; - -function identifyMacro(s: string): integer; - var k: integer; -begin predelete(s,2); getNum(s,k); identifyMacro:=k -end; - -procedure GetNextMusWord (var buf, note: string; var nscan: music_word); - var maybe_error: string; - - procedure expandThisMacro; - var playtag: string[10]; - playID: integer; - w: string; - begin macroInit; if length(note)=1 then - error('Can''t terminate a macro that has not been started',print); - playID:=identifyMacro(note); playtag:=toString(playID); - if (playID<1) or (playID>99) then - error('Macro ID '+playtag+' is not in range 1..99',print); - if note[2]='P' then - begin if macro_text[playID]='' then - warning('Macro '+playtag+ - ' inserts empty text: did you define it before use?',print); - if length(macro_text[playID])+length(buf)>255 - then error('Expansion of macro '+playtag+' causes buffer overflow',print) - else begin if debugMode then writeln('Inserting macro '+playtag+' text "' - +macro_text[playID]+'"'); - writeln('Buffer before insert: ',buf); - buf:=macro_text[playID]+buf; exit - end - end; - if pos1(note[2],'SR')=0 then error('Second character '+note[2]+ - ' of macro word should be in "PRS"',print); - macro_text[playID]:=''; - repeat w:=getNextWord(buf,blank,dummy); - if w='' then error('Macro definition '+playtag+ - ' should be terminated on the same input line',print); - if w='M' then begin - if debugMode then writeln('Macro '+playtag+' is: '+macro_text[playID]); - break - end; - if (w[1]='M') and (length(w)>1) then - if (w[2]<>'P') or (identifyMacro(w)=playID) then - error(w+' not allowed inside macro definition '+playtag,print); - macro_text[playID]:=macro_text[playID]+w+' ' - until false; - if note[2]='R' then begin note[2]:='P'; buf:=note+' '+buf end - end; - - begin note:=GetNextWord(buf,blank,dummy); - if note='' then exit; - if (note[1]='M') and expandMacro then - begin expandThisMacro; GetNextMusWord(buf,note,nscan); exit end; - if note[1]='\' then - begin maybe_error:=''; - if note[length(note)]<>'\' then maybe_error:=note; - while (buf<>'') and (note[length(note)]<>'\') do - note:=note+' '+GetNextWord(buf,blank,dummy); - if note[length(note)]<>'\' then - error('Unterminated TeX literal',print); - nscan:=texword; - if maybe_error<>'' then - warning('Possible unterminated TeX literal: '+maybe_error,print); - exit; - end; - if solfaNoteNames then - begin translateSolfa(note[1]); if note[1]='"' then predelete(note,1); - end; - case note[1] of -'a'..'g': nscan:=abcdefg; -'z': nscan:=zword; -'(': nscan:=lparen; -'{': if note[length(note)]='}' then nscan:=lyrtag else nscan:=lparen; -')': if pos1('(',note)=0 then nscan:=rparen else nscan:=rlparen; -'}': if pos1('{',note)=0 then nscan:=rparen else nscan:=rlparen; -'[': nscan:=lbrac; -']': nscan:=rbrac; -'@': nscan:=atword; -'m': nscan:=mword; -'r': nscan:=rword; -'#','-','n','x','?','s','t','D': nscan:=pmxl; -'M': if note='M' then nscan:=endMacro else nscan:=macro; -'G': if pos1('A',note)>0 then nscan:=pmxl else nscan:=other; -'1'..'9': if pos1('/',note)>0 then nscan:=mword else nscan:=pmxl; -'o': nscan:=oword; -'A', 'V': nscan:=FirstOnly; -'/': if note='//' then nscan:=nextvoice - else if note='/' then - begin note:='//'; warning('/ changed to //',print); nscan:=nextvoice; - end - else begin error('Word starts with /: do you mean \?',print); - nscan:=err; - end; - else if pos1('|',note)>0 then nscan:=barword else - nscan:=other; - end; - end; - -function upper(voice: voice_index): boolean; -begin with info[voice] do - if (voice_pos=1) and (voice0 then write(' and has chords on line ',chord); - writeln; - end; - if debugMode then with info[voice] do - begin write('Line has ', nbar, ' bars'); - if extra>0 then writeln(' + ', extra, '/64 notes') else writeln; - write('Bars:'); - for bar:=1 to nbar do write(' ',getBar(voice,bar),' '); - writeln; write('Word types:'); - for w:=1 to nword do write(' ',name[scan[w]]); writeln; - end; - end; -end; - -function aloneOnStave(stave: stave_index): boolean; - var v: voice_index; -begin - if number_on_stave[stave]<>2 then aloneOnStave:=true else - begin v:=first_on_stave[stave]; - aloneOnStave:= (info[v].mus=0) or (info[v+1].mus=0) - end -end; - -procedure selectVoices(line: string); - var i, k: integer; - word: string; - begin - for k:=1 to nvoices do selected[k]:=false; - write('Voice change to: ',line,' = '); - i:=0; - while iname)) - return true; - previous = previous->prev; - } - return false; -} - - -void pushFile(Char *filename) -{ - filenode *newnode; - Char STR3[256]; - - if (recursive(filename)) { - printf("===! Ignoring recursive include of file %s\n", filename); - return; - } - newnode = Malloc(sizeof(filenode)); - newnode->actualfile = NULL; - strcpy(newnode->name, filename); - newnode->prev = current; - newnode->lineno = 0; - strcpy(newnode->actualfile_NAME, filename); - if (newnode->actualfile != NULL) - newnode->actualfile = freopen(newnode->actualfile_NAME, "r", - newnode->actualfile); - else - newnode->actualfile = fopen(newnode->actualfile_NAME, "r"); - _SETIO(newnode->actualfile != NULL, FileNotFound); - inputerror = (P_ioresult != 0); - if (inputerror) - Free(newnode); - else - current = newnode; - if (!inputerror && (reportitem & reportnewfile) > 0) - printf("==>> Input from file %s\n", currentFilename(STR3)); - if (inputerror && (reportitem & reporterror) > 0) - printf("==!! Could not open file %s\n", filename); -} - - -void popFile(void) -{ - filenode *previous; - Char STR2[256]; - Char STR3[256]; - - if (current == NULL) - return; - if ((reportitem & reportclose) > 0) - printf("==>> Closing file %s at line number %d\n", - currentFilename(STR2), currentLineNo()); - if (current->actualfile != NULL) - fclose(current->actualfile); - current->actualfile = NULL; - previous = current->prev; - Free(current); - current = previous; - if (current != NULL && (reportitem & reportoldfile) > 0) - printf("==>> Resuming input from file %s at line number %d\n", - currentFilename(STR3), currentLineNo()); -} - - -void closeAll(void) -{ - do { - popFile(); - } while (current != NULL); -} - - -boolean eofCurrent(void) -{ - return P_eof(current->actualfile); -} - - -Char *readLine(Char *Result) -{ - Char s[256]; - Char *TEMP; - Char STR2[256]; - - if (*nextData != '\0') { - strcpy(Result, nextData); - *nextData = '\0'; - return Result; - } - if (eofAll()) - return strcpy(Result, ""); - _SETIO(fgets(s, 256, current->actualfile) != NULL, EndOfFile); - TEMP = strchr(s, '\n'); - if (TEMP != NULL) - *TEMP = 0; - strcpy(Result, s); - inputerror = (P_ioresult != 0); - if (!inputerror) - current->lineno++; - if (inputerror && (reportitem & reporterror) > 0) - printf("==!! Could not read from file %s\n", currentFilename(STR2)); - return Result; -} - - -boolean isEmpty(Char *s) -{ - short i, FORLIM; - - if (*s == '\0') - return true; - FORLIM = strlen(s); - for (i = 0; i <= FORLIM - 1; i++) { - if (s[i] != ' ') - return false; - } - return true; -} - - -Char *readData(Char *Result) -{ - Char s[256]; - - if (!isEmpty(nextData)) { - strcpy(Result, nextData); - *nextData = '\0'; - return Result; - } - while (!eofAll()) { - readLine(s); - if (!isEmpty(s)) - return strcpy(Result, s); - } - return strcpy(Result, ""); -} - - -void skipBlanks(void) -{ - while (*nextData == '\0') { - readData(nextData); - if (eofAll()) - return; - } -} - - -boolean eofAll(void) -{ - boolean Result; - -/* p2c: multfile.pas: Note: Eliminated unused assignment statement [338] */ - if (current == NULL) - return true; - if (eofCurrent()) { - popFile(); - return (eofAll()); - } - return false; -} - - -short currentLineNo(void) -{ - if (current == NULL) - return 0; - else - return (current->lineno); -} - - -Char *currentFilename(Char *Result) -{ - if (current == NULL) - return strcpy(Result, "No file open yet"); - else - return strcpy(Result, current->name); -} - - -boolean fileError(void) -{ - return inputerror; -} - - - - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/multfile.h b/Build/source/utils/m-tx/mtx-0.60d/multfile.h deleted file mode 100644 index aaa094cdae7..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/multfile.h +++ /dev/null @@ -1,87 +0,0 @@ -/* Header for module multfile, generated by p2c 1.21alpha-07.Dec.93 */ -#ifndef MULTFILE_H -#define MULTFILE_H - - -#ifdef MULTFILE_G -# define vextern -#else -# define vextern extern -#endif -/* DPL 2004-03-06 -(* Support for including files into an input stream. -(* Intended for an application that does not require Pascal formatting, -(* but reads complete lines one at a time. -(* You never actually work with any files, except by supplying the -( filename when the file is opened. -(* At any stage, you can switch the input to a new file. -(* When the new file is at EOF, and a "read" is issued, the file is -(* closed and the previous one resumed transparently. This inclusion -(* can be nested to any level, memory permitting. -(* --- Normal mode of operation, replacing the usual Pascal style --- - Instead of: assign(textfile,filename); reset(textfile) - use: pushFile(filename) - When another file should be included before the current file is done, - use: pushFile(newfilename) - Instead of: readln(textfile,line) - use: line:=readLine - Instead of: eof(textfilen) - or: eofAll; {Are all files at EOF?} -(* --- Abnormal mode of operation --- - To abort a file before EOF is reached: - use: popFile; - To abort all files: - use: closeAll; - To test whether only the current file is at EOF: - use: eofCurrent; -(* Additional features: - fileError: boolean function, was there an error during file open or read? - currentFilename: string function, name of current file - currentLineNo: integer function, number of line just read from current file - isEmpty(var s: string): boolean function, is s empty? - readData: string function, like readLine, but continue reading until - a non-blank line is found, return blank only at EOF - skipBlanks: skip blank lines in input: next call to readLine will be - non-blank unless EOF is encountered - report(items): procedure to control which messages are printed, - "items" is the sum of the following options - (constants with the appropriate values are defined in the interface) - 1: reportnewfile - file is opened - 2: reportoldfile - file is resumed - 4: reportclose - file is closed - 8: reporterror - a file error is encountered - 16: reportrecursive - there is a recursive include - The default value is items=27 (all the above except reportclose) - At present you cannot turn reportrecursive off. - */ - -extern void pushFile(Char *filename); -extern void popFile(void); -extern void closeAll(void); -extern void report(short items); -extern Char *currentFilename(Char *Result); -extern boolean eofAll(void); -extern boolean eofCurrent(void); -extern boolean fileError(void); -extern Char *readLine(Char *Result); -extern Char *readData(Char *Result); -extern boolean isEmpty(Char *s); -extern short currentLineNo(void); -extern void skipBlanks(void); - - -#define reportnewfile 1 -#define reportoldfile 2 -#define reportclose 4 -#define reporterror 8 -#define reportrecursive 16 - - -extern Char nextData[256]; - - -#undef vextern - -#endif /*MULTFILE_H*/ - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/multfile.pas b/Build/source/utils/m-tx/mtx-0.60d/multfile.pas deleted file mode 100644 index 6c272992a3f..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/multfile.pas +++ /dev/null @@ -1,196 +0,0 @@ -unit multfile; (* DPL 2004-03-06 -(* Support for including files into an input stream. -(* Intended for an application that does not require Pascal formatting, -(* but reads complete lines one at a time. -(* You never actually work with any files, except by supplying the -( filename when the file is opened. -(* At any stage, you can switch the input to a new file. -(* When the new file is at EOF, and a "read" is issued, the file is -(* closed and the previous one resumed transparently. This inclusion -(* can be nested to any level, memory permitting. -(* --- Normal mode of operation, replacing the usual Pascal style --- - Instead of: assign(textfile,filename); reset(textfile) - use: pushFile(filename) - When another file should be included before the current file is done, - use: pushFile(newfilename) - Instead of: readln(textfile,line) - use: line:=readLine - Instead of: eof(textfilen) - or: eofAll; {Are all files at EOF?} -(* --- Abnormal mode of operation --- - To abort a file before EOF is reached: - use: popFile; - To abort all files: - use: closeAll; - To test whether only the current file is at EOF: - use: eofCurrent; -(* Additional features: - fileError: boolean function, was there an error during file open or read? - currentFilename: string function, name of current file - currentLineNo: integer function, number of line just read from current file - isEmpty(var s: string): boolean function, is s empty? - readData: string function, like readLine, but continue reading until - a non-blank line is found, return blank only at EOF - skipBlanks: skip blank lines in input: next call to readLine will be - non-blank unless EOF is encountered - report(items): procedure to control which messages are printed, - "items" is the sum of the following options - (constants with the appropriate values are defined in the interface) - 1: reportnewfile - file is opened - 2: reportoldfile - file is resumed - 4: reportclose - file is closed - 8: reporterror - a file error is encountered - 16: reportrecursive - there is a recursive include - The default value is items=27 (all the above except reportclose) - At present you cannot turn reportrecursive off. - *) -interface - - procedure pushFile(filename: string); - procedure popFile; - procedure closeAll; - procedure report(items: integer); - function currentFilename: string; - function eofAll: boolean; - function eofCurrent: boolean; - function fileError: boolean; - function readLine: string; - function readData: string; - function isEmpty(var s: string): boolean; - function currentLineNo: integer; - procedure skipBlanks; - const nextData: string = ''; - -const - reportnewfile = 1; - reportoldfile = 2; - reportclose = 4; - reporterror = 8; - reportrecursive = 16; - -implementation - - type - pfilenode = ^filenode; - filenode = record - name: string; - actualfile: text; - prev: pfilenode; - lineno: integer; - end; - - const current: pfilenode = NIL; - inputerror: boolean = false; - reportitem: integer = reportnewfile + reportoldfile - + reporterror + reportrecursive; - - procedure report(items: integer); begin reportitem := items end; - - function recursive (filename: string): boolean; - var previous: pfilenode; - begin if current=NIL then begin recursive:=false; exit; end; - previous := current; recursive:=true; - while previous <> NIL do - begin - if filename=previous^.name then exit; - previous := previous^.prev; - end; - recursive:=false - end; - - procedure pushFile(filename: string); - var newnode: pfilenode; - begin - if recursive(filename) then - begin writeln('===! Ignoring recursive include of file ',filename); exit; - end; - new(newnode); newnode^.name := filename; newnode^.prev := current; - newnode^.lineno := 0; -{$I-} - assign(newnode^.actualfile,filename); reset(newnode^.actualfile); -{$I+} - inputerror := ioresult<>0; - if inputerror then dispose(newnode) else current := newnode; - if not inputerror and ((reportitem and reportnewfile)>0) then writeln - ('==>> Input from file ',currentFilename); - if inputerror and ((reportitem and reporterror)>0) then writeln - ('==!! Could not open file ',filename); - end; - - procedure popFile; - var previous: pfilenode; - begin if current=NIL then exit; - if (reportitem and reportclose)>0 then writeln - ('==>> Closing file ',currentFilename,' at line number ', currentLineNo:1); - close(current^.actualfile); previous := current^.prev; dispose(current); - current := previous; - if (current<>NIL) and ((reportitem and reportoldfile)>0) then writeln - ('==>> Resuming input from file ',currentFilename,' at line number ', - currentLineNo:1); - end; - - procedure closeAll; begin repeat popFile until current=NIL; end; - - function eofCurrent: boolean; - begin eofCurrent := eof(current^.actualfile); - end; - - function readLine: string; - var s: string; - begin if nextData<>'' then - begin readLine:=nextData; nextData:=''; exit end; - if eofAll then begin readLine:=''; exit end; -{$I-} - readln(current^.actualfile,s); readLine:=s; -{$I+} - inputerror := ioresult<>0; - if not inputerror then inc(current^.lineno); - if inputerror and ((reportitem and reporterror)>0) then writeln - ('==!! Could not read from file ',currentFilename); - end; - - function isEmpty(var s: string): boolean; - var i: integer; - begin if length(s)=0 then begin isEmpty:=true; exit; end; - for i:=1 to length(s) do if s[i]<>' ' then - begin isEmpty:=false; exit; end; - isEmpty:=true - end; - - function readData: string; - var s: string; - begin if not isEmpty(nextData) then - begin readData:=nextData; nextData:=''; exit end; - while not eofAll do - begin s:=readLine; - if not isEmpty(s) then begin readData:=s; exit end; - end; - readData:=''; - end; - - procedure skipBlanks; - begin while nextData='' do - begin nextData:=readData; if eofAll then exit - end - end; - - function eofAll: boolean; - begin eofAll := true; - if current=NIL then exit else - if eofCurrent then begin popFile; eofAll:=eofAll; exit end; - eofAll:=false - end; - - function currentLineNo: integer; - begin if current = NIL then currentLineNo := 0 - else currentLineNo := current^.lineno; - end; - - function currentFilename: string; - begin if current = NIL then currentFilename := 'No file open yet' - else currentFilename := current^.name; - end; - - function fileError: boolean; begin fileError := inputerror; end; - -end. diff --git a/Build/source/utils/m-tx/mtx-0.60d/notes.c b/Build/source/utils/m-tx/mtx-0.60d/notes.c deleted file mode 100644 index c212896cf90..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/notes.c +++ /dev/null @@ -1,547 +0,0 @@ -/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ -/* From input file "notes.pas" */ - - -#include "p2c.h" - - -#define NOTES_G -#include "notes.h" - - -short count64['9' + 1 - '0'] = { - 64, 4, 32, 2, 16, 0, 1, 0, 8, 128 -}; - -#ifndef STRINGS_H -#include "strings.h" -#endif - -#ifndef GLOBALS_H -#include "globals.h" -#endif - - -typedef struct parsedNote { - Char name; - Char duration[2]; - Char octave[9]; - Char accidental[17], whatever[17], dotgroup[17], xtuplet[17]; - Char shortcut[33]; -} parsedNote; - - -Static Void printNote(n) -parsedNote n; -{ - printf("%c|%s|%s|%s|%s|%s|%s|%s\n", - n.name, n.duration, n.octave, n.accidental, n.whatever, n.dotgroup, - n.xtuplet, n.shortcut); -} - - -/* If rearrangeNote is TRUE, translate original note to the following form: - 1. Note name. - 2. Duration. - 3. Octave adjustments. - 4. Everything except the other six items. - 5. Accidental with adjustments (rest: height adjustment) - 6. Dot with adjustments. - 7. Xtuplet group. -*/ - -Void translateSolfa(nt) -Char *nt; -{ - short k; - - if (!solfaNoteNames()) - return; - k = pos1(*nt, solfa_names); - if (k > 0) - *nt = has_duration[k-1]; -} - - -Char durationCode(note) -Char *note; -{ - Char Result = unspecified; - Char code; - - if (strlen(note) <= 1) - return Result; - code = note[1]; - if (pos1(code, durations) > 0) - return code; - return Result; -} - - -Static Char half(dur) -Char dur; -{ - Char Result; - short k; - Char STR1[20]; - Char STR2[24]; - - k = pos1(dur, durations); - Result = dur; - if (k == 0) { - sprintf(STR1, "Invalid duration %c", dur); - error(STR1, print); - return Result; - } - if (k <= ndurs) - return (durations[k]); - sprintf(STR2, "%c is too short to halve", dur); - error(STR2, print); - return Result; -} - - -Static Void addDuration(note, dur) -Char *note; -Char dur; -{ - if (insertDuration()) - insertChar(dur, note, 2); -} - - -/* Extract procedures. All of these remove part of "note" (sometimes - the part is empty) and put it somewhere else. The part may be anywhere - in "note", except when otherwise specified.*/ - -/* Unconditionally extracts the first character. */ - -Static Void extractFirst(note, first) -Char *note; -Char *first; -{ - *first = note[0]; - predelete(note, 1); -} - - -/* Extracts at most one of the characters in "hits". */ - -Static Void extractOneOf(note, hits, hit) -Char *note; -Char *hits; -Char *hit; -{ - short i, l; - - l = strlen(note); - *hit = '\0'; - for (i = 1; i <= l; i++) { - if (pos1(note[i-1], hits) > 0) { - sprintf(hit, "%c", note[i-1]); - delete1(note, i); - return; - } - } -} - - -/* Extracts contiguous characters in "hits" until no more are found. - There may be more later. */ - -Static Void extractContiguous(note, hits, hit) -Char *note; -Char *hits; -Char *hit; -{ - short i, l, len; - - l = strlen(note); - len = l; - *hit = '\0'; - for (i = 1; i <= l; i++) { - if (pos1(note[i-1], hits) > 0) { - do { - if (pos1(note[i-1], hits) == 0) - return; - sprintf(hit + strlen(hit), "%c", note[i-1]); - delete1(note, i); - len--; - } while (len >= i); - return; - } - } -} - - -/* Extracts the specified character and everything after it. */ - -Static Void extractAfter(note, delim, tail) -Char *note; -Char delim; -Char *tail; -{ - short newlen; - - newlen = pos1(delim, note); - *tail = '\0'; - if (newlen == 0) - return; - newlen--; - strcpy(tail, note); - predelete(tail, newlen); - note[(long)((int)newlen)] = '\0'; -/* p2c: notes.pas, line 108: - * Note: Modification of string length may translate incorrectly [146] */ -} - - -/* Extracts the dot shortcut part of a note: comma shortcut is no problem - because a comma cannot be part of a number. */ - -Static Void extractDotShortcut(note, tail) -Char *note, *tail; -{ - Char names[256], tail2[256]; - short l = 1; - short lt; - Char ch; - - extractAfter(note, '.', tail); - lt = strlen(tail); - if (l < lt && tail[1] == '.') - l = 2; - if (solfaNoteNames()) - strcpy(names, solfa_names); - else - strcpy(names, has_duration); - if (l < lt && pos1(tail[l], names) > 0) { - translateSolfa(&tail[l]); - return; - } - if (l == 2) - error("\"..\" followed by non-note", print); - if (l >= lt) { - strcat(note, tail); - *tail = '\0'; - return; - } - ch = tail[0]; - predelete(tail, 1); - extractDotShortcut(tail, tail2); - sprintf(note + strlen(note), "%c%s", ch, tail); - strcpy(tail, tail2); -} - - -/* Extracts a signed number. */ - -Static Void extractSignedNumber(note, number) -Char *note, *number; -{ - short k; - Char note0[256]; - - k = pos1('+', note); - if (k == 0) - k = pos1('-', note); - *number = '\0'; - if (k == 0) - return; - strcpy(note0, note); - do { - sprintf(number + strlen(number), "%c", note[k-1]); - delete1(note, k); - } while (k <= strlen(note) && - (note[k-1] == '0' || pos1(note[k-1], digits) != 0)); - if (strlen(number) == 1) { - strcpy(note, note0); - *number = '\0'; - } -} - - -/* Local variables for extractGroup: */ -struct LOC_extractGroup { - Char *group; - short gl, k; - boolean probe, nonumber; -} ; - -Local Void tryMore(LINK) -struct LOC_extractGroup *LINK; -{ - while (LINK->k <= LINK->gl && LINK->group[LINK->k-1] == LINK->group[0]) - LINK->k++; -} - -Local Void try_(s, LINK) -Char *s; -struct LOC_extractGroup *LINK; -{ - LINK->probe = (LINK->k < LINK->gl && pos1(LINK->group[LINK->k-1], s) > 0); - if (LINK->probe) - LINK->k++; -} - -Local Void tryNumber(LINK) -struct LOC_extractGroup *LINK; -{ - boolean dot_ = false; - - LINK->nonumber = true; - while (LINK->k <= LINK->gl && pos1(LINK->group[LINK->k-1], digitsdot) > 0) { - LINK->k++; - if (LINK->group[LINK->k-1] == '.') { - if (dot_) - error("Extra dot in number", print); - else - dot_ = true; - } else - LINK->nonumber = false; - } -} - - -/* Extracts a symbol followed by optional +- or <> shift indicators */ - -Static Void extractGroup(note, delim, group_) -Char *note; -Char delim; -Char *group_; -{ - struct LOC_extractGroup V; - short k0; - Char tail[256]; - - V.group = group_; - extractAfter(note, delim, V.group); - if (*V.group == '\0') - return; - V.gl = strlen(V.group); - V.k = 2; - if (V.gl > 1 && V.group[1] == ':') - V.k = 3; - else { - tryMore(&V); - k0 = V.k; - try_("+-<>", &V); - if (V.probe) - tryNumber(&V); - if (V.nonumber) - V.k = k0; - k0 = V.k; - try_("+-<>", &V); - if (V.probe) - tryNumber(&V); - if (V.nonumber) - V.k = k0; - } - strcpy(tail, V.group); - V.k--; - V.group[(long)((int)V.k)] = '\0'; -/* p2c: notes.pas, line 169: - * Note: Modification of string length may translate incorrectly [146] */ - predelete(tail, V.k); - strcat(note, tail); -} - - -Static Void parseNote(note_, pnote) -Char *note_; -parsedNote *pnote; -{ - Char note[256]; - Char onlymidi[256]; - Char STR1[256]; - Char STR2[10]; - - strcpy(note, note_); - *pnote->shortcut = '\0'; - *pnote->xtuplet = '\0'; - *pnote->accidental = '\0'; - *pnote->dotgroup = '\0'; - *pnote->duration = '\0'; - *pnote->octave = '\0'; - *onlymidi = '\0'; - extractFirst(note, &pnote->name); - extractAfter(note, 'x', pnote->xtuplet); - extractAfter(note, ',', pnote->shortcut); - if (*pnote->shortcut == '\0') - extractDotShortcut(note, pnote->shortcut); - if (pnote->name != rest) { - extractGroup(note, 's', pnote->accidental); - if (*pnote->accidental == '\0') - extractGroup(note, 'f', pnote->accidental); - if (*pnote->accidental == '\0') - extractGroup(note, 'n', pnote->accidental); - } - /* Look for 'i' or 'c' anywhere in what is left of note.*/ - if (*pnote->accidental != '\0') { - extractOneOf(note, "ic", onlymidi); - strcat(pnote->accidental, onlymidi); -/* p2c: notes.pas, line 191: - * Note: Possible string truncation in assignment [145] */ - } - extractGroup(note, 'd', pnote->dotgroup); - if (pnote->name == rest) - extractSignedNumber(note, pnote->accidental); - extractOneOf(note, durations, pnote->duration); - sprintf(STR1, "%c", rest); - if (strcmp(note, STR1)) - extractContiguous(note, "=+-", pnote->octave); - if (*note != '\0' && isdigit(note[0])) { - sprintf(STR2, "%c%s", note[0], pnote->octave); - strcpy(pnote->octave, STR2); -/* p2c: notes.pas, line 197: - * Note: Possible string truncation in assignment [145] */ - delete1(note, 1); - } - strcpy(pnote->whatever, note); -/* p2c: notes.pas, line 199: - * Note: Possible string truncation in assignment [145] */ -} - - -/* On input: "note" is a note word; "dur1" is the default duration. - On output: "note" has possibly been modified; - possibly been split into two parts, the second being "shortcut"; - "dur" is the suggested new default duration; - "count" is the count of the total of "note" and "shortcut" */ -Void processNote(note, xnote, dur1, dur, count) -Char *note, *xnote; -Char dur1, *dur; -short *count; -{ - Char sc[3], origdur[3]; - short multiplicity, l; - parsedNote pnote; - Char STR1[36]; - Char STR3[256]; - - *xnote = '\0'; - *dur = dur1; - if (*note == '\0' || !isNoteOrRest(note) || isPause(note)) - return; - parseNote(note, &pnote); - if (debugMode()) { - printf("%s => ", note); - printNote(pnote); - } - if (pos1('.', pnote.whatever) > 0) { - sprintf(STR3, "Suspicious dot in word %s", note); - warning(STR3, print); - } - strcpy(origdur, pnote.duration); - if (*pnote.duration == '\0') - *dur = dur1; - else - *dur = pnote.duration[0]; - *count = count64[*dur - '0']; - if (*pnote.dotgroup != '\0') { - *count += *count / 2; - if (startsWith(pnote.dotgroup, "dd")) - *count += *count / 6; - } - sprintf(pnote.duration, "%c", *dur); - if (*pnote.shortcut != '\0') { - if (*pnote.dotgroup != '\0') - error("You may not explicitly dot a note with a shortcut", print); - sprintf(sc, "%c", pnote.shortcut[0]); - predelete(pnote.shortcut, 1); - if (!strcmp(sc, ".")) { - multiplicity = 1; - if (pnote.shortcut[0] == '.') { - multiplicity++; - predelete(pnote.shortcut, 1); - strcat(sc, "."); -/* p2c: notes.pas, line 233: - * Note: Possible string truncation in assignment [145] */ - } - *count += *count; - dur1 = pnote.duration[0]; - for (l = 1; l <= multiplicity; l++) { - sprintf(pnote.dotgroup + strlen(pnote.dotgroup), "%c", dotcode); -/* p2c: notes.pas, line 236: - * Note: Possible string truncation in assignment [145] */ - dur1 = half(dur1); - } - addDuration(pnote.shortcut, dur1); - } else { - addDuration(pnote.shortcut, half(pnote.duration[0])); - *count += *count / 2; - } - } - if (!insertDuration()) { - strcpy(pnote.duration, origdur); -/* p2c: notes.pas, line 243: - * Note: Possible string truncation in assignment [145] */ - } - if (rearrangeNote()) - sprintf(note, "%c%s%s%s%s%s%s", - pnote.name, pnote.duration, pnote.octave, pnote.whatever, - pnote.accidental, pnote.dotgroup, pnote.xtuplet); - else - strcpy(pnote.shortcut, " "); - if (!insertDuration() && *pnote.shortcut != '\0') { - sprintf(STR1, "%s%s", sc, pnote.shortcut); - strcpy(pnote.shortcut, STR1); -/* p2c: notes.pas, line 248: - * Note: Possible string truncation in assignment [145] */ - } - strcpy(xnote, pnote.shortcut); -} - - -Char octaveCode(note) -Char *note; -{ /*if debugMode then write('Octave code in note "',note,'" is ');*/ - parsedNote pnote; - - parseNote(note, &pnote); - /*if debugMode then writeln('"',octave,'"');*/ - if (*pnote.octave == '\0') - return ' '; - else - return (pnote.octave[0]); -} - - -Void removeOctaveCode(code, note) -Char code; -Char *note; -{ /*if debugMode then writeln('remove ',code,' from ',note);*/ - short k, l; - - l = strlen(note); - for (k = 1; k <= l; k++) { - if (note[k-1] == code) { - if (k == l || note[k] < '0' || note[k] > '9') { - delete1(note, k); - return; - } - } - } - fatalerror("Code not found in note"); -} - - -Void insertOctaveCode(code, note) -Char code; -Char *note; -{ /*if debugMode then writeln('insert ',code,' into ',note); */ - short l; - - l = strlen(note); - if (l < 2 || note[1] < '0' || note[1] > '9') - fatalerror("Trying to insert octave into note without duration"); - if (l <= 2 || note[2] < '0' || note[2] > '9') - insertChar(code, note, 3); - else - printf("Not inserting \"%c\", note already has octave code\"\n", code); -} - - - - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/notes.h b/Build/source/utils/m-tx/mtx-0.60d/notes.h deleted file mode 100644 index 1b534b44186..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/notes.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Header for module notes, generated by p2c 1.21alpha-07.Dec.93 */ -#ifndef NOTES_H -#define NOTES_H - - -#ifndef CONTROL_H -#include "control.h" -#endif - - -#ifdef NOTES_G -# define vextern -#else -# define vextern extern -#endif - - -extern short count64['9' + 1 - '0']; - - -extern Void processNote PP((Char *note, Char *xnote, int dur1, Char *dur, - short *count)); -extern Char durationCode PP((Char *note)); -extern Char octaveCode PP((Char *note)); -extern Void removeOctaveCode PP((int code, Char *note)); -extern Void insertOctaveCode PP((int code, Char *note)); -extern Void translateSolfa PP((Char *nt)); - - -#undef vextern - -#endif /*NOTES_H*/ - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/notes.pas b/Build/source/utils/m-tx/mtx-0.60d/notes.pas deleted file mode 100644 index 3fdb9edb3c2..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/notes.pas +++ /dev/null @@ -1,280 +0,0 @@ -unit notes; - -interface uses control; - -const count64: array['0'..'9'] of integer = - ( 64, 4, 32, 2, 16, 0, 1, 0, 8, 128 ); - -procedure processNote(var note, xnote: string; dur1: char; var dur: char; - var count: integer); -function durationCode (note: string): char; -function octaveCode (note: string): char; -procedure removeOctaveCode(code: char; var note: string); -procedure insertOctaveCode(code: char; var note: string); -procedure translateSolfa(var nt: char); - -implementation uses strings, globals; - -type - -parsedNote = record - name: char; - duration: string[1]; - octave: string[8]; - accidental, whatever, dotgroup, xtuplet: string[16]; - shortcut: string[32]; -end; - -procedure printNote(n: parsedNote); -begin with n do writeln(name,'|',duration,'|',octave,'|',accidental,'|', - whatever,'|',dotgroup,'|',xtuplet,'|',shortcut) -end; - -{ If rearrangeNote is TRUE, translate original note to the following form: - 1. Note name. - 2. Duration. - 3. Octave adjustments. - 4. Everything except the other six items. - 5. Accidental with adjustments (rest: height adjustment) - 6. Dot with adjustments. - 7. Xtuplet group. -} - -procedure translateSolfa(var nt: char); - var k: integer; -begin if solfaNoteNames then - begin k:=pos1(nt,solfa_names); if k>0 then nt:=has_duration[k] - end -end; - -function durationCode (note: string): char; - var code: char; - begin durationCode:=unspecified; if length(note)>1 then - begin code:=note[2]; if pos1(code,durations)>0 then durationCode:=code - end - end; - -function half ( dur: char ) : char; - var k: integer; - begin k:= pos1 (dur, durations ); half := dur; - if k=0 then error ('Invalid duration '+dur,print) - else if k>ndurs then error (dur+' is too short to halve',print) - else half := durations[k+1]; - end; - -procedure addDuration ( var note: string; dur: char); -begin if insertDuration then insertchar(dur,note,2); end; - -{ Extract procedures. All of these remove part of "note" (sometimes - the part is empty) and put it somewhere else. The part may be anywhere - in "note", except when otherwise specified.} - -{ Unconditionally extracts the first character. } - -procedure extractFirst(var note: string; var first: char); -begin first:=note[1]; predelete(note,1) -end; - -{ Extracts at most one of the characters in "hits". } - -procedure extractOneOf(var note: string; hits: string; var hit: string); - var i, l: integer; -begin l:=length(note); hit:=''; - for i:=1 to l do if pos1(note[i],hits)>0 then - begin hit:=note[i]; delete1(note,i); exit; - end; -end; - -{ Extracts contiguous characters in "hits" until no more are found. - There may be more later. } - -procedure extractContiguous(var note: string; hits: string; var hit: string); - var i, l, len: integer; -begin l:=length(note); len:=l; hit:=''; - for i:=1 to l do if pos1(note[i],hits)>0 then - begin - repeat if pos1(note[i],hits)=0 then exit; - hit:=hit+note[i]; delete1(note,i); dec(len) - until len0) then - begin translateSolfa(tail[l+1]); exit end; - if l=2 then error('".." followed by non-note',print); - if l>=lt then begin note:=note+tail; tail:=''; exit end; - ch:=tail[1]; predelete(tail,1); - extractDotShortcut(tail,tail2); note:=note+ch+tail; tail:=tail2; -end; - -{ Extracts a signed number. } - -procedure extractSignedNumber(var note, number: string); - var k: integer; - note0: string; -begin k:=pos1('+',note); if k=0 then k:=pos1('-',note); - number:=''; if k=0 then exit; - note0:=note; - repeat number:=number+note[k]; delete1(note,k) - until (k>length(note)) or (note[k]<>'0') and (pos1(note[k],digits)=0); - if length(number)=1 then begin note:=note0; number:='' end -end; - -{ Extracts a symbol followed by optional +- or <> shift indicators } - -procedure extractGroup(var note: string; delim: char; var group: string); - var gl, k, k0: integer; - probe, nonumber: boolean; - tail: string; - procedure tryMore; - begin while (k<=gl) and (group[k]=group[1]) do inc(k) end; - procedure try(s: string); - begin probe:=(k0); if probe then inc(k) - end; - procedure tryNumber; - var dot: boolean; - begin nonumber:=true; dot:=false; - while (k<=gl) and (pos1(group[k],digitsdot)>0) do - begin inc(k); if group[k]='.' then - if dot then error('Extra dot in number',print) else dot:=true - else nonumber:=false - end - end; -begin extractAfter(note,delim,group); if group='' then exit; - gl:=length(group); k:=2; - if (gl>1) and (group[2]=':') then k:=3 else - begin tryMore; - k0:=k; try('+-<>'); if probe then tryNumber; if nonumber then k:=k0; - k0:=k; try('+-<>'); if probe then tryNumber; if nonumber then k:=k0; - end; - tail:=group; dec(k); group[0]:=char(k); predelete(tail,k); - note:=note+tail -end; - -procedure parseNote(note: string; var pnote: parsedNote); -var onlymidi: string; -begin with pnote do - begin - shortcut:=''; xtuplet:=''; accidental:=''; dotgroup:=''; - duration:=''; octave:=''; onlymidi:=''; - extractFirst(note,name); - extractAfter(note,'x',xtuplet); - extractAfter(note,',',shortcut); - if shortcut='' then extractDotShortcut(note,shortcut); - if name<>rest then - begin extractGroup(note,'s',accidental); - if accidental='' then extractGroup(note,'f',accidental); - if accidental='' then extractGroup(note,'n',accidental); - end; -{ Look for 'i' or 'c' anywhere in what is left of note.} - if accidental<>'' then - begin extractOneOf(note,'ic',onlymidi); accidental:=accidental+onlymidi - end; - extractGroup(note,'d',dotgroup); - if name=rest then extractSignedNumber(note,accidental); - extractOneOf(note,durations,duration); - if note<>rest then extractContiguous(note,'=+-',octave); - if (length(note)>0) and (note[1]>='0') and (note[1]<='9') - then begin octave:=note[1]+octave; delete1(note,1) end; - whatever := note - end -end; - -{ On input: "note" is a note word; "dur1" is the default duration. - On output: "note" has possibly been modified; - possibly been split into two parts, the second being "shortcut"; - "dur" is the suggested new default duration; - "count" is the count of the total of "note" and "shortcut" } -procedure processNote(var note, xnote: string; dur1: char; var dur: char; - var count: integer); -var sc, origdur: string[2]; - multiplicity, l: integer; - pnote: parsedNote; -begin xnote:=''; dur:=dur1; - if (note='') or not isNoteOrRest(note) or isPause(note) then exit; - parseNote(note, pnote); - if debugMode then begin write(note,' => '); printNote(pnote) end; - with pnote do - begin - if pos1('.',whatever)>0 then warning('Suspicious dot in word '+note,print); - origdur := duration; - if duration='' then dur:=dur1 else dur:=duration[1]; - count:=count64[dur]; if dotgroup<>'' then - begin inc(count,count div 2); - if startswith(dotgroup,'dd') then inc(count,count div 6) - end; - duration:=dur; if shortcut<>'' then - begin - if dotgroup<>'' then - error('You may not explicitly dot a note with a shortcut',print); - sc:=shortcut[1]; predelete(shortcut,1); - if sc='.' then - begin multiplicity:=1; - if shortcut[1]='.' then - begin inc(multiplicity); predelete(shortcut,1); sc:=sc+'.' end; - inc(count,count); dur1:=duration[1]; - for l:=1 to multiplicity do - begin dotgroup:=dotgroup+dotcode; dur1:=half(dur1) end; - addDuration(shortcut,dur1); - end else - begin addDuration(shortcut,half(duration[1])); - inc(count,count div 2) - end - end; - if not insertDuration then duration := origdur; - if rearrangeNote - then note := name + duration + octave + whatever - + accidental + dotgroup + xtuplet - else shortcut:=' '; - if not insertDuration and (shortcut<>'') then shortcut:=sc+shortcut; - xnote:=shortcut - end -end; - -function octaveCode (note: string): char; - var pnote: parsedNote; -begin {if debugMode then write('Octave code in note "',note,'" is ');} - parseNote(note,pnote); with pnote do - begin {if debugMode then writeln('"',octave,'"');} - if octave='' then octaveCode:=' ' else octaveCode:=octave[1]; end -end; - -procedure removeOctaveCode(code: char; var note: string); - var k, l: integer; -begin {if debugMode then writeln('remove ',code,' from ',note);} l:=length(note); - for k:=1 to l do if note[k]=code then - if (k=l) or (note[k+1]<'0') or (note[k+1]>'9') then - begin delete1(note,k); exit end; - fatalError('Code not found in note') -end; - -procedure insertOctaveCode(code: char; var note: string); - var l: integer; -begin {if debugMode then writeln('insert ',code,' into ',note); } - l:=length(note); - if (l<2) or (note[2]<'0') or (note[2]>'9') then - fatalError('Trying to insert octave into note without duration'); - if (l<=2) or (note[3]<'0') or (note[3]>'9') then insertChar(code,note,3) - else writeln('Not inserting "',code,'", note already has octave code"') -end; - -end. diff --git a/Build/source/utils/m-tx/mtx-0.60d/preamble.c b/Build/source/utils/m-tx/mtx-0.60d/preamble.c deleted file mode 100644 index 53e4a5b4576..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/preamble.c +++ /dev/null @@ -1,1134 +0,0 @@ -/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ -/* From input file "preamble.pas" */ - - -#include "p2c.h" - - -#define PREAMBLE_G -#include "preamble.h" - - -#ifndef CONTROL_H -#include "control.h" -#endif - -#ifndef MTXLINE_H -#include "mtxline.h" -#endif - -#ifndef STRINGS_H -#include "strings.h" -#endif - -#ifndef MULTFILE_H -#include "multfile.h" -#endif - -#ifndef FILES_H -#include "files.h" -#endif - -#ifndef STATUS_H -#include "status.h" -#endif - -#ifndef UTILITY_H -#include "utility.h" -#endif - - -/* fpc mistakenly thinks CONTROL is not used */ - -#define blank_ ' ' -#define colon_ ':' -#define semicolon ';' -#define comma_ ',' - -#define max_styles 24 - - -typedef enum { - none, title, composer, pmx, options, msize, bars, shortnote, style, sharps, - flats, meter, space, pages, systems, enable, disable, name, indent, poet, - part, only, octave_, start -} command_type; - -typedef enum { - unknown, colon_line, command_line, comment_line, plain_line -} line_type; - -typedef char style_index; - -typedef char style_index0; - - -#define c1 title -#define cn start - - -Static short known_styles = 12; -Static boolean warn_redefine = false; - -Static Char commands[24][17] = { - "NONE", "TITLE", "COMPOSER", "PMX", "OPTIONS", "SIZE", "BARS/LINE", "SHORT", - "STYLE", "SHARPS", "FLATS", "METER", "SPACE", "PAGES", "SYSTEMS", "ENABLE", - "DISABLE", "NAME", "INDENT", "POET", "PART", "ONLY", "OCTAVE", "START" -}; - -Static Char cline[24][256] = { - "", "", "", "", "", "", "", "1/4", "", "0", "", "C", "", "1", "1", "", "", - "", "", "", "", "", "", "" -}; - -Static boolean redefined[24] = { - false, false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, false, - false, false -}; - -/** Known styles */ - -Static Char known_style[max_styles][256] = { - "SATB: Voices S,A T,B; Choral; Clefs G F", - "SATB4: Voices S A T B; Choral; Clefs G G G8 F", - "SINGER: Voices Voice; Vocal; Clefs G", - "PIANO: Voices RH LH; Continuo; Clefs G F", - "ORGAN: Voices RH LH Ped; Continuo; Clefs G F F", - "SOLO: Voices V; Clefs G", "DUET: Voices V1 Vc; Clefs G F", - "TRIO: Voices V1 Va Vc; Clefs G C F", - "QUARTET: Voices V1 V2 Va Vc; Clefs G G C F", - "QUINTET: Voices V1 V2 Va Vc1 Vc2; Clefs G G C F F", - "SEXTET: Voices V1 V2 Va1 Va2 Vc1 Vc2; Clefs G G C C F F", - "SEPTET: Voices V1 V2 Va1 Va2 Vc1 Vc2 Cb; Clefs G G C C F F F", "", "", "", - "", "", "", "", "", "", "", "", "" -}; - -Static style_index old_known_styles; -Static boolean style_used[max_styles]; -Static boolean omit_line[lines_in_paragraph]; -Static style_index0 orig_style_line[max_styles]; - -Static short nclefs, n_pages, n_systems, n_sharps, ngroups; -Static Char part_line[256], title_line[256], composer_line[256], - pmx_line[256], options_line[256], start_line[256], voices[256], - clefs[256]; -Static short group_start[maxgroups], group_stop[maxgroups]; -Static Char instr_name[maxstaves][41]; -Static boolean style_supplied; - - -/* ------------------ Styles ------------------ */ - -Static voice_index0 voiceCount(s_) -Char *s_; -{ - Char s[256]; - short i, l; - - strcpy(s, s_); - l = strlen(s); - for (i = 0; i <= l - 1; i++) { - if (s[i] == comma_) - s[i] = blank_; - } - return (wordCount(s)); -} - - -Static style_index0 findStyle(s_) -Char *s_; -{ - style_index0 Result = 0; - Char s[256]; - style_index0 i = 0; - - strcpy(s, s_); - sprintf(s + strlen(s), "%c", colon_); - while (i < known_styles) { - i++; - if (startsWithIgnoreCase(known_style[i-1], s)) - return i; - } - return Result; -} - - -Static Void addStyle(S) -Char *S; -{ - style_index0 sn; - Char STR1[256]; - - sn = findStyle(NextWord(STR1, S, colon_, dummy)); - if (sn > 0) { - strcpy(known_style[sn-1], S); - return; - } - if (known_styles < max_styles) { - known_styles++; - strcpy(known_style[known_styles-1], S); - } else - error("Can't add another style - table full", print); -} - - -Static Void readStyles() -{ - boolean eofstyle; - Char S[256]; - style_index0 l = 0; - Char *TEMP; - - if (styleFileFound()) - eofstyle = true; - else - eofstyle = P_eof(stylefile); - while (!eofstyle) { - fgets(S, 256, stylefile); - TEMP = strchr(S, '\n'); - if (TEMP != NULL) - *TEMP = 0; - if (*S != '\0') { - addStyle(S); - l++; - orig_style_line[known_styles-1] = l; - } - eofstyle = P_eof(stylefile); - } -} - - -Static Void applyStyle(s_, stylename, first_inst, first_stave) -Char *s_, *stylename; -stave_index first_inst, first_stave; -{ - Char s[256]; - Char clef[256], subline[256], subcommand[256]; - stave_index0 i, last_inst, last_stave; - boolean continuo = false, toosoon = false, vocal = false; - Char STR2[256]; - - strcpy(s, s_); - last_inst = first_inst - 1; - GetNextWord(subline, s, blank_, colon_); - while (*s != '\0') { - GetNextWord(subline, s, semicolon, dummy); - i = curtail(subline, semicolon); - GetNextWord(subcommand, subline, blank_, dummy); - if (equalsIgnoreCase(subcommand, "VOICES")) { - sprintf(voices + strlen(voices), " %s", subline); - last_stave = first_stave + wordCount(subline) - 1; - last_inst = first_inst + voiceCount(subline) - 1; - } else if (equalsIgnoreCase(subcommand, "CLEFS")) { - strcpy(clef, subline); - sprintf(clefs + strlen(clefs), " %s", clef); - } else if (equalsIgnoreCase(subcommand, "VOCAL")) { - if (last_inst < first_inst) - toosoon = true; - else { - some_vocal = true; - vocal = true; - for (i = first_inst; i <= last_inst; i++) - setVocal(i, true); - } - } else if (equalsIgnoreCase(subcommand, "CHORAL") || - equalsIgnoreCase(subcommand, "GROUP")) { - if (last_inst < first_inst) - toosoon = true; - else { - if (equalsIgnoreCase(subcommand, "CHORAL")) { - some_vocal = true; - vocal = true; - for (i = first_inst; i <= last_inst; i++) - setVocal(i, true); - } - if (ngroups == maxgroups) - error("Too many groups", print); - else { - ngroups++; - group_start[ngroups-1] = first_stave; - group_stop[ngroups-1] = last_stave; - } - } - } else if (equalsIgnoreCase(subcommand, "CONTINUO")) - continuo = true; - else { - sprintf(STR2, "Subcommand %s in STYLE unknown", subcommand); - error(STR2, print); - } - if (toosoon) { - sprintf(STR2, "You must first give VOICES before specifying %s", - subcommand); - error(STR2, print); - } - } - if (vocal && continuo) - error("A continuo instrument may not be vocal", print); - if (wordCount(clef) != last_stave - first_stave + 1) - error("Number of clefs does not match number of voices", print); - if (first_stave == last_stave || continuo) { - strcpy(instr_name[first_stave-1], stylename); -/* p2c: preamble.pas, line 184: - * Note: Possible string truncation in assignment [145] */ - } else { - for (i = first_stave - 1; i <= last_stave - 1; i++) - *instr_name[i] = '\0'; - } - if (continuo) { - ninstr++; - stave[ninstr-1] = first_stave; - for (i = first_stave - 1; i <= last_stave - 1; i++) - instr[i] = ninstr; - return; - } - for (i = first_stave; i <= last_stave; i++) { - ninstr++; - stave[ninstr-1] = i; - instr[i-1] = ninstr; - } -} - - -Static Void applyStyles() -{ - short n1, n2, sn; - Char s[256]; - Char STR2[256]; - - *voices = '\0'; - *clefs = '\0'; - ninstr = 0; - while (*cline[(long)style] != '\0') { - n1 = voiceCount(voices) + 1; - n2 = wordCount(voices) + 1; - GetNextWord(s, cline[(long)style], blank_, comma_); - curtail(s, comma_); - sn = findStyle(s); - if (sn == 0) { - sprintf(STR2, "Style %s unknown", s); - error(STR2, print); - } - line_no = orig_style_line[sn-1]; - applyStyle(known_style[sn-1], s, n1, n2); - style_used[sn-1] = true; - } -} - - -/* ------------------------------------------------------------- */ - -Static Void wipeCommands() -{ - command_type c; - - for (c = c1; (long)c <= (long)cn; c = (command_type)((long)c + 1)) - *cline[(long)c] = '\0'; -} - - -boolean omitLine(line) -paragraph_index line; -{ - if (line == 0) - return true; - else - return (omit_line[line-1]); -} - - -Static Void setName() -{ - short i, FORLIM; - - if (!redefined[(long)name]) - return; - setFeature("instrumentNames", true); - FORLIM = ninstr; - for (i = 0; i <= FORLIM - 1; i++) { - GetNextWord(instr_name[i], cline[(long)name], blank_, dummy); -/* p2c: preamble.pas, line 224: - * Note: Possible string truncation in assignment [145] */ - } -} - - -Static Void setIndent() -{ - if (redefined[(long)indent]) - strcpy(fracindent, cline[(long)indent]); -} - - -Static Void setInitOctave() -{ - if (redefined[(long)octave_]) - initOctaves(cline[(long)octave_]); -} - - -Local Void checkLabel(w) -Char *w; -{ - voice_index j, FORLIM; - Char STR1[256], STR2[256]; - - FORLIM = nvoices; - for (j = 0; j <= FORLIM - 1; j++) { - if (!strcmp(w, voice_label[j])) { - sprintf(STR2, "Voice label %s not unique", w); - warning(STR2, print); - return; - } - } - if (strlen(w) > 2) - return; - if (pos1(w[0], "CLU") > 0) { - if (strlen(w) > 1) { - if (pos1(w[1], "123456789") == 0) - return; - } - } else if (pos1(w[0], "123456789") == 0) - return; - sprintf(STR1, "Voice label %s conflicts with reserved label", w); - error(STR1, print); -} - - -Static Void setVoices(line) -Char *line; -{ - short k; - Char s[256], w[256]; - Char STR1[256]; - short FORLIM; - - nvoices = 0; - nstaves = 0; - do { - GetNextWord(s, line, blank_, dummy); - if (*s != '\0') { - nstaves++; - k = 0; - first_on_stave[nstaves-1] = nvoices + 1; - do { - GetNextWord(w, s, blank_, comma_); - curtail(w, comma_); - if (*w != '\0') { - k++; - if (k <= 2) { - nvoices++; - checkLabel(w); - strcpy(voice_label[nvoices-1], w); - if (*instr_name[nstaves-1] == '\0') { - strcpy(instr_name[nstaves-1], w); -/* p2c: preamble.pas, line 264: - * Note: Possible string truncation in assignment [145] */ - } - setStavePos(nvoices, nstaves, k); - } - } - } while (*w != '\0'); - if (k > 2) { - sprintf(STR1, "More than two voices per stave: %s", s); - error(STR1, print); - } - if (k == 2) { - sprintf(instr_name[nstaves-1], "\\mtxTwoInstruments{%s}{%s}", - voice_label[nvoices-2], voice_label[nvoices-1]); -/* p2c: preamble.pas, line 271: - * Note: Possible string truncation in assignment [145] */ - } - number_on_stave[nstaves-1] = k; - } - } while (*line != '\0'); - FORLIM = nvoices; - for (k = 0; k <= FORLIM - 1; k++) - selected[k] = true; -} - - -Static Void setClefs(line_) -Char *line_; -{ - Char line[256]; - Char s[256]; - - strcpy(line, line_); - nclefs = 0; - do { - GetNextWord(s, line, blank_, dummy); - if (*s != '\0') { - nclefs++; - if (strlen(s) == 1) - clef[nclefs-1] = s[0]; - else - clef[nclefs-1] = s[1]; - } - } while (*s != '\0'); -} - - -Static Void setSize(line_) -Char *line_; -{ - Char line[256]; - stave_index0 i = 0; - Char word[256]; - stave_index0 FORLIM; - - strcpy(line, line_); - while (i < ninstr) { - GetNextWord(word, line, blank_, dummy); - if (*word == '\0') - break; - i++; - getNum(word, &musicsize); - stave_size[i-1] = musicsize; - } - if ((unsigned)musicsize >= 32 || ((1L << musicsize) & 0x110000L) == 0) { - FORLIM = ninstr; - for (i = 0; i <= FORLIM - 1; i++) { - if (stave_size[i] == unspec) - stave_size[i] = musicsize; - } - } - if (musicsize < 16) - musicsize = 16; - else if (musicsize > 20) - musicsize = 20; -} - - -Static command_type findCommand(command) -Char *command; -{ - command_type j; - - curtail(command, ':'); - if (equalsIgnoreCase(command, "STYLE")) - style_supplied = true; - for (j = c1; (long)j <= (long)cn; j = (command_type)((long)j + 1)) { - if (equalsIgnoreCase(command, commands[(long)j])) - return j; - } - return none; -} - - -boolean isCommand(command_) -Char *command_; -{ - Char command[256]; - - strcpy(command, command_); - return (findCommand(command) != none); -} - - -Static Void doEnable(line, choice) -Char *line; -boolean choice; -{ - Char word[256]; - Char STR1[256]; - - do { - GetNextWord(word, line, blank_, dummy); - if (*word != '\0') { - if (!setFeature(word, choice)) { - sprintf(STR1, "No such feature: %s", word); - error(STR1, !print); - } - } - } while (*word != '\0'); -} - - -Static line_type doCommand(line_) -Char *line_; -{ - line_type Result; - Char line[256]; - Char command[256]; - command_type last_command; - boolean starts_with_note; - Char STR1[256], STR2[256]; - - strcpy(line, line_); - if (line[0] == comment) - return comment_line; - starts_with_note = maybeMusicLine(line); - GetNextWord(command, line, blank_, colon_); - sprintf(STR1, "%c", colon_); - if (endsWith(command, STR1)) { - last_command = findCommand(command); - Result = command_line; - if (last_command == enable) - doEnable(line, true); - else if (last_command == disable) - doEnable(line, false); - if (last_command != none) { - strcpy(cline[(long)last_command], line); - if (last_command == start) - strcpy(start_line, line); - if (warn_redefine && redefined[(long)last_command]) { - sprintf(STR2, "You have redefined preamble command %s", command); - warning(STR2, print); - } - redefined[(long)last_command] = true; - return Result; - } - Result = colon_line; - sprintf(STR2, "%s%c %s", command, colon_, line); - addStyle(STR2); - orig_style_line[known_styles-1] = line_no; - return Result; - } else if (starts_with_note) - return plain_line; - else - return unknown; - return Result; -} - - -Void setOnly(line_) -Char *line_; -{ - Char line[256]; - short num, num1, num2, l; - Char s[256]; - Char STR1[256]; - - strcpy(line, line_); - if (*line == '\0') - return; - if (startsWithIgnoreCase(line, "only")) - GetNextWord(STR1, line, colon_, dummy); - for (l = 0; l <= lines_in_paragraph - 1; l++) - omit_line[l] = true; - do { - GetNextWord(s, line, blank_, comma_); - if (*s == '\0') - return; - curtail(s, comma_); - if (pos1('-', s) == 0) { - getNum(s, &num); - if (num > 0 && num <= lines_in_paragraph) - omit_line[num-1] = false; - else - warning("Invalid line number in Only: is skipped", print); - } else { - getTwoNums(s, &num1, &num2); - if (num1 > 0 && num2 <= lines_in_paragraph) { - for (num = num1 - 1; num <= num2 - 1; num++) - omit_line[num] = false; - } else - warning("Invalid line range in Only: is skipped", print); - } - } while (true); -} - - -Void interpretCommands() -{ - short i, num, den, nbars; - Char STR2[256]; - short FORLIM; - - strcpy(title_line, cline[(long)title]); - strcpy(part_line, cline[(long)part]); - if (*cline[(long)poet] != '\0' || *cline[(long)composer] != '\0') - sprintf(composer_line, "\\mtxComposerLine{%s}{%s}", - cline[(long)poet], cline[(long)composer]); - else - *composer_line = '\0'; - strcpy(pmx_line, cline[(long)pmx]); - GetNextWord(options_line, cline[(long)options], blank_, dummy); - FORLIM = known_styles; - for (i = 0; i <= FORLIM - 1; i++) - style_used[i] = false; - applyStyles(); - setVoices(voices); - FORLIM = known_styles; - for (i = old_known_styles; i <= FORLIM - 1; i++) { - if (!style_used[i]) { - warning("The following style was supplied but not used", !print); - puts(known_style[i]); - } - } - setClefs(clefs); - if (!redefined[(long)meter]) { - sprintf(STR2, "You have not defined Meter, assuming \"%s\" ", - cline[(long)meter]); - warning(STR2, !print); - } - getMeter(cline[(long)meter], &meternum, &meterdenom, &pmnum, &pmdenom); - setDefaultDuration(meterdenom); - if (meternum == 0 && - !(redefined[(long)pages] || redefined[(long)systems] || - redefined[(long)bars])) { - strcpy(cline[(long)bars], "1"); - redefined[(long)bars] = true; - } - if (redefined[(long)pages] || redefined[(long)systems]) { - if (redefined[(long)bars]) - warning("BARS/LINE ignored since you specified PAGES or SYSTEMS", print); - if (redefined[(long)systems]) - getNum(cline[(long)systems], &n_systems); - else - warning("PAGES specified but not SYSTEMS", !print); - if (redefined[(long)pages]) - getNum(cline[(long)pages], &n_pages); - else - warning("SYSTEMS specified but not PAGES", !print); - } else if (redefined[(long)bars]) { - getNum(cline[(long)bars], &nbars); - if (nbars > 0) { - n_pages = 0; - n_systems = nbars; - } - } - getNum(cline[(long)sharps], &n_sharps); - setSpace(cline[(long)space]); - setSize(cline[(long)msize]); - getTwoNums(cline[(long)shortnote], &num, &den); - if (den == 0) - den = 1; - short_note = num * 64 / den; - if (*cline[(long)flats] != '\0') { - getNum(cline[(long)flats], &n_sharps); - n_sharps = -n_sharps; - } - setName(); - setIndent(); - setInitOctave(); - setOnly(cline[(long)only]); - if (*options_line != '\0') { - warning("\"Options\" is cryptic and obsolescent.", !print); - printf(" Use \"Enable\" and \"Disable\" instead.\n"); - } - FORLIM = strlen(options_line); - for (i = 0; i <= FORLIM - 1; i++) - processOption(options_line[i]); -} - - -Void preambleDefaults() -{ - short i; - - xmtrnum0 = 0.0; - strcpy(fracindent, "0"); - musicsize = 20; - *start_line = '\0'; - some_vocal = false; - ngroups = 0; - style_supplied = false; - for (i = 1; i <= maxvoices; i++) - setVocal(i, false); - for (i = 0; i <= maxstaves - 1; i++) { - nspace[i] = unspec; - stave_size[i] = unspec; - } - n_pages = 1; - n_systems = 1; - readStyles(); - old_known_styles = known_styles; - for (i = 0; i <= lines_in_paragraph - 1; i++) - omit_line[i] = false; -} - - -Static Void preambleGuess(maybe_voices) -voice_index maybe_voices; -{ - switch (maybe_voices) { - - case 1: - strcpy(cline[(long)style], "Solo"); - break; - - case 2: - strcpy(cline[(long)style], "Duet"); - break; - - case 3: - strcpy(cline[(long)style], "Trio"); - break; - - case 4: - strcpy(cline[(long)style], "Quartet"); - break; - - case 5: - strcpy(cline[(long)style], "Quintet"); - break; - - case 6: - strcpy(cline[(long)style], "Sextet"); - break; - - case 7: - strcpy(cline[(long)style], "Septet"); - break; - - default: - error("I cannot guess a style", !print); - return; - break; - } - printf("I guess this piece is a %s for strings in C major.\n", - cline[(long)style]); - printf(" Why not provide a STYLE in the setup paragraph to make sure?\n"); -} - - -/* ------------------------------------------------------------------ */ - -Void nonMusic() -{ - paragraph_index i, FORLIM; - - FORLIM = para_len; - for (i = 0; i <= FORLIM - 1; i++) - doCommand(P[i]); - setOnly(cline[(long)only]); - wipeCommands(); -} - - -boolean thisCase() -{ - boolean Result; - -/* p2c: preamble.pas: Note: Eliminated unused assignment statement [338] */ - if (!startsWithIgnoreCase(P[0], "case:")) - return true; - Result = (choice != ' ' && pos1(choice, P[0]) > 0); - strcpy(P[0], "%"); - return Result; -} - - -Void augmentPreamble(control_para) -boolean control_para; -{ - paragraph_index i; - line_type l; - short s[5]; - paragraph_index FORLIM; - - if (!thisCase()) - return; - for (l = unknown; (long)l <= (long)plain_line; l = (line_type)((long)l + 1)) - s[(long)l] = 0; - FORLIM = para_len; - for (i = 0; i <= FORLIM - 1; i++) { - line_no = orig_line_no[i]; - l = doCommand(P[i]); - s[(long)l]++; - if (l == comment_line && P[i][1] == comment) { - predelete(P[i], 2); - putLine(P[i]); - } - if (!control_para && l == unknown) - error("Unidentifiable line", print); - } - if (!control_para && s[(long)command_line] > 0 && s[(long)plain_line] > 0) - error("Mixture of preamble commands and music", !print); -} - - -Void doPreamble() -{ - paragraph_index i; - voice_index0 maybe_voices = 0; - paragraph_index FORLIM; - - if (style_supplied) /*augmentPreamble(not known);*/ - return; - if (true) - warning("No STYLE supplied", !print); - FORLIM = para_len; - for (i = 0; i <= FORLIM - 1; i++) { - if (maybeMusicLine(P[i])) - maybe_voices++; - } - if (maybe_voices > 0) - preambleGuess(maybe_voices); - else - error("No voices found", !print); -} - - -Void respace() -{ - stave_index i, j; - Char STR1[256]; - Char STR2[256], STR3[256]; - - for (i = ninstr; i >= 2; i--) { - j = ninstr - i + 1; - if (nspace[j-1] != unspec) { - sprintf(STR3, "\\mtxInterInstrument{%s}{%s}", - toString(STR1, i - 1), toString(STR2, nspace[j-1])); - tex3(STR3); - } - } - if (nspace[ninstr-1] != unspec) { - sprintf(STR3, "\\mtxStaffBottom{%s}", toString(STR1, nspace[ninstr-1])); - tex3(STR3); - } - must_respace = false; -} - - -Void restyle() -{ - must_restyle = false; -} - - -Static short clefno(cl) -Char cl; -{ - short Result; - - switch (cl) { - - case 'G': - case '0': - case 't': - case '8': - Result = 0; - break; - - case 's': - case '1': - Result = 1; - break; - - case 'm': - case '2': - Result = 2; - break; - - case 'a': - case '3': - Result = 3; - break; - - case 'n': - case '4': - Result = 4; - break; - - case 'r': - case '5': - Result = 5; - break; - - case 'F': - case 'b': - case '6': - Result = 6; - break; - - case 'C': - Result = 3; - break; - - default: - warning("Unknown clef code - replaced by treble", print); - Result = 0; - break; - } - return Result; -} - - -Static Void doTenorClefs() -{ - voice_index i; - Char c; - voice_index FORLIM; - Char STR1[256]; - Char STR3[256]; - - FORLIM = nclefs; - for (i = 1; i <= FORLIM; i++) { - c = clef[i-1]; - if (c == '8' || c == 't') { - sprintf(STR3, "\\\\mtxTenorClef{%s}\\", toString(STR1, PMXinstr(i))); - putLine(STR3); - } - } -} - - -Local Char *pmxMeter(Result) -Char *Result; -{ - short denom, num; - Char STR1[256], STR3[256], STR4[256], STR5[256]; - - if (meternum == 0) { - num = beatsPerLine(); /** denom := 0; **/ - meterChange(old_meter_word, num, meterdenom, true); - } else - num = meternum; /** denom := pmdenom; **/ - /* CMO: unconditonally assign value of pmdenom to denom */ - denom = pmdenom; - sprintf(Result, "%s %s %s %s", - toString(STR1, num), toString(STR3, PMXmeterdenom(meterdenom)), - toString(STR4, pmnum), toString(STR5, denom)); - return Result; -} - -Local Char *sizecode(Result, k) -Char *Result; -short k; -{ - strcpy(Result, "\\mtxNormalSize"); - switch (k) { - - case 13: - if (musicsize == 20) - strcpy(Result, "\\mtxTinySize"); - else - strcpy(Result, "\\mtxSmallSize"); - break; - - case 16: - if (musicsize == 20) - strcpy(Result, "\\mtxSmallSize"); - break; - - case 20: - if (musicsize == 16) - strcpy(Result, "\\mtxLargeSize"); - break; - - case 24: - if (musicsize == 20) - strcpy(Result, "\\mtxLargeSize"); - else - strcpy(Result, "\\mtxHugeSize"); - break; - - case 29: - strcpy(Result, "\\mtxHugeSize"); - break; - - default: - error("Valid sizes are 13, 16, 20, 24, 29", print); - break; - } - return Result; -} - - -Void doPMXpreamble() -{ - static Char clefcode[9] = "0123456"; - short i, j; - Char clefs[256]; - Char STR1[256]; - Char STR2[256]; - Char STR3[58]; - short FORLIM; - Char STR5[256]; - - if (*composer_line != '\0') - putLine(composer_line); - if (*title_line != '\0') { - sprintf(STR2, "\\mtxTitleLine{%s}", title_line); - putLine(STR2); - } - putLine("---"); - if (instrumentNames() && !redefined[(long)indent]) - strcpy(fracindent, "0.12"); - fprintf(outfile, "%d", nstaves); - fprintf(outfile, " %d", -ninstr); - stave[ninstr] = nstaves + 1; - for (j = ninstr; j >= 1; j--) - fprintf(outfile, " %d", stave[j] - stave[j-1]); - fprintf(outfile, " %s %8.5f %d %d %d %d %s\n", - pmxMeter(STR1), xmtrnum0, n_sharps, n_pages, n_systems, musicsize, - fracindent); - FORLIM = ninstr; - for (i = 1; i <= FORLIM; i++) { - if (!instrumentNames()) - putLine(""); - else { - sprintf(STR3, "\\mtxInstrName{%s}", instr_name[ninstr - i]); - putLine(STR3); - } - } - *clefs = '\0'; - for (i = nclefs - 1; i >= 0; i--) - sprintf(clefs + strlen(clefs), "%c", clefcode[clefno(clef[i])]); - putLine(clefs); - if (*texdir == '\0') - strcpy(texdir, "./"); - putLine(texdir); - - pmx_preamble_done = true; - respace(); - - FORLIM = ngroups; - for (j = 1; j <= FORLIM; j++) - fprintf(outfile, "\\\\mtxGroup{%s}{%s}{%s}\\\n", - toString(STR1, j), toString(STR2, ninstr - group_start[j-1] + 1), - toString(STR5, ninstr - group_stop[j-1] + 1)); - FORLIM = ninstr; - for (j = 1; j <= FORLIM; j++) { - if (stave_size[j-1] != unspec) { - sprintf(STR5, "\\\\mtxSetSize{%s}{%s}\\", - toString(STR1, ninstr - j + 1), - sizecode(STR2, stave_size[j-1])); - putLine(STR5); - } - } - if (*part_line != '\0') { - putLine("Ti"); - putLine(part_line); - } - if (*title_line != '\0') { - putLine("Tt"); - putLine("\\mtxTitle"); - } - if (*composer_line != '\0') { - putLine("Tc"); - putLine("\\mtxPoetComposer"); - } - if (*pmx_line != '\0') - putLine(pmx_line); - doTenorClefs(); - wipeCommands(); -} - - -Char *startString(Result, voice) -Char *Result; -voice_index0 voice; -{ - Char s[256], w[256]; - voice_index j; - - strcpy(s, start_line); - for (j = 1; j <= voice; j++) - GetNextWord(w, s, dummy, ';'); - curtail(w, ';'); - if (*w != '\0') { - sprintf(Result, "%s ", w); - return Result; - } else - return strcpy(Result, w); -} - - - - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/preamble.h b/Build/source/utils/m-tx/mtx-0.60d/preamble.h deleted file mode 100644 index ef854aa0dcb..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/preamble.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Header for module preamble, generated by p2c 1.21alpha-07.Dec.93 */ -#ifndef PREAMBLE_H -#define PREAMBLE_H - - -/*$X+*/ -/* Interpret preamble paragraph, compose PMX preamble */ - -#ifndef GLOBALS_H -#include "globals.h" -#endif - - -#ifdef PREAMBLE_G -# define vextern -#else -# define vextern extern -#endif - -extern boolean thisCase PV(); -extern Void preambleDefaults PV(); -extern Void interpretCommands PV(); -extern Void doPreamble PV(); -extern Void doPMXpreamble PV(); -extern Void respace PV(); -extern Void restyle PV(); -extern Char *startString PP((Char *Result, int voice)); -extern Void augmentPreamble PP((int control_para)); -extern boolean omitLine PP((int line)); -extern Void nonMusic PV(); -extern Void setOnly PP((Char *line)); -extern boolean isCommand PP((Char *command)); - - -#define known true - - -#undef vextern - -#endif /*PREAMBLE_H*/ - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/preamble.pas b/Build/source/utils/m-tx/mtx-0.60d/preamble.pas deleted file mode 100644 index 9ece7d67adc..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/preamble.pas +++ /dev/null @@ -1,624 +0,0 @@ -unit preamble; -{$X+} -{ Interpret preamble paragraph, compose PMX preamble } - -interface uses globals; - -function thisCase: boolean; -procedure preambleDefaults; -procedure interpretCommands; -procedure doPreamble; -procedure doPMXpreamble; -procedure respace; -procedure restyle; -function startString(voice: voice_index0): string; -procedure augmentPreamble(control_para: boolean); -function omitLine(line: paragraph_index): boolean; -procedure nonMusic; -procedure setOnly(line: string); -function isCommand(command: string): boolean; - -const known = true; - -implementation uses control, mtxline, strings, files, status, utility; -{ fpc mistakenly thinks CONTROL is not used } - -const blank = ' '; - colon = ':'; - semicolon = ';'; - comma = ','; - known_styles: integer = 12; - max_styles = 24; - warn_redefine: boolean = false; - -type command_type = - ( none, title, composer, pmx, options, msize, bars, shortnote, - style, sharps, flats, meter, space, pages, systems, - enable, disable, name, indent, - poet, part, only, octave, start ); - - line_type = ( unknown, colon_line, command_line, comment_line, - plain_line ); - - style_index = 1..max_styles; - style_index0 = 0..max_styles; - -const c1 = title; cn = start; - commands: array[command_type] of string[16] = - ( 'NONE', 'TITLE', 'COMPOSER', 'PMX', 'OPTIONS', - 'SIZE', 'BARS/LINE', 'SHORT', - 'STYLE', 'SHARPS', 'FLATS', 'METER', 'SPACE', 'PAGES', 'SYSTEMS', - 'ENABLE', 'DISABLE', - 'NAME', 'INDENT', 'POET', 'PART', 'ONLY', 'OCTAVE', 'START'); - cline: array[command_type] of string = - ( '', '', '', '', '', '', '', '1/4', - '', '0', '', 'C', '', '1', '1', '', '', '', '', '', '', '', '', '' ); - redefined: array[command_type] of boolean = - ( false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false ); - -(** Known styles *) - known_style: array[style_index] of string = ( -'SATB: Voices S,A T,B; Choral; Clefs G F', -'SATB4: Voices S A T B; Choral; Clefs G G G8 F', -'SINGER: Voices Voice; Vocal; Clefs G', -'PIANO: Voices RH LH; Continuo; Clefs G F', -'ORGAN: Voices RH LH Ped; Continuo; Clefs G F F', -'SOLO: Voices V; Clefs G', -'DUET: Voices V1 Vc; Clefs G F', -'TRIO: Voices V1 Va Vc; Clefs G C F', -'QUARTET: Voices V1 V2 Va Vc; Clefs G G C F', -'QUINTET: Voices V1 V2 Va Vc1 Vc2; Clefs G G C F F', -'SEXTET: Voices V1 V2 Va1 Va2 Vc1 Vc2; Clefs G G C C F F', -'SEPTET: Voices V1 V2 Va1 Va2 Vc1 Vc2 Cb; Clefs G G C C F F F', -'', '', '', '', '', '', '', '', '', '', '', ''); - -var old_known_styles: style_index; - style_used: array[style_index] of boolean; - omit_line: array[paragraph_index] of boolean; - orig_style_line: array[style_index] of style_index0; - -var nclefs, n_pages, n_systems, n_sharps, ngroups: integer; - part_line, title_line, composer_line, pmx_line, options_line, - start_line, voices, clefs: string; - group_start, group_stop: array[1..maxgroups] of integer; - instr_name: array[stave_index] of string[40]; - style_supplied: boolean; - -{ ------------------ Styles ------------------ } - -function voiceCount(s: string): voice_index0; - var i, l: integer; - begin l:=length(s); for i:=1 to l do if s[i]=comma then s[i]:=blank; - voiceCount:=wordCount(s); - end; - -function findStyle(s: string): style_index0; - var i: style_index0; -begin - i:=0; s:=s+colon; findStyle:=0; - while i0 then known_style[sn] := S - else if known_styles < max_styles then - begin inc(known_styles); - known_style[known_styles] := S; - end - else error('Can''t add another style - table full',print); -end; - -procedure readStyles; - var eofstyle: boolean; - S: string; - l: style_index0; -begin if styleFileFound then eofstyle:=true else eofstyle := eof(stylefile); - l:=0; - while not eofstyle do - begin readln(stylefile,S); if S<>'' then - begin addStyle(S); inc(l); orig_style_line[known_styles]:=l; end; - eofstyle := eof(stylefile); - end; -end; - -procedure applyStyle(s, stylename: string; - first_inst, first_stave: stave_index); - var clef, subline, subcommand: string; - i, last_inst, last_stave: stave_index0; - continuo, toosoon, vocal: boolean; - begin last_inst:=first_inst-1; - toosoon := false; continuo:=false; vocal := false; - subline:=GetNextWord(s,blank,colon); - while s<>'' do - begin subline:=GetNextWord(s,semicolon,dummy); - i:=curtail(subline,semicolon); - subcommand:=GetNextWord(subline,blank,dummy); - if equalsIgnoreCase(subcommand,'VOICES') then - begin voices:=voices+' '+subline; - last_stave := first_stave + wordCount(subline) - 1; - last_inst := first_inst + voiceCount(subline) - 1; - end - else if equalsIgnoreCase(subcommand,'CLEFS') - then - begin clef:=subline; clefs:=clefs+' '+clef; end - else if equalsIgnoreCase(subcommand,'VOCAL') then - if last_instlast_stave-first_stave+1 then error( - 'Number of clefs does not match number of voices',print); - if (first_stave=last_stave) or continuo - then instr_name[first_stave]:=stylename - else for i:=first_stave to last_stave do instr_name[i]:=''; - if continuo then - begin inc(ninstr); stave[ninstr] := first_stave; - for i:=first_stave to last_stave do instr[i]:=ninstr; - end - else for i:=first_stave to last_stave do - begin inc(ninstr); stave[ninstr] := i; instr[i] := ninstr; - end; - end; - -procedure applyStyles; - var n1, n2, sn: integer; - s: string; - begin voices:=''; clefs:=''; ninstr:=0; - while cline[style]<>'' do - begin n1:=voiceCount(voices)+1; - n2:=wordCount(voices)+1; - s:=GetNextWord(cline[style],blank,comma); - curtail(s,comma); - sn:=findStyle(s); if sn=0 then error ('Style ' + s +' unknown',print); - line_no := orig_style_line[sn]; applyStyle(known_style[sn],s,n1,n2); - style_used[sn] := true; - end; - end; - -{ ------------------------------------------------------------- } - -procedure wipeCommands; - var c: command_type; -begin for c:=c1 to cn do cline[c]:=''; -end; - -function omitLine(line: paragraph_index): boolean; -begin if line=0 then omitLine:=true else omitLine:=omit_line[line] end; - -procedure setName; - var i: integer; -begin if not redefined[name] then exit; - setFeature('instrumentNames',true); - for i:=1 to ninstr do - instr_name[i] := getNextWord(cline[name],blank,dummy); -end; - -procedure setIndent; -begin if redefined[indent] then fracindent := cline[indent]; -end; - -procedure setInitOctave; -begin if redefined[octave] then initOctaves(cline[octave]); -end; - -procedure setVoices(var line: string); - var k: integer; - s, w: string; - procedure checkLabel(w: string); - var j: voice_index; - begin - for j:=1 to nvoices do if w=voice_label[j] then - begin warning('Voice label '+w+' not unique',print); exit; - end; - if length(w)>2 then exit; - if pos1(w[1],'CLU')>0 then - if length(w)>1 then if pos1(w[2],'123456789')=0 then exit - else - else - else if pos1(w[1],'123456789')=0 then exit; - error('Voice label '+w+' conflicts with reserved label',print); - end; -begin nvoices:=0; nstaves:=0; - repeat s:=GetNextWord(line,blank,dummy); - if length(s)>0 then - begin inc(nstaves); k:=0; - first_on_stave[nstaves] := nvoices + 1; - repeat - w:=GetNextWord(s,blank,comma); curtail(w, comma); - if w<>'' then - begin - inc(k); if k<=2 then - begin inc(nvoices); checkLabel(w); - voice_label[nvoices]:=w; - if instr_name[nstaves]='' then instr_name[nstaves]:=w; - setStavePos(nvoices,nstaves,k); - end - end; - until w=''; - if k>2 then error('More than two voices per stave: ' + s,print); - if k=2 then instr_name[nstaves]:='\mtxTwoInstruments{' - + voice_label[nvoices-1] + '}{'+ voice_label[nvoices] + '}'; - number_on_stave[nstaves] := k; - end - until length(line)=0; - for k:=1 to nvoices do selected[k]:=true; -end; - -procedure setClefs(line: string); - var s: string; -begin - nclefs:=0; - repeat - s:=getnextword(line,blank,dummy); - if s<>'' then - begin inc(nclefs); - if length(s)=1 then clef[nclefs]:=s[1] else clef[nclefs]:=s[2]; - end; - until s=''; -end; - -procedure setSize(line: string); - var i: stave_index0; - word: string; - begin i:=0; - while i20 then musicsize:=20; - end; - -function findCommand(var command: string): command_type; - var j: command_type; -begin curtail(command,':'); - if equalsIgnoreCase(command,'STYLE') then style_supplied := true; - for j:=c1 to cn do if equalsIgnoreCase(command,commands[j]) then - begin findCommand:=j; exit; end; - findCommand:=none; -end; - -function isCommand(command: string): boolean; -begin isCommand:=findCommand(command)<>none end; - -procedure doEnable(var line: string; choice: boolean); - var word: string; -begin - repeat word:=GetNextWord(line,blank,dummy); - if word<>'' then if not setFeature(word,choice) then - Error('No such feature: '+word,not print) - until word='' -end; - -function doCommand(line: string): line_type; - var command: string; - last_command: command_type; - starts_with_note: boolean; -begin - if line[1]=comment then begin doCommand:=comment_line; exit; end; - starts_with_note := maybeMusicLine(line); - command:=GetNextWord(line,blank,colon); - if endsWith(command,colon) then - begin last_command:=findCommand(command); - doCommand:=command_line; - if last_command = enable then doEnable(line,true) - else if last_command = disable then doEnable(line,false); - if last_command<>none then - begin cline[last_command]:=line; - if last_command=start then start_line:=line; - if warn_redefine and redefined[last_command] then - warning('You have redefined preamble command '+command,print); - redefined[last_command]:=true; - end - else begin doCommand:=colon_line; addStyle(command+colon+' '+line); - orig_style_line[known_styles] := line_no; - end - end - else if starts_with_note then doCommand:=plain_line - else doCommand:=unknown; -end; - -procedure setOnly(line: string); - var num, num1, num2, l: integer; - s: string; -begin if line='' then exit; - if startsWithIgnoreCase(line,'only') then GetNextWord(line,colon,dummy); - for l:=1 to lines_in_paragraph do omit_line[l]:=true; - repeat s:=GetNextWord(line,blank,comma); if s='' then exit; - curtail(s, comma); - if pos1('-',s)=0 then - begin getNum(s,num); - if (num>0) and (num<=lines_in_paragraph) then omit_line[num]:=false - else warning('Invalid line number in Only: is skipped',print); - end else - begin getTwoNums(s,num1,num2); - if (num1>0) and (num2<=lines_in_paragraph) then - for num:=num1 to num2 do omit_line[num]:=false - else warning('Invalid line range in Only: is skipped',print); - end; - until false; -end; - -procedure interpretCommands; - var i, num, den, nbars: integer; -begin - title_line := cline[title]; - part_line := cline[part]; - if (cline[poet]<>'') or (cline[composer]<>'') then - composer_line:='\mtxComposerLine{'+cline[poet]+'}{'+cline[composer]+'}' - else composer_line:=''; - pmx_line := cline[pmx]; - options_line := GetNextWord(cline[options],blank,dummy); - for i:=1 to known_styles do style_used[i] := false; - applyStyles; setVoices(voices); - for i:=old_known_styles+1 to known_styles do - if not style_used[i] then - begin warning('The following style was supplied but not used',not print); - writeln(known_style[i]); - end; - setClefs(clefs); - if not redefined[meter] then warning( - 'You have not defined Meter, assuming "'+cline[meter]+'" ',not print); - getMeter(cline[meter],meternum, meterdenom, pmnum, pmdenom); - setDefaultDuration(meterdenom); - if (meternum=0) and - not (redefined[pages] or redefined[systems] or redefined[bars]) - then begin cline[bars] := '1'; redefined[bars]:=true; end; - if redefined[pages] or redefined[systems] then - begin if redefined[bars] then - warning('BARS/LINE ignored since you specified PAGES or SYSTEMS',print); - if redefined[systems] then getNum(cline[systems],n_systems) - else warning('PAGES specified but not SYSTEMS',not print); - if redefined[pages] then getNum(cline[pages],n_pages) - else warning('SYSTEMS specified but not PAGES',not print); - end - else if redefined[bars] then - begin getNum(cline[bars],nbars); if nbars>0 then - begin n_pages:=0; n_systems:=nbars end; - end; - getNum(cline[sharps],n_sharps); - setSpace(cline[space]); - setSize(cline[msize]); - getTwoNums(cline[shortnote],num, den); if den=0 then den:=1; - short_note := (num*64) div den; - if cline[flats]<>'' then - begin getNum(cline[flats],n_sharps); n_sharps:=-n_sharps; end; - setName; setIndent; setInitOctave; setOnly(cline[only]); - if options_line <>'' then begin - warning('"Options" is cryptic and obsolescent.', not print); - writeln(' Use "Enable" and "Disable" instead.') - end; - for i:=1 to length(options_line) do processOption(options_line[i]); -end; - -procedure preambleDefaults; - var i: integer; -begin - xmtrnum0:=0; fracindent:='0'; musicsize:=20; start_line:=''; - some_vocal:=false; ngroups:=0; - style_supplied := false; - for i:=1 to maxvoices do setVocal(i,false); - for i:=1 to maxstaves do - begin nspace[i]:=unspec; stave_size[i]:=unspec; end; - n_pages:=1; n_systems:=1; - readStyles; old_known_styles := known_styles; - for i:=1 to lines_in_paragraph do omit_line[i]:=false; -end; - -procedure preambleGuess(maybe_voices: voice_index); -begin - case maybe_voices of - 1: cline[style] := 'Solo'; - 2: cline[style] := 'Duet'; - 3: cline[style] := 'Trio'; - 4: cline[style] := 'Quartet'; - 5: cline[style] := 'Quintet'; - 6: cline[style] := 'Sextet'; - 7: cline[style] := 'Septet'; - else begin error('I cannot guess a style',not print); exit; end; - end; - writeln('I guess this piece is a ',cline[style], - ' for strings in C major.'); - writeln(' Why not provide a STYLE in the setup paragraph to make sure?'); -end; - -{ ------------------------------------------------------------------ } - -procedure nonMusic; - var i: paragraph_index; -begin for i:=1 to para_len do doCommand(P[i]); - setOnly(cline[only]); wipeCommands; -end; - -function thisCase: boolean; -begin thisCase:=true; - if not startsWithIgnoreCase(P[1],'case:') then exit; - thisCase:=(choice<>' ') and (pos1(choice,P[1])>0); P[1]:='%'; -end; - -procedure augmentPreamble(control_para: boolean); - var i: paragraph_index; - l: line_type; - s: array[line_type] of integer; -begin - if not thisCase then exit; - for l:=unknown to plain_line do s[l]:=0; - for i:=1 to para_len do - begin line_no:=orig_line_no[i]; l:=doCommand(P[i]); - inc(s[l]); - if (l=comment_line) and (P[i,2]=comment) - then begin predelete(P[i],2); putLine(P[i]); end; - if not control_para and (l=unknown) then - error('Unidentifiable line',print); - end; - if not control_para and (s[command_line]>0) and (s[plain_line]>0) - then error('Mixture of preamble commands and music',not print); -end; - -procedure doPreamble; - var i: paragraph_index; - maybe_voices: voice_index0; -begin maybe_voices:=0; - if not style_supplied then - begin {augmentPreamble(not known);} - if not style_supplied then warning('No STYLE supplied',not print); - for i:=1 to para_len do if maybeMusicLine(P[i]) then - inc(maybe_voices); - if maybe_voices>0 then preambleGuess(maybe_voices) - else error('No voices found',not print); - end -end; - -procedure respace; - var i, j: stave_index; - begin - for i:=ninstr downto 2 do - begin j:=ninstr-i+1; - if nspace[j]<>unspec then tex3('\mtxInterInstrument{'+toString(i-1)+ - '}{'+toString(nspace[j])+'}'); - end; - if nspace[ninstr]<>unspec then tex3('\mtxStaffBottom{'+ - toString(nspace[ninstr])+'}'); - must_respace:=false; - end; - -procedure restyle; -begin - must_restyle:=false; -end; - -function clefno ( cl: char ): integer; -begin - case cl of -'G','0','t','8': clefno:=0; -'s','1': clefno:=1; -'m','2': clefno:=2; -'a','3': clefno:=3; -'n','4': clefno:=4; -'r','5': clefno:=5; -'F','b','6': clefno:=6; -'C': clefno:=3; - else - begin warning('Unknown clef code - replaced by treble',print); - clefno:=0; - end; - end -end; - -procedure doTenorClefs; - var i: voice_index; - c: char; -begin for i:=1 to nclefs do - begin - c:=clef[i]; if (c='8') or (c='t') then - putLine('\\mtxTenorClef{' + toString(PMXinstr(i)) + '}\' ); - end; -end; - -procedure doPMXpreamble; - const clefcode: string[8]='0123456'; - var i, j: integer; - clefs: string; - function pmxMeter: string; - var denom, num: integer; - begin if meternum=0 then - begin num := beatsPerLine; denom := 0; - old_meter_word := meterChange(num,meterdenom,true); - end - else begin num := meternum; denom := pmdenom; end; - pmxMeter := toString(num) + ' ' + toString(meterdenom) + - ' ' + toString(pmnum) + ' ' + toString(denom); - end; - function sizecode(k: integer): string; - begin sizecode:='\mtxNormalSize'; - case k of -13: if musicsize=20 then sizecode:='\mtxTinySize' else sizecode:='\mtxSmallSize'; -16: if musicsize=20 then sizecode:='\mtxSmallSize'; -20: if musicsize=16 then sizecode:='\mtxLargeSize'; -24: if musicsize=20 then sizecode:='\mtxLargeSize' else sizecode:='\mtxHugeSize'; -29: sizecode:='\mtxHugeSize'; - else error('Valid sizes are 13, 16, 20, 24, 29',print); - end; - end; -begin - if composer_line <> '' then putline(composer_line); - if title_line <> '' then putline('\mtxTitleLine{'+title_line+'}'); - putLine('---'); - if instrumentNames and not redefined[indent] then fracindent:='0.12'; - write(outfile, nstaves); - write(outfile, ' ', -ninstr); - stave[ninstr+1]:=nstaves+1; - for j:=ninstr downto 1 do write(outfile, ' ', stave[j+1] - stave[j]); - writeln(outfile, ' ', pmxMeter, ' ',xmtrnum0:8:5, ' ',n_sharps, - ' ', n_pages, ' ',n_systems, ' ',musicsize, ' ',fracindent); - for i:=1 to ninstr do if not instrumentNames then putLine('') - else putLine('\mtxInstrName{'+instr_name[ninstr+1-i]+'}'); - clefs:=''; - for i:=nclefs downto 1 do clefs:=clefs+clefcode[1+clefno(clef[i])]; - putLine(clefs); - if texdir='' then texdir := './'; - putLine(texdir); - - pmx_preamble_done:=true; respace; - - for j:=1 to ngroups do - writeln(outfile,'\\mtxGroup{'+toString(j)+'}{' - +toString(ninstr+1-group_start[j])+'}{' - +toString(ninstr+1-group_stop[j])+'}\'); - for j:=1 to ninstr do - if (stave_size[j]<>unspec) then - putLine( - '\\mtxSetSize{'+toString(ninstr+1-j)+'}{'+sizecode(stave_size[j])+'}\'); - if part_line <> '' then - begin putLine('Ti'); putLine(part_line); end; - if title_line <> '' then - begin putLine('Tt'); putLine('\mtxTitle'); end; - if composer_line <> '' then - begin putLine('Tc'); putLine('\mtxPoetComposer'); end; - if pmx_line <> '' then putLine(pmx_line); - doTenorClefs; - wipeCommands; -end; - -function startString(voice: voice_index0): string; - var s, w: string; - j: voice_index; -begin s:=start_line; - for j:=1 to voice do w:=getNextWord(s,dummy,';'); - curtail(w,';'); if w<>'' then startString:=w+' ' else startString:=w; -end; - -end. diff --git a/Build/source/utils/m-tx/mtx-0.60d/prepmx.c b/Build/source/utils/m-tx/mtx-0.60d/prepmx.c deleted file mode 100644 index ba186a63e13..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/prepmx.c +++ /dev/null @@ -1,887 +0,0 @@ -/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ -/* From input file "prepmx.pas" */ - - -#include "p2c.h" - - -#ifndef CONTROL_H -#include "control.h" -#endif - -#ifndef STRINGS_H -#include "strings.h" -#endif - -#ifndef GLOBALS_H -#include "globals.h" -#endif - -#ifndef PREAMBLE_H -#include "preamble.h" -#endif - -#ifndef LYRICS_H -#include "lyrics.h" -#endif - -#ifndef MTX_H -#include "mtx.h" -#endif - -#ifndef ANALYZE_H -#include "analyze.h" -#endif - -#ifndef MTXLINE_H -#include "mtxline.h" -#endif - -#ifndef STATUS_H -#include "status.h" -#endif - -#ifndef UPTEXT_H -#include "uptext.h" -#endif - -#ifndef NOTES_H -#include "notes.h" -#endif - -#ifndef MULTFILE_H -#include "multfile.h" -#endif - -#ifndef FILES_H -#include "files.h" -#endif - -#ifndef UTILITY_H -#include "utility.h" -#endif - - -/* fpc mistakenly thinks CONTROL and GLOBALS are not used */ - -/* CMO: addition/change by Christian Mondrup */ - -/** M-Tx preprocessor to PMX Dirk Laurie */ - -#define version "0.60d" -#define version_date "<11 October 2008>" - -/** See file "Corrections" for updates later than those listed below -*/ - -/** Changes since 0.52b - Uses mtx.tex file - More than one # or % per word treated correctly in uptext - Better way of handling line numbers in lyrics -*/ - -/** To do next: - Take notice of recent improvements in musixtex, pmx and musixlyr -{* Current bugs: -{* Old bugs: - Does not check PMX syntax -{* Weaknesses that may later cause bugs: - Decisions sometimes made on note, sometimes on scan - Can 'here' overrun? - Where does one note stop and the next begin? - See comment on '!' in uptext -*/ - -#define chord_flat 't' -#define chord_left 'l' - -#define blind true -#define visible false - - -Static boolean last_bar; -Static Char multibar[256]; -Static Char repeat_sign[256]; -Static short bar_of_line, bars_of_rest, rest_spacing; - - -/* --------------- Bars and rests --------------- */ - -Static Void writeRepeat(bar) -Char *bar; -{ - Char repcode[256]; - Char STR1[256]; - - if (*bar == '\0') - return; - *repcode = '\0'; - if (!strcmp(bar, "||")) - strcpy(repcode, "Rd"); - else if (!strcmp(bar, "|]")) - strcpy(repcode, "RD"); - else if (!strcmp(bar, "|:")) - strcpy(repcode, "Rl"); - else if (!strcmp(bar, ":|:")) - strcpy(repcode, "Rlr"); - else if (!strcmp(bar, ":|")) - strcpy(repcode, "Rr"); - else if (last_bar && !strcmp(bar, "|")) - strcpy(repcode, "Rb"); - if (*repcode != '\0') { - sprintf(STR1, " %s", repcode); - putLine(STR1); - } - *bar = '\0'; -} - - -Static Void supplyRests(voice) -voice_index voice; -{ - Char STR2[4]; - Char STR3[256]; - - if (multi_bar_rest) { - put(multibar, putspace); - return; - } - if (bar_of_line == 1 && pedanticWarnings()) { - printf("Bar %d Voice %d", bar_no, voice); - warning(" Filling missing voice with rests", !print); - } - if (pickup > 0) - put(rests(STR3, pickup, meterdenom, visible), nospace); - sprintf(STR2, "%s ", pause); - put(STR2, putspace); -} - - -Static Void countBars(note_) -Char *note_; -{ - Char note[256]; - short k, adjust; - short sign = 1; - - strcpy(note, note_); - predelete(note, 2); - k = pos1('+', note); - if (k == 0) { - k = pos1('-', note); - if (k > 0) - sign = -1; - } - if (k > 0) { - note[k-1] = '/'; - getTwoNums(note, &bars_of_rest, &adjust); - } else { - getNum(note, &bars_of_rest); - adjust = 0; - } - rest_spacing = adjust * sign + 14; -} - - -/* FIXME This procedure had a serious bug. It now has a smaller bug. - Basically there should be a test on whether a break between staves - is a break between instruments, in which case the procedure is (now) - right; or a break between staves of the same instrument, in which - case a '|' instead of a '&' should be output (as it was). If the Space - feature is not used, the bug does not show up. */ -Static Void putMBRest() -{ - stave_index i, FORLIM; - Char STR1[256]; - Char STR2[256], STR3[256]; - - put("\\\\\\def\\atnextbar{\\znotes", nospace); - FORLIM = nstaves; - for (i = 1; i <= FORLIM; i++) { - sprintf(STR3, "\\mbrest{%s}{%s}0", - toString(STR1, bars_of_rest), toString(STR2, rest_spacing)); - put(STR3, nospace); - if (i < nstaves) - put("&", nospace); - else - putLine("\\en}\\"); - } - sprintf(STR3, "\\\\\\advance\\barno%s\\", toString(STR1, bars_of_rest - 1)); - putLine(STR3); - bar_no += bars_of_rest - 1; -} - - -/* Local variables for processLine: */ -struct LOC_processLine { - voice_index voice; - Char chords[256], note[256], cutnote[256], pretex[256]; - short ngrace, nmulti; - boolean no_chords, no_uptext; - - short l; - boolean in_group; -} ; - -Local Void output(note_, LINK) -Char *note_; -struct LOC_processLine *LINK; -{ - Char note[256]; - Char STR2[256]; - - strcpy(note, note_); - if (*note != '\0') - { /* pretex is saved up until a spacing note or rest comes */ - if (endsWith(note, "\\") && note[1] != '\\') { - curtail(note, '\\'); - strcat(LINK->pretex, note); - *note = '\0'; - return; - } - if (*LINK->pretex != '\0' && isNoteOrRest(note)) { - sprintf(note, "%s\\ %s", LINK->pretex, strcpy(STR2, note)); - *LINK->pretex = '\0'; - } - if (outlen > 0 && note[0] != ' ') - sprintf(note, " %s", strcpy(STR2, note)); - put(note, nospace); - } - if (thisNote(LINK->voice) == nextvoice) - putLine(""); -} - -Local Void maybeDotted(note, LINK) -Char *note; -struct LOC_processLine *LINK; -{ - if (strlen(note) < 2) - return; - if (note[1] == '"') { - note[1] = note[0]; - strcat(LINK->pretex, "\\mtxDotted"); - } -} - -/* Local variables for addChords: */ -struct LOC_addChords { - struct LOC_processLine *LINK; - Char nt[256], labels[256]; - boolean tieme; - Char lab; - int5 pitches; -} ; - -Local Void outChord(LINK) -struct LOC_addChords *LINK; -{ - short k; - Char STR2[256]; - short FORLIM; - - if (*LINK->nt == '\0') - return; - LINK->tieme = (LINK->nt[0] == '{'); - if (LINK->tieme) - predelete(LINK->nt, 1); - if (*LINK->nt == '\0' || LINK->nt[0] < 'a' || LINK->nt[0] > 'g') { - sprintf(STR2, "Must have a note name at the start of \"%s\", not \"%c\"", - LINK->nt, LINK->nt[0]); - error(STR2, print); - } - renewChordPitch(LINK->LINK->voice, LINK->nt); - sprintf(LINK->LINK->chords + strlen(LINK->LINK->chords), " z%s", LINK->nt); - *LINK->nt = '\0'; - FORLIM = strlen(LINK->labels); - for (k = 0; k <= FORLIM - 1; k++) { - if (chordPitch(LINK->LINK->voice) == LINK->pitches[k]) { - sprintf(LINK->LINK->chords + strlen(LINK->LINK->chords), " s%ct", - LINK->labels[k]); - LINK->labels[k] = ' '; - } - } - if (LINK->tieme) { - chordTie(LINK->LINK->voice, &LINK->lab); - sprintf(LINK->LINK->chords + strlen(LINK->LINK->chords), " s%ct", - LINK->lab); - } -} - -Local Void addChords(LINK) -struct LOC_processLine *LINK; -{ - struct LOC_addChords V; - Char w[256]; - short j = 1; - short mus_line; - paragraph_index0 chord_line; - boolean arpeggio; - Char STR1[256]; - short FORLIM; - - V.LINK = LINK; - saveStatus(LINK->voice); - getChordTies(LINK->voice, V.pitches, V.labels); - *LINK->chords = '\0'; - chord_line = chordLineNo(LINK->voice); - if (chord_line == 0) - LINK->no_chords = true; - if (LINK->no_chords) - return; - GetNextWord(w, P[chord_line-1], blank, dummy); - sprintf(STR1, "%c", barsym); - if (!strcmp(w, STR1) || *w == '\0') - LINK->no_chords = true; - sprintf(STR1, "%c", tilde); - if (!strcmp(w, STR1) || LINK->no_chords) - return; - mus_line = line_no; - line_no = orig_line_no[chord_line-1]; - arpeggio = (w[0] == '?'); - if (arpeggio) { - strcpy(LINK->chords, " ?"); - predelete(w, 1); - } - *V.nt = '\0'; - while (j <= strlen(w)) { - if (w[j-1] == '{' || strcmp(V.nt, "{") && w[j-1] >= 'a' && w[j-1] <= 'g') - outChord(&V); - else if (w[j-1] == chord_flat) - w[j-1] = 'f'; - else if (w[j-1] == chord_left) - w[j-1] = 'e'; - sprintf(V.nt + strlen(V.nt), "%c", w[j-1]); - j++; - } - if (*V.nt != '\0') - outChord(&V); - if (arpeggio) - strcat(LINK->chords, " ?"); - strcat(LINK->note, LINK->chords); - FORLIM = strlen(V.labels); - for (j = 0; j <= FORLIM - 1; j++) { - if (V.labels[j] != ' ') - error("Tie on chord note started but not finished", print); - } - line_no = mus_line; -} - -Local Char *processOther(Result, note_, LINK) -Char *Result; -Char *note_; -struct LOC_processLine *LINK; -{ - Char note[256]; - - strcpy(note, note_); - switch (thisNote(LINK->voice)) { - - case other: - if (note[0] == grace_group) { - if (strlen(note) == 1) - LINK->ngrace = 1; - else - LINK->ngrace = pos1(note[1], digits); - if (LINK->ngrace > 0) - LINK->ngrace--; - } - break; - - /* For a zword, take note of pitch but do not change the contents */ - /* Add spurious duration because repich expects duration to be present */ - case zword: - strcpy(LINK->cutnote, note); - predelete(LINK->cutnote, 1); - insertChar('4', LINK->cutnote, 2); - checkOctave(LINK->voice, LINK->cutnote); - renewPitch(LINK->voice, LINK->cutnote); - break; - - case lyrtag: - extractLyrtag(LINK->voice, note); - break; - - case rbrac: - endBeam(LINK->voice); - break; - - case rparen: - case rlparen: - endSlur(LINK->voice, note); - break; - - case lbrac: - beginBeam(LINK->voice, note); - break; - - case lparen: - maybeDotted(note, LINK); - beginSlur(LINK->voice, note); - break; - - case mword: - error3(LINK->voice, "Meter change must be the first word of its bar"); - break; - - case atword: - lyricsAdjust(LINK->voice, note); - break; - } - return strcpy(Result, note); -} - -Local Void lookahead(LINK) -struct LOC_processLine *LINK; -{ - Char STR2[256]; - Char STR3[256]; - - while (bind_left[(long)nextNote(LINK->voice)]) - sprintf(LINK->note + strlen(LINK->note), " %s", - processOther(STR2, getMusicWord(STR3, LINK->voice), LINK)); -} - -Local Void processNote_(LINK) -struct LOC_processLine *LINK; -{ - if (hasVerseNumber(LINK->voice)) - strcat(LINK->pretex, "\\mtxVerse"); - LINK->l = pos1(multi_group, LINK->note); - if (LINK->l > 0) - scan1(LINK->note, LINK->l + 1, &LINK->nmulti); - activateBeamsAndSlurs(LINK->voice); - LINK->in_group = false; - if (LINK->ngrace > 0) { - LINK->in_group = true; - LINK->ngrace--; - } else { - if (LINK->nmulti > 0) { - LINK->in_group = true; - LINK->nmulti--; - } - } - checkOctave(LINK->voice, LINK->note); - renewPitch(LINK->voice, LINK->note); - if (!LINK->in_group) { - resetDuration(LINK->voice, durationCode(LINK->note)); - markDebeamed(LINK->voice, LINK->note); - } - lookahead(LINK); - getSyllable(LINK->voice, LINK->pretex); - addUptext(LINK->voice, &LINK->no_uptext, LINK->pretex); - addChords(LINK); -} - - -/* ---------------------------------------------------------------- */ - -Static Void processLine(voice_, bar_no) -voice_index voice_; -short bar_no; -{ - struct LOC_processLine V; - paragraph_index par_line; - Char STR2[256]; - - V.voice = voice_; - *V.pretex = '\0'; - V.no_chords = false; - V.no_uptext = false; - par_line = musicLineNo(V.voice); - V.nmulti = 0; - V.ngrace = 0; - line_no = orig_line_no[par_line-1]; - do { - getMusicWord(V.note, V.voice); - if (*V.note == '\0') - return; - if (debugMode()) - printf("%d %s\n", V.voice, V.note); - switch (thisNote(V.voice)) { - - case rword: - if (multi_bar_rest) { - countBars(V.note); - strcpy(V.note, multibar); - if (uptextOnRests()) - addUptext(V.voice, &V.no_uptext, V.pretex); - } else { - V.l = pos1(multi_group, V.note); - if (V.l > 0) - scan1(V.note, V.l + 1, &V.nmulti); - if (V.nmulti > 0) { - V.in_group = true; - V.nmulti--; - } - if (uptextOnRests()) - addUptext(V.voice, &V.no_uptext, V.pretex); - if (!isPause(V.note)) - resetDuration(V.voice, durationCode(V.note)); - } - break; - - case abcdefg: - processNote_(&V); - break; - - case barword: - if (V.voice == nvoices) { - if (endOfBar(V.voice, bar_no)) - strcpy(repeat_sign, V.note); - else - writeRepeat(V.note); - } - sprintf(STR2, "%c", barsym); - if (strcmp(V.note, STR2)) - *V.note = '\0'; - V.no_chords = false; - break; - - case FirstOnly: - if (V.voice != nvoices) - *V.note = '\0'; - else - strcpy(V.note, processOther(STR2, V.note, &V)); - break; - - default: - strcpy(V.note, processOther(STR2, V.note, &V)); - break; - } - output(V.note, &V); - } while (!endOfBar(V.voice, bar_no)); - if (!V.no_chords) - skipChordBar(V.voice); -} - - -/* ------------------------------------------------------------------- */ - -Static Void getMeterChange(voice, new_meter) -voice_index voice; -Char *new_meter; -{ - short pn1, pn2; - Char w[256], new_command[256]; - - if (nextNote(voice) != mword) - return; - getMusicWord(w, voice); - getMeter(w, &meternum, &meterdenom, &pn1, &pn2); - full_bar = meternum * (64 / meterdenom); - /* CMO: process denominator value with function PMXmeterdenom */ - meterWord(new_command, meternum, PMXmeterdenom(meterdenom), pn1, pn2); - if (*new_meter != '\0' && strcmp(new_meter, new_command)) - error3(voice, "The same meter change must appear in all voices"); - strcpy(new_meter, new_command); -} - - -/* Local variables for musicParagraph: */ -struct LOC_musicParagraph { - Char new_meter[256]; -} ; - -Local Void putPMXlines(LINK) -struct LOC_musicParagraph *LINK; -{ - paragraph_index i, FORLIM; - - FORLIM = para_len; - for (i = 0; i <= FORLIM - 1; i++) { - if (startsWith(P[i], double_comment)) { - predelete(P[i], 2); - putLine(P[i]); - strcpy(P[i], "%"); - } - } -} - -Local Void processOneBar(LINK) -struct LOC_musicParagraph *LINK; -{ - paragraph_index0 m, cm; - short n1, n2; - voice_index voice, cvoice; - boolean ignore_voice; - boolean wrote_repeat = false; - boolean alone; - Char STR2[256]; - Char STR3[256]; - - if (bar_of_line > 1) { - sprintf(STR3, "%cBar %s", comment, toString(STR2, bar_no)); - putLine(STR3); - } - last_bar = (bar_of_line == nbars && final_paragraph); - if (last_bar && !strcmp(repeat_sign, "|")) - *repeat_sign = '\0'; - writeRepeat(repeat_sign); - *LINK->new_meter = '\0'; - for (voice = nvoices; voice >= 1; voice--) { - if (musicLineNo(voice) > 0) { - gotoBar(voice, bar_of_line); - getMeterChange(voice, LINK->new_meter); - } - } - if (last_bar && *LINK->new_meter == '\0' && nleft > pickup && meternum > 0) - meterChange(LINK->new_meter, nleft, 64, true); - if (*LINK->new_meter != '\0') - putLine(LINK->new_meter); - if (multi_bar_rest) { - n1 = meternum * 64; - n2 = meterdenom; - cancel(&n1, &n2, 1); - rests(multibar, n1, n2, blind); - } - for (voice = nvoices; voice >= 1; voice--) { - ignore_voice = !selected[voice-1]; - cvoice = companion(voice); - m = musicLineNo(voice); - cm = musicLineNo(cvoice); - alone = (voice == cvoice || m > 0 && cm == 0 || - m == 0 && cm == 0 && voice < cvoice || !selected[cvoice-1]); - if (selected[voice-1]) { - if (m > 0) - processLine(voice, bar_of_line); - else if (alone) - supplyRests(voice); - else - ignore_voice = true; - if (last_bar && *repeat_sign != '\0' && !wrote_repeat) { - writeRepeat(repeat_sign); - wrote_repeat = true; - } - if (!ignore_voice) { - if (alone || voicePos(voice) == 1) - putLine(" /"); - else - putLine(" //"); - } - } - } - if (multi_bar_rest) - putMBRest(); - bar_no++; - pickup = 0; - putLine(""); -} - -Local Void putMeter(new_meter_word, LINK) -Char *new_meter_word; -struct LOC_musicParagraph *LINK; -{ - if (strcmp(new_meter_word, old_meter_word)) - putLine(new_meter_word); - strcpy(old_meter_word, new_meter_word); -} - - -Static Void musicParagraph() -{ - struct LOC_musicParagraph V; - voice_index0 j, nvoice; - Char lyrassign[256]; - Char STR1[256]; - Char STR2[256]; - Char STR3[256], STR4[256], STR5[256]; - voice_index0 FORLIM; - short FORLIM1; - - paragraphSetup(&nvoice); - if (nvoice == 0) { - nonMusic(); - return; - } - if (nvoice > nvoices) { - if (nvoice == 0) - error("No voices! Did you remember to to supply a Style?", !print); - sprintf(STR4, "Paragraph has %s voices but Style allows only %s", - toString(STR1, nvoice), toString(STR2, nvoices)); - error(STR4, !print); - return; - } - if (first_paragraph) - includeStartString(); - if (pmx_preamble_done && (!final_paragraph || nvoice > 0)) { - sprintf(STR5, "%c Paragraph %s line %s bar %s", - comment, toString(STR1, paragraph_no), - toString(STR2, orig_line_no[0]), toString(STR3, bar_no)); - putLine(STR5); - } - testParagraph(); - rememberDurations(); - if (beVerbose()) - describeParagraph(); - /* ---- Knowing the score, we can start setting music ---------------- */ - if (!pmx_preamble_done) { - doPMXpreamble(); - sprintf(STR3, "%c Paragraph %s line %s bar ", - comment, toString(STR1, paragraph_no), - toString(STR2, orig_line_no[0])); - put(STR3, putspace); - if (pickup > 0) - putLine("0"); - else - putLine("1"); - } - putPMXlines(&V); - if (must_restyle) - restyle(); - if (some_vocal && (nvoice > 0 || !final_paragraph)) { - FORLIM = ninstr; - for (j = 1; j <= FORLIM; j++) { - assignLyrics(j, lyrassign); - if (*lyrassign != '\0') { - sprintf(STR2, "\\\\%s\\", lyrassign); - putLine(STR2); - } - } - } - if (must_respace) - respace(); - if (meternum == 0) - putMeter(meterChange(STR2, beatsPerLine(), meterdenom, true), &V); - if (nleft > 0) - nbars++; - if (nbars == 0 && multi_bar_rest) - nbars = 1; - FORLIM1 = nbars; - for (bar_of_line = 1; bar_of_line <= FORLIM1; bar_of_line++) - processOneBar(&V); - restoreDurations(); -} - - -/* ----------------------------------------------------------------------- */ - -Static boolean no_commands_yet; - - -Static Void doMusic() -{ - Char STR1[256], STR2[256]; - Char STR4[256]; - - first_paragraph = true; - pmx_preamble_done = false; - bar_no = 1; - *repeat_sign = '\0'; - must_respace = false; - must_restyle = false; - do { - final_paragraph = endOfInfile(); - if (para_len > 0 && !ignore_input && thisCase()) { - if (no_commands_yet) { - interpretCommands(); - printFeatures(false); - one_beat = 64 / meterdenom; - full_bar = meternum * one_beat; - if (nvoices > standardPMXvoices) { - sprintf(STR4, "You have %s voices; standard PMX can only handle %s", - toString(STR1, nvoices), toString(STR2, standardPMXvoices)); - warning(STR4, !print); - } - initMTX(); - initUptext(); - initStatus(); - initLyrics(); - no_commands_yet = false; - } - if (startsWithBracedWord(P[0])) - lyricsParagraph(); - else { - musicParagraph(); - first_paragraph = false; - writeRepeat(repeat_sign); - } - } - readParagraph(P, orig_line_no, ¶_len); - } while (para_len != 0); -} - - -Static boolean control_paragraph, no_report_errors; - - -Static boolean isControlParagraph(P, para_len) -Char (*P)[256]; -paragraph_index para_len; -{ - paragraph_index0 commands = 0, labels = 0, voices = 0, guff = 0; - paragraph_index0 i; - Char w[256]; - -/* p2c: prepmx.pas: Note: Eliminated unused assignment statement [338] */ - for (i = 0; i <= para_len - 1; i++) { - if (!startsWith(P[i], "%")) { - NextWord(w, P[i], ' ', ':'); - if (!endsWith(w, ":")) - guff++; - else if (strlen(w) < 3 || findVoice(w) > 0) - voices++; - else if (isCommand(w)) - commands++; - else - labels++; - } - } - if (voices + guff > commands) - return false; - return true; -} - - -Static Void topOfPMXfile() -{ - Char STR2[24]; - Char STR3[34]; - - putLine("---"); - sprintf(STR2, "\\def\\mtxversion{%s}", version); - putLine(STR2); - sprintf(STR3, "\\def\\mtxdate{%s}", version_date); - putLine(STR3); - putLine("\\input mtx"); -} - - -main(argc, argv) -int argc; -Char *argv[]; -{ /* ---- Main program ------------------------ */ - PASCAL_MAIN(argc, argv); - strcpy(this_version, version); - strcpy(this_version_date, version_date); - printf("==> This is M-Tx %s (Music from TeXt) %s\n", version, version_date); - mtxLevel(version); - OpenFiles(); - no_commands_yet = true; - preambleDefaults(); - no_report_errors = false; - topOfPMXfile(); - do { - readParagraph(P, orig_line_no, ¶_len); - control_paragraph = isControlParagraph(P, para_len); - if (control_paragraph) { - augmentPreamble(no_report_errors); - no_report_errors = true; - if (para_len == 0) - error("No music paragraphs!", !print); - } - } while (control_paragraph); - doPreamble(); - doMusic(); - if (!pmx_preamble_done) - error("No music paragraphs!", !print); - putLine("% Coded by M-Tx"); - CloseFiles(); - printf("PrePMX done. Now run PMX.\n"); - _Escape(0); - exit(EXIT_SUCCESS); -} - - - - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/prepmx.pas b/Build/source/utils/m-tx/mtx-0.60d/prepmx.pas deleted file mode 100644 index 0b246e04f7d..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/prepmx.pas +++ /dev/null @@ -1,444 +0,0 @@ -program prepmx; -uses control, strings, globals, preamble, lyrics, mtx, analyze, - mtxline, status, uptext, notes, files, utility; -{ fpc mistakenly thinks CONTROL and GLOBALS are not used } - -{* M-Tx preprocessor to PMX Dirk Laurie } -const version = '0.60'; - version_date = '<16 March 2005>'; - -{* See file "Corrections" for updates later than those listed below -} - -{* Changes since 0.52b - Uses mtx.tex file - More than one # or % per word treated correctly in uptext - Better way of handling line numbers in lyrics -} - -{* To do next: - Take notice of recent improvements in musixtex, pmx and musixlyr -{* Current bugs: -{* Old bugs: - Does not check PMX syntax -{* Weaknesses that may later cause bugs: - Decisions sometimes made on note, sometimes on scan - Can 'here' overrun? - Where does one note stop and the next begin? - See comment on '!' in uptext -} - chord_flat = 't'; - chord_left = 'l'; - blind = true; - visible = false; - -var - last_bar: boolean; - multibar: string; - repeat_sign: string; - bar_of_line, bars_of_rest, rest_spacing: integer; - -{ --------------- Bars and rests --------------- } - -procedure writeRepeat(var bar: string); - var repcode: string; - begin if bar='' then exit; - repcode:=''; - if bar='||' then repcode:='Rd' - else if (bar='|]') then repcode:='RD' - else if bar='|:' then repcode:='Rl' - else if bar=':|:' then repcode:='Rlr' - else if bar=':|' then repcode:='Rr' - else if last_bar and (bar='|') then repcode:='Rb'; - if repcode<>'' then putLine(' '+repcode); - bar:=''; - end; - -procedure supplyRests(voice: voice_index); -begin - if multi_bar_rest then - begin put(multibar,putspace); exit; end; - if (bar_of_line=1) and pedanticWarnings then - begin write('Bar ', bar_no, ' Voice ', voice); - warning(' Filling missing voice with rests',not print); - end; - if pickup>0 then - put(rests(pickup,meterdenom,visible),nospace); - put(pause+' ',putspace); -end; - -procedure countBars(note: string); - var k, adjust, sign: integer; -begin predelete(note,2); k:=pos1('+',note); sign:=1; - if k=0 then - begin k:=pos1('-',note); if k>0 then sign:=-1; end; - if k>0 then - begin note[k]:='/'; getTwoNums(note,bars_of_rest,adjust); end - else begin getNum(note,bars_of_rest); adjust:=0; end; - rest_spacing := 14 + adjust*sign; -end; - -(* FIXME This procedure had a serious bug. It now has a smaller bug. - Basically there should be a test on whether a break between staves - is a break between instruments, in which case the procedure is (now) - right; or a break between staves of the same instrument, in which - case a '|' instead of a '&' should be output (as it was). If the Space - feature is not used, the bug does not show up. *) -procedure putMBRest; - var i: stave_index; -begin - put('\\\def\atnextbar{\znotes',nospace); - for i:=1 to nstaves do - begin put('\mbrest{'+toString(bars_of_rest)+'}{'+toString(rest_spacing) - +'}0',nospace); - if i'' then - begin { pretex is saved up until a spacing note or rest comes } - if endsWith(note,'\') and (note[2]<>'\') then - begin curtail(note,'\'); pretex:=pretex+note; note:=''; exit end; - if (pretex<>'') and isNoteOrRest(note) then - begin note:=pretex+'\ '+note; pretex:='' end; - if (outlen>0) and (note[1]<>' ') then note:=' '+note; - put(note,nospace); - end; - if thisNote(voice)=nextvoice then putLine(''); - end; - - procedure maybeDotted(var note: string); - begin if length(note)<2 then exit; - if note[2]='"' then - begin note[2]:=note[1]; pretex:=pretex+'\mtxDotted' end - end; - - procedure addChords; - var w, nt, labels: string; - j, mus_line: integer; - chord_line: paragraph_index0; - arpeggio, tieme: boolean; - lab: char; - pitches: int5; - procedure outChord; - var k: integer; - begin if nt='' then exit; tieme:=nt[1]='{'; if tieme then predelete(nt,1); - if (nt='') or (nt[1]<'a') or (nt[1]>'g') then - error('Must have a note name at the start of "'+nt - +'", not "'+nt[1]+'"',print); - renewChordPitch(voice,nt); - chords := chords+' z'+nt; nt:=''; - for k:=1 to length(labels) do if chordPitch(voice)=pitches[k] then - begin chords:=chords+' s'+labels[k]+'t'; labels[k]:=' ' end; - if tieme then begin chordTie(voice,lab); chords:=chords+' s'+lab+'t' end - end; - begin saveStatus(voice); - getChordTies(voice, pitches, labels); - chords:=''; chord_line:=chordLineNo(voice); - if chord_line=0 then no_chords:=true; - if no_chords then exit; - w := getNextWord(P[chord_line],blank,dummy); - if (w=barsym) or (w='') then no_chords:=true; - if (w=tilde) or no_chords then exit; - mus_line:=line_no; line_no:=orig_line_no[chord_line]; - arpeggio := w[1]='?'; if arpeggio then - begin chords:=' ?'; predelete(w,1); end; - j:=1; nt:=''; - while j<=length(w) do - begin - if (w[j]='{') or ((nt<>'{') and (w[j]>='a') and (w[j]<='g')) then outChord - else if w[j]=chord_flat then w[j]:='f' - else if w[j]=chord_left then w[j]:='e'; - nt:=nt+w[j]; j:=j+1 - end; - if nt<>'' then outChord; if arpeggio then chords:=chords+' ?'; - note:=note+chords; - for j:=1 to length(labels) do if labels[j]<>' ' then - error('Tie on chord note started but not finished',print); - line_no:=mus_line; - end; - - function processOther(note: string): string; - begin - case thisNote(voice) of -other: if note[1]=grace_group then - begin if length(note)=1 then ngrace:=1 - else ngrace := pos1(note[2],digits); - if ngrace>0 then dec(ngrace); - end; -{ For a zword, take note of pitch but do not change the contents } -{ Add spurious duration because repich expects duration to be present } -zword: begin cutnote:=note; predelete(cutnote,1); insertchar('4',cutnote,2); - checkOctave(voice,cutnote); renewPitch(voice,cutnote) - end; -lyrtag: extractLyrtag(voice,note); -rbrac: endBeam(voice); -rparen, rlparen: endSlur(voice,note); -lbrac: beginBeam(voice,note); -lparen: begin maybeDotted(note); beginSlur(voice,note); end; -mword: error3(voice,'Meter change must be the first word of its bar'); -atword: lyricsAdjust(voice, note); - end; - processOther:=note; - end; - - procedure lookahead; - begin while bind_left[nextNote(voice)] do - note:=note+' '+processOther(getMusicWord(voice)); - end; - - var l: integer; - in_group: boolean; - - procedure processNote; - begin - begin if hasVerseNumber(voice) then pretex:=pretex+'\mtxVerse'; - l := pos1(multi_group,note); - if l>0 then scan1(note,l+1,nmulti); - activateBeamsAndSlurs(voice); - in_group:=false; - if ngrace>0 then begin in_group:=true; dec(ngrace) end else - if nmulti>0 then begin in_group:=true; dec(nmulti); end; - checkOctave(voice,note); renewPitch(voice,note); - if not in_group then - begin resetDuration(voice,durationCode(note)); markDebeamed(voice,note) end; - lookahead; getSyllable(voice,pretex); - addUptext(voice, no_uptext, pretex); - addChords; - end; - end; - -begin - pretex:=''; no_chords:=false; no_uptext := false; - par_line:=musicLineNo(voice); - nmulti :=0; ngrace := 0; line_no:=orig_line_no[par_line]; - repeat note:=getMusicWord(voice); if note='' then exit; - if debugMode then writeln(voice,' ',note); - case thisNote(voice) of - rword: begin if multi_bar_rest then - begin countBars(note); note:=multibar; - if uptextOnRests then - addUptext(voice, no_uptext, pretex); - end - else begin - l := pos1(multi_group,note); - if l>0 then scan1(note,l+1,nmulti); - if nmulti>0 then begin in_group:=true; dec(nmulti); end; - if uptextOnRests then - addUptext(voice, no_uptext, pretex); - if not isPause(note) then resetDuration(voice,durationCode(note)); - end - end; - abcdefg: processNote; - barword: begin - if voice=nvoices then - if endOfBar(voice,bar_no) then repeat_sign := note - else writeRepeat(note); - if note<>barsym then note:=''; - no_chords:=false; - end; - FirstOnly: if voice<>nvoices then note:='' else - note:=processOther(note); - else note:=processOther(note); - end; - output(note); - until endOfBar(voice,bar_no); - if not no_chords then skipChordBar(voice); -end; - -{ ------------------------------------------------------------------- } - -procedure getMeterChange(voice: voice_index; var new_meter: string); - var pn1, pn2: integer; - w, new_command: string; -begin if nextNote(voice)<>mword then exit; - w:=getMusicWord(voice); - getMeter(w, meternum, meterdenom, pn1, pn2); - full_bar := meternum*(64 div meterdenom); - new_command := meterWord(meternum, meterdenom, pn1, pn2); - if (new_meter<>'') and (new_meter<>new_command) - then error3(voice,'The same meter change must appear in all voices'); - new_meter:=new_command; -end; - -procedure musicParagraph; - var j, nvoice: voice_index0; - new_meter, lyrassign: string; - - procedure putPMXlines; - var i: paragraph_index; - begin for i:=1 to para_len do - if startsWith(P[i],double_comment) then - begin predelete(P[i],2); putLine(P[i]); P[i]:='%'; end; - end; - - procedure processOneBar; - var m, cm: paragraph_index0; - n1, n2: integer; - voice, cvoice: voice_index; - ignore_voice, wrote_repeat, alone: boolean; - begin - if bar_of_line>1 then putLine(comment+'Bar '+toString(bar_no)); - last_bar := (bar_of_line=nbars) and final_paragraph; - if last_bar and (repeat_sign='|') then repeat_sign:=''; - writeRepeat(repeat_sign); new_meter := ''; - for voice:=nvoices downto 1 do - if musicLineNo(voice)>0 then - begin gotoBar(voice,bar_of_line); getMeterChange(voice,new_meter); - end; - if last_bar and (new_meter='') and (nleft>pickup) and (meternum>0) then - new_meter := meterChange(nleft,64,true); - if new_meter<>'' then putLine(new_meter); - wrote_repeat := false; if multi_bar_rest then - begin n1:=64*meternum; n2:=meterdenom; cancel(n1,n2,1); - multibar:=rests(n1,n2,blind); - end; - for voice:=nvoices downto 1 do - begin ignore_voice:=not selected[voice]; cvoice:=companion(voice); - m:=musicLineNo(voice); cm:=musicLineNo(cvoice); - alone:=(voice=cvoice) or ((m>0) and (cm=0)) - or ((m=0) and (cm=0) and (voice0 then processLine(voice,bar_of_line) - else if alone then supplyRests(voice) else ignore_voice:=true; - if last_bar and (repeat_sign<>'') and not wrote_repeat then - begin writeRepeat(repeat_sign); wrote_repeat := true; end; - if not ignore_voice then - if alone or (voicePos(voice)=1) then putLine(' /') - else putLine(' //'); - end; - end; - if multi_bar_rest then putMBRest; - inc(bar_no); pickup:=0; putLine(''); - end; - - procedure putMeter(new_meter_word: string); - begin if new_meter_word<>old_meter_word then putLine(new_meter_word); - old_meter_word := new_meter_word; - end; - -begin - paragraphSetup(nvoice); - if nvoice=0 then begin nonMusic; exit end - else if nvoice>nvoices then - begin if nvoice=0 then - error('No voices! Did you remember to to supply a Style?',not print); - error('Paragraph has '+toString(nvoice)+ - ' voices but Style allows only '+toString(nvoices),not print); exit; - end; - if first_paragraph then includeStartString; - if pmx_preamble_done and (not final_paragraph or (nvoice>0)) then - putLine(comment +' Paragraph ' + toString(paragraph_no) + - ' line ' + toString(orig_line_no[1]) + ' bar ' + toString(bar_no)); - testParagraph; rememberDurations; - if beVerbose then describeParagraph; - { ---- Knowing the score, we can start setting music ---------------- } - if not pmx_preamble_done then - begin doPMXpreamble; - put( comment + ' Paragraph ' + toString(paragraph_no) + ' line ' + - toString(orig_line_no[1]) + ' bar ',putspace); - if pickup>0 then putLine('0') else putLine('1'); - end; - putPMXlines; - if must_restyle then restyle; - if some_vocal and ((nvoice>0) or not final_paragraph) then - for j:=1 to ninstr do - begin assignLyrics(j,lyrassign); - if lyrassign<>'' then putLine('\\'+lyrassign+'\'); - end; - if must_respace then respace; - if (meternum=0) then putMeter(meterChange(beatsPerLine,meterdenom,true)); - if nleft > 0 then inc(nbars); - if (nbars=0) and multi_bar_rest then nbars:=1; - for bar_of_line:=1 to nbars do - processOneBar; - restoreDurations; -end; - -{ ----------------------------------------------------------------------- } - -var no_commands_yet: boolean; - -procedure doMusic; -begin first_paragraph:=true; pmx_preamble_done:=false; bar_no:=1; - repeat_sign:=''; must_respace:=false; must_restyle:=false; - repeat final_paragraph := endOfInfile; - if (para_len>0) and not ignore_input and thisCase then - begin if no_commands_yet then - begin interpretCommands; printFeatures(false); - one_beat := 64 div meterdenom; full_bar := meternum*one_beat; - if nvoices>standardPMXvoices then warning('You have ' - +toString(nvoices)+' voices; standard PMX can only handle ' - +toString(standardPMXvoices),not print); - initMTX; initUptext; initStatus; initLyrics; - no_commands_yet:=false - end; - if startsWithBracedWord(P[1]) then lyricsParagraph else - begin musicParagraph; first_paragraph:=false; - writeRepeat(repeat_sign); - end - end; - readParagraph(P,orig_line_no,para_len); - until para_len=0; -end; - -var control_paragraph, no_report_errors: boolean; - -function isControlParagraph (var P: paragraph; para_len: paragraph_index) - : boolean; - var commands, labels, voices, guff, i: paragraph_index0; - w: string; -begin isControlParagraph:=true; commands:=0; labels:=0; voices:=0; guff:=0; - for i:=1 to para_len do - if not (startsWith(P[i],'%')) then - begin w:=nextWord(P[i],' ',':'); - if not endsWith(w,':') then inc(guff) - else if (length(w)<3) or (findVoice(w)>0) then inc(voices) - else if isCommand(w) then inc(commands) - else inc(labels) - end; - if (voices+guff>commands) then isControlParagraph:=false -end; - -procedure topOfPMXfile; -begin - putLine('---'); - putLine('\def\mtxversion{'+version+'}'); - putline('\def\mtxdate{'+version_date+'}'); - putline('\input mtx'); -end; - -begin { ---- Main program ------------------------ } - this_version := version; this_version_date := version_date; - writeln ('==> This is M-Tx ' + version + ' (Music from TeXt) ' + - version_date ); - mtxLevel(version); OpenFiles; no_commands_yet:=true; preambleDefaults; - no_report_errors:=false; - topOfPMXfile; - repeat readParagraph(P,orig_line_no,para_len); - control_paragraph:=isControlParagraph(P,para_len); - if control_paragraph then - begin augmentPreamble(no_report_errors); - no_report_errors:=true; - if para_len=0 then error('No music paragraphs!',not print) - end - until not control_paragraph; - doPreamble; doMusic; - if not pmx_preamble_done then error('No music paragraphs!',not print); - putline('% Coded by M-Tx'); - CloseFiles; - writeln ('PrePMX done. Now run PMX.'); halt(0); -end. - diff --git a/Build/source/utils/m-tx/mtx-0.60d/status.c b/Build/source/utils/m-tx/mtx-0.60d/status.c deleted file mode 100644 index aef14b88a7b..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/status.c +++ /dev/null @@ -1,649 +0,0 @@ -/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ -/* From input file "status.pas" */ - - -#include "p2c.h" - - -#define STATUS_G -#include "status.h" - - -#ifndef GLOBALS_H -#include "globals.h" -#endif - -#ifndef STRINGS_H -#include "strings.h" -#endif - -#ifndef MTXLINE_H -#include "mtxline.h" -#endif - -#ifndef CONTROL_H -#include "control.h" -#endif - -#ifndef UTILITY_H -#include "utility.h" -#endif - -#ifndef NOTES_H -#include "notes.h" -#endif - - -#define lowest_pitch (-9) -#define highest_pitch 61 - - -typedef struct line_status { - short pitch, chord_pitch, octave_adjust, beam_level, slur_level, after_slur; - Char octave, lastnote, chord_lastnote, duration, slurID, tieID; - boolean beamnext, beamed, slurnext, slurred, no_beam_melisma; - boolean no_slur_melisma[12]; - int5 chord_tie_pitch; - Char chord_tie_label[6]; -} line_status; - - -Static Char init_oct[256] = ""; -Static line_status current[maxvoices]; -Static Char lastdur[maxvoices]; - - -Void chordTie(voice, lab) -short voice; -Char *lab; -{ - short n; - line_status *WITH; - - WITH = ¤t[voice-1]; - n = strlen(WITH->chord_tie_label); - if (n == 5) - error3(voice, "Only five slur ties allowed per voice"); - if (n == 0) - *lab = 'T'; - else - *lab = WITH->chord_tie_label[n-1]; - (*lab)++; - sprintf(WITH->chord_tie_label + strlen(WITH->chord_tie_label), "%c", *lab); -/* p2c: status.pas, line 66: - * Note: Possible string truncation in assignment [145] */ - n++; - WITH->chord_tie_pitch[n-1] = WITH->chord_pitch; -} - - -Void getChordTies(voice, pitches, labels) -short voice; -short *pitches; -Char *labels; -{ - line_status *WITH; - - WITH = ¤t[voice-1]; - memcpy(pitches, WITH->chord_tie_pitch, sizeof(int5)); - strcpy(labels, WITH->chord_tie_label); - *WITH->chord_tie_label = '\0'; -} - - -Void rememberDurations() -{ - voice_index v, FORLIM; - - FORLIM = nvoices; - for (v = 1; v <= FORLIM; v++) - lastdur[v-1] = duration(v); -} - - -Void restoreDurations() -{ - voice_index v, FORLIM; - - FORLIM = nvoices; - for (v = 1; v <= FORLIM; v++) - resetDuration(v, lastdur[v-1]); -} - - -Char duration(voice) -short voice; -{ - return (current[voice-1].duration); -} - - -Void resetDuration(voice, dur) -short voice; -Char dur; -{ - if (pos1(dur, durations) == 0) { - printf("Trying to set duration to %c; ", dur); - error3(voice, "M-Tx system error: resetDuration"); - } - current[voice-1].duration = dur; -} - - -Void activateBeamsAndSlurs(voice) -short voice; -{ - line_status *WITH; - - WITH = ¤t[voice-1]; - if (WITH->beamnext) { - WITH->beamed = true; - WITH->beamnext = false; - } - if (WITH->slurnext) { - WITH->slurred = true; - WITH->slurnext = false; - } - if (WITH->slurred) - WITH->after_slur++; -} - - -Void saveStatus(voice) -short voice; -{ - line_status *WITH; - - WITH = ¤t[voice-1]; - WITH->chord_pitch = WITH->pitch; - WITH->chord_lastnote = WITH->lastnote; -} - - -boolean noBeamMelisma(voice) -short voice; -{ - return (current[voice-1].no_beam_melisma); -} - - -short afterSlur(voice) -short voice; -{ - short Result; - line_status *WITH; - - WITH = ¤t[voice-1]; - Result = WITH->after_slur; - if (WITH->after_slur > 0 && WITH->slur_level < 1) - error3(voice, "M-Tx system error: afterSlur and slur_level incompatible)"); - return Result; -} - - -Char octave(voice) -short voice; -{ - return (current[voice-1].octave); -} - - -Void resetOctave(voice) -short voice; -{ - current[voice-1].octave = ' '; -} - - -Void initOctaves(octaves) -Char *octaves; -{ - short i = 1; - - strcpy(init_oct, octaves); - while (i <= strlen(init_oct)) { - if (init_oct[i-1] == ' ') - delete1(init_oct, i); - else - i++; - } -} - - -Static Char initOctave(voice_stave) -stave_index voice_stave; -{ - if (voice_stave > strlen(init_oct)) { - if (pos1(clef[voice_stave-1], "Gt08") > 0) - return '4'; - else - return '3'; - } else - return (init_oct[voice_stave-1]); -} - - -Void setOctave(voice) -short voice; -{ - current[voice-1].octave = initOctave(voiceStave(voice)); -} - - -Void newOctave(voice, dir) -short voice; -Char dir; -{ - line_status *WITH; - - WITH = ¤t[voice-1]; - switch (dir) { - - case '+': - WITH->octave++; - break; - - case '-': - WITH->octave--; - break; - } -} - - -Static short newPitch(voice, note_, pitch, lastnote) -short voice; -Char *note_; -short pitch; -Char lastnote; -{ - Char note[256]; - short interval, npitch; - Char oct; - - strcpy(note, note_); - /*if debugMode then - write('New pitch for note ',note,' relative to ',lastnote, - ' at pitch ',pitch);*/ - oct = octaveCode(note); - if (oct == '=') - oct = initOctave(voiceStave(voice)); - if (isdigit(oct)) { - pitch = (oct - '0') * 7 - 3; - lastnote = 'f'; - removeOctaveCode(oct, note); - oct = octaveCode(note); - } - interval = note[0] - lastnote; - if (interval > 3) - interval -= 7; - if (interval < -3) - interval += 7; - npitch = pitch + interval; /*if debugMode then write(' was ',npitch);*/ - while (oct != ' ') { - if (oct == '+') - npitch += 7; - else if (oct == '-') - npitch -= 7; - removeOctaveCode(oct, note); - oct = octaveCode(note); - } - /*if debugMode then writeln(' is ',npitch);*/ - return npitch; -} - - -Local Void delins(note, c1, c2, l) -Char *note; -Char c1, c2; -short l; -{ - short i, n; - - n = strlen(note); - i = pos1(c1, note); - if (i == 0) - i = n + 1; - while (l > 0 && i <= n) { - delete1(note, i); - n--; - l--; - } - i = pos1(c2, note); - if (i == 0) { - if (strlen(note) < 2) - error("M-Tx program error", print); - else - i = 3; - } - while (l > 0) { - insertChar(c2, note, i); - l--; - } -} - - -Static Void repitch(note, diff) -Char *note; -short diff; -{ - diff /= 7; - if (diff > 0) - delins(note, '-', '+', diff); - else - delins(note, '+', '-', -diff); -} - - -Void setUnbeamed(voice) -short voice; -{ - current[voice-1].beamed = false; -} - - -Void setUnslurred(voice) -short voice; -{ - line_status *WITH; - - WITH = ¤t[voice-1]; - WITH->slurred = false; - WITH->after_slur = 0; -} - - -Void beginBeam(voice, note) -short voice; -Char *note; -{ - line_status *WITH; - - WITH = ¤t[voice-1]; - if (WITH->beamed) - error3(voice, "Starting a forced beam while another is open"); - if (WITH->beam_level > 0) - error3(voice, - "Starting a forced beam while another is open (beamlevel>0)"); - WITH->beam_level++; - WITH->beamnext = true; - WITH->no_beam_melisma = startsWith(note, "[["); - if (WITH->no_beam_melisma) - predelete(note, 1); -} - - -Void endBeam(voice) -short voice; -{ - line_status *WITH; - - WITH = ¤t[voice-1]; - if (WITH->beam_level < 1) - error3(voice, "Closing a beam that was never opened"); - WITH->beam_level--; - setUnbeamed(voice); -} - - -short slurLevel(voice) -short voice; -{ - return (current[voice-1].slur_level); -} - - -short beamLevel(voice) -short voice; -{ - return (current[voice-1].beam_level); -} - - -boolean noSlurMelisma(voice, history) -short voice, history; -{ - line_status *WITH; - - WITH = ¤t[voice-1]; - return (WITH->no_slur_melisma[WITH->slur_level + history - 1]); -} - - -Static Char *slurLabel(Result, voice, note) -Char *Result; -short voice; -Char *note; -{ - Char sl; - - if (*note == '\0') - return strcpy(Result, ""); - if (strlen(note) < 2) - return strcpy(Result, " "); - if (note[1] >= '0' && note[1] <= 'Z') - sl = note[1]; - else - sl = ' '; - if (sl >= 'I' && sl <= 'T') - warning3(voice, "Slur label in the range I..T may cause conflict"); - sprintf(Result, "%c", sl); - return Result; -} - - -Static Void labelSlur(voice, note) -short voice; -Char *note; -{ - Char sl; - line_status *WITH; - - if (*note == '\0') - return; - WITH = ¤t[voice-1]; - if (note[0] == ')') - WITH->slurID += 2; - else if (note[0] == '}') - WITH->tieID += 2; - /** CMO 0.60a: replace assigning tieID to sl by space charater - if (note[1]='(') or (note[1]=')') then sl:=slurID else sl:=tieID; */ - if (note[0] == '(' || note[0] == ')') - sl = WITH->slurID; - else - sl = ' '; - /** CMO 0.60d: omit insertchar in case of tie - insertchar(sl,note,2); */ - if (note[0] == '(' || note[0] == ')') - insertChar(sl, note, 2); - if (note[0] == '(') - WITH->slurID -= 2; - else if (note[0] == '{') - WITH->tieID -= 2; - if (WITH->slurID < 'I') - warning3(voice, "Too many nested slurs may cause conflict"); - if (WITH->tieID < 'I') - warning3(voice, "Too many nested ties may cause conflict"); -} - - -Void beginSlur(voice, note) -short voice; -Char *note; -{ - short posblind; - line_status *WITH; - Char STR1[256], STR2[256]; - - WITH = ¤t[voice-1]; - WITH->slur_level++; - if (WITH->slur_level > 12) - error3(voice, "Too many open slurs"); - WITH->no_slur_melisma[WITH->slur_level - 1] = (startsWith(note, "((") || - startsWith(note, "{{")); - if (WITH->no_slur_melisma[WITH->slur_level - 1]) - predelete(note, 1); - if (!strcmp(slurLabel(STR1, voice, note), "0")) - delete1(note, 2); - else { - if (!strcmp(slurLabel(STR2, voice, note), " ")) - labelSlur(voice, note); - } - posblind = pos1('~', note); - if (posblind > 0) { - if (hideBlindSlurs()) - *note = '\0'; - else - delete1(note, posblind); - } - WITH->slurnext = true; -} - - -Void endSlur(voice, note) -short voice; -Char *note; -{ - short poscontinue, posblind; - Char contslur[256]; - line_status *WITH; - Char STR1[256], STR2[256]; - - WITH = ¤t[voice-1]; - *contslur = '\0'; - if (WITH->slur_level < 1) - error3(voice, "Ending a slur that was never started"); - if (note[0] == ')') - poscontinue = pos1('(', note); - else if (note[0] == '}') - poscontinue = pos1('{', note); - if (poscontinue == 0) - WITH->slur_level--; - else { - poscontinue--; - strcpy(contslur, note); - predelete(contslur, poscontinue); - shorten(note, poscontinue); - } - if (WITH->slur_level == 0) - setUnslurred(voice); - if (!strcmp(slurLabel(STR1, voice, note), "0")) - delete1(note, 2); - else { - if (!strcmp(slurLabel(STR2, voice, note), " ")) - labelSlur(voice, note); - } - if (!strcmp(slurLabel(STR1, voice, contslur), "0")) - delete1(contslur, 2); - else { - if (!strcmp(slurLabel(STR2, voice, contslur), " ")) - labelSlur(voice, contslur); - } - if (poscontinue > 0) { - if (note[0] == '}') - strcat(note, "t"); - note[0] = 's'; - if (contslur[0] == '{') - strcat(contslur, "t"); - contslur[0] = 's'; - } - posblind = pos1('~', note); - if (posblind > 0) { - if (hideBlindSlurs()) - *note = '\0'; - else - delete1(note, posblind); - } - if (*note != '\0' && *contslur != '\0') - sprintf(note + strlen(note), " %s", contslur); -} - - -Void renewPitch(voice, note) -short voice; -Char *note; -{ - short pstat; - line_status *WITH; - - WITH = ¤t[voice-1]; - pstat = newPitch(voice, note, WITH->chord_pitch, WITH->chord_lastnote); - if (debugMode()) - printf("Current pitch in voice %d is %d, last note was %c, this note is %s", - voice, WITH->pitch, WITH->lastnote, note); - WITH->pitch = newPitch(voice, note, WITH->pitch, WITH->lastnote); - if (WITH->pitch != pstat) - repitch(note, WITH->pitch - pstat); - if (WITH->pitch < lowest_pitch && checkPitch()) { - printf("Pitch of note %s following %c reported as %d", - note, WITH->lastnote, WITH->pitch); - error3(voice, "Pitch too low"); - } - if (WITH->pitch > highest_pitch && checkPitch()) { - printf("Pitch of note %s following %c reported as %d", - note, WITH->lastnote, WITH->pitch); - error3(voice, "Pitch too high"); - } - WITH->lastnote = note[0]; - if (debugMode()) - printf(", repitched to %d\n", WITH->pitch); - if (debugMode() && WITH->pitch != pstat) - printf("Pitch from melodic line = %d from last chordal note = %d\n", - WITH->pitch, pstat); -} - - -short chordPitch(voice) -short voice; -{ - return (current[voice-1].chord_pitch); -} - - -Void renewChordPitch(voice, note) -short voice; -Char *note; -{ - line_status *WITH; - - WITH = ¤t[voice-1]; - WITH->chord_pitch = newPitch(voice, note, WITH->chord_pitch, - WITH->chord_lastnote); - if (WITH->chord_pitch < lowest_pitch) - error3(voice, "Pitch in chord too low"); - if (WITH->chord_pitch > highest_pitch) - error3(voice, "Pitch in chord too high"); - WITH->chord_lastnote = note[0]; -} - - -Void initStatus() -{ - short voice, FORLIM; - line_status *WITH; - - FORLIM = nvoices; - for (voice = 1; voice <= FORLIM; voice++) { - WITH = ¤t[voice-1]; - WITH->duration = default_duration; - WITH->octave_adjust = 0; - WITH->slur_level = 0; - WITH->beam_level = 0; - WITH->beamed = false; - WITH->beamnext = false; - WITH->slurred = false; - WITH->slurnext = false; - WITH->after_slur = 0; - WITH->octave = initOctave(voiceStave(voice)); - WITH->slurID = 'S'; - WITH->tieID = 'T'; - WITH->lastnote = 'f'; - WITH->pitch = (WITH->octave - '0') * 7 - 3; - *WITH->chord_tie_label = '\0'; - saveStatus(voice); - } -} - - - - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/status.h b/Build/source/utils/m-tx/mtx-0.60d/status.h deleted file mode 100644 index 1a81d124398..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/status.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Header for module status, generated by p2c 1.21alpha-07.Dec.93 */ -#ifndef STATUS_H -#define STATUS_H - - -#ifdef STATUS_G -# define vextern -#else -# define vextern extern -#endif -/* Keep track of duration, octave, slur and beam status. */ - - -extern Void initStatus PV(); -extern Void saveStatus PP((int voice)); - -extern Void resetDuration PP((int voice, int dur)); -extern Char duration PP((int voice)); - -extern short slurLevel PP((int voice)); -extern short beamLevel PP((int voice)); -extern boolean noBeamMelisma PP((int voice)); -extern boolean noSlurMelisma PP((int voice, int history)); -extern short afterSlur PP((int voice)); -extern Void setUnbeamed PP((int voice)); -extern Void setUnslurred PP((int voice)); -extern Void beginBeam PP((int voice, Char *note)); -extern Void endBeam PP((int voice)); -extern Void beginSlur PP((int voice, Char *note)); -extern Void endSlur PP((int voice, Char *note)); -extern Void activateBeamsAndSlurs PP((int voice)); - -extern Void setOctave PP((int voice)); -extern Void resetOctave PP((int voice)); -extern Char octave PP((int voice)); -extern Void newOctave PP((int voice, int dir)); -extern Void initOctaves PP((Char *octaves)); - -extern Void renewPitch PP((int voice, Char *note)); -extern short chordPitch PP((int voice)); -extern Void renewChordPitch PP((int voice, Char *note)); -extern Void rememberDurations PV(); -extern Void restoreDurations PV(); -extern Void chordTie PP((int voice, Char *lab)); - - -typedef short int5[5]; - - -extern Void getChordTies PP((int voice, short *pitches, Char *labels)); - - -#undef vextern - -#endif /*STATUS_H*/ - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/status.pas b/Build/source/utils/m-tx/mtx-0.60d/status.pas deleted file mode 100644 index 9056dbe1917..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/status.pas +++ /dev/null @@ -1,348 +0,0 @@ -unit status; -{ Keep track of duration, octave, slur and beam status. } - -interface - -procedure initStatus; -procedure saveStatus(voice: integer); - -procedure resetDuration (voice: integer; dur: char); -function duration(voice: integer): char; - -function slurLevel(voice: integer): integer; -function beamLevel(voice: integer): integer; -function noBeamMelisma(voice: integer): boolean; -function noSlurMelisma(voice, history: integer): boolean; -function afterSlur(voice: integer): integer; -procedure setUnbeamed(voice: integer); -procedure setUnslurred(voice: integer); -procedure beginBeam(voice: integer; var note: string); -procedure endBeam(voice: integer); -procedure beginSlur(voice: integer; var note: string); -procedure endSlur(voice: integer; var note: string); -procedure activateBeamsAndSlurs(voice: integer); - -procedure setOctave(voice: integer); -procedure resetOctave(voice: integer); -function octave(voice: integer): char; -procedure newOctave(voice: integer; dir: char); -procedure initOctaves(octaves: string); - -procedure renewPitch (voice: integer; var note: string); -function chordPitch(voice: integer): integer; -procedure renewChordPitch (voice: integer; note: string); -procedure rememberDurations; -procedure restoreDurations; -procedure chordTie(voice: integer; var lab: char); -type int5 = array[1..5] of integer; -procedure getChordTies(voice: integer; var pitches: int5; var labels: string); - -implementation uses globals, strings, mtxline, control, utility, notes; - -const - init_oct: string = ''; - lowest_pitch = -9; - highest_pitch = 61; - -type - line_status = record - pitch, chord_pitch, octave_adjust, beam_level, slur_level, after_slur: integer; - octave, lastnote, chord_lastnote, duration, slurID, tieID: char; - beamnext, beamed, slurnext, slurred, no_beam_melisma: boolean; - no_slur_melisma: array[1..12] of boolean; - chord_tie_pitch: int5; - chord_tie_label: string[5]; - end; - -var current: array[voice_index] of line_status; - lastdur: array[voice_index] of char; - -procedure chordTie(voice: integer; var lab: char); - var n: integer; -begin with current[voice] do - begin n:=length(chord_tie_label); - if n=5 then error3(voice,'Only five slur ties allowed per voice'); - if n=0 then lab:='T' else lab:=chord_tie_label[n]; - inc(lab); chord_tie_label:=chord_tie_label+lab; - inc(n); chord_tie_pitch[n]:=chord_pitch - end -end; - -procedure getChordTies(voice: integer; var pitches: int5; var labels: string); -begin with current[voice] do - begin pitches:=chord_tie_pitch; labels:=chord_tie_label; chord_tie_label:='' end -end; - -procedure rememberDurations; - var v: voice_index; -begin for v:=1 to nvoices do lastdur[v]:=duration(v) end; - -procedure restoreDurations; - var v: voice_index; -begin for v:=1 to nvoices do resetDuration(v,lastdur[v]) end; - -function duration(voice: integer): char; -begin duration := current[voice].duration; end; - -procedure resetDuration(voice: integer; dur: char); -begin if pos1(dur,durations)=0 then - begin write('Trying to set duration to ',dur,'; '); - error3(voice,'M-Tx system error: resetDuration'); - end; - current[voice].duration := dur -end; - - -procedure activateBeamsAndSlurs(voice: integer); -begin with current[voice] do - begin - if beamnext then begin beamed:=true; beamnext:=false; end; - if slurnext then begin slurred:=true; slurnext:=false; end; - if slurred then inc(after_slur); - end -end; - -procedure saveStatus(voice: integer); -begin with current[voice] do - begin chord_pitch := pitch; chord_lastnote := lastnote; end; -end; - -function noBeamMelisma(voice: integer): boolean; -begin noBeamMelisma := current[voice].no_beam_melisma; end; - -function afterSlur(voice: integer): integer; -begin with current[voice] do - begin afterSlur := after_slur; if (after_slur>0) and (slur_level<1) then - error3(voice,'M-Tx system error: afterSlur and slur_level incompatible)') - end -end; - -function octave(voice: integer): char; -begin octave := current[voice].octave; end; - -procedure resetOctave(voice: integer); -begin current[voice].octave := ' '; end; - -procedure initOctaves(octaves: string); - var i: integer; -begin init_oct:=octaves; - i:=1; - while i<=length(init_oct) do - if init_oct[i]=' ' then delete1(init_oct,i) else inc(i); -end; - -function initOctave(voice_stave: stave_index): char; -begin - if voice_stave>length(init_oct) then - if pos1(clef[voice_stave],'Gt08')>0 - then initOctave:='4' else initOctave:='3' - else initOctave:=init_oct[voice_stave]; -end; - -procedure setOctave(voice: integer); -begin current[voice].octave:=initOctave(voiceStave(voice)); end; - -procedure newOctave(voice: integer; dir: char); -begin with current[voice] do case dir of - '+': inc(octave); - '-': dec(octave); - end; -end; - -function newPitch (voice: integer; note: string; pitch: integer; - lastnote: char): integer; - var interval, npitch: integer; - oct: char; -begin {if debugMode then - write('New pitch for note ',note,' relative to ',lastnote, - ' at pitch ',pitch);} - oct:=octaveCode(note); - if oct='=' then oct:=initOctave(voiceStave(voice)); - if (oct>='0') and (oct<='9') then - begin pitch:=7*(ord(oct)-ord('0'))-3; lastnote:='f'; - removeOctaveCode(oct,note); oct:=octaveCode(note) - end; - interval := ord(note[1])-ord(lastnote); - if interval>3 then dec(interval,7); - if interval<-3 then inc(interval,7); - npitch:=pitch+interval; {if debugMode then write(' was ',npitch);} - while oct<>' ' do - begin if oct='+' then inc(npitch,7) else if oct='-' then dec(npitch,7); - removeOctaveCode(oct,note); oct:=octaveCode(note) - end; - {if debugMode then writeln(' is ',npitch);} - newPitch:=npitch -end; - -procedure repitch(var note: string; diff: integer); - procedure delins(var note: string; c1, c2: char; l: integer); - var i, n: integer; - begin n:=length(note); i:=pos1(c1,note); if i=0 then i:=n+1; - while (l>0) and (i<=n) do begin delete1(note,i); dec(n); dec(l); end; - i:=pos1(c2,note); - if i=0 then if length(note)<2 then error('M-Tx program error',print) - else i:=3; - while l>0 do begin insertchar(c2,note,i); dec(l); end; - end; - begin diff:=diff div 7; - if diff>0 then delins(note, '-','+',diff) - else delins(note, '+','-',-diff); - end; - -procedure setUnbeamed(voice: integer); -begin current[voice].beamed:=false end; - -procedure setUnslurred(voice: integer); -begin with current[voice] do - begin slurred:=false; after_slur:=0; end; -end; - -procedure beginBeam(voice: integer; var note: string); -begin with current[voice] do - begin if beamed then - error3(voice, 'Starting a forced beam while another is open'); - if beam_level>0 then error3(voice, - 'Starting a forced beam while another is open (beamlevel>0)'); - inc(beam_level); - beamnext := true; no_beam_melisma:=startsWith(note,'[['); - if no_beam_melisma then predelete(note,1); - end; -end; - -procedure endBeam(voice: integer); -begin with current[voice] do - begin if beam_level<1 then error3(voice, 'Closing a beam that was never opened'); - dec(beam_level) - end; - setUnbeamed(voice) -end; - -function slurLevel(voice: integer): integer; -begin slurLevel := current[voice].slur_level; end; - -function beamLevel(voice: integer): integer; -begin beamLevel := current[voice].beam_level; end; - -function noSlurMelisma(voice, history: integer): boolean; -begin with current[voice] do - noSlurMelisma := no_slur_melisma[slur_level+history]; -end; - -function slurLabel(voice: integer; note: string): string; - var sl: char; -begin if note='' then begin slurLabel:=''; exit end; - if length(note)<2 then begin slurLabel:=' '; exit end; - if (note[2]>='0') and (note[2]<='Z') then sl:=note[2] else sl:=' '; - if (sl>='I') and (sl<='T') then - warning3(voice,'Slur label in the range I..T may cause conflict'); - slurLabel:=sl -end; - -procedure labelSlur(voice: integer; var note: string); - var sl: char; -begin if note='' then exit; - with current[voice] do - begin - if note[1]=')' then inc(slurID,2) else if note[1]='}' then inc(tieID,2); - if (note[1]='(') or (note[1]=')') then sl:=slurID else sl:=tieID; - insertchar(sl,note,2); - if note[1]='(' then dec(slurID,2) else if note[1]='{' then dec(tieID,2); - if slurID<'I' then warning3(voice,'Too many nested slurs may cause conflict'); - if tieID<'I' then warning3(voice,'Too many nested ties may cause conflict') - end -end; - -procedure beginSlur(voice: integer; var note: string); - var posblind: integer; -begin - with current[voice] do - begin - inc(slur_level); if slur_level>12 then Error3(voice,'Too many open slurs'); - no_slur_melisma[slur_level] := startsWith(note,'((') or startsWith(note,'{{'); - if no_slur_melisma[slur_level] then predelete(note,1); - if slurLabel(voice,note)='0' then delete1(note,2) else - if slurLabel(voice,note)=' ' then labelSlur(voice,note); - posblind:=pos1('~',note); if posblind>0 then - if hideBlindSlurs then note:='' else delete1(note,posblind); - slurnext := true; - end; -end; - -procedure endSlur(voice: integer; var note: string); - var poscontinue, posblind: integer; - contslur: string; -begin with current[voice] do - begin contslur:=''; - if slur_level<1 then Error3(voice,'Ending a slur that was never started'); - if note[1]=')' then poscontinue:=pos1('(',note) - else if note[1]='}' then poscontinue:=pos1('{',note); - if poscontinue=0 then dec(slur_level) else - begin dec(poscontinue); contslur:=note; predelete(contslur,poscontinue); - shorten(note,poscontinue); - end; - if slur_level=0 then setUnslurred(voice); - if slurLabel(voice,note)='0' then delete1(note,2) else - if slurLabel(voice,note)=' ' then labelSlur(voice,note); - if slurLabel(voice,contslur)='0' then delete1(contslur,2) else - if slurLabel(voice,contslur)=' ' then labelSlur(voice,contslur); - if poscontinue>0 then - begin if note[1]='}' then note:=note+'t'; note[1]:='s'; - if contslur[1]='{' then contslur:=contslur+'t'; contslur[1]:='s'; - end; - posblind:=pos1('~',note); if posblind>0 then - if hideBlindSlurs then note:='' else delete1(note,posblind); - if (note<>'') and (contslur<>'') then note := note + ' ' + contslur; - end; -end; - -procedure renewPitch (voice: integer; var note: string); - var pstat: integer; -begin with current[voice] do - begin pstat:=newPitch (voice, note, chord_pitch, chord_lastnote); - if debugMode then write('Current pitch in voice ',voice,' is ',pitch, - ', last note was ',lastnote,', this note is ',note); - pitch := newPitch (voice, note, pitch, lastnote); - if pitch<>pstat then repitch(note,pitch-pstat); - if (pitchhighest_pitch) and checkPitch then - begin write('Pitch of note ',note,' following ',lastnote,' reported as ',pitch); - error3(voice,'Pitch too high') - end; - lastnote:=note[1]; - if debugMode then writeln(', repitched to ',pitch); - if debugMode and (pitch<>pstat) then - writeln('Pitch from melodic line = ',pitch, - ' from last chordal note = ', pstat); - end; -end; - -function chordPitch(voice: integer): integer; -begin chordPitch:=current[voice].chord_pitch end; - -procedure renewChordPitch (voice: integer; note: string); -begin with current[voice] do - begin chord_pitch:=newPitch(voice,note,chord_pitch,chord_lastnote); - if chord_pitchhighest_pitch then error3(voice,'Pitch in chord too high'); - chord_lastnote:=note[1]; - end -end; - -procedure initStatus; - var voice: integer; -begin for voice:=1 to nvoices do with current[voice] do - begin duration:=default_duration; - octave_adjust:=0; slur_level:=0; beam_level:=0; - beamed:=false; beamnext:=false; - slurred:=false; slurnext:=false; after_slur:=0; - octave:=initOctave(voiceStave(voice)); slurID:='S'; tieID:='T'; - lastnote:='f'; pitch:=7*(ord(octave)-ord('0'))-3; - chord_tie_label:=''; - saveStatus(voice); - end; -end; - -end. diff --git a/Build/source/utils/m-tx/mtx-0.60d/strings.h b/Build/source/utils/m-tx/mtx-0.60d/strings.h deleted file mode 100644 index 6e0bcdfae8e..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/strings.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Header for module strings, generated by p2c 1.21alpha-07.Dec.93 */ -#ifndef STRINGS_H -#define STRINGS_H - - -#ifdef STRINGS_G -# define vextern -#else -# define vextern extern -#endif -/* String handling primitives. */ -/* These should be recoded in C instead of using the p2c code. */ - - -extern Void scan1 PP((Char *s, int p, short *n)); -/* Read an integer at position p of s */ -extern boolean startsWith PP((Char *s1, Char *s2)); -extern short pos1 PP((int c, Char *s)); -extern short posNot PP((int c, Char *s)); -extern Void insertChar PP((int c, Char *s, int p)); -extern Char *substr_ PP((Char *Result, Char *s, int start, int count)); -extern Void getNum PP((Char *line, short *k)); -extern Void getTwoNums PP((Char *line, short *k1, short *k2)); -extern Void toUpper PP((Char *s)); -extern Void delete1 PP((Char *s, int p)); -extern Void predelete PP((Char *s, int l)); -extern Void shorten PP((Char *s, int new_length)); - - -#undef vextern - -#endif /*STRINGS_H*/ - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/uptext.c b/Build/source/utils/m-tx/mtx-0.60d/uptext.c deleted file mode 100644 index eb5b2772e02..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/uptext.c +++ /dev/null @@ -1,277 +0,0 @@ -/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ -/* From input file "uptext.pas" */ - - -#include "p2c.h" - - -#define UPTEXT_G -#include "uptext.h" - - -#ifndef GLOBALS_H -#include "globals.h" -#endif - -#ifndef STRINGS_H -#include "strings.h" -#endif - -#ifndef MTXLINE_H -#include "mtxline.h" -#endif - -#ifndef UTILITY_H -#include "utility.h" -#endif - - -typedef struct uptext_info { - short uptext, uptext_adjust, uptext_lcz; - Char uptext_font[256]; -} uptext_info; - - -Static uptext_info U[maxvoices]; - - -short uptextLineNo(voice) -short voice; -{ - return (U[voice-1].uptext); -} - - -Void setUptextLineNo(voice, lno) -short voice, lno; -{ - U[voice-1].uptext = lno; -} - - -Void clearUptext() -{ - voice_index voice, FORLIM; - - FORLIM = nvoices; - for (voice = 0; voice <= FORLIM - 1; voice++) - U[voice].uptext = 0; -} - - -Void initUptext() -{ - voice_index voice, FORLIM; - uptext_info *WITH; - - FORLIM = nvoices; - for (voice = 0; voice <= FORLIM - 1; voice++) { - WITH = &U[voice]; - WITH->uptext_adjust = 0; - WITH->uptext_lcz = 3; - *WITH->uptext_font = '\0'; - } -} - - -Static Void textTranslate(uptext, font) -Char *uptext, *font; -{ - short k; - Char STR1[256], STR2[256], STR3[256], STR4[256]; - short FORLIM; - - if (*uptext == '\0') - return; - do { - k = pos1('%', uptext); - if (k > 0) { - sprintf(STR4, "%s{\\mtxFlat}%s", - substr_(STR1, uptext, 1, k - 1), - substr_(STR3, uptext, k + 1, strlen(uptext) - k)); - strcpy(uptext, STR4); - } - } while (k != 0); - do { - k = pos1('#', uptext); - if (k > 0) { - sprintf(STR2, "%s{\\mtxSharp}%s", - substr_(STR1, uptext, 1, k - 1), - substr_(STR4, uptext, k + 1, strlen(uptext) - k)); - strcpy(uptext, STR2); - } - } while (k != 0); - switch (uptext[0]) { - - case '<': - if (!strcmp(uptext, "<")) - strcpy(uptext, "\\mtxIcresc"); - else if (!strcmp(uptext, "<.")) - strcpy(uptext, "\\mtxTcresc"); - else { - predelete(uptext, 1); - sprintf(uptext, "\\mtxCresc{%s}", strcpy(STR4, uptext)); - } - break; - - case '>': - if (!strcmp(uptext, ">")) - strcpy(uptext, "\\mtxIdecresc"); - else if (!strcmp(uptext, ">.")) - strcpy(uptext, "\\mtxTdecresc"); - else { - predelete(uptext, 1); - sprintf(uptext, "\\mtxDecresc{%s}", strcpy(STR1, uptext)); - } - break; - - default: - FORLIM = strlen(uptext); - for (k = 0; k <= FORLIM - 1; k++) { - if (pos1(uptext[k], "mpfzrs~") == 0) - return; - } - break; - } - strcpy(font, "\\mtxPF"); -} - - -#define default_ 10 -#define under (-14) - - -/* Local variables for addUptext: */ -struct LOC_addUptext { - short voice; - Char w[256]; - short adj; -} ; - -Local Void adjustUptext(LINK) -struct LOC_addUptext *LINK; -{ - Char letter; - boolean force = false; - uptext_info *WITH1; - - delete1(LINK->w, 1); - while (*LINK->w != '\0') { -/* p2c: uptext.pas: Note: Eliminated unused assignment statement [338] */ - letter = LINK->w[0]; - delete1(LINK->w, 1); - WITH1 = &U[LINK->voice-1]; - switch (letter) { - - case '<': - if (WITH1->uptext_lcz > 1) - WITH1->uptext_lcz--; - break; - - case '>': - if (WITH1->uptext_lcz < 3) - WITH1->uptext_lcz++; - break; - - case '^': - WITH1->uptext_adjust = 0; - break; - - case 'v': - WITH1->uptext_adjust = under; - break; - - case '=': - force = true; - break; - - case '+': - case '-': - if (*LINK->w != '\0') - getNum(LINK->w, &LINK->adj); - else - LINK->adj = 0; - if (letter == '-') - LINK->adj = -LINK->adj; - if (force) - WITH1->uptext_adjust = LINK->adj; - else - WITH1->uptext_adjust += LINK->adj; - *LINK->w = '\0'; - break; - - default: - error3(LINK->voice, "Unknown uptext adjustment"); - break; - } - } - strcpy(LINK->w, "!"); -} - - -Void addUptext(voice_, no_uptext, pretex) -short voice_; -boolean *no_uptext; -Char *pretex; -{ - struct LOC_addUptext V; - Char font[256]; - static Char lcz[4] = "lcz"; - uptext_info *WITH; - Char STR1[256], STR2[256], STR3[256]; - - V.voice = voice_; - WITH = &U[V.voice-1]; - if (WITH->uptext == 0) - *no_uptext = true; - if (*no_uptext) - return; - do { - GetNextWord(V.w, P[WITH->uptext - 1], blank, dummy); - sprintf(STR1, "%c", barsym); - if (!strcmp(V.w, STR1) || *V.w == '\0') - *no_uptext = true; - sprintf(STR1, "%c", tilde); - if (!strcmp(V.w, STR1) || *no_uptext) - return; - if (V.w[0] == '!') { - strcpy(WITH->uptext_font, V.w); - WITH->uptext_font[0] = '\\'; - } - if (V.w[0] == '@') - adjustUptext(&V); - } while (V.w[0] == '!'); /* ! is a kludge, will get me in trouble later */ - strcpy(font, WITH->uptext_font); - textTranslate(V.w, font); - if (*font != '\0') - sprintf(V.w, "%s{%s}", font, strcpy(STR1, V.w)); - switch (lcz[WITH->uptext_lcz - 1]) { - - case 'l': - sprintf(V.w, "\\mtxLchar{%s}{%s}", - toString(STR1, default_ + WITH->uptext_adjust), - strcpy(STR3, V.w)); - break; - - case 'c': - sprintf(V.w, "\\mtxCchar{%s}{%s}", - toString(STR1, default_ + WITH->uptext_adjust), - strcpy(STR2, V.w)); - break; - - case 'z': - sprintf(V.w, "\\mtxZchar{%s}{%s}", - toString(STR1, default_ + WITH->uptext_adjust), - strcpy(STR3, V.w)); - break; - } - strcat(pretex, V.w); -} - -#undef default_ -#undef under - - - - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/uptext.h b/Build/source/utils/m-tx/mtx-0.60d/uptext.h deleted file mode 100644 index 8a9a1643dea..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/uptext.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Header for module uptext, generated by p2c 1.21alpha-07.Dec.93 */ -#ifndef UPTEXT_H -#define UPTEXT_H - - -#ifdef UPTEXT_G -# define vextern -#else -# define vextern extern -#endif -/* Insert and translate uptext */ - - -extern Void initUptext PV(); -extern Void clearUptext PV(); -extern short uptextLineNo PP((int voice)); -extern Void setUptextLineNo PP((int voice, int lno)); -extern Void addUptext PP((int voice, boolean *no_uptext, Char *pretex)); - - -#undef vextern - -#endif /*UPTEXT_H*/ - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/uptext.pas b/Build/source/utils/m-tx/mtx-0.60d/uptext.pas deleted file mode 100644 index 16bebc7556f..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/uptext.pas +++ /dev/null @@ -1,119 +0,0 @@ -unit uptext; -{ Insert and translate uptext } - -interface - -procedure initUptext; -procedure clearUptext; -function uptextLineNo(voice: integer): integer; -procedure setUptextLineNo(voice, lno: integer); -procedure addUptext(voice: integer; var no_uptext: boolean; - var pretex: string); - -implementation uses globals, strings, mtxline, utility; - -type uptext_info = record - uptext, uptext_adjust, uptext_lcz: integer; - uptext_font: string; - end; - -var U: array[voice_index] of uptext_info; - -function uptextLineNo(voice: integer): integer; -begin uptextLineNo := U[voice].uptext; end; - -procedure setUptextLineNo(voice, lno: integer); -begin U[voice].uptext := lno; end; - -procedure clearUptext; - var voice: voice_index; -begin for voice:=1 to nvoices do U[voice].uptext:=0; end; - -procedure initUptext; - var voice: voice_index; -begin for voice:=1 to nvoices do with U[voice] do - begin - uptext_adjust:=0; uptext_lcz:=3; uptext_font:=''; - end; -end; - -procedure textTranslate(var uptext, font: string); - var k: integer; -begin - if uptext='' then exit; - repeat k := pos1('%',uptext); - if k>0 then uptext:= - substr(uptext,1,k-1)+'{\mtxFlat}'+substr(uptext,k+1,length(uptext)-k); - until k=0; - repeat k := pos1('#',uptext); - if k>0 then uptext:= - substr(uptext,1,k-1)+'{\mtxSharp}'+substr(uptext,k+1,length(uptext)-k); - until k=0; - case uptext[1] of - '<': if uptext='<' then uptext:='\mtxIcresc' - else if uptext='<.' then uptext:='\mtxTcresc' - else begin - predelete(uptext,1); uptext:='\mtxCresc{'+uptext+'}' - end; - '>': if uptext='>' then uptext:='\mtxIdecresc' - else if uptext='>.' then uptext:='\mtxTdecresc' - else begin - predelete(uptext,1); uptext:='\mtxDecresc{'+uptext+'}' - end; - else for k:=1 to length(uptext) do if pos1(uptext[k],'mpfzrs~')=0 then exit; - end; - font:='\mtxPF'; -end; - -procedure addUptext(voice: integer; var no_uptext: boolean; - var pretex: string); - var w, font: string; - adj: integer; - const default = 10; under = -14; - lcz: string[3] = 'lcz'; - procedure adjustUptext; - var letter: char; - force: boolean; - begin delete1(w,1); force:=false; - while w<>'' do with U[voice] do - begin letter:=w[1]; delete1(w,1); with U[voice] do - case letter of - '<': if uptext_lcz>1 then dec(uptext_lcz); - '>': if uptext_lcz<3 then inc(uptext_lcz); - '^': uptext_adjust:=0; - 'v': uptext_adjust:=under; - '=': force:=true; -'+','-': begin if w<>'' then getNum(w,adj) else adj:=0; - if letter = '-' then adj := -adj; - if force then uptext_adjust := adj else inc(uptext_adjust,adj); - w:=''; - end; - else error3(voice,'Unknown uptext adjustment'); - end; - end; - w:='!'; - end; - - begin - with U[voice] do begin - if uptext=0 then no_uptext := true; - if no_uptext then exit; - repeat - w := GetNextWord(P[uptext],blank,dummy); - if (w=barsym) or (w='') then no_uptext:=true; - if (w=tilde) or no_uptext then exit; - if w[1]='!' then begin uptext_font:=w; uptext_font[1]:='\'; end; - if w[1]='@' then adjustUptext; - until w[1]<>'!'; { ! is a kludge, will get me in trouble later } - font:=uptext_font; textTranslate(w,font); - if font<>'' then w:=font+'{'+w+'}'; - case lcz[uptext_lcz] of -'l': w:='\mtxLchar{' + toString(default+uptext_adjust) + '}{' + w + '}'; -'c': w:='\mtxCchar{' + toString(default+uptext_adjust) + '}{' + w + '}'; -'z': w:='\mtxZchar{' + toString(default+uptext_adjust) + '}{' + w + '}'; - end; - pretex:=pretex+w; - end; - end; - -end. diff --git a/Build/source/utils/m-tx/mtx-0.60d/utility.c b/Build/source/utils/m-tx/mtx-0.60d/utility.c deleted file mode 100644 index 225936909d1..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/utility.c +++ /dev/null @@ -1,393 +0,0 @@ -/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ -/* From input file "utility.pas" */ - - -#include "p2c.h" - - -#define UTILITY_G -#include "utility.h" - - -#ifndef STRINGS_H -#include "strings.h" -#endif - - -#define blank ' ' -#define dummy '\0' - - -short wordCount(s) -Char *s; -{ - short i, n, FORLIM; - - if (*s == '\0') - return 0; - if (s[0] == blank) - n = 0; - else - n = 1; - FORLIM = strlen(s); - for (i = 1; i <= FORLIM - 1; i++) { - if (s[i-1] == blank && s[i] != blank) - n++; - } - return n; -} - - -Char *GetNextWord(Result, s, Delim, Term) -Char *Result; -Char *s; -Char Delim, Term; -{ - /* A delimiter is a character that separates words, but forms no part - of them. A terminator is a character that appears at the end of - a word. */ - short n = 1; - short start, last; - - last = strlen(s); - while (n <= last && s[n-1] == Delim) - n++; - start = n; - while (n <= last && s[n-1] != Term && s[n-1] != Delim) - n++; - if (n <= last && s[n-1] == Term) - n++; - substr_(Result, s, start, n - start); - while (n <= last && s[n-1] == Delim) - n++; - predelete(s, n - 1); - return Result; -} - - -Char *NextWord(Result, s_, Delim, Term) -Char *Result; -Char *s_; -Char Delim, Term; -{ - Char s[256]; - - strcpy(s, s_); - return (GetNextWord(Result, s, Delim, Term)); -} - - -Char *plural(Result, n) -Char *Result; -short n; -{ - if (n == 1) - return strcpy(Result, ""); - else - return strcpy(Result, "s"); -} - - -short curtail(s, c) -Char *s; -Char c; -{ - short Result = 0; - short l; - - l = strlen(s); - if (s[l-1] == c) { - shorten(s, l - 1); - return l; - } - return Result; -} - - -Char *toString(Result, n) -Char *Result; -short n; -{ - Char s[256]; - - sprintf(s, "%d", n); - return strcpy(Result, s); -} - - -short digit(c) -Char c; -{ - return (c - '0'); -} - - -boolean equalsIgnoreCase(s1_, s2_) -Char *s1_, *s2_; -{ - Char s1[256], s2[256]; - - strcpy(s1, s1_); - strcpy(s2, s2_); - toUpper(s1); - toUpper(s2); - return (strcmp(s1, s2) == 0); -} - - -boolean startsWithIgnoreCase(s1_, s2_) -Char *s1_, *s2_; -{ - Char s1[256], s2[256]; - - strcpy(s1, s1_); - strcpy(s2, s2_); - toUpper(s1); - toUpper(s2); - return (startsWith(s1, s2)); -} - - -boolean startsWithBracedWord(P_) -Char *P_; -{ - Char P[256]; - Char w[256]; - - strcpy(P, P_); - GetNextWord(w, P, blank, dummy); - return (w[0] == '{' && w[strlen(w) - 1] == '}'); -} - - -Void trim(s) -Char *s; -{ - short k; - - k = posNot(blank, s); - if (k > 1) - predelete(s, k - 1); - else if (k == 0) - *s = '\0'; -} - - -boolean endsWith(s1_, s2) -Char *s1_, *s2; -{ - Char s1[256]; - short l1, l2; - - strcpy(s1, s1_); - l1 = strlen(s1); - l2 = strlen(s2); - if (l1 < l2) - return false; - predelete(s1, l1 - l2); - return (strcmp(s1, s2) == 0); -} - - -/* Local variables for grep: */ -struct LOC_grep { - Char *source, *pattern; - short p1[10], p2[10]; - short i, p, s, index; - boolean matching; -} ; - -Local Void remember(s1, s2, LINK) -short s1, s2; -struct LOC_grep *LINK; -{ - if (LINK->index > 9) - _Escape(9999); - LINK->p1[LINK->index] = s1; - LINK->p2[LINK->index] = s2; - LINK->s = s2 + 1; - LINK->index++; -} - -Local Void matchnum(LINK) -struct LOC_grep *LINK; -{ - boolean allowsign = false, allowpoint = false, quit = false; - short s0; - - LINK->matching = false; - s0 = LINK->s; - if (LINK->p < strlen(LINK->pattern)) { - if (LINK->pattern[LINK->p] == '#') { - LINK->p++; - allowsign = true; - if (LINK->p < strlen(LINK->pattern)) { - if (LINK->pattern[LINK->p] == '#') { - LINK->p++; - allowpoint = true; - } - } - } - } - if (allowsign && - (LINK->source[LINK->s-1] == '-' || LINK->source[LINK->s-1] == '+')) { - LINK->s++; - if (LINK->s > strlen(LINK->source)) - return; - } - while (!quit && LINK->s <= strlen(LINK->source)) { - if (LINK->source[LINK->s-1] == '.') { - if (!allowpoint) - quit = true; - else { - LINK->s++; - allowpoint = false; - } - } - if (isdigit(LINK->source[LINK->i-1])) { - LINK->s++; - LINK->matching = true; - } else - quit = true; - } - if (LINK->matching) - remember(s0, LINK->s - 1, LINK); -} - -Local Void matchmeta(LINK) -struct LOC_grep *LINK; -{ - if (LINK->p < strlen(LINK->pattern)) - LINK->p++; - if (LINK->source[LINK->s-1] == LINK->pattern[LINK->p-1]) { - LINK->s++; - LINK->p++; - } else - LINK->matching = false; -} - -Local Void subgrep(LINK) -struct LOC_grep *LINK; -{ - LINK->matching = true; - if (LINK->pattern[LINK->p-1] == '*') { - remember(LINK->s, strlen(LINK->source), LINK); - LINK->p++; - return; - } - if (LINK->pattern[LINK->p-1] == '?') { - remember(LINK->s, LINK->s, LINK); - LINK->p++; - return; - } - if (LINK->pattern[LINK->p-1] == '#') { - matchnum(LINK); - return; - } - if (LINK->pattern[LINK->p-1] == '\\') { - matchmeta(LINK); - return; - } - if (LINK->source[LINK->s-1] == LINK->pattern[LINK->p-1]) { - LINK->s++; - LINK->p++; - } else - LINK->matching = false; -} - - -/*--- Match/Replace package --- */ - -/* Search and replace. Stops when pattern no longer matches source. - Pattern wildcards: - ? Any single character - * Any string - # An unsigned integer - ## A signed integer - ### A signed number maybe with a decimal part - Pattern metacharacters: - \x where x is any character, stands for that character - Target wildcards - \0 to \9 Value of corresponding source wildcard - Target metacharacters - \ When not followed by 0..9 or \, stands for itself - \\ Backslash -*/ -Void grep(source_, pattern_, target) -Char *source_, *pattern_, *target; -{ - struct LOC_grep V; - short j, t, reg; - Char product[256]; - boolean trigger = false; - short FORLIM, FORLIM1; - Char STR2[256]; - - V.source = source_; - V.pattern = pattern_; - V.index = 0; - V.s = 1; - V.p = 1; - for (V.i = 0; V.i <= 9; V.i++) { - V.p1[V.i] = 1; - V.p2[V.i] = 0; - } - while (V.matching && V.p <= strlen(V.pattern) && V.s <= strlen(V.source)) - subgrep(&V); - *product = '\0'; - FORLIM = strlen(target); - for (t = 0; t <= FORLIM - 1; t++) { - if (trigger) { - reg = digit(target[t]); - if ((unsigned)reg <= 9) { - FORLIM1 = V.p2[reg]; - for (j = V.p1[reg] - 1; j <= FORLIM1 - 1; j++) - sprintf(product + strlen(product), "%c", V.source[j]); - } else if (target[t] == '\\') - strcat(product, "\\"); - else - sprintf(product + strlen(product), "\\%c", target[t]); - trigger = false; - } else if (target[t] == '\\' && t + 1 < strlen(target)) - trigger = true; - else - sprintf(product + strlen(product), "%c", target[t]); - } - strcpy(V.source, substr_(STR2, V.source, V.s, strlen(V.source))); - strcpy(V.pattern, substr_(STR2, V.pattern, V.p, strlen(V.pattern))); - strcpy(target, product); -} - - -/* "match" tests whether the source matches the pattern exactly */ -boolean match(source_, pattern_) -Char *source_, *pattern_; -{ - Char source[256], pattern[256]; - static Char target[256] = ""; - - strcpy(source, source_); - strcpy(pattern, pattern_); - grep(source, pattern, target); - return (*source == '\0' && *pattern == '\0'); -} - - -/* "translate" replaces the pattern by the target in the source. */ -Char *translate(Result, source_, pattern_, target_) -Char *Result; -Char *source_, *pattern_, *target_; -{ - Char source[256], pattern[256], target[256]; - - strcpy(source, source_); - strcpy(pattern, pattern_); - strcpy(target, target_); - grep(source, pattern, target); - return strcpy(Result, target); -} - - - - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/utility.h b/Build/source/utils/m-tx/mtx-0.60d/utility.h deleted file mode 100644 index eee95a563b7..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/utility.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Header for module utility, generated by p2c 1.21alpha-07.Dec.93 */ -#ifndef UTILITY_H -#define UTILITY_H - - -#ifdef UTILITY_G -# define vextern -#else -# define vextern extern -#endif -/* DPL 2004-03-22 */ - -/* Utilities, mainly aids to parsing */ - - -extern boolean equalsIgnoreCase PP((Char *s1, Char *s2)); -extern boolean startsWithIgnoreCase PP((Char *s1, Char *s2)); -extern boolean endsWith PP((Char *s1, Char *s2)); -extern boolean startsWithBracedWord PP((Char *P)); -extern Char *GetNextWord PP((Char *Result, Char *s, int Delim, int Term)); -extern Char *NextWord PP((Char *Result, Char *s, int Delim, int Term)); -extern short wordCount PP((Char *s)); -extern Char *plural PP((Char *Result, int n)); -extern short curtail PP((Char *s, int c)); -/* Remove last character if it equals c and return its position; - otherwise return 0 */ -extern Char *toString PP((Char *Result, int n)); -extern Void trim PP((Char *s)); -extern short digit PP((int c)); -extern boolean match PP((Char *source, Char *pattern)); -extern Char *translate PP((Char *Result, Char *source, Char *pattern, - Char *target)); -extern Void grep PP((Char *source, Char *pattern, Char *target)); -/* See Implementation for what this currently does. */ - - -#undef vextern - -#endif /*UTILITY_H*/ - -/* End. */ diff --git a/Build/source/utils/m-tx/mtx-0.60d/utility.pas b/Build/source/utils/m-tx/mtx-0.60d/utility.pas deleted file mode 100644 index 42cc76d15d5..00000000000 --- a/Build/source/utils/m-tx/mtx-0.60d/utility.pas +++ /dev/null @@ -1,194 +0,0 @@ -unit utility; { DPL 2004-03-22 } - -{ Utilities, mainly aids to parsing } - -interface - -function equalsIgnoreCase(s1, s2: string): boolean; -function startsWithIgnoreCase(s1, s2: string): boolean; -function endsWith(s1, s2: string): boolean; -function startsWithBracedWord (P: string): boolean; -function GetNextWord (var s: string; Delim, Term: char): string; -function NextWord (s: string; Delim, Term: char): string; -function wordCount (s: string): integer; -function plural (n: integer): string; -function curtail (var s: string; c: char): integer; - { Remove last character if it equals c and return its position; - otherwise return 0 } -function toString(n: integer): string; -procedure trim(var s: string); -function digit(c: char): integer; -function match(source, pattern: string): boolean; -function translate(source, pattern, target: string): string; -procedure grep(var source, pattern, target: string); - { See Implementation for what this currently does. } - -implementation uses strings; - -const blank = ' '; dummy = #0; - -function wordCount (s: string): integer; - var i, n: integer; - begin if length(s)=0 then - begin wordCount:=0; exit; end; - if s[1]=blank then n:=0 else n:=1; - for i:=1 to length(s)-1 do - if (s[i]=blank) and (s[i+1]<>blank) then inc(n); - wordCount:=n; - end; - -function GetNextWord (var s: string; Delim, Term: char): string; -{ A delimiter is a character that separates words, but forms no part - of them. A terminator is a character that appears at the end of - a word. } - var n, start, last: integer; -begin last:=length(s); n:=1; - while (n<=last) and (s[n] = Delim) do inc(n); - start:=n; - while (n<=last) and not (s[n] in [Delim,Term]) do inc(n); - if (n<=last) and (s[n] = Term) then inc(n); - GetNextWord:=substr(s,start,n-start); - while (n<=last) and (s[n] = Delim) do inc(n); - predelete(s,n-1); -end; - -function NextWord (s: string; Delim, Term: char): string; - begin NextWord:=GetNextWord(s,Delim,Term); end; - -function plural (n: integer): string; - begin if n=1 then plural:='' else plural:='s'; end; - -function curtail (var s: string; c: char): integer; - var l: integer; - begin l:=length(s); curtail:=0; - if s[l]=c then begin shorten(s,l-1); curtail:=l; end; - end; - -function toString(n: integer): string; - var s: string; -begin str(n,s); toString:=s; end; - -function digit(c: char): integer; - begin digit:=ord(c)-ord('0'); end; - -function equalsIgnoreCase(s1, s2: string): boolean; -begin toUpper(s1); toUpper(s2); equalsIgnoreCase:=s1=s2; -end; - -function startsWithIgnoreCase(s1, s2: string): boolean; -begin toUpper(s1); toUpper(s2); startsWithIgnoreCase:=startsWith(s1,s2); -end; - -function startsWithBracedWord (P: string): boolean; - var w: string; -begin w := getNextWord(P,blank,dummy); - startsWithBracedWord := (w[1]='{') and (w[length(w)]='}'); -end; - -procedure trim(var s: string); - var k: integer; - begin k:=posnot(blank,s); - if k>1 then predelete(s,k-1) else if k=0 then s:=''; - end; - -function endsWith(s1, s2: string): boolean; - var l1, l2: integer; -begin l1:=length(s1); l2:=length(s2); - if l19 then halt(9999); - p1[index] := s1; p2[index] := s2; s := s2+1; inc(index) - end; - procedure matchnum; - var allowsign, allowpoint, quit: boolean; - s0: integer; - begin allowsign := false; allowpoint := false; matching := false; s0 := s; - if plength(source) then exit end; - quit := false; - while (not quit) and (s<=length(source)) do - begin if source[s]='.' then if not allowpoint then quit := true else - begin inc(s); allowpoint := false end; - if (source[i]>='0') and (source[i]<='9') then - begin inc(s); matching := true end - else quit := true - end; - if matching then remember(s0,s-1) - end; - procedure matchmeta; - begin if p=0) and (reg<=9) then - for j:=p1[reg] to p2[reg] do product := product + source[j] - else if target[t]='\' then product := product + '\' - else product := product + '\' + target[t]; - trigger := false - end - else if (target[t]='\') and (t + + * patch-01-write-bin, patch-02-malloc, patch-03-different-size: + Update for 0.61. + +2013-04-10 Peter Breitenlohner + + * patch-03-different-size: Avoid 'cast to pointer from integer of + different size' when sizeof(int) is less than sizeof(void *). + +2012-10-04 Peter Breitenlohner + + * patch-02-malloc (new): Check value returned by malloc(), i.e., + undo action of sed from Makefile.orig. Do not use libp2c.a. + +2012-05-16 Peter Breitenlohner + + * patch-01-write-bin (new): Use binary mode for output files. + From Akira Kakuto (W32TeX). + +Copyright (C) 2012 Peter Breitenlohner +You may freely use, modify and/or distribute this file. diff --git a/Build/source/utils/m-tx/mtx-src-PATCHES/TL-Changes b/Build/source/utils/m-tx/mtx-src-PATCHES/TL-Changes new file mode 100644 index 00000000000..5c42af1ad01 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src-PATCHES/TL-Changes @@ -0,0 +1,13 @@ +Changes applied to the mtx-0.61 tree as obtained from: + http://www.ctan.org/tex-archive/support/m-tx/ + +Remove: + Makefile.in + aclocal.m4 + configure + depcomp + install-sh + missing + +Move to top directory: + tests/* diff --git a/Build/source/utils/m-tx/mtx-src-PATCHES/patch-01-write-bin b/Build/source/utils/m-tx/mtx-src-PATCHES/patch-01-write-bin new file mode 100644 index 00000000000..150ebbd6caf --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src-PATCHES/patch-01-write-bin @@ -0,0 +1,11 @@ +--- mtx-0.61.orig/globals.c Thu Dec 17 04:15:57 2015 ++++ mtx-0.61/globals.c Thu Dec 17 08:57:13 2015 +@@ -223,7 +223,7 @@ + if (outfile != NULL) + fclose(outfile); + outfile = NULL; +- outfile = fopen(outfile_NAME, "w"); ++ outfile = fopen(outfile_NAME, "wb"); + if (outfile == NULL) + _EscIO2(FileNotFound, outfile_NAME); + fclose(outfile); diff --git a/Build/source/utils/m-tx/mtx-src-PATCHES/patch-02-malloc b/Build/source/utils/m-tx/mtx-src-PATCHES/patch-02-malloc new file mode 100644 index 00000000000..d1ba9181f0f --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src-PATCHES/patch-02-malloc @@ -0,0 +1,11 @@ +--- mtx-0.61.orig/multfile.c Thu Dec 17 04:17:40 2015 ++++ mtx-0.61/multfile.c Thu Dec 17 09:03:39 2015 +@@ -60,7 +60,7 @@ + printf("===! Ignoring recursive include of file %s\n", filename); + return; + } +- newnode = malloc(sizeof(filenode)); ++ newnode = Malloc(sizeof(filenode)); + newnode->actualfile = NULL; + strcpy(newnode->name, filename); + newnode->prev = current; diff --git a/Build/source/utils/m-tx/mtx-src-PATCHES/patch-03-different-size b/Build/source/utils/m-tx/mtx-src-PATCHES/patch-03-different-size new file mode 100644 index 00000000000..0eb96f3c8e2 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src-PATCHES/patch-03-different-size @@ -0,0 +1,15 @@ +--- mtx-0.61.orig/libp2c/p2c.h Wed Mar 17 00:28:20 1999 ++++ mtx-0.61/libp2c/p2c.h Thu Dec 17 09:00:24 2015 +@@ -428,10 +428,10 @@ + + /* Memory allocation */ + #ifdef __GCC__ +-# define Malloc(n) (malloc(n) ?: (Anyptr)_OutMem()) ++# define Malloc(n) (malloc(n) ?: (Anyptr)(size_t)_OutMem()) + #else + extern Anyptr __MallocTemp__; +-# define Malloc(n) ((__MallocTemp__ = malloc(n)) ? __MallocTemp__ : (Anyptr)_OutMem()) ++# define Malloc(n) ((__MallocTemp__ = malloc(n)) ? __MallocTemp__ : (Anyptr)(size_t)_OutMem()) + #endif + #define FreeR(p) (free((Anyptr)(p))) /* used if arg is an rvalue */ + #define Free(p) (free((Anyptr)(p)), (p)=NULL) diff --git a/Build/source/utils/m-tx/mtx-src/AUTHORS b/Build/source/utils/m-tx/mtx-src/AUTHORS new file mode 100644 index 00000000000..9fdff1fe9d3 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/AUTHORS @@ -0,0 +1 @@ +Dirk Laurie (dpl@sun.ac.za) diff --git a/Build/source/utils/m-tx/mtx-src/Bugs b/Build/source/utils/m-tx/mtx-src/Bugs new file mode 100644 index 00000000000..716a28c5d6e --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/Bugs @@ -0,0 +1,9 @@ +Lyrics lines when not from same paragraph don't join neatly. +Problem has been discussed on mailing list and Rainer gave +a solution. This still (TeXLive 2013) seems to be a little +unsatisfactory. + +Rest in dot and comma shortcuts gives error at PMX stage. +Not recently (2015-08-04) checked. + + diff --git a/Build/source/utils/m-tx/mtx-src/COPYING b/Build/source/utils/m-tx/mtx-src/COPYING new file mode 100644 index 00000000000..623b6258a13 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/Build/source/utils/m-tx/mtx-src/ChangeLog b/Build/source/utils/m-tx/mtx-src/ChangeLog new file mode 100644 index 00000000000..6169851f3aa --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/ChangeLog @@ -0,0 +1,187 @@ + Corrections and enhancements to M-Tx starting from 0.53 + Newest items at top + +Version 0.61 + `TeX` preamble command for Type 2 TeX strings. + Assertions: Range, Bars. + User's Manual thoroughly revised. + Misnamed procedure `tex3` is now `TeXtype2`. + Page and font macros are included in `mtx.tex`. + +Version 0.60d + Replaced space character tie label by no label, + status.pas: procedure labelSlur, call procedure insertchar only for slurs. + +Version 0.60c + Added facility for prefixing music words with '_' for handling in PMX. + Prefix is stripped in output file. + mtxline.pas: type music_word, const bind_left, array name, + procedure GetNextMusWord. + +Version 0.60b + Fixed bug in doPMXpreamble causing errors with printed meters. + +Version 0.60a + Fix for music size 13 in preamble.pas. + Convert M-Tx denominators '1', '16', '32' and '64' + to PMX meter denominator syntax '0', '1', '3' and '6'. + {} ties don't get PMX label T attached in order to support MIDI ties. + +Planned for the near future + Accepts detached shortcut. + +Version 0.55h (not released) + Traces pitch including z-words; warns if unreal. Disable checkPitch + to bypass this. + +Version 0.55g (not released) + Corrects another bug in notes.pas, introduced at 0.55d. + Features: countMacro, expandMacro. + +Version 0.55f (not released) + Corrects bugs, mainly in notes.pas, introduced at 0.55d. + Help via command line. + +Version 0.55e (not released) + Chord ties. E.g. C: {ce cf ties the c. No close-tie symbol. + +Version 0.55d (not released) + Mainly code cleanup. Should be transparent to most users. + +Version 0.55c + Corrects continuation slur bug. + +Version 0.55b + Bug correction, but including a substantial rewrite of the lyrics melisma handling. + +Version 0.55 + Basically the same as 0.54k. + +Version 0.54k (not released) + DPL: Slurs are no longer translated to s and t, but to ( and {. This requires + PMX 2.502. Labels are inserted into slurs. + +Version 0.54j (not released) + DPL: "Enable" and "Disable" directives for more flexible handling of optional + features. No further development of "Options:" will be made. + +Version 0.54h (not released) + Certain parts of the unwieldy "globals" unit moved to a new "utility" unit. + Affects programming, not functionality. + +Version 0.54g (released only to beta testers) + DPL: Corrected bug in multfile.pas (end-of-input not properly recognized). + +Version 0.54f (released only to beta testers) + DPL: Cleaning up of files.pas to take full advantage of the new + multifile.pas unit. Corrected some obscure bugs. + +Version 0.54e (not released) + +2004-03-07 + DPL: Added the "Include: filename" directive. This may appear anywhere, + and diverts the input stream to the new filename. This may in turn + include other files, etc. A file may be included more than once, but + do not try recursive includes! When the end of an included file is + reached, the stream reverts to the previous file. End-of-file is + treated seamlessly and does not act as a paragraph separator. + +Version 0.54d (not released) + +2004-02-15 + DPL: {...} gives st slurs, }{ works, -t option to retain old behaviour, + some cleaning up of unused pieces of code. + Affects files.pas, globals.pas, mtxline.pas, preamble.pas, prepmx.pas, + status.pas + +Version 0.54c + +2003-08-14 + Hiroaki Morimoto: + mtx.pas: allow PMX style absolute octave assignment + +Version 0.54b + +2003-08-05 + Christian Mondrup: + mtx.tex: changed \def\mtxLyrlink{\lowlyrlink} to \def\mtxLowLyrlink{\lowlyrlink} + +2003-06-03 + Christian Mondrup: + Correct bug in procedure respace: test on 'nspace[ninstr]' rather than on + nspace[nstaves] in concluding if statement. + +Version 0.54a + +2002-01-29 + Recognizes PMX words D s t as binding to the left. + Uptext also on multi-bar rests. + +Version 0.53j + +2001-12-06 + mtx.tex tuning improvements only + +Version 0.53i + +2001-11-27 + Correct bug in verse numbers when bar starts with rests + (reported by Christian Mondrup) + +Version 0.53h + +2001-11-20 + Correct bug in decrescendo (reported by Christian Mondrup) + -- involves mtx.tex and uptext.* + 100 lines per paragraph + +Version 0.53g + +2001-10-30 + Restore midi accidental capability (lost by mistake from 0.53c to + 0.53f) + +Version 0.53f + +2001-08-29 + xtuplet may start with rest + +Version 0.53e + +2001-06-22 + Recognizes 'D' in xtuplet notes. + +Version 0.53d + +2001-06-21 + Always uses full instrument/stave format, even if there is just + one stave per instrument. + +Version 0.53c + +2001-06-18 + Improved handling of Composer, Poet and Title lines. + procedure selectVoices added (maybe one day we'll support + movement changes) + Braces around \mtxFlat and \mtxSharp + Does not translate '_' in lyrics if + (1) at end of word + (2) followed by another '_' + (3) followed by a digit + +Version 0.53b + +2001-06-02 + Improvements to mtx.tex, including nicer sharps and flats in uptext + +Version 0.53a + +2001-05-29 + Looks for 'i' anywhere in note (except in shortcut and xtuplet parts) + and moves it to follow accidental. + +2001-05-28 + From Christian Mondrup + preamble.pas: added trailing backslash to \mtxTenorClef + mtx.tex: changed \mtxmtxNormalSize to \mtxNormalSize + diff --git a/Build/source/utils/m-tx/mtx-src/ChangeLog.C b/Build/source/utils/m-tx/mtx-src/ChangeLog.C new file mode 100644 index 00000000000..34a54157f8c --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/ChangeLog.C @@ -0,0 +1,4 @@ +2012-05-16 Peter Breitenlohner + + * patch-01-write-bin (new): Use binary mode for output files. + From Akira Kakuto (W32TeX). diff --git a/Build/source/utils/m-tx/mtx-src/Corrections b/Build/source/utils/m-tx/mtx-src/Corrections new file mode 100644 index 00000000000..99efcccc19a --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/Corrections @@ -0,0 +1,208 @@ +Corrections and enhancements to M-Tx starting from 0.53 +======================================================= + +Newest items at top. You might also want to look at file `MAINTENANCE`. + +Version 0.61 +------------ + +Mainly aids to the programmer. + +1. `TeX` preamble command for Type 2 TeX strings. +2. Assertions: Range, Bars. +3. User's Manual thoroughly revised. +4. Misnamed procedure `tex3` is now `TeXtype2`. +5. Page and font macros are included in `mtx.tex`. +6. The part of this file above the horizontal line is in Markdown. + + +---------------------------------------------------------------------- + +Version 0.60f + notes.pas: {$V-} inserted since otherwise Pascal 2.6.2 regards it as an + error to pass a var argument of type `string[16]` to a procedure that + expects type `string`. + lyrics.pas: tests for empty lyrics paragraph + +Version 0.60e (RETRACTED) + Any bar word starting with `|` terminates a pickup, not only `|`. + Actually the manual was clear on this point, so the current version + has reverted to 0.60d. + +Version 0.60d + Replaced space character tie label by no label, + status.pas: procedure labelSlur, call procedure insertchar only for slurs. + +Version 0.60c + Added facility for prefixing music words with '_' for handling in PMX. + Prefix is stripped in output file. + mtxline.pas: type music_word, const bind_left, array name, + procedure GetNextMusWord. + +Version 0.60b + Fixed bug in doPMXpreamble causing errors with printed meters. + +Version 0.60a + Fix for music size 13 in preamble.pas. + Convert M-Tx denominators '1', '16', '32' and '64' + to PMX meter denominator syntax '0', '1', '3' and '6'. + {} ties don't get PMX label T attached in order to support MIDI ties. + +Planned for the near future + Accepts detached shortcut. + +Version 0.55h (not released) + Traces pitch including z-words; warns if unreal. Disable checkPitch + to bypass this. + +Version 0.55g (not released) + Corrects another bug in notes.pas, introduced at 0.55d. + Features: countMacro, expandMacro. + +Version 0.55f (not released) + Corrects bugs, mainly in notes.pas, introduced at 0.55d. + Help via command line. + +Version 0.55e (not released) + Chord ties. E.g. C: {ce cf ties the c. No close-tie symbol. + +Version 0.55d (not released) + Mainly code cleanup. Should be transparent to most users. + +Version 0.55c + Corrects continuation slur bug. + +Version 0.55b + Bug correction, but including a substantial rewrite of the lyrics melisma handling. + +Version 0.55 + Basically the same as 0.54k. + +Version 0.54k (not released) + DPL: Slurs are no longer translated to s and t, but to ( and {. This requires + PMX 2.502. Labels are inserted into slurs. + +Version 0.54j (not released) + DPL: "Enable" and "Disable" directives for more flexible handling of optional + features. No further development of "Options:" will be made. + +Version 0.54h (not released) + Certain parts of the unwieldy "globals" unit moved to a new "utility" unit. + Affects programming, not functionality. + +Version 0.54g (released only to beta testers) + DPL: Corrected bug in multfile.pas (end-of-input not properly recognized). + +Version 0.54f (released only to beta testers) + DPL: Cleaning up of files.pas to take full advantage of the new + multifile.pas unit. Corrected some obscure bugs. + +Version 0.54e (not released) + +2004-03-07 + DPL: Added the "Include: filename" directive. This may appear anywhere, + and diverts the input stream to the new filename. This may in turn + include other files, etc. A file may be included more than once, but + do not try recursive includes! When the end of an included file is + reached, the stream reverts to the previous file. End-of-file is + treated seamlessly and does not act as a paragraph separator. + +Version 0.54d (not released) + +2004-02-15 + DPL: {...} gives st slurs, }{ works, -t option to retain old behaviour, + some cleaning up of unused pieces of code. + Affects files.pas, globals.pas, mtxline.pas, preamble.pas, prepmx.pas, + status.pas + +Version 0.54c + +2003-08-14 + Hiroaki Morimoto: + mtx.pas: allow PMX style absolute octave assignment + +Version 0.54b + +2003-08-05 + Christian Mondrup: + mtx.tex: changed \def\mtxLyrlink{\lowlyrlink} to \def\mtxLowLyrlink{\lowlyrlink} + +2003-06-03 + Christian Mondrup: + Correct bug in procedure respace: test on 'nspace[ninstr]' rather than on + nspace[nstaves] in concluding if statement. + +Version 0.54a + +2002-01-29 + Recognizes PMX words D s t as binding to the left. + Uptext also on multi-bar rests. + +Version 0.53j + +2001-12-06 + mtx.tex tuning improvements only + +Version 0.53i + +2001-11-27 + Correct bug in verse numbers when bar starts with rests + (reported by Christian Mondrup) + +Version 0.53h + +2001-11-20 + Correct bug in decrescendo (reported by Christian Mondrup) + -- involves mtx.tex and uptext.* + 100 lines per paragraph + +Version 0.53g + +2001-10-30 + Restore midi accidental capability (lost by mistake from 0.53c to + 0.53f) + +Version 0.53f + +2001-08-29 + xtuplet may start with rest + +Version 0.53e + +2001-06-22 + Recognizes 'D' in xtuplet notes. + +Version 0.53d + +2001-06-21 + Always uses full instrument/stave format, even if there is just + one stave per instrument. + +Version 0.53c + +2001-06-18 + Improved handling of Composer, Poet and Title lines. + procedure selectVoices added (maybe one day we'll support + movement changes) + Braces around \mtxFlat and \mtxSharp + Does not translate '_' in lyrics if + (1) at end of word + (2) followed by another '_' + (3) followed by a digit + +Version 0.53b + +2001-06-02 + Improvements to mtx.tex, including nicer sharps and flats in uptext + +Version 0.53a + +2001-05-29 + Looks for 'i' anywhere in note (except in shortcut and xtuplet parts) + and moves it to follow accidental. + +2001-05-28 + From Christian Mondrup + preamble.pas: added trailing backslash to \mtxTenorClef + mtx.tex: changed \mtxmtxNormalSize to \mtxNormalSize + diff --git a/Build/source/utils/m-tx/mtx-src/INSTALL b/Build/source/utils/m-tx/mtx-src/INSTALL new file mode 100644 index 00000000000..7d1c323beae --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/INSTALL @@ -0,0 +1,365 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007, 2008, 2009 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without warranty of any kind. + +Basic Installation +================== + + Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. Some packages provide this +`INSTALL' file but do not implement all of the features documented +below. The lack of an optional feature in a given package is not +necessarily a bug. More recommendations for GNU packages can be found +in *note Makefile Conventions: (standards)Makefile Conventions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + + The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package, generally using the just-built uninstalled binaries. + + 4. Type `make install' to install the programs and any data files and + documentation. When installing into a prefix owned by root, it is + recommended that the package be configured and built as a regular + user, and only the `make install' phase executed with root + privileges. + + 5. Optionally, type `make installcheck' to repeat any self-tests, but + this time using the binaries in their final installed location. + This target does not install anything. Running this target as a + regular user, particularly if the prior `make install' required + root privileges, verifies that the installation completed + correctly. + + 6. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + + 7. Often, you can also type `make uninstall' to remove the installed + files again. In practice, not all packages have tested that + uninstallation works correctly, even though it is required by the + GNU Coding Standards. + + 8. Some packages, particularly those that use Automake, provide `make + distcheck', which can by used by developers to test that all other + targets like `make install' and `make uninstall' work correctly. + This target is generally not run by end users. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. This +is known as a "VPATH" build. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + + On MacOS X 10.5 and later systems, you can create libraries and +executables that work on multiple system types--known as "fat" or +"universal" binaries--by specifying multiple `-arch' options to the +compiler but only a single `-arch' option to the preprocessor. Like +this: + + ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CPP="gcc -E" CXXCPP="g++ -E" + + This is not guaranteed to produce working output in all cases, you +may have to build one architecture at a time and combine the results +using the `lipo' tool if you have problems. + +Installation Names +================== + + By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX', where PREFIX must be an +absolute file name. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. In general, the +default for these options is expressed in terms of `${prefix}', so that +specifying just `--prefix' will affect all of the other directory +specifications that were not explicitly provided. + + The most portable way to affect installation locations is to pass the +correct locations to `configure'; however, many packages provide one or +both of the following shortcuts of passing variable assignments to the +`make install' command line to change installation locations without +having to reconfigure or recompile. + + The first method involves providing an override variable for each +affected directory. For example, `make install +prefix=/alternate/directory' will choose an alternate location for all +directory configuration variables that were expressed in terms of +`${prefix}'. Any directories that were specified during `configure', +but not in terms of `${prefix}', must each be overridden at install +time for the entire installation to be relocated. The approach of +makefile variable overrides for each directory variable is required by +the GNU Coding Standards, and ideally causes no recompilation. +However, some platforms have known limitations with the semantics of +shared libraries that end up requiring recompilation when using this +method, particularly noticeable in packages that use GNU Libtool. + + The second method involves providing the `DESTDIR' variable. For +example, `make install DESTDIR=/alternate/directory' will prepend +`/alternate/directory' before all installation names. The approach of +`DESTDIR' overrides is not required by the GNU Coding Standards, and +does not work on platforms that have drive letters. On the other hand, +it does better at avoiding recompilation issues, and works well even +when some directory options were not specified in terms of `${prefix}' +at `configure' time. + +Optional Features +================= + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + + Some packages offer the ability to configure how verbose the +execution of `make' will be. For these packages, running `./configure +--enable-silent-rules' sets the default to minimal output, which can be +overridden with `make V=1'; while running `./configure +--disable-silent-rules' sets the default to verbose, which can be +overridden with `make V=0'. + +Particular systems +================== + + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in +order to use an ANSI C compiler: + + ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" + +and if that doesn't work, install pre-built binaries of GCC for HP-UX. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its `' header file. The option `-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try + + ./configure CC="cc" + +and if that doesn't work, try + + ./configure CC="cc -nodtk" + + On Solaris, don't put `/usr/ucb' early in your `PATH'. This +directory contains several dysfunctional programs; working variants of +these programs are available in `/usr/bin'. So, if you need `/usr/ucb' +in your `PATH', put it _after_ `/usr/bin'. + + On Haiku, software installed for all users goes in `/boot/common', +not `/usr/local'. It is recommended to use the following options: + + ./configure --prefix=/boot/common + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS + KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of all of the options to `configure', and exit. + +`--help=short' +`--help=recursive' + Print a summary of the options unique to this package's + `configure', and exit. The `short' variant lists options used + only in the top level, while the `recursive' variant lists options + also present in any nested packages. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--prefix=DIR' + Use DIR as the installation prefix. *note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. + +`--no-create' +`-n' + Run the configure checks, but stop before creating any output + files. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Build/source/utils/m-tx/mtx-src/Makefile.am b/Build/source/utils/m-tx/mtx-src/Makefile.am new file mode 100644 index 00000000000..02d74dd4527 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/Makefile.am @@ -0,0 +1,78 @@ +## Copyright (C) 2012 Peter Breitenlohner +## You may freely use, modify and/or distribute this file. +## + +INCLUDES = -I$(srcdir)/libp2c +AM_CFLAGS = #$(WARNING_CFLAGS) + +bin_PROGRAMS = prepmx + +## prepmx_SOURCES = config.h + +prepmx_SOURCES = \ + analyze.c \ + analyze.h \ + cfuncs.c \ + cfuncs.h \ + control.c \ + control.h \ + files.c \ + files.h \ + globals.c \ + globals.h \ + lyrics.c \ + lyrics.h \ + mtx.c \ + mtx.h \ + mtxline.c \ + mtxline.h \ + multfile.c \ + multfile.h \ + notes.c \ + notes.h \ + preamble.c \ + preamble.h \ + prepmx.c \ + status.c \ + status.h \ + strings.h \ + uptext.c \ + uptext.h \ + utility.c \ + utility.h + +EXTRA_DIST = \ + analyze.pas \ + control.pas \ + files.pas \ + globals.pas \ + lyrics.pas \ + mtx.pas \ + mtxline.pas \ + multfile.pas \ + notes.pas \ + preamble.pas \ + prepmx.pas \ + status.pas \ + strings.pas \ + uptext.pas \ + utility.pas + +LDADD = libp2c.a + +noinst_LIBRARIES = libp2c.a + +libp2c_a_SOURCES = \ + libp2c/p2c.h \ + libp2c/p2clib.c + +## Tests +## +TESTS = mtx.test +EXTRA_DIST += $(TESTS) + +## mtx.test +EXTRA_DIST += tests/mozart.mtx tests/mozart.pmx Makefile.orig Bugs Corrections ChangeLog.C +EXTRA_DIST += configure.ac Makefile.am +DISTCLEANFILES = mozart* + diff --git a/Build/source/utils/m-tx/mtx-src/Makefile.orig b/Build/source/utils/m-tx/mtx-src/Makefile.orig new file mode 100644 index 00000000000..d3d96e4877b --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/Makefile.orig @@ -0,0 +1,47 @@ +pasfiles = globals.pas mtx.pas preamble.pas lyrics.pas analyze.pas mtxline.pas\ + status.pas uptext.pas prepmx.pas files.pas notes.pas multfile.pas \ + strings.pas utility.pas control.pas +sfiles = mtx.tex mtxdoc.tex mtxdoc.pdf Makefile Corrections Bugs MAINTENANCE + +cfiles = globals.c mtx.c preamble.c lyrics.c analyze.c mtxline.c\ + status.c uptext.c prepmx.c files.c notes.c multfile.c utility.c control.c +native = cfuncs.c cfuncs.h +hfiles = globals.h mtx.h preamble.h lyrics.h analyze.h mtxline.h \ + status.h uptext.h files.h notes.h multfile.h utility.h control.h +ofiles = globals.o mtx.o preamble.o lyrics.o analyze.o mtxline.o \ + status.o uptext.o cfuncs.o files.o notes.o prepmx.o multfile.o utility.o \ + control.o + + +SYSTEM=LINUX + +prepmx: $(pasfiles) + fpc -g -B -vn -So prepmx -T$(SYSTEM) + +prepmxc: $(cfiles) $(ofiles) + gcc $(ofiles) -o prepmx + +multfile.c: multfile.pas + p2c -a -LTurbo multfile.pas -o temp.c + sed -e "s/Malloc/malloc/" < temp.c > multfile.c + rm temp.c + + +%.c: %.pas + p2c -a -LTurbo $*.pas + + +commit: $(pasfiles) $(sfiles) + git add $(pasfiles) $(sfiles) + echo Now type: git commit -m \"DESCRIPTION OF_CHANGES\" + +clean: + - rm *.o *~ *~ core *.pmx *.pml *.log *.dvi + +bare: clean + - rm prepmx *.ppu + +Pzip: + zip -ju mtxP`./version` version $(pasfiles) $(sfiles) README.* + + diff --git a/Build/source/utils/m-tx/mtx-src/NEWS b/Build/source/utils/m-tx/mtx-src/NEWS new file mode 100644 index 00000000000..351792d7e10 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/NEWS @@ -0,0 +1,15 @@ +Lyrics lines when not from same paragraph don't join neatly. +Problem has been discussed on mailing list and Rainer gave +a solution. + +Rest in dot and comma shortcuts gives error at PMX stage. + + +M-Tx 0.60d is a test version of M-Tx 0.60. Please try it out and report any +error observations to Christian Mondrup, reccmo@daimi.au.dk and +Dirk Laurie, dpl@sun.ac.za + +Changes: +======== + +- Fixed a bug with non-labeled ties diff --git a/Build/source/utils/m-tx/mtx-src/README b/Build/source/utils/m-tx/mtx-src/README new file mode 100644 index 00000000000..f57555c8a27 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/README @@ -0,0 +1,35 @@ +M-Tx Preprocessor Source Code +============================= + +This is a development version of `prepmx`, the M-Tx Preprocessor. It contains the file `mtx.tex` and all the sources for generating the binary executable file (`prepmx`, `prepmx.exe`, etc., depending on your operating system). There is no documentation and there are no examples. These are included with the stable release available in the TeXLive and MikTeX distributions of TeX. (If you have not installed one of those, you will be unable to do any useful work with `prepmx`.) + +You probably got it from . If not, you should; that may well contain newer code by now. + +The development version is provided for people who need more recent features than the most recent stable release has, in the hope that they will be willing to report bugs and maybe even suggest how those can be fixed. Send e-mail to the Werner Icking Music Archive mailing list or directly to Dirk Laurie . + +You need the Free Pascal compiler. Any version from 1.0.10 onwards should work; 2.4.4 certainly did on 2014-02-01 and 2.6.2 on 2015-04-24. You may get away with other Pascal compilers, including Borland Pascal 7.0 and the Pascal-to-C translator `p2c`, but no effort has been made to retain compliance. Older versions of this README included details, all probably obsolete by now. + +"GNU System" means any system on which standard GNU utilities such as "bash" and "make" is available. Typical GNU systems are + +- Linux +- Windows with the Cygwin package installed + +You do not need a GNU system to use M-Tx, but it is easier to make the executable on a GNU system. + +If your system has GNU Make, simply type + + make + +Otherwise, find the line in the Makefile starting with `fpc` and type that into your terminal. + +For experts only +---------------- + +You can modify the source code as you wish -- this is open source software and the license is MIT. If you wish to redistribute your modified version, please augment the name so that there is no risk of confusion: e.g. if you are Johannes Brahms and you have made changes to mtxC054f.zip, call it mtxC054f-brahms.zip. + +Even better, send me an e-mail with your changes so that I can insert them into the current development version. + +Or fork the repository. + +The Makefile can make various other things. I don't want to document those, since then I would be constrained to maintain them. Use at your peril. + diff --git a/Build/source/utils/m-tx/mtx-src/analyze.c b/Build/source/utils/m-tx/mtx-src/analyze.c new file mode 100644 index 00000000000..2a7ef8bf0c8 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/analyze.c @@ -0,0 +1,326 @@ +/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ +/* From input file "analyze.pas" */ + + +#include "p2c.h" + + +#define ANALYZE_G +#include "analyze.h" + + +#ifndef MTX_H +#include "mtx.h" +#endif + +#ifndef STRINGS_H +#include "strings.h" +#endif + +#ifndef LYRICS_H +#include "lyrics.h" +#endif + +#ifndef MTXLINE_H +#include "mtxline.h" +#endif + +#ifndef UPTEXT_H +#include "uptext.h" +#endif + +#ifndef PREAMBLE_H +#include "preamble.h" +#endif + +#ifndef UTILITY_H +#include "utility.h" +#endif + + +void includeStartString(void) +{ + voice_index voice; + paragraph_index0 mus; + voice_index FORLIM; + Char STR1[256]; + Char STR2[256]; + + FORLIM = nvoices; + for (voice = 1; voice <= FORLIM; voice++) { + mus = musicLineNo(voice); + if (mus > 0) { + sprintf(STR2, "%s%s", startString(STR1, voice), P[mus-1]); + strcpy(P[mus-1], STR2); + } + } +} + + +Static Char *describe(Char *Result, short nbar, short extra) +{ + Char STR1[256]; + Char STR3[256]; + Char STR4[256]; + + sprintf(Result, "%s bar%s + %s/64 notes", + toString(STR1, nbar), plural(STR3, nbar), toString(STR4, extra)); + return Result; +} + + +void testParagraph(void) +{ + voice_index0 voice; + voice_index0 leader = 0, nv = 0; + paragraph_index0 mus; + short extra, l, nbar; + voice_index0 FORLIM; + Char STR2[256]; + Char STR4[256]; + + nbars = 0; + pickup = 0; + nleft = 0; + if (top > bottom) + return; + pickup = 0; + multi_bar_rest = false; + FORLIM = bottom; + for (voice = top; voice <= FORLIM; voice++) { + mus = musicLineNo(voice); + if (mus > 0) { /** -------------- Voice is present ---- */ + nv++; + line_no = orig_line_no[mus-1]; + scanMusic(voice, &l); + if (multi_bar_rest && nv > 1) + error("Multi-bar rest allows only one voice", print); + if (!pmx_preamble_done) { + if (voice == top) + pickup = l; + else if (pickup != l) + error3(voice, "The same pickup must appear in all voices"); + } + nbar = numberOfBars(voice); + extra = ExtraLength(voice); + if (multi_bar_rest && (nbar > 0 || extra > 0)) + error3(voice, "Multi-bar rest allows no other rests or notes"); + if (nbar > nbars || nbar == nbars && extra > nleft) { + nbars = nbar; + nleft = extra; + leader = voice; + } + if (!final_paragraph && meternum > 0 && extra > 0) { + printf("Line has %s\n", describe(STR2, nbar, extra)); + error(" Line does not end at complete bar", print); + } + if (pmx_preamble_done && l > 0 && meternum > 0) { + printf("l=%d meternum=%d\n", l, meternum); + error3(voice, "Short bar with no meter change"); + } + } + } + if (!pmx_preamble_done) { + xmtrnum0 = (double)pickup / one_beat; /* Don't want an integer result */ + if (beVerbose()) + printf("Pickup = %d/64\n", pickup); + } + if (leader <= 0) + return; + FORLIM = bottom; + for (voice = top; voice <= FORLIM; voice++) { + if (musicLineNo(voice) > 0) { + if (voice != leader) { + mus = musicLineNo(voice); + line_no = orig_line_no[mus-1]; + if (numberOfBars(voice) != numberOfBars(leader) || + ExtraLength(voice) != ExtraLength(leader)) { + printf("Following line has %s\n", + describe(STR4, numberOfBars(voice), ExtraLength(voice))); + puts(musicLine(STR4, voice)); + printf("Longest line has %s\n", + describe(STR2, numberOfBars(leader), ExtraLength(leader))); + puts(musicLine(STR2, leader)); + error("Line duration anomaly", print); + } + } + } + } +} + + +void describeParagraph(void) +{ + voice_index0 voice; + Char STR2[256]; + voice_index0 FORLIM; + + printf("---- Paragraph %d starting at line %d bar %d\n", + paragraph_no, orig_line_no[0], bar_no); + FORLIM = bottom; + for (voice = top; voice <= FORLIM; voice++) + describeVoice(voice, lyricsReport(STR2, voice)); +} + + +/* Local variables for paragraphSetup: */ +struct LOC_paragraphSetup { + voice_index0 *voice; + short l; + voice_index0 k; + Char P_keep[256], w[256]; + boolean is_labelled; +} ; + +Local void maybeUptext(short i, struct LOC_paragraphSetup *LINK) +{ + if (!doUptext()) + return; + if (strlen(LINK->w) == 1) { + if (*LINK->voice == nvoices) + warning("Uptext line below bottom voice should be labelled", print); + } + if (strlen(LINK->w) == 1) { /** Standard chord line ------ */ + LINK->k = *LINK->voice + 1; + if (LINK->k > nvoices) + LINK->k--; + setUptextLineNo(LINK->k, i); + /** Labelled chord line ---- */ + return; + } + predelete(LINK->w, 1); + LINK->k = findVoice(LINK->w); + if (LINK->k == 0) + error("Uptext line belongs to unknown voice", print); + else + setUptextLineNo(LINK->k, i); +} + +Local void maybeChords(short i, struct LOC_paragraphSetup *LINK) +{ + if (!doChords()) + return; + if (strlen(LINK->w) == 1 && *LINK->voice == 0 && pedanticWarnings()) + warning("Chord line above top voice should be labelled", print); + if (strlen(LINK->w) == 1) { /** Standard chord line ------ */ + LINK->k = *LINK->voice; + if (LINK->k == 0) + LINK->k = 1; + setChordLineNo(LINK->k, i); + /** Labelled chord line ---- */ + return; + } + predelete(LINK->w, 1); + LINK->k = findVoice(LINK->w); + if (LINK->k == 0) + error("Chord line belongs to unknown voice", print); + else + setChordLineNo(LINK->k, i); +} + +Local void analyzeParagraph(struct LOC_paragraphSetup *LINK) +{ + paragraph_index i, FORLIM; + + *LINK->voice = 0; + bottom = 0; + top = nvoices + 1; + clearLabels(); + clearTags(); + clearUptext(); + FORLIM = para_len; + for (i = 1; i <= FORLIM; i++) + { /* ----- Paragraph analysis main loop ----- */ + if (*P[i-1] != '\0' && P[i-1][0] != comment) { + NextWord(LINK->w, P[i-1], blank, colon); + line_no = orig_line_no[i-1]; + LINK->l = strlen(LINK->w); + LINK->is_labelled = (LINK->w[LINK->l-1] == colon && + LINK->w[LINK->l-2] != barsym); + if (LINK->is_labelled) { + strcpy(LINK->P_keep, P[i-1]); + predelete(P[i-1], LINK->l); + shorten(LINK->w, LINK->l - 1); + LINK->k = findVoice(LINK->w); /* First look for a voice label */ + if (LINK->k > 0) { + *LINK->voice = LINK->k; + setMusicLineNo(*LINK->voice, i); + } else if (LINK->w[0] == 'L') + maybeLyrics(*LINK->voice, i, LINK->w); + else if (LINK->w[0] == 'C') + maybeChords(i, LINK); + else if (LINK->w[0] == 'U') + maybeUptext(i, LINK); + else { + if (startsWithIgnoreCase(LINK->w, "SPACE")) { + setSpace(P[i-1]); + must_respace = true; + } else { + if (startsWithIgnoreCase(LINK->w, "VOICES")) { + selectVoices(P[i-1]); + must_restyle = true; + } else { + strcpy(P[i-1], LINK->P_keep); + LINK->is_labelled = false; + if (!isNoteOrRest(LINK->w)) { + error("Unknown line label", print); + /** ------------ Maybe Space command ------------ */ + /** ------------ Maybe Voices command ------------ */ + /** Could be sticky attribute **/ + } + } + } + } + } + if (!LINK->is_labelled) { + (*LINK->voice)++; + setMusicLineNo(*LINK->voice, i); + } + if (*LINK->voice > bottom) + bottom = *LINK->voice; + if (*LINK->voice > 0 && *LINK->voice < top) + top = *LINK->voice; + } + } +} + +Local void obliterate(struct LOC_paragraphSetup *LINK) +{ + paragraph_index i; + Char new_only[256]; + paragraph_index FORLIM; + + *new_only = '\0'; + FORLIM = para_len; + for (i = 0; i <= FORLIM - 1; i++) { + if (startsWithIgnoreCase(P[i], "only:")) { + strcpy(new_only, P[i]); + strcpy(P[i], "%"); + } + } + if (*new_only != '\0') { + setOnly(new_only); + return; + } + FORLIM = para_len; + for (i = 1; i <= FORLIM; i++) { + if (omitLine(i)) + strcpy(P[i-1], "%"); + } +} + + +void paragraphSetup(voice_index0 *voice_) +{ + struct LOC_paragraphSetup V; + + V.voice = voice_; + obliterate(&V); + analyzeParagraph(&V); + reviseLyrics(); +} + + + + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/analyze.h b/Build/source/utils/m-tx/mtx-src/analyze.h new file mode 100644 index 00000000000..1a01de09170 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/analyze.h @@ -0,0 +1,33 @@ +/* Header for module analyze, generated by p2c 1.21alpha-07.Dec.93 */ +#ifndef ANALYZE_H +#define ANALYZE_H + + +/* Decide which lines of paragraphs go where; test total duration of lines. */ + +#ifndef CONTROL_H +#include "control.h" +#endif + +#ifndef GLOBALS_H +#include "globals.h" +#endif + + +#ifdef ANALYZE_G +# define vextern +#else +# define vextern extern +#endif + +extern void testParagraph(void); +extern void describeParagraph(void); +extern void paragraphSetup(voice_index0 *voice); +extern void includeStartString(void); + + +#undef vextern + +#endif /*ANALYZE_H*/ + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/analyze.pas b/Build/source/utils/m-tx/mtx-src/analyze.pas new file mode 100644 index 00000000000..e1ce135992d --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/analyze.pas @@ -0,0 +1,184 @@ +unit analyze; + +{ Decide which lines of paragraphs go where; test total duration of lines. } + +interface uses control, globals; + +procedure testParagraph; +procedure describeParagraph; +procedure paragraphSetup (var voice: voice_index0); +procedure includeStartString; + +implementation uses mtx, strings, lyrics, mtxline, uptext, + preamble, utility; + +procedure includeStartString; + var voice: voice_index; + mus: paragraph_index0; +begin for voice:=1 to nvoices do + begin mus:=musicLineNo(voice); if mus>0 then + P[mus]:=startString(voice)+P[mus]; + end; +end; + +function describe(nbar,extra: integer): string; +begin describe:=toString(nbar)+' bar'+plural(nbar)+' + '+ + toString(extra)+'/64 notes'; +end; + +procedure testParagraph; + var voice, leader, nv: voice_index0; + mus: paragraph_index0; + extra, l, nbar: integer; +begin + nbars:=0; pickup:=0; nleft:=0; if top>bottom then exit; + pickup:=0; nv:=0; leader:=0; multi_bar_rest := false; + for voice:=top to bottom do + begin mus:=musicLineNo(voice); + if mus>0 then {* -------------- Voice is present ---- } + begin inc(nv); line_no:=orig_line_no[mus]; + scanMusic(voice,l); + if multi_bar_rest and (nv>1) then error( + 'Multi-bar rest allows only one voice',print); + if not pmx_preamble_done then + if voice=top then pickup:=l + else if pickup<>l then + error3(voice,'The same pickup must appear in all voices'); + nbar := numberOfBars(voice); extra := extraLength(voice); + if multi_bar_rest and ((nbar>0) or (extra>0)) then error3(voice, + 'Multi-bar rest allows no other rests or notes'); + if (nbar>nbars) or (nbar=nbars) and (extra>nleft) then + begin nbars:=nbar; nleft:=extra; leader:=voice; end; + if not final_paragraph and (meternum>0) and (extra>0) then + begin writeln('Line has ', describe(nbar,extra)); + error(' Line does not end at complete bar',print); + end; + if pmx_preamble_done and (l>0) and (meternum>0) then +begin + writeln('l=',l,' meternum=',meternum); + error3(voice,'Short bar with no meter change'); +end + end + end; + if not pmx_preamble_done then + begin + xmtrnum0 := pickup/one_beat; { Don't want an integer result } + if beVerbose then writeln ('Pickup = ', pickup, '/64'); + end; + if leader>0 then + for voice:=top to bottom do if musicLineNo(voice)>0 then + if voice<>leader then + begin mus:=musicLineNo(voice); + line_no:=orig_line_no[mus]; + if (numberOfBars(voice)<>numberOfBars(leader)) + or (extraLength(voice)<>extraLength(leader)) then + begin + writeln('Following line has ', + describe(numberOfBars(voice), extraLength(voice))); + writeln(musicLine(voice)); + writeln('Longest line has ', + describe(numberOfBars(leader), extraLength(leader))); + writeln(musicLine(leader)); + error('Line duration anomaly',print); + end; + end; +end; + +procedure describeParagraph; + var voice: voice_index0; + begin writeln('---- Paragraph ',paragraph_no, + ' starting at line ', orig_line_no[1], ' bar ', bar_no); + for voice:=top to bottom do describeVoice(voice,lyricsReport(voice)); + end; + +procedure paragraphSetup (var voice: voice_index0); + var l: integer; + k: voice_index0; + P_keep, w: string; + is_labelled: boolean; + + procedure maybeUptext(i: integer); + begin if not doUptext then exit; + if (length(w)=1) then if (voice=nvoices) then + warning('Uptext line below bottom voice should be labelled',print); + if length(w)=1 then {* Standard chord line ------ } + begin k:=voice+1; if k>nvoices then dec(k); + setUptextLineNo(k,i); + end + else {* Labelled chord line ---- } + begin predelete(w,1); k:=findVoice(w); + if k=0 then error('Uptext line belongs to unknown voice',print) + else setUptextLineNo(k,i); + end + end; + + procedure maybeChords(i: integer); + begin if not doChords then exit; + if (length(w)=1) and (voice=0) and pedanticWarnings then + warning('Chord line above top voice should be labelled',print); + if length(w)=1 then {* Standard chord line ------ } + begin k:=voice; if k=0 then k:=1; + setChordLineNo(k,i); + end + else {* Labelled chord line ---- } + begin predelete(w,1); k:=findVoice(w); + if k=0 then error('Chord line belongs to unknown voice',print) + else setChordLineNo(k,i); + end + end; + + procedure analyzeParagraph; + var i: paragraph_index; + begin voice:=0; bottom:=0; top:=nvoices+1; + clearLabels; clearTags; clearUptext; + for i:=1 to para_len do { ----- Paragraph analysis main loop ----- } + if (P[i]<>'') and (P[i,1]<>comment) then + begin + w:=NextWord(P[i],blank,colon); line_no := orig_line_no[i]; + l:=length(w); + is_labelled := (w[l]=colon) and (w[l-1]<>barsym); + if is_labelled then + begin P_keep := P[i]; predelete(P[i],l); shorten(w,l-1); + k:=findVoice(w); { First look for a voice label } + if k>0 then + begin voice:=k; setMusicLineNo(voice,i); + end + else if w[1]='L' then maybeLyrics(voice,i,w) + else if w[1]='C' then maybeChords(i) + else if w[1]='U' then maybeUptext(i) + else begin {* ------------ Maybe Space command ------------ } + if startsWithIgnoreCase(w,'SPACE') then + begin setSpace(P[i]); must_respace:=true; + end + else {* ------------ Maybe Voices command ------------ } + if startsWithIgnoreCase(w,'VOICES') then + begin selectVoices(P[i]); must_restyle:=true; + end + else begin {* Could be sticky attribute *} + P[i] := P_keep; is_labelled := false; + if not isNoteOrRest(w) then error('Unknown line label',print); + end + end + end; + if not is_labelled then + begin inc(voice); setMusicLineNo(voice,i); + end; + if voice>bottom then bottom:=voice; + if (voice>0) and (voice'' then setOnly(new_only) + else for i:=1 to para_len do if omitLine(i) then P[i]:='%'; + end; + +begin obliterate; analyzeParagraph; reviseLyrics; +end; + +end. diff --git a/Build/source/utils/m-tx/mtx-src/cfuncs.c b/Build/source/utils/m-tx/mtx-src/cfuncs.c new file mode 100644 index 00000000000..4885ee72a00 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/cfuncs.c @@ -0,0 +1,107 @@ +# define CFUNCS_C +#include "cfuncs.h" + +int P_argc; +char **P_argv; +int P_ioresult; +int _EscIO2 (int errorcode, char* filename) +{ fprintf(stderr,"Input file %s not found\n",filename); + exit(errorcode); return errorcode; } +int _EscIO (int errorcode){ return _EscIO2(errorcode,""); } +int _Escape (int exitcode) +{ exit(exitcode); return exitcode; } +int _SETIO (int OK, int errorcode){ return P_ioresult = OK ? 0 : errorcode; } +int P_eof (FILE * infile) +{ int x; + if (feof(infile)) return 1; + x = fgetc(infile); + if (x==EOF) return 1; + ungetc(x,infile); return 0; + } +void *__MallocTemp__; +int _OutMem(void) { fprintf(stderr,"Out of memory\n"); exit(-2); return -2; } +void PASCAL_MAIN (int npars, char ** pars) +{ P_argc = npars; P_argv = pars; } + +void scan1(char *s, short p, short *n) +{ sscanf(s+p-1,"%hd",n); +} + +short pos1(char c, char *s) +{ char *t = strchr(s,c); + if (t) return (short) (t-s+1); else return 0; +} + +void delete1(char *s, short p) +{ char *t = (s+=p); s=t-1; + while (*s) *s++ = *t++; +} + +void predelete(char *s, short l) +{ char *t = s+l; + while (*t) *s++ = *t++; + *s = *t; +} + +void shorten(char *s, short new_length) +{ s[new_length] = '\0'; +} + +short posNot(char c, char *s) +{ char *t = s; + while (*t == c) t++; + if (*t) return t-s+1; + else return 0; +} + +void getNum(char *line, short *k) +{ int j=sscanf(line,"%hd",k); + if (j<1) *k=0; +} + + +void getTwoNums(char *line, short *k1, short *k2) +{ int param = sscanf(line,"%hd/%hd",k1,k2); + if (param<2) *k2 = 0; +} + +void toUpper(char *s) +{ while (*s) { *s = toupper(*s); s++; } +} + +boolean startsWith(char *s1, char *s2) +{ while (*s2) { if (*s1++ != *s2++) return false; } + return true; +} + +void insertChar(char c, char *s, short p) +{ char x; + s += p-1; + do { x=c; c=*s; *s++=x; } while (x); +} + +char *substr_(char *Result, char *s, short start, short count) +{ char *R = Result; + s += start-1; + while (count--) *R++ = *s++; + *R = '\0'; + return Result; +} + +short strpos2 (char *s1, char *s2, short p) +{ char *r = strstr (s1+p, s2); + if (r == NULL) return 0; + else return r-s1; +} + +short nextWordBound(char *s, char trigger, short p) +{ + do { + p++; + } while (p <= strlen(s) && s[p-1] != trigger); + while (p < strlen(s) && s[p] != ' ') + p++; + return p; +} + +# undef CFUNCS_C diff --git a/Build/source/utils/m-tx/mtx-src/cfuncs.h b/Build/source/utils/m-tx/mtx-src/cfuncs.h new file mode 100644 index 00000000000..f8f3e0c2d0d --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/cfuncs.h @@ -0,0 +1,73 @@ +/* cfuncs.h DPL 1997-03-31, 2001-12-22 */ + +#ifndef CFUNCS_H +# define CFUNCS_H + +#define STRINGS_H +typedef char Char; +typedef void Void; +#define Static static +#define Local static +#define SHORT_MAX 65535 + +# define FileNotFound 10 +# define FileWriteError 38 +#ifndef STDIO_H +# include +#endif +#ifndef CTYPE_H +# include +#endif +#ifndef STRING_H +# include +#endif +#ifndef STDLIB_H +# include +#endif +#ifndef _FNSIZE +# define _FNSIZE 120 +#endif + +typedef unsigned boolean; +#define false 0 +#define true 1 + +extern int _EscIO (int); +extern int _EscIO2 (int errorcode, char* filename); +extern int _Escape (int); +extern int P_eof (FILE *); +extern int _SETIO (int, int); + +extern void PASCAL_MAIN (int, char **); +extern int P_argc; +extern int P_ioresult; +extern char **P_argv; + +#ifdef CFUNCS_C +# define vextern +#else +# define vextern extern +#endif +/* String handling primitives. */ + +extern void scan1(char *s, short p, short *n); +/* Read an integer at position p of s */ +extern boolean startsWith(char *s1, char *s2); +/* True if s1 starts with s2 */ +extern short pos1(char c, char *s); +extern short posNot(char c, char *s); +extern void insertChar(char c, char *s, short p); +extern char *substr_(char *Result, char *s, short start, short count); +extern void getNum(char *line, short *k); +extern void getTwoNums(char *line, short *k1, short *k2); +extern void toUpper(char *s); +extern void delete1(char *s, short p); +extern void predelete(char *s, short l); +extern void shorten(char *s, short new_length); +extern short strpos2 (char *s1, char *s2, short p); +extern short nextWordBound(char *s, char trigger, short p); + +#undef vextern + +#endif /*CFUNCS_H*/ + diff --git a/Build/source/utils/m-tx/mtx-src/configure.ac b/Build/source/utils/m-tx/mtx-src/configure.ac new file mode 100644 index 00000000000..6814d0ba88d --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/configure.ac @@ -0,0 +1,39 @@ +dnl Process this file with autoconf to produce a configure script. +dnl +dnl Copyright (C) 2012 Peter Breitenlohner +dnl +dnl This file is free software; the copyright holder +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +m4_include([version.ac])[] dnl define mtx_version +AC_INIT([mtx], mtx_version, [rdt@cs.queensu.ca]) +AC_PREREQ([2.63]) +AC_CONFIG_SRCDIR([analyze.c]) + +AM_INIT_AUTOMAKE(mtx, mtx_version) + +dnl Check compiler and flags +AC_PROG_CC + +AM_CONDITIONAL([WIN32], [test "x$kpse_cv_have_win32" != xno]) + +dnl Checks for programs. +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_MAKE_SET +AC_PROG_RANLIB + +# Checks for libraries. + +# Checks for header files. +AC_CHECK_HEADERS([memory.h stddef.h stdlib.h string.h strings.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_TYPE_SIZE_T + +# Checks for library functions. +AC_CHECK_FUNCS([memchr memmove memset strchr strrchr strtol]) + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/Build/source/utils/m-tx/mtx-src/control.c b/Build/source/utils/m-tx/mtx-src/control.c new file mode 100644 index 00000000000..ee6907802df --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/control.c @@ -0,0 +1,269 @@ +/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ +/* From input file "control.pas" */ + + +#include "p2c.h" + + +#define CONTROL_G +#include "control.h" + + +#ifndef UTILITY_H +#include "utility.h" +#endif + + +/* enables Include: directive */ +/* one-word shortcut is treated by simply inserting a blank */ +/* detached form of shortcut allowed */ +/* C: lines are taken into account */ +/* U: lines are taken into account */ +/* L: lines are taken into account */ +/* non-melismatic eighth and shorter notes in vocal lines are unbeamed */ +/* blind slurs are hidden */ +/* U: lines synchronize with words and rests */ +/* always insert duration into notes */ +/* include macros in the count */ +/* literally expand macros */ +/* keep track of pitch and warn if unreal */ +/* transform note words to canical form */ +/* use solfa note names */ +/* issue warnings even when default action is likely to be correct */ +/* ignore all errors except fatal errors */ +/* set instrument names */ +/* report what is being done */ +/* write all possible infomative messages */ +typedef enum { + noSuchFeature, FmultiFile, FsplitShortcut, FnewWordShortcut, FdoChords, + FdoUptext, FdoLyrics, FunbeamVocal, FhideBlindSlurs, FuptextOnRests, + FinsertDuration, FcountMacro, FexpandMacro, FcheckPitch, FrearrangeNote, + FsolfaNoteNames, FpedanticWarnings, FignoreErrors, FinstrumentNames, + FbeVerbose, FdebugMode +} feature; + +typedef struct Tfeature { + Char tag[31]; + boolean active, changed; +} Tfeature; + + +#define firstFeature FmultiFile +#define lastFeature FdebugMode + + +Static Tfeature feat[21] = { + { "", false, false }, + { "multiFile", true, false }, + { "splitShortcut", true, false }, + { "newWordShortcut", true, false }, + { "doChords", true, false }, + { "doUptext", true, false }, + { "doLyrics", true, false }, + { "unbeamVocal", true, false }, + { "hideBlindSlurs", true, false }, + { "uptextOnRests", true, false }, + { "insertDuration", true, false }, + { "countMacro", false, false }, + { "expandMacro", false, false }, + { "checkPitch", true, false }, + { "rearrangeNote", true, false }, + { "solfaNoteNames", false, false }, + { "pedanticWarnings", false, false }, + { "ignoreErrors", false, false }, + { "instrumentNames", false, false }, + { "beVerbose", false, false }, + { "debugMode", false, false } +}; + + +void printFeatures(boolean anyway) +{ + feature i; + Tfeature *WITH; + + for (i = firstFeature; i <= lastFeature; i = (feature)((long)i + 1)) { + WITH = &feat[(long)i]; + if (WITH->changed || anyway) + printf("%s = %s\n", WITH->tag, WITH->active ? " TRUE" : "FALSE"); + } +} + + +Static feature featureNamed(Char *s) +{ + feature i; + + for (i = firstFeature; i <= lastFeature; i = (feature)((long)i + 1)) { + if (equalsIgnoreCase(s, feat[(long)i].tag)) + return i; + } + return noSuchFeature; +} + + +boolean setFeature(Char *which, boolean val) +{ + boolean Result = false; + feature f; + Tfeature *WITH; + + f = featureNamed(which); + if (f != noSuchFeature) { + WITH = &feat[(long)f]; + WITH->active = val; + WITH->changed = true; + Result = true; + } + if (f == FdebugMode && val) + feat[(long)FbeVerbose].active = true; + if (f == FbeVerbose && !val) + feat[(long)FdebugMode].active = false; + return Result; +} + + +void mtxLevel(Char *level) +{ + if (strcmp(level, "0.57") < 0) { + setFeature("splitShortcut", false); + setFeature("newWordShortcut", false); + } +} + + +/* Feature functions. To add a new feature "newFeature": + 1. Insert a new value "FnewFeature" in the declaration of type "feature". + 2. Insert an entry for it in array "feat". + 3. Copy the template below and change "FEATURE" into "newFeature". + 4. Copy the function header to the interface section. + 5. (Optional) Insert code into "mtxLevel" to enable/disable the feature. + +function FEATURE: boolean; +begin FEATURE := feat[FFEATURE].active end; +*/ + +boolean checkPitch(void) +{ + return (feat[(long)FcheckPitch].active); +} + + +boolean countMacro(void) +{ + return (feat[(long)FcountMacro].active); +} + + +boolean expandMacro(void) +{ + return (feat[(long)FexpandMacro].active); +} + + +boolean insertDuration(void) +{ + return (feat[(long)FinsertDuration].active); +} + + +boolean rearrangeNote(void) +{ + return (feat[(long)FrearrangeNote].active); +} + + +boolean beVerbose(void) +{ + return (feat[(long)FbeVerbose].active); +} + + +boolean debugMode(void) +{ + return (feat[(long)FdebugMode].active); +} + + +boolean instrumentNames(void) +{ + return (feat[(long)FinstrumentNames].active); +} + + +boolean hideBlindSlurs(void) +{ + return (feat[(long)FhideBlindSlurs].active); +} + + +boolean doLyrics(void) +{ + return (feat[(long)FdoLyrics].active); +} + + +boolean ignoreErrors(void) +{ + return (feat[(long)FignoreErrors].active); +} + + +boolean pedanticWarnings(void) +{ + return (feat[(long)FpedanticWarnings].active); +} + + +boolean solfaNoteNames(void) +{ + return (feat[(long)FsolfaNoteNames].active); +} + + +boolean uptextOnRests(void) +{ + return (feat[(long)FuptextOnRests].active); +} + + +boolean unbeamVocal(void) +{ + return (feat[(long)FunbeamVocal].active); +} + + +boolean doChords(void) +{ + return (feat[(long)FdoChords].active); +} + + +boolean doUptext(void) +{ + return (feat[(long)FdoUptext].active); +} + + +boolean newWordShortcut(void) +{ + return (feat[(long)FnewWordShortcut].active); +} + + +boolean splitShortcut(void) +{ + return (feat[(long)FsplitShortcut].active); +} + + +boolean multiFile(void) +{ + return (feat[(long)FmultiFile].active); +} + + + + + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/control.h b/Build/source/utils/m-tx/mtx-src/control.h new file mode 100644 index 00000000000..32318eedf7d --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/control.h @@ -0,0 +1,52 @@ +/* Header for module control, generated by p2c 1.21alpha-07.Dec.93 */ +#ifndef CONTROL_H +#define CONTROL_H + + +#ifdef CONTROL_G +# define vextern +#else +# define vextern extern +#endif +/* DPL 2004-03-21 */ +/* Controls which M-Tx features are enabled. + The interface allows one to interrogate the feature state, to set + features according to the M-Tx level, and to override features given + the feature name as a character string. +*/ + + +extern void mtxLevel(Char *level); +extern boolean setFeature(Char *which, boolean val); +/* return TRUE means OK, return FALSE means there is no such feature */ +extern void printFeatures(boolean anyway); +/* anyway TRUE means print all feature settings, FALSE means only those + that were set via setFeature */ + +extern boolean multiFile(void); +extern boolean splitShortcut(void); +extern boolean newWordShortcut(void); +extern boolean doChords(void); +extern boolean doUptext(void); +extern boolean doLyrics(void); +extern boolean unbeamVocal(void); +extern boolean uptextOnRests(void); +extern boolean solfaNoteNames(void); +extern boolean pedanticWarnings(void); +extern boolean ignoreErrors(void); +extern boolean hideBlindSlurs(void); +extern boolean instrumentNames(void); +extern boolean beVerbose(void); +extern boolean debugMode(void); +extern boolean insertDuration(void); +extern boolean rearrangeNote(void); +extern boolean countMacro(void); +extern boolean expandMacro(void); +extern boolean checkPitch(void); + + +#undef vextern + +#endif /*CONTROL_H*/ + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/control.pas b/Build/source/utils/m-tx/mtx-src/control.pas new file mode 100644 index 00000000000..fbe224658a8 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/control.pas @@ -0,0 +1,198 @@ +unit control; { DPL 2004-03-21 } +{ Controls which M-Tx features are enabled. + The interface allows one to interrogate the feature state, to set + features according to the M-Tx level, and to override features given + the feature name as a character string. +} + +interface + +procedure mtxLevel(level: string); +function setFeature(which: string; val: boolean): boolean; + { return TRUE means OK, return FALSE means there is no such feature } +procedure printFeatures(anyway: boolean); + { anyway TRUE means print all feature settings, FALSE means only those + that were set via setFeature } + +function multiFile: boolean; +function splitShortcut: boolean; +function newWordShortcut: boolean; +function doChords: boolean; +function doUptext: boolean; +function doLyrics: boolean; +function unbeamVocal: boolean; +function uptextOnRests: boolean; +function solfaNoteNames: boolean; +function pedanticWarnings: boolean; +function ignoreErrors: boolean; +function hideBlindSlurs: boolean; +function instrumentNames: boolean; +function beVerbose: boolean; +function debugMode: boolean; +function insertDuration: boolean; +function rearrangeNote: boolean; +function countMacro: boolean; +function expandMacro: boolean; +function checkPitch: boolean; + +implementation uses utility; + +type feature = (noSuchFeature, + FmultiFile, { enables Include: directive } + FsplitShortcut, { one-word shortcut is treated by simply inserting a blank } + FnewWordShortcut, { detached form of shortcut allowed } + FdoChords, { C: lines are taken into account } + FdoUptext, { U: lines are taken into account } + FdoLyrics, { L: lines are taken into account } + FunbeamVocal, { non-melismatic eighth and shorter notes in vocal lines are unbeamed } + FhideBlindSlurs, { blind slurs are hidden } + FuptextOnRests, { U: lines synchronize with words and rests } + FinsertDuration, { always insert duration into notes } + FcountMacro, { include macros in the count } + FexpandMacro, { literally expand macros } + FcheckPitch, { keep track of pitch and warn if unreal } + FrearrangeNote, { transform note words to canical form } + FsolfaNoteNames, { use solfa note names } + FpedanticWarnings, { issue warnings even when default action is likely to be correct } + FignoreErrors, { ignore all errors except fatal errors } + FinstrumentNames, { set instrument names } + FbeVerbose, { report what is being done } + FdebugMode { write all possible infomative messages } ); + + Tfeature = record + tag: string[30]; + active, changed: boolean + end; + +const + firstFeature = FmultiFile; + lastFeature = FdebugMode; + + feat: array[feature] of Tfeature = ( + ( tag: ''; active: false; changed: false), + ( tag: 'multiFile'; active: true; changed: false), + ( tag: 'splitShortcut'; active: true; changed: false), + ( tag: 'newWordShortcut'; active: true; changed: false), + ( tag: 'doChords'; active: true; changed: false), + ( tag: 'doUptext'; active: true; changed: false), + ( tag: 'doLyrics'; active: true; changed: false), + ( tag: 'unbeamVocal'; active: true; changed: false), + ( tag: 'hideBlindSlurs'; active: true; changed: false), + ( tag: 'uptextOnRests'; active: true; changed: false), + ( tag: 'insertDuration'; active: true; changed: false), + ( tag: 'countMacro'; active: false; changed: false), + ( tag: 'expandMacro'; active: false; changed: false), + ( tag: 'checkPitch'; active: true; changed: false), + ( tag: 'rearrangeNote'; active: true; changed: false), + ( tag: 'solfaNoteNames'; active: false; changed: false), + ( tag: 'pedanticWarnings'; active: false; changed: false), + ( tag: 'ignoreErrors'; active: false; changed: false), + ( tag: 'instrumentNames'; active: false; changed: false), + ( tag: 'beVerbose'; active: false; changed: false), + ( tag: 'debugMode'; active: false; changed: false) + ); + +procedure printFeatures(anyway: boolean); + var i: feature; +begin for i:=firstFeature to lastFeature do with feat[i] do + if changed or anyway then writeln(tag, ' = ', active) +end; + +function featureNamed(s: string): feature; + var i: feature; +begin for i:=firstFeature to lastFeature do + if equalsIgnoreCase(s,feat[i].tag) then begin featureNamed := i; exit end; + featureNamed := noSuchFeature +end; + +function setFeature(which: string; val: boolean): boolean; + var f: feature; +begin setFeature := false; f := featureNamed(which); + if f <> noSuchFeature then with feat[f] do + begin active := val; changed := true; setFeature := true end; + if (f=FdebugMode) and val then feat[FbeVerbose].active := true; + if (f=FbeVerbose) and not val then feat[FdebugMode].active := false; +end; + +procedure mtxLevel(level: string); +begin + if level<'0.57' then + begin + setFeature('splitShortcut',false); + setFeature('newWordShortcut',false); + end +end; + +{ Feature functions. To add a new feature "newFeature": + 1. Insert a new value "FnewFeature" in the declaration of type "feature". + 2. Insert an entry for it in array "feat". + 3. Copy the template below and change "FEATURE" into "newFeature". + 4. Copy the function header to the interface section. + 5. (Optional) Insert code into "mtxLevel" to enable/disable the feature. + +function FEATURE: boolean; +begin FEATURE := feat[FFEATURE].active end; +} + +function checkPitch: boolean; +begin checkPitch := feat[FcheckPitch].active end; + +function countMacro: boolean; +begin countMacro := feat[FcountMacro].active end; + +function expandMacro: boolean; +begin expandMacro := feat[FexpandMacro].active end; + +function insertDuration: boolean; +begin insertDuration := feat[FinsertDuration].active end; + +function rearrangeNote: boolean; +begin rearrangeNote := feat[FrearrangeNote].active end; + +function beVerbose: boolean; +begin beVerbose := feat[FbeVerbose].active end; + +function debugMode: boolean; +begin debugMode := feat[FdebugMode].active end; + +function instrumentNames: boolean; +begin instrumentNames := feat[FinstrumentNames].active end; + +function hideBlindSlurs: boolean; +begin hideBlindSlurs := feat[FhideBlindSlurs].active end; + +function doLyrics: boolean; +begin doLyrics := feat[FdoLyrics].active end; + +function ignoreErrors: boolean; +begin ignoreErrors := feat[FignoreErrors].active end; + +function pedanticWarnings: boolean; +begin pedanticWarnings := feat[FpedanticWarnings].active end; + +function solfaNoteNames: boolean; +begin solfaNoteNames := feat[FsolfaNoteNames].active end; + +function uptextOnRests: boolean; +begin uptextOnRests := feat[FuptextOnRests].active end; + +function unbeamVocal: boolean; +begin unbeamVocal := feat[FunbeamVocal].active end; + +function doChords: boolean; +begin doChords := feat[FdoChords].active end; + +function doUptext: boolean; +begin doUptext := feat[FdoUptext].active end; + +function newWordShortcut: boolean; +begin newWordShortcut := feat[FnewWordShortcut].active end; + +function splitShortcut: boolean; +begin splitShortcut := feat[FsplitShortcut].active end; + +function multiFile: boolean; +begin multiFile := feat[FmultiFile].active end; + +end. + diff --git a/Build/source/utils/m-tx/mtx-src/files.c b/Build/source/utils/m-tx/mtx-src/files.c new file mode 100644 index 00000000000..972d34ac573 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/files.c @@ -0,0 +1,390 @@ +/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ +/* From input file "files.pas" */ + + + +#include "p2c.h" + +#define FILES_G +#include "files.h" + + +#ifndef CONTROL_H +#include "control.h" +#endif + +#ifndef STRINGS_H +#include "strings.h" +#endif + +#ifndef UTILITY_H +#include "utility.h" +#endif + + +#define param_leader '-' + + +Static Char stylefilename[256] = "mtxstyle.txt"; + +Static short teststyle; + + +boolean endOfInfile(void) +{ + return (eofAll()); +} + + +Static void putTeXlines(Char *s_) +{ + Char s[256]; + short p; + Char STR1[256], STR3[256]; + + strcpy(s, s_); + p = pos1('\n', s); + while (p > 0) { + sprintf(STR3, "\\%s\\", substr_(STR1, s, 1, p - 1)); + putLine(STR3); + predelete(s, p); + p = pos1('\n', s); + } + if (*s != '\0') { + sprintf(STR3, "\\%s\\", s); + putLine(STR3); + } +} + + +void TeXtype2(Char *s) +{ + Char STR2[256]; + + if (!pmx_preamble_done) { + putLine(s); + return; + } + if (s[0] == '%') { + putLine(s); + return; + } + if (first_paragraph) + putTeXlines(s); + else { + sprintf(STR2, "\\\\%s\\", s); + putLine(STR2); + } +} + + +void putLine(Char *line) +{ + if (outlen + strlen(line) >= PMXlinelength) + putc('\n', outfile); + fprintf(outfile, "%s\n", line); + outlen = 0; +} + + +void put(Char *line_, boolean putspace_) +{ + Char line[256]; + short l; + Char STR1[256]; + + strcpy(line, line_); + l = strlen(line); + if (l > PMXlinelength) + error("Item longer than PMX line length", print); + if (outlen + l >= PMXlinelength) { + putLine(""); + put(line, false); + return; + } + if (putspace_ && outlen > 0 && line[0] != ' ') + sprintf(line, " %s", strcpy(STR1, line)); + fputs(line, outfile); + outlen += l; +} + + +boolean styleFileFound(void) +{ + return (teststyle != 0); +} + + +Static void helpmessage(void) +{ + printf("Usage: prepmx [-bcfnhimtuvwDH0123456789] MTXFILE [TEXDIR] [STYLEFILE]\n"); +} + + +Static void bighelpmessage(void) +{ + helpmessage(); + printf("\nMTXFILE: name of .mtx file without its extension\n"); + printf("TEXDIR: directory where the TeX file made by PMX goes, default is ./\n"); + printf("STYLEFILE: name of a file containing style definitions. Default is\n"); + printf(" mtxstyle.txt. This feature is now deprecated; use Include: STYLEFILE\n"); + printf(" in the preamble of the .mtx file instead.\n"); + printf("Options: (can also be entered separately: -b -c ...)\n"); + printf(" -b: disable unbeamVocal\n"); + printf(" -c: disable doChords\n"); + printf(" -f: enable solfaNoteNames\n"); + printf(" -h: display this message and quit\n"); + printf(" -i: enable ignoreErrors\n"); + printf(" -m: disable doLyrics\n"); + printf(" -n: enable instrumentNames\n"); + printf(" -t: disable doUptext\n"); + printf(" -u: disable uptextOnRests\n"); + printf(" -v: enable beVerbose\n"); + printf(" -w: enable pedanticWarnings\n"); + printf(" -D: enable debugMode\n"); + printf(" -0123456789: select Case\n"); + printf(" -H: print enabled status of all options\n"); + printf("All the above, and some other, options can be enabled or disabled\n"); + printf(" in the preamble. What you do there overrides what you do here.\n"); +} + + +void processOption(Char j) +{ + switch (j) { + + case 'b': + setFeature("unbeamVocal", false); + break; + + case 'c': + setFeature("doChords", false); + break; + + case 'f': + setFeature("solfaNoteNames", true); + break; + + case 'h': + bighelpmessage(); + _Escape(255); + break; + + case 'i': + setFeature("ignoreErrors", true); + break; + + case 'm': + setFeature("doLyrics", false); + break; + + case 'n': + setFeature("instrumentNames", true); + break; + + case 't': + setFeature("doUptext", false); + break; + + case 'u': + setFeature("uptextOnRests", false); + break; + + case 'v': + setFeature("beVerbose", true); + break; + + case 'w': + setFeature("pedanticWarnings", true); + break; + + case 'D': + setFeature("debugMode", true); + break; + + case 'H': + printFeatures(true); + break; + + default: + if (isdigit(j)) + choice = j; + else { + putchar(j); + error(": invalid option", !print); + } + break; + } +} + + +/* Local variables for OpenFiles: */ +struct LOC_OpenFiles { + short testin; + Char basename[256]; +} ; + +Local void checkExistingFile(struct LOC_OpenFiles *LINK) +{ + FILE *tryfile; + Char tryfile_NAME[_FNSIZE]; + + strcpy(tryfile_NAME, LINK->basename); + tryfile = fopen(tryfile_NAME, "r+b"); + _SETIO(tryfile != NULL, FileNotFound); + LINK->testin = P_ioresult; + if (LINK->testin != 0) + return; + if (tryfile != NULL) + fclose(tryfile); + printf("There exists a file named %s. I am treating this\n", + LINK->basename); + error(" as a fatal error unless you specify -i", !print); +} + + +void OpenFiles(void) +{ + struct LOC_OpenFiles V; + short i, j, l; + short fileid = 0; + Char infilename[256], outfilename[256], param[256], ext[256]; + short FORLIM1; + Char STR3[256]; + + line_no = 0; + paragraph_no = 0; + for (i = 1; i <= P_argc - 1; i++) { + strcpy(param, P_argv[i]); + if (param[0] == param_leader) { + FORLIM1 = strlen(param); + for (j = 1; j <= FORLIM1 - 1; j++) + processOption(param[j]); + } else if (fileid == 0) + fileid = i; + else if (*texdir == '\0') + strcpy(texdir, param); + else + strcpy(stylefilename, param); + } + if (fileid == 0) { + helpmessage(); + printf("Try \"prepmx -h\" for more information.\n"); + _Escape(255); + } + strcpy(V.basename, P_argv[fileid]); + l = strlen(V.basename); + if (l > 4 && V.basename[l-4] == '.') { + substr_(ext, V.basename, l - 2, 3); + toUpper(ext); + if (!strcmp(ext, "MTX")) { + warning(".mtx extension deleted from basename", !print); + shorten(V.basename, l - 4); + } + } + if (pos1('.', V.basename) > 0) + checkExistingFile(&V); + sprintf(infilename, "%s.mtx", V.basename); + sprintf(outfilename, "%s.pmx", V.basename); + pushFile(infilename); + strcpy(outfile_NAME, outfilename); + if (outfile != NULL) + outfile = freopen(outfile_NAME, "wb", outfile); + else + outfile = fopen(outfile_NAME, "wb"); + _SETIO(outfile != NULL, FileNotFound); + strcpy(stylefile_NAME, stylefilename); + if (stylefile != NULL) + stylefile = freopen(stylefile_NAME, "r", stylefile); + else + stylefile = fopen(stylefile_NAME, "r"); + _SETIO(stylefile != NULL, FileNotFound); + teststyle = P_ioresult; + if (teststyle != 0 && strcmp(stylefilename, "mtxstyle.txt")) + _SETIO(printf("Can't read %s\n", stylefilename) >= 0, FileWriteError); + if (fileError()) { + sprintf(STR3, "Input file %s not found", infilename); + fatalerror(STR3); + } + outfile_open = true; + printf("Writing to %s.pmx\n", V.basename); +} + + +void CloseFiles(void) +{ + if (outfile != NULL) + fclose(outfile); + outfile = NULL; + closeAll(); + if (teststyle != 0) + return; + if (stylefile != NULL) + fclose(stylefile); + stylefile = NULL; +} + + +void readParagraph(Char (*P)[256], short *no, paragraph_index0 *L) +{ + boolean another; + Char filename[256], buffer[256]; + Char STR1[256], STR3[256]; + + *L = 0; + readData(buffer); + line_no = currentLineNo(); + if (isEmpty(buffer)) + return; + if (debugMode()) + printf(">>>> %s\n", buffer); + paragraph_no++; + /* Handle directives affecting the processing of the input file */ + do { + another = false; + if (startsWithIgnoreCase(buffer, "SUSPEND")) { + ignore_input = true; + another = true; + if (beVerbose()) + printf("-->> Suspending input file %s at line %d\n", + currentFilename(STR3), line_no); + } + if (startsWithIgnoreCase(buffer, "RESUME")) { + ignore_input = false; + another = true; + if (beVerbose()) + printf("-->> Resuming input file %s at line %d\n", + currentFilename(STR1), line_no); + } + if (startsWithIgnoreCase(buffer, "INCLUDE:")) { + predelete(buffer, 8); + NextWord(filename, buffer, ' ', ' '); + pushFile(filename); + another = true; + } + if (another) { + readLine(buffer); + line_no = currentLineNo(); + } + } while (another); + /* Normal paragraph input*/ + do { + if (*L < lines_in_paragraph) { + (*L)++; + strcpy(P[*L - 1], buffer); + *buffer = '\0'; + no[*L - 1] = line_no; + } else + warning("Paragraph too long: skipping line", !print); + readLine(buffer); + line_no = currentLineNo(); + if (debugMode()) + printf("%d >> %s\n", line_no, buffer); + } while (!isEmpty(buffer)); + skipBlanks(); /* needed to identify final paragraph */ +} + + + + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/files.h b/Build/source/utils/m-tx/mtx-src/files.h new file mode 100644 index 00000000000..3f6381db489 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/files.h @@ -0,0 +1,38 @@ +/* Header for module files, generated by p2c 1.21alpha-07.Dec.93 */ +#ifndef FILES_H +#define FILES_H + + +/* Open and close files, interpret command line, do input, do most output*/ + +#ifndef GLOBALS_H +#include "globals.h" +#endif + +#ifndef MULTFILE_H +#include "multfile.h" +#endif + + +#ifdef FILES_G +# define vextern +#else +# define vextern extern +#endif + +extern void readParagraph(Char (*P)[256], short *no, paragraph_index0 *L); +extern boolean styleFileFound(void); +extern void processOption(Char j); +extern void OpenFiles(void); +extern void CloseFiles(void); +extern void putLine(Char *line); +extern void put(Char *line, boolean putspace_); +extern void TeXtype2(Char *s); +extern boolean endOfInfile(void); + + +#undef vextern + +#endif /*FILES_H*/ + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/files.pas b/Build/source/utils/m-tx/mtx-src/files.pas new file mode 100644 index 00000000000..446a7041508 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/files.pas @@ -0,0 +1,208 @@ +unit files; +{ Open and close files, interpret command line, do input, do most output} + +interface uses globals, multfile; + +procedure readParagraph (var P: paragraph; var no: line_nos; + var L: paragraph_index0); +function styleFileFound: boolean; +procedure processOption(j: char); +procedure OpenFiles; +procedure CloseFiles; +procedure putLine (line: string); +procedure put(line: string; putspace: boolean); +procedure TeXtype2 (s: string); +function endOfInfile: boolean; + +implementation uses control, strings, utility; + +const param_leader = '-'; + stylefilename: string = 'mtxstyle.txt'; + +var teststyle: integer; + +function endOfInfile: boolean; + begin endOfInfile:=eofAll; end; + +procedure putTeXlines(s: string); + var p: integer; +begin p:=pos1(#10,s); + while p>0 do + begin + putLine('\'+substr(s,1,p-1)+'\'); + predelete(s,p); + p:=pos1(#10,s) + end; + if length(s)>0 then putLine('\'+s+'\'); +end; + +procedure TeXtype2 (s: string); + begin + if pmx_preamble_done then + if s[1]='%' then putLine(s) + else if first_paragraph then putTeXLines(s) + else putLine('\\'+s+'\') + else putLine(s); + end; + +procedure putLine (line: string); + begin if outlen+length(line) > pmxlinelength-1 then writeln(outfile); + writeln(outfile,line); outlen:=0; + end; + +procedure put(line: string; putspace: boolean); + var l: integer; + begin l:=length(line); + if l>pmxlinelength then error('Item longer than PMX line length',print); + if outlen+l > pmxlinelength-1 then + begin putLine(''); put(line,false) end + else begin if putspace and (outlen>0) and (line[1]<>' ') then + line:=' '+line; + write(outfile,line); inc(outlen,l); + end + end; + +function styleFileFound: boolean; +begin styleFileFound := teststyle<>0; end; + +procedure helpmessage; +begin + writeln('Usage: prepmx [-bcfnhimtuvwDH0123456789] MTXFILE [TEXDIR] [STYLEFILE]') +end; + +procedure bighelpmessage; +begin helpmessage; writeln; + writeln('MTXFILE: name of .mtx file without its extension'); + writeln('TEXDIR: directory where the TeX file made by PMX goes, default is ./'); + writeln('STYLEFILE: name of a file containing style definitions. Default is'); + writeln(' mtxstyle.txt. This feature is now deprecated; use Include: STYLEFILE'); + writeln(' in the preamble of the .mtx file instead.'); + writeln('Options: (can also be entered separately: -b -c ...)'); + writeln(' -b: disable unbeamVocal'); + writeln(' -c: disable doChords'); + writeln(' -f: enable solfaNoteNames'); + writeln(' -h: display this message and quit'); + writeln(' -i: enable ignoreErrors'); + writeln(' -m: disable doLyrics'); + writeln(' -n: enable instrumentNames'); + writeln(' -t: disable doUptext'); + writeln(' -u: disable uptextOnRests'); + writeln(' -v: enable beVerbose'); + writeln(' -w: enable pedanticWarnings'); + writeln(' -D: enable debugMode'); + writeln(' -0123456789: select Case'); + writeln(' -H: print enabled status of all options'); + writeln('All the above, and some other, options can be enabled or disabled'); + writeln(' in the preamble. What you do there overrides what you do here.') +end; + +procedure processOption(j: char); + begin case j of + 'b': setFeature('unbeamVocal',false); + 'c': setFeature('doChords',false); + 'f': setFeature('solfaNoteNames',true); + 'h': begin bighelpmessage; halt(255) end; + 'i': setFeature('ignoreErrors',true); + 'm': setFeature('doLyrics',false); + 'n': setFeature('instrumentNames',true); + 't': setFeature('doUptext',false); + 'u': setFeature('uptextOnRests',false); + 'v': setFeature('beVerbose',true); + 'w': setFeature('pedanticWarnings',true); + 'D': setFeature('debugMode',true); + '0'..'9': choice:=j; + 'H': printFeatures(true); + else write(j); error(': invalid option',not print); + end; +end; + +procedure OpenFiles; +var i, j, l, fileid, testin: integer; + infilename, outfilename, basename, param, ext: string; + procedure checkExistingFile; + var tryfile: file; + begin +{$I-} + assign(tryfile,basename); reset(tryfile); testin := ioresult; +{$I+} + if testin<>0 then exit else close(tryfile); + writeln('There exists a file named ',basename,'. I am treating this'); + error(' as a fatal error unless you specify -i',not print); + end; +begin + fileid:=0; line_no:=0; paragraph_no:=0; + for i:=1 to ParamCount do + begin param:=ParamStr(i); + if param[1]=param_leader then + for j:=2 to length(param) do processOption(param[j]) + else if fileid=0 then fileid:=i + else if texdir='' then texdir:=param + else stylefilename:=param; + end; + if fileid=0 then + begin helpmessage; writeln('Try "prepmx -h" for more information.'); halt(255) end + else basename:=paramstr(fileid); + l:=length(basename); + if (l>4) and (basename[l-3]='.') then + begin ext:=substr(basename,l-2,3); toUpper(ext); if ext='MTX' then + begin warning('.mtx extension deleted from basename',not print); + shorten(basename,l-4); + end; + end; + if pos1('.',basename)>0 then checkExistingFile; + infilename := basename+'.mtx'; outfilename := basename+'.pmx'; +{$I-} + pushFile(infilename); + assign(outfile,outfilename); rewrite(outfile); + assign(stylefile,stylefilename); reset(stylefile); teststyle := ioresult; + if (teststyle<>0) and (stylefilename<>'mtxstyle.txt') then + writeln('Can''t read ',stylefilename); +{$I+} + if fileError then fatalError('Input file '+infilename+' not found'); + outfile_open := true; writeln('Writing to ',basename,'.pmx'); +end; + +procedure CloseFiles; +begin close(outfile); closeAll; if teststyle=0 then close(stylefile); +end; + +procedure readParagraph (var P: paragraph; var no: line_nos; + var L: paragraph_index0); + var another: boolean; + filename, buffer: string; +begin + L:=0; buffer:=readData; line_no:=currentLineNo; + if isEmpty(buffer) then exit; + if debugMode then writeln('>>>> ',buffer); + inc(paragraph_no); +{ Handle directives affecting the processing of the input file } + repeat another:=false; + if startsWithIgnoreCase(buffer,'SUSPEND') then + begin ignore_input:=true; another:=true; if beVerbose then + writeln('-->> Suspending input file ',currentFilename, + ' at line ', line_no); + end; + if startsWithIgnoreCase(buffer,'RESUME') then + begin ignore_input:=false; another:=true; if beVerbose then + writeln('-->> Resuming input file ',currentFilename, + ' at line ', line_no); + end; + if startsWithIgnoreCase(buffer,'INCLUDE:') then + begin predelete(buffer,8); filename:=nextWord(buffer,' ',' '); + pushfile(filename); another:=true; + end; + if another then begin buffer:=readLine; line_no:=currentLineNo; end; + until not another; +{ Normal paragraph input} + repeat + if L> ', buffer); + until isEmpty(buffer); + skipBlanks; { needed to identify final paragraph } +end; + +end. diff --git a/Build/source/utils/m-tx/mtx-src/globals.c b/Build/source/utils/m-tx/mtx-src/globals.c new file mode 100644 index 00000000000..1e5a27d93c6 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/globals.c @@ -0,0 +1,329 @@ +/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ +/* From input file "globals.pas" */ + + + +#include "p2c.h" + +#define GLOBALS_G +#include "globals.h" + + +Char double_comment[3] = "%%"; +Char durations[ndurs + 1] = "90248136"; +Char terminators[256] = ".x"; +Char has_duration[9] = "abcdefgr"; +Char solfa_names[8] = "drmfslt"; +Char choice = ' '; +boolean outfile_open = false; +Char texdir[256] = ""; +Char old_meter_word[256] = ""; +short outlen = 0; +boolean ignore_input = false; + +#ifndef STRINGS_H +#include "strings.h" +#endif + +#ifndef CONTROL_H +#include "control.h" +#endif + +#ifndef UTILITY_H +#include "utility.h" +#endif + + +boolean isNoteOrRest(Char *w) +{ + return (pos1(w[0], has_duration) > 0); +} + + +boolean isPause(Char *note) +{ + return (startsWith(note, pause)); +} + + +void cancel(short *num, short *denom, short lowest) +{ + while (((*num) & 1) == 0 && *denom > lowest) { + *num /= 2; + *denom /= 2; + } +} + + +Char *meterWord(Char *Result, short num, short denom, short pnum, + short pdenom) +{ + Char STR1[256], STR2[256], STR4[256], STR5[256]; + + sprintf(Result, "m%s/%s/%s/%s", + toString(STR1, num), toString(STR2, denom), toString(STR4, pnum), + toString(STR5, pdenom)); + return Result; +} + + +Char *meterChange(Char *Result, short n1, short n2, boolean blind) +{ + short f = 64; + short l; + + if (!blind) + return (meterWord(Result, n1, PMXmeterdenom(n2), 0, 0)); + /* CMO: process denominator value with function PMXmeterdenom */ + l = n1 * (64 / n2); + cancel(&l, &f, meterdenom); + /* CMO: process denominator value with function PMXmeterdenom */ + meterWord(Result, l, PMXmeterdenom(f), 0, 0); + if (meternum > 0) + printf("Blind meter change to %d/%d on line %d\n", l, f, line_no); + return Result; +} + + +void setSpace(Char *line_) +{ + Char line[256]; + short i = 0; + Char word[256]; + + strcpy(line, line_); + while (i < ninstr) { + GetNextWord(word, line, blank, dummy); + if (*word == '\0') + return; + i++; + getNum(word, &nspace[i-1]); + } +} + + +Static void onumber(Char *s, short *j, short *n1) +{ + if (s[*j - 1] == 'o') + *n1 = 1; + else if (s[*j - 1] == '1') { + *n1 = digit(s[*j]) + 10; + (*j)++; + } else + *n1 = digit(s[*j - 1]); + (*j)++; +} + + +Static void extractNumber(Char *s, short *k) +{ + Char w[256]; + + GetNextWord(w, s, '/', dummy); + getNum(w, k); +} + + +Static void readMeter(Char *meter_, short *meternum, short *meterdenom, + short *pmnum, short *pmdenom) +{ + Char meter[256]; + short j; + + strcpy(meter, meter_); + if (meter[0] == 'm') { + if (pos1('/', meter) == 0) { + j = 2; + onumber(meter, &j, meternum); + onumber(meter, &j, meterdenom); + onumber(meter, &j, pmnum); + onumber(meter, &j, pmdenom); + return; + } + predelete(meter, 1); + extractNumber(meter, meternum); + extractNumber(meter, meterdenom); + extractNumber(meter, pmnum); + extractNumber(meter, pmdenom); + return; + } + getTwoNums(meter, meternum, meterdenom); + *pmnum = *meternum; + *pmdenom = *meterdenom; +} + + +void getMeter(Char *line_, short *meternum, short *meterdenom, short *pmnum, + short *pmdenom) +{ + Char line[256]; + Char meter[256]; + Char STR1[256]; + + strcpy(line, line_); + GetNextWord(meter, line, blank, dummy); + if (!strcmp(meter, "C/") || !strcmp(meter, "mC/")) { + *meternum = 2; + *meterdenom = 2; + *pmdenom = 5; + *pmnum = 0; + } else if (!strcmp(meter, "C") || !strcmp(meter, "mC")) { + *meternum = 4; + *meterdenom = 4; + *pmdenom = 6; + *pmnum = 0; + } else + readMeter(meter, meternum, meterdenom, pmnum, pmdenom); + if (*meterdenom == 0) { + sprintf(STR1, "%s: Meter denominator must be nonzero", meter); + error(STR1, print); + } + /* CMO: Convert PMX syntax meter denominator '0' to '1' to be used for + prepmx duration checks */ + /* if meterdenom=0 then meterdenom:=1; */ +} + + +Static short whereInParagraph(short l) +{ + short Result = 0; + short j, FORLIM; + + FORLIM = para_len; + for (j = 1; j <= FORLIM; j++) { + if (orig_line_no[j-1] == l) + return j; + } + return Result; +} + + +void fatalerror(Char *message) +{ + setFeature("ignoreErrors", false); + error(message, !print); +} + + +void error(Char *message, boolean printLine) +{ + short j; + + j = whereInParagraph(line_no); + if (j > 0 && printLine) + puts(orig_P[j-1]); + printf("%s: ERROR on line %d\n", message, line_no); + if (j > 0 && printLine) { + printf("The line has been modified internally to:\n"); + puts(P[j-1]); + } + if (ignoreErrors()) + return; + if (outfile_open) { + if (outfile != NULL) + fclose(outfile); + outfile = NULL; + outfile = fopen(outfile_NAME, "wb"); + if (outfile == NULL) + _EscIO2(FileNotFound, outfile_NAME); + fclose(outfile); + outfile = NULL; + } + if (line_no == 0) + line_no = 10000; + _Escape(line_no); +} + + +void warning(Char *message, boolean printLine) +{ + short j; + + if (line_no <= 0) { + printf("%s: WARNING in preamble\n", message); + return; + } + printf("%s: WARNING on line %d\n", message, line_no); + if (!printLine) + return; + j = whereInParagraph(line_no); + if (j > 0) + puts(P[j-1]); +} + + +short PMXinstr(short stave) +{ + return (ninstr - instr[stave-1] + 1); +} + + +void setDefaultDuration(short meterdenom) +{ + switch (meterdenom) { + + case 1: + default_duration = '0'; + break; + + case 2: + default_duration = '2'; + break; + + case 4: + default_duration = '4'; + break; + + case 8: + default_duration = '8'; + break; + + case 16: + default_duration = '1'; + break; + + case 32: + default_duration = '3'; + break; + + case 64: + default_duration = '6'; + break; + } +} + + +short PMXmeterdenom(short denom) +{ + short Result; + + /* CMO: Convert M-Tx meter denominators to PMX syntax */ + switch (denom) { + + case 1: + Result = 0; + break; + + case 16: + Result = 1; + break; + + case 32: + Result = 3; + break; + + case 64: + Result = 6; + break; + + default: + Result = denom; + break; + } + return Result; +} + + + + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/globals.h b/Build/source/utils/m-tx/mtx-src/globals.h new file mode 100644 index 00000000000..415383c1c18 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/globals.h @@ -0,0 +1,153 @@ +/* Header for module globals, generated by p2c 1.21alpha-07.Dec.93 */ +#ifndef GLOBALS_H +#define GLOBALS_H + + +#ifdef GLOBALS_G +# define vextern +#else +# define vextern extern +#endif + + +/* 1. All global variables. + 2. Miscellaneous other procedures required by several Units. +*/ + +/* CMO: addition/change by Christian Mondrup */ + + +#define PMXlinelength 128 +/* !!! One or more of the following constants should be reduced if this + program is to be compiled by a 16-bit compiler (e.g. Turbo Pascal), + otherwise you get a "Data segment too large" error */ +#define lines_in_paragraph 100 +#define max_words 128 +#define max_notes 128 +/* Christian Mondrup's suggestion to reduce data segment size: + lines_in_paragraph = 50; + max_words = 64; + max_notes = 64; +*/ +#define max_bars 16 +#define maxstaves 15 +#define maxvoices 15 +#define maxgroups 3 +#define standardPMXvoices 12 + +#define max_lyrics_line_length (PMXlinelength - 4) + +#define inf 32000 +#define unspec 1000 +#define default_size 20 + +#define start_beam '[' +#define stop_beam ']' +#define rest 'r' + +#define pause "rp" + +#define dotcode 'd' +#define grace_group 'G' +#define multi_group 'x' +#define barsym '|' +#define comment '%' +#define blank ' ' +#define dot '.' +#define comma ',' +#define colon ':' +#define tilde '~' +#define dummy '\0' + +#define ndurs 8 + +#define unspecified '5' /* Not a valid duration */ + +#define whole 2 /* position of '0' in durations */ + +#define digits "123456789" +#define digitsdot "0123456789." + +#define putspace true +#define nospace false +#define print true + + +typedef char paragraph_index; + +typedef char voice_index; + +typedef char stave_index; + +typedef char bar_index0; + +typedef uchar word_index0; + +typedef char paragraph_index0; + +typedef char voice_index0; + +typedef char stave_index0; + +typedef Char paragraph[lines_in_paragraph][256]; +typedef short line_nos[lines_in_paragraph]; + + +extern Char double_comment[3]; +extern Char durations[ndurs + 1]; +extern Char terminators[256]; +extern Char has_duration[9]; +extern Char solfa_names[8]; + +extern Char choice; +extern boolean outfile_open; +extern Char texdir[256]; +extern Char old_meter_word[256]; +extern short outlen; +extern boolean ignore_input; +vextern Char voice_label[maxvoices][256]; +vextern Char clef[maxstaves]; +vextern voice_index0 instr[maxstaves], stave[maxstaves], + first_on_stave[maxstaves], number_on_stave[maxstaves]; +vextern short nspace[maxstaves], stave_size[maxstaves]; +vextern voice_index0 nvoices, nstaves, ninstr, bottom, top; +vextern short one_beat, full_bar, line_no, short_note, musicsize, meternum, + meterdenom, pmnum, pmdenom, paragraph_no, bar_no, pickup, nbars, + nleft; +vextern paragraph_index0 para_len; +vextern double xmtrnum0; +vextern paragraph P, orig_P; +vextern line_nos orig_line_no; +vextern FILE *infile, *outfile, *stylefile; +vextern Char default_duration; +vextern Char fracindent[256], this_version[256], this_version_date[256]; +vextern boolean pmx_preamble_done, first_paragraph, final_paragraph, + must_respace, must_restyle, multi_bar_rest, some_vocal; +vextern Char infile_NAME[_FNSIZE]; +vextern Char outfile_NAME[_FNSIZE]; +vextern Char stylefile_NAME[_FNSIZE]; + + +extern void error(Char *message, boolean printLine); +extern void fatalerror(Char *message); +extern void warning(Char *message, boolean printLine); +extern short PMXinstr(short stave); +extern void setDefaultDuration(short meterdenom); +extern void getMeter(Char *line, short *meternum, short *meterdenom, + short *pmnum, short *pmdenom); +extern void setSpace(Char *line); +extern Char *meterChange(Char *Result, short n1, short n2, boolean blind); +extern Char *meterWord(Char *Result, short num, short denom, short pnum, + short pdenom); +extern void cancel(short *num, short *denom, short lowest); +extern boolean isNoteOrRest(Char *w); +extern boolean isPause(Char *note); +/* CMO: */ +extern short PMXmeterdenom(short denom); + + +#undef vextern + +#endif /*GLOBALS_H*/ + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/globals.pas b/Build/source/utils/m-tx/mtx-src/globals.pas new file mode 100644 index 00000000000..bf72e3dee03 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/globals.pas @@ -0,0 +1,275 @@ +unit globals; + +{ 1. All global variables. + 2. Miscellaneous other procedures required by several Units. +} + +{ CMO: addition/change by Christian Mondrup } + +interface + +const PMXlinelength = 128; +{ !!! One or more of the following constants should be reduced if this + program is to be compiled by a 16-bit compiler (e.g. Turbo Pascal), + otherwise you get a "Data segment too large" error } + lines_in_paragraph = 100; + max_words = 128; + max_notes = 128; +{ Christian Mondrup's suggestion to reduce data segment size: + lines_in_paragraph = 50; + max_words = 64; + max_notes = 64; +} + max_bars = 16; + maxstaves = 15; + maxvoices = 15; + maxgroups = 3; + standardPMXvoices = 12; + max_lyrics_line_length = PMXlinelength-4; + inf = 32000; + unspec = 1000; + default_size = 20; + + start_beam = '['; + stop_beam = ']'; + rest = 'r'; + pause = 'rp'; + dotcode = 'd'; + grace_group = 'G'; + multi_group = 'x'; + barsym = '|'; + comment = '%'; + double_comment: string[2] = '%%'; + blank = ' '; + dot = '.'; + comma = ','; + colon = ':'; + tilde = '~'; + dummy = #0; + + ndurs = 8; + durations: string[ndurs] = '90248136'; + unspecified = '5'; { Not a valid duration } + whole = 2; { position of '0' in durations } + terminators: string = '.x'; + digits = '123456789'; + digitsdot = '0123456789.'; + has_duration: string[8] = 'abcdefgr'; + solfa_names: string[7] = 'drmfslt'; + + choice: char = ' '; + outfile_open: boolean = false; + texdir: string = ''; + old_meter_word: string = ''; + outlen: integer = 0; + putspace = true; + nospace = false; + ignore_input: boolean = false; + print = true; + +type + paragraph_index = 1..lines_in_paragraph; + voice_index = 1..maxvoices; + stave_index = 1..maxstaves; + bar_index0 = 0..max_bars; + word_index0 = 0..max_words; + paragraph_index0 = 0..lines_in_paragraph; + voice_index0 = 0..maxvoices; + stave_index0 = 0..maxstaves; + paragraph = array[paragraph_index] of string; + line_nos = array[paragraph_index] of integer; + +var voice_label: array[voice_index] of string; + clef: array[stave_index] of char; + instr, stave, first_on_stave, number_on_stave: + array[stave_index] of voice_index0; + nspace, stave_size: array[stave_index] of integer; + nvoices, nstaves, ninstr, bottom, top: voice_index0; + one_beat, full_bar, line_no, short_note, musicsize, + meternum, meterdenom, pmnum, pmdenom, paragraph_no, + bar_no, pickup, nbars, nleft: integer; + para_len: paragraph_index0; + xmtrnum0: real; + P, orig_P: paragraph; + orig_line_no: line_nos; + infile, outfile, stylefile: text; + default_duration: char; + fracindent, this_version, this_version_date: string; + pmx_preamble_done, first_paragraph, final_paragraph, must_respace, + must_restyle, multi_bar_rest, some_vocal: boolean; + +procedure error(message: string; printLine: boolean); +procedure fatalerror(message: string); +procedure warning(message: string; printLine: boolean); +function PMXinstr (stave: integer): integer; +procedure setDefaultDuration(meterdenom: integer); +procedure getMeter(line: string; + var meternum, meterdenom, pmnum, pmdenom: integer); +procedure setSpace(line: string); +function meterChange(n1, n2: integer; blind: boolean): string; +function meterWord (num, denom, pnum, pdenom: integer): string; +procedure cancel(var num,denom: integer; lowest: integer); +function isNoteOrRest(w: string): boolean; +function isPause(note: string): boolean; +{ CMO: } +function PMXmeterdenom(denom: integer): integer; + +implementation uses strings, control, utility; + +function isNoteOrRest(w: string): boolean; +begin isNoteOrRest := pos1(w[1],has_duration)>0; end; + +function isPause(note: string): boolean; +begin isPause:=startsWith(note,pause); end; + +procedure cancel(var num,denom: integer; lowest: integer); +begin while (num mod 2 = 0) and (denom>lowest) do + begin num:=num div 2; denom:=denom div 2; end; +end; + +function meterWord (num,denom,pnum,pdenom: integer): string; +begin meterWord := 'm' + toString(num) + '/' + toString(denom) + + '/' + toString(pnum) + '/' + toString(pdenom); +end; + +function meterChange(n1, n2: integer; blind: boolean): string; + var f, l: integer; +begin + if blind then + begin f:=64; l:=n1 * (64 div n2); + cancel(l,f,meterdenom); + { CMO: process denominator value with function PMXmeterdenom } + meterChange := meterWord (l,PMXmeterdenom(f),0,0); + if meternum>0 then + writeln('Blind meter change to ', l, '/', f, ' on line ', line_no); + end + { CMO: process denominator value with function PMXmeterdenom } + else meterChange := meterWord(n1,PMXmeterdenom(n2),0,0); +end; + +procedure setSpace(line: string); + var i: integer; + word: string; + begin i:=0; + while i0) and printline then + writeln(orig_P[j]); + writeln (message, ': ERROR on line ', line_no); + if (j>0) and printline then + begin + writeln ('The line has been modified internally to:'); + writeln(P[j]); + end; + if not ignoreErrors then + begin if outfile_open then + begin close(outfile); rewrite(outfile); close(outfile); end; + if line_no=0 then line_no:=10000; + halt(line_no); + end; +end; + +procedure warning(message: string; printline: boolean); + var j: integer; +begin + if line_no>0 then + begin writeln (message, ': WARNING on line ', line_no); + if not printline then exit; + j:=whereInParagraph(line_no); if j>0 then writeln(P[j]) + end + else writeln (message, ': WARNING in preamble'); +end; + +function PMXinstr (stave: integer): integer; +begin PMXinstr := ninstr + 1 - instr[stave]; end; + +procedure setDefaultDuration(meterdenom: integer); +begin + case meterdenom of + 1: default_duration:='0'; + 2: default_duration:='2'; + 4: default_duration:='4'; + 8: default_duration:='8'; + 16: default_duration:='1'; + 32: default_duration:='3'; + 64: default_duration:='6'; + end; +end; + +function PMXmeterdenom(denom: integer): integer; +begin + { CMO: Convert M-Tx meter denominators to PMX syntax } + case denom of + 1 : PMXmeterdenom:=0; + 16 : PMXmeterdenom:=1; + 32 : PMXmeterdenom:=3; + 64 : PMXmeterdenom:=6; + else + PMXmeterdenom:=denom; + end; +end; + +end. diff --git a/Build/source/utils/m-tx/mtx-src/libp2c/p2c.h b/Build/source/utils/m-tx/mtx-src/libp2c/p2c.h new file mode 100644 index 00000000000..03b95201794 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/libp2c/p2c.h @@ -0,0 +1,533 @@ +#ifndef P2C_H +#define P2C_H + + +/* Header file for code generated by "p2c", the Pascal-to-C translator */ + +/* "p2c" Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation. + * By Dave Gillespie, daveg@synaptics.com. Version 1.21alpha-07.Dec.93. + * This file may be copied, modified, etc. in any way. It is not restricted + * by the licence agreement accompanying p2c itself. + */ + + +#include + +#define DOUBLE double + + + +/* If the following heuristic fails, compile -DBSD=0 for non-BSD systems, + or -DBSD=1 for BSD systems. */ + +#ifdef M_XENIX +# define BSD 0 +#endif + +#ifdef vms +# define BSD 0 +# ifndef __STDC__ +# define __STDC__ 1 +# endif +#endif + +#ifdef __TURBOC__ +# define MSDOS 1 +#endif + +#ifdef MSDOS +# define BSD 0 +#endif + +#ifdef FILE /* a #define in BSD, a typedef in SYSV (hp-ux, at least) */ +# ifndef BSD /* (a convenient, but horrible kludge!) */ +# define BSD 1 +# endif +#endif + +#ifdef BSD +# if !BSD +# undef BSD +# endif +#endif + + +#if (defined(__STDC__) && !defined(M_XENIX)) || defined(__TURBOC__) +# include +# include +# define HAS_STDLIB +# if defined(vms) || defined(__TURBOC__) +# define NON_ANSI_CAT +# endif +#else +# ifndef BSD +# ifndef __TURBOC__ +# include +# endif +# endif +# ifdef hpux +# ifdef _INCLUDE__STDC__ +# include +# include +# define HAS_STDLIB +# endif +# endif +# include +# if !defined(MSDOS) || defined(__TURBOC__) +# define NON_ANSI_CAT +# endif +#endif + +#if defined(NON_ANSI_CAT) && !defined(ANSI_CAT) +# ifdef NON_ANSI_CAT_ALTERNATE +# define __CAT__(a,b)a/**/b +# else +# define __ID__(a)a +# define __CAT__(a,b)__ID__(a)b +# endif +#else +# define __CAT__(a,b)a##b +#endif + + +#ifdef BSD +# include +# define memcpy(a,b,n) (bcopy(b,a,n),a) +# define memcmp(a,b,n) bcmp(a,b,n) +# define strchr(s,c) index(s,c) +# define strrchr(s,c) rindex(s,c) +#else +# include +#endif + +#include +#include +#include +#include + + +#ifndef NO_LACK +#ifdef vms + +#define LACK_LABS +#define LACK_MEMMOVE +#define LACK_MEMCPY + +#else + +#define LACK_LABS /* Undefine these if your library has these */ +#define LACK_MEMMOVE + +#endif +#endif + + +typedef struct __p2c_jmp_buf { + struct __p2c_jmp_buf *next; + jmp_buf jbuf; +} __p2c_jmp_buf; + + +/* Warning: The following will not work if setjmp is used simultaneously. + This also violates the ANSI restriction about using vars after longjmp, + but a typical implementation of longjmp will get it right anyway. */ + +#ifndef FAKE_TRY +# define TRY(x) do { __p2c_jmp_buf __try_jb; \ + __try_jb.next = __top_jb; \ + if (!setjmp((__top_jb = &__try_jb)->jbuf)) { +# define RECOVER(x) __top_jb = __try_jb.next; } else { +# define RECOVER2(x,L) __top_jb = __try_jb.next; } else { \ + if (0) { L: __top_jb = __try_jb.next; } +# define ENDTRY(x) } } while (0) +#else +# define TRY(x) if (1) { +# define RECOVER(x) } else do { +# define RECOVER2(x,L) } else do { L: ; +# define ENDTRY(x) } while (0) +#endif + + + +#ifdef M_XENIX /* avoid compiler bug */ +# define SHORT_MAX (32767) +# define SHORT_MIN (-32768) +#endif + + +/* The following definitions work only on twos-complement machines */ +#ifndef SHORT_MAX +# define SHORT_MAX ((short)(((unsigned short) -1) >> 1)) +# define SHORT_MIN (~SHORT_MAX) +#endif + +#ifndef INT_MAX +# define INT_MAX ((int)(((unsigned int) -1) >> 1)) +# define INT_MIN (~INT_MAX) +#endif + +#ifndef LONG_MAX +# define LONG_MAX ((long)(((unsigned long) -1) >> 1)) +# define LONG_MIN (~LONG_MAX) +#endif + +#ifndef SEEK_SET +# define SEEK_SET 0 +# define SEEK_CUR 1 +# define SEEK_END 2 +#endif + +#ifndef EXIT_SUCCESS +# ifdef vms +# define EXIT_SUCCESS 1 +# define EXIT_FAILURE (02000000000L) +# else +# define EXIT_SUCCESS 0 +# define EXIT_FAILURE 1 +# endif +#endif + + +#define SETBITS 32 + + +#if defined(__STDC__) || defined(__TURBOC__) +# if !defined(vms) && !defined(M_LINT) +# define Signed signed +# else +# define Signed +# endif +# define Void void /* Void f() = procedure */ +# ifndef Const +# define Const const +# endif +# ifndef Volatile +# define Volatile volatile +# endif +# ifdef M_LINT +# define PP(x) () +# define PV() () +typedef char *Anyptr; +# else +# define PP(x) x /* function prototype */ +# define PV() (void) /* null function prototype */ +typedef void *Anyptr; +# endif +#else +# define Signed +# define Void void +# ifndef Const +# define Const +# endif +# ifndef Volatile +# define Volatile +# endif +# define PP(x) () +# define PV() () +typedef char *Anyptr; +#endif + +#ifdef __GNUC__ +# define Inline inline +#else +# define Inline +#endif + +#define Register register /* Register variables */ +#define Char char /* Characters (not bytes) */ + +#ifndef Static +# define Static static /* Private global funcs and vars */ +#endif + +#ifndef Local +# define Local static /* Nested functions */ +#endif + +typedef Signed char schar; +typedef unsigned char uchar; +typedef unsigned char boolean; + +#ifndef NO_DECLARE_ALFA +typedef Char alfa[10]; +#endif + +#ifndef true +# define true 1 +# define false 0 +#endif + +#ifndef TRUE +# define TRUE 1 +# define FALSE 0 +#endif + + +typedef struct { + Anyptr proc, link; +} _PROCEDURE; + +#ifndef _FNSIZE +# define _FNSIZE 120 +#endif + + +extern Void PASCAL_MAIN PP( (int, Char **) ); +extern Char **P_argv; +extern int P_argc; +extern short P_escapecode; +extern int P_ioresult; +extern __p2c_jmp_buf *__top_jb; + + +#ifdef P2C_H_PROTO /* if you have Ansi C but non-prototyped header files */ +extern Char *strcat PP( (Char *, Const Char *) ); +extern Char *strchr PP( (Const Char *, int) ); +extern int strcmp PP( (Const Char *, Const Char *) ); +extern Char *strcpy PP( (Char *, Const Char *) ); +extern size_t strlen PP( (Const Char *) ); +extern Char *strncat PP( (Char *, Const Char *, size_t) ); +extern int strncmp PP( (Const Char *, Const Char *, size_t) ); +extern Char *strncpy PP( (Char *, Const Char *, size_t) ); +extern Char *strrchr PP( (Const Char *, int) ); + +extern Anyptr memchr PP( (Const Anyptr, int, size_t) ); +extern Anyptr memmove PP( (Anyptr, Const Anyptr, size_t) ); +extern Anyptr memset PP( (Anyptr, int, size_t) ); +#ifndef memcpy +extern Anyptr memcpy PP( (Anyptr, Const Anyptr, size_t) ); +extern int memcmp PP( (Const Anyptr, Const Anyptr, size_t) ); +#endif + +extern int atoi PP( (Const Char *) ); +extern double atof PP( (Const Char *) ); +extern long atol PP( (Const Char *) ); +extern double strtod PP( (Const Char *, Char **) ); +extern long strtol PP( (Const Char *, Char **, int) ); +#endif /*P2C_H_PROTO*/ + +#ifndef HAS_STDLIB +#ifndef NO_DECLARE_MALLOC +extern Anyptr malloc PP( (size_t) ); +extern Void free PP( (Anyptr) ); +#endif +#endif + +extern int _OutMem PV(); +extern int _CaseCheck PV(); +extern int _NilCheck PV(); +extern int _Escape PP( (int) ); +extern int _EscIO PP( (int) ); +extern int _EscIO2 PP( (int, Char *) ); + +extern long ipow PP( (long, long) ); +extern long P_imax PP( (long, long) ); +extern long P_imin PP( (long, long) ); +extern double P_rmax PP( (double, double) ); +extern double P_rmin PP( (double, double) ); +extern Char *strsub PP( (Char *, Char *, int, int) ); +extern Char *strltrim PP( (Char *) ); +extern Char *strrtrim PP( (Char *) ); +extern Char *strrpt PP( (Char *, Char *, int) ); +extern Char *strpad PP( (Char *, Char *, int, int) ); +extern int strpos2 PP( (Char *, Char *, int) ); +extern long memavail PV(); +extern int P_peek PP( (FILE *) ); +extern int P_eof PP( (FILE *) ); +extern int P_eoln PP( (FILE *) ); +extern Void P_readpaoc PP( (FILE *, Char *, int) ); +extern Void P_readlnpaoc PP( (FILE *, Char *, int) ); +extern long P_maxpos PP( (FILE *) ); +extern Char *P_trimname PP( (Char *, int) ); +extern long *P_setunion PP( (long *, long *, long *) ); +extern long *P_setint PP( (long *, long *, long *) ); +extern long *P_setdiff PP( (long *, long *, long *) ); +extern long *P_setxor PP( (long *, long *, long *) ); +extern int P_inset PP( (unsigned, long *) ); +extern int P_setequal PP( (long *, long *) ); +extern int P_subset PP( (long *, long *) ); +extern long *P_addset PP( (long *, unsigned) ); +extern long *P_addsetr PP( (long *, unsigned, unsigned) ); +extern long *P_remset PP( (long *, unsigned) ); +extern long *P_setcpy PP( (long *, long *) ); +extern long *P_expset PP( (long *, long) ); +extern long P_packset PP( (long *) ); +extern int P_getcmdline PP( (int, int, Char *) ); +extern Void TimeStamp PP( (int *, int *, int *, + int *, int *, int *) ); +extern Void P_sun_argv PP( (char *, int, int) ); +extern FILE *_skipspaces PP( (FILE *) ); +extern FILE *_skipnlspaces PP( (FILE *) ); + + +/* I/O error handling */ +#define _CHKIO(cond,ior,val,def) ((cond) ? P_ioresult=0,(val) \ + : P_ioresult=(ior),(def)) +#define _SETIO(cond,ior) (P_ioresult = (cond) ? 0 : (ior)) + +/* Following defines are suitable for the HP Pascal operating system */ +#define FileNotFound 10 +#define FileNotOpen 13 +#define FileWriteError 38 +#define BadInputFormat 14 +#define EndOfFile 30 + +#define FILENOTFOUND 10 +#define FILENOTOPEN 13 +#define FILEWRITEERROR 38 +#define BADINPUTFORMAT 14 +#define ENDOFFILE 30 + +/* Creating temporary files */ +#if (defined(BSD) || defined(NO_TMPFILE)) && !defined(HAVE_TMPFILE) +# define tmpfile() (fopen(tmpnam(NULL), "w+")) +#endif + +/* File buffers */ +#define FILEBUF(f,sc,type) sc int __CAT__(f,_BFLAGS); \ + sc type __CAT__(f,_BUFFER) +#define FILEBUFNC(f,type) int __CAT__(f,_BFLAGS); \ + type __CAT__(f,_BUFFER) + +#define RESETBUF(f,type) (__CAT__(f,_BFLAGS) = 1) +#define SETUPBUF(f,type) (__CAT__(f,_BFLAGS) = 0) + +#define GETFBUF(f,type) (*((__CAT__(f,_BFLAGS) == 1 && \ + ((__CAT__(f,_BFLAGS) = 2), \ + fread(&__CAT__(f,_BUFFER), \ + sizeof(type),1,(f)))),\ + &__CAT__(f,_BUFFER))) +#define AGETFBUF(f,type) ((__CAT__(f,_BFLAGS) == 1 && \ + ((__CAT__(f,_BFLAGS) = 2), \ + fread(__CAT__(f,_BUFFER), \ + sizeof(type),1,(f)))),\ + __CAT__(f,_BUFFER)) + +#define PUTFBUF(f,type,v) (GETFBUF(f,type) = (v)) +#define CPUTFBUF(f,v) (PUTFBUF(f,char,v)) +#define APUTFBUF(f,type,v) (memcpy(AGETFBUF(f,type), (v), \ + sizeof(__CAT__(f,_BUFFER)))) + +#define GET(f,type) (__CAT__(f,_BFLAGS) == 1 ? \ + fread(&__CAT__(f,_BUFFER),sizeof(type),1,(f)) : \ + (__CAT__(f,_BFLAGS) = 1)) + +#define PUT(f,type) (fwrite(&__CAT__(f,_BUFFER),sizeof(type),1,(f)), \ + (__CAT__(f,_BFLAGS) = 0)) +#define CPUT(f) (PUT(f,char)) + +#define BUFEOF(f) (__CAT__(f,_BFLAGS) != 2 && P_eof(f)) +#define BUFFPOS(f) (ftell(f) - (__CAT__(f,_BFLAGS) == 2)) + +typedef struct { + FILE *f; + int f_BFLAGS; /* FILEBUFNC(f,Char); */ + Char f_BUFFER; + Char name[_FNSIZE]; +} _TEXT; + +/* Memory allocation */ +#ifdef __GCC__ +# define Malloc(n) (malloc(n) ?: (Anyptr)(size_t)_OutMem()) +#else +extern Anyptr __MallocTemp__; +# define Malloc(n) ((__MallocTemp__ = malloc(n)) ? __MallocTemp__ : (Anyptr)(size_t)_OutMem()) +#endif +#define FreeR(p) (free((Anyptr)(p))) /* used if arg is an rvalue */ +#define Free(p) (free((Anyptr)(p)), (p)=NULL) + +/* sign extension */ +#define SEXT(x,n) ((x) | -(((x) & (1L<<((n)-1))) << 1)) + +/* packed arrays */ /* BEWARE: these are untested! */ +#define P_getbits_UB(a,i,n,L) ((int)((a)[(i)>>(L)-(n)] >> \ + (((~(i))&((1<<(L)-(n))-1)) << (n)) & \ + (1<<(1<<(n)))-1)) + +#define P_getbits_SB(a,i,n,L) ((int)((a)[(i)>>(L)-(n)] << \ + (16 - ((((~(i))&((1<<(L)-(n))-1))+1) <<\ + (n)) >> (16-(1<<(n)))))) + +#define P_putbits_UB(a,i,x,n,L) ((a)[(i)>>(L)-(n)] |= \ + (x) << (((~(i))&((1<<(L)-(n))-1)) << (n))) + +#define P_putbits_SB(a,i,x,n,L) ((a)[(i)>>(L)-(n)] |= \ + ((x) & (1<<(1<<(n)))-1) << \ + (((~(i))&((1<<(L)-(n))-1)) << (n))) + +#define P_clrbits_B(a,i,n,L) ((a)[(i)>>(L)-(n)] &= \ + ~( ((1<<(1<<(n)))-1) << \ + (((~(i))&((1<<(L)-(n))-1)) << (n))) ) + +/* small packed arrays */ +#define P_getbits_US(v,i,n) ((int)((v) >> ((i)<<(n)) & (1<<(1<<(n)))-1)) +#define P_getbits_SS(v,i,n) ((int)((long)(v) << (SETBITS - (((i)+1) << (n))) >> (SETBITS-(1<<(n))))) +#define P_putbits_US(v,i,x,n) ((v) |= (x) << ((i) << (n))) +#define P_putbits_SS(v,i,x,n) ((v) |= ((x) & (1<<(1<<(n)))-1) << ((i)<<(n))) +#define P_clrbits_S(v,i,n) ((v) &= ~( ((1<<(1<<(n)))-1) << ((i)<<(n)) )) + +#define P_max(a,b) ((a) > (b) ? (a) : (b)) +#define P_min(a,b) ((a) < (b) ? (a) : (b)) + + +/* Fix ANSI-isms */ + +#ifdef LACK_LABS +# ifndef labs +# define labs my_labs + extern long my_labs PP( (long) ); +# endif +#endif + +#ifdef LACK_MEMMOVE +# ifndef memmove +# define memmove my_memmove + extern Anyptr my_memmove PP( (Anyptr, Const Anyptr, size_t) ); +# endif +#endif + +#ifdef LACK_MEMCPY +# ifndef memcpy +# define memcpy my_memcpy + extern Anyptr my_memcpy PP( (Anyptr, Const Anyptr, size_t) ); +# endif +# ifndef memcmp +# define memcmp my_memcmp + extern int my_memcmp PP( (Const Anyptr, Const Anyptr, size_t) ); +# endif +# ifndef memset +# define memset my_memset + extern Anyptr my_memset PP( (Anyptr, int, size_t) ); +# endif +#endif + +/* Fix toupper/tolower on Suns and other stupid BSD systems */ +#ifdef toupper +# undef toupper +# undef tolower +# define toupper(c) my_toupper(c) +# define tolower(c) my_tolower(c) +#endif + +#ifndef _toupper +# if 'A' == 65 && 'a' == 97 +# define _toupper(c) ((c)-'a'+'A') +# define _tolower(c) ((c)-'A'+'a') +# else +# ifdef toupper +# undef toupper /* hope these are shadowing real functions, */ +# undef tolower /* because my_toupper calls _toupper! */ +# endif +# define _toupper(c) toupper(c) +# define _tolower(c) tolower(c) +# endif +#endif + + +#endif /* P2C_H */ + + + +/* End. */ + + diff --git a/Build/source/utils/m-tx/mtx-src/libp2c/p2clib.c b/Build/source/utils/m-tx/mtx-src/libp2c/p2clib.c new file mode 100644 index 00000000000..98a00edf41b --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/libp2c/p2clib.c @@ -0,0 +1,1117 @@ + +/* Run-time library for use with "p2c", the Pascal to C translator */ + +/* "p2c" Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation. + * By Dave Gillespie, daveg@synaptics.com. Version --VERSION--. + * This file may be copied, modified, etc. in any way. It is not restricted + * by the licence agreement accompanying p2c itself. + */ + + + +#include "p2c.h" + + +#ifndef NO_TIME +# include +#endif + + +#define Isspace(c) isspace(c) /* or "((c) == ' ')" if preferred */ + + + + +int P_argc; +char **P_argv; + +short P_escapecode; +int P_ioresult; + +long EXCP_LINE; /* Used by Pascal workstation system */ + +Anyptr __MallocTemp__; + +__p2c_jmp_buf *__top_jb; + + + + +void PASCAL_MAIN(argc, argv) +int argc; +char **argv; +{ + P_argc = argc; + P_argv = argv; + __top_jb = NULL; + +#ifdef LOCAL_INIT + LOCAL_INIT(); +#endif +} + + + + + +/* In case your system lacks these... */ + +long my_labs(x) +long x; +{ + return((x > 0) ? x : -x); +} + + +#ifdef __STDC__ +Anyptr my_memmove(Anyptr d, Const Anyptr s, size_t n) +#else +Anyptr my_memmove(d, s, n) +Anyptr d, s; +register int n; +#endif +{ + register char *dd = (char *)d, *ss = (char *)s; + if (dd < ss || dd - ss >= n) { +#if defined(bcopy) && defined(memcpy) + my_memcpy(dd, ss, n); +#else + memcpy(dd, ss, n); +#endif + } else if (n > 0) { + dd += n; + ss += n; + while (n-- > 0) + *--dd = *--ss; + } + return d; +} + + +#ifdef __STDC__ +Anyptr my_memcpy(Anyptr d, Const Anyptr s, size_t n) +#else +Anyptr my_memcpy(d, s, n) +Anyptr d, s; +register int n; +#endif +{ + register char *ss = (char *)s, *dd = (char *)d; + while (n-- > 0) + *dd++ = *ss++; + return d; +} + +#ifdef __STDC__ +int my_memcmp(Const Anyptr s1, Const Anyptr s2, size_t n) +#else +int my_memcmp(s1, s2, n) +Anyptr s1, s2; +register int n; +#endif +{ + register char *a = (char *)s1, *b = (char *)s2; + register int i; + while (n-- > 0) + if ((i = (*a++) - (*b++)) != 0) + return i; + return 0; +} + +#ifdef __STDC__ +Anyptr my_memset(Anyptr d, int c, size_t n) +#else +Anyptr my_memset(d, c, n) +Anyptr d; +register int c; +register int n; +#endif +{ + register char *dd = (char *)d; + while (n-- > 0) + *dd++ = c; + return d; +} + + +int my_toupper(c) +int c; +{ + if (islower(c)) + return _toupper(c); + else + return c; +} + + +int my_tolower(c) +int c; +{ + if (isupper(c)) + return _tolower(c); + else + return c; +} + + + + +long ipow(a, b) +long a, b; +{ + long v; + + if (a == 0 || a == 1) + return a; + if (a == -1) + return (b & 1) ? -1 : 1; + if (b < 0) + return 0; + if (a == 2) + return 1L << b; + v = (b & 1) ? a : 1; + while ((b >>= 1) > 0) { + a *= a; + if (b & 1) + v *= a; + } + return v; +} + + +long P_imax(a, b) +long a, b; +{ + if (a > b) + return a; + else + return b; +} + +long P_imin(a, b) +long a, b; +{ + if (a < b) + return a; + else + return b; +} + + +double P_rmax(a, b) +double a, b; +{ + if (a > b) + return a; + else + return b; +} + +double P_rmin(a, b) +double a, b; +{ + if (a < b) + return a; + else + return b; +} + + + + +/* Common string functions: */ + +/* Store in "ret" the substring of length "len" starting from "pos" (1-based). + Store a shorter or null string if out-of-range. Return "ret". */ + +char *strsub(ret, s, pos, len) +register char *ret, *s; +register int pos, len; +{ + register char *s2; + + if (--pos < 0 || len <= 0) { + *ret = 0; + return ret; + } + while (pos > 0) { + if (!*s++) { + *ret = 0; + return ret; + } + pos--; + } + s2 = ret; + while (--len >= 0) { + if (!(*s2++ = *s++)) + return ret; + } + *s2 = 0; + return ret; +} + + +/* Return the index of the first occurrence of "pat" as a substring of "s", + starting at index "pos" (1-based). Result is 1-based, 0 if not found. */ + +int strpos2(s, pat, pos) +char *s; +register char *pat; +register int pos; +{ + register char *cp, ch; + register int slen; + + if (--pos < 0) + return 0; + slen = strlen(s) - pos; + cp = s + pos; + if (!(ch = *pat++)) + return 0; + pos = strlen(pat); + slen -= pos; + while (--slen >= 0) { + if (*cp++ == ch && !strncmp(cp, pat, pos)) + return cp - s; + } + return 0; +} + + +/* Case-insensitive version of strcmp. */ + +int strcicmp(s1, s2) +register char *s1, *s2; +{ + register unsigned char c1, c2; + + while (*s1) { + if (*s1++ != *s2++) { + if (!s2[-1]) + return 1; + c1 = toupper(s1[-1]); + c2 = toupper(s2[-1]); + if (c1 != c2) + return c1 - c2; + } + } + if (*s2) + return -1; + return 0; +} + + + + +/* HP and Turbo Pascal string functions: */ + +/* Trim blanks at left end of string. */ + +char *strltrim(s) +register char *s; +{ + while (Isspace(*s++)) ; + return s - 1; +} + + +/* Trim blanks at right end of string. */ + +char *strrtrim(s) +register char *s; +{ + register char *s2 = s; + + if (!*s) + return s; + while (*++s2) ; + while (s2 > s && Isspace(*--s2)) + *s2 = 0; + return s; +} + + +/* Store in "ret" "num" copies of string "s". Return "ret". */ + +char *strrpt(ret, s, num) +char *ret; +register char *s; +register int num; +{ + register char *s2 = ret; + register char *s1; + + while (--num >= 0) { + s1 = s; + while ((*s2++ = *s1++)) ; + s2--; + } + return ret; +} + + +/* Store in "ret" string "s" with enough pad chars added to reach "size". */ + +char *strpad(ret, s, padchar, num) +char *ret; +register char *s; +register int padchar, num; +{ + register char *d = ret; + + if (s == d) { + while (*d++) ; + } else { + while ((*d++ = *s++)) ; + } + num -= (--d - ret); + while (--num >= 0) + *d++ = padchar; + *d = 0; + return ret; +} + + +/* Copy the substring of length "len" from index "spos" of "s" (1-based) + to index "dpos" of "d", lengthening "d" if necessary. Length and + indices must be in-range. */ + +void strmove(len, s, spos, d, dpos) +register char *s, *d; +register int len, spos, dpos; +{ + s += spos - 1; + d += dpos - 1; + while (*d && --len >= 0) + *d++ = *s++; + if (len > 0) { + while (--len >= 0) + *d++ = *s++; + *d = 0; + } +} + + +/* Delete the substring of length "len" at index "pos" from "s". + Delete less if out-of-range. */ + +void strdelete(s, pos, len) +register char *s; +register int pos, len; +{ + register int slen; + + if (--pos < 0) + return; + slen = strlen(s) - pos; + if (slen <= 0) + return; + s += pos; + if (slen <= len) { + *s = 0; + return; + } + while ((*s = s[len])) s++; +} + + +/* Insert string "src" at index "pos" of "dst". */ + +void strinsert(src, dst, pos) +register char *src, *dst; +register int pos; +{ + register int slen, dlen; + + if (--pos < 0) + return; + dlen = strlen(dst); + dst += dlen; + dlen -= pos; + if (dlen <= 0) { + strcpy(dst, src); + return; + } + slen = strlen(src); + do { + dst[slen] = *dst; + --dst; + } while (--dlen >= 0); + dst++; + while (--slen >= 0) + *dst++ = *src++; +} + + + + +/* File functions */ + +/* Peek at next character of input stream; return EOF at end-of-file. */ + +int P_peek(f) +FILE *f; +{ + int ch; + + ch = getc(f); + if (ch == EOF) + return EOF; + ungetc(ch, f); + return (ch == '\n') ? ' ' : ch; +} + + +/* Check if at end of file, using Pascal "eof" semantics. End-of-file for + stdin is broken; remove the special case for it to be broken in a + different way. */ + +int P_eof(f) +FILE *f; +{ + register int ch; + + if (feof(f)) + return 1; +#ifdef HAVE_ISATTY + if (isatty(fileno(f))) +#else + if (f == stdin) +#endif + return 0; /* not safe to look-ahead on the keyboard! */ + ch = getc(f); + if (ch == EOF) + return 1; + ungetc(ch, f); + return 0; +} + + +/* Check if at end of line (or end of entire file). */ + +int P_eoln(f) +FILE *f; +{ + register int ch; + + ch = getc(f); + if (ch == EOF) + return 1; + ungetc(ch, f); + return (ch == '\n'); +} + + +/* Skip whitespace (including newlines) in a file. */ + +FILE *_skipnlspaces(f) +FILE *f; +{ + register int ch; + + do { + ch = getc(f); + } while (ch == ' ' || ch == '\t' || ch == '\n'); + if (ch != EOF) + ungetc(ch, f); + return f; +} + + +/* Skip whitespace (not including newlines) in a file. */ + +FILE *_skipspaces(f) +FILE *f; +{ + register int ch; + + do { + ch = getc(f); + } while (ch == ' ' || ch == '\t'); + if (ch != EOF) + ungetc(ch, f); + return f; +} + + +/* Read a packed array of characters from a file. */ + +Void P_readpaoc(f, s, len) +FILE *f; +char *s; +int len; +{ + int ch; + + for (;;) { + if (len <= 0) + return; + ch = getc(f); + if (ch == EOF || ch == '\n') + break; + *s++ = ch; + --len; + } + while (--len >= 0) + *s++ = ' '; + if (ch != EOF) + ungetc(ch, f); +} + +Void P_readlnpaoc(f, s, len) +FILE *f; +char *s; +int len; +{ + int ch; + + for (;;) { + ch = getc(f); + if (ch == EOF || ch == '\n') + break; + if (len > 0) { + *s++ = ch; + --len; + } + } + while (--len >= 0) + *s++ = ' '; +} + + +/* Compute maximum legal "seek" index in file (0-based). */ + +long P_maxpos(f) +FILE *f; +{ + long savepos = ftell(f); + long val; + + if (fseek(f, 0L, SEEK_END)) + return -1; + val = ftell(f); + if (fseek(f, savepos, SEEK_SET)) + return -1; + return val; +} + + +/* Use packed array of char for a file name. */ + +Char *P_trimname(fn, len) +register Char *fn; +register int len; +{ + static Char fnbuf[256]; + register Char *cp = fnbuf; + + while (--len >= 0 && *fn && !isspace(*fn)) + *cp++ = *fn++; + *cp = 0; + return fnbuf; +} + + + + +/* Pascal's "memavail" doesn't make much sense in Unix with virtual memory. + We fix memory size as 10Meg as a reasonable compromise. */ + +long memavail() +{ + return 10000000; /* worry about this later! */ +} + +long maxavail() +{ + return memavail(); +} + + + + +/* Sets are stored as an array of longs. S[0] is the size of the set; + S[N] is the N'th 32-bit chunk of the set. S[0] equals the maximum + I such that S[I] is nonzero. S[0] is zero for an empty set. Within + each long, bits are packed from lsb to msb. The first bit of the + set is the element with ordinal value 0. (Thus, for a "set of 5..99", + the lowest five bits of the first long are unused and always zero.) */ + +/* (Sets with 32 or fewer elements are normally stored as plain longs.) */ + +long *P_setunion(d, s1, s2) /* d := s1 + s2 */ +register long *d, *s1, *s2; +{ + long *dbase = d++; + register int sz1 = *s1++, sz2 = *s2++; + while (sz1 > 0 && sz2 > 0) { + *d++ = *s1++ | *s2++; + sz1--, sz2--; + } + while (--sz1 >= 0) + *d++ = *s1++; + while (--sz2 >= 0) + *d++ = *s2++; + *dbase = d - dbase - 1; + return dbase; +} + + +long *P_setint(d, s1, s2) /* d := s1 * s2 */ +register long *d, *s1, *s2; +{ + long *dbase = d++; + register int sz1 = *s1++, sz2 = *s2++; + while (--sz1 >= 0 && --sz2 >= 0) + *d++ = *s1++ & *s2++; + while (--d > dbase && !*d) ; + *dbase = d - dbase; + return dbase; +} + + +long *P_setdiff(d, s1, s2) /* d := s1 - s2 */ +register long *d, *s1, *s2; +{ + long *dbase = d++; + register int sz1 = *s1++, sz2 = *s2++; + while (--sz1 >= 0 && --sz2 >= 0) + *d++ = *s1++ & ~*s2++; + if (sz1 >= 0) { + while (sz1-- >= 0) + *d++ = *s1++; + } + while (--d > dbase && !*d) ; + *dbase = d - dbase; + return dbase; +} + + +long *P_setxor(d, s1, s2) /* d := s1 / s2 */ +register long *d, *s1, *s2; +{ + long *dbase = d++; + register int sz1 = *s1++, sz2 = *s2++; + while (sz1 > 0 && sz2 > 0) { + *d++ = *s1++ ^ *s2++; + sz1--, sz2--; + } + while (--sz1 >= 0) + *d++ = *s1++; + while (--sz2 >= 0) + *d++ = *s2++; + while (--d > dbase && !*d) ; + *dbase = d - dbase; + return dbase; +} + + +int P_inset(val, s) /* val IN s */ +register unsigned val; +register long *s; +{ + register int bit; + bit = val % SETBITS; + val /= SETBITS; + if (val < *s++ && ((1L< size) { + s += size; + while (val > size) + *++s = 0, size++; + *sbase = size; + } else + s += val; + *s |= 1L< (int)v2) + return sbase; + b1 = v1 % SETBITS; + v1 /= SETBITS; + b2 = v2 % SETBITS; + v2 /= SETBITS; + size = *s; + v1++; + if (++v2 > size) { + while (v2 > size) + s[++size] = 0; + s[v2] = 0; + *s = v2; + } + s += v1; + if (v1 == v2) { + *s |= (~((-2L)<<(b2-b1))) << b1; + } else { + *s++ |= (-1L) << b1; + while (++v1 < v2) + *s++ = -1; + *s |= ~((-2L) << b2); + } + return sbase; +} + + +long *P_remset(s, val) /* s := s - [val] */ +register long *s; +register unsigned val; +{ + register int bit; + bit = val % SETBITS; + val /= SETBITS; + if (++val <= *s) { + if (!(s[val] &= ~(1L<= 0) { + if (*s1++ != *s2++) + return 0; + } + return 1; +} + + +int P_subset(s1, s2) /* s1 <= s2 */ +register long *s1, *s2; +{ + register int sz1 = *s1++, sz2 = *s2++; + if (sz1 > sz2) + return 0; + while (--sz1 >= 0) { + if (*s1++ & ~*s2++) + return 0; + } + return 1; +} + + +long *P_setcpy(d, s) /* d := s */ +register long *d, *s; +{ + register long *save_d = d; + +#ifdef SETCPY_MEMCPY + memcpy(d, s, (*s + 1) * sizeof(long)); +#else + register int i = *s + 1; + while (--i >= 0) + *d++ = *s++; +#endif + return save_d; +} + + +/* s is a "smallset", i.e., a 32-bit or less set stored + directly in a long. */ + +long *P_expset(d, s) /* d := s */ +register long *d; +register long s; +{ + if (s) { + d[1] = s; + *d = 1; + } else + *d = 0; + return d; +} + + +long P_packset(s) /* convert s to a small-set */ +register long *s; +{ + if (*s++) + return *s; + else + return 0; +} + + + + + +/* Oregon Software Pascal extensions, courtesy of William Bader */ + +int P_getcmdline(l, h, line) +int l, h; +Char *line; +{ + int i, len; + char *s; + + h = h - l + 1; + len = 0; + for(i = 1; i < P_argc; i++) { + s = P_argv[i]; + while (*s) { + if (len >= h) return len; + line[len++] = *s++; + } + if (len >= h) return len; + line[len++] = ' '; + } + return len; +} + +Void TimeStamp(Day, Month, Year, Hour, Min, Sec) +int *Day, *Month, *Year, *Hour, *Min, *Sec; +{ +#ifndef NO_TIME + struct tm *tm; + long clock; + + time(&clock); + tm = localtime(&clock); + *Day = tm->tm_mday; + *Month = tm->tm_mon + 1; /* Jan = 0 */ + *Year = tm->tm_year; + if (*Year < 1900) + *Year += 1900; /* year since 1900 */ + *Hour = tm->tm_hour; + *Min = tm->tm_min; + *Sec = tm->tm_sec; +#endif +} + +Void VAXdate(s) +char *s; +{ + long clock; + char *c; + int i; + static int where[] = {8, 9, 0, 4, 5, 6, 0, 20, 21, 22, 23}; + + time(&clock); + c = ctime(&clock); + for (i = 0; i < 11; i++) + s[i] = my_toupper(c[where[i]]); + s[2] = '-'; + s[6] = '-'; +} + +Void VAXtime(s) +char *s; +{ + long clock; + char *c; + int i; + + time(&clock); + c = ctime(&clock); + for (i = 0; i < 8; i++) + s[i] = c[i+11]; + s[8] = '.'; + s[9] = '0'; + s[10] = '0'; +} + + + + +/* SUN Berkeley Pascal extensions */ + +Void P_sun_argv(s, len, n) +register char *s; +register int len, n; +{ + register char *cp; + + if ((unsigned)n < P_argc) + cp = P_argv[n]; + else + cp = ""; + while (*cp && --len >= 0) + *s++ = *cp++; + while (--len >= 0) + *s++ = ' '; +} + + + + +int _OutMem() +{ + return _Escape(-2); +} + +int _CaseCheck() +{ + return _Escape(-9); +} + +int _NilCheck() +{ + return _Escape(-3); +} + + + + + +/* The following is suitable for the HP Pascal operating system. + It might want to be revised when emulating another system. */ + +char *_ShowEscape(buf, code, ior, prefix) +char *buf, *prefix; +int code, ior; +{ + char *bufp; + + if (prefix && *prefix) { + strcpy(buf, prefix); + strcat(buf, ": "); + bufp = buf + strlen(buf); + } else { + bufp = buf; + } + if (code == -10) { + sprintf(bufp, "Pascal system I/O error %d", ior); + switch (ior) { + case 3: + strcat(buf, " (illegal I/O request)"); + break; + case 7: + strcat(buf, " (bad file name)"); + break; + case FileNotFound: /*10*/ + strcat(buf, " (file not found)"); + break; + case FileNotOpen: /*13*/ + strcat(buf, " (file not open)"); + break; + case BadInputFormat: /*14*/ + strcat(buf, " (bad input format)"); + break; + case 24: + strcat(buf, " (not open for reading)"); + break; + case 25: + strcat(buf, " (not open for writing)"); + break; + case 26: + strcat(buf, " (not open for direct access)"); + break; + case 28: + strcat(buf, " (string subscript out of range)"); + break; + case EndOfFile: /*30*/ + strcat(buf, " (end-of-file)"); + break; + case FileWriteError: /*38*/ + strcat(buf, " (file write error)"); + break; + } + } else { + sprintf(bufp, "Pascal system error %d", code); + switch (code) { + case -2: + strcat(buf, " (out of memory)"); + break; + case -3: + strcat(buf, " (reference to NIL pointer)"); + break; + case -4: + strcat(buf, " (integer overflow)"); + break; + case -5: + strcat(buf, " (divide by zero)"); + break; + case -6: + strcat(buf, " (real math overflow)"); + break; + case -8: + strcat(buf, " (value range error)"); + break; + case -9: + strcat(buf, " (CASE value range error)"); + break; + case -12: + strcat(buf, " (bus error)"); + break; + case -20: + strcat(buf, " (stopped by user)"); + break; + } + } + return buf; +} + + +int _Escape(code) +int code; +{ + char buf[100]; + + P_escapecode = code; + if (__top_jb) { + __p2c_jmp_buf *jb = __top_jb; + __top_jb = jb->next; + longjmp(jb->jbuf, 1); + } + if (code == 0) + exit(EXIT_SUCCESS); + if (code == -1) + exit(EXIT_FAILURE); + fprintf(stderr, "%s\n", _ShowEscape(buf, P_escapecode, P_ioresult, "")); + exit(EXIT_FAILURE); +} + +int _EscIO(code) +int code; +{ + P_ioresult = code; + return _Escape(-10); +} + +int _EscIO2(code, name) +int code; +char *name; +{ + P_ioresult = code; + if (!__top_jb && name && *name) { + char buf[100]; + fprintf(stderr, "%s: %s\n", + name, _ShowEscape(buf, P_escapecode, P_ioresult, "")); + exit(EXIT_FAILURE); + } + return _Escape(-10); +} + + + +/* End. */ + + + diff --git a/Build/source/utils/m-tx/mtx-src/lyrics.c b/Build/source/utils/m-tx/mtx-src/lyrics.c new file mode 100644 index 00000000000..4c56ea18a3d --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/lyrics.c @@ -0,0 +1,830 @@ +/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ +/* From input file "lyrics.pas" */ + + + +#include "p2c.h" + +#define LYRICS_G +#include "lyrics.h" + + +#ifndef CONTROL_H +#include "control.h" +#endif + +#ifndef STRINGS_H +#include "strings.h" +#endif + +#ifndef MTXLINE_H +#include "mtxline.h" +#endif + +#ifndef STATUS_H +#include "status.h" +#endif + +#ifndef MULTFILE_H +#include "multfile.h" +#endif + +#ifndef FILES_H +#include "files.h" +#endif + +#ifndef UTILITY_H +#include "utility.h" +#endif + + +/* Symbols used in strings of melismatype */ + +#define beam_melisma '[' +#define inhibit_beam_melisma '<' +#define slur_melisma '(' +#define inhibit_slur_melisma '{' + + +typedef char other_index; + +typedef char other_index0; + +typedef Char melismatype[256]; + +typedef enum { + nolyr, haslyr +} haslyrtype; +typedef enum { + normal, aux +} auxtype; +typedef enum { + asbefore, newassign +} assigntype; +typedef enum { + virgin, active +} inittype; + +typedef struct lyrinfotype { + short lyr_adjust, slur_level, slur_change, beam_level, beam_change; + melismatype melisma; + boolean numbered; +} lyrinfotype; + +typedef enum { + none_given, global_lyrics, local_lyrics +} lyrlinetype; + +typedef struct lyrtagtype { + lyrlinetype lyrsource; + haslyrtype has_lyrics; + auxtype auxiliary; + assigntype new_assign; + inittype initialized; + short linecount; + Char tags[256]; +} lyrtagtype; + + +#define maxLyrNums 64 +#define lyrtaglength 40 + + +#define lyr_adjust_undef (-12345) +#define interstave 24 + + +Static short LyrNum = 0; + +Static boolean lyrmodealter[maxstaves], oldlyrmodealter[maxstaves]; +Static lyrtagtype tag[maxvoices], oldtag[maxvoices]; +Static lyrinfotype lyrinfo[maxvoices]; +Static Char numberedParagraph[maxLyrNums][lyrtaglength + 1]; + + +/* Information flow for verse numbers: at the SetLyrics stage, the first +line of each lyrics paragraph is checked for a verse number, and if +found, the paragraph tag is remembered. At the AssignLyrics stage, +the first time that paragraph is encountered, the particular voice +is marked in lyrinfo as being numbered. When that voice is later processed, +the mark in lyrinfo is interrogated and turned off: if it was on, the +mtxVerse pre-TeX string is put into the output. */ + +boolean hasVerseNumber(voice_index voice) +{ + boolean Result; + + Result = lyrinfo[voice-1].numbered; + lyrinfo[voice-1].numbered = false; + return Result; +} + + +Static boolean isNumberedLyricsParagraph(Char *tag) +{ + short i, FORLIM; + + FORLIM = LyrNum; + for (i = 0; i <= FORLIM - 1; i++) { + if (!strcmp(tag, numberedParagraph[i])) + return true; + } + return false; +} + + +Static boolean anyTagNumbered(Char *tags_) +{ + boolean Result; + Char tags[256]; + Char s[256]; + + strcpy(tags, tags_); +/* p2c: lyrics.pas: Note: Eliminated unused assignment statement [338] */ + if (curtail(tags, '}') > 0) + delete1(tags, 1); + do { + GetNextWord(s, tags, ',', dummy); + if (*s == '\0') + return false; + if (isNumberedLyricsParagraph(s)) + return true; + } while (true); + return false; +} + + +/* Save the tag in the numberedParagraph list, stripping off braces if any */ +Static void markNumbered(Char *tag_) +{ + Char tag[256]; + + strcpy(tag, tag_); + if (LyrNum >= maxLyrNums) { + error("Too many numbered lines in the lyrics", !print); + return; + } + LyrNum++; + if (curtail(tag, '}') > 0) + delete1(tag, 1); + strcpy(numberedParagraph[LyrNum-1], tag); +/* p2c: lyrics.pas, line 104: + * Note: Possible string truncation in assignment [145] */ +} + + +/* --- end of procedures to keep track of verse numbering --- */ + +void lyricsParagraph(void) +{ + Char first[256], w[256]; + paragraph_index0 l, line; + other_index0 i; + other_index0 nother = 0; + Char other_[10][lyrtaglength + 1]; + boolean numbered; + Char STR1[256], STR3[256]; + paragraph_index0 FORLIM; + Char STR4[256]; + Char STR5[256]; + + if (!doLyrics()) + return; + if (para_len < 2) + fatalerror("empty lyrics paragraph"); + NextWord(w, P[0], blank, dummy); + l = strlen(w); + line_no = orig_line_no[0]; + if (w[l-1] != '}') + strcat(w, "}"); + GetNextWord(first, w, dummy, '}'); + while (*w != '\0') { + if (w[0] == '=') + predelete(w, 1); + if (w[0] != '{') + sprintf(w, "{%s", strcpy(STR1, w)); + nother++; + GetNextWord(other_[nother-1], w, dummy, '}'); +/* p2c: lyrics.pas, line 123: + * Note: Possible string truncation in assignment [145] */ + } + if (beVerbose()) { + printf("---- Paragraph %d starting at line %d has lyrics headed %s", + paragraph_no, line_no, first); + for (i = 0; i <= nother - 1; i++) + printf("=%s", other_[i]); + putchar('\n'); + } + sprintf(STR5, "%c Paragraph %s line %s bar %s", + comment, toString(STR1, paragraph_no), toString(STR3, line_no), + toString(STR4, bar_no)); + TeXtype2(STR5); + sprintf(STR3, "\\mtxSetLyrics%s{%%", first); + TeXtype2(STR3); + FORLIM = para_len; + for (line = 2; line <= FORLIM; line++) { + lyrTranslate(P[line-1], &numbered); + if (numbered) { + if (line > 2) + warning("Verse number not in first line of paragraph treated as lyrics", + print); + else { + markNumbered(first); + for (i = 0; i <= nother - 1; i++) + markNumbered(other_[i]); + } + } + line_no = orig_line_no[line-1]; + if (strlen(P[line-1]) > max_lyrics_line_length && pmx_preamble_done) + error("Lyrics line too long", print); + if (pmx_preamble_done) { + if (line == 2) { + sprintf(STR3, "\\\\\\:%s", P[line-1]); + put(STR3, putspace); + } else { + sprintf(STR3, "\\\\\\ %s", P[line-1]); + put(STR3, putspace); + } + } else + put(P[line-1], putspace); + if (line < para_len) { + if (pmx_preamble_done) + putLine(" %\\"); + else + putLine(" %"); + } else if (pmx_preamble_done) + putLine("}\\"); + else + putLine("}"); + } + for (i = 0; i <= nother - 1; i++) { + sprintf(STR1, "\\mtxCopyLyrics%s%s", first, other_[i]); + TeXtype2(STR1); + } +} + + +Static Char *songraise(Char *Result, voice_index voice) +{ + Char s[256]; + lyrtagtype *WITH; + lyrinfotype *WITH1; + Char STR1[256], STR3[256]; + + WITH = &tag[voice-1]; + WITH1 = &lyrinfo[voice-1]; + if (WITH->initialized == virgin && WITH1->lyr_adjust == 0) + return strcpy(Result, ""); + else { + if (WITH->auxiliary == aux) + strcpy(s, "Aux"); + else + *s = '\0'; + sprintf(Result, "\\mtx%sLyricsAdjust{%s}{%s}", + s, toString(STR1, PMXinstr(voiceStave(voice))), + toString(STR3, WITH1->lyr_adjust)); + return Result; + } +} + + +Char *lyricsReport(Char *Result, voice_index voice) +{ + Char l[256]; + lyrtagtype *WITH; + + WITH = &tag[voice-1]; + if (WITH->has_lyrics == nolyr || + WITH->lyrsource == none_given && *WITH->tags == '\0') + return strcpy(Result, " but has no own lyrics"); + else { + strcpy(l, " with "); + if (WITH->auxiliary == aux) + strcat(l, "auxiliary "); + strcat(l, "lyrics "); + if (WITH->lyrsource == local_lyrics) + strcat(l, "locally defined as \""); + else + strcat(l, "labelled \""); + sprintf(l + strlen(l), "%s\"", WITH->tags); + if (anyTagNumbered(WITH->tags)) + strcat(l, " with verse numbers"); + return strcpy(Result, l); + } +} + + +void initLyrics(void) +{ + /* at the start only */ + stave_index stave; + voice_index voice, FORLIM; + lyrinfotype *WITH; + lyrtagtype *WITH1; + stave_index FORLIM1; + + FORLIM = nvoices; + for (voice = 0; voice <= FORLIM - 1; voice++) { + WITH = &lyrinfo[voice]; + WITH1 = &tag[voice]; + WITH1->has_lyrics = nolyr; + WITH->lyr_adjust = lyr_adjust_undef; + *WITH->melisma = '\0'; + WITH->slur_level = 0; + WITH->beam_level = 0; + WITH1->auxiliary = aux; + WITH1->lyrsource = none_given; + WITH1->new_assign = asbefore; + WITH1->initialized = virgin; + } + FORLIM1 = nstaves; + for (stave = 0; stave <= FORLIM1 - 1; stave++) + oldlyrmodealter[stave] = false; +} + + +Static void registerLyrics(voice_index voice, Char *w) +{ + lyrtagtype *WITH; + + WITH = &tag[voice-1]; + strcpy(oldtag[voice-1].tags, WITH->tags); + oldtag[voice-1].lyrsource = WITH->lyrsource; + WITH->lyrsource = global_lyrics; + switch (strlen(w)) { + + case 0: + *WITH->tags = '\0'; + break; + + case 1: + fatalerror("M-Tx system error in registerLyrics"); + break; + + default: + strcpy(WITH->tags, w); + break; + } +} + + +void extractLyrtag(voice_index voice, Char *note) +{ + /* inline lyrics change */ + lyrtagtype *WITH; + Char STR1[256], STR2[256]; + + WITH = &tag[voice-1]; + if (WITH->has_lyrics == nolyr) { + error3(voice, "Inline lyrics change on no-lyrics line"); + return; + } + registerLyrics(voice, note); /* was: ''); */ + sprintf(note, "\\mtxAssignLyrics{%s}%s", + toString(STR1, PMXinstr(voiceStave(voice))), strcpy(STR2, note)); + if (WITH->auxiliary == aux) + sprintf(note, "\\mtxAuxLyr{%s}\\", strcpy(STR2, note)); + else + strcat(note, "\\"); +} + + +void clearTags(void) +{ + /* at start of paragraph analyis */ + voice_index voice, FORLIM; + lyrtagtype *WITH; + + memcpy(oldtag, tag, maxvoices * sizeof(lyrtagtype)); + FORLIM = nvoices; + for (voice = 0; voice <= FORLIM - 1; voice++) { + WITH = &tag[voice]; + WITH->lyrsource = none_given; + *WITH->tags = '\0'; + WITH->linecount = 0; + } +} + + +#define maxlyrlen (PMXlinelength - 15) + + +Local void convertlyrics(Char *lyn, voice_index voice, auxtype mx) +{ + static Char setlyr[256] = "%%\\\\\\mtxSetLyrics"; + Char btag[256], thistag[256], w[256]; + boolean numbered; + Char STR1[256]; + lyrtagtype *WITH; + Char STR2[256]; + + NextWord(w, lyn, blank, dummy); + WITH = &tag[voice-1]; + if (*w == '\0') { + *WITH->tags = '\0'; + return; + } + WITH->has_lyrics = haslyr; + WITH->auxiliary = mx; + if (w[0] == '{') { + registerLyrics(voice, w); + return; + } + WITH->lyrsource = local_lyrics; + WITH->linecount++; + toString(thistag, voice * 10 + WITH->linecount); + sprintf(btag, "{%s}", thistag); + if (*WITH->tags == '\0') + strcpy(WITH->tags, btag); + else { + WITH->tags[strlen(WITH->tags) - 1] = ','; + sprintf(WITH->tags + strlen(WITH->tags), "%s}", thistag); + } + trim(lyn); + lyrTranslate(lyn, &numbered); + if (numbered) + markNumbered(thistag); + if (strlen(lyn) + strlen(btag) > maxlyrlen) + sprintf(lyn, "%s%s{\\\n\\\\\\:%s}\\", setlyr, btag, strcpy(STR2, lyn)); + else + sprintf(lyn, "%s%s{%s}\\", setlyr, btag, strcpy(STR1, lyn)); +} + +#undef maxlyrlen + + +void maybeLyrics(voice_index voice, paragraph_index parline, Char *w_) +{ + /* during paragraph analysis, parline had L:, already stripped */ + Char w[256]; + voice_index0 k; + + /** Labelled lyrics line -- */ + strcpy(w, w_); + if (!doLyrics()) + return; + if (strlen(w) == 1 && voice == 0) + warning("Lyrics line above top voice should be labelled", print); + if (strlen(w) == 1) { /** Standard lyrics line -------- */ + k = voice; + if (k == 0) + k = 1; + convertlyrics(P[parline-1], k, normal); + return; + } + predelete(w, 1); + k = findVoice(w); + if (k == 0) + error("Lyrics line belongs to unknown voice", print); + else + convertlyrics(P[parline-1], k, aux); +} + + +void reviseLyrics(void) +{ + /* after paragraph analysis */ + voice_index voice; + stave_index stave; + voice_index FORLIM; + lyrtagtype *WITH; + stave_index FORLIM1; + + FORLIM = nvoices; + for (voice = 0; voice <= FORLIM - 1; voice++) { + WITH = &tag[voice]; + if (oldtag[voice].lyrsource == global_lyrics && + WITH->lyrsource == none_given) { + strcpy(WITH->tags, oldtag[voice].tags); + WITH->lyrsource = global_lyrics; + } + WITH->new_assign = (assigntype)(WITH->has_lyrics == haslyr && + strcmp(WITH->tags, oldtag[voice].tags)); + if (*WITH->tags == '\0') + WITH->has_lyrics = nolyr; + strcpy(oldtag[voice].tags, WITH->tags); + oldtag[voice].lyrsource = WITH->lyrsource; + } + FORLIM1 = nstaves; + for (stave = 1; stave <= FORLIM1; stave++) { + WITH = &tag[first_on_stave[stave-1] - 1]; + lyrmodealter[stave-1] = (!aloneOnStave(stave) && + WITH->has_lyrics == haslyr && + WITH->auxiliary == normal); + } +} + + +void assignLyrics(stave_index stave, Char *lyrassign) +{ + /* at start of new block */ + Char atag[256], instr[256], l[256]; + voice_index v1, v2, voice; + lyrtagtype *WITH; + Char STR2[256]; + lyrinfotype *WITH1; + + *lyrassign = '\0'; + toString(instr, PMXinstr(stave)); + v1 = first_on_stave[stave-1]; + v2 = v1 + number_on_stave[stave-1] - 1; + /* don't reassign if other voice takes over */ + if (tag[v1-1].auxiliary == tag[v2-1].auxiliary && + tag[v1-1].has_lyrics != tag[v2-1].has_lyrics) { + for (voice = v1 - 1; voice <= v2 - 1; voice++) { + WITH = &tag[voice]; + if (WITH->new_assign == newassign) + WITH->new_assign = (assigntype)WITH->has_lyrics; + } + } + for (voice = v1 - 1; voice <= v2 - 1; voice++) + lyrinfo[voice].numbered = false; + for (voice = v1; voice <= v2; voice++) { + WITH = &tag[voice-1]; + if (WITH->new_assign == newassign) { + strcpy(atag, WITH->tags); + if (*atag == '\0') + strcpy(atag, "{}"); + sprintf(l, "\\mtxAssignLyrics{%s}%s", instr, atag); + if (WITH->auxiliary == aux) + sprintf(l, "\\mtxAuxLyr{%s}", strcpy(STR2, l)); + strcat(lyrassign, l); + if (*WITH->tags == '\0') + WITH->has_lyrics = nolyr; + if (WITH->has_lyrics == haslyr && WITH->initialized == virgin) { + WITH1 = &lyrinfo[voice-1]; + if (WITH->auxiliary == aux && upper(voice)) + WITH1->lyr_adjust = interstave; + else + WITH1->lyr_adjust = 0; + strcat(lyrassign, songraise(STR2, voice)); + WITH->initialized = active; + } + if (anyTagNumbered(atag)) + lyrinfo[voice-1].numbered = true; + } + } + if (lyrmodealter[stave-1] == oldlyrmodealter[stave-1]) + return; + if (lyrmodealter[stave-1]) + sprintf(lyrassign + strlen(lyrassign), "\\mtxLyrModeAlter{%s}", instr); + else + sprintf(lyrassign + strlen(lyrassign), "\\mtxLyrModeNormal{%s}", instr); + oldlyrmodealter[stave-1] = lyrmodealter[stave-1]; +} + + +void lyricsAdjust(voice_index voice, Char *note) +{ + /* inline at-word */ + short adj; + boolean force, put_above, put_below; + lyrinfotype *WITH; + lyrtagtype *WITH1; + Char STR2[256]; + + WITH = &lyrinfo[voice-1]; + WITH1 = &tag[voice-1]; + predelete(note, 1); + force = (note[0] == '='); + if (force) + predelete(note, 1); + put_above = (note[0] == '^'); + if (put_above) + predelete(note, 1); + put_below = (note[0] == 'v'); + if (put_below) + predelete(note, 1); + if (*note != '\0') + getNum(note, &adj); + else + adj = 0; + if (WITH1->has_lyrics == nolyr) { + *note = '\0'; + return; + } + if (put_above) + WITH->lyr_adjust = interstave; + else if (put_below) + WITH->lyr_adjust = 0; + if (force) + WITH->lyr_adjust = adj; + else + WITH->lyr_adjust += adj; + songraise(note, voice); + if (*note != '\0') + sprintf(note, "\\\\%s\\", strcpy(STR2, note)); +} + + +void lyrTranslate(Char *P, boolean *numbered) +{ /* Test for starting number */ + short k, l, number; + Char Q[256], w[256]; + + NextWord(w, P, blank, dummy); + *numbered = false; + if (endsWith(w, ".")) { + getNum(w, &number); + *numbered = (number != 0); + } + /*Translate lyrics link */ + *Q = '\0'; + l = strlen(P); + for (k = 1; k <= l - 1; k++) { + if (P[k-1] != '_' || P[k] == '_' || P[k] == ' ' || pos1(P[k], digits) > 0) + sprintf(Q + strlen(Q), "%c", P[k-1]); + else if (k > 1 && P[k-2] == '\\') + strcat(Q, "mtxLowLyrlink "); + else + strcat(Q, "\\mtxLyrlink "); + } + sprintf(Q + strlen(Q), "%c", P[l-1]); + strcpy(P, Q); +} + + +typedef enum { + beam, slur +} melismaEnd; + + +Static Char removeLast(Char *s, Char *t) +{ + Char Result; + short i, l; + + l = strlen(s); + for (i = l; i >= 1; i--) { + if (pos1(s[i-1], t) > 0) { + Result = s[i-1]; + delete1(s, i); + return Result; + } + } + return dummy; +} + + +Static boolean OpenMelisma(Char *s) +{ + return (pos1(slur_melisma, s) > 0 || pos1(beam_melisma, s) > 0); +} + + +/* Local variables for getSyllable: */ +struct LOC_getSyllable { + voice_index voice; + boolean BM, EM; +} ; + +Local void startMelismas(Char *t, struct LOC_getSyllable *LINK) +{ + boolean open_before, open_now; + short i, k; + lyrinfotype *WITH; + + k = strlen(t); + for (i = 0; i <= k - 1; i++) { + WITH = &lyrinfo[LINK->voice-1]; + open_before = OpenMelisma(WITH->melisma); + sprintf(WITH->melisma + strlen(WITH->melisma), "%c", t[i]); + open_now = OpenMelisma(WITH->melisma); + LINK->BM = (LINK->BM || open_now && !open_before); + } +} + +Local boolean endMelisma(short voice, struct LOC_getSyllable *LINK) +{ + Char found; + short i; + short count[2]; + melismaEnd t; + short FORLIM1; + lyrinfotype *WITH; + Char STR1[4]; + + LINK->EM = false; + count[(long)slur] = -lyrinfo[voice-1].slur_change; + count[(long)beam] = -lyrinfo[voice-1].beam_change; + for (t = beam; t <= slur; t = (melismaEnd)((long)t + 1)) { + FORLIM1 = count[(long)t]; + for (i = 1; i <= FORLIM1; i++) { + WITH = &lyrinfo[voice-1]; + switch (t) { + + case slur: + sprintf(STR1, "%c%c", slur_melisma, inhibit_slur_melisma); + found = removeLast(WITH->melisma, STR1); + break; + + case beam: + sprintf(STR1, "%c%c", beam_melisma, inhibit_beam_melisma); + found = removeLast(WITH->melisma, STR1); + break; + } + if (found == dummy) + error3(voice, "Ending a melisma that was never started"); + LINK->EM = (LINK->EM || + (!OpenMelisma(WITH->melisma) && + pos1(found, (sprintf(STR1, "%c%c", slur_melisma, beam_melisma), + STR1)) > 0)); + } + } + return LINK->EM; +} + +Local void startSlurMelisma(voice_index voice, struct LOC_getSyllable *LINK) +{ + static Char start[2] = { + slur_melisma, inhibit_slur_melisma + }; + + Char slurs[256]; + short k, FORLIM; + Char STR1[256]; + + *slurs = '\0'; + FORLIM = lyrinfo[voice-1].slur_change; + for (k = 1; k <= FORLIM; k++) + sprintf(slurs, "%c%s", + start[noSlurMelisma(voice, 1 - k)], strcpy(STR1, slurs)); + startMelismas(slurs, LINK); +} + +Local void startBeamMelisma(voice_index voice, struct LOC_getSyllable *LINK) +{ + static Char start[2] = { + beam_melisma, inhibit_beam_melisma + }; + + Char beams[256]; + short k, FORLIM; + Char STR1[256]; + + *beams = '\0'; + FORLIM = lyrinfo[voice-1].beam_change; + for (k = 1; k <= FORLIM; k++) + sprintf(beams, "%c%s", start[noBeamMelisma(voice)], strcpy(STR1, beams)); + startMelismas(beams, LINK); +} + +Local boolean startMelisma(short voice, struct LOC_getSyllable *LINK) +{ + LINK->BM = false; + startSlurMelisma(voice, LINK); + startBeamMelisma(voice, LINK); + return LINK->BM; +} + + +/* Append mtxBM or mtxEM to pretex when appropriate */ +void getSyllable(voice_index voice_, Char *pretex) +{ + struct LOC_getSyllable V; + short t; + lyrtagtype *WITH; + lyrinfotype *WITH1; + + V.voice = voice_; + WITH = &tag[V.voice-1]; + WITH1 = &lyrinfo[V.voice-1]; + if (WITH->has_lyrics != haslyr) + return; + t = WITH1->slur_level; + WITH1->slur_level = slurLevel(V.voice); + WITH1->slur_change = WITH1->slur_level - t; + t = WITH1->beam_level; + WITH1->beam_level = beamLevel(V.voice); + WITH1->beam_change = WITH1->beam_level - t; + if (startMelisma(V.voice, &V)) { + if (WITH->auxiliary == aux) + strcat(pretex, "\\mtxAuxBM"); + else + strcat(pretex, "\\mtxBM"); + } + if (!endMelisma(V.voice, &V)) + return; + if (WITH->auxiliary == aux) + strcat(pretex, "\\mtxAuxEM"); + else + strcat(pretex, "\\mtxEM"); +} + + +Static void getSyllable1(voice_index voice, Char *pretex) +{ + lyrinfotype *WITH; + + WITH = &lyrinfo[voice-1]; + printf("voice=%d, slurchange=%d, melisma=%s, beamchange=%d\n", + voice, WITH->slur_change, WITH->melisma, WITH->beam_change); + getSyllable1(voice, pretex); + if (*pretex != '\0') + printf("pretex = %s\n", pretex); +} + + + + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/lyrics.h b/Build/source/utils/m-tx/mtx-src/lyrics.h new file mode 100644 index 00000000000..89ab1532cb6 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/lyrics.h @@ -0,0 +1,37 @@ +/* Header for module lyrics, generated by p2c 1.21alpha-07.Dec.93 */ +#ifndef LYRICS_H +#define LYRICS_H + + +/* Everything related to lyrics */ + +#ifndef GLOBALS_H +#include "globals.h" +#endif + + +#ifdef LYRICS_G +# define vextern +#else +# define vextern extern +#endif + +extern void initLyrics(void); +extern void clearTags(void); +extern void reviseLyrics(void); +extern void lyrTranslate(Char *P, boolean *numbered); +extern void getSyllable(voice_index voice, Char *pretex); +extern Char *lyricsReport(Char *Result, voice_index voice); +extern void maybeLyrics(voice_index voice, paragraph_index parline, Char *w); +extern void extractLyrtag(voice_index voice, Char *note); +extern void lyricsAdjust(voice_index voice, Char *note); +extern void assignLyrics(stave_index stave, Char *lyrassign); +extern void lyricsParagraph(void); +extern boolean hasVerseNumber(voice_index voice); + + +#undef vextern + +#endif /*LYRICS_H*/ + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/lyrics.pas b/Build/source/utils/m-tx/mtx-src/lyrics.pas new file mode 100644 index 00000000000..51253b222d7 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/lyrics.pas @@ -0,0 +1,456 @@ +unit lyrics; +{ Everything related to lyrics } + +interface uses globals; + +procedure initLyrics; +procedure clearTags; +procedure reviseLyrics; +procedure lyrTranslate(var P: string; var numbered: boolean); +procedure getSyllable(voice: voice_index; var pretex: string); +function lyricsReport (voice: voice_index): string; +procedure maybeLyrics (voice: voice_index; parline: paragraph_index; + w: string); +procedure extractLyrtag (voice: voice_index; var note: string); +procedure lyricsAdjust (voice: voice_index; var note: string); +procedure assignLyrics(stave: stave_index; var lyrassign: string); +procedure lyricsParagraph; +function hasVerseNumber(voice: voice_index): boolean; + +implementation uses control, strings, mtxline, status, files, utility; + +{ Symbols used in strings of melismatype } +const + beam_melisma = '['; + inhibit_beam_melisma = '<'; + slur_melisma = '('; + inhibit_slur_melisma = '{'; + +type + other_index = 1..10; + other_index0 = 0..10; + melismatype = string; + haslyrtype = (nolyr, haslyr); + auxtype= (normal, aux); + assigntype = (asbefore, newassign); + inittype = (virgin,active); + lyrinfotype = record + lyr_adjust, slur_level, slur_change, beam_level, beam_change: integer; + melisma: melismatype; + numbered: boolean; + end; + + lyrlinetype = (none_given, global_lyrics, local_lyrics); + lyrtagtype = record + lyrsource: lyrlinetype; + has_lyrics: haslyrtype; + auxiliary: auxtype; + new_assign: assigntype; + initialized: inittype; + linecount: integer; + tags: string; + end; + +const maxLyrNums=64; + lyrtaglength=40; + LyrNum: integer=0; + +var lyrmodealter, oldlyrmodealter: array[stave_index] of boolean; + tag, oldtag: array[voice_index] of lyrtagtype; + lyrinfo: array[voice_index] of lyrinfotype; + numberedParagraph: array[1..maxLyrNums] of string[lyrtaglength]; + +const lyr_adjust_undef = -12345; + interstave = 24; + +{ Information flow for verse numbers: at the SetLyrics stage, the first +line of each lyrics paragraph is checked for a verse number, and if +found, the paragraph tag is remembered. At the AssignLyrics stage, +the first time that paragraph is encountered, the particular voice +is marked in lyrinfo as being numbered. When that voice is later processed, +the mark in lyrinfo is interrogated and turned off: if it was on, the +mtxVerse pre-TeX string is put into the output. } + +function hasVerseNumber(voice: voice_index): boolean; +begin hasVerseNumber:=lyrinfo[voice].numbered; + lyrinfo[voice].numbered:=false; +end; + +function isNumberedLyricsParagraph(tag: string): boolean; + var i: integer; +begin + for i:=1 to LyrNum do if tag=numberedParagraph[i] then + begin isNumberedLyricsParagraph:=true; exit; end; + isNumberedLyricsParagraph:=false; +end; + +function anyTagNumbered(tags: string): boolean; + var s: string; +begin anyTagNumbered:=false; + if curtail(tags,'}')>0 then delete1(tags,1); + repeat s:=getNextWord(tags,',',dummy); + if s='' then exit; + if isNumberedLyricsParagraph(s) then + begin anyTagNumbered:=true; exit; end; + until false; +end; + +{ Save the tag in the numberedParagraph list, stripping off braces if any } +procedure markNumbered(tag: string); +begin if LyrNum >= maxLyrNums then + begin error('Too many numbered lines in the lyrics',not print); exit; end; + inc(LyrNum); + if curtail(tag,'}')>0 then delete1(tag,1); + numberedParagraph[LyrNum] := tag; +end; + +{ --- end of procedures to keep track of verse numbering --- } + +procedure lyricsParagraph; + var first, w: string; + l, line: paragraph_index0; + i, nother: other_index0; + other: array[other_index] of string[lyrtaglength]; + numbered: boolean; +begin if not doLyrics then exit; + if para_len<2 then fatalerror('empty lyrics paragraph'); + w:=NextWord(P[1],blank,dummy); l:=length(w); line_no := orig_line_no[1]; + if w[l]<>'}' then w:=w+'}'; + first:=GetNextWord(w,dummy,'}'); nother:=0; + while w<>'' do + begin if w[1]='=' then predelete(w,1); + if w[1]<>'{' then w:='{'+w; + inc(nother); other[nother]:=GetNextWord(w,dummy,'}'); + end; + if beVerbose then + begin write('---- Paragraph ', paragraph_no, ' starting at line ', line_no, + ' has lyrics headed ',first); + for i:=1 to nother do write('=',other[i]); writeln; + end; + TeXtype2(comment+' Paragraph '+toString(paragraph_no)+' line '+ + toString(line_no)+' bar '+toString(bar_no)); + TeXtype2('\mtxSetLyrics'+first+'{%'); + for line:=2 to para_len do + begin lyrTranslate(P[line],numbered); + if numbered then if (line>2) then warning( + 'Verse number not in first line of paragraph treated as lyrics',print) + else + begin markNumbered(first); for i:=1 to nother do markNumbered(other[i]); + end; + line_no:=orig_line_no[line]; + if (length(P[line])>max_lyrics_line_length) and pmx_preamble_done + then error('Lyrics line too long',print); + if pmx_preamble_done then + if line=2 then put('\\\:'+P[line],putspace) + else put('\\\ ' + P[line],putspace) + else put(P[line],putspace); + if linemaxlyrlen then + lyn := setlyr + btag + '{\'^J'\\\:' + lyn +'}\' + else lyn:= setlyr + btag + '{' + lyn +'}\'; + end; + end; + end; + end; +begin if not dolyrics then exit; + if (length(w)=1) and (voice=0) then + warning('Lyrics line above top voice should be labelled',print); + if length(w)=1 then {* Standard lyrics line -------- } + begin k:=voice; if k=0 then k:=1; convertlyrics(P[parline],k,normal); + end + else {* Labelled lyrics line -- } + begin predelete(w,1); k:=findVoice(w); + if k=0 then error('Lyrics line belongs to unknown voice',print) + else convertlyrics(P[parline],k,aux); + end; +end; + +procedure reviseLyrics; { after paragraph analysis } + var voice : voice_index; + stave : stave_index; +begin + for voice:=1 to nvoices do with tag[voice] do + begin if (oldtag[voice].lyrsource=global_lyrics) and + (lyrsource=none_given) then + begin tags:=oldtag[voice].tags; lyrsource:=global_lyrics; end; + new_assign := + assigntype(ord((has_lyrics=haslyr) and (tags<>oldtag[voice].tags))); + if tags='' then has_lyrics := nolyr; + oldtag[voice].tags := tags; + oldtag[voice].lyrsource := lyrsource; + end; + for stave:=1 to nstaves do with tag[first_on_stave[stave]] do + lyrmodealter[stave] := not aloneOnStave(stave) and + (has_lyrics=haslyr) and (auxiliary=normal); +end; + +procedure assignLyrics(stave: stave_index; var lyrassign: string); + { at start of new block } + var atag, instr, l: string; + v1, v2, voice: voice_index; + begin lyrassign:=''; instr := toString(pmxinstr(stave)); + v1:=first_on_stave[stave]; v2:=v1+number_on_stave[stave]-1; + if v1tag[v2].has_lyrics) then + for voice:=v1 to v2 do with tag[voice] do + if new_assign=newassign then new_assign:=assigntype(has_lyrics); + for voice:=v1 to v2 do lyrinfo[voice].numbered:=false; + for voice:=v1 to v2 do + with tag[voice] do if new_assign=newassign then + begin atag:=tags; if atag='' then atag:='{}'; + l := '\mtxAssignLyrics{' + instr + '}' + atag; + if auxiliary=aux then l:='\mtxAuxLyr{' + l + '}'; + lyrassign := lyrassign + l; + if tags='' then has_lyrics:=nolyr; + if (has_lyrics=haslyr) and (initialized=virgin) then + with lyrinfo[voice] do + begin if (auxiliary=aux) and upper(voice) then + lyr_adjust:=interstave else lyr_adjust:=0; + lyrassign := lyrassign + songraise(voice); + initialized := active; + end; + if anyTagNumbered(atag) then lyrinfo[voice].numbered:=true; + end; + if lyrmodealter[stave]<>oldlyrmodealter[stave] then + begin if lyrmodealter[stave] then + lyrassign := lyrassign + '\mtxLyrModeAlter{' + instr + '}' + else lyrassign := lyrassign + '\mtxLyrModeNormal{' + instr + '}'; + oldlyrmodealter[stave] := lyrmodealter[stave]; + end; + end; + +procedure lyricsAdjust (voice: voice_index; var note: string); + { inline at-word } + var adj: integer; + force, put_above, put_below: boolean; +begin with lyrinfo[voice] do with tag[voice] do + begin predelete(note,1); + force:=note[1]='='; if force then predelete(note,1); + put_above:=note[1]='^'; if put_above then predelete(note,1); + put_below:=note[1]='v'; if put_below then predelete(note,1); + if note<>'' then getNum(note,adj) else adj:=0; + if has_lyrics=nolyr then begin note:=''; exit; end; + if put_above then lyr_adjust:=interstave + else if put_below then lyr_adjust:=0; + if force then lyr_adjust:=adj else inc(lyr_adjust,adj); + note:=songraise(voice); if note<>'' then note:='\\'+note+'\'; + end +end; + +procedure lyrTranslate(var P: string; var numbered: boolean); + var k, l, number: integer; + Q, w: string; +begin { Test for starting number } w:=NextWord(P,blank,dummy); + numbered:=false; + if endsWith(w,'.') then begin getNum(w,number); numbered:=number<>0 end; + {Translate lyrics link } Q := ''; l:=length(P); + for k:=1 to l-1 do + if (P[k]<>'_') or (P[k+1]='_') or (P[k+1]=' ') or (pos1(P[k+1],digits)>0) + then Q := Q+P[k] + else if (k>1) and (P[k-1]='\') then Q := Q+'mtxLowLyrlink ' + else Q := Q+'\mtxLyrlink '; + Q:=Q+P[l]; + P := Q; +end; + +type melismaEnd = (beam, slur); + +function removeLast(var s: string; t: string): char; + var i,l: integer; +begin l:=length(s); + for i:=l downto 1 do if pos1(s[i],t)>0 then + begin removeLast:=s[i]; delete1(s,i); exit; end; + removeLast := dummy; +end; + +function OpenMelisma(s: string): boolean; +begin OpenMelisma := (pos1(slur_melisma,s)>0) or (pos1(beam_melisma,s)>0); +end; + +{ Append mtxBM or mtxEM to pretex when appropriate } +procedure getSyllable(voice: voice_index; var pretex: string); + var BM, EM: boolean; + procedure startMelismas (t: string); + var open_before, open_now: boolean; + i, k: integer; + begin k:=length(t); + for i:=1 to k do with lyrinfo[voice] do + begin open_before := OpenMelisma(melisma); + melisma := melisma + t[i]; + open_now := OpenMelisma(melisma); + BM := BM or (open_now and not open_before) + end; + end; + function endMelisma(voice: integer): boolean; + var found: char; + i: integer; + count: array[melismaEnd] of integer; + t: melismaEnd; + begin EM := false; + count[slur] := -lyrinfo[voice].slur_change; + count[beam] := -lyrinfo[voice].beam_change; + for t:=beam to slur do for i:=1 to count[t] do with lyrinfo[voice] do + begin + case t of + slur: found := removeLast(melisma,slur_melisma+inhibit_slur_melisma); + beam: found := removeLast(melisma,beam_melisma+inhibit_beam_melisma); + end; + if found=dummy then + error3(voice,'Ending a melisma that was never started'); + EM := EM or (not openMelisma(melisma) + and (pos1(found,slur_melisma+beam_melisma)>0)) + end; + endMelisma := EM + end; + procedure startSlurMelisma(voice: voice_index); + const start: array[boolean] of char = (slur_melisma,inhibit_slur_melisma); + var slurs: string; + k: integer; + begin slurs:=''; + for k:=1 to lyrinfo[voice].slur_change do + slurs:=start[noSlurMelisma(voice,1-k)]+slurs; + startMelismas(slurs) + end; + procedure startBeamMelisma(voice: voice_index); + const start: array[boolean] of char = (beam_melisma,inhibit_beam_melisma); + var beams: string; + k: integer; + begin beams:=''; + for k:=1 to lyrinfo[voice].beam_change do + beams:=start[noBeamMelisma(voice)]+beams; + startMelismas(beams) + end; + function startMelisma(voice: integer): boolean; + begin BM:=false; startSlurMelisma(voice); startBeamMelisma(voice); + startMelisma := BM + end; + var t: integer; +begin with tag[voice] do with lyrinfo[voice] do + begin if has_lyrics<>haslyr then exit; + t:=slur_level; slur_level:=slurLevel(voice); slur_change:=slur_level-t; + t:=beam_level; beam_level:=beamLevel(voice); beam_change:=beam_level-t; + if startMelisma(voice) then if auxiliary=aux + then pretex:=pretex+'\mtxAuxBM' else pretex:=pretex+'\mtxBM'; + if endMelisma(voice) then if auxiliary=aux + then pretex:=pretex+'\mtxAuxEM' else pretex:=pretex+'\mtxEM' + end +end; + +procedure getSyllable1(voice: voice_index; var pretex: string); +begin with lyrinfo[voice] do + begin + writeln('voice=',voice, ', slurchange=',slur_change, + ', melisma=',melisma, ', beamchange=', beam_change) + end; + getSyllable1(voice,pretex); + if pretex<>'' then writeln('pretex = ',pretex) +end; + +end. diff --git a/Build/source/utils/m-tx/mtx-src/mtx.c b/Build/source/utils/m-tx/mtx-src/mtx.c new file mode 100644 index 00000000000..12d9c089e5d --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/mtx.c @@ -0,0 +1,481 @@ +/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ +/* From input file "mtx.pas" */ + + + +#include "p2c.h" + +#define MTX_G +#include "mtx.h" + + +#ifndef CONTROL_H +#include "control.h" +#endif + +#ifndef MTXLINE_H +#include "mtxline.h" +#endif + +#ifndef STRINGS_H +#include "strings.h" +#endif + +#ifndef STATUS_H +#include "status.h" +#endif + +#ifndef NOTES_H +#include "notes.h" +#endif + + +#define flagged "8136" + + +typedef boolean sticky['z' + 1 - 'a']; + + +Static sticky note_attrib[maxvoices], rest_attrib[maxvoices]; + + +Static short logTwo(short denom) +{ + short l = 0; + + while (denom > 1) { + l++; + denom /= 2; + } + return l; +} + + +Local boolean dotted(short n) +{ + boolean Result; + +/* p2c: mtx.pas: Note: Eliminated unused assignment statement [338] */ + if (n == 0) + return false; + if (n != n / 3 * 3) + return false; + n /= 3; + while ((n & 1) == 0) + n /= 2; + return (n == 1); +} + + +/* RESTS should have a third parameter OFFSET. At present we in effect + assume OFFSET+LENGTH to be a multiple of METERDENOM. */ +Char *rests(Char *Result, short len, short meterdenom, boolean blind) +{ + Char r[256], bl[256]; + Char STR1[256]; + + if (blind) + strcpy(bl, "b"); + else + *bl = '\0'; + if (len == 0) + return strcpy(Result, ""); + else { + if (len == meterdenom * 128) { + sprintf(Result, "r9%s ", bl); + return Result; + } else { + if (dotted(len)) { + rests(r, len - len / 3, meterdenom, false); + r[2] = 'd'; + sprintf(Result, "%s%s ", r, bl); + return Result; + } else if (len >= 64 / meterdenom) { + sprintf(Result, "%sr%c%s ", + rests(STR1, len - 64 / meterdenom, meterdenom, blind), + durations[whole + logTwo(meterdenom) - 1], bl); + return Result; + } else + return (rests(Result, len, meterdenom * 2, blind)); + } + } +} + + +Local Char *attribs(Char *Result, Char *note) +{ + Char a[256]; + short i = 2; + short l; + Char n; + + *a = '\0'; + l = strlen(note); + while (i <= l) { + n = note[i-1]; + if (n == 'x') + i = l; + else if (islower(n)) + sprintf(a + strlen(a), "%c", n); + i++; + } + return strcpy(Result, a); +} + + +Static void checkSticky(Char *note, boolean *attrib) +{ + short i = 2; + short l; + Char c; + Char a[256]; + + if (*note == '\0') + return; + l = strlen(note); + while (i <= l) { + c = note[i-1]; + if (islower(c)) { + if (i < l && note[i] == ':') { + delete1(note, i + 1); + l--; + attrib[c - 'a'] = !attrib[c - 'a']; + } else + attrib[c - 'a'] = false; + } + i++; + } + attribs(a, note); + for (c = 'z'; c >= 'a'; c--) { + if (attrib[c - 'a'] && pos1(c, a) == 0) + insertChar(c, note, 3); + } +} + + +/* Routine was patched by Hiroaki Morimoto, revised 2003/08/15. + Rewritten by DPL 2004/05/16 to be more understandable. + octaveCode returns octave adjustments in the order + [absolute or =],[relative] */ +void checkOctave(voice_index voice, Char *note) +{ + Char code; + + code = octaveCode(note); + if (code == '=') { + setOctave(voice); + removeOctaveCode(code, note); + } + if (octave(voice) == blank) + return; + code = octaveCode(note); + if (isdigit(code)) { + resetOctave(voice); + return; + } + while (code == '+' || code == '-') { + newOctave(voice, code); + removeOctaveCode(code, note); + code = octaveCode(note); + } + if (code != ' ') + error3(voice, "You may have only one absolute octave assignment"); + insertOctaveCode(octave(voice), note); + checkRange(voice, note); + resetOctave(voice); +} + + +void markDebeamed(voice_index voice, Char *note) +{ + if (isVocal(voice) && afterSlur(voice) == 0 && unbeamVocal() && + pos1(duration(voice), flagged) > 0) + insertChar('a', note, 2); +} + + +Static short barLength(Char *meter) +{ + short n1, n2, pn1, pn2; + + getMeter(meter, &n1, &n2, &pn1, &pn2); + return (n1 * (64 / n2)); +} + + +Static boolean isMultiBarRest(Char *rest_) +{ + boolean Result; + +/* p2c: mtx.pas: Note: Eliminated unused assignment statement [338] */ + if (strlen(rest_) < 3) + return false; + if (rest_[1] != 'm') + return false; + if (multi_bar_rest) + error("Only one multibar rest allowed per line", print); + multi_bar_rest = true; + return true; +} + + +/* Double-length in xtuplet detected by a brute search for D anywhere. + Could be more elegant. */ + +Static short macro_length[20]; + +Static Char macro_ID[20][3] = { + "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", + "15", "16", "17", "18", "19", "20" +}; + + +/* Local variables for scanMusic: */ +struct LOC_scanMusic { + voice_index voice; + Char note[256]; + boolean doublex, store_macro; + short bar, old_length, bar_length, count, l, mlen, ngrace, nmulti, macroID, + playID; + Char macro_type; +} ; + +Local void decmulti(struct LOC_scanMusic *LINK) +{ + if (LINK->doublex) + LINK->nmulti -= 2; + else + LINK->nmulti--; +} + +/* Local variables for countIt: */ +struct LOC_countIt { + struct LOC_scanMusic *LINK; +} ; + +Local void incbar(short nl, struct LOC_countIt *LINK) +{ + LINK->LINK->bar_length += nl; + if (LINK->LINK->bar_length > LINK->LINK->bar && meternum > 0) + error3(LINK->LINK->voice, "Bar end occurs in mid-note"); +} + +Local void countIt(struct LOC_scanMusic *LINK) +{ + struct LOC_countIt V; + + V.LINK = LINK; + if (LINK->ngrace > 0) { + LINK->ngrace--; + return; + } + if (LINK->nmulti > 0) { + decmulti(LINK); + return; + } + if (LINK->count % 3 != 0 && + (LINK->note[0] != rest && note_attrib[LINK->voice-1]['d' - 'a'] || + LINK->note[0] == rest && rest_attrib[LINK->voice-1]['d' - 'a'])) + LINK->count += LINK->count / 2; +/* p2c: mtx.pas, line 150: + * Note: Using % for possibly-negative arguments [317] */ + incbar(LINK->count, &V); + LINK->l = pos1(multi_group, LINK->note); + if (LINK->l <= 0) + return; + predelete(LINK->note, LINK->l); + getNum(LINK->note, &LINK->nmulti); + decmulti(LINK); +} + +Local void maybeGroup(struct LOC_scanMusic *LINK) +{ + if (LINK->note[0] != grace_group) + return; + if (strlen(LINK->note) == 1) + LINK->ngrace = 1; + else + LINK->ngrace = pos1(LINK->note[1], digits); + /* bug if ngrace>9 */ + if (LINK->ngrace > 0) + LINK->ngrace--; +} + +Local short identifyMacro(Char *s_, struct LOC_scanMusic *LINK) +{ + Char s[256]; + short k; + + strcpy(s, s_); + predelete(s, 2); + for (k = 1; k <= 20; k++) { + if (!strcmp(s, macro_ID[k-1])) + return k; + } + return 0; +} + +Local void examineMacro(struct LOC_scanMusic *LINK) +{ + if (!countMacro()) + return; + if (debugMode()) + printf("%s: ", LINK->note); + if (strlen(LINK->note) == 1) { + LINK->mlen = LINK->bar_length - LINK->old_length; + if (LINK->macroID < 1 || LINK->macroID > 20) + error3(LINK->voice, "Invalid macro ID"); + macro_length[LINK->macroID-1] = LINK->mlen; + if (debugMode()) + printf("Ending macro %d of type %c, length=%d\n", + LINK->macroID, LINK->macro_type, LINK->mlen); + if (LINK->macro_type == 'S') + LINK->bar_length = LINK->old_length; + LINK->store_macro = false; + return; + } + LINK->playID = identifyMacro(LINK->note, LINK); + if (LINK->playID < 1 || LINK->playID > 20) + error3(LINK->voice, "Invalid macro ID"); + if (LINK->note[1] == 'P') { + if (debugMode()) + printf("Playing macro %d of length %d\n", + LINK->playID, macro_length[LINK->playID-1]); + LINK->bar_length += macro_length[LINK->playID-1]; + return; + } + if (pos1(LINK->note[1], "SR") <= 0) + return; + LINK->old_length = LINK->bar_length; + LINK->macro_type = LINK->note[1]; + LINK->macroID = LINK->playID; + LINK->store_macro = true; + if (debugMode()) + printf("Defining macro %d of type %c\n", LINK->macroID, LINK->note[1]); +} + + +void scanMusic(voice_index voice_, short *left_over) +{ + struct LOC_scanMusic V; + Char buf[256], enote[256], xnote[256]; + boolean has_next = false, done = false; + Char dur1, lastdur; + music_word nscan; + Char STR1[256]; + + V.voice = voice_; + strcpy(terminators, "d.x"); + resetInfo(V.voice, buf); + *left_over = 0; + V.store_macro = false; + V.bar = full_bar; + V.bar_length = 0; + V.ngrace = 0; + V.nmulti = 0; + if (meternum == 0) + V.bar = 32000; + dur1 = duration(V.voice); + lastdur = dur1; + do { + getNextMusWord(buf, V.note, &nscan); + if (*V.note == '\0') + break; + V.count = 0; + /* if isNoteOrRest(note) and not (isPause(note) or isMultibarRest(note)) + then note:=toStandard(note); */ + V.doublex = (pos1('D', V.note) > 0); + if (nscan == mword) { + if (*V.note == '\0') + error3(V.voice, "You may not end a line with a meter change"); + if (V.bar_length > 0) + error3(V.voice, "Meter change only allowed at start of bar"); + else + V.bar = barLength(V.note); + } else if (nscan == rword) { + if (!(isPause(V.note) || isMultiBarRest(V.note))) { + processNote(V.note, xnote, dur1, &lastdur, &V.count); + checkSticky(V.note, rest_attrib[V.voice-1]); + } + } + if (*V.note != '\0') + appendNote(V.voice, nscan); + strcpy(enote, V.note); + if (nscan == macro || nscan == endmacro) + examineMacro(&V); + if (nscan == abcdefg) { + if (!multi_bar_rest && V.ngrace + V.nmulti == 0) { + processNote(enote, xnote, dur1, &lastdur, &V.count); + if (*xnote != '\0') { + checkSticky(enote, note_attrib[V.voice-1]); + appendToLine(V.voice, enote); + appendNote(V.voice, nscan); + strcpy(enote, xnote); + } + checkSticky(enote, note_attrib[V.voice-1]); + } + } + appendToLine(V.voice, enote); + if (*V.note == '\0') /* !!! else word_bound[here]:=length(line); */ + done = true; + sprintf(STR1, "%c", barsym); + if (!strcmp(V.note, STR1)) { + if (meternum == 0) + error3(V.voice, "You may not use bar lines in barless music"); + else if (V.bar_length == 0) + markBar(V.voice); + else if (numberOfBars(V.voice) == 0 && V.bar_length < V.bar) { + if (has_next) + has_next = false; /*Should check whether pickups are equal*/ + else if (*left_over > 0) + error3(V.voice, "Bar is too short"); + *left_over = V.bar_length; + V.bar_length = 0; + } + } + if (nscan == nextvoice) { + if (V.bar_length > 0) + error3(V.voice, "Next voice before bar is full"); + else + barForward(V.voice, -1); + has_next = true; + } else if (isPause(V.note)) + V.bar_length += V.bar; + else if (!multi_bar_rest) { /*do nothing*/ + if (!done && isNoteOrRest(V.note)) + countIt(&V); + else + maybeGroup(&V); + } + dur1 = lastdur; + if (V.bar_length >= V.bar && V.ngrace + V.nmulti == 0 && !V.store_macro) { + if (debugMode()) + printf("%d %d\n", V.voice, V.bar_length); + barForward(V.voice, V.bar_length / V.bar); + V.bar_length %= V.bar; +/* p2c: mtx.pas, line 268: + * Note: Using % for possibly-negative arguments [317] */ + } + } while (!done); + setExtraLength(V.voice, V.bar_length); + resetDuration(V.voice, dur1); + regroup(V.voice); +} + + +void initMTX(void) +{ + voice_index i; + Char j; + + for (i = 0; i <= maxvoices - 1; i++) { + for (j = 'a'; j <= 'z'; j++) + note_attrib[i][j - 'a'] = false; + } + memcpy(rest_attrib, note_attrib, maxvoices * sizeof(sticky)); +} + + + + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/mtx.h b/Build/source/utils/m-tx/mtx-src/mtx.h new file mode 100644 index 00000000000..a056afd9b3a --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/mtx.h @@ -0,0 +1,30 @@ +/* Header for module mtx, generated by p2c 1.21alpha-07.Dec.93 */ +#ifndef MTX_H +#define MTX_H + + +/* Details of M-Tx -> PMX translation */ + +#ifndef GLOBALS_H +#include "globals.h" +#endif + + +#ifdef MTX_G +# define vextern +#else +# define vextern extern +#endif + +extern void scanMusic(voice_index voice, short *left_over); +extern void markDebeamed(voice_index voice, Char *note); +extern void checkOctave(voice_index voice, Char *note); +extern Char *rests(Char *Result, short len, short meterdenom, boolean blind); +extern void initMTX(void); + + +#undef vextern + +#endif /*MTX_H*/ + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/mtx.pas b/Build/source/utils/m-tx/mtx-src/mtx.pas new file mode 100644 index 00000000000..0b1b1042cd4 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/mtx.pas @@ -0,0 +1,282 @@ +unit mtx; +{ Details of M-Tx -> PMX translation } + +interface uses globals; + +procedure scanMusic(voice: voice_index; var left_over: integer); +procedure markDebeamed(voice: voice_index; var note: string); +procedure checkOctave(voice: voice_index; var note: string); +function rests (len, meterdenom: integer; blind: boolean): string; +procedure initMTX; + +implementation uses control, mtxline, strings, status, notes; + +const flagged = '8136'; + +type sticky = array['a'..'z'] of boolean; + +var note_attrib, rest_attrib: array[voice_index] of sticky; + +function logTwo(denom: integer): integer; + var l: integer; +begin l:=0; while denom>1 do begin inc(l); denom:=denom div 2; end; + logtwo:=l; +end; + +{ RESTS should have a third parameter OFFSET. At present we in effect + assume OFFSET+LENGTH to be a multiple of METERDENOM. } +function rests (len, meterdenom: integer; blind: boolean): string; + var r, bl: string; + function dotted(n: integer): boolean; + begin dotted:=false; if n=0 then exit; + if n<>3*(n div 3) then exit; + n:=n div 3; while n mod 2 = 0 do n:=n div 2; + dotted := n=1; + end; + begin if blind then bl:='b' else bl:=''; + if len=0 then rests:='' else + if len=128*meterdenom then rests:='r9'+bl+' ' else + if dotted(len) then + begin r:=rests(len-len div 3,meterdenom,false); + r[3]:='d'; rests:=r+bl+' '; + end + else if len>=64 div meterdenom then + rests:=rests(len-64 div meterdenom,meterdenom,blind)+'r' + +durations[whole+logtwo(meterdenom)]+bl+' ' + else rests:=rests(len,meterdenom*2,blind); + end; + +procedure checkSticky(var note: string; var attrib: sticky); + var i,l: integer; + c: char; + a: string; + function attribs(note: string): string; + var a: string; + i,l: integer; + n: char; + begin a:=''; i:=2; l:=length(note); + while i<=l do + begin n:=note[i]; + if n='x' then i:=l else if (n>='a') and (n<='z') then a:=a+n; + inc(i); + end; + attribs:=a; + end; +begin if note='' then exit; + l:=length(note); i:=2; + while i<=l do + begin c:=note[i]; + if (c>='a') and (c<='z') then + if (i='0') and (code<='9') then begin resetOctave(voice); exit end; + while (code='+') or (code='-') do + begin + newOctave(voice,code); removeOctaveCode(code,note); code:=octaveCode(note) + end; + if code<>' ' then error3(voice,'You may have only one absolute octave assignment'); + insertOctaveCode(octave(voice),note); + checkRange(voice,note); + resetOctave(voice) +end; + +procedure markDebeamed(voice: voice_index; var note: string); +begin + if isVocal(voice) and (afterSlur(voice)=0) and unbeamVocal + and (pos1(duration(voice),flagged)>0) then insertchar('a',note,2); +end; + +function barLength (meter: string): integer; + var n1, n2, pn1, pn2: integer; +begin + getMeter(meter,n1,n2,pn1,pn2); barLength := n1*(64 div n2); +end; + +function isMultiBarRest(rest: string): boolean; +begin isMultibarRest:=false; if length(rest)<3 then exit; + if rest[2]<>'m' then exit; + if multi_bar_rest then error( + 'Only one multibar rest allowed per line',print); + multi_bar_rest := true; isMultibarRest:=true; +end; + +{ Double-length in xtuplet detected by a brute search for D anywhere. + Could be more elegant. } + +var macro_length: array[1..20] of integer; +const macro_ID: array[1..20] of string[2]=('1','2','3','4','5','6','7','8', + '9','10','11','12','13','14','15','16','17','18','19','20'); + +procedure scanMusic(voice: voice_index; var left_over: integer); + var buf, note, enote, xnote: string; + has_next, done, doublex, store_macro: boolean; + bar, old_length, bar_length, count, l, mlen, ngrace, nmulti, + macroID, playID: integer; + dur1, lastdur, macro_type: char; + nscan: music_word; + + procedure decmulti; + begin if doublex then dec(nmulti,2) else dec(nmulti) + end; + + procedure countIt; + procedure incbar(nl: integer); + begin inc(bar_length,nl); + if (bar_length>bar) and (meternum>0) + then error3(voice,'Bar end occurs in mid-note'); + end; + begin + if ngrace>0 then dec(ngrace) else + if nmulti>0 then decmulti else + begin if (count mod 3<>0) and ( + (note[1]<>rest) and note_attrib[voice,'d'] or + (note[1]=rest) and rest_attrib[voice,'d']) then + inc(count,count div 2); + incbar(count); + l := pos1(multi_group,note); + if l>0 then + begin predelete(note,l); getNum(note,nmulti); decmulti; + end; + end + end; + + procedure maybeGroup; + begin if note[1]=grace_group then + begin if length(note)=1 then ngrace:=1 + else ngrace := pos1(note[2],digits); (* bug if ngrace>9 *) + if ngrace>0 then dec(ngrace); + end; + end; + + function identifyMacro(s: string): integer; + var k: integer; + begin predelete(s,2); for k:=1 to 20 do if s=macro_ID[k] then + begin identifyMacro:=k; exit end; + identifyMacro:=0 + end; + + procedure examineMacro; + begin if not countMacro then exit; + if debugMode then write(note,': '); if length(note)=1 then + begin + mlen:=bar_length-old_length; + if (macroID<1) or (macroID>20) then error3(voice,'Invalid macro ID'); + macro_length[macroID]:=mlen; + if debugMode then + writeln('Ending macro ',macroID,' of type ',macro_type,', length=', mlen); + if macro_type='S' then bar_length:=old_length; store_macro:=false + end + else begin playID:=identifyMacro(note); + if (playID<1) or (playID>20) then error3(voice,'Invalid macro ID'); + if note[2]='P' then + begin if debugMode then + writeln('Playing macro ',playID,' of length ', + macro_length[playID]); + inc(bar_length,macro_length[playID]) + end + else if pos1(note[2],'SR')>0 then + begin old_length:=bar_length; macro_type:=note[2]; macroID:=playID; + store_macro:=true; + if debugMode then writeln('Defining macro ',macroID,' of type ',note[2]) + end + end + end; + +begin + terminators:='d.x'; + resetInfo(voice, buf); has_next := false; left_over:=0; store_macro:=false; + bar:=full_bar; bar_length:=0; ngrace:=0; nmulti:=0; + if meternum=0 then bar:=32000; + dur1:=duration(voice); lastdur:=dur1; + done:=false; + repeat GetNextMusWord(buf,note,nscan); if length(note)=0 then break; count:=0; +{ if isNoteOrRest(note) and not (isPause(note) or isMultibarRest(note)) + then note:=toStandard(note); } + doublex := pos1('D',note)>0; + if nscan=mword then + begin + if length(note)=0 then + Error3(voice,'You may not end a line with a meter change'); + if bar_length>0 then + error3(voice,'Meter change only allowed at start of bar') + else bar:=barLength(note); + end + else if nscan=rword then + if not (isPause(note) or isMultiBarRest(note)) then + begin + processNote(note,xnote,dur1,lastdur,count); + checkSticky(note,rest_attrib[voice]); + end; + if note<>'' then appendNote(voice,nscan); + enote := note; + if (nscan=macro) or (nscan=endMacro) then examineMacro; + if nscan=abcdefg then + if (not multi_bar_rest) and (ngrace + nmulti = 0) then + begin + processNote(enote,xnote,dur1,lastdur,count); + if xnote<>'' then + begin + checkSticky(enote,note_attrib[voice]); + appendToLine(voice,enote); + appendNote(voice,nscan); enote := xnote; + end; + checkSticky(enote,note_attrib[voice]); + end; + appendToLine(voice,enote); + if note='' then done:=true; { !!! else word_bound[here]:=length(line); } + if note=barsym then + if meternum=0 then + error3(voice,'You may not use bar lines in barless music') + else if bar_length=0 then markBar(voice) + else if (numberOfBars(voice)=0) and (bar_length0 then error3(voice,'Bar is too short'); + left_over:=bar_length; bar_length := 0; + end; + if nscan=nextvoice then + begin if bar_length>0 then error3(voice, 'Next voice before bar is full') + else barForward(voice,-1); has_next := true; + end + else if isPause(note) then inc(bar_length,bar) + else if multi_bar_rest then {do nothing} + else if not done and isNoteOrRest(note) then countIt + else maybeGroup; + dur1:=lastdur; + if (bar_length>=bar) and (ngrace+nmulti=0) and not store_macro then + begin if debugMode then writeln(voice,' ',bar_length); + barForward(voice,bar_length div bar); bar_length:=bar_length mod bar + end; + until done; + setExtraLength(voice,bar_length); + resetDuration(voice,dur1); + regroup(voice) +end; + +procedure initMTX; + var i: voice_index; j: char; +begin for i:=1 to maxvoices do for j:='a' to 'z' do + note_attrib[i,j] := false; + rest_attrib := note_attrib; +end; + +end. diff --git a/Build/source/utils/m-tx/mtx-src/mtx.test b/Build/source/utils/m-tx/mtx-src/mtx.test new file mode 100644 index 00000000000..e9f2e4259c5 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/mtx.test @@ -0,0 +1,16 @@ +#! /bin/sh + +# Copyright (C) 2012 Peter Breitenlohner +# You may freely use, modify and/or distribute this file. + +rm -f mozart* + +cp $srcdir/tests/mozart.mtx . + +set -x + +./prepmx mozart \ + && diff mozart.pmx $srcdir/tests/mozart.pmx \ + || exit 1 + +exit 0 diff --git a/Build/source/utils/m-tx/mtx-src/mtxline.c b/Build/source/utils/m-tx/mtx-src/mtxline.c new file mode 100644 index 00000000000..b08eef73777 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/mtxline.c @@ -0,0 +1,851 @@ +/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ +/* From input file "mtxline.pas" */ + + +#include "p2c.h" + +#define MTXLINE_G +#include "mtxline.h" + + +boolean bind_left[22] = { + false, false, true, false, false, true, true, false, true, true, true, + false, true, false, true, false, true, false, false, false, false, false +}; + +#ifndef STRINGS_H +#include "strings.h" +#endif + +#ifndef CONTROL_H +#include "control.h" +#endif + +#ifndef NOTES_H +#include "notes.h" +#endif + +#ifndef UTILITY_H +#include "utility.h" +#endif + + +typedef music_word word_scan[max_words]; + +typedef struct line_info { + word_index0 here, nword; + bar_index0 nbar; + paragraph_index0 voice_pos, voice_stave, mus, chord; + short extra; + boolean vocal; + word_index0 bar_bound[max_bars + 1]; + short word_bound[max_words + 1], orig_word_bound[max_words + 1]; + word_scan scan; +} line_info; + + +Static Char name[22][10] = { + "?", "note", "znote", "lyricsTag", "(", ")", ")(", "[", "]", "_", "PMX<", + "macro", "endMacro", "meter", "ornament", "rest", "//", "BAR", "TeX", "@", + "firstonly", "ERROR" +}; + +Static line_info info[maxvoices]; + + +/* ------------------------------------------------------------- */ + +short beatsPerLine(void) +{ + short Result; + voice_index voice, FORLIM; + line_info *WITH; + + FORLIM = nvoices; + for (voice = 1; voice <= FORLIM; voice++) { + WITH = &info[voice-1]; + if (WITH->nbar > 0 || WITH->extra > 0) { + if (WITH->extra % one_beat > 0) { +/* p2c: mtxline.pas, line 99: + * Note: Using % for possibly-negative arguments [317] */ + error3(voice, "Line length not an integer number of beats"); + } + Result = WITH->nbar * meternum + WITH->extra / one_beat; + } + } + return Result; +} + + +void skipChordBar(voice_index voice) +{ + line_info *WITH; + Char STR1[256]; + + WITH = &info[voice-1]; + if (WITH->chord > 0) { + sprintf(STR1, "%c", barsym); + if (!strcmp(P[WITH->chord - 1], STR1)) + predelete(P[WITH->chord - 1], 1); + } +} + + +Char *getBar(Char *Result, voice_index voice, short bar) +{ + line_info *WITH; + + WITH = &info[voice-1]; + return (substr_(Result, P[WITH->mus - 1], + WITH->word_bound[WITH->bar_bound[bar-1]] + 1, + WITH->word_bound[WITH->bar_bound[bar]] - + WITH->word_bound[WITH->bar_bound[bar-1]])); +} + + +Char *musicLine(Char *Result, voice_index voice) +{ + return strcpy(Result, P[musicLineNo(voice) - 1]); +} + + +paragraph_index0 musicLineNo(voice_index voice) +{ + return (info[voice-1].mus); +} + + +void setMusicLineNo(voice_index voice, paragraph_index lno) +{ + info[voice-1].mus = lno; +} + + +paragraph_index0 chordLineNo(voice_index voice) +{ + return (info[voice-1].chord); +} + + +void setChordLineNo(voice_index voice, paragraph_index lno) +{ + info[voice-1].chord = lno; +} + + +void setVocal(voice_index voice, boolean voc) +{ + info[voice-1].vocal = voc; +} + + +boolean isVocal(voice_index voice) +{ + return (info[voice-1].vocal); +} + + +void setStavePos(voice_index voice, stave_index stave, stave_index pos) +{ + line_info *WITH; + + WITH = &info[voice-1]; + WITH->voice_pos = pos; + WITH->voice_stave = stave; +} + + +stave_index voiceStave(voice_index voice) +{ + return (info[voice-1].voice_stave); +} + + +stave_index voicePos(voice_index voice) +{ + return (info[voice-1].voice_pos); +} + + +voice_index companion(voice_index voice) +{ + short s; + + s = info[voice-1].voice_stave; + if (number_on_stave[s-1] == 1) + return voice; + else if (info[voice-1].voice_pos == 1) + return (voice + 1); + else + return (voice - 1); +} + + +void regroup(voice_index voice) +{ + word_index0 i, j; + word_index0 j2 = 0; + line_info *WITH; + word_index0 FORLIM; + + WITH = &info[voice-1]; + if (debugMode()) + printf("Voice %d has %d bars at ", voice, WITH->nbar); + if (debugMode()) { + FORLIM = WITH->nbar + 1; + for (i = 1; i <= FORLIM; i++) + printf("%d ", WITH->bar_bound[i]); + } + FORLIM = WITH->nbar; + for (i = 1; i <= FORLIM; i++) { + j2 = WITH->bar_bound[i]; + j = j2 + 1; + while (j <= WITH->here && + (bind_left[(long)WITH->scan[j-1]] || WITH->scan[j-1] == barword)) { + WITH->bar_bound[i]++; + j++; + } + } + if (WITH->extra > 0) + WITH->bar_bound[WITH->nbar + 1] = WITH->here; + if (debugMode()) { + printf(" regrouped to "); + FORLIM = WITH->nbar + 1; + for (i = 1; i <= FORLIM; i++) + printf("%d ", WITH->bar_bound[i]); + } + if (debugMode()) + putchar('\n'); + WITH->nword = WITH->here; +} + + +void resetInfo(voice_index voice, Char *buf) +{ + line_info *WITH; + + WITH = &info[voice-1]; + strcpy(buf, P[WITH->mus - 1]); + *P[WITH->mus - 1] = '\0'; + WITH->bar_bound[0] = 0; + WITH->word_bound[0] = 0; + WITH->orig_word_bound[0] = 0; + WITH->nbar = 0; + WITH->here = 0; +} + + +void clearLabels(void) +{ + voice_index voice, FORLIM; + line_info *WITH; + + FORLIM = nvoices; + for (voice = 0; voice <= FORLIM - 1; voice++) { + WITH = &info[voice]; + WITH->chord = 0; + WITH->mus = 0; + } +} + + +void appendNote(voice_index voice, music_word nscan) +{ + line_info *WITH; + + WITH = &info[voice-1]; + WITH->here++; + if (WITH->here > max_words) + error3(voice, "Words per line limit exceeded"); + WITH->scan[WITH->here - 1] = nscan; +} + + +void appendToLine(voice_index voice, Char *note) +{ + line_info *WITH; + + if (*note == '\0') + return; + WITH = &info[voice-1]; + sprintf(P[WITH->mus - 1] + strlen(P[WITH->mus - 1]), "%s%c", note, blank); + WITH->word_bound[WITH->here] = strlen(P[WITH->mus - 1]); + WITH->orig_word_bound[WITH->here] = nextWordBound(orig_P[WITH->mus - 1], + note[0], WITH->orig_word_bound[WITH->here - 1]); +} + + +void markBar(voice_index voice) +{ + line_info *WITH; + + WITH = &info[voice-1]; + if (WITH->nbar == 0) + error3(voice, "Empty bar"); + else + WITH->bar_bound[WITH->nbar] = WITH->here; +} + + +short numberOfBars(voice_index voice) +{ + return (info[voice-1].nbar); +} + + +void barForward(voice_index voice, short nbars) +{ + line_info *WITH; + + WITH = &info[voice-1]; + if (WITH->nbar + nbars < 0) + error3(voice, "Next voice before bar is full"); + if (WITH->nbar + nbars > max_bars) + error3(voice, "Bars per line limit exceeded"); + WITH->nbar += nbars; + if (nbars > 0) + WITH->bar_bound[WITH->nbar] = WITH->here; +} + + +void setExtraLength(voice_index voice, short ext) +{ + line_info *WITH; + + WITH = &info[voice-1]; + WITH->extra = ext; + WITH->scan[WITH->here] = other; +} + + +short ExtraLength(voice_index voice) +{ + return (info[voice-1].extra); +} + + +voice_index0 findVoice(Char *w_) +{ + voice_index0 Result = 0; + Char w[256]; + short i, FORLIM; + + strcpy(w, w_); + curtail(w, ':'); + FORLIM = nvoices; + for (i = 1; i <= FORLIM; i++) { + if (!strcmp(w, voice_label[i-1])) + return i; + } + getNum(w, &i); + if (i == 0) + return Result; + if (i > 0 && i <= nvoices) + return i; + error("Numeric label outside range 1..nvoices", print); + return Result; +} + + +Static void info3(voice_index voice) +{ + short p; + line_info *WITH; + + WITH = &info[voice-1]; + printf("In voice \"%s\" near word %d:\n", voice_label[voice-1], WITH->here); + p = WITH->orig_word_bound[WITH->here - 1] - 1; + if (p < 0) + p = 0; + printf("%*cV\n", p, ' '); +} + + +void error3(voice_index voice, Char *message) +{ + Char STR1[256]; + + info3(voice); + sprintf(STR1, " %s", message); + error(STR1, print); +} + + +void warning3(voice_index voice, Char *message) +{ + Char STR1[256]; + + info3(voice); + sprintf(STR1, " %s", message); + warning(STR1, print); +} + + +Char *nextMusicWord(Char *Result, voice_index voice) +{ + return (MusicWord(Result, voice, info[voice-1].here)); +} + + +Char *MusicWord(Char *Result, short voice, short n) +{ + line_info *WITH; + + WITH = &info[voice-1]; + if (n > 0 && n <= WITH->nword) + return (substr_(Result, P[WITH->mus - 1], WITH->word_bound[n-1] + 1, + WITH->word_bound[n] - WITH->word_bound[n-1] - 1)); + else + return strcpy(Result, ""); +} + + +music_word thisNote(voice_index voice) +{ + line_info *WITH; + + WITH = &info[voice-1]; + return (WITH->scan[WITH->here - 2]); +} + + +music_word nextNote(voice_index voice) +{ + line_info *WITH; + + WITH = &info[voice-1]; + return (WITH->scan[WITH->here - 1]); +} + + +boolean endOfBar(voice_index voice, short bar_no) +{ + line_info *WITH; + + WITH = &info[voice-1]; + return (WITH->here > WITH->bar_bound[bar_no]); +} + + +void gotoBar(voice_index voice, short bar_no) +{ + line_info *WITH; + + WITH = &info[voice-1]; + WITH->here = WITH->bar_bound[bar_no-1] + 1; +} + + +Char *getMusicWord(Char *Result, voice_index voice) +{ + line_info *WITH; + + WITH = &info[voice-1]; + line_no = orig_line_no[WITH->mus - 1]; + MusicWord(Result, voice, WITH->here); + WITH->here++; + return Result; +} + + +boolean maybeMusicLine(Char *l_) +{ + Char l[256]; + Char w[256]; + music_word nscan; + + strcpy(l, l_); + GetNextWord(w, l, blank, dummy); +/* p2c: mtxline.pas: Note: Eliminated unused assignment statement [338] */ + if (pos1(w[0], "abcdefgr()[]{}CMm") == 0) + return false; + if (pos1(':', w) == 0) + return true; + getNextMusWord(w, l, &nscan); + return (nscan == abcdefg); +} + + +#define nmacros 99 + + +Static boolean macro_initialized = false; +Static Char macro_text[nmacros][256]; + + +Static void macroInit(void) +{ + short i; + + if (macro_initialized) + return; + macro_initialized = true; + for (i = 0; i <= nmacros - 1; i++) + *macro_text[i] = '\0'; +} + + +Static short identifyMacro(Char *s_) +{ + Char s[256]; + short k; + + strcpy(s, s_); + predelete(s, 2); + getNum(s, &k); + return k; +} + + +/* Local variables for getNextMusWord: */ +struct LOC_getNextMusWord { + Char *buf, *note; +} ; + +Local void expandThisMacro(struct LOC_getNextMusWord *LINK) +{ + Char playtag[11]; + short playID; + Char w[256]; + Char STR1[72]; + Char STR2[42]; + Char STR3[68]; + Char STR4[54]; + Char STR5[256], STR7[256]; + + macroInit(); + if (strlen(LINK->note) == 1) + error("Can't terminate a macro that has not been started", print); + playID = identifyMacro(LINK->note); + toString(playtag, playID); +/* p2c: mtxline.pas, line 317: + * Note: Possible string truncation in assignment [145] */ + if (playID < 1 || playID > 99) { + sprintf(STR2, "Macro ID %s is not in range 1..99", playtag); + error(STR2, print); + } + if (LINK->note[1] == 'P') { + if (*macro_text[playID-1] == '\0') { + sprintf(STR3, + "Macro %s inserts empty text: did you define it before use?", + playtag); + warning(STR3, print); + } + if (strlen(macro_text[playID-1]) + strlen(LINK->buf) <= 255) { + if (debugMode()) { + printf("Inserting macro %s text \"%s\"\n", + playtag, macro_text[playID-1]); + printf("Buffer before insert: %s\n", LINK->buf); + } + sprintf(LINK->buf, "%s%s", + macro_text[playID-1], strcpy(STR5, LINK->buf)); + return; + } + sprintf(STR4, "Expansion of macro %s causes buffer overflow", playtag); + error(STR4, print); + } + if (pos1(LINK->note[1], "SR") == 0) { + sprintf(STR4, "Second character %c of macro word should be in \"PRS\"", + LINK->note[1]); + error(STR4, print); + } + *macro_text[playID-1] = '\0'; + do { + GetNextWord(w, LINK->buf, blank, dummy); + if (*w == '\0') { + sprintf(STR1, + "Macro definition %s should be terminated on the same input line", + playtag); + error(STR1, print); + } + if (!strcmp(w, "M")) { + if (debugMode()) + printf("Macro %s is: %s\n", playtag, macro_text[playID-1]); + break; + } + if (w[0] == 'M' && strlen(w) > 1) { + if (w[1] != 'P' || identifyMacro(w) == playID) { + sprintf(STR7, "%s not allowed inside macro definition %s", w, playtag); + error(STR7, print); + } + } + sprintf(macro_text[playID-1] + strlen(macro_text[playID-1]), "%s ", w); + } while (true); + if (LINK->note[1] == 'R') { + LINK->note[1] = 'P'; + sprintf(LINK->buf, "%s %s", LINK->note, strcpy(STR7, LINK->buf)); + } +} + + +void getNextMusWord(Char *buf_, Char *note_, music_word *nscan) +{ + struct LOC_getNextMusWord V; + Char maybe_error[256]; + Char STR2[256]; + + V.buf = buf_; + V.note = note_; + GetNextWord(V.note, V.buf, blank, dummy); + if (*V.note == '\0') + return; + if (V.note[0] == 'M' && expandMacro()) { + expandThisMacro(&V); + getNextMusWord(V.buf, V.note, nscan); + return; + } + if (V.note[0] == '\\') { + *maybe_error = '\0'; + if (V.note[strlen(V.note) - 1] != '\\') + strcpy(maybe_error, V.note); + while (*V.buf != '\0' && V.note[strlen(V.note) - 1] != '\\') + sprintf(V.note + strlen(V.note), " %s", + GetNextWord(STR2, V.buf, blank, dummy)); + if (V.note[strlen(V.note) - 1] != '\\') + error("Unterminated TeX literal", print); + *nscan = texword; + if (*maybe_error != '\0') { + sprintf(STR2, "Possible unterminated TeX literal: %s", maybe_error); + warning(STR2, print); + } + return; + } + if (solfaNoteNames()) { + translateSolfa(V.note); + if (V.note[0] == '"') + predelete(V.note, 1); + } + switch (V.note[0]) { + + case '_': + *nscan = pmxprefix; + delete1(V.note, 1); + break; + + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + *nscan = abcdefg; + break; + + case 'z': + *nscan = zword; + break; + + case '(': + *nscan = lparen; + break; + + case '{': + if (V.note[strlen(V.note) - 1] == '}') + *nscan = lyrtag; + else + *nscan = lparen; + break; + + case ')': + if (pos1('(', V.note) == 0) + *nscan = rparen; + else + *nscan = rlparen; + break; + + case '}': + if (pos1('{', V.note) == 0) + *nscan = rparen; + else + *nscan = rlparen; + break; + + case '[': + *nscan = lbrac; + break; + + case ']': + *nscan = rbrac; + break; + + case '@': + *nscan = atword; + break; + + case 'm': + *nscan = mword; + break; + + case 'r': + *nscan = rword; + break; + + case '#': + case '-': + case 'n': + case 'x': + case '?': + case 's': + case 't': + case 'D': + *nscan = pmxl; + break; + + case 'M': + if (!strcmp(V.note, "M")) + *nscan = endmacro; + else + *nscan = macro; + break; + + case 'G': + if (pos1('A', V.note) > 0) + *nscan = pmxl; + else + *nscan = other; + break; + + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (pos1('/', V.note) > 0) + *nscan = mword; + else + *nscan = pmxl; + break; + + case 'o': + *nscan = oword; + break; + + case 'A': + case 'V': + *nscan = FirstOnly; + break; + + case '/': + if (!strcmp(V.note, "//")) + *nscan = nextvoice; + else if (!strcmp(V.note, "/")) { + strcpy(V.note, "//"); + warning("/ changed to //", print); + *nscan = nextvoice; + } else { + error("Word starts with /: do you mean \\?", print); + *nscan = err; + } + break; + + default: + if (pos1('|', V.note) > 0) + *nscan = barword; + else + *nscan = other; + break; + } +} + + +boolean upper(voice_index voice) +{ + line_info *WITH; + + WITH = &info[voice-1]; + if (WITH->voice_pos == 1 && voice < nvoices) + return (WITH->voice_stave == info[voice].voice_stave); + else + return false; +} + + +void describeVoice(voice_index voice, Char *describe_lyr) +{ + short bar, w; + line_info *WITH; + Char STR1[256]; + line_info *WITH1; + short FORLIM; + + WITH = &info[voice-1]; + printf("Voice `%s' is on line %d", voice_label[voice-1], WITH->mus); + if (WITH->vocal) { + printf(", is vocal"); + puts(describe_lyr); + } else { + if (WITH->chord > 0) + printf(" and has chords on line %d", WITH->chord); + putchar('\n'); + } + if (!debugMode()) + return; + WITH1 = &info[voice-1]; + printf("Line has %d bars", WITH1->nbar); + if (WITH1->extra > 0) + printf(" + %d/64 notes\n", WITH1->extra); + else + putchar('\n'); + printf("Bars:"); + FORLIM = WITH1->nbar; + for (bar = 1; bar <= FORLIM; bar++) + printf(" %s ", getBar(STR1, voice, bar)); + printf("\nWord types:"); + FORLIM = WITH1->nword; + for (w = 0; w <= FORLIM - 1; w++) + printf(" %s", name[(long)WITH1->scan[w]]); + putchar('\n'); +} + + +boolean aloneOnStave(stave_index stave) +{ + voice_index v; + + if (number_on_stave[stave-1] != 2) + return true; + else { + v = first_on_stave[stave-1]; + return (info[v-1].mus == 0 || info[v].mus == 0); + } +} + + +void selectVoices(Char *line_) +{ + Char line[256]; + short i = 0; + short k; + Char word[256]; + short FORLIM; + + strcpy(line, line_); + FORLIM = nvoices; + for (k = 0; k <= FORLIM - 1; k++) + selected[k] = false; + printf("Voice change to: %s = ", line); + while (i < nvoices) { + GetNextWord(word, line, blank, dummy); + if (*word == '\0') { + putchar('\n'); + return; + } + i++; + printf("%s ", word); + k = findVoice(word); + if (k == 0) + error("This voice is not in the style", print); + selected[k-1] = true; + } + putchar('\n'); +} + + + + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/mtxline.h b/Build/source/utils/m-tx/mtx-src/mtxline.h new file mode 100644 index 00000000000..23fc05be32c --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/mtxline.h @@ -0,0 +1,83 @@ +/* Header for module mtxline, generated by p2c 1.21alpha-07.Dec.93 */ +#ifndef MTXLINE_H +#define MTXLINE_H + + +/* Break input up into words, classify them. Supply words and + information about them. */ + +#ifndef GLOBALS_H +#include "globals.h" +#endif + + +#ifdef MTXLINE_G +# define vextern +#else +# define vextern extern +#endif + + +typedef enum { + other, abcdefg, zword, lyrtag, lparen, rparen, rlparen, lbrac, rbrac, + pmxprefix, pmxl, macro, endmacro, mword, oword, rword, nextvoice, barword, + texword, atword, FirstOnly, err +} music_word; + + +extern boolean bind_left[22]; + +/* changed bind_left[barword] to false */ + +vextern boolean selected[maxvoices]; + + +extern void error3(voice_index voice, Char *message); +extern void warning3(voice_index voice, Char *message); +extern void getNextMusWord(Char *buf, Char *note, music_word *nscan); +extern Char *MusicWord(Char *Result, short voice, short n); +extern Char *nextMusicWord(Char *Result, voice_index voice); +extern music_word thisNote(voice_index voice); +extern music_word nextNote(voice_index voice); +extern Char *getMusicWord(Char *Result, voice_index voice); +extern void gotoBar(voice_index voice, short bar_no); +extern boolean endOfBar(voice_index voice, short bar_no); +extern Char *getBar(Char *Result, voice_index voice, short bar); +extern boolean upper(voice_index voice); +extern void clearLabels(void); +extern voice_index0 findVoice(Char *w); +extern void selectVoices(Char *line); +extern void resetInfo(voice_index voice, Char *buf); +extern void setVocal(voice_index voice, boolean voc); +extern boolean isVocal(voice_index voice); +extern void setStavePos(voice_index voice, stave_index stave, stave_index pos); +extern stave_index voiceStave(voice_index voice); +extern stave_index voicePos(voice_index voice); +extern boolean aloneOnStave(stave_index stave); +extern voice_index companion(voice_index voice); +extern void appendNote(voice_index voice, music_word nscan); +extern void appendToLine(voice_index voice, Char *note); +extern void markBar(voice_index voice); +extern short numberOfBars(voice_index voice); +extern void barForward(voice_index voice, short nbars); +extern void regroup(voice_index voice); + +extern short beatsPerLine(void); +extern void setExtraLength(voice_index voice, short ext); +extern short ExtraLength(voice_index voice); +extern paragraph_index0 musicLineNo(voice_index voice); +extern void setMusicLineNo(voice_index voice, paragraph_index lno); +extern paragraph_index0 chordLineNo(voice_index voice); +extern void setChordLineNo(voice_index voice, paragraph_index lno); +extern void skipChordBar(voice_index voice); + +extern void describeVoice(voice_index voice, Char *describe_lyr); +extern boolean maybeMusicLine(Char *l); +extern Char *musicLine(Char *Result, voice_index voice); + + +#undef vextern + +#endif /*MTXLINE_H*/ + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/mtxline.pas b/Build/source/utils/m-tx/mtx-src/mtxline.pas new file mode 100644 index 00000000000..5f6e4062fde --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/mtxline.pas @@ -0,0 +1,457 @@ +unit mtxline; +{ Break input up into words, classify them. Supply words and + information about them. } + +interface uses globals; + +type + music_word = (other, abcdefg, zword, lyrtag, + lparen, rparen, rlparen, lbrac, rbrac, + pmxprefix, pmxl, macro, endmacro, mword, oword, rword, nextvoice, + barword, texword, atword, FirstOnly, err ); + +const + bind_left: array[music_word] of boolean = ( + false, false, true, false, + false, true, true, false, true, + true, true, false, true, false, true, false, true, + false, false, false, false, false ); +{ changed bind_left[barword] to false } + +var selected: array[voice_index] of boolean; + +procedure error3(voice: voice_index; message: string ); +procedure warning3(voice: voice_index; message: string ); +procedure getNextMusWord (var buf, note: string; var nscan: music_word); +function MusicWord(voice, n: integer): string; +function nextMusicWord(voice: voice_index): string; +function thisNote(voice: voice_index): music_word; +function nextNote(voice: voice_index): music_word; +function getMusicWord(voice: voice_index): string; +procedure gotoBar(voice: voice_index; bar_no: integer); +function endOfBar(voice: voice_index; bar_no: integer): boolean; +function getBar(voice:voice_index; bar: integer): string; +function upper(voice: voice_index): boolean; +procedure clearLabels; +function findVoice(w: string): voice_index0; +procedure selectVoices(line: string); +procedure resetInfo(voice: voice_index; var buf: string); +procedure setVocal(voice: voice_index; voc: boolean); +function isVocal(voice: voice_index): boolean; +procedure setStavePos(voice: voice_index; stave, pos: stave_index); +function voiceStave(voice: voice_index): stave_index; +function voicePos(voice: voice_index): stave_index; +function aloneOnStave(stave: stave_index): boolean; +function companion(voice: voice_index): voice_index; +procedure appendNote(voice: voice_index; nscan: music_word); +procedure appendToLine(voice: voice_index; note: string); +procedure markBar(voice: voice_index); +function numberOfBars(voice: voice_index): integer; +procedure barForward(voice: voice_index; nbars: integer); +procedure regroup(voice: voice_index); + +function beatsPerLine: integer; +procedure setExtraLength(voice: voice_index; ext: integer); +function ExtraLength(voice: voice_index): integer; +function musicLineNo(voice: voice_index): paragraph_index0; +procedure setMusicLineNo(voice: voice_index; lno: paragraph_index); +function chordLineNo(voice: voice_index): paragraph_index0; +procedure setChordLineNo(voice: voice_index; lno: paragraph_index); +procedure skipChordBar(voice: voice_index); + +procedure describeVoice(voice: voice_index; describe_lyr: string); +function maybeMusicLine(l: string): boolean; +function musicLine(voice: voice_index): string; + +implementation uses strings, notes, control, utility; + +const + + name: array[music_word] of string[9] = ( + '?', 'note', 'znote', 'lyricsTag', + '(', ')', ')(', '[', ']', + '_','PMX<', 'macro', 'endMacro', 'meter', 'ornament', 'rest', '//', + 'BAR', 'TeX', '@', 'firstonly', 'ERROR'); + +type + word_scan = array[1..max_words] of music_word; + + line_info = record + here, nword: word_index0; + nbar: bar_index0; + voice_pos, voice_stave, mus, chord: paragraph_index0; + extra: integer; + vocal: boolean; + bar_bound: array[bar_index0] of word_index0; + word_bound, orig_word_bound: array[word_index0] of integer; + scan: word_scan; + end; + +var info: array[voice_index] of line_info; + +{ ------------------------------------------------------------- } + +function beatsPerLine: integer; + var voice: voice_index; +begin for voice:=1 to nvoices do with info[voice] do + if (nbar>0) or (extra>0) then + begin + if extra mod one_beat > 0 + then error3(voice,'Line length not an integer number of beats'); + beatsPerLine := nbar*meternum + extra div one_beat; + end; +end; + +procedure skipChordBar(voice: voice_index); +begin with info[voice] do + if chord>0 then if P[chord]=barsym then predelete(P[chord],1); +end; + +function getBar(voice: voice_index; bar: integer): string; +begin with info[voice] do + getBar := substr(P[mus],word_bound[bar_bound[bar-1]]+1, + word_bound[bar_bound[bar]]-word_bound[bar_bound[bar-1]]); +end; + +function musicLine(voice: voice_index): string; +begin musicLine:=P[musicLineNo(voice)]; end; + +function musicLineNo(voice: voice_index): paragraph_index0; +begin musicLineNo := info[voice].mus; end; + +procedure setMusicLineNo(voice: voice_index; lno: paragraph_index); +begin info[voice].mus := lno; end; + +function chordLineNo(voice: voice_index): paragraph_index0; +begin chordLineNo := info[voice].chord; end; + +procedure setChordLineNo(voice: voice_index; lno: paragraph_index); +begin info[voice].chord := lno; end; + +procedure setVocal(voice: voice_index; voc: boolean); +begin info[voice].vocal:=voc; end; + +function isVocal(voice: voice_index): boolean; +begin isVocal := info[voice].vocal; end; + +procedure setStavePos(voice: voice_index; stave, pos: stave_index); +begin with info[voice] do begin voice_pos:=pos; voice_stave:=stave; end; +end; + +function voiceStave(voice: voice_index): stave_index; +begin voiceStave:=info[voice].voice_stave; end; + +function voicePos(voice: voice_index): stave_index; +begin voicePos:=info[voice].voice_pos; end; + +function companion(voice: voice_index): voice_index; + var s: integer; +begin s:=info[voice].voice_stave; + if number_on_stave[s]=1 then companion:=voice + else if info[voice].voice_pos=1 then companion:=voice+1 + else companion:=voice-1; +end; + +procedure regroup(voice: voice_index); + var i, j, j2: word_index0; +begin j2 := 0; with info[voice] do + begin if debugMode then write('Voice ',voice,' has ',nbar,' bars at '); + if debugMode then for i:=1 to nbar+1 do write(bar_bound[i],' '); + for i:=1 to nbar do + begin j2:=bar_bound[i]; j:=j2+1; + while (j<=here) and (bind_left[scan[j]] or (scan[j]=barword)) do + begin inc(bar_bound[i]); inc(j) end; + end; + if extra>0 then bar_bound[nbar+1]:=here; + if debugMode then + begin write(' regrouped to '); + for i:=1 to nbar+1 do write(bar_bound[i],' ') + end; + if debugMode then writeln; + nword := here + end; +end; + +procedure resetInfo(voice: voice_index; var buf: string); +begin with info[voice] do + begin buf := P[mus]; P[mus]:=''; + bar_bound[0]:=0; word_bound[0]:=0; orig_word_bound[0]:=0; + nbar:=0; here := 0; + end; +end; + +procedure clearLabels; + var voice: voice_index; +begin for voice:=1 to nvoices do with info[voice] do + begin chord:=0; mus:=0; end; +end; + +procedure appendNote(voice: voice_index; nscan: music_word); +begin with info[voice] do + begin inc(here); if here>max_words then + error3(voice,'Words per line limit exceeded'); + scan[here]:=nscan; end; +end; + +procedure appendToLine(voice: voice_index; note: string); +begin if note<>'' then with info[voice] do + begin P[mus]:=P[mus]+note+blank; word_bound[here]:=length(P[mus]); + orig_word_bound[here]:=nextWordBound(orig_P[mus],note[1], + orig_word_bound[here-1]); + end; +end; + +procedure markBar(voice: voice_index); +begin with info[voice] do + if nbar=0 then error3(voice,'Empty bar') else bar_bound[nbar]:=here +end; + +function numberOfBars(voice: voice_index): integer; +begin numberOfBars := info[voice].nbar; end; + +procedure barForward(voice: voice_index; nbars: integer); +begin with info[voice] do + begin + if (nbar+nbars<0) then error3(voice, 'Next voice before bar is full'); + if nbar+nbars>max_bars then error3(voice,'Bars per line limit exceeded'); + inc(nbar,nbars); + if nbars>0 then bar_bound[nbar]:=here; + end; +end; + +procedure setExtraLength(voice: voice_index; ext: integer); +begin with info[voice] do begin extra:=ext; scan[here+1]:=other; end; +end; + +function ExtraLength(voice: voice_index): integer; +begin ExtraLength := info[voice].extra; end; + +function findVoice(w: string): voice_index0; + var i: integer; +begin curtail(w,':'); findVoice:=0; + for i:=1 to nvoices do + if w=voice_label[i] then begin findVoice:=i; exit end; + getNum(w,i); if i=0 then exit; + if (i>0) and (i<=nvoices) then findVoice:=i + else error('Numeric label outside range 1..nvoices',print); +end; + +procedure info3(voice: voice_index); + var p: integer; +begin with info[voice] do + begin + writeln ('In voice "', voice_label[voice], '" near word ', here, ':'); + p:=orig_word_bound[here-1]-1; + if p<0 then p:=0; + writeln(' ':p,'V') + end +end; + +procedure error3(voice: voice_index; message: string ); +begin info3(voice); error(' '+message,print) end; + +procedure warning3(voice: voice_index; message: string ); +begin info3(voice); warning(' '+message,print) end; + +function nextMusicWord(voice: voice_index): string; +begin nextMusicWord := MusicWord(voice,info[voice].here); end; + +function MusicWord(voice, n: integer): string; + begin with info[voice] do if (n>0) and (n<=nword) then + MusicWord := substr(P[mus],word_bound[n-1]+1, + word_bound[n]-word_bound[n-1]-1) + else MusicWord := ''; + end; + +function thisNote(voice: voice_index): music_word; +begin with info[voice] do thisNote := scan[here-1]; end; + +function nextNote(voice: voice_index): music_word; +begin with info[voice] do nextNote := scan[here]; end; + +function endOfBar(voice: voice_index; bar_no: integer): boolean; +begin with info[voice] do endOfBar := here > bar_bound[bar_no]; end; + +procedure gotoBar(voice: voice_index; bar_no: integer); +begin with info[voice] do here := bar_bound[bar_no-1]+1; end; + +function getMusicWord(voice: voice_index): string; +begin with info[voice] do + begin line_no := orig_line_no[mus]; + GetMusicWord := MusicWord(voice,here); inc(here); + end +end; + +function maybeMusicLine(l: string): boolean; + var w: string; + nscan: music_word; +begin w:=GetNextWord(l,blank,dummy); maybeMusicLine := false; + if pos1(w[1],'abcdefgr()[]{}CMm')=0 then begin maybeMusicLine := false; exit end; + if pos1(':',w)=0 then begin maybeMusicLine := true; exit end; + GetNextMusWord(w,l,nscan); maybeMusicLine := nscan=abcdefg; +end; + +const macro_initialized: boolean=false; + nmacros = 99; +var macro_text: array[1..nmacros] of string; +procedure macroInit; + var i: integer; +begin if macro_initialized then exit else macro_initialized:=true; + for i:=1 to nmacros do macro_text[i]:='' +end; + +function identifyMacro(s: string): integer; + var k: integer; +begin predelete(s,2); getNum(s,k); identifyMacro:=k +end; + +procedure GetNextMusWord (var buf, note: string; var nscan: music_word); + var maybe_error: string; + + procedure expandThisMacro; + var playtag: string[10]; + playID: integer; + w: string; + begin macroInit; if length(note)=1 then + error('Can''t terminate a macro that has not been started',print); + playID:=identifyMacro(note); playtag:=toString(playID); + if (playID<1) or (playID>99) then + error('Macro ID '+playtag+' is not in range 1..99',print); + if note[2]='P' then + begin if macro_text[playID]='' then + warning('Macro '+playtag+ + ' inserts empty text: did you define it before use?',print); + if length(macro_text[playID])+length(buf)>255 + then error('Expansion of macro '+playtag+' causes buffer overflow',print) + else begin if debugMode then + begin writeln('Inserting macro '+playtag+' text "' + +macro_text[playID]+'"'); + writeln('Buffer before insert: ',buf) + end; + buf:=macro_text[playID]+buf; exit + end + end; + if pos1(note[2],'SR')=0 then error('Second character '+note[2]+ + ' of macro word should be in "PRS"',print); + macro_text[playID]:=''; + repeat w:=getNextWord(buf,blank,dummy); + if w='' then error('Macro definition '+playtag+ + ' should be terminated on the same input line',print); + if w='M' then begin + if debugMode then writeln('Macro '+playtag+' is: '+macro_text[playID]); + break + end; + if (w[1]='M') and (length(w)>1) then + if (w[2]<>'P') or (identifyMacro(w)=playID) then + error(w+' not allowed inside macro definition '+playtag,print); + macro_text[playID]:=macro_text[playID]+w+' ' + until false; + if note[2]='R' then begin note[2]:='P'; buf:=note+' '+buf end + end; + + begin note:=GetNextWord(buf,blank,dummy); + if note='' then exit; + if (note[1]='M') and expandMacro then + begin expandThisMacro; GetNextMusWord(buf,note,nscan); exit end; + if note[1]='\' then + begin maybe_error:=''; + if note[length(note)]<>'\' then maybe_error:=note; + while (buf<>'') and (note[length(note)]<>'\') do + note:=note+' '+GetNextWord(buf,blank,dummy); + if note[length(note)]<>'\' then + error('Unterminated TeX literal',print); + nscan:=texword; + if maybe_error<>'' then + warning('Possible unterminated TeX literal: '+maybe_error,print); + exit; + end; + if solfaNoteNames then + begin translateSolfa(note[1]); if note[1]='"' then predelete(note,1); + end; + case note[1] of +'_': begin nscan:=pmxprefix;delete1(note,1); end; +'a'..'g': nscan:=abcdefg; +'z': nscan:=zword; +'(': nscan:=lparen; +'{': if note[length(note)]='}' then nscan:=lyrtag else nscan:=lparen; +')': if pos1('(',note)=0 then nscan:=rparen else nscan:=rlparen; +'}': if pos1('{',note)=0 then nscan:=rparen else nscan:=rlparen; +'[': nscan:=lbrac; +']': nscan:=rbrac; +'@': nscan:=atword; +'m': nscan:=mword; +'r': nscan:=rword; +'#','-','n','x','?','s','t','D': nscan:=pmxl; +'M': if note='M' then nscan:=endMacro else nscan:=macro; +'G': if pos1('A',note)>0 then nscan:=pmxl else nscan:=other; +'1'..'9': if pos1('/',note)>0 then nscan:=mword else nscan:=pmxl; +'o': nscan:=oword; +'A', 'V': nscan:=FirstOnly; +'/': if note='//' then nscan:=nextvoice + else if note='/' then + begin note:='//'; warning('/ changed to //',print); nscan:=nextvoice; + end + else begin error('Word starts with /: do you mean \?',print); + nscan:=err; + end; + else if pos1('|',note)>0 then nscan:=barword else + nscan:=other; + end; + end; + +function upper(voice: voice_index): boolean; +begin with info[voice] do + if (voice_pos=1) and (voice0 then write(' and has chords on line ',chord); + writeln; + end; + if debugMode then with info[voice] do + begin write('Line has ', nbar, ' bars'); + if extra>0 then writeln(' + ', extra, '/64 notes') else writeln; + write('Bars:'); + for bar:=1 to nbar do write(' ',getBar(voice,bar),' '); + writeln; write('Word types:'); + for w:=1 to nword do write(' ',name[scan[w]]); writeln; + end; + end; +end; + +function aloneOnStave(stave: stave_index): boolean; + var v: voice_index; +begin + if number_on_stave[stave]<>2 then aloneOnStave:=true else + begin v:=first_on_stave[stave]; + aloneOnStave:= (info[v].mus=0) or (info[v+1].mus=0) + end +end; + +procedure selectVoices(line: string); + var i, k: integer; + word: string; + begin + for k:=1 to nvoices do selected[k]:=false; + write('Voice change to: ',line,' = '); + i:=0; + while iname)) + return true; + previous = previous->prev; + } + return false; +} + + +void pushFile(Char *filename) +{ + filenode *newnode; + Char STR3[256]; + + if (recursive(filename)) { + printf("===! Ignoring recursive include of file %s\n", filename); + return; + } + newnode = Malloc(sizeof(filenode)); + newnode->actualfile = NULL; + strcpy(newnode->name, filename); + newnode->prev = current; + newnode->lineno = 0; + strcpy(newnode->actualfile_NAME, filename); + if (newnode->actualfile != NULL) + newnode->actualfile = freopen(newnode->actualfile_NAME, "r", + newnode->actualfile); + else + newnode->actualfile = fopen(newnode->actualfile_NAME, "r"); + _SETIO(newnode->actualfile != NULL, FileNotFound); + inputerror = (P_ioresult != 0); + if (inputerror) + Free(newnode); + else + current = newnode; + if (!inputerror && (reportitem & reportnewfile) > 0) + printf("==>> Input from file %s\n", currentFilename(STR3)); + if (inputerror && (reportitem & reporterror) > 0) + printf("==!! Could not open file %s\n", filename); +} + + +void popFile(void) +{ + filenode *previous; + Char STR2[256]; + Char STR3[256]; + + if (current == NULL) + return; + if ((reportitem & reportclose) > 0) + printf("==>> Closing file %s at line number %d\n", + currentFilename(STR2), currentLineNo()); + if (current->actualfile != NULL) + fclose(current->actualfile); + current->actualfile = NULL; + previous = current->prev; + Free(current); + current = previous; + if (current != NULL && (reportitem & reportoldfile) > 0) + printf("==>> Resuming input from file %s at line number %d\n", + currentFilename(STR3), currentLineNo()); +} + + +void closeAll(void) +{ + do { + popFile(); + } while (current != NULL); +} + + +boolean eofCurrent(void) +{ + return P_eof(current->actualfile); +} + + +Char *readLine(Char *Result) +{ + Char s[256]; + Char *TEMP; + Char STR2[256]; + + if (*nextData != '\0') { + strcpy(Result, nextData); + *nextData = '\0'; + return Result; + } + if (eofAll()) + return strcpy(Result, ""); + _SETIO(fgets(s, 256, current->actualfile) != NULL, EndOfFile); + TEMP = strchr(s, '\n'); + if (TEMP != NULL) + *TEMP = 0; + strcpy(Result, s); + inputerror = (P_ioresult != 0); + if (!inputerror) + current->lineno++; + if (inputerror && (reportitem & reporterror) > 0) + printf("==!! Could not read from file %s\n", currentFilename(STR2)); + return Result; +} + + +boolean isEmpty(Char *s) +{ + short i, FORLIM; + + if (*s == '\0') + return true; + FORLIM = strlen(s); + for (i = 0; i <= FORLIM - 1; i++) { + if (s[i] != ' ') + return false; + } + return true; +} + + +Char *readData(Char *Result) +{ + Char s[256]; + + if (!isEmpty(nextData)) { + strcpy(Result, nextData); + *nextData = '\0'; + return Result; + } + while (!eofAll()) { + readLine(s); + if (!isEmpty(s)) + return strcpy(Result, s); + } + return strcpy(Result, ""); +} + + +void skipBlanks(void) +{ + while (*nextData == '\0') { + readData(nextData); + if (eofAll()) + return; + } +} + + +boolean eofAll(void) +{ + boolean Result; + +/* p2c: multfile.pas: Note: Eliminated unused assignment statement [338] */ + if (current == NULL) + return true; + if (eofCurrent()) { + popFile(); + return (eofAll()); + } + return false; +} + + +short currentLineNo(void) +{ + if (current == NULL) + return 0; + else + return (current->lineno); +} + + +Char *currentFilename(Char *Result) +{ + if (current == NULL) + return strcpy(Result, "No file open yet"); + else + return strcpy(Result, current->name); +} + + +boolean fileError(void) +{ + return inputerror; +} + + + + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/multfile.h b/Build/source/utils/m-tx/mtx-src/multfile.h new file mode 100644 index 00000000000..aaa094cdae7 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/multfile.h @@ -0,0 +1,87 @@ +/* Header for module multfile, generated by p2c 1.21alpha-07.Dec.93 */ +#ifndef MULTFILE_H +#define MULTFILE_H + + +#ifdef MULTFILE_G +# define vextern +#else +# define vextern extern +#endif +/* DPL 2004-03-06 +(* Support for including files into an input stream. +(* Intended for an application that does not require Pascal formatting, +(* but reads complete lines one at a time. +(* You never actually work with any files, except by supplying the +( filename when the file is opened. +(* At any stage, you can switch the input to a new file. +(* When the new file is at EOF, and a "read" is issued, the file is +(* closed and the previous one resumed transparently. This inclusion +(* can be nested to any level, memory permitting. +(* --- Normal mode of operation, replacing the usual Pascal style --- + Instead of: assign(textfile,filename); reset(textfile) + use: pushFile(filename) + When another file should be included before the current file is done, + use: pushFile(newfilename) + Instead of: readln(textfile,line) + use: line:=readLine + Instead of: eof(textfilen) + or: eofAll; {Are all files at EOF?} +(* --- Abnormal mode of operation --- + To abort a file before EOF is reached: + use: popFile; + To abort all files: + use: closeAll; + To test whether only the current file is at EOF: + use: eofCurrent; +(* Additional features: + fileError: boolean function, was there an error during file open or read? + currentFilename: string function, name of current file + currentLineNo: integer function, number of line just read from current file + isEmpty(var s: string): boolean function, is s empty? + readData: string function, like readLine, but continue reading until + a non-blank line is found, return blank only at EOF + skipBlanks: skip blank lines in input: next call to readLine will be + non-blank unless EOF is encountered + report(items): procedure to control which messages are printed, + "items" is the sum of the following options + (constants with the appropriate values are defined in the interface) + 1: reportnewfile - file is opened + 2: reportoldfile - file is resumed + 4: reportclose - file is closed + 8: reporterror - a file error is encountered + 16: reportrecursive - there is a recursive include + The default value is items=27 (all the above except reportclose) + At present you cannot turn reportrecursive off. + */ + +extern void pushFile(Char *filename); +extern void popFile(void); +extern void closeAll(void); +extern void report(short items); +extern Char *currentFilename(Char *Result); +extern boolean eofAll(void); +extern boolean eofCurrent(void); +extern boolean fileError(void); +extern Char *readLine(Char *Result); +extern Char *readData(Char *Result); +extern boolean isEmpty(Char *s); +extern short currentLineNo(void); +extern void skipBlanks(void); + + +#define reportnewfile 1 +#define reportoldfile 2 +#define reportclose 4 +#define reporterror 8 +#define reportrecursive 16 + + +extern Char nextData[256]; + + +#undef vextern + +#endif /*MULTFILE_H*/ + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/multfile.pas b/Build/source/utils/m-tx/mtx-src/multfile.pas new file mode 100644 index 00000000000..6c272992a3f --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/multfile.pas @@ -0,0 +1,196 @@ +unit multfile; (* DPL 2004-03-06 +(* Support for including files into an input stream. +(* Intended for an application that does not require Pascal formatting, +(* but reads complete lines one at a time. +(* You never actually work with any files, except by supplying the +( filename when the file is opened. +(* At any stage, you can switch the input to a new file. +(* When the new file is at EOF, and a "read" is issued, the file is +(* closed and the previous one resumed transparently. This inclusion +(* can be nested to any level, memory permitting. +(* --- Normal mode of operation, replacing the usual Pascal style --- + Instead of: assign(textfile,filename); reset(textfile) + use: pushFile(filename) + When another file should be included before the current file is done, + use: pushFile(newfilename) + Instead of: readln(textfile,line) + use: line:=readLine + Instead of: eof(textfilen) + or: eofAll; {Are all files at EOF?} +(* --- Abnormal mode of operation --- + To abort a file before EOF is reached: + use: popFile; + To abort all files: + use: closeAll; + To test whether only the current file is at EOF: + use: eofCurrent; +(* Additional features: + fileError: boolean function, was there an error during file open or read? + currentFilename: string function, name of current file + currentLineNo: integer function, number of line just read from current file + isEmpty(var s: string): boolean function, is s empty? + readData: string function, like readLine, but continue reading until + a non-blank line is found, return blank only at EOF + skipBlanks: skip blank lines in input: next call to readLine will be + non-blank unless EOF is encountered + report(items): procedure to control which messages are printed, + "items" is the sum of the following options + (constants with the appropriate values are defined in the interface) + 1: reportnewfile - file is opened + 2: reportoldfile - file is resumed + 4: reportclose - file is closed + 8: reporterror - a file error is encountered + 16: reportrecursive - there is a recursive include + The default value is items=27 (all the above except reportclose) + At present you cannot turn reportrecursive off. + *) +interface + + procedure pushFile(filename: string); + procedure popFile; + procedure closeAll; + procedure report(items: integer); + function currentFilename: string; + function eofAll: boolean; + function eofCurrent: boolean; + function fileError: boolean; + function readLine: string; + function readData: string; + function isEmpty(var s: string): boolean; + function currentLineNo: integer; + procedure skipBlanks; + const nextData: string = ''; + +const + reportnewfile = 1; + reportoldfile = 2; + reportclose = 4; + reporterror = 8; + reportrecursive = 16; + +implementation + + type + pfilenode = ^filenode; + filenode = record + name: string; + actualfile: text; + prev: pfilenode; + lineno: integer; + end; + + const current: pfilenode = NIL; + inputerror: boolean = false; + reportitem: integer = reportnewfile + reportoldfile + + reporterror + reportrecursive; + + procedure report(items: integer); begin reportitem := items end; + + function recursive (filename: string): boolean; + var previous: pfilenode; + begin if current=NIL then begin recursive:=false; exit; end; + previous := current; recursive:=true; + while previous <> NIL do + begin + if filename=previous^.name then exit; + previous := previous^.prev; + end; + recursive:=false + end; + + procedure pushFile(filename: string); + var newnode: pfilenode; + begin + if recursive(filename) then + begin writeln('===! Ignoring recursive include of file ',filename); exit; + end; + new(newnode); newnode^.name := filename; newnode^.prev := current; + newnode^.lineno := 0; +{$I-} + assign(newnode^.actualfile,filename); reset(newnode^.actualfile); +{$I+} + inputerror := ioresult<>0; + if inputerror then dispose(newnode) else current := newnode; + if not inputerror and ((reportitem and reportnewfile)>0) then writeln + ('==>> Input from file ',currentFilename); + if inputerror and ((reportitem and reporterror)>0) then writeln + ('==!! Could not open file ',filename); + end; + + procedure popFile; + var previous: pfilenode; + begin if current=NIL then exit; + if (reportitem and reportclose)>0 then writeln + ('==>> Closing file ',currentFilename,' at line number ', currentLineNo:1); + close(current^.actualfile); previous := current^.prev; dispose(current); + current := previous; + if (current<>NIL) and ((reportitem and reportoldfile)>0) then writeln + ('==>> Resuming input from file ',currentFilename,' at line number ', + currentLineNo:1); + end; + + procedure closeAll; begin repeat popFile until current=NIL; end; + + function eofCurrent: boolean; + begin eofCurrent := eof(current^.actualfile); + end; + + function readLine: string; + var s: string; + begin if nextData<>'' then + begin readLine:=nextData; nextData:=''; exit end; + if eofAll then begin readLine:=''; exit end; +{$I-} + readln(current^.actualfile,s); readLine:=s; +{$I+} + inputerror := ioresult<>0; + if not inputerror then inc(current^.lineno); + if inputerror and ((reportitem and reporterror)>0) then writeln + ('==!! Could not read from file ',currentFilename); + end; + + function isEmpty(var s: string): boolean; + var i: integer; + begin if length(s)=0 then begin isEmpty:=true; exit; end; + for i:=1 to length(s) do if s[i]<>' ' then + begin isEmpty:=false; exit; end; + isEmpty:=true + end; + + function readData: string; + var s: string; + begin if not isEmpty(nextData) then + begin readData:=nextData; nextData:=''; exit end; + while not eofAll do + begin s:=readLine; + if not isEmpty(s) then begin readData:=s; exit end; + end; + readData:=''; + end; + + procedure skipBlanks; + begin while nextData='' do + begin nextData:=readData; if eofAll then exit + end + end; + + function eofAll: boolean; + begin eofAll := true; + if current=NIL then exit else + if eofCurrent then begin popFile; eofAll:=eofAll; exit end; + eofAll:=false + end; + + function currentLineNo: integer; + begin if current = NIL then currentLineNo := 0 + else currentLineNo := current^.lineno; + end; + + function currentFilename: string; + begin if current = NIL then currentFilename := 'No file open yet' + else currentFilename := current^.name; + end; + + function fileError: boolean; begin fileError := inputerror; end; + +end. diff --git a/Build/source/utils/m-tx/mtx-src/notes.c b/Build/source/utils/m-tx/mtx-src/notes.c new file mode 100644 index 00000000000..88d85791bdb --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/notes.c @@ -0,0 +1,511 @@ +/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ +/* From input file "notes.pas" */ + + + +#include "p2c.h" + +#define NOTES_G +#include "notes.h" + + +short count64['9' + 1 - '0'] = { + 64, 4, 32, 2, 16, 0, 1, 0, 8, 128 +}; + +#ifndef STRINGS_H +#include "strings.h" +#endif + +#ifndef GLOBALS_H +#include "globals.h" +#endif + + +typedef struct parsedNote { + Char name; + Char duration[2]; + Char octave[9]; + Char accidental[17], whatever[17], dotgroup[17], xtuplet[17]; + Char shortcut[33]; +} parsedNote; + + +Static void printNote(parsedNote n) +{ + printf("%c|%s|%s|%s|%s|%s|%s|%s\n", + n.name, n.duration, n.octave, n.accidental, n.whatever, n.dotgroup, + n.xtuplet, n.shortcut); +} + + +/* If rearrangeNote is TRUE, translate original note to the following form: + 1. Note name. + 2. Duration. + 3. Octave adjustments. + 4. Everything except the other six items. + 5. Accidental with adjustments (rest: height adjustment) + 6. Dot with adjustments. + 7. Xtuplet group. +*/ + +void translateSolfa(Char *nt) +{ + short k; + + if (!solfaNoteNames()) + return; + k = pos1(*nt, solfa_names); + if (k > 0) + *nt = has_duration[k-1]; +} + + +Char durationCode(Char *note) +{ + Char Result = unspecified; + Char code; + + if (strlen(note) <= 1) + return Result; + code = note[1]; + if (pos1(code, durations) > 0) + return code; + return Result; +} + + +Static Char half(Char dur) +{ + Char Result; + short k; + Char STR1[20]; + Char STR2[24]; + + k = pos1(dur, durations); + Result = dur; + if (k == 0) { + sprintf(STR1, "Invalid duration %c", dur); + error(STR1, print); + return Result; + } + if (k <= ndurs) + return (durations[k]); + sprintf(STR2, "%c is too short to halve", dur); + error(STR2, print); + return Result; +} + + +Static void addDuration(Char *note, Char dur) +{ + if (insertDuration()) + insertChar(dur, note, 2); +} + + +/* Extract procedures. All of these remove part of "note" (sometimes + the part is empty) and put it somewhere else. The part may be anywhere + in "note", except when otherwise specified.*/ + +/* Unconditionally extracts the first character. */ + +Static void extractFirst(Char *note, Char *first) +{ + *first = note[0]; + predelete(note, 1); +} + + +/* Extracts at most one of the characters in "hits". */ + +Static void extractOneOf(Char *note, Char *hits, Char *hit) +{ + short i, l; + + l = strlen(note); + *hit = '\0'; + for (i = 1; i <= l; i++) { + if (pos1(note[i-1], hits) > 0) { + sprintf(hit, "%c", note[i-1]); + delete1(note, i); + return; + } + } +} + + +/* Extracts contiguous characters in "hits" until no more are found. + There may be more later. */ + +Static void extractContiguous(Char *note, Char *hits, Char *hit) +{ + short i, l, len; + + l = strlen(note); + len = l; + *hit = '\0'; + for (i = 1; i <= l; i++) { + if (pos1(note[i-1], hits) > 0) { + do { + if (pos1(note[i-1], hits) == 0) + return; + sprintf(hit + strlen(hit), "%c", note[i-1]); + delete1(note, i); + len--; + } while (len >= i); + return; + } + } +} + + +/* Extracts the specified character and everything after it. */ + +Static void extractAfter(Char *note, Char delim, Char *tail) +{ + short newlen; + + newlen = pos1(delim, note); + *tail = '\0'; + if (newlen == 0) + return; + newlen--; + strcpy(tail, note); + predelete(tail, newlen); + note[(long)((int)newlen)] = '\0'; +/* p2c: notes.pas, line 109: + * Note: Modification of string length may translate incorrectly [146] */ +} + + +/* Extracts the dot shortcut part of a note: comma shortcut is no problem + because a comma cannot be part of a number. */ + +Static void extractDotShortcut(Char *note, Char *tail) +{ + Char names[256], tail2[256]; + short l = 1; + short lt; + Char ch; + + extractAfter(note, '.', tail); + lt = strlen(tail); + if (l < lt && tail[1] == '.') + l = 2; + if (solfaNoteNames()) + strcpy(names, solfa_names); + else + strcpy(names, has_duration); + if (l < lt && pos1(tail[l], names) > 0) { + translateSolfa(&tail[l]); + return; + } + if (l == 2) + error("\"..\" followed by non-note", print); + if (l >= lt) { + strcat(note, tail); + *tail = '\0'; + return; + } + ch = tail[0]; + predelete(tail, 1); + extractDotShortcut(tail, tail2); + sprintf(note + strlen(note), "%c%s", ch, tail); + strcpy(tail, tail2); +} + + +/* Extracts a signed number. */ + +Static void extractSignedNumber(Char *note, Char *number) +{ + short k; + Char note0[256]; + + k = pos1('+', note); + if (k == 0) + k = pos1('-', note); + *number = '\0'; + if (k == 0) + return; + strcpy(note0, note); + do { + sprintf(number + strlen(number), "%c", note[k-1]); + delete1(note, k); + } while (k <= strlen(note) && + (note[k-1] == '0' || pos1(note[k-1], digits) != 0)); + if (strlen(number) == 1) { + strcpy(note, note0); + *number = '\0'; + } +} + + +/* Local variables for extractGroup: */ +struct LOC_extractGroup { + Char *group; + short gl, k; + boolean probe, nonumber; +} ; + +Local void tryMore(struct LOC_extractGroup *LINK) +{ + while (LINK->k <= LINK->gl && LINK->group[LINK->k-1] == LINK->group[0]) + LINK->k++; +} + +Local void try_(Char *s, struct LOC_extractGroup *LINK) +{ + LINK->probe = (LINK->k < LINK->gl && pos1(LINK->group[LINK->k-1], s) > 0); + if (LINK->probe) + LINK->k++; +} + +Local void tryNumber(struct LOC_extractGroup *LINK) +{ + boolean dot_ = false; + + LINK->nonumber = true; + while (LINK->k <= LINK->gl && pos1(LINK->group[LINK->k-1], digitsdot) > 0) { + LINK->k++; + if (LINK->group[LINK->k-1] == '.') { + if (dot_) + error("Extra dot in number", print); + else + dot_ = true; + } else + LINK->nonumber = false; + } +} + + +/* Extracts a symbol followed by optional +- or <> shift indicators */ + +Static void extractGroup(Char *note, Char delim, Char *group_) +{ + struct LOC_extractGroup V; + short k0; + Char tail[256]; + + V.group = group_; + extractAfter(note, delim, V.group); + if (*V.group == '\0') + return; + V.gl = strlen(V.group); + V.k = 2; + if (V.gl > 1 && V.group[1] == ':') + V.k = 3; + else { + tryMore(&V); + k0 = V.k; + try_("+-<>", &V); + if (V.probe) + tryNumber(&V); + if (V.nonumber) + V.k = k0; + k0 = V.k; + try_("+-<>", &V); + if (V.probe) + tryNumber(&V); + if (V.nonumber) + V.k = k0; + } + strcpy(tail, V.group); + V.k--; + V.group[(long)((int)V.k)] = '\0'; +/* p2c: notes.pas, line 170: + * Note: Modification of string length may translate incorrectly [146] */ + predelete(tail, V.k); + strcat(note, tail); +} + + +Static void parseNote(Char *note_, parsedNote *pnote) +{ + Char note[256]; + Char onlymidi[256]; + Char STR1[256]; + Char STR2[10]; + + strcpy(note, note_); + *pnote->shortcut = '\0'; + *pnote->xtuplet = '\0'; + *pnote->accidental = '\0'; + *pnote->dotgroup = '\0'; + *pnote->duration = '\0'; + *pnote->octave = '\0'; + *onlymidi = '\0'; + extractFirst(note, &pnote->name); + extractAfter(note, 'x', pnote->xtuplet); + extractAfter(note, ',', pnote->shortcut); + if (*pnote->shortcut == '\0') + extractDotShortcut(note, pnote->shortcut); + if (pnote->name != rest) { + extractGroup(note, 's', pnote->accidental); + if (*pnote->accidental == '\0') + extractGroup(note, 'f', pnote->accidental); + if (*pnote->accidental == '\0') + extractGroup(note, 'n', pnote->accidental); + } + /* Look for 'i' or 'c' anywhere in what is left of note.*/ + if (*pnote->accidental != '\0') { + extractOneOf(note, "ic", onlymidi); + strcat(pnote->accidental, onlymidi); +/* p2c: notes.pas, line 192: + * Note: Possible string truncation in assignment [145] */ + } + extractGroup(note, 'd', pnote->dotgroup); + if (pnote->name == rest) + extractSignedNumber(note, pnote->accidental); + extractOneOf(note, durations, pnote->duration); + sprintf(STR1, "%c", rest); + if (strcmp(note, STR1)) + extractContiguous(note, "=+-", pnote->octave); + if (*note != '\0' && isdigit(note[0])) { + sprintf(STR2, "%c%s", note[0], pnote->octave); + strcpy(pnote->octave, STR2); +/* p2c: notes.pas, line 198: + * Note: Possible string truncation in assignment [145] */ + delete1(note, 1); + } + strcpy(pnote->whatever, note); +/* p2c: notes.pas, line 200: + * Note: Possible string truncation in assignment [145] */ +} + + +/* On input: "note" is a note word; "dur1" is the default duration. + On output: "note" has possibly been modified; + possibly been split into two parts, the second being "shortcut"; + "dur" is the suggested new default duration; + "count" is the count of the total of "note" and "shortcut" */ +void processNote(Char *note, Char *xnote, Char dur1, Char *dur, short *count) +{ + Char sc[3], origdur[3]; + short multiplicity, l; + parsedNote pnote; + Char STR1[36]; + Char STR3[256]; + + *xnote = '\0'; + *dur = dur1; + if (*note == '\0' || !isNoteOrRest(note) || isPause(note)) + return; + parseNote(note, &pnote); + if (debugMode()) { + printf("%s => ", note); + printNote(pnote); + } + if (pos1('.', pnote.whatever) > 0) { + sprintf(STR3, "Suspicious dot in word %s", note); + warning(STR3, print); + } + strcpy(origdur, pnote.duration); + if (*pnote.duration == '\0') + *dur = dur1; + else + *dur = pnote.duration[0]; + *count = count64[*dur - '0']; + if (*pnote.dotgroup != '\0') { + *count += *count / 2; + if (startsWith(pnote.dotgroup, "dd")) + *count += *count / 6; + } + sprintf(pnote.duration, "%c", *dur); + if (*pnote.shortcut != '\0') { + if (*pnote.dotgroup != '\0') + error("You may not explicitly dot a note with a shortcut", print); + sprintf(sc, "%c", pnote.shortcut[0]); + predelete(pnote.shortcut, 1); + if (!strcmp(sc, ".")) { + multiplicity = 1; + if (pnote.shortcut[0] == '.') { + multiplicity++; + predelete(pnote.shortcut, 1); + strcat(sc, "."); +/* p2c: notes.pas, line 234: + * Note: Possible string truncation in assignment [145] */ + } + *count += *count; + dur1 = pnote.duration[0]; + for (l = 1; l <= multiplicity; l++) { + sprintf(pnote.dotgroup + strlen(pnote.dotgroup), "%c", dotcode); +/* p2c: notes.pas, line 237: + * Note: Possible string truncation in assignment [145] */ + dur1 = half(dur1); + } + addDuration(pnote.shortcut, dur1); + } else { + addDuration(pnote.shortcut, half(pnote.duration[0])); + *count += *count / 2; + } + } + if (!insertDuration()) { + strcpy(pnote.duration, origdur); +/* p2c: notes.pas, line 244: + * Note: Possible string truncation in assignment [145] */ + } + if (rearrangeNote()) + sprintf(note, "%c%s%s%s%s%s%s", + pnote.name, pnote.duration, pnote.octave, pnote.whatever, + pnote.accidental, pnote.dotgroup, pnote.xtuplet); + else + strcpy(pnote.shortcut, " "); + if (!insertDuration() && *pnote.shortcut != '\0') { + sprintf(STR1, "%s%s", sc, pnote.shortcut); + strcpy(pnote.shortcut, STR1); +/* p2c: notes.pas, line 249: + * Note: Possible string truncation in assignment [145] */ + } + strcpy(xnote, pnote.shortcut); +} + + +Char octaveCode(Char *note) +{ /*if debugMode then write('Octave code in note "',note,'" is ');*/ + parsedNote pnote; + + parseNote(note, &pnote); + /*if debugMode then writeln('"',octave,'"');*/ + if (*pnote.octave == '\0') + return ' '; + else + return (pnote.octave[0]); +} + + +void removeOctaveCode(Char code, Char *note) +{ /*if debugMode then writeln('remove ',code,' from ',note);*/ + short k, l; + + l = strlen(note); + for (k = 1; k <= l; k++) { + if (note[k-1] == code) { + if (k == l || note[k] < '0' || note[k] > '9') { + delete1(note, k); + return; + } + } + } + fatalerror("Code not found in note"); +} + + +void insertOctaveCode(Char code, Char *note) +{ /*if debugMode then writeln('insert ',code,' into ',note); */ + short l; + + l = strlen(note); + if (l < 2 || note[1] < '0' || note[1] > '9') + fatalerror("Trying to insert octave into note without duration"); + if (l <= 2 || note[2] < '0' || note[2] > '9') + insertChar(code, note, 3); + else + printf("Not inserting \"%c\", note already has octave code\"\n", code); +} + + + + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/notes.h b/Build/source/utils/m-tx/mtx-src/notes.h new file mode 100644 index 00000000000..8806ef868cc --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/notes.h @@ -0,0 +1,36 @@ +/* Header for module notes, generated by p2c 1.21alpha-07.Dec.93 */ +#ifndef NOTES_H +#define NOTES_H + + +/*$V-*/ + +#ifndef CONTROL_H +#include "control.h" +#endif + + +#ifdef NOTES_G +# define vextern +#else +# define vextern extern +#endif + + +extern short count64['9' + 1 - '0']; + + +extern void processNote(Char *note, Char *xnote, Char dur1, Char *dur, + short *count); +extern Char durationCode(Char *note); +extern Char octaveCode(Char *note); +extern void removeOctaveCode(Char code, Char *note); +extern void insertOctaveCode(Char code, Char *note); +extern void translateSolfa(Char *nt); + + +#undef vextern + +#endif /*NOTES_H*/ + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/notes.pas b/Build/source/utils/m-tx/mtx-src/notes.pas new file mode 100644 index 00000000000..2f6a01505f5 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/notes.pas @@ -0,0 +1,281 @@ +unit notes; +{$V-} + +interface uses control; + +const count64: array['0'..'9'] of integer = + ( 64, 4, 32, 2, 16, 0, 1, 0, 8, 128 ); + +procedure processNote(var note, xnote: string; dur1: char; var dur: char; + var count: integer); +function durationCode (note: string): char; +function octaveCode (note: string): char; +procedure removeOctaveCode(code: char; var note: string); +procedure insertOctaveCode(code: char; var note: string); +procedure translateSolfa(var nt: char); + +implementation uses strings, globals; + +type + +parsedNote = record + name: char; + duration: string[1]; + octave: string[8]; + accidental, whatever, dotgroup, xtuplet: string[16]; + shortcut: string[32]; +end; + +procedure printNote(n: parsedNote); +begin with n do writeln(name,'|',duration,'|',octave,'|',accidental,'|', + whatever,'|',dotgroup,'|',xtuplet,'|',shortcut) +end; + +{ If rearrangeNote is TRUE, translate original note to the following form: + 1. Note name. + 2. Duration. + 3. Octave adjustments. + 4. Everything except the other six items. + 5. Accidental with adjustments (rest: height adjustment) + 6. Dot with adjustments. + 7. Xtuplet group. +} + +procedure translateSolfa(var nt: char); + var k: integer; +begin if solfaNoteNames then + begin k:=pos1(nt,solfa_names); if k>0 then nt:=has_duration[k] + end +end; + +function durationCode (note: string): char; + var code: char; + begin durationCode:=unspecified; if length(note)>1 then + begin code:=note[2]; if pos1(code,durations)>0 then durationCode:=code + end + end; + +function half ( dur: char ) : char; + var k: integer; + begin k:= pos1 (dur, durations ); half := dur; + if k=0 then error ('Invalid duration '+dur,print) + else if k>ndurs then error (dur+' is too short to halve',print) + else half := durations[k+1]; + end; + +procedure addDuration ( var note: string; dur: char); +begin if insertDuration then insertchar(dur,note,2); end; + +{ Extract procedures. All of these remove part of "note" (sometimes + the part is empty) and put it somewhere else. The part may be anywhere + in "note", except when otherwise specified.} + +{ Unconditionally extracts the first character. } + +procedure extractFirst(var note: string; var first: char); +begin first:=note[1]; predelete(note,1) +end; + +{ Extracts at most one of the characters in "hits". } + +procedure extractOneOf(var note: string; hits: string; var hit: string); + var i, l: integer; +begin l:=length(note); hit:=''; + for i:=1 to l do if pos1(note[i],hits)>0 then + begin hit:=note[i]; delete1(note,i); exit; + end; +end; + +{ Extracts contiguous characters in "hits" until no more are found. + There may be more later. } + +procedure extractContiguous(var note: string; hits: string; var hit: string); + var i, l, len: integer; +begin l:=length(note); len:=l; hit:=''; + for i:=1 to l do if pos1(note[i],hits)>0 then + begin + repeat if pos1(note[i],hits)=0 then exit; + hit:=hit+note[i]; delete1(note,i); dec(len) + until len0) then + begin translateSolfa(tail[l+1]); exit end; + if l=2 then error('".." followed by non-note',print); + if l>=lt then begin note:=note+tail; tail:=''; exit end; + ch:=tail[1]; predelete(tail,1); + extractDotShortcut(tail,tail2); note:=note+ch+tail; tail:=tail2; +end; + +{ Extracts a signed number. } + +procedure extractSignedNumber(var note, number: string); + var k: integer; + note0: string; +begin k:=pos1('+',note); if k=0 then k:=pos1('-',note); + number:=''; if k=0 then exit; + note0:=note; + repeat number:=number+note[k]; delete1(note,k) + until (k>length(note)) or (note[k]<>'0') and (pos1(note[k],digits)=0); + if length(number)=1 then begin note:=note0; number:='' end +end; + +{ Extracts a symbol followed by optional +- or <> shift indicators } + +procedure extractGroup(var note: string; delim: char; var group: string); + var gl, k, k0: integer; + probe, nonumber: boolean; + tail: string; + procedure tryMore; + begin while (k<=gl) and (group[k]=group[1]) do inc(k) end; + procedure try(s: string); + begin probe:=(k0); if probe then inc(k) + end; + procedure tryNumber; + var dot: boolean; + begin nonumber:=true; dot:=false; + while (k<=gl) and (pos1(group[k],digitsdot)>0) do + begin inc(k); if group[k]='.' then + if dot then error('Extra dot in number',print) else dot:=true + else nonumber:=false + end + end; +begin extractAfter(note,delim,group); if group='' then exit; + gl:=length(group); k:=2; + if (gl>1) and (group[2]=':') then k:=3 else + begin tryMore; + k0:=k; try('+-<>'); if probe then tryNumber; if nonumber then k:=k0; + k0:=k; try('+-<>'); if probe then tryNumber; if nonumber then k:=k0; + end; + tail:=group; dec(k); group[0]:=char(k); predelete(tail,k); + note:=note+tail +end; + +procedure parseNote(note: string; var pnote: parsedNote); +var onlymidi: string; +begin with pnote do + begin + shortcut:=''; xtuplet:=''; accidental:=''; dotgroup:=''; + duration:=''; octave:=''; onlymidi:=''; + extractFirst(note,name); + extractAfter(note,'x',xtuplet); + extractAfter(note,',',shortcut); + if shortcut='' then extractDotShortcut(note,shortcut); + if name<>rest then + begin extractGroup(note,'s',accidental); + if accidental='' then extractGroup(note,'f',accidental); + if accidental='' then extractGroup(note,'n',accidental); + end; +{ Look for 'i' or 'c' anywhere in what is left of note.} + if accidental<>'' then + begin extractOneOf(note,'ic',onlymidi); accidental:=accidental+onlymidi + end; + extractGroup(note,'d',dotgroup); + if name=rest then extractSignedNumber(note,accidental); + extractOneOf(note,durations,duration); + if note<>rest then extractContiguous(note,'=+-',octave); + if (length(note)>0) and (note[1]>='0') and (note[1]<='9') + then begin octave:=note[1]+octave; delete1(note,1) end; + whatever := note + end +end; + +{ On input: "note" is a note word; "dur1" is the default duration. + On output: "note" has possibly been modified; + possibly been split into two parts, the second being "shortcut"; + "dur" is the suggested new default duration; + "count" is the count of the total of "note" and "shortcut" } +procedure processNote(var note, xnote: string; dur1: char; var dur: char; + var count: integer); +var sc, origdur: string[2]; + multiplicity, l: integer; + pnote: parsedNote; +begin xnote:=''; dur:=dur1; + if (note='') or not isNoteOrRest(note) or isPause(note) then exit; + parseNote(note, pnote); + if debugMode then begin write(note,' => '); printNote(pnote) end; + with pnote do + begin + if pos1('.',whatever)>0 then warning('Suspicious dot in word '+note,print); + origdur := duration; + if duration='' then dur:=dur1 else dur:=duration[1]; + count:=count64[dur]; if dotgroup<>'' then + begin inc(count,count div 2); + if startswith(dotgroup,'dd') then inc(count,count div 6) + end; + duration:=dur; if shortcut<>'' then + begin + if dotgroup<>'' then + error('You may not explicitly dot a note with a shortcut',print); + sc:=shortcut[1]; predelete(shortcut,1); + if sc='.' then + begin multiplicity:=1; + if shortcut[1]='.' then + begin inc(multiplicity); predelete(shortcut,1); sc:=sc+'.' end; + inc(count,count); dur1:=duration[1]; + for l:=1 to multiplicity do + begin dotgroup:=dotgroup+dotcode; dur1:=half(dur1) end; + addDuration(shortcut,dur1); + end else + begin addDuration(shortcut,half(duration[1])); + inc(count,count div 2) + end + end; + if not insertDuration then duration := origdur; + if rearrangeNote + then note := name + duration + octave + whatever + + accidental + dotgroup + xtuplet + else shortcut:=' '; + if not insertDuration and (shortcut<>'') then shortcut:=sc+shortcut; + xnote:=shortcut + end +end; + +function octaveCode (note: string): char; + var pnote: parsedNote; +begin {if debugMode then write('Octave code in note "',note,'" is ');} + parseNote(note,pnote); with pnote do + begin {if debugMode then writeln('"',octave,'"');} + if octave='' then octaveCode:=' ' else octaveCode:=octave[1]; end +end; + +procedure removeOctaveCode(code: char; var note: string); + var k, l: integer; +begin {if debugMode then writeln('remove ',code,' from ',note);} l:=length(note); + for k:=1 to l do if note[k]=code then + if (k=l) or (note[k+1]<'0') or (note[k+1]>'9') then + begin delete1(note,k); exit end; + fatalError('Code not found in note') +end; + +procedure insertOctaveCode(code: char; var note: string); + var l: integer; +begin {if debugMode then writeln('insert ',code,' into ',note); } + l:=length(note); + if (l<2) or (note[2]<'0') or (note[2]>'9') then + fatalError('Trying to insert octave into note without duration'); + if (l<=2) or (note[3]<'0') or (note[3]>'9') then insertChar(code,note,3) + else writeln('Not inserting "',code,'", note already has octave code"') +end; + +end. diff --git a/Build/source/utils/m-tx/mtx-src/preamble.c b/Build/source/utils/m-tx/mtx-src/preamble.c new file mode 100644 index 00000000000..15b84b4ee02 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/preamble.c @@ -0,0 +1,1195 @@ +/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ +/* From input file "preamble.pas" */ + + +#include "p2c.h" + +#define PREAMBLE_G +#include "preamble.h" + + +#ifndef CONTROL_H +#include "control.h" +#endif + +#ifndef MTXLINE_H +#include "mtxline.h" +#endif + +#ifndef STRINGS_H +#include "strings.h" +#endif + +#ifndef MULTFILE_H +#include "multfile.h" +#endif + +#ifndef FILES_H +#include "files.h" +#endif + +#ifndef STATUS_H +#include "status.h" +#endif + +#ifndef UTILITY_H +#include "utility.h" +#endif + + +#define blank_ ' ' +#define colon_ ':' +#define semicolon ';' +#define comma_ ',' + +#define max_styles 24 + + +typedef enum { + none, title, composer, pmx, tex, options, msize, bars, shortnote, style, + sharps, flats, meter, space, pages, systems, width, height, enable, disable, + range, name, indent, poet, part, only, octave_, start +} command_type; + +typedef enum { + unknown, colon_line, command_line, comment_line, plain_line +} line_type; + +typedef char style_index; + +typedef char style_index0; + + +#define c1 title +#define cn start + + +Static short known_styles = 12; +Static boolean warn_redefine = false; + +Static Char commands[28][17] = { + "NONE", "TITLE", "COMPOSER", "PMX", "TEX", "OPTIONS", "SIZE", "BARS/LINE", + "SHORT", "STYLE", "SHARPS", "FLATS", "METER", "SPACE", "PAGES", "SYSTEMS", + "WIDTH", "HEIGHT", "ENABLE", "DISABLE", "RANGE", "NAME", "INDENT", "POET", + "PART", "ONLY", "OCTAVE", "START" +}; + +/* short */ +/* systems */ + +Static Char cline[28][256] = { + "", "", "", "", "", "", "", "", "1/4", "", "0", "", "C", "", "1", "1", + "190mm", "260mm", "", "", "", "", "", "", "", "", "", "" +}; + +Static boolean redefined[28] = { + false, false, false, false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false, false, false, + false, false, false, false, false, false +}; + +/** Known styles */ + +Static Char known_style[max_styles][256] = { + "SATB: Voices S,A T,B; Choral; Clefs G F", + "SATB4: Voices S A T B; Choral; Clefs G G G8 F", + "SINGER: Voices Voice; Vocal; Clefs G", + "PIANO: Voices RH LH; Continuo; Clefs G F", + "ORGAN: Voices RH LH Ped; Continuo; Clefs G F F", + "SOLO: Voices V; Clefs G", "DUET: Voices V1 Vc; Clefs G F", + "TRIO: Voices V1 Va Vc; Clefs G C F", + "QUARTET: Voices V1 V2 Va Vc; Clefs G G C F", + "QUINTET: Voices V1 V2 Va Vc1 Vc2; Clefs G G C F F", + "SEXTET: Voices V1 V2 Va1 Va2 Vc1 Vc2; Clefs G G C C F F", + "SEPTET: Voices V1 V2 Va1 Va2 Vc1 Vc2 Cb; Clefs G G C C F F F", "", "", "", + "", "", "", "", "", "", "", "", "" +}; + +Static style_index old_known_styles; +Static boolean style_used[max_styles]; +Static boolean omit_line[lines_in_paragraph]; +Static style_index0 orig_style_line[max_styles]; +Static short orig_range_line; + +Static short nclefs, n_pages, n_systems, n_sharps, ngroups; +Static Char part_line[256], title_line[256], composer_line[256], + pmx_line[256], options_line[256], start_line[256], voices[256], + clefs[256]; +Static short group_start[maxgroups], group_stop[maxgroups]; +Static Char instr_name[maxstaves][41]; +Static boolean style_supplied; + + +/* ------------------ Styles ------------------ */ + +Static voice_index0 voiceCount(Char *s_) +{ + Char s[256]; + short i, l; + + strcpy(s, s_); + l = strlen(s); + for (i = 0; i <= l - 1; i++) { + if (s[i] == comma_) + s[i] = blank_; + } + return (wordCount(s)); +} + + +Static style_index0 findStyle(Char *s_) +{ + style_index0 Result = 0; + Char s[256]; + style_index0 i = 0; + + strcpy(s, s_); + sprintf(s + strlen(s), "%c", colon_); + while (i < known_styles) { + i++; + if (startsWithIgnoreCase(known_style[i-1], s)) + return i; + } + return Result; +} + + +Static void addStyle(Char *S) +{ + style_index0 sn; + Char STR1[256]; + + sn = findStyle(NextWord(STR1, S, colon_, dummy)); + if (sn > 0) { + strcpy(known_style[sn-1], S); + return; + } + if (known_styles < max_styles) { + known_styles++; + strcpy(known_style[known_styles-1], S); + } else + error("Can't add another style - table full", print); +} + + +Static void readStyles(void) +{ + boolean eofstyle; + Char S[256]; + style_index0 l = 0; + Char *TEMP; + + if (styleFileFound()) + eofstyle = true; + else + eofstyle = P_eof(stylefile); + while (!eofstyle) { + fgets(S, 256, stylefile); + TEMP = strchr(S, '\n'); + if (TEMP != NULL) + *TEMP = 0; + if (*S != '\0') { + addStyle(S); + l++; + orig_style_line[known_styles-1] = l; + } + eofstyle = P_eof(stylefile); + } +} + + +Static void applyStyle(Char *s_, Char *stylename, stave_index first_inst, + stave_index first_stave) +{ + Char s[256]; + Char clef[256], subline[256], subcommand[256]; + stave_index0 i, last_inst, last_stave; + boolean continuo = false, toosoon = false, vocal = false; + Char STR2[256]; + + strcpy(s, s_); + last_inst = first_inst - 1; + GetNextWord(subline, s, blank_, colon_); + while (*s != '\0') { + GetNextWord(subline, s, semicolon, dummy); + i = curtail(subline, semicolon); + GetNextWord(subcommand, subline, blank_, dummy); + if (equalsIgnoreCase(subcommand, "VOICES")) { + sprintf(voices + strlen(voices), " %s", subline); + last_stave = first_stave + wordCount(subline) - 1; + last_inst = first_inst + voiceCount(subline) - 1; + } else if (equalsIgnoreCase(subcommand, "CLEFS")) { + strcpy(clef, subline); + sprintf(clefs + strlen(clefs), " %s", clef); + } else if (equalsIgnoreCase(subcommand, "VOCAL")) { + if (last_inst < first_inst) + toosoon = true; + else { + some_vocal = true; + vocal = true; + for (i = first_inst; i <= last_inst; i++) + setVocal(i, true); + } + } else if (equalsIgnoreCase(subcommand, "CHORAL") || + equalsIgnoreCase(subcommand, "GROUP")) { + if (last_inst < first_inst) + toosoon = true; + else { + if (equalsIgnoreCase(subcommand, "CHORAL")) { + some_vocal = true; + vocal = true; + for (i = first_inst; i <= last_inst; i++) + setVocal(i, true); + } + if (ngroups == maxgroups) + error("Too many groups", print); + else { + ngroups++; + group_start[ngroups-1] = first_stave; + group_stop[ngroups-1] = last_stave; + } + } + } else if (equalsIgnoreCase(subcommand, "CONTINUO")) + continuo = true; + else { + sprintf(STR2, "Subcommand %s in STYLE unknown", subcommand); + error(STR2, print); + } + if (toosoon) { + sprintf(STR2, "You must first give VOICES before specifying %s", + subcommand); + error(STR2, print); + } + } + if (vocal && continuo) + error("A continuo instrument may not be vocal", print); + if (wordCount(clef) != last_stave - first_stave + 1) + error("Number of clefs does not match number of voices", print); + if (first_stave == last_stave || continuo) { + strcpy(instr_name[first_stave-1], stylename); +/* p2c: preamble.pas, line 185: + * Note: Possible string truncation in assignment [145] */ + } else { + for (i = first_stave - 1; i <= last_stave - 1; i++) + *instr_name[i] = '\0'; + } + if (continuo) { + ninstr++; + stave[ninstr-1] = first_stave; + for (i = first_stave - 1; i <= last_stave - 1; i++) + instr[i] = ninstr; + return; + } + for (i = first_stave; i <= last_stave; i++) { + ninstr++; + stave[ninstr-1] = i; + instr[i-1] = ninstr; + } +} + + +Static void applyStyles(void) +{ + short n1, n2, sn; + Char s[256]; + Char STR2[256]; + + *voices = '\0'; + *clefs = '\0'; + ninstr = 0; + while (*cline[(long)style] != '\0') { + n1 = voiceCount(voices) + 1; + n2 = wordCount(voices) + 1; + GetNextWord(s, cline[(long)style], blank_, comma_); + curtail(s, comma_); + sn = findStyle(s); + if (sn == 0) { + sprintf(STR2, "Style %s unknown", s); + error(STR2, print); + } + line_no = orig_style_line[sn-1]; + applyStyle(known_style[sn-1], s, n1, n2); + style_used[sn-1] = true; + } +} + + +/* ------------------------------------------------------------- */ + +Static void wipeCommands(void) +{ + command_type c; + + for (c = c1; c <= cn; c = (command_type)((long)c + 1)) + *cline[(long)c] = '\0'; +} + + +boolean omitLine(paragraph_index line) +{ + return (line > 0 && omit_line[line-1]); +} + + +Static void setName(void) +{ + short i, FORLIM; + + if (!redefined[(long)name]) + return; + setFeature("instrumentNames", true); + FORLIM = ninstr; + for (i = 0; i <= FORLIM - 1; i++) { + GetNextWord(instr_name[i], cline[(long)name], blank_, dummy); +/* p2c: preamble.pas, line 226: + * Note: Possible string truncation in assignment [145] */ + } +} + + +Static void setIndent(void) +{ + if (redefined[(long)indent]) + strcpy(fracindent, cline[(long)indent]); +} + + +Static void setInitOctave(void) +{ + if (redefined[(long)octave_]) + initOctaves(cline[(long)octave_]); +} + + +Local void checkLabel(Char *w) +{ + voice_index j, FORLIM; + Char STR1[256], STR2[256]; + + FORLIM = nvoices; + for (j = 0; j <= FORLIM - 1; j++) { + if (!strcmp(w, voice_label[j])) { + sprintf(STR2, "Voice label %s not unique", w); + warning(STR2, print); + return; + } + } + if (strlen(w) > 2) + return; + if (pos1(w[0], "CLU") > 0) { + if (strlen(w) > 1) { + if (pos1(w[1], "123456789") == 0) + return; + } + } else if (pos1(w[0], "123456789") == 0) + return; + sprintf(STR1, "Voice label %s conflicts with reserved label", w); + error(STR1, print); +} + + +Static void setVoices(Char *line) +{ + short k; + Char s[256], w[256]; + Char STR1[256]; + short FORLIM; + + nvoices = 0; + nstaves = 0; + do { + GetNextWord(s, line, blank_, dummy); + if (*s != '\0') { + nstaves++; + k = 0; + first_on_stave[nstaves-1] = nvoices + 1; + do { + GetNextWord(w, s, blank_, comma_); + curtail(w, comma_); + if (*w != '\0') { + k++; + if (k <= 2) { + nvoices++; + checkLabel(w); + strcpy(voice_label[nvoices-1], w); + if (*instr_name[nstaves-1] == '\0') { + strcpy(instr_name[nstaves-1], w); +/* p2c: preamble.pas, line 266: + * Note: Possible string truncation in assignment [145] */ + } + setStavePos(nvoices, nstaves, k); + } + } + } while (*w != '\0'); + if (k > 2) { + sprintf(STR1, "More than two voices per stave: %s", s); + error(STR1, print); + } + if (k == 2) { + sprintf(instr_name[nstaves-1], "\\mtxTwoInstruments{%s}{%s}", + voice_label[nvoices-2], voice_label[nvoices-1]); +/* p2c: preamble.pas, line 273: + * Note: Possible string truncation in assignment [145] */ + } + number_on_stave[nstaves-1] = k; + } + } while (*line != '\0'); + FORLIM = nvoices; + for (k = 0; k <= FORLIM - 1; k++) + selected[k] = true; +} + + +Static void setClefs(Char *line_) +{ + Char line[256]; + Char s[256]; + + strcpy(line, line_); + nclefs = 0; + do { + GetNextWord(s, line, blank_, dummy); + if (*s != '\0') { + nclefs++; + if (strlen(s) == 1) + clef[nclefs-1] = s[0]; + else + clef[nclefs-1] = s[1]; + } + } while (*s != '\0'); +} + + +Static void setDimension(Char *line_, command_type lno) +{ + Char line[256]; + short l; + short n = 0, p = 0; + Char STR1[256]; + + strcpy(line, line_); + if (*line == '\0') + return; + l = strlen(line); + do { + n++; + if (line[n-1] == '.') + p++; + } while (n <= l && (line[n-1] == '.' || isdigit(line[n-1]))); + if (n == p || p > 1 || + line[n-1] != 'i' && line[n-1] != 'm' && line[n-1] != 'p') + error("Dimension must be a number followed by in, mm or pt", print); + sprintf(cline[(long)lno], "w%s", substr_(STR1, line, 1, n)); +} + + +Static void setSize(Char *line_) +{ + Char line[256]; + stave_index0 i = 0; + Char word[256]; + stave_index0 FORLIM; + + strcpy(line, line_); + while (i < ninstr) { + GetNextWord(word, line, blank_, dummy); + if (*word == '\0') + break; + i++; + getNum(word, &musicsize); + stave_size[i-1] = musicsize; + } + if ((unsigned)musicsize >= 32 || ((1L << musicsize) & 0x110000L) == 0) { + FORLIM = ninstr; + for (i = 0; i <= FORLIM - 1; i++) { + if (stave_size[i] == unspec) + stave_size[i] = musicsize; + } + } + if (musicsize < 16) + musicsize = 16; + else if (musicsize > 20) + musicsize = 20; +} + + +Static command_type findCommand(Char *command) +{ + command_type j; + + curtail(command, ':'); + if (equalsIgnoreCase(command, "STYLE")) + style_supplied = true; + for (j = c1; j <= cn; j = (command_type)((long)j + 1)) { + if (equalsIgnoreCase(command, commands[(long)j])) + return j; + } + return none; +} + + +boolean isCommand(Char *command_) +{ + Char command[256]; + + strcpy(command, command_); + return (findCommand(command) != none); +} + + +Static boolean mustAppend(command_type command) +{ + return (command == tex); +} + + +Static void doEnable(Char *line, boolean choice) +{ + Char word[256]; + Char STR1[256]; + + do { + GetNextWord(word, line, blank_, dummy); + if (*word != '\0') { + if (!setFeature(word, choice)) { + sprintf(STR1, "No such feature: %s", word); + error(STR1, !print); + } + } + } while (*word != '\0'); +} + + +Static void setRange(Char *line_) +{ + Char line[256]; + short v, p, FORLIM; + Char STR1[256]; + Char STR2[256]; + + strcpy(line, line_); + line_no = orig_range_line; + FORLIM = nvoices; + for (v = 1; v <= FORLIM; v++) { + sprintf(STR1, "%s=", voice_label[v-1]); + p = strpos2(line, STR1, 1); + if (p > 0) { + if (strlen(line) < p + 6) { + sprintf(STR2, "At least five characters must follow \"%s=\"", + voice_label[v-1]); + error(STR2, print); + } + defineRange(v, substr_(STR2, line, p + 2, 5)); + } else + defineRange(v, ""); + } +} + + +Static boolean isAssertion(Char *line) +{ + boolean Result; + +/* p2c: preamble.pas, line 369: + * Note: Attempting to EXIT beyond this function [188] */ + return Result; +} + + +Static line_type doCommand(Char *line_) +{ + line_type Result; + Char line[256]; + Char command[256]; + command_type last_command; + boolean starts_with_note; + Char STR1[256], STR3[256]; + + strcpy(line, line_); + if (line[0] == comment && !isAssertion(line)) + return comment_line; + starts_with_note = maybeMusicLine(line); + GetNextWord(command, line, blank_, colon_); + sprintf(STR1, "%c", colon_); + if (endsWith(command, STR1)) { + last_command = findCommand(command); + Result = command_line; + if (last_command == enable) + doEnable(line, true); + else if (last_command == disable) + doEnable(line, false); + else if (last_command == range) + orig_range_line = line_no; + if (last_command != none) { + if (mustAppend(last_command) && redefined[(long)last_command]) + sprintf(cline[(long)last_command] + strlen(cline[(long)last_command]), + "\n%s", line); + else { + strcpy(cline[(long)last_command], line); + if (warn_redefine && redefined[(long)last_command]) { + sprintf(STR3, "You have redefined preamble command %s", command); + warning(STR3, print); + } + } + if (last_command == start) + strcpy(start_line, line); + redefined[(long)last_command] = true; + return Result; + } + Result = colon_line; + sprintf(STR3, "%s%c %s", command, colon_, line); + addStyle(STR3); + orig_style_line[known_styles-1] = line_no; + return Result; + } else if (starts_with_note) + return plain_line; + else + return unknown; + return Result; +} + + +void setOnly(Char *line_) +{ + Char line[256]; + short num, num1, num2, l; + Char s[256]; + Char STR1[256]; + + strcpy(line, line_); + if (*line == '\0') + return; + if (startsWithIgnoreCase(line, "only")) + GetNextWord(STR1, line, colon_, dummy); + for (l = 0; l <= lines_in_paragraph - 1; l++) + omit_line[l] = true; + do { + GetNextWord(s, line, blank_, comma_); + if (*s == '\0') + return; + curtail(s, comma_); + if (pos1('-', s) == 0) { + getNum(s, &num); + if (num > 0 && num <= lines_in_paragraph) + omit_line[num-1] = false; + else + warning("Invalid line number in Only: is skipped", print); + } else { + getTwoNums(s, &num1, &num2); + if (num1 > 0 && num2 <= lines_in_paragraph) { + for (num = num1 - 1; num <= num2 - 1; num++) + omit_line[num] = false; + } else + warning("Invalid line range in Only: is skipped", print); + } + } while (true); +} + + +void interpretCommands(void) +{ + short i, num, den, nbars; + Char STR2[256]; + short FORLIM; + + strcpy(title_line, cline[(long)title]); + strcpy(part_line, cline[(long)part]); + if (*cline[(long)poet] != '\0' || *cline[(long)composer] != '\0') + sprintf(composer_line, "\\mtxComposerLine{%s}{%s}", + cline[(long)poet], cline[(long)composer]); + else + *composer_line = '\0'; + strcpy(pmx_line, cline[(long)pmx]); + GetNextWord(options_line, cline[(long)options], blank_, dummy); + FORLIM = known_styles; + for (i = 0; i <= FORLIM - 1; i++) + style_used[i] = false; + applyStyles(); + setVoices(voices); + FORLIM = known_styles; + for (i = old_known_styles; i <= FORLIM - 1; i++) { + if (!style_used[i]) { + warning("The following style was supplied but not used", !print); + puts(known_style[i]); + } + } + setClefs(clefs); + if (!redefined[(long)meter]) { + sprintf(STR2, "You have not defined Meter, assuming \"%s\" ", + cline[(long)meter]); + warning(STR2, !print); + } + getMeter(cline[(long)meter], &meternum, &meterdenom, &pmnum, &pmdenom); + setDefaultDuration(meterdenom); + if (meternum == 0 && + !(redefined[(long)pages] || redefined[(long)systems] || + redefined[(long)bars])) { + strcpy(cline[(long)bars], "1"); + redefined[(long)bars] = true; + } + if (redefined[(long)pages] || redefined[(long)systems]) { + if (redefined[(long)bars]) + warning("BARS/LINE ignored since you specified PAGES or SYSTEMS", print); + if (redefined[(long)systems]) + getNum(cline[(long)systems], &n_systems); + else + warning("PAGES specified but not SYSTEMS", !print); + if (redefined[(long)pages]) + getNum(cline[(long)pages], &n_pages); + else + warning("SYSTEMS specified but not PAGES", !print); + } else if (redefined[(long)bars]) { + getNum(cline[(long)bars], &nbars); + if (nbars > 0) { + n_pages = 0; + n_systems = nbars; + } + } + getNum(cline[(long)sharps], &n_sharps); + setSpace(cline[(long)space]); + setSize(cline[(long)msize]); + getTwoNums(cline[(long)shortnote], &num, &den); + if (den == 0) + den = 1; + short_note = num * 64 / den; + if (*cline[(long)flats] != '\0') { + getNum(cline[(long)flats], &n_sharps); + n_sharps = -n_sharps; + } + setName(); + setIndent(); + setInitOctave(); + setOnly(cline[(long)only]); + setRange(cline[(long)range]); + setDimension(cline[(long)width], width); + setDimension(cline[(long)height], height); + if (*options_line != '\0') { + warning("\"Options\" is cryptic and obsolescent.", !print); + printf(" Use \"Enable\" and \"Disable\" instead.\n"); + } + FORLIM = strlen(options_line); + for (i = 0; i <= FORLIM - 1; i++) + processOption(options_line[i]); +} + + +void preambleDefaults(void) +{ + short i; + + xmtrnum0 = 0.0; + strcpy(fracindent, "0"); + musicsize = 20; + *start_line = '\0'; + some_vocal = false; + ngroups = 0; + style_supplied = false; + for (i = 1; i <= maxvoices; i++) + setVocal(i, false); + for (i = 0; i <= maxstaves - 1; i++) { + nspace[i] = unspec; + stave_size[i] = unspec; + } + n_pages = 1; + n_systems = 1; + readStyles(); + old_known_styles = known_styles; + for (i = 0; i <= lines_in_paragraph - 1; i++) + omit_line[i] = false; +} + + +Static void preambleGuess(voice_index maybe_voices) +{ + switch (maybe_voices) { + + case 1: + strcpy(cline[(long)style], "Solo"); + break; + + case 2: + strcpy(cline[(long)style], "Duet"); + break; + + case 3: + strcpy(cline[(long)style], "Trio"); + break; + + case 4: + strcpy(cline[(long)style], "Quartet"); + break; + + case 5: + strcpy(cline[(long)style], "Quintet"); + break; + + case 6: + strcpy(cline[(long)style], "Sextet"); + break; + + case 7: + strcpy(cline[(long)style], "Septet"); + break; + + default: + error("I cannot guess a style", !print); + return; + break; + } + printf("I guess this piece is a %s for strings in C major.\n", + cline[(long)style]); + printf(" Why not provide a STYLE in the setup paragraph to make sure?\n"); +} + + +/* ------------------------------------------------------------------ */ + +void nonMusic(void) +{ + paragraph_index i, FORLIM; + + FORLIM = para_len; + for (i = 0; i <= FORLIM - 1; i++) + doCommand(P[i]); + setOnly(cline[(long)only]); + wipeCommands(); +} + + +boolean thisCase(void) +{ + boolean Result; + +/* p2c: preamble.pas: Note: Eliminated unused assignment statement [338] */ + if (!startsWithIgnoreCase(P[0], "case:")) + return true; + Result = (choice != ' ' && pos1(choice, P[0]) > 0); + strcpy(P[0], "%"); + return Result; +} + + +void augmentPreamble(boolean control_para) +{ + paragraph_index i; + line_type l; + short s[5]; + paragraph_index FORLIM; + + if (!thisCase()) + return; + for (l = unknown; l <= plain_line; l = (line_type)((long)l + 1)) + s[(long)l] = 0; + FORLIM = para_len; + for (i = 0; i <= FORLIM - 1; i++) { + line_no = orig_line_no[i]; + l = doCommand(P[i]); + s[(long)l]++; + if (l == comment_line && P[i][1] == comment) { + predelete(P[i], 2); + putLine(P[i]); + } + if (!control_para && l == unknown) + error("Unidentifiable line", print); + } + if (!control_para && s[(long)command_line] > 0 && s[(long)plain_line] > 0) + error("Mixture of preamble commands and music", !print); +} + + +void doPreamble(void) +{ + paragraph_index i; + voice_index0 maybe_voices = 0; + paragraph_index FORLIM; + + if (style_supplied) /*augmentPreamble(not known);*/ + return; + if (true) + warning("No STYLE supplied", !print); + FORLIM = para_len; + for (i = 0; i <= FORLIM - 1; i++) { + if (maybeMusicLine(P[i])) + maybe_voices++; + } + if (maybe_voices > 0) + preambleGuess(maybe_voices); + else + error("No voices found", !print); +} + + +void respace(void) +{ + stave_index i, j; + Char STR1[256]; + Char STR2[256], STR3[256]; + + for (i = ninstr; i >= 2; i--) { + j = ninstr - i + 1; + if (nspace[j-1] != unspec) { + sprintf(STR3, "\\mtxInterInstrument{%s}{%s}", + toString(STR1, i - 1), toString(STR2, nspace[j-1])); + TeXtype2(STR3); + } + } + if (nspace[ninstr-1] != unspec) { + sprintf(STR3, "\\mtxStaffBottom{%s}", toString(STR1, nspace[ninstr-1])); + TeXtype2(STR3); + } + must_respace = false; +} + + +void restyle(void) +{ + must_restyle = false; +} + + +Static short clefno(Char cl) +{ + short Result; + + switch (cl) { + + case 'G': + case '0': + case 't': + case '8': + Result = 0; + break; + + case 's': + case '1': + Result = 1; + break; + + case 'm': + case '2': + Result = 2; + break; + + case 'a': + case '3': + Result = 3; + break; + + case 'n': + case '4': + Result = 4; + break; + + case 'r': + case '5': + Result = 5; + break; + + case 'F': + case 'b': + case '6': + Result = 6; + break; + + case 'C': + Result = 3; + break; + + default: + warning("Unknown clef code - replaced by treble", print); + Result = 0; + break; + } + return Result; +} + + +Static void doTenorClefs(void) +{ + voice_index i; + Char c; + voice_index FORLIM; + Char STR1[256]; + Char STR3[256]; + + FORLIM = nclefs; + for (i = 1; i <= FORLIM; i++) { + c = clef[i-1]; + if (c == '8' || c == 't') { + sprintf(STR3, "\\\\mtxTenorClef{%s}\\", toString(STR1, PMXinstr(i))); + putLine(STR3); + } + } +} + + +Static void insertTeX(void) +{ + if (redefined[(long)tex]) + TeXtype2(cline[(long)tex]); +} + + +Local Char *pmxMeter(Char *Result) +{ + short denom, num; + Char STR1[256], STR3[256], STR4[256], STR5[256]; + + if (meternum == 0) { + num = beatsPerLine(); /** denom := 0; **/ + meterChange(old_meter_word, num, meterdenom, true); + } else + num = meternum; /** denom := pmdenom; **/ + /* CMO: unconditonally assign value of pmdenom to denom */ + denom = pmdenom; + sprintf(Result, "%s %s %s %s", + toString(STR1, num), toString(STR3, PMXmeterdenom(meterdenom)), + toString(STR4, pmnum), toString(STR5, denom)); + return Result; +} + +Local Char *sizecode(Char *Result, short k) +{ + strcpy(Result, "\\mtxNormalSize"); + switch (k) { + + case 13: + if (musicsize == 20) + strcpy(Result, "\\mtxTinySize"); + else + strcpy(Result, "\\mtxSmallSize"); + break; + + case 16: + if (musicsize == 20) + strcpy(Result, "\\mtxSmallSize"); + break; + + case 20: + if (musicsize == 16) + strcpy(Result, "\\mtxLargeSize"); + break; + + case 24: + if (musicsize == 20) + strcpy(Result, "\\mtxLargeSize"); + else + strcpy(Result, "\\mtxHugeSize"); + break; + + case 29: + strcpy(Result, "\\mtxHugeSize"); + break; + + default: + error("Valid sizes are 13, 16, 20, 24, 29", print); + break; + } + return Result; +} + + +void doPMXpreamble(void) +{ + static Char clefcode[9] = "0123456"; + short i, j; + Char clefs[256]; + Char STR1[256]; + Char STR2[256]; + Char STR3[58]; + short FORLIM; + Char STR5[256]; + + if (*composer_line != '\0') + putLine(composer_line); + if (*title_line != '\0') { + sprintf(STR2, "\\mtxTitleLine{%s}", title_line); + putLine(STR2); + } + putLine("---"); + if (instrumentNames() && !redefined[(long)indent]) + strcpy(fracindent, "0.12"); + fprintf(outfile, "%d", nstaves); + fprintf(outfile, " %d", -ninstr); + stave[ninstr] = nstaves + 1; + for (j = ninstr; j >= 1; j--) + fprintf(outfile, " %d", stave[j] - stave[j-1]); + fprintf(outfile, " %s %8.5f %d %d %d %d %s\n", + pmxMeter(STR1), xmtrnum0, n_sharps, n_pages, n_systems, musicsize, + fracindent); + FORLIM = ninstr; + for (i = 1; i <= FORLIM; i++) { + if (!instrumentNames()) + putLine(""); + else { + sprintf(STR3, "\\mtxInstrName{%s}", instr_name[ninstr - i]); + putLine(STR3); + } + } + *clefs = '\0'; + for (i = nclefs - 1; i >= 0; i--) + sprintf(clefs + strlen(clefs), "%c", clefcode[clefno(clef[i])]); + putLine(clefs); + if (*texdir == '\0') + strcpy(texdir, "./"); + putLine(texdir); + + pmx_preamble_done = true; + insertTeX(); + respace(); + + FORLIM = ngroups; + for (j = 1; j <= FORLIM; j++) + fprintf(outfile, "\\\\mtxGroup{%s}{%s}{%s}\\\n", + toString(STR1, j), toString(STR2, ninstr - group_start[j-1] + 1), + toString(STR5, ninstr - group_stop[j-1] + 1)); + FORLIM = ninstr; + for (j = 1; j <= FORLIM; j++) { + if (stave_size[j-1] != unspec) { + sprintf(STR5, "\\\\mtxSetSize{%s}{%s}\\", + toString(STR1, ninstr - j + 1), + sizecode(STR2, stave_size[j-1])); + putLine(STR5); + } + } + if (*part_line != '\0') { + putLine("Ti"); + putLine(part_line); + } + if (*title_line != '\0') { + putLine("Tt"); + putLine("\\mtxTitle"); + } + if (*composer_line != '\0') { + putLine("Tc"); + putLine("\\mtxPoetComposer"); + } + if (*pmx_line != '\0') + putLine(pmx_line); + doTenorClefs(); + if (*cline[(long)width] != '\0') + putLine(cline[(long)width]); + wipeCommands(); +} + + +Char *startString(Char *Result, voice_index0 voice) +{ + Char s[256], w[256]; + voice_index j; + + strcpy(s, start_line); + for (j = 1; j <= voice; j++) + GetNextWord(w, s, dummy, ';'); + curtail(w, ';'); + if (*w != '\0') { + sprintf(Result, "%s ", w); + return Result; + } else + return strcpy(Result, w); +} + + + + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/preamble.h b/Build/source/utils/m-tx/mtx-src/preamble.h new file mode 100644 index 00000000000..6b6c4090e6f --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/preamble.h @@ -0,0 +1,42 @@ +/* Header for module preamble, generated by p2c 1.21alpha-07.Dec.93 */ +#ifndef PREAMBLE_H +#define PREAMBLE_H + + +/*$X+*/ +/* Interpret preamble paragraph, compose PMX preamble */ + +#ifndef GLOBALS_H +#include "globals.h" +#endif + + +#ifdef PREAMBLE_G +# define vextern +#else +# define vextern extern +#endif + +extern boolean thisCase(void); +extern void preambleDefaults(void); +extern void interpretCommands(void); +extern void doPreamble(void); +extern void doPMXpreamble(void); +extern void respace(void); +extern void restyle(void); +extern Char *startString(Char *Result, voice_index0 voice); +extern void augmentPreamble(boolean control_para); +extern boolean omitLine(paragraph_index line); +extern void nonMusic(void); +extern void setOnly(Char *line); +extern boolean isCommand(Char *command); + + +#define known true + + +#undef vextern + +#endif /*PREAMBLE_H*/ + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/preamble.pas b/Build/source/utils/m-tx/mtx-src/preamble.pas new file mode 100644 index 00000000000..ffc3716567b --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/preamble.pas @@ -0,0 +1,688 @@ +unit preamble; +{$X+} +{ Interpret preamble paragraph, compose PMX preamble } + +interface uses globals; + +function thisCase: boolean; +procedure preambleDefaults; +procedure interpretCommands; +procedure doPreamble; +procedure doPMXpreamble; +procedure respace; +procedure restyle; +function startString(voice: voice_index0): string; +procedure augmentPreamble(control_para: boolean); +function omitLine(line: paragraph_index): boolean; +procedure nonMusic; +procedure setOnly(line: string); +function isCommand(command: string): boolean; + +const known = true; + +implementation uses control, mtxline, strings, files, status, utility; + +const blank = ' '; + colon = ':'; + semicolon = ';'; + comma = ','; + known_styles: integer = 12; + max_styles = 24; + warn_redefine: boolean = false; + +type command_type = + ( none, title, composer, pmx, tex, options, msize, bars, shortnote, + style, sharps, flats, meter, space, pages, systems, width, height, + enable, disable, range, name, indent, + poet, part, only, octave, start ); + + line_type = ( unknown, colon_line, command_line, comment_line, + plain_line ); + + style_index = 1..max_styles; + style_index0 = 0..max_styles; + +const c1 = title; cn = start; + commands: array[command_type] of string[16] = + ( 'NONE', 'TITLE', 'COMPOSER', 'PMX', 'TEX', 'OPTIONS', + 'SIZE', 'BARS/LINE', 'SHORT', + 'STYLE', 'SHARPS', 'FLATS', 'METER', 'SPACE', 'PAGES', 'SYSTEMS', 'WIDTH', + 'HEIGHT', 'ENABLE', 'DISABLE', 'RANGE', + 'NAME', 'INDENT', 'POET', 'PART', 'ONLY', 'OCTAVE', 'START'); + cline: array[command_type] of string = + ( '', '', '', '', '', '', '', '', '1/4', (* short *) + '', '0', '', 'C', '', '1', '1', (* systems *) + '190mm', '260mm', '', '', '', '', '', '', '', '', '', '' ); + redefined: array[command_type] of boolean = + ( false, false, false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false ); + +(** Known styles *) + known_style: array[style_index] of string = ( +'SATB: Voices S,A T,B; Choral; Clefs G F', +'SATB4: Voices S A T B; Choral; Clefs G G G8 F', +'SINGER: Voices Voice; Vocal; Clefs G', +'PIANO: Voices RH LH; Continuo; Clefs G F', +'ORGAN: Voices RH LH Ped; Continuo; Clefs G F F', +'SOLO: Voices V; Clefs G', +'DUET: Voices V1 Vc; Clefs G F', +'TRIO: Voices V1 Va Vc; Clefs G C F', +'QUARTET: Voices V1 V2 Va Vc; Clefs G G C F', +'QUINTET: Voices V1 V2 Va Vc1 Vc2; Clefs G G C F F', +'SEXTET: Voices V1 V2 Va1 Va2 Vc1 Vc2; Clefs G G C C F F', +'SEPTET: Voices V1 V2 Va1 Va2 Vc1 Vc2 Cb; Clefs G G C C F F F', +'', '', '', '', '', '', '', '', '', '', '', ''); + +var old_known_styles: style_index; + style_used: array[style_index] of boolean; + omit_line: array[paragraph_index] of boolean; + orig_style_line: array[style_index] of style_index0; + orig_range_line: integer; + +var nclefs, n_pages, n_systems, n_sharps, ngroups: integer; + part_line, title_line, composer_line, pmx_line, options_line, + start_line, voices, clefs: string; + group_start, group_stop: array[1..maxgroups] of integer; + instr_name: array[stave_index] of string[40]; + style_supplied: boolean; + +{ ------------------ Styles ------------------ } + +function voiceCount(s: string): voice_index0; + var i, l: integer; + begin l:=length(s); for i:=1 to l do if s[i]=comma then s[i]:=blank; + voiceCount:=wordCount(s); + end; + +function findStyle(s: string): style_index0; + var i: style_index0; +begin + i:=0; s:=s+colon; findStyle:=0; + while i0 then known_style[sn] := S + else if known_styles < max_styles then + begin inc(known_styles); + known_style[known_styles] := S; + end + else error('Can''t add another style - table full',print); +end; + +procedure readStyles; + var eofstyle: boolean; + S: string; + l: style_index0; +begin if styleFileFound then eofstyle:=true else eofstyle := eof(stylefile); + l:=0; + while not eofstyle do + begin readln(stylefile,S); if S<>'' then + begin addStyle(S); inc(l); orig_style_line[known_styles]:=l; end; + eofstyle := eof(stylefile); + end; +end; + +procedure applyStyle(s, stylename: string; + first_inst, first_stave: stave_index); + var clef, subline, subcommand: string; + i, last_inst, last_stave: stave_index0; + continuo, toosoon, vocal: boolean; + begin last_inst:=first_inst-1; + toosoon := false; continuo:=false; vocal := false; + subline:=GetNextWord(s,blank,colon); + while s<>'' do + begin subline:=GetNextWord(s,semicolon,dummy); + i:=curtail(subline,semicolon); + subcommand:=GetNextWord(subline,blank,dummy); + if equalsIgnoreCase(subcommand,'VOICES') then + begin voices:=voices+' '+subline; + last_stave := first_stave + wordCount(subline) - 1; + last_inst := first_inst + voiceCount(subline) - 1; + end + else if equalsIgnoreCase(subcommand,'CLEFS') + then + begin clef:=subline; clefs:=clefs+' '+clef; end + else if equalsIgnoreCase(subcommand,'VOCAL') then + if last_instlast_stave-first_stave+1 then error( + 'Number of clefs does not match number of voices',print); + if (first_stave=last_stave) or continuo + then instr_name[first_stave]:=stylename + else for i:=first_stave to last_stave do instr_name[i]:=''; + if continuo then + begin inc(ninstr); stave[ninstr] := first_stave; + for i:=first_stave to last_stave do instr[i]:=ninstr; + end + else for i:=first_stave to last_stave do + begin inc(ninstr); stave[ninstr] := i; instr[i] := ninstr; + end; + end; + +procedure applyStyles; + var n1, n2, sn: integer; + s: string; + begin voices:=''; clefs:=''; ninstr:=0; + while cline[style]<>'' do + begin n1:=voiceCount(voices)+1; + n2:=wordCount(voices)+1; + s:=GetNextWord(cline[style],blank,comma); + curtail(s,comma); + sn:=findStyle(s); if sn=0 then error ('Style ' + s +' unknown',print); + line_no := orig_style_line[sn]; applyStyle(known_style[sn],s,n1,n2); + style_used[sn] := true; + end; + end; + +{ ------------------------------------------------------------- } + +procedure wipeCommands; + var c: command_type; +begin for c:=c1 to cn do cline[c]:=''; +end; + +function omitLine(line: paragraph_index): boolean; +begin omitLine := (line>0) and omit_line[line] +end; + +procedure setName; + var i: integer; +begin if not redefined[name] then exit; + setFeature('instrumentNames',true); + for i:=1 to ninstr do + instr_name[i] := getNextWord(cline[name],blank,dummy); +end; + +procedure setIndent; +begin if redefined[indent] then fracindent := cline[indent]; +end; + +procedure setInitOctave; +begin if redefined[octave] then initOctaves(cline[octave]); +end; + +procedure setVoices(var line: string); + var k: integer; + s, w: string; + procedure checkLabel(w: string); + var j: voice_index; + begin + for j:=1 to nvoices do if w=voice_label[j] then + begin warning('Voice label '+w+' not unique',print); exit; + end; + if length(w)>2 then exit; + if pos1(w[1],'CLU')>0 then + if length(w)>1 then if pos1(w[2],'123456789')=0 then exit + else + else + else if pos1(w[1],'123456789')=0 then exit; + error('Voice label '+w+' conflicts with reserved label',print); + end; +begin nvoices:=0; nstaves:=0; + repeat s:=GetNextWord(line,blank,dummy); + if length(s)>0 then + begin inc(nstaves); k:=0; + first_on_stave[nstaves] := nvoices + 1; + repeat + w:=GetNextWord(s,blank,comma); curtail(w, comma); + if w<>'' then + begin + inc(k); if k<=2 then + begin inc(nvoices); checkLabel(w); + voice_label[nvoices]:=w; + if instr_name[nstaves]='' then instr_name[nstaves]:=w; + setStavePos(nvoices,nstaves,k); + end + end; + until w=''; + if k>2 then error('More than two voices per stave: ' + s,print); + if k=2 then instr_name[nstaves]:='\mtxTwoInstruments{' + + voice_label[nvoices-1] + '}{'+ voice_label[nvoices] + '}'; + number_on_stave[nstaves] := k; + end + until length(line)=0; + for k:=1 to nvoices do selected[k]:=true; +end; + +procedure setClefs(line: string); + var s: string; +begin + nclefs:=0; + repeat + s:=getnextword(line,blank,dummy); + if s<>'' then + begin inc(nclefs); + if length(s)=1 then clef[nclefs]:=s[1] else clef[nclefs]:=s[2]; + end; + until s=''; +end; + +procedure setDimension(line: string; lno: command_type); + var l, n, p: integer; +begin + if line = '' then exit; + l := length(line); + n := 0; + p := 0; + repeat n := n+1; + if line[n]='.' then p:=p+1; + until (n>l) or not ((line[n]='.') or (line[n]>='0') and (line[n]<='9')); + if (n=p) or (p>1) or + not ((line[n]='i') or (line[n]='m') or (line[n]='p')) then + error('Dimension must be a number followed by in, mm or pt',print); + cline[lno] := 'w' + substr(line,1,n); +end; + +procedure setSize(line: string); + var i: stave_index0; + word: string; + begin i:=0; + while i20 then musicsize:=20; + end; + +function findCommand(var command: string): command_type; + var j: command_type; +begin curtail(command,':'); + if equalsIgnoreCase(command,'STYLE') then style_supplied := true; + for j:=c1 to cn do if equalsIgnoreCase(command,commands[j]) then + begin findCommand:=j; exit; end; + findCommand:=none; +end; + +function isCommand(command: string): boolean; +begin isCommand:=findCommand(command)<>none end; + +function mustAppend(command: command_type): boolean; +begin mustAppend := command=tex end; + +procedure doEnable(var line: string; choice: boolean); + var word: string; +begin + repeat word:=GetNextWord(line,blank,dummy); + if word<>'' then if not setFeature(word,choice) then + Error('No such feature: '+word,not print) + until word='' +end; + +procedure setRange(line: string); + var v,p: integer; +begin + line_no := orig_range_line; + for v:=1 to nvoices do + begin p:=pos(voice_label[v]+'=',line); + if p>0 then + begin + if length(line)0 then + begin n_pages:=0; n_systems:=nbars end; + end; + getNum(cline[sharps],n_sharps); + setSpace(cline[space]); + setSize(cline[msize]); + getTwoNums(cline[shortnote],num, den); if den=0 then den:=1; + short_note := (num*64) div den; + if cline[flats]<>'' then + begin getNum(cline[flats],n_sharps); n_sharps:=-n_sharps; end; + setName; setIndent; setInitOctave; setOnly(cline[only]); + setRange(cline[range]); + setDimension(cline[width],width); + setDimension(cline[height],height); + if options_line <>'' then begin + warning('"Options" is cryptic and obsolescent.', not print); + writeln(' Use "Enable" and "Disable" instead.') + end; + for i:=1 to length(options_line) do processOption(options_line[i]); +end; + +procedure preambleDefaults; + var i: integer; +begin + xmtrnum0:=0; fracindent:='0'; musicsize:=20; start_line:=''; + some_vocal:=false; ngroups:=0; + style_supplied := false; + for i:=1 to maxvoices do setVocal(i,false); + for i:=1 to maxstaves do + begin nspace[i]:=unspec; stave_size[i]:=unspec; end; + n_pages:=1; n_systems:=1; + readStyles; old_known_styles := known_styles; + for i:=1 to lines_in_paragraph do omit_line[i]:=false; +end; + +procedure preambleGuess(maybe_voices: voice_index); +begin + case maybe_voices of + 1: cline[style] := 'Solo'; + 2: cline[style] := 'Duet'; + 3: cline[style] := 'Trio'; + 4: cline[style] := 'Quartet'; + 5: cline[style] := 'Quintet'; + 6: cline[style] := 'Sextet'; + 7: cline[style] := 'Septet'; + else begin error('I cannot guess a style',not print); exit; end; + end; + writeln('I guess this piece is a ',cline[style], + ' for strings in C major.'); + writeln(' Why not provide a STYLE in the setup paragraph to make sure?'); +end; + +{ ------------------------------------------------------------------ } + +procedure nonMusic; + var i: paragraph_index; +begin for i:=1 to para_len do doCommand(P[i]); + setOnly(cline[only]); wipeCommands; +end; + +function thisCase: boolean; +begin thisCase:=true; + if not startsWithIgnoreCase(P[1],'case:') then exit; + thisCase:=(choice<>' ') and (pos1(choice,P[1])>0); P[1]:='%'; +end; + +procedure augmentPreamble(control_para: boolean); + var i: paragraph_index; + l: line_type; + s: array[line_type] of integer; +begin + if not thisCase then exit; + for l:=unknown to plain_line do s[l]:=0; + for i:=1 to para_len do + begin line_no:=orig_line_no[i]; l:=doCommand(P[i]); + inc(s[l]); + if (l=comment_line) and (P[i,2]=comment) + then begin predelete(P[i],2); putLine(P[i]); end; + if not control_para and (l=unknown) then + error('Unidentifiable line',print); + end; + if not control_para and (s[command_line]>0) and (s[plain_line]>0) + then error('Mixture of preamble commands and music',not print); +end; + +procedure doPreamble; + var i: paragraph_index; + maybe_voices: voice_index0; +begin maybe_voices:=0; + if not style_supplied then + begin {augmentPreamble(not known);} + if not style_supplied then warning('No STYLE supplied',not print); + for i:=1 to para_len do if maybeMusicLine(P[i]) then + inc(maybe_voices); + if maybe_voices>0 then preambleGuess(maybe_voices) + else error('No voices found',not print); + end +end; + +procedure respace; + var i, j: stave_index; + begin + for i:=ninstr downto 2 do + begin j:=ninstr-i+1; + if nspace[j]<>unspec then TeXtype2('\mtxInterInstrument{'+toString(i-1)+ + '}{'+toString(nspace[j])+'}'); + end; + if nspace[ninstr]<>unspec then TeXtype2('\mtxStaffBottom{'+ + toString(nspace[ninstr])+'}'); + must_respace:=false; + end; + +procedure restyle; +begin + must_restyle:=false; +end; + +function clefno ( cl: char ): integer; +begin + case cl of +'G','0','t','8': clefno:=0; +'s','1': clefno:=1; +'m','2': clefno:=2; +'a','3': clefno:=3; +'n','4': clefno:=4; +'r','5': clefno:=5; +'F','b','6': clefno:=6; +'C': clefno:=3; + else + begin warning('Unknown clef code - replaced by treble',print); + clefno:=0; + end; + end +end; + +procedure doTenorClefs; + var i: voice_index; + c: char; +begin for i:=1 to nclefs do + begin + c:=clef[i]; if (c='8') or (c='t') then + putLine('\\mtxTenorClef{' + toString(PMXinstr(i)) + '}\' ); + end; +end; + +procedure insertTeX; +begin + if redefined[tex] then TeXtype2(cline[tex]); +end; + +procedure doPMXpreamble; + const clefcode: string[8]='0123456'; + var i, j: integer; + clefs: string; + function pmxMeter: string; + var denom, num: integer; + begin if meternum=0 then + begin num := beatsPerLine; {* denom := 0; *} + old_meter_word := meterChange(num,meterdenom,true); + end + else begin num := meternum; {* denom := pmdenom; *} end; + { CMO: unconditonally assign value of pmdenom to denom } + denom := pmdenom; + pmxMeter := toString(num) + ' ' + toString(PMXmeterdenom(meterdenom)) + + ' ' + toString(pmnum) + ' ' + toString(denom); + end; + function sizecode(k: integer): string; + begin sizecode:='\mtxNormalSize'; + case k of +13: if musicsize=20 then sizecode:='\mtxTinySize' else sizecode:='\mtxSmallSize'; +16: if musicsize=20 then sizecode:='\mtxSmallSize'; +20: if musicsize=16 then sizecode:='\mtxLargeSize'; +24: if musicsize=20 then sizecode:='\mtxLargeSize' else sizecode:='\mtxHugeSize'; +29: sizecode:='\mtxHugeSize'; + else error('Valid sizes are 13, 16, 20, 24, 29',print); + end; + end; +begin + if composer_line <> '' then putline(composer_line); + if title_line <> '' then putline('\mtxTitleLine{'+title_line+'}'); + putLine('---'); + if instrumentNames and not redefined[indent] then fracindent:='0.12'; + write(outfile, nstaves); + write(outfile, ' ', -ninstr); + stave[ninstr+1]:=nstaves+1; + for j:=ninstr downto 1 do write(outfile, ' ', stave[j+1] - stave[j]); + writeln(outfile, ' ', pmxMeter, ' ',xmtrnum0:8:5, ' ',n_sharps, + ' ', n_pages, ' ',n_systems, ' ',musicsize, ' ',fracindent); + for i:=1 to ninstr do if not instrumentNames then putLine('') + else putLine('\mtxInstrName{'+instr_name[ninstr+1-i]+'}'); + clefs:=''; + for i:=nclefs downto 1 do clefs:=clefs+clefcode[1+clefno(clef[i])]; + putLine(clefs); + if texdir='' then texdir := './'; + putLine(texdir); + + pmx_preamble_done:=true; insertTeX; respace; + + for j:=1 to ngroups do + writeln(outfile,'\\mtxGroup{'+toString(j)+'}{' + +toString(ninstr+1-group_start[j])+'}{' + +toString(ninstr+1-group_stop[j])+'}\'); + for j:=1 to ninstr do + if (stave_size[j]<>unspec) then + putLine( + '\\mtxSetSize{'+toString(ninstr+1-j)+'}{'+sizecode(stave_size[j])+'}\'); + if part_line <> '' then + begin putLine('Ti'); putLine(part_line); end; + if title_line <> '' then + begin putLine('Tt'); putLine('\mtxTitle'); end; + if composer_line <> '' then + begin putLine('Tc'); putLine('\mtxPoetComposer'); end; + if pmx_line <> '' then putLine(pmx_line); + doTenorClefs; + if cline[width] <> '' then putLine(cline[width]); + wipeCommands; +end; + +function startString(voice: voice_index0): string; + var s, w: string; + j: voice_index; +begin s:=start_line; + for j:=1 to voice do w:=getNextWord(s,dummy,';'); + curtail(w,';'); if w<>'' then startString:=w+' ' else startString:=w; +end; + +end. diff --git a/Build/source/utils/m-tx/mtx-src/prepmx.c b/Build/source/utils/m-tx/mtx-src/prepmx.c new file mode 100644 index 00000000000..715d4c1ca37 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/prepmx.c @@ -0,0 +1,861 @@ +/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ +/* From input file "prepmx.pas" */ + + + +#include "p2c.h" + +#ifndef CONTROL_H +#include "control.h" +#endif + +#ifndef STRINGS_H +#include "strings.h" +#endif + +#ifndef GLOBALS_H +#include "globals.h" +#endif + +#ifndef PREAMBLE_H +#include "preamble.h" +#endif + +#ifndef LYRICS_H +#include "lyrics.h" +#endif + +#ifndef MTX_H +#include "mtx.h" +#endif + +#ifndef ANALYZE_H +#include "analyze.h" +#endif + +#ifndef MTXLINE_H +#include "mtxline.h" +#endif + +#ifndef STATUS_H +#include "status.h" +#endif + +#ifndef UPTEXT_H +#include "uptext.h" +#endif + +#ifndef NOTES_H +#include "notes.h" +#endif + +#ifndef MULTFILE_H +#include "multfile.h" +#endif + +#ifndef FILES_H +#include "files.h" +#endif + +#ifndef UTILITY_H +#include "utility.h" +#endif + + +/* CMO: addition/change by Christian Mondrup */ + +/** M-Tx preprocessor to PMX Dirk Laurie */ + +#define version "0.61" +#define version_date "<16 December 2015>" + +/** See file "Corrections" for updates later than those listed below +*/ + +/** Changes since 0.52b + Uses mtx.tex file + More than one # or % per word treated correctly in uptext + Better way of handling line numbers in lyrics +*/ + +/** To do next: + Take notice of recent improvements in musixtex, pmx and musixlyr +{* Current bugs: +{* Old bugs: + Does not check PMX syntax +{* Weaknesses that may later cause bugs: + Decisions sometimes made on note, sometimes on scan + Can 'here' overrun? + Where does one note stop and the next begin? + See comment on '!' in uptext +*/ + +#define chord_flat 't' +#define chord_left 'l' + +#define blind true +#define visible false + + +Static boolean last_bar; +Static Char multibar[256]; +Static Char repeat_sign[256]; +Static short bar_of_line, bars_of_rest, rest_spacing; + + +/* --------------- Bars and rests --------------- */ + +Static void writeRepeat(Char *bar) +{ + Char repcode[256]; + Char STR1[256]; + + if (*bar == '\0') + return; + *repcode = '\0'; + if (!strcmp(bar, "||")) + strcpy(repcode, "Rd"); + else if (!strcmp(bar, "|]")) + strcpy(repcode, "RD"); + else if (!strcmp(bar, "|:")) + strcpy(repcode, "Rl"); + else if (!strcmp(bar, ":|:")) + strcpy(repcode, "Rlr"); + else if (!strcmp(bar, ":|")) + strcpy(repcode, "Rr"); + else if (last_bar && !strcmp(bar, "|")) + strcpy(repcode, "Rb"); + if (*repcode != '\0') { + sprintf(STR1, " %s", repcode); + putLine(STR1); + } + *bar = '\0'; +} + + +Static void supplyRests(voice_index voice) +{ + Char STR2[4]; + Char STR3[256]; + + if (multi_bar_rest) { + put(multibar, putspace); + return; + } + if (bar_of_line == 1 && pedanticWarnings()) { + printf("Bar %d Voice %d", bar_no, voice); + warning(" Filling missing voice with rests", !print); + } + if (pickup > 0) + put(rests(STR3, pickup, meterdenom, visible), nospace); + sprintf(STR2, "%s ", pause); + put(STR2, putspace); +} + + +Static void countBars(Char *note_) +{ + Char note[256]; + short k, adjust; + short sign = 1; + + strcpy(note, note_); + predelete(note, 2); + k = pos1('+', note); + if (k == 0) { + k = pos1('-', note); + if (k > 0) + sign = -1; + } + if (k > 0) { + note[k-1] = '/'; + getTwoNums(note, &bars_of_rest, &adjust); + } else { + getNum(note, &bars_of_rest); + adjust = 0; + } + rest_spacing = adjust * sign + 14; +} + + +/* FIXME This procedure had a serious bug. It now has a smaller bug. + Basically there should be a test on whether a break between staves + is a break between instruments, in which case the procedure is (now) + right; or a break between staves of the same instrument, in which + case a '|' instead of a '&' should be output (as it was). If the Space + feature is not used, the bug does not show up. */ +Static void putMBRest(void) +{ + stave_index i, FORLIM; + Char STR1[256]; + Char STR2[256], STR3[256]; + + put("\\\\\\def\\atnextbar{\\znotes", nospace); + FORLIM = nstaves; + for (i = 1; i <= FORLIM; i++) { + sprintf(STR3, "\\mbrest{%s}{%s}0", + toString(STR1, bars_of_rest), toString(STR2, rest_spacing)); + put(STR3, nospace); + if (i < nstaves) + put("&", nospace); + else + putLine("\\en}\\"); + } + sprintf(STR3, "\\\\\\advance\\barno%s\\", toString(STR1, bars_of_rest - 1)); + putLine(STR3); + bar_no += bars_of_rest - 1; +} + + +/* Local variables for processLine: */ +struct LOC_processLine { + voice_index voice; + Char chords[256], note[256], cutnote[256], pretex[256]; + short ngrace, nmulti; + boolean no_chords, no_uptext; + + short l; + boolean in_group; +} ; + +Local void output(Char *note_, struct LOC_processLine *LINK) +{ + Char note[256]; + Char STR2[256]; + + strcpy(note, note_); + if (*note != '\0') + { /* pretex is saved up until a spacing note or rest comes */ + if (endsWith(note, "\\") && note[1] != '\\') { + curtail(note, '\\'); + strcat(LINK->pretex, note); + *note = '\0'; + return; + } + if (*LINK->pretex != '\0' && isNoteOrRest(note)) { + sprintf(note, "%s\\ %s", LINK->pretex, strcpy(STR2, note)); + *LINK->pretex = '\0'; + } + if (outlen > 0 && note[0] != ' ') + sprintf(note, " %s", strcpy(STR2, note)); + put(note, nospace); + } + if (thisNote(LINK->voice) == nextvoice) + putLine(""); +} + +Local void maybeDotted(Char *note, struct LOC_processLine *LINK) +{ + if (strlen(note) < 2) + return; + if (note[1] == '"') { + note[1] = note[0]; + strcat(LINK->pretex, "\\mtxDotted"); + } +} + +/* Local variables for addChords: */ +struct LOC_addChords { + struct LOC_processLine *LINK; + Char nt[256], labels[256]; + boolean tieme; + Char lab; + int5 pitches; +} ; + +Local void outChord(struct LOC_addChords *LINK) +{ + short k; + Char STR2[256]; + short FORLIM; + + if (*LINK->nt == '\0') + return; + LINK->tieme = (LINK->nt[0] == '{'); + if (LINK->tieme) + predelete(LINK->nt, 1); + if (*LINK->nt == '\0' || LINK->nt[0] < 'a' || LINK->nt[0] > 'g') { + sprintf(STR2, "Must have a note name at the start of \"%s\", not \"%c\"", + LINK->nt, LINK->nt[0]); + error(STR2, print); + } + renewChordPitch(LINK->LINK->voice, LINK->nt); + sprintf(LINK->LINK->chords + strlen(LINK->LINK->chords), " z%s", LINK->nt); + *LINK->nt = '\0'; + FORLIM = strlen(LINK->labels); + for (k = 0; k <= FORLIM - 1; k++) { + if (chordPitch(LINK->LINK->voice) == LINK->pitches[k]) { + sprintf(LINK->LINK->chords + strlen(LINK->LINK->chords), " s%ct", + LINK->labels[k]); + LINK->labels[k] = ' '; + } + } + if (LINK->tieme) { + chordTie(LINK->LINK->voice, &LINK->lab); + sprintf(LINK->LINK->chords + strlen(LINK->LINK->chords), " s%ct", + LINK->lab); + } +} + +Local void addChords(struct LOC_processLine *LINK) +{ + struct LOC_addChords V; + Char w[256]; + short j = 1; + short mus_line; + paragraph_index0 chord_line; + boolean arpeggio; + Char STR1[256]; + short FORLIM; + + V.LINK = LINK; + saveStatus(LINK->voice); + getChordTies(LINK->voice, V.pitches, V.labels); + *LINK->chords = '\0'; + chord_line = chordLineNo(LINK->voice); + if (chord_line == 0) + LINK->no_chords = true; + if (LINK->no_chords) + return; + GetNextWord(w, P[chord_line-1], blank, dummy); + sprintf(STR1, "%c", barsym); + if (!strcmp(w, STR1) || *w == '\0') + LINK->no_chords = true; + sprintf(STR1, "%c", tilde); + if (!strcmp(w, STR1) || LINK->no_chords) + return; + mus_line = line_no; + line_no = orig_line_no[chord_line-1]; + arpeggio = (w[0] == '?'); + if (arpeggio) { + strcpy(LINK->chords, " ?"); + predelete(w, 1); + } + *V.nt = '\0'; + while (j <= strlen(w)) { + if (w[j-1] == '{' || strcmp(V.nt, "{") && w[j-1] >= 'a' && w[j-1] <= 'g') + outChord(&V); + else if (w[j-1] == chord_flat) + w[j-1] = 'f'; + else if (w[j-1] == chord_left) + w[j-1] = 'e'; + sprintf(V.nt + strlen(V.nt), "%c", w[j-1]); + j++; + } + if (*V.nt != '\0') + outChord(&V); + if (arpeggio) + strcat(LINK->chords, " ?"); + strcat(LINK->note, LINK->chords); + FORLIM = strlen(V.labels); + for (j = 0; j <= FORLIM - 1; j++) { + if (V.labels[j] != ' ') + error("Tie on chord note started but not finished", print); + } + line_no = mus_line; +} + +Local Char *processOther(Char *Result, Char *note_, + struct LOC_processLine *LINK) +{ + Char note[256]; + + strcpy(note, note_); + switch (thisNote(LINK->voice)) { + + case other: + if (note[0] == grace_group) { + if (strlen(note) == 1) + LINK->ngrace = 1; + else + LINK->ngrace = pos1(note[1], digits); + if (LINK->ngrace > 0) + LINK->ngrace--; + } + break; + + /* For a zword, take note of pitch but do not change the contents */ + /* Add spurious duration because repitch expects duration to be present */ + case zword: + strcpy(LINK->cutnote, note); + predelete(LINK->cutnote, 1); + insertChar('4', LINK->cutnote, 2); + checkOctave(LINK->voice, LINK->cutnote); + renewPitch(LINK->voice, LINK->cutnote); + break; + + case lyrtag: + extractLyrtag(LINK->voice, note); + break; + + case rbrac: + endBeam(LINK->voice); + break; + + case rparen: + case rlparen: + endSlur(LINK->voice, note); + break; + + case lbrac: + beginBeam(LINK->voice, note); + break; + + case lparen: + maybeDotted(note, LINK); + beginSlur(LINK->voice, note); + break; + + case mword: + error3(LINK->voice, "Meter change must be the first word of its bar"); + break; + + case atword: + lyricsAdjust(LINK->voice, note); + break; + } + return strcpy(Result, note); +} + +Local void lookahead(struct LOC_processLine *LINK) +{ + Char STR2[256]; + Char STR3[256]; + + while (bind_left[(long)nextNote(LINK->voice)]) + sprintf(LINK->note + strlen(LINK->note), " %s", + processOther(STR2, getMusicWord(STR3, LINK->voice), LINK)); +} + +Local void processNote_(struct LOC_processLine *LINK) +{ + if (hasVerseNumber(LINK->voice)) + strcat(LINK->pretex, "\\mtxVerse"); + LINK->l = pos1(multi_group, LINK->note); + if (LINK->l > 0) + scan1(LINK->note, LINK->l + 1, &LINK->nmulti); + activateBeamsAndSlurs(LINK->voice); + LINK->in_group = false; + if (LINK->ngrace > 0) { + LINK->in_group = true; + LINK->ngrace--; + } else { + if (LINK->nmulti > 0) { + LINK->in_group = true; + LINK->nmulti--; + } + } + checkOctave(LINK->voice, LINK->note); + renewPitch(LINK->voice, LINK->note); + if (!LINK->in_group) { + resetDuration(LINK->voice, durationCode(LINK->note)); + markDebeamed(LINK->voice, LINK->note); + } + lookahead(LINK); + getSyllable(LINK->voice, LINK->pretex); + addUptext(LINK->voice, &LINK->no_uptext, LINK->pretex); + addChords(LINK); +} + + +/* ---------------------------------------------------------------- */ + +Static void processLine(voice_index voice_, short bar_no) +{ + struct LOC_processLine V; + paragraph_index par_line; + Char STR1[256]; + + V.voice = voice_; + *V.pretex = '\0'; + V.no_chords = false; + V.no_uptext = false; + par_line = musicLineNo(V.voice); + V.nmulti = 0; + V.ngrace = 0; + line_no = orig_line_no[par_line-1]; + do { + getMusicWord(V.note, V.voice); + if (*V.note == '\0') + return; + /* if debugMode then writeln(voice,' ',note); */ + switch (thisNote(V.voice)) { + + case rword: + if (multi_bar_rest) { + countBars(V.note); + strcpy(V.note, multibar); + if (uptextOnRests()) + addUptext(V.voice, &V.no_uptext, V.pretex); + } else { + V.l = pos1(multi_group, V.note); + if (V.l > 0) + scan1(V.note, V.l + 1, &V.nmulti); + if (V.nmulti > 0) { + V.in_group = true; + V.nmulti--; + } + if (uptextOnRests()) + addUptext(V.voice, &V.no_uptext, V.pretex); + if (!isPause(V.note)) + resetDuration(V.voice, durationCode(V.note)); + } + break; + + case abcdefg: + processNote_(&V); + break; + + case barword: + if (V.voice == nvoices) { + if (endOfBar(V.voice, bar_no)) + strcpy(repeat_sign, V.note); + else + writeRepeat(V.note); + } + sprintf(STR1, "%c", barsym); + if (strcmp(V.note, STR1)) + *V.note = '\0'; + V.no_chords = false; + break; + + case FirstOnly: + if (V.voice != nvoices) + *V.note = '\0'; + else + strcpy(V.note, processOther(STR1, V.note, &V)); + break; + + default: + strcpy(V.note, processOther(STR1, V.note, &V)); + break; + } + output(V.note, &V); + } while (!endOfBar(V.voice, bar_no)); + if (!V.no_chords) + skipChordBar(V.voice); +} + + +/* ------------------------------------------------------------------- */ + +Static void getMeterChange(voice_index voice, Char *new_meter) +{ + short pn1, pn2; + Char w[256], new_command[256]; + + if (nextNote(voice) != mword) + return; + getMusicWord(w, voice); + getMeter(w, &meternum, &meterdenom, &pn1, &pn2); + full_bar = meternum * (64 / meterdenom); + /* CMO: process denominator value with function PMXmeterdenom */ + meterWord(new_command, meternum, PMXmeterdenom(meterdenom), pn1, pn2); + if (*new_meter != '\0' && strcmp(new_meter, new_command)) + error3(voice, "The same meter change must appear in all voices"); + strcpy(new_meter, new_command); +} + + +/* Local variables for musicParagraph: */ +struct LOC_musicParagraph { + Char new_meter[256]; +} ; + +Local void putPMXlines(struct LOC_musicParagraph *LINK) +{ + paragraph_index i, FORLIM; + + FORLIM = para_len; + for (i = 0; i <= FORLIM - 1; i++) { + if (startsWith(P[i], double_comment)) { + predelete(P[i], 2); + putLine(P[i]); + strcpy(P[i], "%"); + } + } +} + +Local void processOneBar(struct LOC_musicParagraph *LINK) +{ + paragraph_index0 m, cm; + short n1, n2; + voice_index voice, cvoice; + boolean ignore_voice; + boolean wrote_repeat = false; + boolean alone; + Char STR2[256]; + Char STR3[256]; + + if (bar_of_line > 1) { + sprintf(STR3, "%cBar %s", comment, toString(STR2, bar_no)); + putLine(STR3); + } + last_bar = (bar_of_line == nbars && final_paragraph); + if (last_bar && !strcmp(repeat_sign, "|")) + *repeat_sign = '\0'; + writeRepeat(repeat_sign); + *LINK->new_meter = '\0'; + for (voice = nvoices; voice >= 1; voice--) { + if (musicLineNo(voice) > 0) { + gotoBar(voice, bar_of_line); + getMeterChange(voice, LINK->new_meter); + } + } + if (last_bar && *LINK->new_meter == '\0' && nleft > pickup && meternum > 0) + meterChange(LINK->new_meter, nleft, 64, true); + if (*LINK->new_meter != '\0') + putLine(LINK->new_meter); + if (multi_bar_rest) { + n1 = meternum * 64; + n2 = meterdenom; + cancel(&n1, &n2, 1); + rests(multibar, n1, n2, blind); + } + for (voice = nvoices; voice >= 1; voice--) { + ignore_voice = !selected[voice-1]; + cvoice = companion(voice); + m = musicLineNo(voice); + cm = musicLineNo(cvoice); + alone = (voice == cvoice || m > 0 && cm == 0 || + m == 0 && cm == 0 && voice < cvoice || !selected[cvoice-1]); + if (selected[voice-1]) { + if (m > 0) + processLine(voice, bar_of_line); + else if (alone) + supplyRests(voice); + else + ignore_voice = true; + if (last_bar && *repeat_sign != '\0' && !wrote_repeat) { + writeRepeat(repeat_sign); + wrote_repeat = true; + } + if (!ignore_voice) { + if (alone || voicePos(voice) == 1) + putLine(" /"); + else + putLine(" //"); + } + } + } + if (multi_bar_rest) + putMBRest(); + bar_no++; + pickup = 0; + putLine(""); +} + +Local void putMeter(Char *new_meter_word, struct LOC_musicParagraph *LINK) +{ + if (strcmp(new_meter_word, old_meter_word)) + putLine(new_meter_word); + strcpy(old_meter_word, new_meter_word); +} + + +Static void musicParagraph(void) +{ + struct LOC_musicParagraph V; + voice_index0 j, nvoice; + Char lyrassign[256]; + Char STR1[256]; + Char STR2[256]; + Char STR3[256], STR4[256], STR5[256]; + voice_index0 FORLIM; + short FORLIM1; + + paragraphSetup(&nvoice); + if (nvoice == 0) { + nonMusic(); + return; + } + if (nvoice > nvoices) { + if (nvoice == 0) + error("No voices! Did you remember to to supply a Style?", !print); + sprintf(STR4, "Paragraph has %s voices but Style allows only %s", + toString(STR1, nvoice), toString(STR2, nvoices)); + error(STR4, !print); + return; + } + if (first_paragraph) + includeStartString(); + if (pmx_preamble_done && (!final_paragraph || nvoice > 0)) { + sprintf(STR5, "%c Paragraph %s line %s bar %s", + comment, toString(STR1, paragraph_no), + toString(STR2, orig_line_no[0]), toString(STR3, bar_no)); + putLine(STR5); + } + testParagraph(); + rememberDurations(); + if (beVerbose()) + describeParagraph(); + /* ---- Knowing the score, we can start setting music ---------------- */ + if (!pmx_preamble_done) { + doPMXpreamble(); + sprintf(STR3, "%c Paragraph %s line %s bar ", + comment, toString(STR1, paragraph_no), + toString(STR2, orig_line_no[0])); + put(STR3, putspace); + if (pickup > 0) + putLine("0"); + else + putLine("1"); + } + putPMXlines(&V); + if (must_restyle) + restyle(); + if (some_vocal && (nvoice > 0 || !final_paragraph)) { + FORLIM = ninstr; + for (j = 1; j <= FORLIM; j++) { + assignLyrics(j, lyrassign); + if (*lyrassign != '\0') { + sprintf(STR2, "\\\\%s\\", lyrassign); + putLine(STR2); + } + } + } + if (must_respace) + respace(); + if (meternum == 0) + putMeter(meterChange(STR2, beatsPerLine(), meterdenom, true), &V); + if (nleft > 0) + nbars++; + if (nbars == 0 && multi_bar_rest) + nbars = 1; + FORLIM1 = nbars; + for (bar_of_line = 1; bar_of_line <= FORLIM1; bar_of_line++) + processOneBar(&V); + restoreDurations(); +} + + +/* ----------------------------------------------------------------------- */ + +Static boolean no_commands_yet; + + +Static void doMusic(void) +{ + Char STR1[256], STR2[256]; + Char STR4[256]; + + first_paragraph = true; + pmx_preamble_done = false; + bar_no = 1; + *repeat_sign = '\0'; + must_respace = false; + must_restyle = false; + do { + final_paragraph = endOfInfile(); + memcpy(orig_P, P, sizeof(paragraph)); + if (para_len > 0 && !ignore_input && thisCase()) { + if (no_commands_yet) { + interpretCommands(); + printFeatures(false); + one_beat = 64 / meterdenom; + full_bar = meternum * one_beat; + if (nvoices > standardPMXvoices) { + sprintf(STR4, "You have %s voices; standard PMX can only handle %s", + toString(STR1, nvoices), toString(STR2, standardPMXvoices)); + warning(STR4, !print); + } + initMTX(); + initUptext(); + initStatus(); + initLyrics(); + no_commands_yet = false; + } + if (startsWithBracedWord(P[0])) + lyricsParagraph(); + else { + musicParagraph(); + first_paragraph = false; + writeRepeat(repeat_sign); + } + } + readParagraph(P, orig_line_no, ¶_len); + } while (para_len != 0); +} + + +Static boolean control_paragraph, no_report_errors; + + +Static boolean isControlParagraph(Char (*P)[256], paragraph_index para_len) +{ + paragraph_index0 commands = 0, labels = 0, voices = 0, guff = 0; + paragraph_index0 i; + Char w[256]; + +/* p2c: prepmx.pas: Note: Eliminated unused assignment statement [338] */ + for (i = 0; i <= para_len - 1; i++) { + if (!startsWith(P[i], "%")) { + NextWord(w, P[i], ' ', ':'); + if (!endsWith(w, ":")) + guff++; + else if (strlen(w) < 3 || findVoice(w) > 0) + voices++; + else if (isCommand(w)) + commands++; + else + labels++; + } + } + if (voices + guff > commands) + return false; + return true; +} + + +Static void topOfPMXfile(void) +{ + Char STR2[24]; + Char STR3[34]; + + putLine("---"); + sprintf(STR2, "\\def\\mtxversion{%s}", version); + putLine(STR2); + sprintf(STR3, "\\def\\mtxdate{%s}", version_date); + putLine(STR3); + putLine("\\input mtx"); +} + + +main(int argc, Char *argv[]) +{ /* ---- Main program ------------------------ */ + PASCAL_MAIN(argc, argv); + strcpy(this_version, version); + strcpy(this_version_date, version_date); + printf("==> This is M-Tx %s (Music from TeXt) %s\n", version, version_date); + + mtxLevel(version); + OpenFiles(); + no_commands_yet = true; + preambleDefaults(); + no_report_errors = false; + topOfPMXfile(); + do { + readParagraph(P, orig_line_no, ¶_len); + control_paragraph = isControlParagraph(P, para_len); + if (control_paragraph) { + augmentPreamble(no_report_errors); + no_report_errors = true; + if (para_len == 0) + error("No music paragraphs!", !print); + } + } while (control_paragraph); + doPreamble(); + doMusic(); + if (!pmx_preamble_done) + error("No music paragraphs!", !print); + putLine("% Coded by M-Tx"); + CloseFiles(); + printf("PrePMX done. Now run PMX.\n"); + _Escape(0); + exit(EXIT_SUCCESS); +} + + + + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/prepmx.pas b/Build/source/utils/m-tx/mtx-src/prepmx.pas new file mode 100644 index 00000000000..08661beba6b --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/prepmx.pas @@ -0,0 +1,449 @@ +program prepmx; +uses control, strings, globals, preamble, lyrics, mtx, analyze, + mtxline, status, uptext, notes, files, utility; + +{ CMO: addition/change by Christian Mondrup } + +{* M-Tx preprocessor to PMX Dirk Laurie } +const version = '0.61'; + version_date = '<11 December 2015>'; + +{* See file "Corrections" for updates later than those listed below +} + +{* Changes since 0.52b + Uses mtx.tex file + More than one # or % per word treated correctly in uptext + Better way of handling line numbers in lyrics +} + +{* To do next: + Take notice of recent improvements in musixtex, pmx and musixlyr +{* Current bugs: +{* Old bugs: + Does not check PMX syntax +{* Weaknesses that may later cause bugs: + Decisions sometimes made on note, sometimes on scan + Can 'here' overrun? + Where does one note stop and the next begin? + See comment on '!' in uptext +} + chord_flat = 't'; + chord_left = 'l'; + blind = true; + visible = false; + +var + last_bar: boolean; + multibar: string; + repeat_sign: string; + bar_of_line, bars_of_rest, rest_spacing: integer; + +{ --------------- Bars and rests --------------- } + +procedure writeRepeat(var bar: string); + var repcode: string; + begin if bar='' then exit; + repcode:=''; + if bar='||' then repcode:='Rd' + else if (bar='|]') then repcode:='RD' + else if bar='|:' then repcode:='Rl' + else if bar=':|:' then repcode:='Rlr' + else if bar=':|' then repcode:='Rr' + else if last_bar and (bar='|') then repcode:='Rb'; + if repcode<>'' then putLine(' '+repcode); + bar:=''; + end; + +procedure supplyRests(voice: voice_index); +begin + if multi_bar_rest then + begin put(multibar,putspace); exit; end; + if (bar_of_line=1) and pedanticWarnings then + begin write('Bar ', bar_no, ' Voice ', voice); + warning(' Filling missing voice with rests',not print); + end; + if pickup>0 then + put(rests(pickup,meterdenom,visible),nospace); + put(pause+' ',putspace); +end; + +procedure countBars(note: string); + var k, adjust, sign: integer; +begin predelete(note,2); k:=pos1('+',note); sign:=1; + if k=0 then + begin k:=pos1('-',note); if k>0 then sign:=-1; end; + if k>0 then + begin note[k]:='/'; getTwoNums(note,bars_of_rest,adjust); end + else begin getNum(note,bars_of_rest); adjust:=0; end; + rest_spacing := 14 + adjust*sign; +end; + +(* FIXME This procedure had a serious bug. It now has a smaller bug. + Basically there should be a test on whether a break between staves + is a break between instruments, in which case the procedure is (now) + right; or a break between staves of the same instrument, in which + case a '|' instead of a '&' should be output (as it was). If the Space + feature is not used, the bug does not show up. *) +procedure putMBRest; + var i: stave_index; +begin + put('\\\def\atnextbar{\znotes',nospace); + for i:=1 to nstaves do + begin put('\mbrest{'+toString(bars_of_rest)+'}{'+toString(rest_spacing) + +'}0',nospace); + if i'' then + begin { pretex is saved up until a spacing note or rest comes } + if endsWith(note,'\') and (note[2]<>'\') then + begin curtail(note,'\'); pretex:=pretex+note; note:=''; exit end; + if (pretex<>'') and isNoteOrRest(note) then + begin note:=pretex+'\ '+note; pretex:='' end; + if (outlen>0) and (note[1]<>' ') then note:=' '+note; + put(note,nospace); + end; + if thisNote(voice)=nextvoice then putLine(''); + end; + + procedure maybeDotted(var note: string); + begin if length(note)<2 then exit; + if note[2]='"' then + begin note[2]:=note[1]; pretex:=pretex+'\mtxDotted' end + end; + + procedure addChords; + var w, nt, labels: string; + j, mus_line: integer; + chord_line: paragraph_index0; + arpeggio, tieme: boolean; + lab: char; + pitches: int5; + procedure outChord; + var k: integer; + begin if nt='' then exit; tieme:=nt[1]='{'; if tieme then predelete(nt,1); + if (nt='') or (nt[1]<'a') or (nt[1]>'g') then + error('Must have a note name at the start of "'+nt + +'", not "'+nt[1]+'"',print); + renewChordPitch(voice,nt); + chords := chords+' z'+nt; nt:=''; + for k:=1 to length(labels) do if chordPitch(voice)=pitches[k] then + begin chords:=chords+' s'+labels[k]+'t'; labels[k]:=' ' end; + if tieme then begin chordTie(voice,lab); chords:=chords+' s'+lab+'t' end + end; + begin saveStatus(voice); + getChordTies(voice, pitches, labels); + chords:=''; chord_line:=chordLineNo(voice); + if chord_line=0 then no_chords:=true; + if no_chords then exit; + w := getNextWord(P[chord_line],blank,dummy); + if (w=barsym) or (w='') then no_chords:=true; + if (w=tilde) or no_chords then exit; + mus_line:=line_no; line_no:=orig_line_no[chord_line]; + arpeggio := w[1]='?'; if arpeggio then + begin chords:=' ?'; predelete(w,1); end; + j:=1; nt:=''; + while j<=length(w) do + begin + if (w[j]='{') or ((nt<>'{') and (w[j]>='a') and (w[j]<='g')) then outChord + else if w[j]=chord_flat then w[j]:='f' + else if w[j]=chord_left then w[j]:='e'; + nt:=nt+w[j]; j:=j+1 + end; + if nt<>'' then outChord; if arpeggio then chords:=chords+' ?'; + note:=note+chords; + for j:=1 to length(labels) do if labels[j]<>' ' then + error('Tie on chord note started but not finished',print); + line_no:=mus_line; + end; + + function processOther(note: string): string; + begin + case thisNote(voice) of +other: if note[1]=grace_group then + begin if length(note)=1 then ngrace:=1 + else ngrace := pos1(note[2],digits); + if ngrace>0 then dec(ngrace); + end; +{ For a zword, take note of pitch but do not change the contents } +{ Add spurious duration because repitch expects duration to be present } +zword: begin cutnote:=note; predelete(cutnote,1); insertchar('4',cutnote,2); + checkOctave(voice,cutnote); renewPitch(voice,cutnote) + end; +lyrtag: extractLyrtag(voice,note); +rbrac: endBeam(voice); +rparen, rlparen: endSlur(voice,note); +lbrac: beginBeam(voice,note); +lparen: begin maybeDotted(note); beginSlur(voice,note); end; +mword: error3(voice,'Meter change must be the first word of its bar'); +atword: lyricsAdjust(voice, note); + end; + processOther:=note; + end; + + procedure lookahead; + begin while bind_left[nextNote(voice)] do + note:=note+' '+processOther(getMusicWord(voice)); + end; + + var l: integer; + in_group: boolean; + + procedure processNote; + begin + begin if hasVerseNumber(voice) then pretex:=pretex+'\mtxVerse'; + l := pos1(multi_group,note); + if l>0 then scan1(note,l+1,nmulti); + activateBeamsAndSlurs(voice); + in_group:=false; + if ngrace>0 then begin in_group:=true; dec(ngrace) end else + if nmulti>0 then begin in_group:=true; dec(nmulti); end; + checkOctave(voice,note); renewPitch(voice,note); + if not in_group then + begin resetDuration(voice,durationCode(note)); markDebeamed(voice,note) end; + lookahead; getSyllable(voice,pretex); + addUptext(voice, no_uptext, pretex); + addChords; + end; + end; + +begin + pretex:=''; no_chords:=false; no_uptext := false; + par_line:=musicLineNo(voice); + nmulti :=0; ngrace := 0; line_no:=orig_line_no[par_line]; + repeat note:=getMusicWord(voice); if note='' then exit; + { if debugMode then writeln(voice,' ',note); } + case thisNote(voice) of + rword: begin if multi_bar_rest then + begin countBars(note); note:=multibar; + if uptextOnRests then + addUptext(voice, no_uptext, pretex); + end + else begin + l := pos1(multi_group,note); + if l>0 then scan1(note,l+1,nmulti); + if nmulti>0 then begin in_group:=true; dec(nmulti); end; + if uptextOnRests then + addUptext(voice, no_uptext, pretex); + if not isPause(note) then resetDuration(voice,durationCode(note)); + end + end; + abcdefg: processNote; + barword: begin + if voice=nvoices then + if endOfBar(voice,bar_no) then repeat_sign := note + else writeRepeat(note); + if note<>barsym then note:=''; + no_chords:=false; + end; + FirstOnly: if voice<>nvoices then note:='' else + note:=processOther(note); + else note:=processOther(note); + end; + output(note); + until endOfBar(voice,bar_no); + if not no_chords then skipChordBar(voice); +end; + +{ ------------------------------------------------------------------- } + +procedure getMeterChange(voice: voice_index; var new_meter: string); + var pn1, pn2: integer; + w, new_command: string; +begin if nextNote(voice)<>mword then exit; + w:=getMusicWord(voice); + getMeter(w, meternum, meterdenom, pn1, pn2); + full_bar := meternum*(64 div meterdenom); + { CMO: process denominator value with function PMXmeterdenom } + new_command := meterWord(meternum, PMXmeterdenom(meterdenom), pn1, pn2); + if (new_meter<>'') and (new_meter<>new_command) + then error3(voice,'The same meter change must appear in all voices'); + new_meter:=new_command; +end; + +procedure musicParagraph; + var j, nvoice: voice_index0; + new_meter, lyrassign: string; + + procedure putPMXlines; + var i: paragraph_index; + begin for i:=1 to para_len do + if startsWith(P[i],double_comment) then + begin predelete(P[i],2); putLine(P[i]); P[i]:='%'; end; + end; + + procedure processOneBar; + var m, cm: paragraph_index0; + n1, n2: integer; + voice, cvoice: voice_index; + ignore_voice, wrote_repeat, alone: boolean; + begin + if bar_of_line>1 then putLine(comment+'Bar '+toString(bar_no)); + last_bar := (bar_of_line=nbars) and final_paragraph; + if last_bar and (repeat_sign='|') then repeat_sign:=''; + writeRepeat(repeat_sign); new_meter := ''; + for voice:=nvoices downto 1 do + if musicLineNo(voice)>0 then + begin gotoBar(voice,bar_of_line); getMeterChange(voice,new_meter); + end; + if last_bar and (new_meter='') and (nleft>pickup) and (meternum>0) then + new_meter := meterChange(nleft,64,true); + if new_meter<>'' then putLine(new_meter); + wrote_repeat := false; if multi_bar_rest then + begin n1:=64*meternum; n2:=meterdenom; cancel(n1,n2,1); + multibar:=rests(n1,n2,blind); + end; + for voice:=nvoices downto 1 do + begin ignore_voice:=not selected[voice]; cvoice:=companion(voice); + m:=musicLineNo(voice); cm:=musicLineNo(cvoice); + alone:=(voice=cvoice) or ((m>0) and (cm=0)) + or ((m=0) and (cm=0) and (voice0 then processLine(voice,bar_of_line) + else if alone then supplyRests(voice) else ignore_voice:=true; + if last_bar and (repeat_sign<>'') and not wrote_repeat then + begin writeRepeat(repeat_sign); wrote_repeat := true; end; + if not ignore_voice then + if alone or (voicePos(voice)=1) then putLine(' /') + else putLine(' //'); + end; + end; + if multi_bar_rest then putMBRest; + inc(bar_no); pickup:=0; putLine(''); + end; + + procedure putMeter(new_meter_word: string); + begin if new_meter_word<>old_meter_word then putLine(new_meter_word); + old_meter_word := new_meter_word; + end; + +begin + paragraphSetup(nvoice); + if nvoice=0 then begin nonMusic; exit end + else if nvoice>nvoices then + begin if nvoice=0 then + error('No voices! Did you remember to to supply a Style?',not print); + error('Paragraph has '+toString(nvoice)+ + ' voices but Style allows only '+toString(nvoices),not print); exit; + end; + if first_paragraph then includeStartString; + if pmx_preamble_done and (not final_paragraph or (nvoice>0)) then + putLine(comment +' Paragraph ' + toString(paragraph_no) + + ' line ' + toString(orig_line_no[1]) + ' bar ' + toString(bar_no)); + testParagraph; rememberDurations; + if beVerbose then describeParagraph; + { ---- Knowing the score, we can start setting music ---------------- } + if not pmx_preamble_done then + begin doPMXpreamble; + put( comment + ' Paragraph ' + toString(paragraph_no) + ' line ' + + toString(orig_line_no[1]) + ' bar ',putspace); + if pickup>0 then putLine('0') else putLine('1'); + end; + putPMXlines; + if must_restyle then restyle; + if some_vocal and ((nvoice>0) or not final_paragraph) then + for j:=1 to ninstr do + begin assignLyrics(j,lyrassign); + if lyrassign<>'' then putLine('\\'+lyrassign+'\'); + end; + if must_respace then respace; + if (meternum=0) then putMeter(meterChange(beatsPerLine,meterdenom,true)); + if nleft > 0 then inc(nbars); + if (nbars=0) and multi_bar_rest then nbars:=1; + for bar_of_line:=1 to nbars do + processOneBar; + restoreDurations; +end; + +{ ----------------------------------------------------------------------- } + +var no_commands_yet: boolean; + +procedure doMusic; +begin first_paragraph:=true; pmx_preamble_done:=false; bar_no:=1; + repeat_sign:=''; must_respace:=false; must_restyle:=false; + repeat final_paragraph := endOfInfile; + orig_P := P; + if (para_len>0) and not ignore_input and thisCase then + begin if no_commands_yet then + begin interpretCommands; printFeatures(false); + one_beat := 64 div meterdenom; full_bar := meternum*one_beat; + if nvoices>standardPMXvoices then warning('You have ' + +toString(nvoices)+' voices; standard PMX can only handle ' + +toString(standardPMXvoices),not print); + initMTX; initUptext; initStatus; initLyrics; + no_commands_yet:=false + end; + if startsWithBracedWord(P[1]) then lyricsParagraph else + begin + musicParagraph; first_paragraph:=false; + writeRepeat(repeat_sign); + end + end; + readParagraph(P,orig_line_no,para_len); + until para_len=0; +end; + +var control_paragraph, no_report_errors: boolean; + +function isControlParagraph (var P: paragraph; para_len: paragraph_index) + : boolean; + var commands, labels, voices, guff, i: paragraph_index0; + w: string; +begin isControlParagraph:=true; commands:=0; labels:=0; voices:=0; guff:=0; + for i:=1 to para_len do + if not (startsWith(P[i],'%')) then + begin w:=nextWord(P[i],' ',':'); + if not endsWith(w,':') then inc(guff) + else if (length(w)<3) or (findVoice(w)>0) then inc(voices) + else if isCommand(w) then inc(commands) + else inc(labels) + end; + if (voices+guff>commands) then isControlParagraph:=false +end; + +procedure topOfPMXfile; +begin + putLine('---'); + putLine('\def\mtxversion{'+version+'}'); + putline('\def\mtxdate{'+version_date+'}'); + putline('\input mtx'); +end; + +begin { ---- Main program ------------------------ } + this_version := version; this_version_date := version_date; + writeln ('==> This is M-Tx ' + version + ' (Music from TeXt) ' + + version_date ); + + mtxLevel(version); OpenFiles; no_commands_yet:=true; preambleDefaults; + no_report_errors:=false; + topOfPMXfile; + repeat readParagraph(P,orig_line_no,para_len); + control_paragraph:=isControlParagraph(P,para_len); + if control_paragraph then + begin augmentPreamble(no_report_errors); + no_report_errors:=true; + if para_len=0 then error('No music paragraphs!',not print) + end + until not control_paragraph; + doPreamble; doMusic; + if not pmx_preamble_done then error('No music paragraphs!',not print); + putline('% Coded by M-Tx'); + CloseFiles; + writeln ('PrePMX done. Now run PMX.'); halt(0); +end. + diff --git a/Build/source/utils/m-tx/mtx-src/status.c b/Build/source/utils/m-tx/mtx-src/status.c new file mode 100644 index 00000000000..08845f156e3 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/status.c @@ -0,0 +1,664 @@ +/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ +/* From input file "status.pas" */ + + + +#include "p2c.h" + +#define STATUS_G +#include "status.h" + + +#ifndef GLOBALS_H +#include "globals.h" +#endif + +#ifndef STRINGS_H +#include "strings.h" +#endif + +#ifndef MTXLINE_H +#include "mtxline.h" +#endif + +#ifndef CONTROL_H +#include "control.h" +#endif + +#ifndef UTILITY_H +#include "utility.h" +#endif + +#ifndef NOTES_H +#include "notes.h" +#endif + + +#define lowest_pitch (-9) +#define highest_pitch 61 + + +typedef struct line_status { + short pitch, chord_pitch, octave_adjust, beam_level, slur_level, after_slur; + Char octave, lastnote, chord_lastnote, duration, slurID, tieID; + boolean beamnext, beamed, slurnext, slurred, no_beam_melisma; + boolean no_slur_melisma[12]; + int5 chord_tie_pitch; + Char chord_tie_label[6]; +} line_status; + + +Static Char init_oct[256] = ""; + +Static Char range_name[56][256] = { + "0c", "0d", "0e", "0f", "0g", "0a", "0b", "1c", "1d", "1e", "1f", "1g", + "1a", "1b", "2c", "2d", "2e", "2f", "2g", "2a", "2b", "3c", "3d", "3e", + "3f", "3g", "3a", "3b", "4c", "4d", "4e", "4f", "4g", "4a", "4b", "5c", + "5d", "5e", "5f", "5g", "5a", "5b", "6c", "6d", "6e", "6f", "6g", "6a", + "6b", "7c", "7d", "7e", "7f", "7g", "7a", "7b" +/* p2c: status.pas, line 76: + * Note: Line breaker spent 0.0 seconds, 5000 tries on line 58 [251] */ +}; + +Static line_status current[maxvoices]; +Static Char lastdur[maxvoices]; +Static Char voice_range[maxvoices][256], range_low[maxvoices][256], + range_high[maxvoices][256]; + + +/* Range limits are user-specified as e.g. 3c. To make comparisons +meaningful, a and b (which come after g) are translated to h and i. */ + +void checkRange(short voice, Char *note_) +{ + Char note[256]; + Char STR1[4]; + Char STR3[256]; + + strcpy(note, note_); + if (*voice_range[voice-1] == '\0') + return; + if (strlen(note) > 2) { /* assume usual PMX form with octave */ + sprintf(STR1, "%c%c", note[2], note[0]); + strcpy(note, STR1); + } + if (note[1] == 'a') + note[1] = 'h'; + if (note[1] == 'b') + note[1] = 'i'; + if (strcmp(note, range_low[voice-1]) < 0 || + strcmp(note, range_high[voice-1]) > 0) { + sprintf(STR3, "%s is out of range, specified as %s", + note, voice_range[voice-1]); + error3(voice, STR3); + } +} + + +void defineRange(short voice, Char *range_) +{ + Char range[256]; + Char STR2[256]; + + strcpy(range, range_); + strcpy(voice_range[voice-1], range); + if (*range == '\0') + return; + if ('0' > range[0] || range[0] > '7' || 'a' > range[1] || range[1] > 'g' || + range[2] != '-' || '0' > range[3] || range[3] > '7' || 'a' > range[4] || + range[4] > 'g') { + sprintf(STR2, + "Badly formatted range \"%s\" for voice %s, must be e.g. 3c-4a", + range, voice_label[voice-1]); + error(STR2, print); + } + if (range[1] == 'a') + range[1] = 'h'; + if (range[1] == 'b') + range[1] = 'i'; + if (range[4] == 'a') + range[4] = 'h'; + if (range[4] == 'b') + range[4] = 'i'; + substr_(range_low[voice-1], range, 1, 2); + substr_(range_high[voice-1], range, 4, 2); +} + + +void chordTie(short voice, Char *lab) +{ + short n; + line_status *WITH; + + WITH = ¤t[voice-1]; + n = strlen(WITH->chord_tie_label); + if (n == 5) + error3(voice, "Only five slur ties allowed per voice"); + if (n == 0) + *lab = 'T'; + else + *lab = WITH->chord_tie_label[n-1]; + (*lab)++; + sprintf(WITH->chord_tie_label + strlen(WITH->chord_tie_label), "%c", *lab); +/* p2c: status.pas, line 113: + * Note: Possible string truncation in assignment [145] */ + n++; + WITH->chord_tie_pitch[n-1] = WITH->chord_pitch; +} + + +void getChordTies(short voice, short *pitches, Char *labels) +{ + line_status *WITH; + + WITH = ¤t[voice-1]; + memcpy(pitches, WITH->chord_tie_pitch, sizeof(int5)); + strcpy(labels, WITH->chord_tie_label); + *WITH->chord_tie_label = '\0'; +} + + +void rememberDurations(void) +{ + voice_index v, FORLIM; + + FORLIM = nvoices; + for (v = 1; v <= FORLIM; v++) + lastdur[v-1] = duration(v); +} + + +void restoreDurations(void) +{ + voice_index v, FORLIM; + + FORLIM = nvoices; + for (v = 1; v <= FORLIM; v++) + resetDuration(v, lastdur[v-1]); +} + + +Char duration(short voice) +{ + return (current[voice-1].duration); +} + + +void resetDuration(short voice, Char dur) +{ + if (pos1(dur, durations) == 0) { + printf("Trying to set duration to %c; ", dur); + error3(voice, "M-Tx system error: resetDuration"); + } + current[voice-1].duration = dur; +} + + +void activateBeamsAndSlurs(short voice) +{ + line_status *WITH; + + WITH = ¤t[voice-1]; + if (WITH->beamnext) { + WITH->beamed = true; + WITH->beamnext = false; + } + if (WITH->slurnext) { + WITH->slurred = true; + WITH->slurnext = false; + } + if (WITH->slurred) + WITH->after_slur++; +} + + +void saveStatus(short voice) +{ + line_status *WITH; + + WITH = ¤t[voice-1]; + WITH->chord_pitch = WITH->pitch; + WITH->chord_lastnote = WITH->lastnote; +} + + +boolean noBeamMelisma(short voice) +{ + return (current[voice-1].no_beam_melisma); +} + + +short afterSlur(short voice) +{ + short Result; + line_status *WITH; + + WITH = ¤t[voice-1]; + Result = WITH->after_slur; + if (WITH->after_slur > 0 && WITH->slur_level < 1) + error3(voice, "M-Tx system error: afterSlur and slur_level incompatible)"); + return Result; +} + + +Char octave(short voice) +{ + return (current[voice-1].octave); +} + + +void resetOctave(short voice) +{ + current[voice-1].octave = ' '; +} + + +void initOctaves(Char *octaves) +{ + short i = 1; + + strcpy(init_oct, octaves); + while (i <= strlen(init_oct)) { + if (init_oct[i-1] == ' ') + delete1(init_oct, i); + else + i++; + } +} + + +Static Char initOctave(stave_index voice_stave) +{ + if (voice_stave > strlen(init_oct)) { + if (pos1(clef[voice_stave-1], "Gt08") > 0) + return '4'; + else + return '3'; + } else + return (init_oct[voice_stave-1]); +} + + +void setOctave(short voice) +{ + current[voice-1].octave = initOctave(voiceStave(voice)); +} + + +void newOctave(short voice, Char dir) +{ + line_status *WITH; + + WITH = ¤t[voice-1]; + switch (dir) { + + case '+': + WITH->octave++; + break; + + case '-': + WITH->octave--; + break; + } +} + + +Static short newPitch(short voice, Char *note_, short pitch, Char lastnote) +{ + Char note[256]; + short interval, npitch; + Char oct; + + strcpy(note, note_); + oct = octaveCode(note); + if (oct == '=') + oct = initOctave(voiceStave(voice)); + if (isdigit(oct)) { + pitch = (oct - '0') * 7 - 3; + lastnote = 'f'; + removeOctaveCode(oct, note); + oct = octaveCode(note); + } + interval = note[0] - lastnote; + if (interval > 3) + interval -= 7; + if (interval < -3) + interval += 7; + npitch = pitch + interval; + while (oct != ' ') { + if (oct == '+') + npitch += 7; + else if (oct == '-') + npitch -= 7; + removeOctaveCode(oct, note); + oct = octaveCode(note); + } + return npitch; +} + + +Local void delins(Char *note, Char c1, Char c2, short l) +{ + short i, n; + + n = strlen(note); + i = pos1(c1, note); + if (i == 0) + i = n + 1; + while (l > 0 && i <= n) { + delete1(note, i); + n--; + l--; + } + i = pos1(c2, note); + if (i == 0) { + if (strlen(note) < 2) + error("M-Tx program error", print); + else + i = 3; + } + while (l > 0) { + insertChar(c2, note, i); + l--; + } +} + + +Static void repitch(Char *note, short diff) +{ + diff /= 7; + if (diff > 0) + delins(note, '-', '+', diff); + else + delins(note, '+', '-', -diff); +} + + +void setUnbeamed(short voice) +{ + current[voice-1].beamed = false; +} + + +void setUnslurred(short voice) +{ + line_status *WITH; + + WITH = ¤t[voice-1]; + WITH->slurred = false; + WITH->after_slur = 0; +} + + +void beginBeam(short voice, Char *note) +{ + line_status *WITH; + + WITH = ¤t[voice-1]; + if (WITH->beamed) + error3(voice, "Starting a forced beam while another is open"); + if (WITH->beam_level > 0) + error3(voice, + "Starting a forced beam while another is open (beamlevel>0)"); + WITH->beam_level++; + WITH->beamnext = true; + WITH->no_beam_melisma = startsWith(note, "[["); + if (WITH->no_beam_melisma) + predelete(note, 1); +} + + +void endBeam(short voice) +{ + line_status *WITH; + + WITH = ¤t[voice-1]; + if (WITH->beam_level < 1) + error3(voice, "Closing a beam that was never opened"); + WITH->beam_level--; + setUnbeamed(voice); +} + + +short slurLevel(short voice) +{ + return (current[voice-1].slur_level); +} + + +short beamLevel(short voice) +{ + return (current[voice-1].beam_level); +} + + +boolean noSlurMelisma(short voice, short history) +{ + line_status *WITH; + + WITH = ¤t[voice-1]; + return (WITH->no_slur_melisma[WITH->slur_level + history - 1]); +} + + +Static Char *slurLabel(Char *Result, short voice, Char *note) +{ + Char sl; + + if (*note == '\0') + return strcpy(Result, ""); + if (strlen(note) < 2) + return strcpy(Result, " "); + if (note[1] >= '0' && note[1] <= 'Z') + sl = note[1]; + else + sl = ' '; + if (sl >= 'I' && sl <= 'T') + warning3(voice, "Slur label in the range I..T may cause conflict"); + sprintf(Result, "%c", sl); + return Result; +} + + +Static void labelSlur(short voice, Char *note) +{ + Char sl; + line_status *WITH; + + if (*note == '\0') + return; + WITH = ¤t[voice-1]; + if (note[0] == ')') + WITH->slurID += 2; + else if (note[0] == '}') + WITH->tieID += 2; + /** CMO 0.60a: replace assigning tieID to sl by space charater + if (note[1]='(') or (note[1]=')') then sl:=slurID else sl:=tieID; */ + if (note[0] == '(' || note[0] == ')') + sl = WITH->slurID; + else + sl = ' '; + /** CMO 0.60d: omit insertchar in case of tie + insertchar(sl,note,2); */ + if (note[0] == '(' || note[0] == ')') + insertChar(sl, note, 2); + if (note[0] == '(') + WITH->slurID -= 2; + else if (note[0] == '{') + WITH->tieID -= 2; + if (WITH->slurID < 'I') + warning3(voice, "Too many nested slurs may cause conflict"); + if (WITH->tieID < 'I') + warning3(voice, "Too many nested ties may cause conflict"); +} + + +void beginSlur(short voice, Char *note) +{ + short posblind; + line_status *WITH; + Char STR1[256], STR2[256]; + + WITH = ¤t[voice-1]; + WITH->slur_level++; + if (WITH->slur_level > 12) + error3(voice, "Too many open slurs"); + WITH->no_slur_melisma[WITH->slur_level - 1] = (startsWith(note, "((") || + startsWith(note, "{{")); + if (WITH->no_slur_melisma[WITH->slur_level - 1]) + predelete(note, 1); + if (!strcmp(slurLabel(STR1, voice, note), "0")) + delete1(note, 2); + else { + if (!strcmp(slurLabel(STR2, voice, note), " ")) + labelSlur(voice, note); + } + posblind = pos1('~', note); + if (posblind > 0) { + if (hideBlindSlurs()) + *note = '\0'; + else + delete1(note, posblind); + } + WITH->slurnext = true; +} + + +void endSlur(short voice, Char *note) +{ + short poscontinue, posblind; + Char contslur[256]; + line_status *WITH; + Char STR1[256], STR2[256]; + + WITH = ¤t[voice-1]; + *contslur = '\0'; + if (WITH->slur_level < 1) + error3(voice, "Ending a slur that was never started"); + if (note[0] == ')') + poscontinue = pos1('(', note); + else if (note[0] == '}') + poscontinue = pos1('{', note); + if (poscontinue == 0) + WITH->slur_level--; + else { + poscontinue--; + strcpy(contslur, note); + predelete(contslur, poscontinue); + shorten(note, poscontinue); + } + if (WITH->slur_level == 0) + setUnslurred(voice); + if (!strcmp(slurLabel(STR1, voice, note), "0")) + delete1(note, 2); + else { + if (!strcmp(slurLabel(STR2, voice, note), " ")) + labelSlur(voice, note); + } + if (!strcmp(slurLabel(STR1, voice, contslur), "0")) + delete1(contslur, 2); + else { + if (!strcmp(slurLabel(STR2, voice, contslur), " ")) + labelSlur(voice, contslur); + } + if (poscontinue > 0) { + if (note[0] == '}') + strcat(note, "t"); + note[0] = 's'; + if (contslur[0] == '{') + strcat(contslur, "t"); + contslur[0] = 's'; + } + posblind = pos1('~', note); + if (posblind > 0) { + if (hideBlindSlurs()) + *note = '\0'; + else + delete1(note, posblind); + } + if (*note != '\0' && *contslur != '\0') + sprintf(note + strlen(note), " %s", contslur); +} + + +/* This is the routine called by prepmx.pas for every normal and chordal +note, immediately after checkOctave. It does two things: adjusts pitch +of notes following a C: chord to what it would have been without that +chord, and checks for pitch overruns. */ +void renewPitch(short voice, Char *note) +{ + short pstat; + line_status *WITH; + + WITH = ¤t[voice-1]; + pstat = newPitch(voice, note, WITH->chord_pitch, WITH->chord_lastnote); + WITH->pitch = newPitch(voice, note, WITH->pitch, WITH->lastnote); + if (WITH->pitch != pstat) + repitch(note, WITH->pitch - pstat); + checkRange(voice, range_name[WITH->pitch + 6]); + if (WITH->pitch < lowest_pitch && checkPitch()) { + printf("Pitch of note %s following %c reported as %d", + note, WITH->lastnote, WITH->pitch); + error3(voice, "Pitch too low"); + } + if (WITH->pitch > highest_pitch && checkPitch()) { + printf("Pitch of note %s following %c reported as %d", + note, WITH->lastnote, WITH->pitch); + error3(voice, "Pitch too high"); + } + WITH->lastnote = note[0]; +} + + +short chordPitch(short voice) +{ + return (current[voice-1].chord_pitch); +} + + +void renewChordPitch(short voice, Char *note) +{ + line_status *WITH; + + WITH = ¤t[voice-1]; + WITH->chord_pitch = newPitch(voice, note, WITH->chord_pitch, + WITH->chord_lastnote); + if (WITH->chord_pitch < lowest_pitch) + error3(voice, "Pitch in chord too low"); + if (WITH->chord_pitch > highest_pitch) + error3(voice, "Pitch in chord too high"); + WITH->chord_lastnote = note[0]; +} + + +void initStatus(void) +{ + short voice, FORLIM; + line_status *WITH; + + FORLIM = nvoices; + for (voice = 1; voice <= FORLIM; voice++) { + WITH = ¤t[voice-1]; + WITH->duration = default_duration; + WITH->octave_adjust = 0; + WITH->slur_level = 0; + WITH->beam_level = 0; + WITH->beamed = false; + WITH->beamnext = false; + WITH->slurred = false; + WITH->slurnext = false; + WITH->after_slur = 0; + WITH->octave = initOctave(voiceStave(voice)); + WITH->slurID = 'S'; + WITH->tieID = 'T'; + WITH->lastnote = 'f'; + WITH->pitch = (WITH->octave - '0') * 7 - 3; + *WITH->chord_tie_label = '\0'; + saveStatus(voice); + } +} + + + + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/status.h b/Build/source/utils/m-tx/mtx-src/status.h new file mode 100644 index 00000000000..3acebe3dabe --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/status.h @@ -0,0 +1,59 @@ +/* Header for module status, generated by p2c 1.21alpha-07.Dec.93 */ +#ifndef STATUS_H +#define STATUS_H + + +#ifdef STATUS_G +# define vextern +#else +# define vextern extern +#endif +/* Keep track of duration, octave, slur and beam status. */ + + +extern void initStatus(void); +extern void saveStatus(short voice); + +extern void resetDuration(short voice, Char dur); +extern Char duration(short voice); + +extern short slurLevel(short voice); +extern short beamLevel(short voice); +extern boolean noBeamMelisma(short voice); +extern boolean noSlurMelisma(short voice, short history); +extern short afterSlur(short voice); +extern void setUnbeamed(short voice); +extern void setUnslurred(short voice); +extern void beginBeam(short voice, Char *note); +extern void endBeam(short voice); +extern void beginSlur(short voice, Char *note); +extern void endSlur(short voice, Char *note); +extern void activateBeamsAndSlurs(short voice); + +extern void setOctave(short voice); +extern void resetOctave(short voice); +extern Char octave(short voice); +extern void newOctave(short voice, Char dir); +extern void initOctaves(Char *octaves); + +extern void renewPitch(short voice, Char *note); +extern short chordPitch(short voice); +extern void renewChordPitch(short voice, Char *note); +extern void defineRange(short voice, Char *range); +extern void checkRange(short voice, Char *note); +extern void rememberDurations(void); +extern void restoreDurations(void); +extern void chordTie(short voice, Char *lab); + + +typedef short int5[5]; + + +extern void getChordTies(short voice, short *pitches, Char *labels); + + +#undef vextern + +#endif /*STATUS_H*/ + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/status.pas b/Build/source/utils/m-tx/mtx-src/status.pas new file mode 100644 index 00000000000..3048027a7bb --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/status.pas @@ -0,0 +1,396 @@ +unit status; +{ Keep track of duration, octave, slur and beam status. } + +interface + +procedure initStatus; +procedure saveStatus(voice: integer); + +procedure resetDuration (voice: integer; dur: char); +function duration(voice: integer): char; + +function slurLevel(voice: integer): integer; +function beamLevel(voice: integer): integer; +function noBeamMelisma(voice: integer): boolean; +function noSlurMelisma(voice, history: integer): boolean; +function afterSlur(voice: integer): integer; +procedure setUnbeamed(voice: integer); +procedure setUnslurred(voice: integer); +procedure beginBeam(voice: integer; var note: string); +procedure endBeam(voice: integer); +procedure beginSlur(voice: integer; var note: string); +procedure endSlur(voice: integer; var note: string); +procedure activateBeamsAndSlurs(voice: integer); + +procedure setOctave(voice: integer); +procedure resetOctave(voice: integer); +function octave(voice: integer): char; +procedure newOctave(voice: integer; dir: char); +procedure initOctaves(octaves: string); + +procedure renewPitch (voice: integer; var note: string); +function chordPitch(voice: integer): integer; +procedure renewChordPitch (voice: integer; note: string); +procedure defineRange(voice: integer; range: string); +procedure checkRange(voice: integer; note: string); +procedure rememberDurations; +procedure restoreDurations; +procedure chordTie(voice: integer; var lab: char); +type int5 = array[1..5] of integer; +procedure getChordTies(voice: integer; var pitches: int5; var labels: string); + +implementation uses globals, strings, mtxline, control, utility, notes; + +const + init_oct: string = ''; + lowest_pitch = -9; + highest_pitch = 61; + range_name: array[-6..49] of string = ( +'0c','0d','0e','0f','0g','0a','0b', +'1c','1d','1e','1f','1g','1a','1b', +'2c','2d','2e','2f','2g','2a','2b', +'3c','3d','3e','3f','3g','3a','3b', +'4c','4d','4e','4f','4g','4a','4b', +'5c','5d','5e','5f','5g','5a','5b', +'6c','6d','6e','6f','6g','6a','6b', +'7c','7d','7e','7f','7g','7a','7b'); + +type + line_status = record + pitch, chord_pitch, octave_adjust, beam_level, + slur_level, after_slur: integer; + octave, lastnote, chord_lastnote, duration, slurID, tieID: char; + beamnext, beamed, slurnext, slurred, no_beam_melisma: boolean; + no_slur_melisma: array[1..12] of boolean; + chord_tie_pitch: int5; + chord_tie_label: string[5]; + end; + +var current: array[voice_index] of line_status; + lastdur: array[voice_index] of char; + voice_range, range_low, range_high: array[voice_index] of string; + +{ Range limits are user-specified as e.g. 3c. To make comparisons +meaningful, a and b (which come after g) are translated to h and i. } + +procedure checkRange(voice: integer; note: string); +begin + if voice_range[voice]='' then exit; + if length(note)>2 { assume usual PMX form with octave } then + note := note[3]+note[1]; + if note[2]='a' then note[2]:='h'; + if note[2]='b' then note[2]:='i'; + if (noterange_high[voice]) then + error3(voice,note+' is out of range, specified as '+voice_range[voice]) +end; + +procedure defineRange(voice: integer; range: string); +begin + voice_range[voice] := range; + if range='' then exit; + if not ( + ('0'<=range[1]) and (range[1]<='7') + and ('a'<=range[2]) and (range[2]<='g') + and (range[3]='-') + and ('0'<=range[4]) and (range[4]<='7') + and ('a'<=range[5]) and (range[5]<='g') + ) then error('Badly formatted range "'+range+ + '" for voice '+voice_label[voice]+', must be e.g. 3c-4a',print); + if range[2]='a' then range[2]:='h'; + if range[2]='b' then range[2]:='i'; + if range[5]='a' then range[5]:='h'; + if range[5]='b' then range[5]:='i'; + range_low[voice]:=substr(range,1,2); + range_high[voice]:=substr(range,4,2); +end; + +procedure chordTie(voice: integer; var lab: char); + var n: integer; +begin with current[voice] do + begin n:=length(chord_tie_label); + if n=5 then error3(voice,'Only five slur ties allowed per voice'); + if n=0 then lab:='T' else lab:=chord_tie_label[n]; + inc(lab); chord_tie_label:=chord_tie_label+lab; + inc(n); chord_tie_pitch[n]:=chord_pitch + end +end; + +procedure getChordTies(voice: integer; var pitches: int5; var labels: string); +begin with current[voice] do + begin pitches:=chord_tie_pitch; labels:=chord_tie_label; chord_tie_label:='' end +end; + +procedure rememberDurations; + var v: voice_index; +begin for v:=1 to nvoices do lastdur[v]:=duration(v) end; + +procedure restoreDurations; + var v: voice_index; +begin for v:=1 to nvoices do resetDuration(v,lastdur[v]) end; + +function duration(voice: integer): char; +begin duration := current[voice].duration; end; + +procedure resetDuration(voice: integer; dur: char); +begin if pos1(dur,durations)=0 then + begin write('Trying to set duration to ',dur,'; '); + error3(voice,'M-Tx system error: resetDuration'); + end; + current[voice].duration := dur +end; + + +procedure activateBeamsAndSlurs(voice: integer); +begin with current[voice] do + begin + if beamnext then begin beamed:=true; beamnext:=false; end; + if slurnext then begin slurred:=true; slurnext:=false; end; + if slurred then inc(after_slur); + end +end; + +procedure saveStatus(voice: integer); +begin with current[voice] do + begin chord_pitch := pitch; chord_lastnote := lastnote; end; +end; + +function noBeamMelisma(voice: integer): boolean; +begin noBeamMelisma := current[voice].no_beam_melisma; end; + +function afterSlur(voice: integer): integer; +begin with current[voice] do + begin afterSlur := after_slur; if (after_slur>0) and (slur_level<1) then + error3(voice,'M-Tx system error: afterSlur and slur_level incompatible)') + end +end; + +function octave(voice: integer): char; +begin octave := current[voice].octave; end; + +procedure resetOctave(voice: integer); +begin current[voice].octave := ' '; end; + +procedure initOctaves(octaves: string); + var i: integer; +begin init_oct:=octaves; + i:=1; + while i<=length(init_oct) do + if init_oct[i]=' ' then delete1(init_oct,i) else inc(i); +end; + +function initOctave(voice_stave: stave_index): char; +begin + if voice_stave>length(init_oct) then + if pos1(clef[voice_stave],'Gt08')>0 + then initOctave:='4' else initOctave:='3' + else initOctave:=init_oct[voice_stave]; +end; + +procedure setOctave(voice: integer); +begin current[voice].octave:=initOctave(voiceStave(voice)); end; + +procedure newOctave(voice: integer; dir: char); +begin with current[voice] do case dir of + '+': inc(octave); + '-': dec(octave); + end; +end; + +function newPitch (voice: integer; note: string; pitch: integer; + lastnote: char): integer; + var interval, npitch: integer; + oct: char; +begin + oct:=octaveCode(note); + if oct='=' then oct:=initOctave(voiceStave(voice)); + if (oct>='0') and (oct<='9') then + begin pitch:=7*(ord(oct)-ord('0'))-3; lastnote:='f'; + removeOctaveCode(oct,note); oct:=octaveCode(note) + end; + interval := ord(note[1])-ord(lastnote); + if interval>3 then dec(interval,7); + if interval<-3 then inc(interval,7); + npitch:=pitch+interval; + while oct<>' ' do + begin if oct='+' then inc(npitch,7) else if oct='-' then dec(npitch,7); + removeOctaveCode(oct,note); oct:=octaveCode(note) + end; + newPitch:=npitch +end; + +procedure repitch(var note: string; diff: integer); + procedure delins(var note: string; c1, c2: char; l: integer); + var i, n: integer; + begin n:=length(note); i:=pos1(c1,note); if i=0 then i:=n+1; + while (l>0) and (i<=n) do begin delete1(note,i); dec(n); dec(l); end; + i:=pos1(c2,note); + if i=0 then if length(note)<2 then error('M-Tx program error',print) + else i:=3; + while l>0 do begin insertchar(c2,note,i); dec(l); end; + end; + begin diff:=diff div 7; + if diff>0 then delins(note, '-','+',diff) + else delins(note, '+','-',-diff); + end; + +procedure setUnbeamed(voice: integer); +begin current[voice].beamed:=false end; + +procedure setUnslurred(voice: integer); +begin with current[voice] do + begin slurred:=false; after_slur:=0; end; +end; + +procedure beginBeam(voice: integer; var note: string); +begin with current[voice] do + begin if beamed then + error3(voice, 'Starting a forced beam while another is open'); + if beam_level>0 then error3(voice, + 'Starting a forced beam while another is open (beamlevel>0)'); + inc(beam_level); + beamnext := true; no_beam_melisma:=startsWith(note,'[['); + if no_beam_melisma then predelete(note,1); + end; +end; + +procedure endBeam(voice: integer); +begin with current[voice] do + begin if beam_level<1 then error3(voice, 'Closing a beam that was never opened'); + dec(beam_level) + end; + setUnbeamed(voice) +end; + +function slurLevel(voice: integer): integer; +begin slurLevel := current[voice].slur_level; end; + +function beamLevel(voice: integer): integer; +begin beamLevel := current[voice].beam_level; end; + +function noSlurMelisma(voice, history: integer): boolean; +begin with current[voice] do + noSlurMelisma := no_slur_melisma[slur_level+history]; +end; + +function slurLabel(voice: integer; note: string): string; + var sl: char; +begin if note='' then begin slurLabel:=''; exit end; + if length(note)<2 then begin slurLabel:=' '; exit end; + if (note[2]>='0') and (note[2]<='Z') then sl:=note[2] else sl:=' '; + if (sl>='I') and (sl<='T') then + warning3(voice,'Slur label in the range I..T may cause conflict'); + slurLabel:=sl +end; + +procedure labelSlur(voice: integer; var note: string); + var sl: char; +begin if note='' then exit; + with current[voice] do + begin + if note[1]=')' then inc(slurID,2) else if note[1]='}' then inc(tieID,2); + {* CMO 0.60a: replace assigning tieID to sl by space charater + if (note[1]='(') or (note[1]=')') then sl:=slurID else sl:=tieID; } + if (note[1]='(') or (note[1]=')') then sl:=slurID else sl:=' '; + {* CMO 0.60d: omit insertchar in case of tie + insertchar(sl,note,2); } + if (note[1]='(') or (note[1]=')') then insertchar(sl,note,2); + if note[1]='(' then dec(slurID,2) else if note[1]='{' then dec(tieID,2); + if slurID<'I' then warning3(voice,'Too many nested slurs may cause conflict'); + if tieID<'I' then warning3(voice,'Too many nested ties may cause conflict') + end +end; + +procedure beginSlur(voice: integer; var note: string); + var posblind: integer; +begin + with current[voice] do + begin + inc(slur_level); if slur_level>12 then Error3(voice,'Too many open slurs'); + no_slur_melisma[slur_level] := startsWith(note,'((') or startsWith(note,'{{'); + if no_slur_melisma[slur_level] then predelete(note,1); + if slurLabel(voice,note)='0' then delete1(note,2) else + if slurLabel(voice,note)=' ' then labelSlur(voice,note); + posblind:=pos1('~',note); if posblind>0 then + if hideBlindSlurs then note:='' else delete1(note,posblind); + slurnext := true; + end; +end; + +procedure endSlur(voice: integer; var note: string); + var poscontinue, posblind: integer; + contslur: string; +begin with current[voice] do + begin contslur:=''; + if slur_level<1 then Error3(voice,'Ending a slur that was never started'); + if note[1]=')' then poscontinue:=pos1('(',note) + else if note[1]='}' then poscontinue:=pos1('{',note); + if poscontinue=0 then dec(slur_level) else + begin dec(poscontinue); contslur:=note; predelete(contslur,poscontinue); + shorten(note,poscontinue); + end; + if slur_level=0 then setUnslurred(voice); + if slurLabel(voice,note)='0' then delete1(note,2) else + if slurLabel(voice,note)=' ' then labelSlur(voice,note); + if slurLabel(voice,contslur)='0' then delete1(contslur,2) else + if slurLabel(voice,contslur)=' ' then labelSlur(voice,contslur); + if poscontinue>0 then + begin if note[1]='}' then note:=note+'t'; note[1]:='s'; + if contslur[1]='{' then contslur:=contslur+'t'; contslur[1]:='s'; + end; + posblind:=pos1('~',note); if posblind>0 then + if hideBlindSlurs then note:='' else delete1(note,posblind); + if (note<>'') and (contslur<>'') then note := note + ' ' + contslur; + end; +end; + +{ This is the routine called by prepmx.pas for every normal and chordal +note, immediately after checkOctave. It does two things: adjusts pitch +of notes following a C: chord to what it would have been without that +chord, and checks for pitch overruns. } +procedure renewPitch (voice: integer; var note: string); + var pstat: integer; +begin with current[voice] do + begin + pstat:=newPitch (voice, note, chord_pitch, chord_lastnote); + pitch := newPitch (voice, note, pitch, lastnote); + if pitch<>pstat then repitch(note,pitch-pstat); + checkRange(voice,range_name[pitch]); + if (pitchhighest_pitch) and checkPitch then + begin write('Pitch of note ',note,' following ',lastnote,' reported as ',pitch); + error3(voice,'Pitch too high') + end; + lastnote:=note[1]; + end; +end; + +function chordPitch(voice: integer): integer; +begin chordPitch:=current[voice].chord_pitch end; + +procedure renewChordPitch (voice: integer; note: string); +begin with current[voice] do + begin chord_pitch:=newPitch(voice,note,chord_pitch,chord_lastnote); + if chord_pitchhighest_pitch then error3(voice,'Pitch in chord too high'); + chord_lastnote:=note[1]; + end +end; + +procedure initStatus; + var voice: integer; +begin for voice:=1 to nvoices do with current[voice] do + begin duration:=default_duration; + octave_adjust:=0; slur_level:=0; beam_level:=0; + beamed:=false; beamnext:=false; + slurred:=false; slurnext:=false; after_slur:=0; + octave:=initOctave(voiceStave(voice)); slurID:='S'; tieID:='T'; + lastnote:='f'; pitch:=7*(ord(octave)-ord('0'))-3; + chord_tie_label:=''; + saveStatus(voice); + end; +end; + +end. diff --git a/Build/source/utils/m-tx/mtx-src/strings.h b/Build/source/utils/m-tx/mtx-src/strings.h new file mode 100644 index 00000000000..3b8e7f4a539 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/strings.h @@ -0,0 +1,36 @@ +/* Header for module strings, generated by p2c 1.21alpha-07.Dec.93 */ +#ifndef STRINGS_H +#define STRINGS_H + + +#ifdef STRINGS_G +# define vextern +#else +# define vextern extern +#endif +/* String handling primitives. */ +/* These should be recoded in C instead of using the p2c code. */ + + +extern void scan1(Char *s, short p, short *n); +/* Read an integer at position p of s */ +extern boolean startsWith(Char *s1, Char *s2); +extern short pos1(Char c, Char *s); +extern short posNot(Char c, Char *s); +extern void insertChar(Char c, Char *s, short p); +extern Char *substr_(Char *Result, Char *s, short start, short count); +extern void getNum(Char *line, short *k); +extern void getTwoNums(Char *line, short *k1, short *k2); +extern void toUpper(Char *s); +extern void delete1(Char *s, short p); +extern void predelete(Char *s, short l); +extern void shorten(Char *s, short new_length); +extern short nextWordBound(Char *s, Char trigger, short p); +/* find end of first word starting with trigger after s[p] */ + + +#undef vextern + +#endif /*STRINGS_H*/ + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/strings.pas b/Build/source/utils/m-tx/mtx-src/strings.pas new file mode 100644 index 00000000000..9f7deabd183 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/strings.pas @@ -0,0 +1,109 @@ +unit strings; { String handling primitives. } + { These should be recoded in C instead of using the p2c code. } + +interface + +procedure scan1 (s: string; p: integer; var n: integer); + { Read an integer at position p of s } +function startsWith (s1, s2: string): boolean; +function pos1(c: char; s: string): integer; +function posNot (c: char; var s: string): integer; +procedure insertChar (c: char; var s: string; p: integer); +function substr (var s: string; start, count: integer): string; +procedure getNum(line: string; var k: integer); +procedure getTwoNums(var line: string; var k1, k2: integer); +procedure toUpper(var s: string); +procedure delete1 (var s: string; p: integer); +procedure predelete (var s: string; l: integer); +procedure shorten (var s: string; new_length: integer); +function nextWordBound(s: string; trigger: char; p: integer): integer; + { find end of first word starting with trigger after s[p] } + +implementation + +procedure scan1 (s: string; p: integer; var n: integer); + begin if length(s)

c then + begin posnot:=i; exit; end; + posnot:=0; +end; + +procedure strval(line: string; var num, p: integer); + begin val(line,num,p); end; + +procedure getNum(line: string; var k: integer); + var code: integer; +begin strval(line,k,code); + if code>0 then strval(copy(line,1,code-1),k,code); +end; + +procedure getTwoNums(var line: string; var k1, k2: integer); + var num, code, p: integer; +begin + strval(line,num,p); strval(copy(line,1,p-1),k1,code); + strval(copy(line,p+1,255),k2,code); + if code>0 then strval(copy(line,1,code-1),k2,code); +end; + +procedure toUpper (var s: string); + var i: integer; +begin + for i:=1 to length(s) do s[i]:=upcase(s[i]); +end; + +function startsWith (s1, s2: string): boolean; + var i, l1, l2: integer; + begin l1:=length(s1); l2:=length(s2); + startsWith := false; if l1s2[i] then exit; + startsWith := true; + end; + +procedure insertChar (c: char; var s: string; p: integer); + begin if length(s)length(s)) or (s[p]=trigger); + while (p' ') do p:=p+1; + nextWordBound:=p; +end; + +end. diff --git a/Build/source/utils/m-tx/mtx-src/uptext.c b/Build/source/utils/m-tx/mtx-src/uptext.c new file mode 100644 index 00000000000..de3f2f6d182 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/uptext.c @@ -0,0 +1,270 @@ +/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ +/* From input file "uptext.pas" */ + + + +#include "p2c.h" + +#define UPTEXT_G +#include "uptext.h" + + +#ifndef GLOBALS_H +#include "globals.h" +#endif + +#ifndef STRINGS_H +#include "strings.h" +#endif + +#ifndef MTXLINE_H +#include "mtxline.h" +#endif + +#ifndef UTILITY_H +#include "utility.h" +#endif + + +typedef struct uptext_info { + short uptext, uptext_adjust, uptext_lcz; + Char uptext_font[256]; +} uptext_info; + + +Static uptext_info U[maxvoices]; + + +short uptextLineNo(short voice) +{ + return (U[voice-1].uptext); +} + + +void setUptextLineNo(short voice, short lno) +{ + U[voice-1].uptext = lno; +} + + +void clearUptext(void) +{ + voice_index voice, FORLIM; + + FORLIM = nvoices; + for (voice = 0; voice <= FORLIM - 1; voice++) + U[voice].uptext = 0; +} + + +void initUptext(void) +{ + voice_index voice, FORLIM; + uptext_info *WITH; + + FORLIM = nvoices; + for (voice = 0; voice <= FORLIM - 1; voice++) { + WITH = &U[voice]; + WITH->uptext_adjust = 0; + WITH->uptext_lcz = 3; + *WITH->uptext_font = '\0'; + } +} + + +Static void textTranslate(Char *uptext, Char *font) +{ + short k; + Char STR1[256], STR2[256], STR3[256], STR4[256]; + short FORLIM; + + if (*uptext == '\0') + return; + do { + k = pos1('%', uptext); + if (k > 0) { + sprintf(STR4, "%s{\\mtxFlat}%s", + substr_(STR1, uptext, 1, k - 1), + substr_(STR3, uptext, k + 1, strlen(uptext) - k)); + strcpy(uptext, STR4); + } + } while (k != 0); + do { + k = pos1('#', uptext); + if (k > 0) { + sprintf(STR2, "%s{\\mtxSharp}%s", + substr_(STR1, uptext, 1, k - 1), + substr_(STR4, uptext, k + 1, strlen(uptext) - k)); + strcpy(uptext, STR2); + } + } while (k != 0); + switch (uptext[0]) { + + case '<': + if (!strcmp(uptext, "<")) + strcpy(uptext, "\\mtxIcresc"); + else if (!strcmp(uptext, "<.")) + strcpy(uptext, "\\mtxTcresc"); + else { + predelete(uptext, 1); + sprintf(uptext, "\\mtxCresc{%s}", strcpy(STR4, uptext)); + } + break; + + case '>': + if (!strcmp(uptext, ">")) + strcpy(uptext, "\\mtxIdecresc"); + else if (!strcmp(uptext, ">.")) + strcpy(uptext, "\\mtxTdecresc"); + else { + predelete(uptext, 1); + sprintf(uptext, "\\mtxDecresc{%s}", strcpy(STR1, uptext)); + } + break; + + default: + FORLIM = strlen(uptext); + for (k = 0; k <= FORLIM - 1; k++) { + if (pos1(uptext[k], "mpfzrs~") == 0) + return; + } + break; + } + strcpy(font, "\\mtxPF"); +} + + +#define default_ 10 +#define under (-14) + + +/* Local variables for addUptext: */ +struct LOC_addUptext { + short voice; + Char w[256]; + short adj; +} ; + +Local void adjustUptext(struct LOC_addUptext *LINK) +{ + Char letter; + boolean force = false; + uptext_info *WITH1; + + delete1(LINK->w, 1); + while (*LINK->w != '\0') { +/* p2c: uptext.pas: Note: Eliminated unused assignment statement [338] */ + letter = LINK->w[0]; + delete1(LINK->w, 1); + WITH1 = &U[LINK->voice-1]; + switch (letter) { + + case '<': + if (WITH1->uptext_lcz > 1) + WITH1->uptext_lcz--; + break; + + case '>': + if (WITH1->uptext_lcz < 3) + WITH1->uptext_lcz++; + break; + + case '^': + WITH1->uptext_adjust = 0; + break; + + case 'v': + WITH1->uptext_adjust = under; + break; + + case '=': + force = true; + break; + + case '+': + case '-': + if (*LINK->w != '\0') + getNum(LINK->w, &LINK->adj); + else + LINK->adj = 0; + if (letter == '-') + LINK->adj = -LINK->adj; + if (force) + WITH1->uptext_adjust = LINK->adj; + else + WITH1->uptext_adjust += LINK->adj; + *LINK->w = '\0'; + break; + + default: + error3(LINK->voice, "Unknown uptext adjustment"); + break; + } + } + strcpy(LINK->w, "!"); +} + + +void addUptext(short voice_, boolean *no_uptext, Char *pretex) +{ + struct LOC_addUptext V; + Char font[256]; + static Char lcz[4] = "lcz"; + uptext_info *WITH; + Char STR1[256], STR2[256], STR3[256]; + + V.voice = voice_; + WITH = &U[V.voice-1]; + if (WITH->uptext == 0) + *no_uptext = true; + if (*no_uptext) + return; + do { + GetNextWord(V.w, P[WITH->uptext - 1], blank, dummy); + sprintf(STR1, "%c", barsym); + if (!strcmp(V.w, STR1) || *V.w == '\0') + *no_uptext = true; + sprintf(STR1, "%c", tilde); + if (!strcmp(V.w, STR1) || *no_uptext) + return; + if (V.w[0] == '!') { + strcpy(WITH->uptext_font, V.w); + WITH->uptext_font[0] = '\\'; + } + if (V.w[0] == '@') + adjustUptext(&V); + } while (V.w[0] == '!'); /* ! is a kludge, will get me in trouble later */ + strcpy(font, WITH->uptext_font); + textTranslate(V.w, font); + if (*font != '\0') + sprintf(V.w, "%s{%s}", font, strcpy(STR1, V.w)); + switch (lcz[WITH->uptext_lcz - 1]) { + + case 'l': + sprintf(V.w, "\\mtxLchar{%s}{%s}", + toString(STR1, default_ + WITH->uptext_adjust), + strcpy(STR3, V.w)); + break; + + case 'c': + sprintf(V.w, "\\mtxCchar{%s}{%s}", + toString(STR1, default_ + WITH->uptext_adjust), + strcpy(STR2, V.w)); + break; + + case 'z': + sprintf(V.w, "\\mtxZchar{%s}{%s}", + toString(STR1, default_ + WITH->uptext_adjust), + strcpy(STR3, V.w)); + break; + } + strcat(pretex, V.w); +} + +#undef default_ +#undef under + + + + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/uptext.h b/Build/source/utils/m-tx/mtx-src/uptext.h new file mode 100644 index 00000000000..00fc6646a0a --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/uptext.h @@ -0,0 +1,25 @@ +/* Header for module uptext, generated by p2c 1.21alpha-07.Dec.93 */ +#ifndef UPTEXT_H +#define UPTEXT_H + + +#ifdef UPTEXT_G +# define vextern +#else +# define vextern extern +#endif +/* Insert and translate uptext */ + + +extern void initUptext(void); +extern void clearUptext(void); +extern short uptextLineNo(short voice); +extern void setUptextLineNo(short voice, short lno); +extern void addUptext(short voice, boolean *no_uptext, Char *pretex); + + +#undef vextern + +#endif /*UPTEXT_H*/ + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/uptext.pas b/Build/source/utils/m-tx/mtx-src/uptext.pas new file mode 100644 index 00000000000..16bebc7556f --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/uptext.pas @@ -0,0 +1,119 @@ +unit uptext; +{ Insert and translate uptext } + +interface + +procedure initUptext; +procedure clearUptext; +function uptextLineNo(voice: integer): integer; +procedure setUptextLineNo(voice, lno: integer); +procedure addUptext(voice: integer; var no_uptext: boolean; + var pretex: string); + +implementation uses globals, strings, mtxline, utility; + +type uptext_info = record + uptext, uptext_adjust, uptext_lcz: integer; + uptext_font: string; + end; + +var U: array[voice_index] of uptext_info; + +function uptextLineNo(voice: integer): integer; +begin uptextLineNo := U[voice].uptext; end; + +procedure setUptextLineNo(voice, lno: integer); +begin U[voice].uptext := lno; end; + +procedure clearUptext; + var voice: voice_index; +begin for voice:=1 to nvoices do U[voice].uptext:=0; end; + +procedure initUptext; + var voice: voice_index; +begin for voice:=1 to nvoices do with U[voice] do + begin + uptext_adjust:=0; uptext_lcz:=3; uptext_font:=''; + end; +end; + +procedure textTranslate(var uptext, font: string); + var k: integer; +begin + if uptext='' then exit; + repeat k := pos1('%',uptext); + if k>0 then uptext:= + substr(uptext,1,k-1)+'{\mtxFlat}'+substr(uptext,k+1,length(uptext)-k); + until k=0; + repeat k := pos1('#',uptext); + if k>0 then uptext:= + substr(uptext,1,k-1)+'{\mtxSharp}'+substr(uptext,k+1,length(uptext)-k); + until k=0; + case uptext[1] of + '<': if uptext='<' then uptext:='\mtxIcresc' + else if uptext='<.' then uptext:='\mtxTcresc' + else begin + predelete(uptext,1); uptext:='\mtxCresc{'+uptext+'}' + end; + '>': if uptext='>' then uptext:='\mtxIdecresc' + else if uptext='>.' then uptext:='\mtxTdecresc' + else begin + predelete(uptext,1); uptext:='\mtxDecresc{'+uptext+'}' + end; + else for k:=1 to length(uptext) do if pos1(uptext[k],'mpfzrs~')=0 then exit; + end; + font:='\mtxPF'; +end; + +procedure addUptext(voice: integer; var no_uptext: boolean; + var pretex: string); + var w, font: string; + adj: integer; + const default = 10; under = -14; + lcz: string[3] = 'lcz'; + procedure adjustUptext; + var letter: char; + force: boolean; + begin delete1(w,1); force:=false; + while w<>'' do with U[voice] do + begin letter:=w[1]; delete1(w,1); with U[voice] do + case letter of + '<': if uptext_lcz>1 then dec(uptext_lcz); + '>': if uptext_lcz<3 then inc(uptext_lcz); + '^': uptext_adjust:=0; + 'v': uptext_adjust:=under; + '=': force:=true; +'+','-': begin if w<>'' then getNum(w,adj) else adj:=0; + if letter = '-' then adj := -adj; + if force then uptext_adjust := adj else inc(uptext_adjust,adj); + w:=''; + end; + else error3(voice,'Unknown uptext adjustment'); + end; + end; + w:='!'; + end; + + begin + with U[voice] do begin + if uptext=0 then no_uptext := true; + if no_uptext then exit; + repeat + w := GetNextWord(P[uptext],blank,dummy); + if (w=barsym) or (w='') then no_uptext:=true; + if (w=tilde) or no_uptext then exit; + if w[1]='!' then begin uptext_font:=w; uptext_font[1]:='\'; end; + if w[1]='@' then adjustUptext; + until w[1]<>'!'; { ! is a kludge, will get me in trouble later } + font:=uptext_font; textTranslate(w,font); + if font<>'' then w:=font+'{'+w+'}'; + case lcz[uptext_lcz] of +'l': w:='\mtxLchar{' + toString(default+uptext_adjust) + '}{' + w + '}'; +'c': w:='\mtxCchar{' + toString(default+uptext_adjust) + '}{' + w + '}'; +'z': w:='\mtxZchar{' + toString(default+uptext_adjust) + '}{' + w + '}'; + end; + pretex:=pretex+w; + end; + end; + +end. diff --git a/Build/source/utils/m-tx/mtx-src/utility.c b/Build/source/utils/m-tx/mtx-src/utility.c new file mode 100644 index 00000000000..b44c07b5555 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/utility.c @@ -0,0 +1,364 @@ +/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ +/* From input file "utility.pas" */ + + +#include "p2c.h" + +#define UTILITY_G +#include "utility.h" + + +#ifndef STRINGS_H +#include "strings.h" +#endif + + +#define blank ' ' +#define dummy '\0' + + +short wordCount(Char *s) +{ + short i, n, FORLIM; + + if (*s == '\0') + return 0; + if (s[0] == blank) + n = 0; + else + n = 1; + FORLIM = strlen(s); + for (i = 1; i <= FORLIM - 1; i++) { + if (s[i-1] == blank && s[i] != blank) + n++; + } + return n; +} + + +Char *GetNextWord(Char *Result, Char *s, Char Delim, Char Term) +{ + /* A delimiter is a character that separates words, but forms no part + of them. A terminator is a character that appears at the end of + a word. */ + short n = 1; + short start, last; + + last = strlen(s); + while (n <= last && s[n-1] == Delim) + n++; + start = n; + while (n <= last && s[n-1] != Term && s[n-1] != Delim) + n++; + if (n <= last && s[n-1] == Term) + n++; + substr_(Result, s, start, n - start); + while (n <= last && s[n-1] == Delim) + n++; + predelete(s, n - 1); + return Result; +} + + +Char *NextWord(Char *Result, Char *s_, Char Delim, Char Term) +{ + Char s[256]; + + strcpy(s, s_); + return (GetNextWord(Result, s, Delim, Term)); +} + + +Char *plural(Char *Result, short n) +{ + if (n == 1) + return strcpy(Result, ""); + else + return strcpy(Result, "s"); +} + + +short curtail(Char *s, Char c) +{ + short Result = 0; + short l; + + l = strlen(s); + if (s[l-1] == c) { + shorten(s, l - 1); + return l; + } + return Result; +} + + +Char *toString(Char *Result, short n) +{ + Char s[256]; + + sprintf(s, "%d", n); + return strcpy(Result, s); +} + + +short digit(Char c) +{ + return (c - '0'); +} + + +boolean equalsIgnoreCase(Char *s1_, Char *s2_) +{ + Char s1[256], s2[256]; + + strcpy(s1, s1_); + strcpy(s2, s2_); + toUpper(s1); + toUpper(s2); + return (strcmp(s1, s2) == 0); +} + + +boolean startsWithIgnoreCase(Char *s1_, Char *s2_) +{ + Char s1[256], s2[256]; + + strcpy(s1, s1_); + strcpy(s2, s2_); + toUpper(s1); + toUpper(s2); + return (startsWith(s1, s2)); +} + + +boolean startsWithBracedWord(Char *P_) +{ + Char P[256]; + Char w[256]; + + strcpy(P, P_); + GetNextWord(w, P, blank, dummy); + return (w[0] == '{' && w[strlen(w) - 1] == '}'); +} + + +void trim(Char *s) +{ + short k; + + k = posNot(blank, s); + if (k > 1) + predelete(s, k - 1); + else if (k == 0) + *s = '\0'; +} + + +boolean endsWith(Char *s1_, Char *s2) +{ + Char s1[256]; + short l1, l2; + + strcpy(s1, s1_); + l1 = strlen(s1); + l2 = strlen(s2); + if (l1 < l2) + return false; + predelete(s1, l1 - l2); + return (strcmp(s1, s2) == 0); +} + + +/* Local variables for grep: */ +struct LOC_grep { + Char *source, *pattern; + short p1[10], p2[10]; + short i, p, s, index; + boolean matching; +} ; + +Local void remember(short s1, short s2, struct LOC_grep *LINK) +{ + if (LINK->index > 9) + _Escape(9999); + LINK->p1[LINK->index] = s1; + LINK->p2[LINK->index] = s2; + LINK->s = s2 + 1; + LINK->index++; +} + +Local void matchnum(struct LOC_grep *LINK) +{ + boolean allowsign = false, allowpoint = false, quit = false; + short s0; + + LINK->matching = false; + s0 = LINK->s; + if (LINK->p < strlen(LINK->pattern)) { + if (LINK->pattern[LINK->p] == '#') { + LINK->p++; + allowsign = true; + if (LINK->p < strlen(LINK->pattern)) { + if (LINK->pattern[LINK->p] == '#') { + LINK->p++; + allowpoint = true; + } + } + } + } + if (allowsign && + (LINK->source[LINK->s-1] == '-' || LINK->source[LINK->s-1] == '+')) { + LINK->s++; + if (LINK->s > strlen(LINK->source)) + return; + } + while (!quit && LINK->s <= strlen(LINK->source)) { + if (LINK->source[LINK->s-1] == '.') { + if (!allowpoint) + quit = true; + else { + LINK->s++; + allowpoint = false; + } + } + if (isdigit(LINK->source[LINK->i-1])) { + LINK->s++; + LINK->matching = true; + } else + quit = true; + } + if (LINK->matching) + remember(s0, LINK->s - 1, LINK); +} + +Local void matchmeta(struct LOC_grep *LINK) +{ + if (LINK->p < strlen(LINK->pattern)) + LINK->p++; + if (LINK->source[LINK->s-1] == LINK->pattern[LINK->p-1]) { + LINK->s++; + LINK->p++; + } else + LINK->matching = false; +} + +Local void subgrep(struct LOC_grep *LINK) +{ + LINK->matching = true; + if (LINK->pattern[LINK->p-1] == '*') { + remember(LINK->s, strlen(LINK->source), LINK); + LINK->p++; + return; + } + if (LINK->pattern[LINK->p-1] == '?') { + remember(LINK->s, LINK->s, LINK); + LINK->p++; + return; + } + if (LINK->pattern[LINK->p-1] == '#') { + matchnum(LINK); + return; + } + if (LINK->pattern[LINK->p-1] == '\\') { + matchmeta(LINK); + return; + } + if (LINK->source[LINK->s-1] == LINK->pattern[LINK->p-1]) { + LINK->s++; + LINK->p++; + } else + LINK->matching = false; +} + + +/*--- Match/Replace package --- */ + +/* Search and replace. Stops when pattern no longer matches source. + Pattern wildcards: + ? Any single character + * Any string + # An unsigned integer + ## A signed integer + ### A signed number maybe with a decimal part + Pattern metacharacters: + \x where x is any character, stands for that character + Target wildcards + \0 to \9 Value of corresponding source wildcard + Target metacharacters + \ When not followed by 0..9 or \, stands for itself + \\ Backslash +*/ +void grep(Char *source_, Char *pattern_, Char *target) +{ + struct LOC_grep V; + short j, t, reg; + Char product[256]; + boolean trigger = false; + short FORLIM, FORLIM1; + Char STR2[256]; + + V.source = source_; + V.pattern = pattern_; + V.index = 0; + V.s = 1; + V.p = 1; + for (V.i = 0; V.i <= 9; V.i++) { + V.p1[V.i] = 1; + V.p2[V.i] = 0; + } + while (V.matching && V.p <= strlen(V.pattern) && V.s <= strlen(V.source)) + subgrep(&V); + *product = '\0'; + FORLIM = strlen(target); + for (t = 0; t <= FORLIM - 1; t++) { + if (trigger) { + reg = digit(target[t]); + if ((unsigned)reg <= 9) { + FORLIM1 = V.p2[reg]; + for (j = V.p1[reg] - 1; j <= FORLIM1 - 1; j++) + sprintf(product + strlen(product), "%c", V.source[j]); + } else if (target[t] == '\\') + strcat(product, "\\"); + else + sprintf(product + strlen(product), "\\%c", target[t]); + trigger = false; + } else if (target[t] == '\\' && t + 1 < strlen(target)) + trigger = true; + else + sprintf(product + strlen(product), "%c", target[t]); + } + strcpy(V.source, substr_(STR2, V.source, V.s, strlen(V.source))); + strcpy(V.pattern, substr_(STR2, V.pattern, V.p, strlen(V.pattern))); + strcpy(target, product); +} + + +/* "match" tests whether the source matches the pattern exactly */ +boolean match(Char *source_, Char *pattern_) +{ + Char source[256], pattern[256]; + static Char target[256] = ""; + + strcpy(source, source_); + strcpy(pattern, pattern_); + grep(source, pattern, target); + return (*source == '\0' && *pattern == '\0'); +} + + +/* "translate" replaces the pattern by the target in the source. */ +Char *translate(Char *Result, Char *source_, Char *pattern_, Char *target_) +{ + Char source[256], pattern[256], target[256]; + + strcpy(source, source_); + strcpy(pattern, pattern_); + strcpy(target, target_); + grep(source, pattern, target); + return strcpy(Result, target); +} + + + + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/utility.h b/Build/source/utils/m-tx/mtx-src/utility.h new file mode 100644 index 00000000000..2faeb292ffa --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/utility.h @@ -0,0 +1,41 @@ +/* Header for module utility, generated by p2c 1.21alpha-07.Dec.93 */ +#ifndef UTILITY_H +#define UTILITY_H + + +#ifdef UTILITY_G +# define vextern +#else +# define vextern extern +#endif +/* DPL 2004-03-22 */ + +/* Utilities, mainly aids to parsing */ + + +extern boolean equalsIgnoreCase(Char *s1, Char *s2); +extern boolean startsWithIgnoreCase(Char *s1, Char *s2); +extern boolean endsWith(Char *s1, Char *s2); +extern boolean startsWithBracedWord(Char *P); +extern Char *GetNextWord(Char *Result, Char *s, Char Delim, Char Term); +extern Char *NextWord(Char *Result, Char *s, Char Delim, Char Term); +extern short wordCount(Char *s); +extern Char *plural(Char *Result, short n); +extern short curtail(Char *s, Char c); +/* Remove last character if it equals c and return its position; + otherwise return 0 */ +extern Char *toString(Char *Result, short n); +extern void trim(Char *s); +extern short digit(Char c); +extern boolean match(Char *source, Char *pattern); +extern Char *translate(Char *Result, Char *source, Char *pattern, + Char *target); +extern void grep(Char *source, Char *pattern, Char *target); +/* See Implementation for what this currently does. */ + + +#undef vextern + +#endif /*UTILITY_H*/ + +/* End. */ diff --git a/Build/source/utils/m-tx/mtx-src/utility.pas b/Build/source/utils/m-tx/mtx-src/utility.pas new file mode 100644 index 00000000000..42cc76d15d5 --- /dev/null +++ b/Build/source/utils/m-tx/mtx-src/utility.pas @@ -0,0 +1,194 @@ +unit utility; { DPL 2004-03-22 } + +{ Utilities, mainly aids to parsing } + +interface + +function equalsIgnoreCase(s1, s2: string): boolean; +function startsWithIgnoreCase(s1, s2: string): boolean; +function endsWith(s1, s2: string): boolean; +function startsWithBracedWord (P: string): boolean; +function GetNextWord (var s: string; Delim, Term: char): string; +function NextWord (s: string; Delim, Term: char): string; +function wordCount (s: string): integer; +function plural (n: integer): string; +function curtail (var s: string; c: char): integer; + { Remove last character if it equals c and return its position; + otherwise return 0 } +function toString(n: integer): string; +procedure trim(var s: string); +function digit(c: char): integer; +function match(source, pattern: string): boolean; +function translate(source, pattern, target: string): string; +procedure grep(var source, pattern, target: string); + { See Implementation for what this currently does. } + +implementation uses strings; + +const blank = ' '; dummy = #0; + +function wordCount (s: string): integer; + var i, n: integer; + begin if length(s)=0 then + begin wordCount:=0; exit; end; + if s[1]=blank then n:=0 else n:=1; + for i:=1 to length(s)-1 do + if (s[i]=blank) and (s[i+1]<>blank) then inc(n); + wordCount:=n; + end; + +function GetNextWord (var s: string; Delim, Term: char): string; +{ A delimiter is a character that separates words, but forms no part + of them. A terminator is a character that appears at the end of + a word. } + var n, start, last: integer; +begin last:=length(s); n:=1; + while (n<=last) and (s[n] = Delim) do inc(n); + start:=n; + while (n<=last) and not (s[n] in [Delim,Term]) do inc(n); + if (n<=last) and (s[n] = Term) then inc(n); + GetNextWord:=substr(s,start,n-start); + while (n<=last) and (s[n] = Delim) do inc(n); + predelete(s,n-1); +end; + +function NextWord (s: string; Delim, Term: char): string; + begin NextWord:=GetNextWord(s,Delim,Term); end; + +function plural (n: integer): string; + begin if n=1 then plural:='' else plural:='s'; end; + +function curtail (var s: string; c: char): integer; + var l: integer; + begin l:=length(s); curtail:=0; + if s[l]=c then begin shorten(s,l-1); curtail:=l; end; + end; + +function toString(n: integer): string; + var s: string; +begin str(n,s); toString:=s; end; + +function digit(c: char): integer; + begin digit:=ord(c)-ord('0'); end; + +function equalsIgnoreCase(s1, s2: string): boolean; +begin toUpper(s1); toUpper(s2); equalsIgnoreCase:=s1=s2; +end; + +function startsWithIgnoreCase(s1, s2: string): boolean; +begin toUpper(s1); toUpper(s2); startsWithIgnoreCase:=startsWith(s1,s2); +end; + +function startsWithBracedWord (P: string): boolean; + var w: string; +begin w := getNextWord(P,blank,dummy); + startsWithBracedWord := (w[1]='{') and (w[length(w)]='}'); +end; + +procedure trim(var s: string); + var k: integer; + begin k:=posnot(blank,s); + if k>1 then predelete(s,k-1) else if k=0 then s:=''; + end; + +function endsWith(s1, s2: string): boolean; + var l1, l2: integer; +begin l1:=length(s1); l2:=length(s2); + if l19 then halt(9999); + p1[index] := s1; p2[index] := s2; s := s2+1; inc(index) + end; + procedure matchnum; + var allowsign, allowpoint, quit: boolean; + s0: integer; + begin allowsign := false; allowpoint := false; matching := false; s0 := s; + if plength(source) then exit end; + quit := false; + while (not quit) and (s<=length(source)) do + begin if source[s]='.' then if not allowpoint then quit := true else + begin inc(s); allowpoint := false end; + if (source[i]>='0') and (source[i]<='9') then + begin inc(s); matching := true end + else quit := true + end; + if matching then remember(s0,s-1) + end; + procedure matchmeta; + begin if p=0) and (reg<=9) then + for j:=p1[reg] to p2[reg] do product := product + source[j] + else if target[t]='\' then product := product + '\' + else product := product + '\' + target[t]; + trigger := false + end + else if (target[t]='\') and (t +dnl +dnl This file is free software; the copyright holder +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl -------------------------------------------------------- +dnl +dnl m4-include this file to define the current mtx version +m4_define([mtx_version], [0.61]) diff --git a/Build/source/utils/m-tx/prepmx.1 b/Build/source/utils/m-tx/prepmx.1 index 299591e2e9d..226457c532e 100644 --- a/Build/source/utils/m-tx/prepmx.1 +++ b/Build/source/utils/m-tx/prepmx.1 @@ -1,4 +1,4 @@ -.TH prepmx 1 "01 September 2005" "M-Tx Version 0.60" "prepmx Manual Page" +.TH prepmx 1 "15 December 2015" "M-Tx Version 0.61" "prepmx Manual Page" .SH NAME prepmx \- preprocessor for PMX, easy music typesetting program .SH SYNOPSIS @@ -18,17 +18,18 @@ easy example, have a look at the following example: c8 g+ e g c- g+ e g | d g f g c- g+ e g | For syntax reference, please look at the M-Tx manual written by Dirk -Laurie, the creator of the M-Tx language and the author of prepmx, its -command line utility. +Laurie, the creator of the M-Tx language and the author of +.BR prepmx (1), +its command-line utility. .B prepmx processes the file .IR jobname .mtx to generate .IR jobname .pmx. -You can then process this file using the `pmx' command. -.B PMX -is a preprocessor for MusiXTeX. +You can then process this file using the +.BR pmxab (1) +command, which is a preprocessor for MusiXTeX. .I outdir/ is the directory where `pmx' will put the final .tex file. Note that the @@ -41,40 +42,44 @@ Options can also be specified in a `Options:' line in the preamble, which takes precedence over the command line. .TP .B \-b -never unbeam eighth notes and shorter +disable unbeamVocal .TP .B \-c -main music lines only \- ignore chords +disable doChords .TP .B \-D -enable debug mode +enable debugMode .TP .B \-f -use tonic sol\-fa note names +enable solfaNoteNames .TP .B \-i -ignore errors +enable ignoreErrors .TP .B \-m -music only \- ignore lyrics +disable doLyrics .TP .B \-n -indent first system and print default instrument names +enable instrumentNames .TP .B \-t -ignore uptext lines +disable doUptext .TP .B \-u -uptext synchronizes with notes only, not rests +disable uptextOnRests .TP .B \-v -verbose progress report +enable beVerbose .TP .B \-w -enable pedantic warnings +enable pedanticWarnings .TP .BI \- n -select specified case of multiple score +select Special Case +.I n +.TP +.B \-H +print enabled status of all options .SH EXIT STATUS If no error was found, .B prepmx @@ -84,12 +89,12 @@ the actual error. A return status of 10000 means that the input file was empty or could not be opened. .SH SEE ALSO .B M-Tx -User's Guide (mtx060.pdf) +User's Guide (mtxdoc.pdf) .br -pmx(1), musixtex(1) +pmxab(1), musixtex(1) .SH AUTHORS -prepmx was written by Dirk Laurie . -This manual page was written by Roland Stigge for the Debian -project. It was revised and extended by Nis Martensen -, mostly by copying text from Dirk Laurie's M-Tx -User's Guide. +prepmx was written by Dirk Laurie . This +manual page was written by Roland Stigge +for the Debian project. It was revised and extended by +Nis Martensen and Bob Tennent +. diff --git a/Build/source/utils/m-tx/version.ac b/Build/source/utils/m-tx/version.ac index cfad6555f7b..84d5d2ed6be 100644 --- a/Build/source/utils/m-tx/version.ac +++ b/Build/source/utils/m-tx/version.ac @@ -8,4 +8,4 @@ dnl dnl -------------------------------------------------------- dnl dnl m4-include this file to define the current mtx version -m4_define([mtx_version], [0.60d]) +m4_define([mtx_version], [0.61]) -- cgit v1.2.3