diff -Nru adplug-2.3.1+dfsg/aclocal.m4 adplug-2.3.3+dfsg/aclocal.m4 --- adplug-2.3.1+dfsg/aclocal.m4 2018-04-22 09:12:27.000000000 +0000 +++ adplug-2.3.3+dfsg/aclocal.m4 2020-06-10 00:53:19.000000000 +0000 @@ -21,7 +21,7 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# serial 12 (pkg-config-0.29.2) +# serial 11 (pkg-config-0.29.1) dnl Copyright © 2004 Scott James Remnant . dnl Copyright © 2012-2015 Dan Nicholson @@ -63,7 +63,7 @@ dnl See the "Since" comment for each macro you use to see what version dnl of the macros you require. m4_defun([PKG_PREREQ], -[m4_define([PKG_MACROS_VERSION], [0.29.2]) +[m4_define([PKG_MACROS_VERSION], [0.29.1]) m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) ])dnl PKG_PREREQ @@ -164,7 +164,7 @@ AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no -AC_MSG_CHECKING([for $2]) +AC_MSG_CHECKING([for $1]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) @@ -174,11 +174,11 @@ See the pkg-config man page for more details.]) if test $pkg_failed = yes; then - AC_MSG_RESULT([no]) + AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` - else + else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs @@ -195,7 +195,7 @@ _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then - AC_MSG_RESULT([no]) + AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full @@ -296,6 +296,74 @@ AS_VAR_IF([$1], [""], [$5], [$4])dnl ])dnl PKG_CHECK_VAR +dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES, +dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND], +dnl [DESCRIPTION], [DEFAULT]) +dnl ------------------------------------------ +dnl +dnl Prepare a "--with-" configure option using the lowercase +dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and +dnl PKG_CHECK_MODULES in a single macro. +AC_DEFUN([PKG_WITH_MODULES], +[ +m4_pushdef([with_arg], m4_tolower([$1])) + +m4_pushdef([description], + [m4_default([$5], [build with ]with_arg[ support])]) + +m4_pushdef([def_arg], [m4_default([$6], [auto])]) +m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes]) +m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no]) + +m4_case(def_arg, + [yes],[m4_pushdef([with_without], [--without-]with_arg)], + [m4_pushdef([with_without],[--with-]with_arg)]) + +AC_ARG_WITH(with_arg, + AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),, + [AS_TR_SH([with_]with_arg)=def_arg]) + +AS_CASE([$AS_TR_SH([with_]with_arg)], + [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)], + [auto],[PKG_CHECK_MODULES([$1],[$2], + [m4_n([def_action_if_found]) $3], + [m4_n([def_action_if_not_found]) $4])]) + +m4_popdef([with_arg]) +m4_popdef([description]) +m4_popdef([def_arg]) + +])dnl PKG_WITH_MODULES + +dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES, +dnl [DESCRIPTION], [DEFAULT]) +dnl ----------------------------------------------- +dnl +dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES +dnl check._[VARIABLE-PREFIX] is exported as make variable. +AC_DEFUN([PKG_HAVE_WITH_MODULES], +[ +PKG_WITH_MODULES([$1],[$2],,,[$3],[$4]) + +AM_CONDITIONAL([HAVE_][$1], + [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"]) +])dnl PKG_HAVE_WITH_MODULES + +dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES, +dnl [DESCRIPTION], [DEFAULT]) +dnl ------------------------------------------------------ +dnl +dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after +dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make +dnl and preprocessor variable. +AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES], +[ +PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4]) + +AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"], + [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])]) +])dnl PKG_HAVE_DEFINE_WITH_MODULES + # Copyright (C) 2002-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation diff -Nru adplug-2.3.1+dfsg/adplug.qpg adplug-2.3.3+dfsg/adplug.qpg --- adplug-2.3.1+dfsg/adplug.qpg 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/adplug.qpg 2020-05-12 00:58:03.000000000 +0000 @@ -91,7 +91,7 @@ - + diff -Nru adplug-2.3.1+dfsg/compile adplug-2.3.3+dfsg/compile --- adplug-2.3.1+dfsg/compile 2018-04-22 09:12:29.000000000 +0000 +++ adplug-2.3.3+dfsg/compile 2015-07-25 00:29:35.000000000 +0000 @@ -1,9 +1,9 @@ #! /bin/sh # Wrapper for compilers which do not understand '-c -o'. -scriptversion=2018-03-07.03; # UTC +scriptversion=2012-10-14.11; # UTC -# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Copyright (C) 1999-2014 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -255,8 +255,7 @@ echo "compile $scriptversion" exit $? ;; - cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ - icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac @@ -340,9 +339,9 @@ # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'before-save-hook 'time-stamp) +# eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" +# time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: diff -Nru adplug-2.3.1+dfsg/config.guess adplug-2.3.3+dfsg/config.guess --- adplug-2.3.1+dfsg/config.guess 2018-04-22 09:12:29.000000000 +0000 +++ adplug-2.3.3+dfsg/config.guess 2015-07-25 00:29:35.000000000 +0000 @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2018 Free Software Foundation, Inc. +# Copyright 1992-2014 Free Software Foundation, Inc. -timestamp='2018-01-01' +timestamp='2014-11-04' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -27,7 +27,7 @@ # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # # Please send patches to . @@ -39,7 +39,7 @@ Output the configuration name of the system \`$me' is run on. -Options: +Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -50,7 +50,7 @@ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2018 Free Software Foundation, Inc. +Copyright 1992-2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -168,29 +168,19 @@ # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - /sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || \ - echo unknown)` + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; - earmv*) - arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` - endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` - machine=${arch}${endian}-unknown - ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently (or will in the future) and ABI. + # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in - earm*) - os=netbsdelf - ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ @@ -207,13 +197,6 @@ os=netbsd ;; esac - # Determine ABI tags. - case "${UNAME_MACHINE_ARCH}" in - earm*) - expr='s/^earmv[0-9]/-eabi/;s/eb$//' - abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` - ;; - esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need @@ -224,13 +207,13 @@ release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}${abi}" + echo "${machine}-${os}${release}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` @@ -240,13 +223,6 @@ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; - *:LibertyBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} - exit ;; - *:MidnightBSD:*:*) - echo ${UNAME_MACHINE}-unknown-midnightbsd${UNAME_RELEASE} - exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; @@ -259,15 +235,6 @@ *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; - *:Sortix:*:*) - echo ${UNAME_MACHINE}-unknown-sortix - exit ;; - *:Redox:*:*) - echo ${UNAME_MACHINE}-unknown-redox - exit ;; - mips:OSF1:*.*) - echo mips-dec-osf1 - exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) @@ -284,46 +251,55 @@ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") - UNAME_MACHINE=alpha ;; + UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") - UNAME_MACHINE=alpha ;; + UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") - UNAME_MACHINE=alpha ;; + UNAME_MACHINE="alpha" ;; "EV5 (21164)") - UNAME_MACHINE=alphaev5 ;; + UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") - UNAME_MACHINE=alphaev56 ;; + UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") - UNAME_MACHINE=alphapca56 ;; + UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") - UNAME_MACHINE=alphapca57 ;; + UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") - UNAME_MACHINE=alphaev6 ;; + UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") - UNAME_MACHINE=alphaev67 ;; + UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") - UNAME_MACHINE=alphaev68 ;; + UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") - UNAME_MACHINE=alphaev68 ;; + UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") - UNAME_MACHINE=alphaev68 ;; + UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE=alphaev69 ;; + UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") - UNAME_MACHINE=alphaev7 ;; + UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") - UNAME_MACHINE=alphaev79 ;; + UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; @@ -383,16 +359,16 @@ exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build - SUN_ARCH=i386 + SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then - SUN_ARCH=x86_64 + SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` @@ -417,7 +393,7 @@ exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} @@ -485,13 +461,13 @@ #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); @@ -614,7 +590,7 @@ *:AIX:*:*) echo rs6000-ibm-aix exit ;; - ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) + ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and @@ -635,20 +611,20 @@ 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in - 9000/31?) HP_ARCH=m68000 ;; - 9000/[34]??) HP_ARCH=m68k ;; + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in - 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 - 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in - 32) HP_ARCH=hppa2.0n ;; - 64) HP_ARCH=hppa2.0w ;; - '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi @@ -687,11 +663,11 @@ exit (0); } EOF - (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = hppa2.0w ] + if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build @@ -704,12 +680,12 @@ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then - HP_ARCH=hppa2.0w + HP_ARCH="hppa2.0w" else - HP_ARCH=hppa64 + HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} @@ -749,7 +725,7 @@ { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) @@ -758,7 +734,7 @@ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) @@ -814,14 +790,14 @@ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` - FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) @@ -837,11 +813,10 @@ UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) - UNAME_PROCESSOR=x86_64 ;; - i386) - UNAME_PROCESSOR=i586 ;; + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin @@ -855,6 +830,10 @@ *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; @@ -870,12 +849,27 @@ echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; @@ -885,7 +879,7 @@ exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix @@ -908,7 +902,7 @@ EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + if test "$?" = 0 ; then LIBC="gnulibc1" ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) @@ -939,9 +933,6 @@ crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; - e2k:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; @@ -954,9 +945,6 @@ ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; - k1om:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; @@ -982,9 +970,6 @@ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; - mips64el:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; @@ -1017,9 +1002,6 @@ ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; - riscv32:Linux:*:* | riscv64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; @@ -1039,18 +1021,7 @@ echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) - eval $set_cc_for_build - X86_64_ABI= - # If there is a compiler, see if it is configured for 32-bit objects. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_X32 >/dev/null - then - X86_64_ABI=x32 - fi - fi - echo ${UNAME_MACHINE}-pc-linux-${LIBC}${X86_64_ABI} + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} @@ -1089,7 +1060,7 @@ i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; - i*86:*:4.*:*) + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} @@ -1129,7 +1100,7 @@ # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configure will decide that + # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; @@ -1278,9 +1249,6 @@ SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; - SX-ACE:SUPER-UX:*:*) - echo sxace-nec-superux${UNAME_RELEASE} - exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; @@ -1294,23 +1262,16 @@ UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi - # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc - if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_PPC >/dev/null - then - UNAME_PROCESSOR=powerpc - fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub @@ -1325,7 +1286,7 @@ exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = x86; then + if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi @@ -1334,18 +1295,15 @@ *:QNX:*:4*) echo i386-pc-qnx exit ;; - NEO-*:NONSTOP_KERNEL:*:*) + NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; - NSR-*:NONSTOP_KERNEL:*:*) + NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; - NSX-*:NONSTOP_KERNEL:*:*) - echo nsx-tandem-nsk${UNAME_RELEASE} - exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; @@ -1359,7 +1317,7 @@ # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = 386; then + if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" @@ -1401,7 +1359,7 @@ echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos @@ -1412,37 +1370,23 @@ x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; - amd64:Isilon\ OneFS:*:*) - echo x86_64-unknown-onefs - exit ;; -esac - -echo "$0: unable to guess system type" >&2 - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}" in - mips:Linux | mips64:Linux) - # If we got here on MIPS GNU/Linux, output extra information. - cat >&2 <&2 < in order to provide the needed +information to handle your system. config.guess timestamp = $timestamp @@ -1470,7 +1414,7 @@ exit 1 # Local variables: -# eval: (add-hook 'write-file-functions 'time-stamp) +# eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff -Nru adplug-2.3.1+dfsg/config.sub adplug-2.3.3+dfsg/config.sub --- adplug-2.3.1+dfsg/config.sub 2018-04-22 09:12:29.000000000 +0000 +++ adplug-2.3.3+dfsg/config.sub 2015-07-25 00:29:35.000000000 +0000 @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2018 Free Software Foundation, Inc. +# Copyright 1992-2014 Free Software Foundation, Inc. -timestamp='2018-01-01' +timestamp='2014-12-03' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -33,7 +33,7 @@ # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -53,11 +53,12 @@ me=`echo "$0" | sed -e 's,.*/,,'` usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS Canonicalize a configuration name. -Options: +Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -67,7 +68,7 @@ version="\ GNU config.sub ($timestamp) -Copyright 1992-2018 Free Software Foundation, Inc. +Copyright 1992-2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -116,8 +117,8 @@ case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | cloudabi*-eabi* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` @@ -229,6 +230,9 @@ -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; -psos*) os=-psos ;; @@ -251,16 +255,15 @@ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ - | ba \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx | dvp \ - | e2k | epiphany \ - | fido | fr30 | frv | ft32 \ + | d10v | d30v | dlx | dsp16xx \ + | epiphany \ + | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ - | i370 | i860 | i960 | ia16 | ia64 \ + | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ @@ -298,12 +301,11 @@ | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pru \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ @@ -312,7 +314,7 @@ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ - | wasm32 \ + | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown @@ -374,18 +376,17 @@ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ - | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ - | e2k-* | elxsi-* \ + | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ - | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ @@ -426,15 +427,13 @@ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pru-* \ | pyramid-* \ - | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ @@ -443,7 +442,6 @@ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ - | wasm32-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ @@ -520,9 +518,6 @@ basic_machine=i386-pc os=-aros ;; - asmjs) - basic_machine=asmjs-unknown - ;; aux) basic_machine=m68k-apple os=-aux @@ -639,18 +634,10 @@ basic_machine=rs6000-bull os=-bosx ;; - dpx2*) + dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; - e500v[12]) - basic_machine=powerpc-unknown - os=$os"spe" - ;; - e500v[12]-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - os=$os"spe" - ;; ebmon29k) basic_machine=a29k-amd os=-ebmon @@ -836,24 +823,6 @@ basic_machine=m68k-atari os=-mint ;; - mipsEE* | ee | ps2) - basic_machine=mips64r5900el-scei - case $os in - -linux*) - ;; - *) - os=-elf - ;; - esac - ;; - iop) - basic_machine=mipsel-scei - os=-irx - ;; - dvp) - basic_machine=dvp-scei - os=-elf - ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; @@ -919,7 +888,7 @@ basic_machine=v70-nec os=-sysv ;; - next | m*-next) + next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) @@ -964,9 +933,6 @@ nsr-tandem) basic_machine=nsr-tandem ;; - nsx-tandem) - basic_machine=nsx-tandem - ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf @@ -1051,7 +1017,7 @@ ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - ppcle | powerpclittle) + ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) @@ -1061,7 +1027,7 @@ ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - ppc64le | powerpc64little) + ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) @@ -1262,9 +1228,6 @@ basic_machine=a29k-wrs os=-vxworks ;; - wasm32) - basic_machine=wasm32-unknown - ;; w65*) basic_machine=w65-wdc os=-none @@ -1273,9 +1236,6 @@ basic_machine=hppa1.1-winbond os=-proelf ;; - x64) - basic_machine=x86_64-pc - ;; xbox) basic_machine=i686-pc os=-mingw32 @@ -1383,8 +1343,8 @@ if [ x"$os" != x"" ] then case $os in - # First match some system type aliases that might get confused - # with valid system types. + # First match some system type aliases + # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux @@ -1404,37 +1364,36 @@ -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; - # Now accept the basic system types. + # First accept the basic system types. # The portable systems comes first. - # Each alternative MUST end in a * to match a version number. + # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* | -cloudabi* | -sortix* \ + | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ + | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ + | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -irx* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ - | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1509,7 +1468,7 @@ -nova*) os=-rtmk-nova ;; - -ns2) + -ns2 ) os=-nextstep2 ;; -nsk*) @@ -1564,23 +1523,8 @@ -dicos*) os=-dicos ;; - -pikeos*) - # Until real need of OS specific support for - # particular features comes up, bare metal - # configurations are quite functional. - case $basic_machine in - arm*) - os=-eabi - ;; - *) - os=-elf - ;; - esac - ;; -nacl*) ;; - -ios) - ;; -none) ;; *) @@ -1676,9 +1620,6 @@ sparc-* | *-sun) os=-sunos4.1.1 ;; - pru-*) - os=-elf - ;; *-be) os=-beos ;; @@ -1724,7 +1665,7 @@ m88k-omron*) os=-luna ;; - *-next) + *-next ) os=-nextstep ;; *-sequent) @@ -1859,7 +1800,7 @@ exit # Local variables: -# eval: (add-hook 'write-file-functions 'time-stamp) +# eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff -Nru adplug-2.3.1+dfsg/configure adplug-2.3.3+dfsg/configure --- adplug-2.3.1+dfsg/configure 2018-04-22 09:12:28.000000000 +0000 +++ adplug-2.3.3+dfsg/configure 2020-06-10 00:53:21.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for adplug 2.3.1. +# Generated by GNU Autoconf 2.69 for adplug 2.3.3. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -587,8 +587,8 @@ # Identity of this package. PACKAGE_NAME='adplug' PACKAGE_TARNAME='adplug' -PACKAGE_VERSION='2.3.1' -PACKAGE_STRING='adplug 2.3.1' +PACKAGE_VERSION='2.3.3' +PACKAGE_STRING='adplug 2.3.3' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1335,7 +1335,7 @@ # 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 adplug 2.3.1 to adapt to many kinds of systems. +\`configure' configures adplug 2.3.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1405,7 +1405,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of adplug 2.3.1:";; + short | recursive ) echo "Configuration of adplug 2.3.3:";; esac cat <<\_ACEOF @@ -1531,7 +1531,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -adplug configure 2.3.1 +adplug configure 2.3.3 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2425,7 +2425,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by adplug $as_me 2.3.1, which was +It was created by adplug $as_me 2.3.3, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3401,7 +3401,7 @@ # Define the identity of the package. PACKAGE='adplug' - VERSION='2.3.1' + VERSION='2.3.3' cat >>confdefs.h <<_ACEOF @@ -3502,8 +3502,8 @@ -macro_version='2.4.6' -macro_revision='2.4.6' +macro_version='2.4.6.40-6ca5' +macro_revision='2.4.6.40' @@ -5367,11 +5367,6 @@ lt_cv_sys_max_cmd_len=8192; ;; - mint*) - # On MiNT this can take a long time and run out of memory. - lt_cv_sys_max_cmd_len=8192; - ;; - amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. @@ -6210,13 +6205,29 @@ fi : ${AR=ar} -: ${AR_FLAGS=cru} +# Use ARFLAGS variable as AR's operation code to sync the variable naming with +# Automake. If both AR_FLAGS and ARFLAGS are specified, AR_FLAGS should have +# higher priority because thats what people were doing historically (setting +# ARFLAGS for automake and AR_FLAGS for libtool). FIXME: Make the AR_FLAGS +# variable obsoleted/removed. + +test ${AR_FLAGS+y} || AR_FLAGS=${ARFLAGS-cr} +lt_ar_flags=$AR_FLAGS + + + + + + +# Make AR_FLAGS overridable by 'make ARFLAGS='. Don't try to run-time override +# by AR_FLAGS because that was never working and AR_FLAGS is about to die. + @@ -7141,10 +7152,10 @@ x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; - powerpcle-*linux*|powerpc64le-*linux*) + powerpcle-*linux*) LD="${LD-ld} -m elf64lppc" ;; - powerpc-*linux*|powerpc64-*linux*) + powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) @@ -7934,8 +7945,8 @@ _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 - echo "$AR cru libconftest.a conftest.o" >&5 - $AR cru libconftest.a conftest.o 2>&5 + echo "$AR $AR_FLAGS libconftest.a conftest.o" >&5 + $AR $AR_FLAGS libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF @@ -9698,6 +9709,7 @@ emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes + file_list_spec='@' ;; interix[3-9]*) @@ -9915,7 +9927,7 @@ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else - export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no @@ -10552,6 +10564,7 @@ emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes + file_list_spec='@' ;; osf3*) @@ -11330,11 +11343,11 @@ version_type=darwin need_lib_prefix=no need_version=no - library_names_spec='$libname$release$versuffix$shared_ext $libname$release$major$shared_ext $libname$shared_ext' + library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .bundle || echo .dylib`' + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' @@ -11360,14 +11373,7 @@ *) objformat=elf ;; esac fi - # Handle Gentoo/FreeBSD as it was Linux - case $host_vendor in - gentoo) - version_type=linux ;; - *) - version_type=freebsd-$objformat ;; - esac - + version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' @@ -11379,12 +11385,6 @@ library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; - linux) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - need_lib_prefix=no - need_version=no - ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in @@ -12508,30 +12508,41 @@ old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } -if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } +if test -z "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP"; then + if $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + old_striplib="$STRIP --strip-debug" + striplib="$STRIP --strip-unneeded" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + case $host_os in + darwin*) + # FIXME - insert some real tests, host_os isn't really good enough striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + ;; + freebsd*) + if $STRIP -V 2>&1 | $GREP "elftoolchain" >/dev/null; then + old_striplib="$STRIP --strip-debug" + striplib="$STRIP --strip-unneeded" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - fi - ;; - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + fi + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - ;; - esac + ;; + esac + fi fi @@ -15652,6 +15663,7 @@ emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds_CXX='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes_CXX=yes + file_list_spec_CXX='@' ;; dgux*) @@ -17087,7 +17099,7 @@ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else - export_symbols_cmds_CXX='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + export_symbols_cmds_CXX='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi ;; pw32*) @@ -17528,11 +17540,11 @@ version_type=darwin need_lib_prefix=no need_version=no - library_names_spec='$libname$release$versuffix$shared_ext $libname$release$major$shared_ext $libname$shared_ext' + library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .bundle || echo .dylib`' + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; @@ -17557,14 +17569,7 @@ *) objformat=elf ;; esac fi - # Handle Gentoo/FreeBSD as it was Linux - case $host_vendor in - gentoo) - version_type=linux ;; - *) - version_type=freebsd-$objformat ;; - esac - + version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' @@ -17576,12 +17581,6 @@ library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; - linux) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - need_lib_prefix=no - need_version=no - ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in @@ -19113,6 +19112,231 @@ $as_echo "$ax_cv_cxx_compiler_version" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 +$as_echo_n "checking whether byte ordering is bigendian... " >&6; } +if ${ac_cv_c_bigendian+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_bigendian=unknown + # See if we're dealing with a universal compiler. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __APPLE_CC__ + not a universal capable compiler + #endif + typedef int dummy; + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + + # Check for potential -arch flags. It is not universal unless + # there are at least two -arch flags with different values. + ac_arch= + ac_prev= + for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do + if test -n "$ac_prev"; then + case $ac_word in + i?86 | x86_64 | ppc | ppc64) + if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then + ac_arch=$ac_word + else + ac_cv_c_bigendian=universal + break + fi + ;; + esac + ac_prev= + elif test "x$ac_word" = "x-arch"; then + ac_prev=arch + fi + done +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test $ac_cv_c_bigendian = unknown; then + # See if sys/param.h defines the BYTE_ORDER macro. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ + && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ + && LITTLE_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + # It does; now see whether it defined to BIG_ENDIAN or not. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_c_bigendian=yes +else + ac_cv_c_bigendian=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + # It does; now see whether it defined to _BIG_ENDIAN or not. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef _BIG_ENDIAN + not big endian + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_c_bigendian=yes +else + ac_cv_c_bigendian=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # Compile a test program. + if test "$cross_compiling" = yes; then : + # Try to guess by grepping values from an object file. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +short int ascii_mm[] = + { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; + short int ascii_ii[] = + { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; + int use_ascii (int i) { + return ascii_mm[i] + ascii_ii[i]; + } + short int ebcdic_ii[] = + { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; + short int ebcdic_mm[] = + { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; + int use_ebcdic (int i) { + return ebcdic_mm[i] + ebcdic_ii[i]; + } + extern int foo; + +int +main () +{ +return use_ascii (foo) == use_ebcdic (foo); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then + ac_cv_c_bigendian=yes + fi + if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi + fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ + + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long int l; + char c[sizeof (long int)]; + } u; + u.l = 1; + return u.c[sizeof (long int) - 1] == 1; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + ac_cv_c_bigendian=no +else + ac_cv_c_bigendian=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 +$as_echo "$ac_cv_c_bigendian" >&6; } + case $ac_cv_c_bigendian in #( + yes) + $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h +;; #( + no) + ;; #( + universal) + +$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h + + ;; #( + *) + as_fn_error $? "unknown endianness + presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; + esac + + if test "x${enable_flags_setting}" = "xyes" && test "x${enable_debug}" = "xno"; then : ac_ext=c @@ -19509,8 +19733,8 @@ fi pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libbinio >= 1.4" >&5 -$as_echo_n "checking for libbinio >= 1.4... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libbinio" >&5 +$as_echo_n "checking for libbinio... " >&6; } if test -n "$libbinio_CFLAGS"; then pkg_cv_libbinio_CFLAGS="$libbinio_CFLAGS" @@ -19550,7 +19774,7 @@ if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -19577,7 +19801,7 @@ and libbinio_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} @@ -19933,6 +20157,7 @@ Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi + : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files @@ -20329,7 +20554,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by adplug $as_me 2.3.1, which was +This file was extended by adplug $as_me 2.3.3, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -20386,7 +20611,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -adplug config.status 2.3.1 +adplug config.status 2.3.3 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -20546,6 +20771,7 @@ DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' +lt_ar_flags='`$ECHO "$lt_ar_flags" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' @@ -20728,7 +20954,6 @@ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ -AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ @@ -21572,8 +21797,11 @@ # The archiver. AR=$lt_AR +# Flags to create an archive (by configure). +lt_ar_flags=$lt_ar_flags + # Flags to create an archive. -AR_FLAGS=$lt_AR_FLAGS +AR_FLAGS=\${ARFLAGS-"\$lt_ar_flags"} # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec diff -Nru adplug-2.3.1+dfsg/configure.ac adplug-2.3.3+dfsg/configure.ac --- adplug-2.3.1+dfsg/configure.ac 2018-04-22 09:09:23.000000000 +0000 +++ adplug-2.3.3+dfsg/configure.ac 2020-06-10 00:52:28.000000000 +0000 @@ -1,6 +1,6 @@ dnl Tell autoconf we're compiling a C++ library, using automake & libtool AC_PREREQ([2.69]) -AC_INIT([adplug], [2.3.1]) +AC_INIT([adplug], [2.3.3]) AC_CONFIG_MACRO_DIR([m4]) dnl Check whether we want to set defaults for CFLAGS, CXXFLAGS, CPPFLAGS and LDFLAGS @@ -35,6 +35,8 @@ AX_COMPILER_VENDOR AX_COMPILER_VERSION +AC_C_BIGENDIAN + AS_IF([test "x${enable_flags_setting}" = "xyes" && test "x${enable_debug}" = "xno"], [ AC_LANG([C]) AX_APPEND_COMPILE_FLAGS([-O2 -pipe], [CFLAGS]) diff -Nru adplug-2.3.1+dfsg/debian/changelog adplug-2.3.3+dfsg/debian/changelog --- adplug-2.3.1+dfsg/debian/changelog 2020-03-22 15:32:28.000000000 +0000 +++ adplug-2.3.3+dfsg/debian/changelog 2020-07-15 07:39:35.000000000 +0000 @@ -1,8 +1,31 @@ -adplug (2.3.1+dfsg-2build1) focal; urgency=medium +adplug (2.3.3+dfsg-2) unstable; urgency=medium - * No-change rebuild for libgcc-s1 package name change. + * Upload to unstable - -- Matthias Klose Sun, 22 Mar 2020 16:32:28 +0100 + -- Yangfl Wed, 15 Jul 2020 15:39:35 +0800 + +adplug (2.3.3+dfsg-1) experimental; urgency=medium + + * New upstream release + - Fix CVE-2019-14692 (Closes: #943927) + - Fix CVE-2019-14691 (Closes: #943928) + - Fix CVE-2019-14690 (Closes: #943929) + - Fix CVE-2019-15151 (Closes: #946340) + * Bump debhelper compat to 13 + + -- Yangfl Sat, 13 Jun 2020 11:40:08 +0800 + +adplug (2.3.2+dfsg-1) experimental; urgency=medium + + * New upstream release (Closes: #961480) + - Fix CVE-2019-14692 (Closes: #943927) + - Fix CVE-2019-14691 (Closes: #943928) + - Fix CVE-2019-14690 (Closes: #943929) + - Fix CVE-2019-15151 (Closes: #946340) + * Bump Standards-Version to 4.5.0 + * Add upstream metadata + + -- Yangfl Fri, 29 May 2020 23:11:55 +0800 adplug (2.3.1+dfsg-2) unstable; urgency=medium diff -Nru adplug-2.3.1+dfsg/debian/control adplug-2.3.3+dfsg/debian/control --- adplug-2.3.1+dfsg/debian/control 2019-10-14 09:50:54.000000000 +0000 +++ adplug-2.3.3+dfsg/debian/control 2020-06-14 15:08:45.000000000 +0000 @@ -2,21 +2,30 @@ Priority: optional Maintainer: Yangfl Build-Depends: - debhelper-compat (= 12), + debhelper-compat (= 13), libbinio-dev (>= 1.4+dfsg1-4.1), pkg-config, -Standards-Version: 4.4.1 +Rules-Requires-Root: no +Standards-Version: 4.5.0 Section: libs Homepage: https://adplug.github.io/ Vcs-Git: https://salsa.debian.org/yangfl-guest/adplug.git Vcs-Browser: https://salsa.debian.org/yangfl-guest/adplug -Package: libadplug-2.3.1-0 +Package: libadplug-2.3.3-0 Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Suggests: adplug-utils -Conflicts: libadplug-2.2.1-0, libadplug-2.2.1-0v5 -Replaces: libadplug-2.2.1-0, libadplug-2.2.1-0v5 +Conflicts: + libadplug-2.2.1-0, + libadplug-2.2.1-0v5, + libadplug-2.3.1-0, + libadplug-2.3.2-0, +Replaces: + libadplug-2.2.1-0, + libadplug-2.2.1-0v5, + libadplug-2.3.1-0, + libadplug-2.3.2-0, Description: free AdLib sound library AdPlug is a free, cross-platform, hardware independent AdLib sound player library, mainly written in C++ and released under the LGPL. AdPlug plays @@ -28,7 +37,7 @@ Package: libadplug-dev Section: libdevel Architecture: any -Depends: libadplug-2.3.1-0 (= ${binary:Version}), ${misc:Depends}, libbinio-dev +Depends: libadplug-2.3.3-0 (= ${binary:Version}), ${misc:Depends}, libbinio-dev Description: free AdLib sound library (development) AdPlug is a free, cross-platform, hardware independent AdLib sound player library, mainly written in C++ and released under the LGPL. AdPlug plays diff -Nru adplug-2.3.1+dfsg/debian/gbp.conf adplug-2.3.3+dfsg/debian/gbp.conf --- adplug-2.3.1+dfsg/debian/gbp.conf 1970-01-01 00:00:00.000000000 +0000 +++ adplug-2.3.3+dfsg/debian/gbp.conf 2020-05-30 23:00:12.000000000 +0000 @@ -0,0 +1,4 @@ +[DEFAULT] +upstream-branch = upstream +debian-branch = master +pristine-tar = True diff -Nru adplug-2.3.1+dfsg/debian/gitlab-ci.yml adplug-2.3.3+dfsg/debian/gitlab-ci.yml --- adplug-2.3.1+dfsg/debian/gitlab-ci.yml 1970-01-01 00:00:00.000000000 +0000 +++ adplug-2.3.3+dfsg/debian/gitlab-ci.yml 2020-05-30 23:00:12.000000000 +0000 @@ -0,0 +1,3 @@ +include: + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml diff -Nru adplug-2.3.1+dfsg/debian/libadplug-2.3.1-0.docs adplug-2.3.3+dfsg/debian/libadplug-2.3.1-0.docs --- adplug-2.3.1+dfsg/debian/libadplug-2.3.1-0.docs 2019-10-11 13:43:57.000000000 +0000 +++ adplug-2.3.3+dfsg/debian/libadplug-2.3.1-0.docs 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -AUTHORS -BUGS -NEWS -README -TODO diff -Nru adplug-2.3.1+dfsg/debian/libadplug-2.3.1-0.install adplug-2.3.3+dfsg/debian/libadplug-2.3.1-0.install --- adplug-2.3.1+dfsg/debian/libadplug-2.3.1-0.install 2019-10-11 13:43:57.000000000 +0000 +++ adplug-2.3.3+dfsg/debian/libadplug-2.3.1-0.install 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -usr/lib/*/libadplug-*.so.* diff -Nru adplug-2.3.1+dfsg/debian/libadplug-2.3.1-0.lintian-overrides adplug-2.3.3+dfsg/debian/libadplug-2.3.1-0.lintian-overrides --- adplug-2.3.1+dfsg/debian/libadplug-2.3.1-0.lintian-overrides 2019-10-11 13:43:57.000000000 +0000 +++ adplug-2.3.3+dfsg/debian/libadplug-2.3.1-0.lintian-overrides 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -# versioned so name -libadplug-2.3.1-0: dev-pkg-without-shlib-symlink usr/lib/*/libadplug-*.so.* diff -Nru adplug-2.3.1+dfsg/debian/libadplug-2.3.3-0.docs adplug-2.3.3+dfsg/debian/libadplug-2.3.3-0.docs --- adplug-2.3.1+dfsg/debian/libadplug-2.3.3-0.docs 1970-01-01 00:00:00.000000000 +0000 +++ adplug-2.3.3+dfsg/debian/libadplug-2.3.3-0.docs 2020-06-14 15:08:45.000000000 +0000 @@ -0,0 +1,5 @@ +AUTHORS +BUGS +NEWS +README +TODO diff -Nru adplug-2.3.1+dfsg/debian/libadplug-2.3.3-0.install adplug-2.3.3+dfsg/debian/libadplug-2.3.3-0.install --- adplug-2.3.1+dfsg/debian/libadplug-2.3.3-0.install 1970-01-01 00:00:00.000000000 +0000 +++ adplug-2.3.3+dfsg/debian/libadplug-2.3.3-0.install 2020-06-14 15:08:45.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/*/libadplug-*.so.* diff -Nru adplug-2.3.1+dfsg/debian/libadplug-2.3.3-0.lintian-overrides adplug-2.3.3+dfsg/debian/libadplug-2.3.3-0.lintian-overrides --- adplug-2.3.1+dfsg/debian/libadplug-2.3.3-0.lintian-overrides 1970-01-01 00:00:00.000000000 +0000 +++ adplug-2.3.3+dfsg/debian/libadplug-2.3.3-0.lintian-overrides 2020-06-14 15:08:45.000000000 +0000 @@ -0,0 +1,2 @@ +# versioned so name +libadplug-2.3.3-0: dev-pkg-without-shlib-symlink usr/lib/*/libadplug-*.so.* diff -Nru adplug-2.3.1+dfsg/debian/rules adplug-2.3.3+dfsg/debian/rules --- adplug-2.3.1+dfsg/debian/rules 2019-10-14 09:50:54.000000000 +0000 +++ adplug-2.3.3+dfsg/debian/rules 2020-05-30 23:00:12.000000000 +0000 @@ -5,7 +5,7 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all export DEB_CXXFLAGS_MAINT_APPEND = -Wall -pedantic -export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed +export DEB_LDFLAGS_MAINT_APPEND = %: diff -Nru adplug-2.3.1+dfsg/debian/upstream/metadata adplug-2.3.3+dfsg/debian/upstream/metadata --- adplug-2.3.1+dfsg/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ adplug-2.3.3+dfsg/debian/upstream/metadata 2020-06-14 15:08:45.000000000 +0000 @@ -0,0 +1,3 @@ +Bug-Submit: https://github.com/adplug/adplug/issues +Repository: https://github.com/adplug/adplug.git +Repository-Browse: https://github.com/adplug/adplug diff -Nru adplug-2.3.1+dfsg/debian/watch adplug-2.3.3+dfsg/debian/watch --- adplug-2.3.1+dfsg/debian/watch 2019-10-11 13:43:57.000000000 +0000 +++ adplug-2.3.3+dfsg/debian/watch 2020-05-30 23:00:12.000000000 +0000 @@ -1,4 +1,4 @@ version=4 -opts="dversionmangle=s/\+(debian|dfsg|ds|deb)(\.\d+)?$//,repacksuffix=+dfsg,filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.bz2%adplug-$1.tar.bz2%,pgpsigurlmangle=s%$%.asc%" \ +opts="dversionmangle=s/\+(debian|dfsg|ds|deb)(\.\d+)?$//,repacksuffix=+dfsg,filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.bz2%adplug-$1.tar.bz2%" \ https://github.com/adplug/adplug/releases \ (?:.*?/)?adplug-(\d[\d.]*)\.tar\.bz2 debian uupdate diff -Nru adplug-2.3.1+dfsg/depcomp adplug-2.3.3+dfsg/depcomp --- adplug-2.3.1+dfsg/depcomp 2018-04-22 09:12:29.000000000 +0000 +++ adplug-2.3.3+dfsg/depcomp 2015-07-25 00:29:35.000000000 +0000 @@ -1,9 +1,9 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2018-03-07.03; # UTC +scriptversion=2013-05-30.07; # UTC -# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Copyright (C) 1999-2014 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ # GNU General Public License for more details. # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -783,9 +783,9 @@ # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'before-save-hook 'time-stamp) +# eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" +# time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: diff -Nru adplug-2.3.1+dfsg/doc/adplugdb.1 adplug-2.3.3+dfsg/doc/adplugdb.1 --- adplug-2.3.1+dfsg/doc/adplugdb.1 2018-04-22 09:13:11.000000000 +0000 +++ adplug-2.3.3+dfsg/doc/adplugdb.1 2018-09-30 10:06:06.000000000 +0000 @@ -13,7 +13,7 @@ .\" License along with this library; if not, write to the Free Software .\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA .\" -.TH ADPLUGDB 1 "March 4, 2006" "AdPlug database maintenance utility 2.3.1" "User Commands" +.TH ADPLUGDB 1 "March 4, 2006" "AdPlug database maintenance utility 2.3" "User Commands" .SH NAME adplugdb \- AdPlug database maintenance utility .SH SYNOPSIS diff -Nru adplug-2.3.1+dfsg/doc/stamp-vti adplug-2.3.3+dfsg/doc/stamp-vti --- adplug-2.3.1+dfsg/doc/stamp-vti 2018-04-22 09:13:11.000000000 +0000 +++ adplug-2.3.3+dfsg/doc/stamp-vti 2020-06-10 00:53:33.000000000 +0000 @@ -1,4 +1,4 @@ -@set UPDATED 22 January 2018 -@set UPDATED-MONTH January 2018 -@set EDITION 2.3.1 -@set VERSION 2.3.1 +@set UPDATED 19 November 2017 +@set UPDATED-MONTH November 2017 +@set EDITION 2.3.3 +@set VERSION 2.3.3 diff -Nru adplug-2.3.1+dfsg/doc/version.texi adplug-2.3.3+dfsg/doc/version.texi --- adplug-2.3.1+dfsg/doc/version.texi 2018-04-22 09:13:11.000000000 +0000 +++ adplug-2.3.3+dfsg/doc/version.texi 2020-06-10 00:53:33.000000000 +0000 @@ -1,4 +1,4 @@ -@set UPDATED 22 January 2018 -@set UPDATED-MONTH January 2018 -@set EDITION 2.3.1 -@set VERSION 2.3.1 +@set UPDATED 19 November 2017 +@set UPDATED-MONTH November 2017 +@set EDITION 2.3.3 +@set VERSION 2.3.3 diff -Nru adplug-2.3.1+dfsg/INSTALL adplug-2.3.3+dfsg/INSTALL --- adplug-2.3.1+dfsg/INSTALL 1970-01-01 00:00:00.000000000 +0000 +++ adplug-2.3.3+dfsg/INSTALL 2015-07-25 00:29:35.000000000 +0000 @@ -0,0 +1,370 @@ +Installation Instructions +************************* + +Copyright (C) 1994-1996, 1999-2002, 2004-2013 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 command `./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. + + HP-UX `make' updates targets which have the same time stamps as +their prerequisites, which makes it generally unusable when shipped +generated files such as `configure' are involved. Use GNU `make' +instead. + + 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 limitation. Until the limitation is lifted, you can use +this workaround: + + CONFIG_SHELL=/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 -Nru adplug-2.3.1+dfsg/install-sh adplug-2.3.3+dfsg/install-sh --- adplug-2.3.1+dfsg/install-sh 2018-04-22 09:12:29.000000000 +0000 +++ adplug-2.3.3+dfsg/install-sh 2015-07-25 00:29:35.000000000 +0000 @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2018-03-11.20; # UTC +scriptversion=2013-12-25.23; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -271,18 +271,15 @@ fi dst=$dst_arg - # If destination is a directory, append the input filename. + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. if test -d "$dst"; then if test "$is_target_a_directory" = never; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst - dstbase=`basename "$src"` - case $dst in - */) dst=$dst$dstbase;; - *) dst=$dst/$dstbase;; - esac + dst=$dstdir/`basename "$src"` dstdir_status=0 else dstdir=`dirname "$dst"` @@ -291,11 +288,6 @@ fi fi - case $dstdir in - */) dstdirslash=$dstdir;; - *) dstdirslash=$dstdir/;; - esac - obsolete_mkdir_used=false if test $dstdir_status != 0; then @@ -332,43 +324,34 @@ # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) - # Note that $RANDOM variable is not portable (e.g. dash); Use it - # here however when possible just to lower collision chance. tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 - - # Because "mkdir -p" follows existing symlinks and we likely work - # directly in world-writeable /tmp, make sure that the '$tmpdir' - # directory is successfully created first before we actually test - # 'mkdir -p' feature. if (umask $mkdir_umask && - $mkdirprog $mkdir_mode "$tmpdir" && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - test_tmpdir="$tmpdir/a" - ls_ld_tmpdir=`ls -ld "$test_tmpdir"` + ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && - $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi - rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" + rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; @@ -444,8 +427,8 @@ else # Make a couple of temp file names in the proper directory. - dsttmp=${dstdirslash}_inst.$$_ - rmtmp=${dstdirslash}_rm.$$_ + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 @@ -510,9 +493,9 @@ done # Local variables: -# eval: (add-hook 'before-save-hook 'time-stamp) +# eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" +# time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: diff -Nru adplug-2.3.1+dfsg/ltmain.sh adplug-2.3.3+dfsg/ltmain.sh --- adplug-2.3.1+dfsg/ltmain.sh 2018-04-22 09:12:19.000000000 +0000 +++ adplug-2.3.3+dfsg/ltmain.sh 2017-11-08 04:33:12.000000000 +0000 @@ -1,12 +1,12 @@ #! /bin/sh ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in -## by inline-source v2014-01-03.01 +## by inline-source v2016-02-21.11 -# libtool (GNU libtool) 2.4.6 +# libtool (GNU libtool) 2.4.6.40-6ca5 # Provide generalized library-building support services. # Written by Gordon Matzigkeit , 1996 -# Copyright (C) 1996-2015 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @@ -31,8 +31,8 @@ PROGRAM=libtool PACKAGE=libtool -VERSION=2.4.6 -package_revision=2.4.6 +VERSION=2.4.6.40-6ca5 +package_revision=2.4.6.40 ## ------ ## @@ -64,34 +64,25 @@ # libraries, which are installed to $pkgauxdir. # Set a version string for this script. -scriptversion=2015-10-04.22; # UTC +scriptversion=2017-04-19.12; # UTC # General shell script boiler plate, and helper functions. # Written by Gary V. Vaughan, 2004 -# Copyright (C) 2004-2015 Free Software Foundation, Inc. -# This is free software; see the source for copying conditions. There is NO -# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -# 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 3 of the License, or -# (at your option) any later version. - -# As a special exception to the GNU General Public License, if you distribute -# this file as part of a program or library that is built using GNU Libtool, -# you may include this file under the same distribution terms that you use -# for the rest of that program. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNES 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, see . +# This is free software. There is NO warranty; not even for +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# Copyright (C) 2004-2017 Bootstrap Authors +# +# This file is dual licensed under the terms of the MIT license +# , and GPL version 3 or later +# . You must apply one of +# these licenses when using or redistributing this software or any of +# the files within it. See the URLs above, or the file `LICENSE` +# included in the Bootstrap distribution for the full license texts. -# Please report bugs or propose patches to gary@gnu.org. +# Please report bugs or propose patches to: +# ## ------ ## @@ -140,9 +131,6 @@ fi" done -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - # Make sure IFS has a sensible default sp=' ' nl=' @@ -159,6 +147,26 @@ fi +# func_unset VAR +# -------------- +# Portably unset VAR. +# In some shells, an 'unset VAR' statement leaves a non-zero return +# status if VAR is already unset, which might be problematic if the +# statement is used at the end of a function (thus poisoning its return +# value) or when 'set -e' is active (causing even a spurious abort of +# the script in this case). +func_unset () +{ + { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } +} + + +# Make sure CDPATH doesn't cause `cd` commands to output the target dir. +func_unset CDPATH + +# Make sure ${,E,F}GREP behave sanely. +func_unset GREP_OPTIONS + ## ------------------------- ## ## Locate command utilities. ## @@ -259,7 +267,7 @@ rm -f conftest.in conftest.tmp conftest.nl conftest.out } - func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin + func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" rm -f conftest.sed SED=$func_path_progs_result } @@ -295,7 +303,7 @@ rm -f conftest.in conftest.tmp conftest.nl conftest.out } - func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin + func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" GREP=$func_path_progs_result } @@ -580,16 +588,16 @@ { $debug_cmd - func_quote_for_eval "$2" - eval "$1+=\\ \$func_quote_for_eval_result" + func_quote_arg pretty "$2" + eval "$1+=\\ \$func_quote_arg_result" }' else func_append_quoted () { $debug_cmd - func_quote_for_eval "$2" - eval "$1=\$$1\\ \$func_quote_for_eval_result" + func_quote_arg pretty "$2" + eval "$1=\$$1\\ \$func_quote_arg_result" } fi @@ -1091,132 +1099,199 @@ } -# func_quote ARG -# -------------- -# Aesthetically quote one ARG, store the result into $func_quote_result. Note -# that we keep attention to performance here (so far O(N) complexity as long as -# func_append is O(1)). -func_quote () +# func_quote_portable EVAL ARG +# ---------------------------- +# Internal function to portably implement func_quote_arg. Note that we still +# keep attention to performance here so we as much as possible try to avoid +# calling sed binary (so far O(N) complexity as long as func_append is O(1)). +func_quote_portable () { $debug_cmd - func_quote_result=$1 + func_quote_portable_result=$2 - case $func_quote_result in - *[\\\`\"\$]*) - case $func_quote_result in - *[\[\*\?]*) - func_quote_result=`$ECHO "$func_quote_result" | $SED "$sed_quote_subst"` - return 0 - ;; - esac + # one-time-loop (easy break) + while true + do + if $1; then + func_quote_portable_result=`$ECHO "$2" | $SED \ + -e "$sed_double_quote_subst" -e "$sed_double_backslash"` + break + fi - func_quote_old_IFS=$IFS - for _G_char in '\' '`' '"' '$' - do - # STATE($1) PREV($2) SEPARATOR($3) - set start "" "" - func_quote_result=dummy"$_G_char$func_quote_result$_G_char"dummy - IFS=$_G_char - for _G_part in $func_quote_result - do - case $1 in - quote) - func_append func_quote_result "$3$2" - set quote "$_G_part" "\\$_G_char" - ;; - start) - set first "" "" - func_quote_result= + # Quote for eval. + case $func_quote_portable_result in + *[\\\`\"\$]*) + case $func_quote_portable_result in + *[\[\*\?]*) + func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ + | $SED "$sed_quote_subst"` + break ;; - first) - set quote "$_G_part" "" - ;; - esac + esac + + func_quote_portable_old_IFS=$IFS + for _G_char in '\' '`' '"' '$' + do + # STATE($1) PREV($2) SEPARATOR($3) + set start "" "" + func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy + IFS=$_G_char + for _G_part in $func_quote_portable_result + do + case $1 in + quote) + func_append func_quote_portable_result "$3$2" + set quote "$_G_part" "\\$_G_char" + ;; + start) + set first "" "" + func_quote_portable_result= + ;; + first) + set quote "$_G_part" "" + ;; + esac + done done - IFS=$func_quote_old_IFS - done + IFS=$func_quote_portable_old_IFS + ;; + *) ;; + esac + break + done + + func_quote_portable_unquoted_result=$func_quote_portable_result + case $func_quote_portable_result in + # double-quote args containing shell metacharacters to delay + # word splitting, command substitution and variable expansion + # for a subsequent eval. + # many bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + func_quote_portable_result=\"$func_quote_portable_result\" ;; - *) ;; esac } -# func_quote_for_eval ARG... -# -------------------------- -# Aesthetically quote ARGs to be evaled later. -# This function returns two values: -# i) func_quote_for_eval_result -# double-quoted, suitable for a subsequent eval -# ii) func_quote_for_eval_unquoted_result -# has all characters that are still active within double -# quotes backslashified. -func_quote_for_eval () -{ - $debug_cmd - - func_quote_for_eval_unquoted_result= - func_quote_for_eval_result= - while test 0 -lt $#; do - func_quote "$1" - _G_unquoted_arg=$func_quote_result - if test -n "$func_quote_for_eval_unquoted_result"; then - func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" - else - func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" - fi - - case $_G_unquoted_arg in - # Double-quote args containing shell metacharacters to delay - # word splitting, command substitution and variable expansion - # for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - _G_quoted_arg=\"$_G_unquoted_arg\" +# func_quotefast_eval ARG +# ----------------------- +# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', +# but optimized for speed. Result is stored in $func_quotefast_eval. +if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then + printf -v _GL_test_printf_tilde %q '~' + if test '\~' = "$_GL_test_printf_tilde"; then + func_quotefast_eval () + { + printf -v func_quotefast_eval_result %q "$1" + } + else + # Broken older Bash implementations. Make those faster too if possible. + func_quotefast_eval () + { + case $1 in + '~'*) + func_quote_portable false "$1" + func_quotefast_eval_result=$func_quote_portable_result ;; *) - _G_quoted_arg=$_G_unquoted_arg - ;; + printf -v func_quotefast_eval_result %q "$1" + ;; esac + } + fi +else + func_quotefast_eval () + { + func_quote_portable false "$1" + func_quotefast_eval_result=$func_quote_portable_result + } +fi - if test -n "$func_quote_for_eval_result"; then - func_append func_quote_for_eval_result " $_G_quoted_arg" - else - func_append func_quote_for_eval_result "$_G_quoted_arg" - fi - shift - done -} - - -# func_quote_for_expand ARG -# ------------------------- -# Aesthetically quote ARG to be evaled later; same as above, -# but do not quote variable references. -func_quote_for_expand () -{ - $debug_cmd - case $1 in - *[\\\`\"]*) - _G_arg=`$ECHO "$1" | $SED \ - -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; - *) - _G_arg=$1 ;; +# func_quote_arg MODEs ARG +# ------------------------ +# Quote one ARG to be evaled later. MODEs argument may contain zero or more +# specifiers listed below separated by ',' character. This function returns two +# values: +# i) func_quote_arg_result +# double-quoted (when needed), suitable for a subsequent eval +# ii) func_quote_arg_unquoted_result +# has all characters that are still active within double +# quotes backslashified. Available only if 'unquoted' is specified. +# +# Available modes: +# ---------------- +# 'eval' (default) +# - escape shell special characters +# 'expand' +# - the same as 'eval'; but do not quote variable references +# 'pretty' +# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might +# be used later in func_quote to get output like: 'echo "a b"' instead +# of 'echo a\ b'. This is slower than default on some shells. +# 'unquoted' +# - produce also $func_quote_arg_unquoted_result which does not contain +# wrapping double-quotes. +# +# Examples for 'func_quote_arg pretty,unquoted string': +# +# string | *_result | *_unquoted_result +# ------------+-----------------------+------------------- +# " | \" | \" +# a b | "a b" | a b +# "a b" | "\"a b\"" | \"a b\" +# * | "*" | * +# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" +# +# Examples for 'func_quote_arg pretty,unquoted,expand string': +# +# string | *_result | *_unquoted_result +# --------------+---------------------+-------------------- +# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" +func_quote_arg () +{ + _G_quote_expand=false + case ,$1, in + *,expand,*) + _G_quote_expand=: + ;; esac - case $_G_arg in - # Double-quote args containing shell metacharacters to delay - # word splitting and command substitution for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - _G_arg=\"$_G_arg\" + case ,$1, in + *,pretty,*|*,expand,*|*,unquoted,*) + func_quote_portable $_G_quote_expand "$2" + func_quote_arg_result=$func_quote_portable_result + func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result + ;; + *) + # Faster quote-for-eval for some shells. + func_quotefast_eval "$2" + func_quote_arg_result=$func_quotefast_eval_result ;; esac +} - func_quote_for_expand_result=$_G_arg + +# func_quote MODEs ARGs... +# ------------------------ +# Quote all ARGs to be evaled later and join them into single command. See +# func_quote_arg's description for more info. +func_quote () +{ + $debug_cmd + _G_func_quote_mode=$1 ; shift + func_quote_result= + while test 0 -lt $#; do + func_quote_arg "$_G_func_quote_mode" "$1" + if test -n "$func_quote_result"; then + func_append func_quote_result " $func_quote_arg_result" + else + func_append func_quote_result "$func_quote_arg_result" + fi + shift + done } @@ -1262,8 +1337,8 @@ _G_cmd=$1 _G_fail_exp=${2-':'} - func_quote_for_expand "$_G_cmd" - eval "func_notquiet $func_quote_for_expand_result" + func_quote_arg pretty,expand "$_G_cmd" + eval "func_notquiet $func_quote_arg_result" $opt_dry_run || { eval "$_G_cmd" @@ -1288,8 +1363,8 @@ _G_fail_exp=${2-':'} $opt_quiet || { - func_quote_for_expand "$_G_cmd" - eval "func_echo $func_quote_for_expand_result" + func_quote_arg expand,pretty "$_G_cmd" + eval "func_echo $func_quote_arg_result" } $opt_dry_run || { @@ -1416,30 +1491,26 @@ # End: #! /bin/sh -# Set a version string for this script. -scriptversion=2014-01-07.03; # UTC - # A portable, pluggable option parser for Bourne shell. # Written by Gary V. Vaughan, 2010 -# Copyright (C) 2010-2015 Free Software Foundation, Inc. -# This is free software; see the source for copying conditions. There is NO -# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -# 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 3 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. +# This is free software. There is NO warranty; not even for +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# Copyright (C) 2010-2017 Bootstrap Authors +# +# This file is dual licensed under the terms of the MIT license +# , and GPL version 3 or later +# . You must apply one of +# these licenses when using or redistributing this software or any of +# the files within it. See the URLs above, or the file `LICENSE` +# included in the Bootstrap distribution for the full license texts. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# Please report bugs or propose patches to: +# -# Please report bugs or propose patches to gary@gnu.org. +# Set a version string for this script. +scriptversion=2016-03-06.01; # UTC ## ------ ## @@ -1462,7 +1533,7 @@ # # In order for the '--version' option to work, you will need to have a # suitably formatted comment like the one at the top of this file -# starting with '# Written by ' and ending with '# warranty; '. +# starting with '# Written by ' and ending with '# Copyright'. # # For '-h' and '--help' to work, you will also need a one line # description of your script's purpose in a comment directly above the @@ -1474,7 +1545,7 @@ # to display verbose messages only when your user has specified # '--verbose'. # -# After sourcing this file, you can plug processing for additional +# After sourcing this file, you can plug in processing for additional # options by amending the variables from the 'Configuration' section # below, and following the instructions in the 'Option parsing' # section further down. @@ -1523,8 +1594,8 @@ ## ------------------------- ## # This section contains functions for adding, removing, and running hooks -# to the main code. A hook is just a named list of of function, that can -# be run in order later on. +# in the main code. A hook is just a list of function names that can be +# run in order later on. # func_hookable FUNC_NAME # ----------------------- @@ -1557,7 +1628,8 @@ # func_remove_hook FUNC_NAME HOOK_FUNC # ------------------------------------ -# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. +# Remove HOOK_FUNC from the list of hook functions to be called by +# FUNC_NAME. func_remove_hook () { $debug_cmd @@ -1566,10 +1638,28 @@ } +# func_propagate_result FUNC_NAME_A FUNC_NAME_B +# --------------------------------------------- +# If the *_result variable of FUNC_NAME_A _is set_, assign its value to +# *_result variable of FUNC_NAME_B. +func_propagate_result () +{ + $debug_cmd + + func_propagate_result_result=: + if eval "test \"\${${1}_result+set}\" = set" + then + eval "${2}_result=\$${1}_result" + else + func_propagate_result_result=false + fi +} + + # func_run_hooks FUNC_NAME [ARG]... # --------------------------------- # Run all hook functions registered to FUNC_NAME. -# It is assumed that the list of hook functions contains nothing more +# It's assumed that the list of hook functions contains nothing more # than a whitespace-delimited list of legal shell function names, and # no effort is wasted trying to catch shell meta-characters or preserve # whitespace. @@ -1579,22 +1669,19 @@ case " $hookable_fns " in *" $1 "*) ;; - *) func_fatal_error "'$1' does not support hook funcions.n" ;; + *) func_fatal_error "'$1' does not support hook functions." ;; esac eval _G_hook_fns=\$$1_hooks; shift for _G_hook in $_G_hook_fns; do - eval $_G_hook '"$@"' - - # store returned options list back into positional - # parameters for next 'cmd' execution. - eval _G_hook_result=\$${_G_hook}_result - eval set dummy "$_G_hook_result"; shift + func_unset "${_G_hook}_result" + eval $_G_hook '${1+"$@"}' + func_propagate_result $_G_hook func_run_hooks + if $func_propagate_result_result; then + eval set dummy "$func_run_hooks_result"; shift + fi done - - func_quote_for_eval ${1+"$@"} - func_run_hooks_result=$func_quote_for_eval_result } @@ -1604,10 +1691,18 @@ ## --------------- ## # In order to add your own option parsing hooks, you must accept the -# full positional parameter list in your hook function, remove any -# options that you action, and then pass back the remaining unprocessed -# options in '_result', escaped suitably for -# 'eval'. Like this: +# full positional parameter list from your hook function. You may remove +# or edit any options that you action, and then pass back the remaining +# unprocessed options in '_result', escaped +# suitably for 'eval'. +# +# The '_result' variable is automatically unset +# before your hook gets called; for best performance, only set the +# *_result variable when necessary (i.e. don't call the 'func_quote' +# function unnecessarily because it can be an expensive operation on some +# machines). +# +# Like this: # # my_options_prep () # { @@ -1617,9 +1712,8 @@ # usage_message=$usage_message' # -s, --silent don'\''t print informational messages # ' -# -# func_quote_for_eval ${1+"$@"} -# my_options_prep_result=$func_quote_for_eval_result +# # No change in '$@' (ignored completely by this hook). Leave +# # my_options_prep_result variable intact. # } # func_add_hook func_options_prep my_options_prep # @@ -1628,25 +1722,36 @@ # { # $debug_cmd # -# # Note that for efficiency, we parse as many options as we can +# args_changed=false +# +# # Note that, for efficiency, we parse as many options as we can # # recognise in a loop before passing the remainder back to the # # caller on the first unrecognised argument we encounter. # while test $# -gt 0; do # opt=$1; shift # case $opt in -# --silent|-s) opt_silent=: ;; +# --silent|-s) opt_silent=: +# args_changed=: +# ;; # # Separate non-argument short options: # -s*) func_split_short_opt "$_G_opt" # set dummy "$func_split_short_opt_name" \ # "-$func_split_short_opt_arg" ${1+"$@"} # shift +# args_changed=: # ;; -# *) set dummy "$_G_opt" "$*"; shift; break ;; +# *) # Make sure the first unrecognised option "$_G_opt" +# # is added back to "$@" in case we need it later, +# # if $args_changed was set to 'true'. +# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; # esac # done # -# func_quote_for_eval ${1+"$@"} -# my_silent_option_result=$func_quote_for_eval_result +# # Only call 'func_quote' here if we processed at least one argument. +# if $args_changed; then +# func_quote eval ${1+"$@"} +# my_silent_option_result=$func_quote_result +# fi # } # func_add_hook func_parse_options my_silent_option # @@ -1657,17 +1762,26 @@ # # $opt_silent && $opt_verbose && func_fatal_help "\ # '--silent' and '--verbose' options are mutually exclusive." -# -# func_quote_for_eval ${1+"$@"} -# my_option_validation_result=$func_quote_for_eval_result # } # func_add_hook func_validate_options my_option_validation # -# You'll alse need to manually amend $usage_message to reflect the extra +# You'll also need to manually amend $usage_message to reflect the extra # options you parse. It's preferable to append if you can, so that # multiple option parsing hooks can be added safely. +# func_options_finish [ARG]... +# ---------------------------- +# Finishing the option parse loop (call 'func_options' hooks ATM). +func_options_finish () +{ + $debug_cmd + + func_run_hooks func_options ${1+"$@"} + func_propagate_result func_run_hooks func_options_finish +} + + # func_options [ARG]... # --------------------- # All the functions called inside func_options are hookable. See the @@ -1677,17 +1791,27 @@ { $debug_cmd - func_options_prep ${1+"$@"} - eval func_parse_options \ - ${func_options_prep_result+"$func_options_prep_result"} - eval func_validate_options \ - ${func_parse_options_result+"$func_parse_options_result"} + _G_options_quoted=false - eval func_run_hooks func_options \ - ${func_validate_options_result+"$func_validate_options_result"} + for my_func in options_prep parse_options validate_options options_finish + do + func_unset func_${my_func}_result + func_unset func_run_hooks_result + eval func_$my_func '${1+"$@"}' + func_propagate_result func_$my_func func_options + if $func_propagate_result_result; then + eval set dummy "$func_options_result"; shift + _G_options_quoted=: + fi + done - # save modified positional parameters for caller - func_options_result=$func_run_hooks_result + $_G_options_quoted || { + # As we (func_options) are top-level options-parser function and + # nobody quoted "$@" for us yet, we need to do it explicitly for + # caller. + func_quote eval ${1+"$@"} + func_options_result=$func_quote_result + } } @@ -1696,9 +1820,8 @@ # All initialisations required before starting the option parse loop. # Note that when calling hook functions, we pass through the list of # positional parameters. If a hook function modifies that list, and -# needs to propogate that back to rest of this script, then the complete -# modified list must be put in 'func_run_hooks_result' before -# returning. +# needs to propagate that back to rest of this script, then the complete +# modified list must be put in 'func_run_hooks_result' before returning. func_hookable func_options_prep func_options_prep () { @@ -1709,9 +1832,7 @@ opt_warning_types= func_run_hooks func_options_prep ${1+"$@"} - - # save modified positional parameters for caller - func_options_prep_result=$func_run_hooks_result + func_propagate_result func_run_hooks func_options_prep } @@ -1723,25 +1844,32 @@ { $debug_cmd - func_parse_options_result= - + _G_parse_options_requote=false # this just eases exit handling while test $# -gt 0; do # Defer to hook functions for initial option parsing, so they # get priority in the event of reusing an option name. func_run_hooks func_parse_options ${1+"$@"} - - # Adjust func_parse_options positional parameters to match - eval set dummy "$func_run_hooks_result"; shift + func_propagate_result func_run_hooks func_parse_options + if $func_propagate_result_result; then + eval set dummy "$func_parse_options_result"; shift + # Even though we may have changed "$@", we passed the "$@" array + # down into the hook and it quoted it for us (because we are in + # this if-branch). No need to quote it again. + _G_parse_options_requote=false + fi # Break out of the loop if we already parsed every option. test $# -gt 0 || break + # We expect that one of the options parsed in this function matches + # and thus we remove _G_opt from "$@" and need to re-quote. + _G_match_parse_options=: _G_opt=$1 shift case $_G_opt in --debug|-x) debug_cmd='set -x' - func_echo "enabling shell trace mode" + func_echo "enabling shell trace mode" >&2 $debug_cmd ;; @@ -1751,7 +1879,10 @@ ;; --warnings|--warning|-W) - test $# = 0 && func_missing_arg $_G_opt && break + if test $# = 0 && func_missing_arg $_G_opt; then + _G_parse_options_requote=: + break + fi case " $warning_categories $1" in *" $1 "*) # trailing space prevents matching last $1 above @@ -1804,15 +1935,24 @@ shift ;; - --) break ;; + --) _G_parse_options_requote=: ; break ;; -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; - *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + *) set dummy "$_G_opt" ${1+"$@"}; shift + _G_match_parse_options=false + break + ;; esac + + if $_G_match_parse_options; then + _G_parse_options_requote=: + fi done - # save modified positional parameters for caller - func_quote_for_eval ${1+"$@"} - func_parse_options_result=$func_quote_for_eval_result + if $_G_parse_options_requote; then + # save modified positional parameters for caller + func_quote eval ${1+"$@"} + func_parse_options_result=$func_quote_result + fi } @@ -1829,12 +1969,10 @@ test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" func_run_hooks func_validate_options ${1+"$@"} + func_propagate_result func_run_hooks func_validate_options # Bail if the options were screwed! $exit_cmd $EXIT_FAILURE - - # save modified positional parameters for caller - func_validate_options_result=$func_run_hooks_result } @@ -1890,8 +2028,8 @@ # func_split_equals STRING # ------------------------ -# Set func_split_equals_lhs and func_split_equals_rhs shell variables after -# splitting STRING at the '=' sign. +# Set func_split_equals_lhs and func_split_equals_rhs shell variables +# after splitting STRING at the '=' sign. test -z "$_G_HAVE_XSI_OPS" \ && (eval 'x=a/b/c; test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ @@ -1906,8 +2044,9 @@ func_split_equals_lhs=${1%%=*} func_split_equals_rhs=${1#*=} - test "x$func_split_equals_lhs" = "x$1" \ - && func_split_equals_rhs= + if test "x$func_split_equals_lhs" = "x$1"; then + func_split_equals_rhs= + fi }' else # ...otherwise fall back to using expr, which is often a shell builtin. @@ -1985,31 +2124,44 @@ # func_version # ------------ # Echo version message to standard output and exit. +# The version message is extracted from the calling file's header +# comments, with leading '# ' stripped: +# 1. First display the progname and version +# 2. Followed by the header comment line matching /^# Written by / +# 3. Then a blank line followed by the first following line matching +# /^# Copyright / +# 4. Immediately followed by any lines between the previous matches, +# except lines preceding the intervening completely blank line. +# For example, see the header comments of this file. func_version () { $debug_cmd printf '%s\n' "$progname $scriptversion" $SED -n ' - /(C)/!b go - :more - /\./!{ - N - s|\n# | | - b more - } - :go - /^# Written by /,/# warranty; / { - s|^# || - s|^# *$|| - s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| - p + /^# Written by /!b + s|^# ||; p; n + + :fwd2blnk + /./ { + n + b fwd2blnk } - /^# Written by / { - s|^# || - p + p; n + + :holdwrnt + s|^# || + s|^# *$|| + /^Copyright /!{ + /./H + n + b holdwrnt } - /^warranty; /q' < "$progpath" + + s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| + G + s|\(\n\)\n*|\1|g + p; q' < "$progpath" exit $? } @@ -2024,7 +2176,7 @@ # End: # Set a version string. -scriptversion='(GNU libtool) 2.4.6' +scriptversion='(GNU libtool) 2.4.6.40-6ca5' # func_echo ARG... @@ -2115,12 +2267,12 @@ compiler: $LTCC compiler flags: $LTCFLAGS linker: $LD (gnu? $with_gnu_ld) - version: $progname (GNU libtool) 2.4.6 + version: $progname (GNU libtool) 2.4.6.40-6ca5 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` Report bugs to . -GNU libtool home page: . +GNU libtool home page: . General help using GNU software: ." exit 0 } @@ -2171,7 +2323,7 @@ # a configuration failure hint, and exit. func_fatal_configuration () { - func__fatal_error ${1+"$@"} \ + func_fatal_error ${1+"$@"} \ "See the $PACKAGE documentation for more information." \ "Fatal configuration error." } @@ -2317,6 +2469,8 @@ nonopt= preserve_args= + _G_rc_lt_options_prep=: + # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) @@ -2340,11 +2494,16 @@ uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; + *) + _G_rc_lt_options_prep=false + ;; esac - # Pass back the list of options. - func_quote_for_eval ${1+"$@"} - libtool_options_prep_result=$func_quote_for_eval_result + if $_G_rc_lt_options_prep; then + # Pass back the list of options. + func_quote eval ${1+"$@"} + libtool_options_prep_result=$func_quote_result + fi } func_add_hook func_options_prep libtool_options_prep @@ -2356,9 +2515,12 @@ { $debug_cmd + _G_rc_lt_parse_options=false + # Perform our own loop to consume as many options as possible in # each iteration. while test $# -gt 0; do + _G_match_lt_parse_options=: _G_opt=$1 shift case $_G_opt in @@ -2433,15 +2595,20 @@ func_append preserve_args " $_G_opt" ;; - # An option not handled by this hook function: - *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + # An option not handled by this hook function: + *) set dummy "$_G_opt" ${1+"$@"} ; shift + _G_match_lt_parse_options=false + break + ;; esac + $_G_match_lt_parse_options && _G_rc_lt_parse_options=: done - - # save modified positional parameters for caller - func_quote_for_eval ${1+"$@"} - libtool_parse_options_result=$func_quote_for_eval_result + if $_G_rc_lt_parse_options; then + # save modified positional parameters for caller + func_quote eval ${1+"$@"} + libtool_parse_options_result=$func_quote_result + fi } func_add_hook func_parse_options libtool_parse_options @@ -2498,8 +2665,8 @@ } # Pass back the unparsed argument list - func_quote_for_eval ${1+"$@"} - libtool_validate_options_result=$func_quote_for_eval_result + func_quote eval ${1+"$@"} + libtool_validate_options_result=$func_quote_result } func_add_hook func_validate_options libtool_validate_options @@ -3465,8 +3632,8 @@ esac done - func_quote_for_eval "$libobj" - test "X$libobj" != "X$func_quote_for_eval_result" \ + func_quote_arg pretty "$libobj" + test "X$libobj" != "X$func_quote_arg_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name '$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" @@ -3539,8 +3706,8 @@ func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result - func_quote_for_eval "$srcfile" - qsrcfile=$func_quote_for_eval_result + func_quote_arg pretty "$srcfile" + qsrcfile=$func_quote_arg_result # Only build a PIC object if we are building libtool libraries. if test yes = "$build_libtool_libs"; then @@ -4143,8 +4310,8 @@ case $nonopt in *shtool*) :;; *) false;; esac then # Aesthetically quote it. - func_quote_for_eval "$nonopt" - install_prog="$func_quote_for_eval_result " + func_quote_arg pretty "$nonopt" + install_prog="$func_quote_arg_result " arg=$1 shift else @@ -4154,8 +4321,8 @@ # The real first argument should be the name of the installation program. # Aesthetically quote it. - func_quote_for_eval "$arg" - func_append install_prog "$func_quote_for_eval_result" + func_quote_arg pretty "$arg" + func_append install_prog "$func_quote_arg_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; @@ -4212,12 +4379,12 @@ esac # Aesthetically quote the argument. - func_quote_for_eval "$arg" - func_append install_prog " $func_quote_for_eval_result" + func_quote_arg pretty "$arg" + func_append install_prog " $func_quote_arg_result" if test -n "$arg2"; then - func_quote_for_eval "$arg2" + func_quote_arg pretty "$arg2" fi - func_append install_shared_prog " $func_quote_for_eval_result" + func_append install_shared_prog " $func_quote_arg_result" done test -z "$install_prog" && \ @@ -4228,8 +4395,8 @@ if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else - func_quote_for_eval "$install_override_mode" - func_append install_shared_prog " -m $func_quote_for_eval_result" + func_quote_arg pretty "$install_override_mode" + func_append install_shared_prog " -m $func_quote_arg_result" fi fi @@ -4525,8 +4692,8 @@ relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_quiet || { - func_quote_for_expand "$relink_command" - eval "func_echo $func_quote_for_expand_result" + func_quote_arg expand,pretty "$relink_command" + eval "func_echo $func_quote_arg_result" } if eval "$relink_command"; then : else @@ -5305,8 +5472,8 @@ if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" - func_quote "$ECHO" - qECHO=$func_quote_result + func_quote_arg pretty "$ECHO" + qECHO=$func_quote_arg_result $ECHO "\ # A function that is used when there is no print builtin or printf. @@ -5316,7 +5483,7 @@ \$1 _LTECHO_EOF' } - ECHO=\"$qECHO\" + ECHO=$qECHO fi # Very basic option parsing. These options are (a) specific to @@ -6659,9 +6826,9 @@ while test "$#" -gt 0; do arg=$1 shift - func_quote_for_eval "$arg" - qarg=$func_quote_for_eval_unquoted_result - func_append libtool_args " $func_quote_for_eval_result" + func_quote_arg pretty,unquoted "$arg" + qarg=$func_quote_arg_unquoted_result + func_append libtool_args " $func_quote_arg_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then @@ -7127,16 +7294,6 @@ *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac - - # As we are forced to pass -nostdlib to g++ during linking, the option - # -pthread{,s} is not in effect; add the -lpthread to $deplist - # explicitly to link correctly. - if test "$tagname" = CXX -a x"$with_gcc" = xyes; then - case "$arg" in - -pthread*) func_append deplibs " -lpthread" ;; - esac - fi - continue ;; @@ -7269,9 +7426,9 @@ save_ifs=$IFS; IFS=, for flag in $args; do IFS=$save_ifs - func_quote_for_eval "$flag" - func_append arg " $func_quote_for_eval_result" - func_append compiler_flags " $func_quote_for_eval_result" + func_quote_arg pretty "$flag" + func_append arg " $func_quote_arg_result" + func_append compiler_flags " $func_quote_arg_result" done IFS=$save_ifs func_stripname ' ' '' "$arg" @@ -7285,10 +7442,10 @@ save_ifs=$IFS; IFS=, for flag in $args; do IFS=$save_ifs - func_quote_for_eval "$flag" - func_append arg " $wl$func_quote_for_eval_result" - func_append compiler_flags " $wl$func_quote_for_eval_result" - func_append linker_flags " $func_quote_for_eval_result" + func_quote_arg pretty "$flag" + func_append arg " $wl$func_quote_arg_result" + func_append compiler_flags " $wl$func_quote_arg_result" + func_append linker_flags " $func_quote_arg_result" done IFS=$save_ifs func_stripname ' ' '' "$arg" @@ -7312,8 +7469,8 @@ # -msg_* for osf cc -msg_*) - func_quote_for_eval "$arg" - arg=$func_quote_for_eval_result + func_quote_arg pretty "$arg" + arg=$func_quote_arg_result ;; # Flags to be passed through unchanged, with rationale: @@ -7338,8 +7495,8 @@ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ -specs=*|-fsanitize=*|-fuse-ld=*) - func_quote_for_eval "$arg" - arg=$func_quote_for_eval_result + func_quote_arg pretty "$arg" + arg=$func_quote_arg_result func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" @@ -7360,15 +7517,15 @@ continue else # Otherwise treat like 'Some other compiler flag' below - func_quote_for_eval "$arg" - arg=$func_quote_for_eval_result + func_quote_arg pretty "$arg" + arg=$func_quote_arg_result fi ;; # Some other compiler flag. -* | +*) - func_quote_for_eval "$arg" - arg=$func_quote_for_eval_result + func_quote_arg pretty "$arg" + arg=$func_quote_arg_result ;; *.$objext) @@ -7488,8 +7645,8 @@ *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. - func_quote_for_eval "$arg" - arg=$func_quote_for_eval_result + func_quote_arg pretty "$arg" + arg=$func_quote_arg_result ;; esac # arg @@ -9995,8 +10152,8 @@ for cmd in $concat_cmds; do IFS=$save_ifs $opt_quiet || { - func_quote_for_expand "$cmd" - eval "func_echo $func_quote_for_expand_result" + func_quote_arg expand,pretty "$cmd" + eval "func_echo $func_quote_arg_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? @@ -10089,8 +10246,8 @@ eval cmd=\"$cmd\" IFS=$save_ifs $opt_quiet || { - func_quote_for_expand "$cmd" - eval "func_echo $func_quote_for_expand_result" + func_quote_arg expand,pretty "$cmd" + eval "func_echo $func_quote_arg_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? @@ -10564,12 +10721,13 @@ elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else - func_quote_for_eval "$var_value" - relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + func_quote_arg pretty "$var_value" + relink_command="$var=$func_quote_arg_result; export $var; $relink_command" fi done - func_quote "(cd `pwd`; $relink_command)" - relink_command=$func_quote_result + func_quote eval cd "`pwd`" + func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" + relink_command=$func_quote_arg_unquoted_result fi # Only actually do things if not in dry run mode. @@ -10809,14 +10967,15 @@ elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else - func_quote_for_eval "$var_value" - relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + func_quote_arg pretty,unquoted "$var_value" + relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" fi done # Quote the link command for shipping. - relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" - func_quote "$relink_command" - relink_command=$func_quote_result + func_quote eval cd "`pwd`" + relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" + func_quote_arg pretty,unquoted "$relink_command" + relink_command=$func_quote_arg_unquoted_result if test yes = "$hardcode_automatic"; then relink_command= fi diff -Nru adplug-2.3.1+dfsg/m4/libtool.m4 adplug-2.3.3+dfsg/m4/libtool.m4 --- adplug-2.3.1+dfsg/m4/libtool.m4 2018-04-22 09:12:19.000000000 +0000 +++ adplug-2.3.3+dfsg/m4/libtool.m4 2017-11-21 23:32:04.000000000 +0000 @@ -1,6 +1,6 @@ # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # -# Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc. +# Copyright (C) 1996-2001, 2003-2017 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives @@ -1042,8 +1042,8 @@ _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD - echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD - $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD + echo "$AR $AR_FLAGS libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD + $AR $AR_FLAGS libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF @@ -1417,10 +1417,10 @@ x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; - powerpcle-*linux*|powerpc64le-*linux*) + powerpcle-*linux*) LD="${LD-ld} -m elf64lppc" ;; - powerpc-*linux*|powerpc64-*linux*) + powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) @@ -1493,9 +1493,22 @@ m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} -: ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) -_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) + +# Use ARFLAGS variable as AR's operation code to sync the variable naming with +# Automake. If both AR_FLAGS and ARFLAGS are specified, AR_FLAGS should have +# higher priority because thats what people were doing historically (setting +# ARFLAGS for automake and AR_FLAGS for libtool). FIXME: Make the AR_FLAGS +# variable obsoleted/removed. + +test ${AR_FLAGS+y} || AR_FLAGS=${ARFLAGS-cr} +lt_ar_flags=$AR_FLAGS +_LT_DECL([], [lt_ar_flags], [0], [Flags to create an archive (by configure)]) + +# Make AR_FLAGS overridable by 'make ARFLAGS='. Don't try to run-time override +# by AR_FLAGS because that was never working and AR_FLAGS is about to die. +_LT_DECL([], [AR_FLAGS], [\@S|@{ARFLAGS-"\@S|@lt_ar_flags"}], + [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no @@ -1708,11 +1721,6 @@ lt_cv_sys_max_cmd_len=8192; ;; - mint*) - # On MiNT this can take a long time and run out of memory. - lt_cv_sys_max_cmd_len=8192; - ;; - amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. @@ -2212,26 +2220,35 @@ striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) -if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - AC_MSG_RESULT([yes]) +if test -z "$STRIP"; then + AC_MSG_RESULT([no]) else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP"; then + if $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + old_striplib="$STRIP --strip-debug" + striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) + else + case $host_os in + darwin*) + # FIXME - insert some real tests, host_os isn't really good enough striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) - else + ;; + freebsd*) + if $STRIP -V 2>&1 | $GREP "elftoolchain" >/dev/null; then + old_striplib="$STRIP --strip-debug" + striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + ;; + *) AC_MSG_RESULT([no]) - fi - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac + ;; + esac + fi fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) @@ -2641,11 +2658,11 @@ version_type=darwin need_lib_prefix=no need_version=no - library_names_spec='$libname$release$versuffix$shared_ext $libname$release$major$shared_ext $libname$shared_ext' + library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .bundle || echo .dylib`' + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' @@ -2671,14 +2688,7 @@ *) objformat=elf ;; esac fi - # Handle Gentoo/FreeBSD as it was Linux - case $host_vendor in - gentoo) - version_type=linux ;; - *) - version_type=freebsd-$objformat ;; - esac - + version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' @@ -2690,12 +2700,6 @@ library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; - linux) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - need_lib_prefix=no - need_version=no - ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in @@ -4937,7 +4941,7 @@ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else - _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi ;; pw32*) @@ -5174,6 +5178,7 @@ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' ;; interix[[3-9]]*) @@ -5391,7 +5396,7 @@ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else - _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no @@ -5879,6 +5884,7 @@ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' ;; osf3*) @@ -6748,6 +6754,7 @@ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' ;; dgux*) diff -Nru adplug-2.3.1+dfsg/m4/lt~obsolete.m4 adplug-2.3.3+dfsg/m4/lt~obsolete.m4 --- adplug-2.3.1+dfsg/m4/lt~obsolete.m4 2018-04-22 09:12:19.000000000 +0000 +++ adplug-2.3.3+dfsg/m4/lt~obsolete.m4 2017-11-21 23:32:04.000000000 +0000 @@ -1,6 +1,6 @@ # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # -# Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software +# Copyright (C) 2004-2005, 2007, 2009, 2011-2017 Free Software # Foundation, Inc. # Written by Scott James Remnant, 2004. # diff -Nru adplug-2.3.1+dfsg/m4/ltoptions.m4 adplug-2.3.3+dfsg/m4/ltoptions.m4 --- adplug-2.3.1+dfsg/m4/ltoptions.m4 2018-04-22 09:12:19.000000000 +0000 +++ adplug-2.3.3+dfsg/m4/ltoptions.m4 2017-11-21 23:32:04.000000000 +0000 @@ -1,6 +1,6 @@ # Helper functions for option handling. -*- Autoconf -*- # -# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software +# Copyright (C) 2004-2005, 2007-2009, 2011-2017 Free Software # Foundation, Inc. # Written by Gary V. Vaughan, 2004 # diff -Nru adplug-2.3.1+dfsg/m4/ltsugar.m4 adplug-2.3.3+dfsg/m4/ltsugar.m4 --- adplug-2.3.1+dfsg/m4/ltsugar.m4 2018-04-22 09:12:19.000000000 +0000 +++ adplug-2.3.3+dfsg/m4/ltsugar.m4 2017-11-21 23:32:04.000000000 +0000 @@ -1,6 +1,6 @@ # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # -# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software +# Copyright (C) 2004-2005, 2007-2008, 2011-2017 Free Software # Foundation, Inc. # Written by Gary V. Vaughan, 2004 # diff -Nru adplug-2.3.1+dfsg/m4/ltversion.m4 adplug-2.3.3+dfsg/m4/ltversion.m4 --- adplug-2.3.1+dfsg/m4/ltversion.m4 2018-04-22 09:12:19.000000000 +0000 +++ adplug-2.3.3+dfsg/m4/ltversion.m4 2017-11-21 23:32:04.000000000 +0000 @@ -1,6 +1,6 @@ # ltversion.m4 -- version numbers -*- Autoconf -*- # -# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. +# Copyright (C) 2004, 2011-2017 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives @@ -9,15 +9,15 @@ # @configure_input@ -# serial 4179 ltversion.m4 +# serial 4219 ltversion.m4 # This file is part of GNU Libtool -m4_define([LT_PACKAGE_VERSION], [2.4.6]) -m4_define([LT_PACKAGE_REVISION], [2.4.6]) +m4_define([LT_PACKAGE_VERSION], [2.4.6.40-6ca5]) +m4_define([LT_PACKAGE_REVISION], [2.4.6.40]) AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.4.6' -macro_revision='2.4.6' +[macro_version='2.4.6.40-6ca5' +macro_revision='2.4.6.40' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) diff -Nru adplug-2.3.1+dfsg/Makefile.am adplug-2.3.3+dfsg/Makefile.am --- adplug-2.3.1+dfsg/Makefile.am 2018-04-22 09:08:52.000000000 +0000 +++ adplug-2.3.3+dfsg/Makefile.am 2020-05-12 00:58:03.000000000 +0000 @@ -61,7 +61,7 @@ src/players.cpp \ src/protrack.cpp \ src/psi.cpp \ - src/rad.cpp \ + src/rad2.cpp \ src/rat.cpp \ src/raw.cpp \ src/realopl.cpp \ @@ -110,7 +110,7 @@ src/mkj.h \ src/mtk.h \ src/protrack.h \ - src/rad.h \ + src/rad2.h \ src/raw.h \ src/s3m.h \ src/sa2.h \ @@ -160,7 +160,8 @@ src/cmfmcsop.h \ src/vgm.h \ src/sop.h \ - src/herad.h + src/herad.h \ + src/load_helper.h ############# # adplugdb/ # @@ -228,19 +229,23 @@ check_PROGRAMS = \ test/playertest \ test/emutest \ - test/crctest + test/crctest \ + test/stresstest test_playertest_SOURCES = test/playertest.cpp test_emutest_SOURCES = test/emutest.cpp test_crctest_SOURCES = test/crctest.cpp +test_stresstest_SOURCES = test/stresstest.cpp test_playertest_CPPFLAGS = $(libbinio_CFLAGS) test_emutest_CPPFLAGS = $(libbinio_CFLAGS) test_crctest_CPPFLAGS = $(libbinio_CFLAGS) +test_stresstest_CPPFLAGS = $(libbinio_CFLAGS) test_playertest_LDADD = src/libadplug.la $(libbinio_LIBS) test_emutest_LDADD = src/libadplug.la $(libbinio_LIBS) test_crctest_LDADD = src/libadplug.la $(libbinio_LIBS) +test_stresstest_LDADD = src/libadplug.la $(libbinio_LIBS) AM_TESTS_ENVIRONMENT = testdir='$(srcdir)/test'; export testdir; TESTS = $(check_PROGRAMS) @@ -388,3 +393,80 @@ test/WORMINTR.ref \ test/YsBattle.ref \ test/YsBattle.vgm +# Regression tests: +EXTRA_DIST += \ + test/i-85.bmf \ + test/i-86.dtm \ + test/i-87.mkj \ + test/i-88_1.a2m test/i-88_2.a2m \ + test/i-89_1.rad test/i-89_2.rad \ + test/i-90_1.mtk test/i-90_2.mtk \ + test/i-91.m \ + test/i-92_1.m test/i-92_2.m test/i-92_3.m test/i-92_4.m \ + test/i-93_01.bmf test/i-93_02.bmf test/i-93_03.xad test/i-93_04.bmf \ + test/i-93_05.xad test/i-93_06.xad test/i-93_07.bmf test/i-93_08.xad \ + test/i-93_09.xad test/i-93_10.xad test/i-93_11.xad test/i-93_12.xad \ + test/i-93_13.xad test/i-93_14.xad test/i-93_15.bmf test/i-93_16.xad \ + test/i-93_17.xad test/i-93_18.xad \ + test/i-94.rix \ + test/i-95_1.ctm test/i-95_2.ctm \ + test/i-96_1.rol test/i-96_2.rol test/i-96_3.rol \ + test/i-98.sng \ + test/i-99.dro \ + test/i-100_01.xad test/i-100_02.xad test/i-100_03.dro \ + test/i-100_04.dro test/i-100_05.raw test/i-100_06.raw \ + test/i-100_07.dro test/i-100_08.dro test/i-100_09.adlib \ + test/i-100_10.mkj test/i-100_11.mkj test/i-100_12.cmf \ + test/i-100_13.cmf \ + test/i-101_1.d00 test/i-101_2.d00 \ + test/i-102_001.dfm test/i-102_002.dfm test/i-102_003.dfm \ + test/i-102_004.dfm test/i-102_005.dfm test/i-102_006.dfm \ + test/i-102_007.dfm test/i-102_008.dfm test/i-102_009.dfm \ + test/i-102_010.dfm test/i-102_011.dfm test/i-102_012.dfm \ + test/i-102_013.dfm test/i-102_014.dfm test/i-102_015.dfm \ + test/i-102_016.dfm test/i-102_017.dfm test/i-102_018.dfm \ + test/i-102_019.dfm test/i-102_020.dfm test/i-102_021.dfm \ + test/i-102_022.dfm test/i-102_023.dfm test/i-102_024.dfm \ + test/i-102_025.dfm test/i-102_026.dfm test/i-102_027.dfm \ + test/i-102_028.dfm test/i-102_029.dfm test/i-102_030.dfm \ + test/i-102_031.dfm test/i-102_032.dfm test/i-102_033.dfm \ + test/i-102_034.dfm test/i-102_035.dfm test/i-102_036.dfm \ + test/i-102_037.dfm test/i-102_038.dfm test/i-102_039.dfm \ + test/i-102_040.dfm test/i-102_041.dfm test/i-102_042.dfm \ + test/i-102_043.dfm test/i-102_044.dfm test/i-102_045.dfm \ + test/i-102_046.dfm test/i-102_047.dfm test/i-102_048.dfm \ + test/i-102_049.dfm test/i-102_050.dfm test/i-102_051.dfm \ + test/i-102_052.dfm test/i-102_053.dfm test/i-102_054.dfm \ + test/i-102_055.dfm test/i-102_056.dfm test/i-102_057.dfm \ + test/i-102_058.dfm test/i-102_059.dfm test/i-102_060.dfm \ + test/i-102_061.dfm test/i-102_062.dfm test/i-102_063.dfm \ + test/i-102_064.dfm test/i-102_065.dfm test/i-102_066.dfm \ + test/i-102_067.dfm test/i-102_068.dfm test/i-102_069.dfm \ + test/i-102_070.dfm test/i-102_071.dfm test/i-102_072.dfm \ + test/i-102_073.dfm test/i-102_074.dfm test/i-102_075.dfm \ + test/i-102_076.dfm test/i-102_077.dfm test/i-102_078.dfm \ + test/i-102_079.dfm test/i-102_080.dfm test/i-102_081.dfm \ + test/i-102_082.dfm test/i-102_083.dfm test/i-102_084.dfm \ + test/i-102_085.dfm test/i-102_086.dfm test/i-102_087.dfm \ + test/i-102_088.dfm test/i-102_089.dfm test/i-102_090.dfm \ + test/i-102_091.dfm test/i-102_092.dfm test/i-102_093.dfm \ + test/i-102_094.dfm test/i-102_095.dfm test/i-102_096.dfm \ + test/i-102_097.dfm test/i-102_098.dfm test/i-102_099.dfm \ + test/i-102_100.dfm test/i-102_101.dfm test/i-102_102.dfm \ + test/i-102_103.dfm test/i-102_104.dfm test/i-102_105.dfm \ + test/i-102_106.dfm test/i-102_107.dfm test/i-102_108.dfm \ + test/i-102_109.dfm test/i-102_110.dfm test/i-102_111.dfm \ + test/i-102_112.dfm test/i-102_113.dfm test/i-102_114.dfm \ + test/i-102_115.dfm test/i-102_116.dfm test/i-102_117.dfm \ + test/i-102_118.dfm test/i-102_119.dfm test/i-102_120.dfm \ + test/i-102_121.dfm test/i-102_122.dfm test/i-102_123.dfm \ + test/i-102_124.dfm test/i-102_125.dfm test/i-102_126.dfm \ + test/i-102_127.dfm test/i-102_128.dfm test/i-102_129.dfm \ + test/i-102_130.dfm test/i-102_131.dfm test/i-102_132.dfm \ + test/i-102_133.dfm test/i-102_134.dfm test/i-102_135.dfm \ + test/i-102_136.dfm test/i-102_137.dfm test/i-102_138.dfm \ + test/i-102_139.dfm test/i-102_140.dfm test/i-102_141.dfm \ + test/i-102_142.dfm test/i-102_143.dfm test/i-102_144.dfm \ + test/i-102_145.dfm test/i-102_146.dfm test/i-102_147.dfm \ + test/i-102_148.dfm test/i-102_149.dfm test/i-102_150.dfm \ + test/i-102_151.dfm diff -Nru adplug-2.3.1+dfsg/Makefile.in adplug-2.3.3+dfsg/Makefile.in --- adplug-2.3.1+dfsg/Makefile.in 2018-04-22 09:12:30.000000000 +0000 +++ adplug-2.3.3+dfsg/Makefile.in 2020-06-10 00:53:20.000000000 +0000 @@ -93,7 +93,7 @@ host_triplet = @host@ bin_PROGRAMS = adplugdb/adplugdb$(EXEEXT) check_PROGRAMS = test/playertest$(EXEEXT) test/emutest$(EXEEXT) \ - test/crctest$(EXEEXT) + test/crctest$(EXEEXT) test/stresstest$(EXEEXT) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_append_compile_flags.m4 \ @@ -180,7 +180,7 @@ src/libadplug_la-mtk.lo src/libadplug_la-mus.lo \ src/libadplug_la-nemuopl.lo src/libadplug_la-player.lo \ src/libadplug_la-players.lo src/libadplug_la-protrack.lo \ - src/libadplug_la-psi.lo src/libadplug_la-rad.lo \ + src/libadplug_la-psi.lo src/libadplug_la-rad2.lo \ src/libadplug_la-rat.lo src/libadplug_la-raw.lo \ src/libadplug_la-realopl.lo src/libadplug_la-rix.lo \ src/libadplug_la-rol.lo src/libadplug_la-s3m.lo \ @@ -209,6 +209,9 @@ am_test_playertest_OBJECTS = test/playertest-playertest.$(OBJEXT) test_playertest_OBJECTS = $(am_test_playertest_OBJECTS) test_playertest_DEPENDENCIES = src/libadplug.la $(am__DEPENDENCIES_1) +am_test_stresstest_OBJECTS = test/stresstest-stresstest.$(OBJEXT) +test_stresstest_OBJECTS = $(am_test_stresstest_OBJECTS) +test_stresstest_DEPENDENCIES = src/libadplug.la $(am__DEPENDENCIES_1) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -276,7 +279,7 @@ src/$(DEPDIR)/libadplug_la-players.Plo \ src/$(DEPDIR)/libadplug_la-protrack.Plo \ src/$(DEPDIR)/libadplug_la-psi.Plo \ - src/$(DEPDIR)/libadplug_la-rad.Plo \ + src/$(DEPDIR)/libadplug_la-rad2.Plo \ src/$(DEPDIR)/libadplug_la-rat.Plo \ src/$(DEPDIR)/libadplug_la-raw.Plo \ src/$(DEPDIR)/libadplug_la-realopl.Plo \ @@ -295,7 +298,8 @@ src/$(DEPDIR)/libadplug_la-xsm.Plo \ test/$(DEPDIR)/crctest-crctest.Po \ test/$(DEPDIR)/emutest-emutest.Po \ - test/$(DEPDIR)/playertest-playertest.Po + test/$(DEPDIR)/playertest-playertest.Po \ + test/$(DEPDIR)/stresstest-stresstest.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -335,11 +339,13 @@ am__v_CXXLD_1 = SOURCES = $(src_libadplug_la_SOURCES) $(adplugdb_adplugdb_SOURCES) \ $(EXTRA_adplugdb_adplugdb_SOURCES) $(test_crctest_SOURCES) \ - $(test_emutest_SOURCES) $(test_playertest_SOURCES) + $(test_emutest_SOURCES) $(test_playertest_SOURCES) \ + $(test_stresstest_SOURCES) DIST_SOURCES = $(src_libadplug_la_SOURCES) \ $(adplugdb_adplugdb_SOURCES) \ $(EXTRA_adplugdb_adplugdb_SOURCES) $(test_crctest_SOURCES) \ - $(test_emutest_SOURCES) $(test_playertest_SOURCES) + $(test_emutest_SOURCES) $(test_playertest_SOURCES) \ + $(test_stresstest_SOURCES) AM_V_DVIPS = $(am__v_DVIPS_@AM_V@) am__v_DVIPS_ = $(am__v_DVIPS_@AM_DEFAULT_V@) am__v_DVIPS_0 = @echo " DVIPS " $@; @@ -589,9 +595,10 @@ $(TEST_LOG_FLAGS) am__DIST_COMMON = $(dist_man_MANS) $(doc_libadplug_TEXINFOS) \ $(srcdir)/Makefile.in $(srcdir)/adplug.pc.in \ - $(top_srcdir)/src/version.h.in AUTHORS COPYING ChangeLog NEWS \ - README TODO compile config.guess config.sub depcomp install-sh \ - ltmain.sh mdate-sh missing test-driver texinfo.tex + $(top_srcdir)/src/version.h.in AUTHORS COPYING ChangeLog \ + INSTALL NEWS README TODO compile config.guess config.sub \ + depcomp install-sh ltmain.sh mdate-sh missing test-driver \ + texinfo.tex DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -736,6 +743,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +# Regression tests: EXTRA_DIST = adplug.spec adplug.qpg BUGS adplug.pc.in \ doc/adplugdb.1.in test/2001.MKJ test/2001.ref test/2.CMF \ test/2.ref test/ADAGIO.DFM test/ADAGIO.ref test/adlibsp.ref \ @@ -779,7 +787,74 @@ test/TUBES.SAT test/TU_BLESS.AMD test/TU_BLESS.ref \ test/VIB_VOL3.D00 test/VIB_VOL3.ref test/WONDERIN.ref \ test/WONDERIN.WLF test/WORMINTR.AGD test/WORMINTR.ref \ - test/YsBattle.ref test/YsBattle.vgm + test/YsBattle.ref test/YsBattle.vgm test/i-85.bmf \ + test/i-86.dtm test/i-87.mkj test/i-88_1.a2m test/i-88_2.a2m \ + test/i-89_1.rad test/i-89_2.rad test/i-90_1.mtk \ + test/i-90_2.mtk test/i-91.m test/i-92_1.m test/i-92_2.m \ + test/i-92_3.m test/i-92_4.m test/i-93_01.bmf test/i-93_02.bmf \ + test/i-93_03.xad test/i-93_04.bmf test/i-93_05.xad \ + test/i-93_06.xad test/i-93_07.bmf test/i-93_08.xad \ + test/i-93_09.xad test/i-93_10.xad test/i-93_11.xad \ + test/i-93_12.xad test/i-93_13.xad test/i-93_14.xad \ + test/i-93_15.bmf test/i-93_16.xad test/i-93_17.xad \ + test/i-93_18.xad test/i-94.rix test/i-95_1.ctm test/i-95_2.ctm \ + test/i-96_1.rol test/i-96_2.rol test/i-96_3.rol test/i-98.sng \ + test/i-99.dro test/i-100_01.xad test/i-100_02.xad \ + test/i-100_03.dro test/i-100_04.dro test/i-100_05.raw \ + test/i-100_06.raw test/i-100_07.dro test/i-100_08.dro \ + test/i-100_09.adlib test/i-100_10.mkj test/i-100_11.mkj \ + test/i-100_12.cmf test/i-100_13.cmf test/i-101_1.d00 \ + test/i-101_2.d00 test/i-102_001.dfm test/i-102_002.dfm \ + test/i-102_003.dfm test/i-102_004.dfm test/i-102_005.dfm \ + test/i-102_006.dfm test/i-102_007.dfm test/i-102_008.dfm \ + test/i-102_009.dfm test/i-102_010.dfm test/i-102_011.dfm \ + test/i-102_012.dfm test/i-102_013.dfm test/i-102_014.dfm \ + test/i-102_015.dfm test/i-102_016.dfm test/i-102_017.dfm \ + test/i-102_018.dfm test/i-102_019.dfm test/i-102_020.dfm \ + test/i-102_021.dfm test/i-102_022.dfm test/i-102_023.dfm \ + test/i-102_024.dfm test/i-102_025.dfm test/i-102_026.dfm \ + test/i-102_027.dfm test/i-102_028.dfm test/i-102_029.dfm \ + test/i-102_030.dfm test/i-102_031.dfm test/i-102_032.dfm \ + test/i-102_033.dfm test/i-102_034.dfm test/i-102_035.dfm \ + test/i-102_036.dfm test/i-102_037.dfm test/i-102_038.dfm \ + test/i-102_039.dfm test/i-102_040.dfm test/i-102_041.dfm \ + test/i-102_042.dfm test/i-102_043.dfm test/i-102_044.dfm \ + test/i-102_045.dfm test/i-102_046.dfm test/i-102_047.dfm \ + test/i-102_048.dfm test/i-102_049.dfm test/i-102_050.dfm \ + test/i-102_051.dfm test/i-102_052.dfm test/i-102_053.dfm \ + test/i-102_054.dfm test/i-102_055.dfm test/i-102_056.dfm \ + test/i-102_057.dfm test/i-102_058.dfm test/i-102_059.dfm \ + test/i-102_060.dfm test/i-102_061.dfm test/i-102_062.dfm \ + test/i-102_063.dfm test/i-102_064.dfm test/i-102_065.dfm \ + test/i-102_066.dfm test/i-102_067.dfm test/i-102_068.dfm \ + test/i-102_069.dfm test/i-102_070.dfm test/i-102_071.dfm \ + test/i-102_072.dfm test/i-102_073.dfm test/i-102_074.dfm \ + test/i-102_075.dfm test/i-102_076.dfm test/i-102_077.dfm \ + test/i-102_078.dfm test/i-102_079.dfm test/i-102_080.dfm \ + test/i-102_081.dfm test/i-102_082.dfm test/i-102_083.dfm \ + test/i-102_084.dfm test/i-102_085.dfm test/i-102_086.dfm \ + test/i-102_087.dfm test/i-102_088.dfm test/i-102_089.dfm \ + test/i-102_090.dfm test/i-102_091.dfm test/i-102_092.dfm \ + test/i-102_093.dfm test/i-102_094.dfm test/i-102_095.dfm \ + test/i-102_096.dfm test/i-102_097.dfm test/i-102_098.dfm \ + test/i-102_099.dfm test/i-102_100.dfm test/i-102_101.dfm \ + test/i-102_102.dfm test/i-102_103.dfm test/i-102_104.dfm \ + test/i-102_105.dfm test/i-102_106.dfm test/i-102_107.dfm \ + test/i-102_108.dfm test/i-102_109.dfm test/i-102_110.dfm \ + test/i-102_111.dfm test/i-102_112.dfm test/i-102_113.dfm \ + test/i-102_114.dfm test/i-102_115.dfm test/i-102_116.dfm \ + test/i-102_117.dfm test/i-102_118.dfm test/i-102_119.dfm \ + test/i-102_120.dfm test/i-102_121.dfm test/i-102_122.dfm \ + test/i-102_123.dfm test/i-102_124.dfm test/i-102_125.dfm \ + test/i-102_126.dfm test/i-102_127.dfm test/i-102_128.dfm \ + test/i-102_129.dfm test/i-102_130.dfm test/i-102_131.dfm \ + test/i-102_132.dfm test/i-102_133.dfm test/i-102_134.dfm \ + test/i-102_135.dfm test/i-102_136.dfm test/i-102_137.dfm \ + test/i-102_138.dfm test/i-102_139.dfm test/i-102_140.dfm \ + test/i-102_141.dfm test/i-102_142.dfm test/i-102_143.dfm \ + test/i-102_144.dfm test/i-102_145.dfm test/i-102_146.dfm \ + test/i-102_147.dfm test/i-102_148.dfm test/i-102_149.dfm \ + test/i-102_150.dfm test/i-102_151.dfm pkgconfig_DATA = adplug.pc ######## @@ -839,7 +914,7 @@ src/players.cpp \ src/protrack.cpp \ src/psi.cpp \ - src/rad.cpp \ + src/rad2.cpp \ src/rat.cpp \ src/raw.cpp \ src/realopl.cpp \ @@ -887,7 +962,7 @@ src/mkj.h \ src/mtk.h \ src/protrack.h \ - src/rad.h \ + src/rad2.h \ src/raw.h \ src/s3m.h \ src/sa2.h \ @@ -937,7 +1012,8 @@ src/cmfmcsop.h \ src/vgm.h \ src/sop.h \ - src/herad.h + src/herad.h \ + src/load_helper.h adplugdb_adplugdb_SOURCES = adplugdb/adplugdb.cpp EXTRA_adplugdb_adplugdb_SOURCES = adplugdb/getopt.c adplugdb/mygetopt.h @@ -972,12 +1048,15 @@ test_playertest_SOURCES = test/playertest.cpp test_emutest_SOURCES = test/emutest.cpp test_crctest_SOURCES = test/crctest.cpp +test_stresstest_SOURCES = test/stresstest.cpp test_playertest_CPPFLAGS = $(libbinio_CFLAGS) test_emutest_CPPFLAGS = $(libbinio_CFLAGS) test_crctest_CPPFLAGS = $(libbinio_CFLAGS) +test_stresstest_CPPFLAGS = $(libbinio_CFLAGS) test_playertest_LDADD = src/libadplug.la $(libbinio_LIBS) test_emutest_LDADD = src/libadplug.la $(libbinio_LIBS) test_crctest_LDADD = src/libadplug.la $(libbinio_LIBS) +test_stresstest_LDADD = src/libadplug.la $(libbinio_LIBS) AM_TESTS_ENVIRONMENT = testdir='$(srcdir)/test'; export testdir; TESTS = $(check_PROGRAMS) all: all-am @@ -1220,7 +1299,7 @@ src/$(DEPDIR)/$(am__dirstamp) src/libadplug_la-psi.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) -src/libadplug_la-rad.lo: src/$(am__dirstamp) \ +src/libadplug_la-rad2.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/libadplug_la-rat.lo: src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) @@ -1295,6 +1374,12 @@ test/playertest$(EXEEXT): $(test_playertest_OBJECTS) $(test_playertest_DEPENDENCIES) $(EXTRA_test_playertest_DEPENDENCIES) test/$(am__dirstamp) @rm -f test/playertest$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(test_playertest_OBJECTS) $(test_playertest_LDADD) $(LIBS) +test/stresstest-stresstest.$(OBJEXT): test/$(am__dirstamp) \ + test/$(DEPDIR)/$(am__dirstamp) + +test/stresstest$(EXEEXT): $(test_stresstest_OBJECTS) $(test_stresstest_DEPENDENCIES) $(EXTRA_test_stresstest_DEPENDENCIES) test/$(am__dirstamp) + @rm -f test/stresstest$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(test_stresstest_OBJECTS) $(test_stresstest_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -1358,7 +1443,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libadplug_la-players.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libadplug_la-protrack.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libadplug_la-psi.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libadplug_la-rad.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libadplug_la-rad2.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libadplug_la-rat.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libadplug_la-raw.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libadplug_la-realopl.Plo@am__quote@ # am--include-marker @@ -1378,6 +1463,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/crctest-crctest.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/emutest-emutest.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/playertest-playertest.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/stresstest-stresstest.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @@ -1797,12 +1883,12 @@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libadplug_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/libadplug_la-psi.lo `test -f 'src/psi.cpp' || echo '$(srcdir)/'`src/psi.cpp -src/libadplug_la-rad.lo: src/rad.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libadplug_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/libadplug_la-rad.lo -MD -MP -MF src/$(DEPDIR)/libadplug_la-rad.Tpo -c -o src/libadplug_la-rad.lo `test -f 'src/rad.cpp' || echo '$(srcdir)/'`src/rad.cpp -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libadplug_la-rad.Tpo src/$(DEPDIR)/libadplug_la-rad.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/rad.cpp' object='src/libadplug_la-rad.lo' libtool=yes @AMDEPBACKSLASH@ +src/libadplug_la-rad2.lo: src/rad2.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libadplug_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/libadplug_la-rad2.lo -MD -MP -MF src/$(DEPDIR)/libadplug_la-rad2.Tpo -c -o src/libadplug_la-rad2.lo `test -f 'src/rad2.cpp' || echo '$(srcdir)/'`src/rad2.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libadplug_la-rad2.Tpo src/$(DEPDIR)/libadplug_la-rad2.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/rad2.cpp' object='src/libadplug_la-rad2.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libadplug_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/libadplug_la-rad.lo `test -f 'src/rad.cpp' || echo '$(srcdir)/'`src/rad.cpp +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libadplug_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/libadplug_la-rad2.lo `test -f 'src/rad2.cpp' || echo '$(srcdir)/'`src/rad2.cpp src/libadplug_la-rat.lo: src/rat.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(src_libadplug_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/libadplug_la-rat.lo -MD -MP -MF src/$(DEPDIR)/libadplug_la-rat.Tpo -c -o src/libadplug_la-rat.lo `test -f 'src/rat.cpp' || echo '$(srcdir)/'`src/rat.cpp @@ -1972,6 +2058,20 @@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_playertest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o test/playertest-playertest.obj `if test -f 'test/playertest.cpp'; then $(CYGPATH_W) 'test/playertest.cpp'; else $(CYGPATH_W) '$(srcdir)/test/playertest.cpp'; fi` +test/stresstest-stresstest.o: test/stresstest.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_stresstest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT test/stresstest-stresstest.o -MD -MP -MF test/$(DEPDIR)/stresstest-stresstest.Tpo -c -o test/stresstest-stresstest.o `test -f 'test/stresstest.cpp' || echo '$(srcdir)/'`test/stresstest.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) test/$(DEPDIR)/stresstest-stresstest.Tpo test/$(DEPDIR)/stresstest-stresstest.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='test/stresstest.cpp' object='test/stresstest-stresstest.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_stresstest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o test/stresstest-stresstest.o `test -f 'test/stresstest.cpp' || echo '$(srcdir)/'`test/stresstest.cpp + +test/stresstest-stresstest.obj: test/stresstest.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_stresstest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT test/stresstest-stresstest.obj -MD -MP -MF test/$(DEPDIR)/stresstest-stresstest.Tpo -c -o test/stresstest-stresstest.obj `if test -f 'test/stresstest.cpp'; then $(CYGPATH_W) 'test/stresstest.cpp'; else $(CYGPATH_W) '$(srcdir)/test/stresstest.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) test/$(DEPDIR)/stresstest-stresstest.Tpo test/$(DEPDIR)/stresstest-stresstest.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='test/stresstest.cpp' object='test/stresstest-stresstest.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_stresstest_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o test/stresstest-stresstest.obj `if test -f 'test/stresstest.cpp'; then $(CYGPATH_W) 'test/stresstest.cpp'; else $(CYGPATH_W) '$(srcdir)/test/stresstest.cpp'; fi` + mostlyclean-libtool: -rm -f *.lo @@ -2453,6 +2553,13 @@ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +test/stresstest.log: test/stresstest$(EXEEXT) + @p='test/stresstest$(EXEEXT)'; \ + b='test/stresstest'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ @@ -2752,7 +2859,7 @@ -rm -f src/$(DEPDIR)/libadplug_la-players.Plo -rm -f src/$(DEPDIR)/libadplug_la-protrack.Plo -rm -f src/$(DEPDIR)/libadplug_la-psi.Plo - -rm -f src/$(DEPDIR)/libadplug_la-rad.Plo + -rm -f src/$(DEPDIR)/libadplug_la-rad2.Plo -rm -f src/$(DEPDIR)/libadplug_la-rat.Plo -rm -f src/$(DEPDIR)/libadplug_la-raw.Plo -rm -f src/$(DEPDIR)/libadplug_la-realopl.Plo @@ -2772,6 +2879,7 @@ -rm -f test/$(DEPDIR)/crctest-crctest.Po -rm -f test/$(DEPDIR)/emutest-emutest.Po -rm -f test/$(DEPDIR)/playertest-playertest.Po + -rm -f test/$(DEPDIR)/stresstest-stresstest.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-libtool distclean-tags @@ -2963,7 +3071,7 @@ -rm -f src/$(DEPDIR)/libadplug_la-players.Plo -rm -f src/$(DEPDIR)/libadplug_la-protrack.Plo -rm -f src/$(DEPDIR)/libadplug_la-psi.Plo - -rm -f src/$(DEPDIR)/libadplug_la-rad.Plo + -rm -f src/$(DEPDIR)/libadplug_la-rad2.Plo -rm -f src/$(DEPDIR)/libadplug_la-rat.Plo -rm -f src/$(DEPDIR)/libadplug_la-raw.Plo -rm -f src/$(DEPDIR)/libadplug_la-realopl.Plo @@ -2983,6 +3091,7 @@ -rm -f test/$(DEPDIR)/crctest-crctest.Po -rm -f test/$(DEPDIR)/emutest-emutest.Po -rm -f test/$(DEPDIR)/playertest-playertest.Po + -rm -f test/$(DEPDIR)/stresstest-stresstest.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-aminfo \ maintainer-clean-generic maintainer-clean-vti diff -Nru adplug-2.3.1+dfsg/mdate-sh adplug-2.3.3+dfsg/mdate-sh --- adplug-2.3.1+dfsg/mdate-sh 2018-04-22 09:12:30.000000000 +0000 +++ adplug-2.3.3+dfsg/mdate-sh 2017-11-21 23:32:08.000000000 +0000 @@ -1,9 +1,9 @@ #!/bin/sh # Get modification time of a file or directory and pretty-print it. -scriptversion=2018-03-07.03; # UTC +scriptversion=2016-01-11.22; # UTC -# Copyright (C) 1995-2018 Free Software Foundation, Inc. +# Copyright (C) 1995-2017 Free Software Foundation, Inc. # written by Ulrich Drepper , June 1995 # # This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -74,10 +74,6 @@ LC_TIME=C export LC_TIME -# Use UTC to get reproducible result. -TZ=UTC0 -export TZ - # GNU ls changes its time format in response to the TIME_STYLE # variable. Since we cannot assume 'unset' works, revert this # variable to its documented default. @@ -220,7 +216,7 @@ # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'before-save-hook 'time-stamp) +# eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" diff -Nru adplug-2.3.1+dfsg/missing adplug-2.3.3+dfsg/missing --- adplug-2.3.1+dfsg/missing 2018-04-22 09:12:29.000000000 +0000 +++ adplug-2.3.3+dfsg/missing 2015-07-25 00:29:35.000000000 +0000 @@ -1,9 +1,9 @@ #! /bin/sh # Common wrapper for a few potentially missing GNU programs. -scriptversion=2018-03-07.03; # UTC +scriptversion=2013-10-28.13; # UTC -# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ # GNU General Public License for more details. # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -101,9 +101,9 @@ exit $st fi -perl_URL=https://www.perl.org/ -flex_URL=https://github.com/westes/flex -gnu_software_URL=https://www.gnu.org/software +perl_URL=http://www.perl.org/ +flex_URL=http://flex.sourceforge.net/ +gnu_software_URL=http://www.gnu.org/software program_details () { @@ -207,9 +207,9 @@ exit $st # Local variables: -# eval: (add-hook 'before-save-hook 'time-stamp) +# eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" +# time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: diff -Nru adplug-2.3.1+dfsg/NEWS adplug-2.3.3+dfsg/NEWS --- adplug-2.3.1+dfsg/NEWS 2018-04-22 09:09:23.000000000 +0000 +++ adplug-2.3.3+dfsg/NEWS 2020-05-12 01:32:48.000000000 +0000 @@ -1,5 +1,27 @@ This is a brief overview of user-visible changes in AdPlug. +Changes for version 2.3.3: +-------------------------- +- New RAD player replacing the old one +- Bug fixes: (huge thanks to Alexander Miller for these) + - CVE-2019-14690 - buffer overflow in .bmf + - CVE-2019-14691 - buffer overflow in .dtm + - CVE-2019-14692 - buffer overflow in .mkj + - CVE-2019-14732 - buffer overflow in .a2m + - CVE-2019-14733 - buffer overflow in .rad + - CVE-2019-14734 - buffer overflow in .mtk + - CVE-2019-15151 - double free and OOB reads in .u6m + - OOB reads in .xad + - OOB reads in .rix + +Changes for version 2.3.2: +-------------------------- +- Bug fixes: + - FMOPL: Fix global variable pointer double-free (CVE-2018-17825) + - HERAD: Fix compilation on GCC 4.2.1 + - ADL: Calling rewind() before update() causes access violation + - Move OPL reset/init code to rewind() for some players + Changes for version 2.3.1: -------------------------- - Fixed unconditional inclusion of "sys/io.h" on Linux diff -Nru adplug-2.3.1+dfsg/README adplug-2.3.3+dfsg/README --- adplug-2.3.1+dfsg/README 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/README 2020-05-11 23:53:51.000000000 +0000 @@ -21,7 +21,8 @@ IA32 - x86 Windows XP MinGW 3.4 MS-DOS 6.22 DJGPP 4.0 Linux 2.6 GCC 4.1 -x86_64 Linux 2.6 GCC 4.4.2 +x86_64 Linux GCC 6.3.1 + Linux GCC 8.2.1 This list only incorporates platforms on which this release of AdPlug has been tested successfully. This and/or earlier versions of AdPlug may and did @@ -49,9 +50,9 @@ -------------- If you checked out from git, please first run: -autoreconf --install + autoreconf --install -to generate the build cruft and get the configure script. Oh, and did i +to generate the build cruft and get the configure script. Oh, and did I mention you need recent versions of autoconf, automake and libtool? Windows git: diff -Nru adplug-2.3.1+dfsg/src/a2m.cpp adplug-2.3.3+dfsg/src/a2m.cpp --- adplug-2.3.1+dfsg/src/a2m.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/a2m.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -65,7 +65,7 @@ char id[10]; int i,j,k,t; unsigned int l; - unsigned char *org = NULL, *orgptr, flags = 0, numpats, version; + unsigned char *org, *orgptr, flags = 0, numpats, version; unsigned long crc, alength; unsigned short len[9], *secdata, *secptr; const unsigned char convfx[16] = {0,1,2,23,24,3,5,4,6,9,17,13,11,19,7,14}; @@ -79,8 +79,9 @@ version = f->readInt(1); numpats = f->readInt(1); // file validation section - if(strncmp(id,"_A2module_",10) || (version != 1 && version != 5 && - version != 4 && version != 8)) { + if (memcmp(id, "_A2module_", 10) || + (version != 1 && version != 5 && version != 4 && version != 8) || + numpats > 64) { fp.close(f); return false; } @@ -96,20 +97,33 @@ } // block 0 - secdata = new unsigned short [len[0] / 2]; if(version == 1 || version == 5) { + orgptr = org = new unsigned char [MAXBUF]; + secdata = new unsigned short [len[0] / 2]; for(i=0;ireadInt(2); - org = new unsigned char [MAXBUF]; orgptr = org; - sixdepak(secdata,org,len[0]); + // What if len[0] is odd: ignore, skip extra byte, or fail? + l = sixdepak(secdata,org,len[0]); + delete [] secdata; } else { - orgptr = (unsigned char *)secdata; - for(i=0;ireadInt(1); + orgptr = org = new unsigned char [len[0]]; + for(l = 0; l < len[0]; l++) orgptr[l] = f->readInt(1); } + if (l < 2*43 + 250*(33+13) + 128 + 2 + (version >= 5)) { + // Block is too short; fail. + delete [] org; + fp.close(f); + return false; + } + memcpy(songname,orgptr,43); orgptr += 43; memcpy(author,orgptr,43); orgptr += 43; memcpy(instname,orgptr,250*33); orgptr += 250*33; + // If string length is invalid, just use the maximum. Should we fail instead? + if (songname[0] > 42 || songname[0] < 0) songname[0] = 42; + if (author[0] > 42 || author[0] < 0) author[0] = 42; for(i=0;i<250;i++) { // instruments + if (instname[i][0] > 32 || instname[i][0] < 0) instname[i][0] = 32; inst[i].data[0] = *(orgptr+i*13+10); inst[i].data[1] = *(orgptr+i*13); inst[i].data[2] = *(orgptr+i*13+1); @@ -141,19 +155,21 @@ bpm = *orgptr; orgptr++; initspeed = *orgptr; orgptr++; if(version >= 5) flags = *orgptr; - if(version == 1 || version == 5) delete [] org; - delete [] secdata; + delete [] org; // blocks 1-4 or 1-8 alength = len[1]; - for(i = 0; i < (version < 5 ? numpats / 16 : numpats / 8); i++) + for (i = 0; i < numpats / (version < 5 ? 16 : 8); i++) alength += len[i+2]; - secdata = new unsigned short [alength / 2]; if(version == 1 || version == 5) { + org = new unsigned char [MAXBUF * (numpats / (version < 5 ? 16 : 8) + 1)]; + secdata = new unsigned short [alength / 2]; for(l=0;lreadInt(2); - org = new unsigned char [MAXBUF * (numpats / (version == 1 ? 16 : 8) + 1)]; orgptr = org; secptr = secdata; + // FIXME: The number of depacked blocks is inconsistent with the + // lengths summed and the size of org (if numpats is a multiple of 16/8). + // Also the "secptr += ..." statements below are not guarded by the "if"s! orgptr += sixdepak(secptr,orgptr,len[1]); secptr += len[1] / 2; if(version == 1) { if(numpats > 16) @@ -161,7 +177,7 @@ if(numpats > 32) orgptr += sixdepak(secptr,orgptr,len[3]); secptr += len[3] / 2; if(numpats > 48) - sixdepak(secptr,orgptr,len[4]); + orgptr += sixdepak(secptr,orgptr,len[4]); } else { if(numpats > 8) orgptr += sixdepak(secptr,orgptr,len[2]); secptr += len[2] / 2; @@ -176,12 +192,19 @@ if(numpats > 48) orgptr += sixdepak(secptr,orgptr,len[7]); secptr += len[7] / 2; if(numpats > 56) - sixdepak(secptr,orgptr,len[8]); + orgptr += sixdepak(secptr,orgptr,len[8]); } delete [] secdata; } else { - org = (unsigned char *)secdata; + org = new unsigned char [alength]; for(l=0;lreadInt(1); + orgptr = org + alength; + } + + if (orgptr - org < numpats * 64 * t * 4) { + delete [] org; + fp.close(f); + return false; } if(version < 5) { @@ -193,7 +216,7 @@ track->note = o[0] == 255 ? 127 : o[0]; track->inst = o[1]; - track->command = convfx[o[2]]; + track->command = o[2] < sizeof(convfx) ? convfx[o[2]] : 255; track->param2 = o[3] & 0x0f; if(track->command != 14) track->param1 = o[3] >> 4; @@ -235,7 +258,7 @@ track->note = o[0] == 255 ? 127 : o[0]; track->inst = o[1]; - track->command = newconvfx[o[2]]; + track->command = o[2] < sizeof(newconvfx) ? newconvfx[o[2]] : 255; track->param1 = o[3] >> 4; track->param2 = o[3] & 0x0f; @@ -259,10 +282,7 @@ init_trackord(); - if(version == 1 || version == 5) - delete [] org; - else - delete [] secdata; + delete [] org; // Process flags if(version >= 5) { @@ -271,6 +291,8 @@ if(flags & 16) CmodPlayer::flags |= Vibrato; // Vibrato depth } + // Note: crc value is not checked. + fp.close(f); rewind(0); return true; diff -Nru adplug-2.3.1+dfsg/src/a2m.h adplug-2.3.3+dfsg/src/a2m.h --- adplug-2.3.1+dfsg/src/a2m.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/a2m.h 2020-05-12 00:01:00.000000000 +0000 @@ -38,13 +38,13 @@ std::string gettype() { return std::string("AdLib Tracker 2"); } std::string gettitle() - { if(*songname) return std::string(songname,1,*songname); else return std::string(); } + { return std::string(songname + 1, *songname); } std::string getauthor() - { if(*author) return std::string(author,1,*author); else return std::string(); } + { return std::string(author + 1, *author); } unsigned int getinstruments() { return 250; } std::string getinstrument(unsigned int n) - { return std::string(instname[n],1,*instname[n]); } + { return std::string(instname[n] + 1, *instname[n]); } private: diff -Nru adplug-2.3.1+dfsg/src/adl.cpp adplug-2.3.3+dfsg/src/adl.cpp --- adplug-2.3.1+dfsg/src/adl.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/adl.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -2238,8 +2238,6 @@ _soundTriggers = _kyra1SoundTriggers; _numSoundTriggers = _kyra1NumSoundTriggers; - - init(); } CadlPlayer::~CadlPlayer() { @@ -2322,6 +2320,10 @@ _sfxPlayingSound = -1; } + // Verify that the sound/program offset is valid. + // KYRA3A.ADL subsong 2 points to sound 2, but the offset sound 2 is 0xffff. + if (READ_LE_UINT16(_soundDataPtr + 2 * soundId) == 0xffff) + return; int chan = _driver->callback(9, soundId, int(0)); if (chan != 9) { @@ -2435,7 +2437,6 @@ file_data = new uint8 [file_size]; f->readString((char *)file_data, file_size); - _driver->callback(8, int(-1)); _soundDataPtr = 0; uint8 *p = file_data; @@ -2499,18 +2500,23 @@ } fp.close(f); - cursubsong = -1; + rewind(-1); return true; } void CadlPlayer::rewind(int subsong) { - if(subsong == -1) subsong = cursubsong; - opl->init(); - opl->write(1,32); - playSoundEffect(subsong); + // rewind(-1) re-initializes the opl. + if(subsong == -1) + { + init(); + _driver->callback(8, int(-1)); + opl->init(); + opl->write(1,32); + subsong = 2; + } cursubsong = subsong; - update(); + loadcursubsong = true; } unsigned int CadlPlayer::getsubsongs() @@ -2520,9 +2526,11 @@ bool CadlPlayer::update() { - if (cursubsong == -1) - rewind(2); - + if (loadcursubsong) + { + loadcursubsong = false; + playSoundEffect(cursubsong); + } bool songend = true; // if(_trackEntries[cursubsong] == 0xff) diff -Nru adplug-2.3.1+dfsg/src/adl.h adplug-2.3.3+dfsg/src/adl.h --- adplug-2.3.1+dfsg/src/adl.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/adl.h 2020-05-12 00:01:00.000000000 +0000 @@ -52,6 +52,7 @@ private: int numsubsongs, cursubsong; + bool loadcursubsong; AdlibDriver *_driver; diff -Nru adplug-2.3.1+dfsg/src/adlib.cpp adplug-2.3.3+dfsg/src/adlib.cpp --- adplug-2.3.1+dfsg/src/adlib.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/adlib.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -653,32 +653,14 @@ */ void CadlibDriver::ChangePitch(int voice, int pitchBend) { - int l, t1, t2, delta; - static int oldL = -1; - static int oldHt; - static uint16_t * oldPtr; + int t = (pitchBend - MID_PITCH) * pitchRangeStep / MID_PITCH; + int delta = t < 0 ? NR_STEP_PITCH - 1 : 0; + t -= delta; - l = (int)(pitchBend - MID_PITCH) * pitchRangeStep; - if (oldL == l) { /* optimisation ... */ - fNumFreqPtr[voice] = oldPtr; - halfToneOffset[voice] = oldHt; - } - else { - t1 = l / MID_PITCH; - if (t1 < 0) { - t2 = NR_STEP_PITCH - 1 - t1; - oldHt = halfToneOffset[voice] = -(t2 / NR_STEP_PITCH); - delta = (t2 - NR_STEP_PITCH + 1) % NR_STEP_PITCH; - if (delta) - delta = NR_STEP_PITCH - delta; - } - else { - oldHt = halfToneOffset[voice] = t1 / NR_STEP_PITCH; - delta = t1 % NR_STEP_PITCH; - } - oldPtr = fNumFreqPtr[voice] = (uint16_t *)fNumNotes[delta]; - oldL = l; - } + halfToneOffset[voice] = t / NR_STEP_PITCH; + delta += t % NR_STEP_PITCH; + + fNumFreqPtr[voice] = fNumNotes[delta]; } /* diff -Nru adplug-2.3.1+dfsg/src/adplug.cpp adplug-2.3.3+dfsg/src/adplug.cpp --- adplug-2.3.1+dfsg/src/adplug.cpp 2018-01-22 20:20:49.000000000 +0000 +++ adplug-2.3.3+dfsg/src/adplug.cpp 2020-05-12 00:58:03.000000000 +0000 @@ -56,7 +56,7 @@ #include "dtm.h" #include "fmc.h" #include "mtk.h" -#include "rad.h" +#include "rad2.h" #include "raw.h" #include "sa2.h" #include "bmf.h" @@ -110,7 +110,7 @@ CPlayerDesc(CdtmLoader::factory, "DeFy Adlib Tracker", ".dtm\0"), CPlayerDesc(CfmcLoader::factory, "Faust Music Creator", ".sng\0"), CPlayerDesc(CmtkLoader::factory, "MPU-401 Trakker", ".mtk\0"), - CPlayerDesc(CradLoader::factory, "Reality Adlib Tracker", ".rad\0"), + CPlayerDesc(Crad2Player::factory, "Reality Adlib Tracker", ".rad\0"), CPlayerDesc(CrawPlayer::factory, "Raw AdLib Capture", ".rac\0.raw\0"), CPlayerDesc(Csa2Loader::factory, "Surprise! Adlib Tracker", ".sat\0.sa2\0"), CPlayerDesc(CxadbmfPlayer::factory, "BMF Adlib Tracker", ".xad\0.bmf\0"), diff -Nru adplug-2.3.1+dfsg/src/bmf.cpp adplug-2.3.3+dfsg/src/bmf.cpp --- adplug-2.3.1+dfsg/src/bmf.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/bmf.cpp 2020-05-24 05:22:12.000000000 +0000 @@ -31,21 +31,22 @@ type : Ford Knox BBStro tune : by The Brain [Razor 1911] player : ver.1.1 by ? - comment : in original player at 9th channel the feedback adlib register is not C8 but C6. + comment : in original player at 9th channel the feedback adlib register is + not C8 but C6. file(s) : DATURA.COM type : Datura BBStro tune : by The Brain [Razor 1911] player : ver.1.2 by ? - comment : inaccurate replaying, because constant outport; in original player it can be 380 or 382. + comment : inaccurate replaying, because constant outport; in original player + it can be 380 or 382. */ #include #include "bmf.h" #include "debug.h" -const unsigned char CxadbmfPlayer::bmf_adlib_registers[117] = -{ +const unsigned char CxadbmfPlayer::bmf_adlib_registers[117] = { 0x20, 0x23, 0x40, 0x43, 0x60, 0x63, 0x80, 0x83, 0xA0, 0xB0, 0xC0, 0xE0, 0xE3, 0x21, 0x24, 0x41, 0x44, 0x61, 0x64, 0x81, 0x84, 0xA1, 0xB1, 0xC1, 0xE1, 0xE4, 0x22, 0x25, 0x42, 0x45, 0x62, 0x65, 0x82, 0x85, 0xA2, 0xB2, 0xC2, 0xE2, 0xE5, @@ -57,19 +58,18 @@ 0x32, 0x35, 0x52, 0x55, 0x72, 0x75, 0x92, 0x95, 0xA8, 0xB8, 0xC8, 0xF2, 0xF5 }; -const unsigned short CxadbmfPlayer::bmf_notes[12] = -{ - 0x157, 0x16B, 0x181, 0x198, 0x1B0, 0x1CA, 0x1E5, 0x202, 0x220, 0x241, 0x263, 0x287 +const unsigned short CxadbmfPlayer::bmf_notes[12] = { + 0x157, 0x16B, 0x181, 0x198, 0x1B0, 0x1CA, + 0x1E5, 0x202, 0x220, 0x241, 0x263, 0x287 }; /* for 1.1 */ -const unsigned short CxadbmfPlayer::bmf_notes_2[12] = -{ - 0x159, 0x16D, 0x183, 0x19A, 0x1B2, 0x1CC, 0x1E8, 0x205, 0x223, 0x244, 0x267, 0x28B +const unsigned short CxadbmfPlayer::bmf_notes_2[12] = { + 0x159, 0x16D, 0x183, 0x19A, 0x1B2, 0x1CC, + 0x1E8, 0x205, 0x223, 0x244, 0x267, 0x28B }; -const unsigned char CxadbmfPlayer::bmf_default_instrument[13] = -{ +const unsigned char CxadbmfPlayer::bmf_default_instrument[13] = { 0x01, 0x01, 0x3F, 0x3F, 0x00, 0x00, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -80,115 +80,149 @@ bool CxadbmfPlayer::xadplayer_load() { - unsigned short ptr = 0; + size_t ptr = 0; int i; - if(xad.fmt != BMF) + if (xad.fmt != BMF) return false; #ifdef DEBUG AdPlug_LogWrite("\nbmf_load():\n\n"); #endif - if (!strncmp((char *)&tune[0],"BMF1.2",6)) - { + if (tune_size < 6) + return false; + if (!memcmp(&tune[0], "BMF1.2", 6)) { bmf.version = BMF1_2; bmf.timer = 70.0f; - } - else if (!strncmp((char *)&tune[0],"BMF1.1",6)) - { + ptr = 6; + } else if (!memcmp(&tune[0], "BMF1.1", 6)) { bmf.version = BMF1_1; bmf.timer = 68.5f; - } - else - { + ptr = 6; + } else { bmf.version = BMF0_9B; bmf.timer = 18.2f; } // copy title & author - if (bmf.version > BMF0_9B) - { - ptr = 6; - - strncpy(bmf.title,(char *)&tune[ptr],36); - bmf.title[35] = 0; - - while (tune[ptr]) { ptr++; } - ptr++; - - strncpy(bmf.author,(char *)&tune[ptr],36); - bmf.author[35] = 0; + if (bmf.version > BMF0_9B) { + // It's unclear whether title/author can be longer than 35 chars. The + // implementation reads an arbitrarily long NUL-terminated string and + // truncates it to fit in a fixed 36 byte buffer. Doesn't make sense! + size_t len = strnlen((char *)&tune[ptr], tune_size - ptr); + if (ptr + len == tune_size) + return false; + if (len >= sizeof(bmf.title)) { + memcpy(bmf.title, &tune[ptr], sizeof(bmf.title) - 1); + bmf.title[sizeof(bmf.title) - 1] = 0; + } else { + memcpy(bmf.title, &tune[ptr], len + 1); + } + ptr += len + 1; - while (tune[ptr]) { ptr++; } - ptr++; - } - else - { - strncpy(bmf.title,xad.title,36); - strncpy(bmf.author,xad.author,36); + len = strnlen((char *)&tune[ptr], tune_size - ptr); + if (ptr + len == tune_size) + return false; + if (len >= sizeof(bmf.author)) { + memcpy(bmf.author, &tune[ptr], sizeof(bmf.author) - 1); + bmf.author[sizeof(bmf.author) - 1] = 0; + } else { + memcpy(bmf.author, &tune[ptr], len + 1); + } + ptr += len + 1; + } else { + // bmf.version == BMF0_9B + strncpy(bmf.title, xad.title, sizeof(bmf.title)); + strncpy(bmf.author, xad.author, sizeof(bmf.author)); } // speed - if (bmf.version > BMF0_9B) - bmf.speed = tune[ptr++]; - else - bmf.speed = ((tune[ptr++] << 8) / 3) >> 8; // strange, yeh ? + if (tune_size - ptr < 1) + return false; + bmf.speed = tune[ptr++]; + if (bmf.version == BMF0_9B) + bmf.speed /= 3; // removed pointless shifts from original code // load instruments - if (bmf.version > BMF0_9B) - { - unsigned long iflags = (tune[ptr] << 24) | (tune[ptr+1] << 16) | (tune[ptr+2] << 8) | tune[ptr+3]; - ptr+=4; - - for(i=0;i<32;i++) - if (iflags & (1 << (31-i))) - { - strcpy(bmf.instruments[i].name, (char *)&tune[ptr]); - memcpy(bmf.instruments[i].data, &tune[ptr+11], 13); - ptr += 24; - } - else - { - bmf.instruments[i].name[0] = 0; - - if (bmf.version == BMF1_1) - for(int j=0;j<13;j++) - bmf.instruments[i].data[j] = bmf_default_instrument[j]; - else - for(int j=0;j<13;j++) - bmf.instruments[i].data[j] = 0; - } - } - else - { + if (bmf.version > BMF0_9B) { + if (tune_size - ptr < 4) + return false; + unsigned long iflags = (tune[ptr] << 24) | (tune[ptr+1] << 16) + | (tune[ptr+2] << 8) | tune[ptr+3]; + ptr += 4; + + for (i = 0; i < 32; i++) { + if (iflags & (1 << (31-i))) { + if (tune_size - ptr < sizeof(bmf.instruments[i])) + return false; + memcpy(bmf.instruments[i].name, &tune[ptr], + sizeof(bmf.instruments[i].name) - 1); + // last char ignored since name must be 0-terminated + bmf.instruments[i].name[sizeof(bmf.instruments[i].name) - 1] = 0; + memcpy(bmf.instruments[i].data, + &tune[ptr + sizeof(bmf.instruments[i].name)], + sizeof(bmf.instruments[i].data)); + ptr += sizeof(bmf.instruments[i]); + } else if (bmf.version == BMF1_1) { + memset(bmf.instruments[i].name, 0, sizeof(bmf.instruments[i].name)); + memcpy(bmf.instruments[i].data, bmf_default_instrument, + sizeof(bmf.instruments[i].data)); + } else { + memset(&bmf.instruments[i], 0, sizeof(bmf.instruments[i])); + } + } + } else { + // bmf.version == BMF0_9B ptr = 6; - for(i=0;i<32;i++) - { - bmf.instruments[i].name[0] = 0; - memcpy(bmf.instruments[tune[ptr]].data, &tune[ptr+2],13); // bug no.1 (no instrument-table-end detection) - ptr+=15; + if (tune_size - ptr < 32 * 15) + return false; + // Should unset entries be zero or set to bmf_default_instrument? + memset(bmf.instruments, 0, sizeof(bmf.instruments)); + for (i = 0; i < 32; i++) { + size_t ip = ptr + 15 * i; + // Original code lacked check and had a comment: "bug no.1 (no + // instrument-table-end detection)" - what does that mean? + if (tune[ip] < 32) + memcpy(bmf.instruments[tune[ip]].data, &tune[ip + 2], + sizeof(bmf.instruments[tune[ip]].data)); + else // what? continue, return false, or skip rest of the table? + break; // Old comment (see above) suggests it's a table end marker. } + ptr += 32 * 15; } - + // load streams - if (bmf.version > BMF0_9B) - { - unsigned long sflags = (tune[ptr] << 24) | (tune[ptr+1] << 16) | (tune[ptr+2] << 8) | tune[ptr+3]; - ptr+=4; - - for(i=0;i<9;i++) - if (sflags & (1 << (31-i))) - ptr+=__bmf_convert_stream(&tune[ptr],i); - else + if (bmf.version > BMF0_9B) { + if (tune_size - ptr < 4) + return false; + unsigned long sflags = (tune[ptr] << 24) + | (tune[ptr+1] << 16) + | (tune[ptr+2] << 8) + | tune[ptr+3]; + ptr += 4; + + for (i = 0; i < 9; i++) + if (sflags & (1 << (31-i))) { + long len = __bmf_convert_stream(tune + ptr, i, tune_size - ptr); + if (len < 0) + return false; + ptr += len; + } else { bmf.streams[i][0].cmd = 0xFF; - } - else - { - for(i=0;i 9) + return false; + for (i = 0; i < tune[5]; i++) { + long len = __bmf_convert_stream(tune + ptr, i, tune_size - ptr); + if (len < 0) + return false; + ptr += len; + } - for(i=tune[5];i<9;i++) + for (i = tune[5]; i < 9; i++) bmf.streams[i][0].cmd = 0xFF; } @@ -197,183 +231,159 @@ void CxadbmfPlayer::xadplayer_rewind(int subsong) { - int i,j; - - for(i=0; i<9; i++) - { - bmf.channel[i].stream_position = 0; - bmf.channel[i].delay = 0; - bmf.channel[i].loop_position = 0; - bmf.channel[i].loop_counter = 0; - } + memset(bmf.channel, 0, sizeof(bmf.channel)); plr.speed = bmf.speed; #ifdef DEBUG - AdPlug_LogWrite("speed: %x\n",plr.speed); + AdPlug_LogWrite("speed: %x\n", plr.speed); #endif bmf.active_streams = 9; // OPL initialization - if (bmf.version > BMF0_9B) - { + if (bmf.version > BMF0_9B) { opl_write(0x01, 0x20); - + /* 1.1 */ + int i, j; if (bmf.version == BMF1_1) - for(i=0;i<9;i++) - for(j=0;j<13;j++) - opl_write(bmf_adlib_registers[13*i+j], bmf_default_instrument[j]); + for (i = 0; i < 9; i++) + for (j = 0; j < 13; j++) + opl_write(bmf_adlib_registers[13 * i + j], bmf_default_instrument[j]); /* 1.2 */ else if (bmf.version == BMF1_2) - for(i=0x20; i<0x100; i++) - opl_write(i,0xFF); // very interesting, really! + for (i = 0x20; i < 0x100; i++) + opl_write(i, 0xFF); // very interesting, really! } /* ALL */ - opl_write(0x08, 0x00); opl_write(0xBD, 0xC0); } void CxadbmfPlayer::xadplayer_update() { - for(int i=0;i<9;i++) - if (bmf.channel[i].stream_position != 0xFFFF) - if (bmf.channel[i].delay) + for (int i = 0; i < 9; i++) { + unsigned short &pos = bmf.channel[i].stream_position; + if (pos == 0xFFFF) + continue; + + if (bmf.channel[i].delay) { bmf.channel[i].delay--; - else - { + continue; + } + #ifdef DEBUG - AdPlug_LogWrite("channel %02X:\n", i); + AdPlug_LogWrite("channel %02X:\n", i); #endif - bmf_event event; - // process so-called cross-events - while (true) - { - memcpy(&event, &bmf.streams[i][bmf.channel[i].stream_position], sizeof(bmf_event)); +again: + const bmf_event &event = bmf.streams[i][pos]; #ifdef DEBUG - AdPlug_LogWrite("%02X %02X %02X %02X %02X %02X\n", - event.note,event.delay,event.volume,event.instrument, - event.cmd,event.cmd_data); + AdPlug_LogWrite("%02X %02X %02X %02X %02X %02X\n", + event.note, event.delay, event.volume, + event.instrument, event.cmd, event.cmd_data); #endif - if (event.cmd == 0xFF) - { - bmf.channel[i].stream_position = 0xFFFF; - bmf.active_streams--; - break; - } - else if (event.cmd == 0xFE) - { - bmf.channel[i].loop_position = bmf.channel[i].stream_position+1; - bmf.channel[i].loop_counter = event.cmd_data; - } - else if (event.cmd == 0xFD) - { - if (bmf.channel[i].loop_counter) - { - bmf.channel[i].stream_position = bmf.channel[i].loop_position-1; - bmf.channel[i].loop_counter--; - } - } - else - break; + switch (event.cmd) { + // Process so-called Cross-Events - bmf.channel[i].stream_position++; - } // while (true) + case 0xFF: // End of Stream + pos = 0xFFFF; + bmf.active_streams--; + continue; + + case 0xFE: // Save Loop Position + bmf.channel[i].loop_position = ++pos; + bmf.channel[i].loop_counter = event.cmd_data; + goto again; + + case 0xFD: // Loop to Saved Position + if (bmf.channel[i].loop_counter) { + pos = bmf.channel[i].loop_position; + bmf.channel[i].loop_counter--; + } else { + pos++; + } + goto again; - // process normal event - unsigned short pos = bmf.channel[i].stream_position; + // Process normal event - if (pos != 0xFFFF) + case 0x01: // Set Modulator Volume { - bmf.channel[i].delay = bmf.streams[i][pos].delay; + unsigned char reg = bmf_adlib_registers[13 * i + 2]; + // Masking cmd_data to avoid out of range writes might be a good idea, + // or do it while parsing the file. + opl_write(reg, (adlib[reg] | 0x3F) - event.cmd_data); + } + break; + + case 0x10: // Set Speed + plr.speed = event.cmd_data; + plr.speed_counter = plr.speed; + break; + } - // command ? - if (bmf.streams[i][pos].cmd) - { - unsigned char cmd = bmf.streams[i][pos].cmd; - - // 0x01: Set Modulator Volume - if (cmd == 0x01) - { - unsigned char reg = bmf_adlib_registers[13*i+2]; - - opl_write(reg, (adlib[reg] | 0x3F) - bmf.streams[i][pos].cmd_data); - } - // 0x10: Set Speed - else if (cmd == 0x10) - { - plr.speed = bmf.streams[i][pos].cmd_data; - plr.speed_counter = plr.speed; - } - } // if (bmf.streams[i][pos].cmd) - - // instrument ? - if (bmf.streams[i][pos].instrument) - { - unsigned char ins = bmf.streams[i][pos].instrument-1; - - if (bmf.version != BMF1_1) - opl_write(0xB0+i, adlib[0xB0+i] & 0xDF); - - for(int j=0;j<13;j++) - opl_write(bmf_adlib_registers[i*13+j], bmf.instruments[ins].data[j]); - } // if (bmf.streams[i][pos].instrument) - - // volume ? - if (bmf.streams[i][pos].volume) - { - unsigned char vol = bmf.streams[i][pos].volume-1; - unsigned char reg = bmf_adlib_registers[13*i+3]; - - opl_write(reg, (adlib[reg] | 0x3F) - vol); - } // if (bmf.streams[i][pos].volume) - - // note ? - if (bmf.streams[i][pos].note) - { - unsigned short note = bmf.streams[i][pos].note; - unsigned short freq = 0; - - // mute channel - opl_write(0xB0+i, adlib[0xB0+i] & 0xDF); - - // get frequency - if (bmf.version == BMF1_1) - { - if (note <= 0x60) - freq = bmf_notes_2[--note % 12]; - } - else - { - if (note != 0x7F) - freq = bmf_notes[--note % 12]; - } - - // play note - if (freq) - { - opl_write(0xB0+i, (freq >> 8) | ((note / 12) << 2) | 0x20); - opl_write(0xA0+i, freq & 0xFF); - } - } // if (bmf.streams[i][pos].note) + // Got normal event, pos != 0xFFFF - bmf.channel[i].stream_position++; - } // if (pos != 0xFFFF) + // Process delay + bmf.channel[i].delay = event.delay; - } // if (!bmf.channel[i].delay) + // Process instrument + if (event.instrument) { + unsigned char ins = event.instrument - 1; + + if (bmf.version != BMF1_1) + opl_write(0xB0 + i, adlib[0xB0 + i] & 0xDF); + + for (int j = 0; j < 13; j++) + opl_write(bmf_adlib_registers[13 * i + j], + bmf.instruments[ins].data[j]); + } + + // Process volume + if (event.volume) { + unsigned char vol = event.volume - 1; + unsigned char reg = bmf_adlib_registers[13 * i + 3]; + + // Masking cmd_data to avoid out of range writes might be a good idea, + // or do it while parsing the file. + opl_write(reg, (adlib[reg] | 0x3F) - vol); + } + + // Process note + if (event.note) { + unsigned short note = event.note - 1; + unsigned short freq = 0; + + // mute channel + opl_write(0xB0 + i, adlib[0xB0 + i] & 0xDF); + + // get frequency + if (bmf.version == BMF1_1) { + if (note < 0x60) + freq = bmf_notes_2[note % 12]; + } else { + if (note != 0x7E) // really? + freq = bmf_notes[note % 12]; + } + + // play note + if (freq) { + opl_write(0xB0 + i, (freq >> 8) | ((note / 12) << 2) | 0x20); + opl_write(0xA0 + i, freq & 0xFF); + } + } // if (event.note) + + pos++; + } // for (i) // is module loop ? - if (!bmf.active_streams) - { - for(int j=0;j<9;j++) + if (!bmf.active_streams) { + for (int j = 0; j < 9; j++) bmf.channel[j].stream_position = 0; - bmf.active_streams = 9; - + bmf.active_streams = 9; plr.looping = 1; } } @@ -415,190 +425,144 @@ /* -------- Internal Functions ---------------------------- */ -int CxadbmfPlayer::__bmf_convert_stream(unsigned char *stream, int channel) +long int CxadbmfPlayer::__bmf_convert_stream(const unsigned char *stream, + int channel, unsigned long stream_size) { #ifdef DEBUG - AdPlug_LogWrite("channel %02X (note,delay,volume,instrument,command,command_data):\n",channel); - unsigned char *last = stream; + AdPlug_LogWrite("channel %02X (note, delay, volume, instrument, " + "command, command_data):\n", channel); + const unsigned char *last = stream; #endif - unsigned char *stream_start = stream; - - int pos = 0; - - while (true) - { - memset(&bmf.streams[channel][pos], 0, sizeof(bmf_event)); - - bool is_cmd = false; - - if (*stream == 0xFE) - { - // 0xFE -> 0xFF: End of Stream - bmf.streams[channel][pos].cmd = 0xFF; - - stream++; - + const unsigned char *const stream_start = stream; + const unsigned char *const stream_end = stream + stream_size; + const int last_pos = sizeof(bmf.streams[0]) / sizeof(bmf.streams[0][0]) - 1; + + // The loop exits when End of Stream (0xFE) is found (or on error). + // If the stream is too long to store, truncate it, but keep reading + // until the end marker is found and stored. + for (int pos = 0; pos <= last_pos; pos < last_pos && pos++) { + bmf_event &event = bmf.streams[channel][pos]; + memset(&event, 0, sizeof(bmf_event)); + + if (stream_end - stream < 1) + return -1; + switch (*stream) { + /* Cross-Events */ + case 0xFE: // 0xFE -> 0xFF: End of Stream + event.cmd = 0xFF; + stream++; + pos = last_pos + 1; // end loop break; - } - else if (*stream == 0xFC) - { - // 0xFC -> 0xFE xx: Save Loop Position - bmf.streams[channel][pos].cmd = 0xFE; - bmf.streams[channel][pos].cmd_data = (*(stream+1) & ((bmf.version == BMF0_9B) ? 0x7F : 0x3F)) - 1; - stream+=2; - } - else if (*stream == 0x7D) - { - // 0x7D -> 0xFD: Loop Saved Position - bmf.streams[channel][pos].cmd = 0xFD; - - stream++; - } - else - { - if (*stream & 0x80) - { - if (*(stream+1) & 0x80) - { - if (*(stream+1) & 0x40) - { - // byte0: 1aaaaaaa = NOTE - bmf.streams[channel][pos].note = *stream & 0x7F; - // byte1: 11bbbbbb = DELAY - bmf.streams[channel][pos].delay = *(stream+1) & 0x3F; - // byte2: cccccccc = COMMAND - - stream+=2; - - is_cmd = true; - } - else - { - // byte0: 1aaaaaaa = NOTE - bmf.streams[channel][pos].note = *stream & 0x7F; - // byte1: 11bbbbbb = DELAY - bmf.streams[channel][pos].delay = *(stream+1) & 0x3F; - - stream+=2; - } // if (*(stream+1) & 0x40) - } - else - { - // byte0: 1aaaaaaa = NOTE - bmf.streams[channel][pos].note = *stream & 0x7F; - // byte1: 0bbbbbbb = COMMAND - - stream++; - - is_cmd = true; - } // if (*(stream+1) & 0x80) - } - else - { - // byte0: 0aaaaaaa = NOTE - bmf.streams[channel][pos].note = *stream & 0x7F; - - stream++; - } // if (*stream & 0x80) - } // if (*stream == 0xFE) - - // is command ? - if (is_cmd) - { - - /* ALL */ + case 0xFC: // 0xFC -> 0xFE xx: Save Loop Position + event.cmd = 0xFE; + if (stream_end - stream < 2) + return -1; + event.cmd_data = (stream[1] & (bmf.version == BMF0_9B ? 0x7F : 0x3F)) - 1; + stream += 2; + break; - if ((0x20 <= *stream) && (*stream <= 0x3F)) - { - // 0x20 or higher; 0x3F or lower: Set Instrument - bmf.streams[channel][pos].instrument = *stream - 0x20 + 1; + case 0x7D: // 0x7D -> 0xFD: Loop to Saved Position + event.cmd = 0xFD; + stream++; + break; - stream++; - } - else if (0x40 <= *stream) - { - // 0x40 or higher: Set Volume - bmf.streams[channel][pos].volume = *stream - 0x40 + 1; + /* Normal Events */ + default: + // The event is defined by the next 1 to 4 bytes and consists of + // a note, an optional delay, and an optional command (which may + // take another data byte as argument). + // Bit 0x80 of the first byte indicates the presence of an optional + // part; if present, bits 0x80 and 0x40 of the second byte determine + // whether we have delay, command, or both. The possible forms are: + // 0NNNNNNN - 1 byte: note + // 1NNNNNNN 0CCCCCCC - 2+ bytes: note, command [data] + // 1NNNNNNN 10DDDDDD - 2 bytes: note, delay + // 1NNNNNNN 11DDDDDD CCCCCCCC - 3+ bytes: note, delay, command [data] + event.note = *stream & 0x7F; + + if (!(*stream++ & 0x80)) + break; // 1st byte is 0NNNNNNN: no delay or command; done. + + if (stream_end - stream < 1) + return -1; + if (*stream & 0x80) { + // 2nd byte is 1xDDDDDD: delay byte present + event.delay = *stream & 0x3F; - stream++; + if (!(*stream++ & 0x40)) + break; // 2nd byte is 10DDDDDD: no command; done. } - else - { - /* 0.9b */ - - if (bmf.version == BMF0_9B) - if (*stream < 0x20) - { - // 0x1F or lower: ? - stream++; - } - - /* 1.2 */ - - if (bmf.version == BMF1_2) - if (*stream == 0x01) - { - // 0x01: Set Modulator Volume -> 0x01 - bmf.streams[channel][pos].cmd = 0x01; - bmf.streams[channel][pos].cmd_data = *(stream+1); - - stream+=2; - } - else if (*stream == 0x02) - { - // 0x02: ? - stream+=2; - } - else if (*stream == 0x03) - { - // 0x03: ? - stream+=2; - } - else if (*stream == 0x04) - { - // 0x04: Set Speed -> 0x10 - bmf.streams[channel][pos].cmd = 0x10; - bmf.streams[channel][pos].cmd_data = *(stream+1); - - stream+=2; - } - else if (*stream == 0x05) - { - // 0x05: Set Carrier Volume (port 380) - bmf.streams[channel][pos].volume = *(stream+1) + 1; - - stream+=2; - } - else if (*stream == 0x06) - { - // 0x06: Set Carrier Volume (port 382) - bmf.streams[channel][pos].volume = *(stream+1) + 1; - - stream+=2; - } // if (bmf.version == BMF1_2) + // If we reach this point, a command byte follows. + if (stream_end - stream < 1) + return -1; + + if (0x40 <= *stream) { + // command 0x40 or higher: Set Volume + event.volume = *stream - 0x40 + 1; // masking needed? + stream++; + } else if ((0x20 <= *stream) && (*stream <= 0x3F)) { + // command 0x20 to 0x3F: Set Instrument + event.instrument = *stream - 0x20 + 1; + stream++; + } else { + // command 0x1F or lower + if (bmf.version == BMF0_9B) { + // version 0.9b, command 0x1F or lower: ? + stream++; + } else if (bmf.version == BMF1_2) { + /* 1.2 */ + if (0x01 <= *stream && *stream <= 0x06) { + if (stream_end - stream < 2) + return -1; + switch (*stream) { + case 0x01: // Set Modulator Volume -> 0x01 + event.cmd = 0x01; + event.cmd_data = stream[1]; + break; + + case 0x02: // ? + case 0x03: // ? + break; + + case 0x04: // Set Speed -> 0x10 + event.cmd = 0x10; + event.cmd_data = stream[1]; + break; + + case 0x05: // Set Carrier Volume (port 380) + event.volume = stream[1] + 1; // masking needed? + break; + + case 0x06: // Set Carrier Volume (port 382) + event.volume = stream[1] + 1; // masking needed? + break; + } + stream += 2; + } // if (0x01 <= *stream && *stream <= 0x06) + + } // if (bmf.version == BMF1_2) + + // The following cases are not handled and don't even + // increment the stream pointer (that's probably wrong): + // * version 1.1, commands 0x1F or lower + // * version 1.2, commands 0x00 and 0x07 to 0x1F - } // if ((0x20 <= *stream) && (*stream <= 0x3F)) + } // ! if (0x40 <= *stream) - } // if (is_cmd) + } // switch #ifdef DEBUG - AdPlug_LogWrite("%02X %02X %02X %02X %02X %02X <---- ", - bmf.streams[channel][pos].note, - bmf.streams[channel][pos].delay, - bmf.streams[channel][pos].volume, - bmf.streams[channel][pos].instrument, - bmf.streams[channel][pos].cmd, - bmf.streams[channel][pos].cmd_data - ); - for(int zz=0;zz<(stream-last);zz++) - AdPlug_LogWrite("%02X ",last[zz]); - AdPlug_LogWrite("\n"); - last=stream; + AdPlug_LogWrite("%02X %02X %02X %02X %02X %02X <---- ", + event.note, event.delay, event.volume, + event.instrument, event.cmd, event.cmd_data); + for (int zz = 0; zz < (stream - last); zz++) + AdPlug_LogWrite(" %02X", last[zz]); + AdPlug_LogWrite("\n"); + last = stream; #endif - pos++; - } // while (true) + } // for - return (stream - stream_start); + return stream - stream_start; } diff -Nru adplug-2.3.1+dfsg/src/bmf.h adplug-2.3.3+dfsg/src/bmf.h --- adplug-2.3.1+dfsg/src/bmf.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/bmf.h 2020-05-12 00:01:00.000000000 +0000 @@ -88,5 +88,6 @@ static const unsigned short bmf_notes_2[12]; static const unsigned char bmf_default_instrument[13]; - int __bmf_convert_stream(unsigned char *stream, int channel); + long int __bmf_convert_stream(const unsigned char *stream, int channel, + unsigned long stream_size); }; diff -Nru adplug-2.3.1+dfsg/src/cmf.cpp adplug-2.3.3+dfsg/src/cmf.cpp --- adplug-2.3.1+dfsg/src/cmf.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/cmf.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -209,6 +209,10 @@ // Load the MIDI data into memory f->seek(this->cmfHeader.iMusicOffset); this->iSongLen = fp.filesize(f) - this->cmfHeader.iMusicOffset; + if (this->iSongLen <= 0) { // invalid offset value + fp.close(f); + return false; + } this->data = new unsigned char[this->iSongLen]; f->readString((char *)data, this->iSongLen); @@ -225,7 +229,7 @@ // Read in the next event while (!this->iDelayRemaining) { - uint8_t iCommand = this->data[this->iPlayPointer++]; + uint8_t iCommand = this->iPlayPointer < this->iSongLen ? this->data[this->iPlayPointer++] : 0; if ((iCommand & 0x80) == 0) { // Running status, use previous command this->iPlayPointer--; @@ -236,12 +240,14 @@ uint8_t iChannel = iCommand & 0x0F; switch (iCommand & 0xF0) { case 0x80: { // Note off (two data bytes) + if (this->iPlayPointer < this->iSongLen - 1) break; uint8_t iNote = this->data[this->iPlayPointer++]; uint8_t iVelocity = this->data[this->iPlayPointer++]; // release velocity this->cmfNoteOff(iChannel, iNote, iVelocity); break; } case 0x90: { // Note on (two data bytes) + if (this->iPlayPointer > this->iSongLen - 2) break; uint8_t iNote = this->data[this->iPlayPointer++]; uint8_t iVelocity = this->data[this->iPlayPointer++]; // attack velocity if (iVelocity) { @@ -272,29 +278,34 @@ break; } case 0xA0: { // Polyphonic key pressure (two data bytes) + if (this->iPlayPointer > this->iSongLen - 2) break; uint8_t iNote = this->data[this->iPlayPointer++]; uint8_t iPressure = this->data[this->iPlayPointer++]; AdPlug_LogWrite("CMF: Key pressure not yet implemented! (wanted ch%d/note %d set to %d)\n", iChannel, iNote, iPressure); break; } case 0xB0: { // Controller (two data bytes) + if (this->iPlayPointer > this->iSongLen - 2) break; uint8_t iController = this->data[this->iPlayPointer++]; uint8_t iValue = this->data[this->iPlayPointer++]; this->MIDIcontroller(iChannel, iController, iValue); break; } case 0xC0: { // Instrument change (one data byte) + if (this->iPlayPointer >= this->iSongLen) break; uint8_t iNewInstrument = this->data[this->iPlayPointer++]; this->chMIDI[iChannel].iPatch = iNewInstrument; AdPlug_LogWrite("CMF: Remembering MIDI channel %d now uses patch %d\n", iChannel, iNewInstrument); break; } case 0xD0: { // Channel pressure (one data byte) + if (this->iPlayPointer >= this->iSongLen) break; uint8_t iPressure = this->data[this->iPlayPointer++]; AdPlug_LogWrite("CMF: Channel pressure not yet implemented! (wanted ch%d set to %d)\n", iChannel, iPressure); break; } case 0xE0: { // Pitch bend (two data bytes) + if (this->iPlayPointer > this->iSongLen - 2) break; uint8_t iLSB = this->data[this->iPlayPointer++]; uint8_t iMSB = this->data[this->iPlayPointer++]; uint16_t iValue = (iMSB << 7) | iLSB; @@ -307,26 +318,31 @@ case 0xF0: // System message (arbitrary data bytes) switch (iCommand) { case 0xF0: { // Sysex - uint8_t iNextByte; + uint8_t iNextByte = 0; AdPlug_LogWrite("Sysex message: "); - do { + while ((iNextByte & 0x80) == 0 && this->iPlayPointer < this->iSongLen) { iNextByte = this->data[this->iPlayPointer++]; AdPlug_LogWrite("%02X", iNextByte); - } while ((iNextByte & 0x80) == 0); + } AdPlug_LogWrite("\n"); // This will have read in the terminating EOX (0xF7) message too break; } case 0xF1: // MIDI Time Code Quarter Frame - this->data[this->iPlayPointer++]; // message data (ignored) + if (this->iPlayPointer < this->iSongLen) + (void)this->data[this->iPlayPointer++]; // message data (ignored) break; case 0xF2: // Song position pointer - this->data[this->iPlayPointer++]; // message data (ignored) - this->data[this->iPlayPointer++]; + if (this->iPlayPointer < this->iSongLen - 1) { + (void)this->data[this->iPlayPointer++]; // message data (ignored) + (void)this->data[this->iPlayPointer++]; + } break; case 0xF3: // Song select - this->data[this->iPlayPointer++]; // message data (ignored) - AdPlug_LogWrite("CMF: MIDI Song Select is not implemented.\n"); + if (this->iPlayPointer < this->iSongLen - 1) { + (void)this->data[this->iPlayPointer++]; // message data (ignored) + AdPlug_LogWrite("CMF: MIDI Song Select is not implemented.\n"); + } break; case 0xF6: // Tune request break; @@ -348,6 +364,7 @@ this->iPlayPointer = 0; // for repeat in endless-play mode break; case 0xFF: { // System reset, used as meta-events in a MIDI file + if (this->iPlayPointer >= this->iSongLen) break; uint8_t iEvent = this->data[this->iPlayPointer++]; switch (iEvent) { case 0x2F: // end of track @@ -489,7 +506,7 @@ { uint32_t iValue = 0; for (int i = 0; i < 4; i++) { - uint8_t iNext = this->data[this->iPlayPointer++]; + uint8_t iNext = this->iPlayPointer < this->iSongLen ? this->data[this->iPlayPointer++] : 0; iValue <<= 7; iValue |= (iNext & 0x7F); // ignore the MSB if ((iNext & 0x80) == 0) break; // last byte has the MSB unset diff -Nru adplug-2.3.1+dfsg/src/d00.cpp adplug-2.3.3+dfsg/src/d00.cpp --- adplug-2.3.1+dfsg/src/d00.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/d00.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -37,6 +37,9 @@ #define HIBYTE(val) (val >> 8) #define LOBYTE(val) (val & 0xff) +#define INDEX_OK(ptr, idx) \ + (((char*)(ptr) - filedata) + ((idx)+1) * sizeof(*(ptr)) <= filesize) + static const unsigned short notetable[12] = // D00 note table {340,363,385,408,432,458,485,514,544,577,611,647}; @@ -58,7 +61,6 @@ binistream *f = fp.open(filename); if(!f) return false; d00header *checkhead; d00header1 *ch; - unsigned long filesize; int i,ver1=0; char *str; @@ -68,7 +70,8 @@ // Check for version 2-4 header if(strncmp(checkhead->id,"JCH\x26\x02\x66",6) || checkhead->type || - !checkhead->subsongs || checkhead->soundcard) { + !checkhead->subsongs || checkhead->soundcard || + checkhead->version < 2 || checkhead->version > 4) { // Check for version 0 or 1 header (and .d00 file extension) delete checkhead; if(!fp.extension(filename, ".d00")) { fp.close(f); return false; } @@ -88,25 +91,38 @@ filesize = fp.filesize(f); f->seek(0); filedata = new char [filesize + 1]; // 1 byte is needed for old-style DataInfo block f->readString((char *)filedata, filesize); + filedata[filesize] = 0; fp.close(f); if(!ver1) { // version 2 and above header = (struct d00header *)filedata; + if (filesize < sizeof(d00header) || + filesize < LE_WORD(&header->infoptr) || + filesize < LE_WORD(&header->instptr) || + filesize < LE_WORD(&header->seqptr)) + return false; version = header->version; datainfo = (char *)filedata + LE_WORD(&header->infoptr); inst = (struct Sinsts *)((char *)filedata + LE_WORD(&header->instptr)); seqptr = (unsigned short *)((char *)filedata + LE_WORD(&header->seqptr)); - for(i=31;i>=0;i--) // erase whitespace + header->songname[31] = '\0'; + for(i=30;i>=0;i--) // erase whitespace if(header->songname[i] == ' ') header->songname[i] = '\0'; else break; - for(i=31;i>=0;i--) + header->author[31] = '\0'; + for(i=30;i>=0;i--) if(header->author[i] == ' ') header->author[i] = '\0'; else break; } else { // version 1 header1 = (struct d00header1 *)filedata; + if (filesize < sizeof(d00header1) || + filesize <= LE_WORD(&header1->infoptr) || + filesize <= LE_WORD(&header1->instptr) || + filesize <= LE_WORD(&header1->seqptr)) + return false; version = header1->version; datainfo = (char *)filedata + LE_WORD(&header1->infoptr); inst = (struct Sinsts *)((char *)filedata + LE_WORD(&header1->instptr)); @@ -119,10 +135,12 @@ header1->speed = 70; // v0 files default to 70Hz break; case 1: + if (filesize <= LE_WORD(&header1->lpulptr)) return false; levpuls = (struct Slevpuls *)((char *)filedata + LE_WORD(&header1->lpulptr)); spfx = 0; break; case 2: + if (filesize <= LE_WORD(&header->spfxptr)) return false; levpuls = (struct Slevpuls *)((char *)filedata + LE_WORD(&header->spfxptr)); spfx = 0; break; @@ -131,6 +149,7 @@ levpuls = 0; break; case 4: + if (filesize <= LE_WORD(&header->spfxptr)) return false; spfx = (struct Sspfx *)((char *)filedata + LE_WORD(&header->spfxptr)); levpuls = 0; break; @@ -139,8 +158,6 @@ while((*str == '\xff' || *str == ' ') && str >= datainfo) { *str = '\0'; str--; } - else // old-style block - memset((char *)filedata+filesize,0,1); rewind(0); return true; @@ -156,11 +173,15 @@ channel[c].slideval += channel[c].slide; setfreq(c); // sliding vibrato(c); // vibrato - if(channel[c].spfx != 0xffff) { // SpFX + if (channel[c].spfx != 0xffff) do { // SpFX if(channel[c].fxdel) channel[c].fxdel--; else { channel[c].spfx = LE_WORD(&spfx[channel[c].spfx].ptr); + if (channel[c].spfx == 0xffff || !INDEX_OK(spfx, channel[c].spfx)) { + channel[c].spfx = 0xffff; + break; + } channel[c].fxdel = spfx[channel[c].spfx].duration; channel[c].inst = LE_WORD(&spfx[channel[c].spfx].instnr) & 0xfff; if(spfx[channel[c].spfx].modlev != 0xff) @@ -175,16 +196,16 @@ } channel[c].modvol += spfx[channel[c].spfx].modlevadd; channel[c].modvol &= 63; setvolume(c); - } + } while (0); if(channel[c].levpuls != 0xff) { // Levelpuls if(channel[c].frameskip) channel[c].frameskip--; - else { + else if (INDEX_OK(inst, channel[c].inst)) { channel[c].frameskip = inst[channel[c].inst].timer; if(channel[c].fxdel) channel[c].fxdel--; - else { + else if (INDEX_OK(levpuls, channel[c].levpuls)) { channel[c].levpuls = levpuls[channel[c].levpuls].ptr - 1; channel[c].fxdel = levpuls[channel[c].levpuls].duration; if(levpuls[channel[c].levpuls].level != 0xff) @@ -229,25 +250,38 @@ continue; } readorder: // process arrangement (orderlist) + if (!INDEX_OK(channel[c].order, channel[c].ordpos)) { + channel[c].seqend = 1; continue; + } ord = LE_WORD(&channel[c].order[channel[c].ordpos]); switch(ord) { case 0xfffe: channel[c].seqend = 1; continue; // end of arrangement stream case 0xffff: // jump to order - channel[c].ordpos = LE_WORD(&channel[c].order[channel[c].ordpos + 1]); channel[c].seqend = 1; + if (!INDEX_OK(channel[c].order, channel[c].ordpos + 1)) continue; + channel[c].ordpos = LE_WORD(&channel[c].order[channel[c].ordpos + 1]); goto readorder; default: if(ord >= 0x9000) { // set speed channel[c].speed = ord & 0xff; - ord = LE_WORD(&channel[c].order[channel[c].ordpos - 1]); + if (channel[c].ordpos > 0) + ord = LE_WORD(&channel[c].order[channel[c].ordpos - 1]); + else + ord = 0; channel[c].ordpos++; } else if(ord >= 0x8000) { // transpose track channel[c].transpose = ord & 0xff; if(ord & 0x100) channel[c].transpose = -channel[c].transpose; + if (!INDEX_OK(channel[c].order, channel[c].ordpos + 1)) { + channel[c].seqend = 1; continue; + } ord = LE_WORD(&channel[c].order[++channel[c].ordpos]); } + if (!INDEX_OK(seqptr, ord) || LE_WORD(&seqptr[ord]) + 2U > filesize) { + channel[c].seqend = 1; continue; + } patt = (unsigned short *)((char *)filedata + LE_WORD(&seqptr[ord])); break; } @@ -255,7 +289,8 @@ readseq: // process sequence (pattern) if(!version) // v0: always initialize rhcnt channel[c].rhcnt = channel[c].irhcnt; - pattpos = LE_WORD(&patt[channel[c].pattpos]); + pattpos = INDEX_OK(patt, channel[c].pattpos) ? + LE_WORD(&patt[channel[c].pattpos]) : 0xffff; if(pattpos == 0xffff) { // pattern ended? channel[c].pattpos = 0; channel[c].ordpos++; @@ -265,7 +300,9 @@ note = LOBYTE(pattpos); fx = pattpos >> 12; fxop = pattpos & 0x0fff; - channel[c].pattpos++; pattpos = LE_WORD(&patt[channel[c].pattpos]); + channel[c].pattpos++; + pattpos = INDEX_OK(patt, channel[c].pattpos) ? + LE_WORD(&patt[channel[c].pattpos]) : 0; channel[c].nextnote = LOBYTE(pattpos) & 0x7f; if(version ? cnt < 0x40 : !fx) { // note event switch(note) { @@ -295,7 +332,8 @@ note += channel[c].transpose; channel[c].note = note; // remember note for SpFX - if(channel[c].ispfx != 0xffff && cnt < 0x20) { // reset SpFX + if (channel[c].ispfx != 0xffff && cnt < 0x20 && + INDEX_OK(spfx, channel[c].ispfx)) { // reset SpFX channel[c].spfx = channel[c].ispfx; if(LE_WORD(&spfx[channel[c].spfx].instnr) & 0x8000) // locked frequency note = spfx[channel[c].spfx].halfnote; @@ -309,7 +347,9 @@ channel[c].modvol = inst[channel[c].inst].data[7] & 63; } - if(channel[c].ilevpuls != 0xff && cnt < 0x20) { // reset LevelPuls + if (channel[c].ilevpuls != 0xff && cnt < 0x20 && + INDEX_OK(levpuls, channel[c].ilevpuls) && + INDEX_OK(inst, channel[c].inst)) { // reset LevelPuls channel[c].levpuls = channel[c].ilevpuls; channel[c].fxdel = levpuls[channel[c].levpuls].duration; channel[c].frameskip = inst[channel[c].inst].timer; @@ -376,6 +416,11 @@ channel[c].ispfx = 0xffff; channel[c].spfx = 0xffff; channel[c].inst = fxop; + if (!INDEX_OK(inst, fxop)) { + channel[c].modvol = 0; + channel[c].levpuls = channel[c].ilevpuls = 0xff; + break; + } channel[c].modvol = inst[fxop].data[7] & 63; if(version < 3 && version && inst[fxop].tunelev) // Set LevelPuls channel[c].ilevpuls = inst[fxop].tunelev - 1; @@ -411,41 +456,38 @@ struct Stpoin { unsigned short ptr[9]; unsigned char volume[9],dummy[5]; - } *tpoin; - int i; + } tpoin; - if(subsong == -1) subsong = cursubsong; + if(subsong < 0) subsong = cursubsong; - if(version > 1) { // do nothing if subsong > number of subsongs - if(subsong >= header->subsongs) - return; - } else - if(subsong >= header1->subsongs) - return; - - memset(channel,0,sizeof(channel)); - if(version > 1) - tpoin = (struct Stpoin *)((char *)filedata + LE_WORD(&header->tpoin)); + size_t dataofs = subsong * sizeof(Stpoin) + + LE_WORD(&(version > 1 ? header->tpoin : header1->tpoin)); + if (subsong < getsubsongs() && dataofs + sizeof(Stpoin) <= filesize) + memcpy(&tpoin, filedata + dataofs, sizeof(Stpoin)); else - tpoin = (struct Stpoin *)((char *)filedata + LE_WORD(&header1->tpoin)); - for(i=0;i<9;i++) { - if(LE_WORD(&tpoin[subsong].ptr[i])) { // track enabled + memset(&tpoin, 0, sizeof(Stpoin)); + + memset(channel, 0, sizeof(channel)); + + for (int i = 0; i < 9; i++) { + if (LE_WORD(&tpoin.ptr[i]) && // track enabled + LE_WORD(&tpoin.ptr[i]) + 4U <= filesize) { channel[i].speed = LE_WORD((unsigned short *) - ((char *)filedata + LE_WORD(&tpoin[subsong].ptr[i]))); + ((char *)filedata + LE_WORD(&tpoin.ptr[i]))); channel[i].order = (unsigned short *) - ((char *)filedata + LE_WORD(&tpoin[subsong].ptr[i]) + 2); + ((char *)filedata + LE_WORD(&tpoin.ptr[i]) + 2); } else { // track disabled channel[i].speed = 0; channel[i].order = 0; } channel[i].ispfx = 0xffff; channel[i].spfx = 0xffff; // no SpFX channel[i].ilevpuls = 0xff; channel[i].levpuls = 0xff; // no LevelPuls - channel[i].cvol = tpoin[subsong].volume[i] & 0x7f; // our player may savely ignore bit 7 + channel[i].cvol = tpoin.volume[i] & 0x7f; // our player may savely ignore bit 7 channel[i].vol = channel[i].cvol; // initialize volume } songend = 0; opl->init(); opl->write(1,32); // reset OPL chip - cursubsong = subsong; + cursubsong = subsong > 0xff ? 0xff : subsong; } std::string Cd00Player::gettype() @@ -478,6 +520,7 @@ { unsigned char op = op_table[chan]; unsigned short insnr = channel[chan].inst; + if (!INDEX_OK(inst, insnr)) return; opl->write(0x43 + op,(int)(63-((63-(inst[insnr].data[2] & 63))/63.0)*(63-channel[chan].vol)) + (inst[insnr].data[2] & 192)); @@ -492,7 +535,8 @@ { unsigned short freq = channel[chan].freq; - if(version == 4) // v4: apply instrument finetune + if (version == 4 && // v4: apply instrument finetune + INDEX_OK(inst, channel[chan].inst)) freq += inst[channel[chan].inst].tunelev; freq += channel[chan].slideval; @@ -507,6 +551,7 @@ { unsigned char op = op_table[chan]; unsigned short insnr = channel[chan].inst; + if (!INDEX_OK(inst, insnr)) return; // set instrument data opl->write(0x63 + op, inst[insnr].data[0]); diff -Nru adplug-2.3.1+dfsg/src/d00.h adplug-2.3.3+dfsg/src/d00.h --- adplug-2.3.1+dfsg/src/d00.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/d00.h 2020-05-12 00:01:00.000000000 +0000 @@ -97,6 +97,7 @@ d00header *header; d00header1 *header1; char *filedata; + unsigned long filesize; private: void setvolume(unsigned char chan); diff -Nru adplug-2.3.1+dfsg/src/dfm.cpp adplug-2.3.3+dfsg/src/dfm.cpp --- adplug-2.3.1+dfsg/src/dfm.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/dfm.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -47,9 +47,16 @@ restartpos = 0; flags = Standard; bpm = 0; init_trackord(); f->readString(songinfo, 33); + if (*songinfo > 32 || *songinfo < 0) { + fp.close(f); return false; + } initspeed = f->readInt(1); - for(i = 0; i < 32; i++) + for(i = 0; i < 32; i++) { f->readString(instname[i], 12); + if (*instname[i] > 11 || *instname[i] < 0) { + fp.close(f); return false; + } + } for(i = 0; i < 32; i++) { inst[i].data[1] = f->readInt(1); inst[i].data[2] = f->readInt(1); @@ -68,8 +75,14 @@ ; length = i; npats = f->readInt(1); + if (npats > 64) { + fp.close(f); return false; // or: realloc_patterns(npats, 64, 9); + } for(i = 0; i < npats; i++) { n = f->readInt(1); + if (n >= npats) { + fp.close(f); return false; + } for(r = 0; r < 64; r++) for(c = 0; c < 9; c++) { note = f->readInt(1); diff -Nru adplug-2.3.1+dfsg/src/dfm.h adplug-2.3.3+dfsg/src/dfm.h --- adplug-2.3.1+dfsg/src/dfm.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/dfm.h 2020-05-12 00:01:00.000000000 +0000 @@ -37,9 +37,9 @@ unsigned int getinstruments() { return 32; }; std::string getinstrument(unsigned int n) - { if(*instname[n]) return std::string(instname[n],1,*instname[n]); else return std::string(); }; + { if (n < 32 && *instname[n]) return std::string(instname[n] + 1, *instname[n]); else return std::string(); }; std::string getdesc() - { return std::string(songinfo,1,*songinfo); }; + { return std::string(songinfo + 1, *songinfo); }; private: struct { diff -Nru adplug-2.3.1+dfsg/src/dmo.cpp adplug-2.3.3+dfsg/src/dmo.cpp --- adplug-2.3.1+dfsg/src/dmo.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/dmo.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -243,8 +243,8 @@ ax = LOWORD(bseed); bx = HIWORD(bseed); cx = ax; - ax = LOWORD(cx * 0x8405); - dx = HIWORD(cx * 0x8405); + ax = LOWORD(cx * 0x8405U); + dx = HIWORD(cx * 0x8405U); cx <<= 3; cx = (((HIBYTE(cx) + LOBYTE(cx)) & 0xFF) << 8) + LOBYTE(cx); dx += cx; diff -Nru adplug-2.3.1+dfsg/src/dro2.cpp adplug-2.3.3+dfsg/src/dro2.cpp --- adplug-2.3.1+dfsg/src/dro2.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/dro2.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -64,7 +64,13 @@ return false; } - this->iLength = f->readInt(4) * 2; // stored in file as number of byte pairs + this->iLength = f->readInt(4); // should better use an unsigned type + if (this->iLength <= 0 || this->iLength >= 1<<30 || + this->iLength > fp.filesize(f) - f->pos()) { + fp.close(f); + return false; + } + this->iLength *= 2; // stored in file as number of byte p f->ignore(4); // Length in milliseconds f->ignore(1); /// OPL type (0 == OPL2, 1 == Dual OPL2, 2 == OPL3) int iFormat = f->readInt(1); @@ -157,7 +163,7 @@ } else { this->opl->setchip(0); } - if (iIndex > this->iConvTableLen) { + if (iIndex >= this->iConvTableLen) { printf("DRO2: Error - index beyond end of codemap table! Corrupted .dro?\n"); return false; // EOF } diff -Nru adplug-2.3.1+dfsg/src/dro.cpp adplug-2.3.3+dfsg/src/dro.cpp --- adplug-2.3.1+dfsg/src/dro.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/dro.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -73,6 +73,10 @@ f->ignore(4); // Length in milliseconds this->iLength = f->readInt(4); // stored in file as number of bytes + if (this->iLength < 3 || this->iLength > fp.filesize(f) - f->pos()) { + fp.close(f); + return false; + } this->data = new uint8_t[this->iLength]; @@ -150,12 +154,14 @@ // Short delay if (iIndex == this->iCmdDelayS) { + if (this->iPos >= this->iLength) return false; iValue = this->data[this->iPos++]; this->iDelay = iValue + 1; return true; // Long delay } else if (iIndex == this->iCmdDelayL) { + if (this->iPos + 1 >= this->iLength) return false; iValue = this->data[this->iPos] | (this->data[this->iPos + 1] << 8); this->iPos += 2; this->iDelay = (iValue + 1); @@ -168,8 +174,10 @@ // Normal write } else { if (iIndex == 0x04) { + if (this->iPos+1 >= this->iLength) return false; iIndex = this->data[this->iPos++]; } + else if (this->iPos >= this->iLength) return false; iValue = this->data[this->iPos++]; this->opl->write(iIndex, iValue); } diff -Nru adplug-2.3.1+dfsg/src/dtm.cpp adplug-2.3.3+dfsg/src/dtm.cpp --- adplug-2.3.1+dfsg/src/dtm.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/dtm.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -42,19 +42,24 @@ // read header f->readString(header.id, 12); header.version = f->readInt(1); - f->readString(header.title, 20); f->readString(header.author, 20); - header.numpat = f->readInt(1); header.numinst = f->readInt(1); + f->readString(header.title, 20); + f->readString(header.author, 20); + // Ensure title and author are NUL terminated. We may overwrite the + // last character because the arrays are too short. + header.author[19] = header.title[19] = 0; + header.numpat = f->readInt(1); + header.numinst = f->readInt(1) + 1; // signature exists ? good version ? - if(memcmp(header.id,"DeFy DTM ",9) || header.version != 0x10) + if (memcmp(header.id, "DeFy DTM ", 9) || header.version != 0x10 || + header.numinst > sizeof(instruments) / sizeof(instruments[0]) || + f->error()) { fp.close (f); return false; } - header.numinst++; - // load description memset(desc,0,80*16); - char bufstr[80]; + char *bufstr = desc; for (i=0;i<16;i++) { @@ -62,10 +67,18 @@ unsigned char bufstr_length = f->readInt(1); if(bufstr_length > 80) { + // "desc" is too small to hold 16 lines with 80 chars each plus + // 16 newlines an a NUL terminator. Accept a line length of 80 + // anyway and truncate the last line if necessary. + // Maybe we should grow desc or allocate it dynamically instead. fp.close(f); return false; } + int max_length = desc + sizeof(desc) - 1 - bufstr; + int discard = bufstr_length > max_length ? bufstr_length - max_length : 0; + bufstr_length -= discard; + // read line if (bufstr_length) { @@ -74,14 +87,15 @@ for (j=0;jignore(discard); } - - strcat(desc,"\n"); + if (bufstr_length < max_length) + *(bufstr++) = '\n'; } + *bufstr = 0; // init CmodPlayer realloc_instruments(header.numinst); @@ -130,7 +144,7 @@ delete [] packed_pattern; - if (!unpacked_length) + if (unpacked_length != 0x480) { delete [] pattern; fp.close(f); @@ -206,6 +220,11 @@ } delete [] pattern; + if (f->error()) + { + fp.close(f); + return false; + } fp.close(f); // order length @@ -273,7 +292,7 @@ std::string CdtmLoader::getinstrument(unsigned int n) { - return std::string(instruments[n].name); + return n < header.numinst ? std::string(instruments[n].name) : std::string(); } unsigned int CdtmLoader::getinstruments() @@ -301,6 +320,8 @@ if ((repeat_byte & 0xF0) == 0xD0) { repeat_counter = repeat_byte & 15; + if (input_length == ilen) + return output_length; // truncated input repeat_byte = input[input_length++]; } else diff -Nru adplug-2.3.1+dfsg/src/emuopl.cpp adplug-2.3.3+dfsg/src/emuopl.cpp --- adplug-2.3.1+dfsg/src/emuopl.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/emuopl.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -39,6 +39,7 @@ if(mixbufSamples) { delete [] mixbuf0; delete [] mixbuf1; + delete [] mixbuf2; } } @@ -48,12 +49,13 @@ //ensure that our mix buffers are adequately sized if(mixbufSamples < samples) { - if(mixbufSamples) { delete[] mixbuf0; delete[] mixbuf1; } + if(mixbufSamples) { delete[] mixbuf0; delete[] mixbuf1; delete[] mixbuf2; } mixbufSamples = samples; //*2 = make room for stereo, if we need it mixbuf0 = new short[samples*2]; mixbuf1 = new short[samples*2]; + mixbuf2 = new short[samples*2]; } //data should be rendered to outbuf @@ -68,9 +70,7 @@ short *tempbuf=mixbuf0; short *tempbuf2=mixbuf1; if(use16bit) outbuf = buf; - else outbuf = mixbuf1; - //...there is a potentially confusing situation where mixbuf1 can be aliased. - //beware. it is a little loony. + else outbuf = mixbuf2; //all of the following rendering code produces 16bit output diff -Nru adplug-2.3.1+dfsg/src/emuopl.h adplug-2.3.3+dfsg/src/emuopl.h --- adplug-2.3.1+dfsg/src/emuopl.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/emuopl.h 2020-05-12 00:01:00.000000000 +0000 @@ -42,7 +42,7 @@ private: bool use16bit, stereo; FM_OPL *opl[2]; // OPL2 emulator data - short *mixbuf0, *mixbuf1; + short *mixbuf0, *mixbuf1, *mixbuf2; int mixbufSamples; }; diff -Nru adplug-2.3.1+dfsg/src/fmc.cpp adplug-2.3.3+dfsg/src/fmc.cpp --- adplug-2.3.1+dfsg/src/fmc.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/fmc.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -39,10 +39,14 @@ // read header f->readString(header.id, 4); f->readString(header.title, 21); + header.title[20] = 0; header.numchan = f->readInt(1); // 'FMC!' - signed ? - if (strncmp(header.id,"FMC!",4)) { fp.close(f); return false; } + if (memcmp(header.id, "FMC!", 4) || + header.numchan < 1 || header.numchan > 32) { + fp.close(f); return false; + } // init CmodPlayer realloc_instruments(32); @@ -89,6 +93,7 @@ instruments[i].pitch_shift = f->readInt(1); f->readString(instruments[i].name, 21); + instruments[i].name[20] = 0; } // load tracks @@ -151,7 +156,7 @@ } // data for Protracker - activechan = (0xffffffff >> (32 - header.numchan)) << (32 - header.numchan); + activechan = (0xffffffffUL >> (32 - header.numchan)) << (32 - header.numchan); nop = t / header.numchan; restartpos = 0; @@ -180,7 +185,7 @@ std::string CfmcLoader::getinstrument(unsigned int n) { - return std::string(instruments[n].name); + return n < 32 ? std::string(instruments[n].name) : std::string(); } unsigned int CfmcLoader::getinstruments() diff -Nru adplug-2.3.1+dfsg/src/fmopl.c adplug-2.3.3+dfsg/src/fmopl.c --- adplug-2.3.1+dfsg/src/fmopl.c 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/fmopl.c 2020-05-11 23:53:51.000000000 +0000 @@ -1269,6 +1269,10 @@ /* ---------- Destroy one of vietual YM3812 ---------- */ void OPLDestroy(FM_OPL *OPL) { + if(!OPL) + { + return; + } #ifdef OPL_OUTPUT_LOG if(opl_dbg_fp) { diff -Nru adplug-2.3.1+dfsg/src/got.h adplug-2.3.3+dfsg/src/got.h --- adplug-2.3.1+dfsg/src/got.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/got.h 2020-05-12 00:01:00.000000000 +0000 @@ -56,6 +56,11 @@ return std::string("God of Thunder Music"); } + unsigned int getspeed() + { + return (int)rate; + } + protected: unsigned long pos, size; unsigned short del; diff -Nru adplug-2.3.1+dfsg/src/herad.cpp adplug-2.3.3+dfsg/src/herad.cpp --- adplug-2.3.1+dfsg/src/herad.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/herad.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -1,4 +1,4 @@ -/* +/* * Adplug - Replayer for many OPL2/OPL3 audio file formats. * Copyright (C) 1999 - 2008 Simon Peter , et al. * @@ -37,6 +37,7 @@ #include #include "herad.h" +#include "load_helper.h" #ifdef DEBUG #include "debug.h" @@ -86,7 +87,10 @@ #endif return false; } - if ( *(uint16_t *)(data + 3) != size ) + + const uint16_t temp_size = u16_unaligned(data + 3); + + if ( temp_size != size ) { #ifdef DEBUG AdPlug_LogWrite("HERAD: Is not HSQ, wrong compressed size.\n"); @@ -148,7 +152,7 @@ // get next bit of the queue if (queue == 1) { - queue = *(uint16_t *)src | 0x10000; + queue = u16_unaligned(src) | 0x10000; src += 2; } bit = queue & 1; @@ -164,7 +168,7 @@ // get next bit of the queue if (queue == 1) { - queue = *(uint16_t *)src | 0x10000; + queue = u16_unaligned(src) | 0x10000; src += 2; } bit = queue & 1; @@ -174,7 +178,7 @@ { // count = next 3 bits of the input // offset = next 13 bits of the input minus 8192 - count = *(uint16_t *)src; + count = u16_unaligned(src); offset = (count >> 3) - 8192; count &= 7; src += 2; @@ -194,7 +198,7 @@ // count = next bit of the queue * 2 + next bit of the queue if (queue == 1) { - queue = *(uint16_t *)src | 0x10000; + queue = u16_unaligned(src) | 0x10000; src += 2; } bit = queue & 1; @@ -202,7 +206,7 @@ count = bit << 1; if (queue == 1) { - queue = *(uint16_t *)src | 0x10000; + queue = u16_unaligned(src) | 0x10000; src += 2; } bit = queue & 1; @@ -233,7 +237,7 @@ uint8_t * dst = out; bool done = false; - *(uint16_t *)dst = *(uint16_t *)src; + std::memcpy(dst, src, sizeof(uint16_t)); src += 6; uint16_t queue = 1; uint8_t bit, bit_p; @@ -243,7 +247,7 @@ queue >>= 1; if (queue == 0) { - queue = *(uint16_t *)src; + queue = u16_unaligned(src); src += 2; bit_p = bit; bit = queue & 1; @@ -264,7 +268,7 @@ queue >>= 1; if (queue == 0) { - queue = *(uint16_t *)src; + queue = u16_unaligned(src); src += 2; bit_p = bit; bit = queue & 1; @@ -282,7 +286,7 @@ queue >>= 1; if (queue == 0) { - queue = *(uint16_t *)src; + queue = u16_unaligned(src); src += 2; bit_p = bit; bit = queue & 1; @@ -303,7 +307,7 @@ } break; case 2: - count = *(uint16_t *)src; + count = u16_unaligned(src); offset = (count >> data[5]) - (1 << (16 - data[5])); count &= (1 << data[5]) - 1; src += 2; @@ -335,7 +339,7 @@ queue >>= 1; if (queue == 0) { - queue = *(uint16_t *)src; + queue = u16_unaligned(src); src += 2; bit_p = bit; bit = queue & 1; @@ -356,7 +360,7 @@ queue >>= 1; if (queue == 0) { - queue = *(uint16_t *)src; + queue = u16_unaligned(src); src += 2; bit_p = bit; bit = queue & 1; @@ -374,7 +378,7 @@ queue >>= 1; if (queue == 0) { - queue = *(uint16_t *)src; + queue = u16_unaligned(src); src += 2; bit_p = bit; bit = queue & 1; @@ -395,7 +399,7 @@ } break; case 2: - count = *(uint16_t *)src; + count = u16_unaligned(src); offset = (count >> data[5]) - (1 << (16 - data[5])); count &= (1 << data[5]) - 1; src += 2; @@ -434,7 +438,7 @@ queue >>= 1; if (queue == 0) { - queue = *(uint16_t *)src; + queue = u16_unaligned(src); src += 2; bit_p = bit; bit = queue & 1; @@ -452,7 +456,7 @@ queue >>= 1; if (queue == 0) { - queue = *(uint16_t *)src; + queue = u16_unaligned(src); src += 2; bit_p = bit; bit = queue & 1; @@ -473,7 +477,7 @@ } break; case 2: - count = *(uint16_t *)src; + count = u16_unaligned(src); offset = (count >> data[5]) - (1 << (16 - data[5])); count &= (1 << data[5]) - 1; src += 2; diff -Nru adplug-2.3.1+dfsg/src/herad.h adplug-2.3.3+dfsg/src/herad.h --- adplug-2.3.1+dfsg/src/herad.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/herad.h 2020-05-11 23:53:51.000000000 +0000 @@ -1,4 +1,4 @@ -/* +/* * Adplug - Replayer for many OPL2/OPL3 audio file formats. * Copyright (C) 1999 - 2005 Simon Peter , et al. * diff -Nru adplug-2.3.1+dfsg/src/hybrid.cpp adplug-2.3.3+dfsg/src/hybrid.cpp --- adplug-2.3.1+dfsg/src/hybrid.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/hybrid.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -193,8 +193,10 @@ // is slide ? if (slide) { - hyb.channel[i].freq_slide = (((slide >> 3) * -1) * (slide & 7)) << 1; - + // Looks bogus. Should values 0..8 really result + // in 0 or is bit 3 supposed to be a sign? + hyb.channel[i].freq_slide = -(slide >> 3) * (slide & 7) * 2; + // And this statement is dead anyway. if (slide & 0x80) slide = -(slide & 7); } diff -Nru adplug-2.3.1+dfsg/src/imf.cpp adplug-2.3.3+dfsg/src/imf.cpp --- adplug-2.3.1+dfsg/src/imf.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/imf.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -89,6 +89,10 @@ else fsize = f->readInt(2); flsize = fp.filesize(f); + if (mfsize + 4 > flsize || fsize >= flsize - 2 - mfsize || fsize & 3) { + fp.close(f); // truncated file or bad size record + return false; + } if(!fsize) { // footerless file (raw music data) if(mfsize) f->seek(-4, binio::Add); diff -Nru adplug-2.3.1+dfsg/src/jbm.h adplug-2.3.3+dfsg/src/jbm.h --- adplug-2.3.1+dfsg/src/jbm.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/jbm.h 2020-05-12 00:01:00.000000000 +0000 @@ -29,10 +29,10 @@ public: static CPlayer *factory(Copl *newopl); - CjbmPlayer(Copl *newopl) : CPlayer(newopl), m(0) + CjbmPlayer(Copl *newopl) : CPlayer(newopl), m(0), sequences(0) { } ~CjbmPlayer() - { if(m != NULL) delete [] m; } + { delete[] sequences; delete[] m; } bool load(const std::string &filename, const CFileProvider &fp); bool update(); diff -Nru adplug-2.3.1+dfsg/src/kemuopl.h adplug-2.3.3+dfsg/src/kemuopl.h --- adplug-2.3.1+dfsg/src/kemuopl.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/kemuopl.h 2020-05-12 00:01:00.000000000 +0000 @@ -32,7 +32,7 @@ { public: CKemuopl(int rate, bool bit16, bool usestereo) - : use16bit(bit16), stereo(usestereo) + : use16bit(bit16), stereo(usestereo), sampleerate(rate) { adlibinit(rate, usestereo ? 2 : 1, bit16 ? 2 : 1); currType = TYPE_OPL2; @@ -52,10 +52,14 @@ adlib0(reg, val); }; - void init() {}; + void init() { + adlibinit(sampleerate, stereo ? 2 : 1, use16bit ? 2 : 1); + currChip = 0; + }; private: bool use16bit,stereo; + int sampleerate; }; #endif diff -Nru adplug-2.3.1+dfsg/src/load_helper.h adplug-2.3.3+dfsg/src/load_helper.h --- adplug-2.3.1+dfsg/src/load_helper.h 1970-01-01 00:00:00.000000000 +0000 +++ adplug-2.3.3+dfsg/src/load_helper.h 2020-05-12 00:01:00.000000000 +0000 @@ -0,0 +1,58 @@ +#ifndef ADPLUG_LOAD_HELPER_H +#define ADPLUG_LOAD_HELPER_H + +#include +#include + +inline uint16_t adplug_byteswap(const uint16_t val) +{ + return + ((val & 0x00FF) << 8) | + ((val & 0xFF00) >> 8); +} + +inline uint32_t adplug_byteswap(const uint32_t val) +{ + return + ((val & 0x000000FF) << 24) | + ((val & 0x0000FF00) << 8) | + ((val & 0x00FF0000) >> 8) | + ((val & 0xFF000000) >> 24); +} + +// In many cases, we need to load a uint16_t/uint32_t from a (possibly) +// unaligned byte stream. In order to avoid undefined behavior, we have to use +// memcpy as the only portable way to perform type punning. See: +// https://blog.regehr.org/archives/959 +template +static inline T load_unaligned_impl(const unsigned char* src, const bool big_endian) +{ + T result; + std::memcpy(&result, src, sizeof(T)); + +#ifdef WORDS_BIGENDIAN + // big-endian CHOST + if (!big_endian) +#else + // little-endian CHOST + if (big_endian) +#endif + { + // have to do a byte-swap + result = adplug_byteswap(result); + } + + return result; +} + +inline uint16_t u16_unaligned(const unsigned char* src, const bool big_endian = false) +{ + return load_unaligned_impl(src, big_endian); +} + +inline uint32_t u32_unaligned(const unsigned char* src, const bool big_endian = false) +{ + return load_unaligned_impl(src, big_endian); +} + +#endif // ADPLUG_LOAD_HELPER_H diff -Nru adplug-2.3.1+dfsg/src/mdi.h adplug-2.3.3+dfsg/src/mdi.h --- adplug-2.3.1+dfsg/src/mdi.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/mdi.h 2020-05-12 00:01:00.000000000 +0000 @@ -73,7 +73,7 @@ ~CmdiPlayer() { if(data) delete [] data; - if (drv) drv->~CadlibDriver(); + if (drv) delete drv; }; bool load(const std::string &filename, const CFileProvider &fp); diff -Nru adplug-2.3.1+dfsg/src/mid.cpp adplug-2.3.3+dfsg/src/mid.cpp --- adplug-2.3.1+dfsg/src/mid.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/mid.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -81,6 +81,7 @@ #include #include "mid.h" #include "mididata.h" +#include "load_helper.h" /*#define TESTING*/ #ifdef TESTING @@ -202,7 +203,9 @@ j = i+1; break; } - sprintf(pfilename+j+3,"patch.003"); + for (i = 0; i < 3; i++) + if (pfilename[j]) j++; + sprintf(pfilename+j,"patch.003"); f = fp.open(pfilename); free(pfilename); @@ -300,7 +303,7 @@ uint32_t size; f->readString((char *)s, 6); - size = *(uint32_t *)s; // size of FILE_OLDLUCAS + size = u32_unaligned(s); // size of FILE_OLDLUCAS good=0; subsongs=0; switch(s[0]) @@ -662,7 +665,7 @@ break; case 0xc0: /*patch change*/ x=getnext(1); - ch[c].inum=x; + ch[c].inum = x & 0x7f; for (j=0; j<11; j++) ch[c].ins[j]=myinsbank[ch[c].inum][j]; break; @@ -697,24 +700,34 @@ midiprintf ("\n"); getnext(1); getnext(1); - c=getnext(1); + c = getnext(1) & 0x0f; getnext(1); // getnext(22); //temp - ch[c].ins[0]=(unsigned char)((getnext(1)<<4)+getnext(1)); - ch[c].ins[2]=(unsigned char)(0xff-(((getnext(1)<<4)+getnext(1))&0x3f)); - ch[c].ins[4]=(unsigned char)(0xff-((getnext(1)<<4)+getnext(1))); - ch[c].ins[6]=(unsigned char)(0xff-((getnext(1)<<4)+getnext(1))); - ch[c].ins[8]=(unsigned char)((getnext(1)<<4)+getnext(1)); - - ch[c].ins[1]=(unsigned char)((getnext(1)<<4)+getnext(1)); - ch[c].ins[3]=(unsigned char)(0xff-(((getnext(1)<<4)+getnext(1))&0x3f)); - ch[c].ins[5]=(unsigned char)(0xff-((getnext(1)<<4)+getnext(1))); - ch[c].ins[7]=(unsigned char)(0xff-((getnext(1)<<4)+getnext(1))); - ch[c].ins[9]=(unsigned char)((getnext(1)<<4)+getnext(1)); + unsigned char tmp; + tmp = getnext(1) << 4; + ch[c].ins[0] = tmp + getnext(1); + tmp = getnext(1) << 4; + ch[c].ins[2] = 0xff - ((tmp + getnext(1)) & 0x3f); + tmp = getnext(1) << 4; + ch[c].ins[4] = 0xff - (tmp + getnext(1)); + tmp = getnext(1) << 4; + ch[c].ins[6] = 0xff-(tmp + getnext(1)); + tmp = getnext(1) << 4; + ch[c].ins[8] = tmp + getnext(1); + tmp = getnext(1) << 4; + ch[c].ins[1] = tmp + getnext(1); + tmp = getnext(1) << 4; + ch[c].ins[3] = 0xff - ((tmp + getnext(1)) & 0x3f); + tmp = getnext(1) << 4; + ch[c].ins[5] = 0xff - (tmp + getnext(1)); + tmp = getnext(1) << 4; + ch[c].ins[7] = 0xff - (tmp + getnext(1)); + tmp = getnext(1) << 4; + ch[c].ins[9] = tmp + getnext(1); - i=(getnext(1)<<4)+getnext(1); - ch[c].ins[10]=i; + i = getnext(1) << 4; + ch[c].ins[10] = (i += getnext(1)); //if ((i&1)==1) ch[c].ins[10]=1; @@ -884,7 +897,7 @@ for (i=0; i<128; i++) for (j=0; j<14; j++) myinsbank[i][j]=midi_fm_instruments[i][j]; - for (i=0; i<16; i++) + for (i=0; i<16; i++) { ch[i].inum=0; for (j=0; j<11; j++) @@ -949,15 +962,21 @@ n=getnexti(2); // instrument offset m=getnexti(2); // music offset deltas=getnexti(2); //ticks/qtr note - msqtr=1000000/getnexti(2)*deltas; - //the stuff in the cmf is click ticks per second.. + i = getnexti(2); // stuff in cmf is click ticks per second.. + if (i) msqtr = 1000000L / i * deltas; i=getnexti(2); - if(i) title = (char *)data+i; + if (i > 0 && i < flen && + strnlen((char *)data + i, flen - i) < flen - i) + title = (char *)data + i; i=getnexti(2); - if(i) author = (char *)data+i; + if (i > 0 && i < flen && + strnlen((char *)data + i, flen - i) < flen - i) + author = (char *)data + i; i=getnexti(2); - if(i) remarks = (char *)data+i; + if (i > 0 && i < flen && + strnlen((char *)data + i, flen - i) < flen - i) + remarks = (char *)data + i; getnext(16); // channel in use table .. i=getnexti(2); // num instr @@ -1076,7 +1095,7 @@ { ch[i].nshift=-13; ch[i].on=getnext(1); - ch[i].inum=getnext(1); + ch[i].inum = getnext(1) & 0x7f; for (j=0; j<11; j++) ch[i].ins[j]=myinsbank[ch[i].inum][j]; } diff -Nru adplug-2.3.1+dfsg/src/mkj.cpp adplug-2.3.3+dfsg/src/mkj.cpp --- adplug-2.3.1+dfsg/src/mkj.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/mkj.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -36,7 +36,6 @@ char id[6]; float ver; int i, j; - short inst[8]; // file validation f->readString(id, 6); @@ -46,24 +45,35 @@ // load maxchannel = f->readInt(2); - opl->init(); opl->write(1, 32); + if (maxchannel > 9 || maxchannel < 0) { + fp.close(f); + return false; + } + // load and store the channel instruments. for(i = 0; i < maxchannel; i++) { - for(j = 0; j < 8; j++) inst[j] = f->readInt(2); - opl->write(0x20+op_table[i],inst[4]); - opl->write(0x23+op_table[i],inst[0]); - opl->write(0x40+op_table[i],inst[5]); - opl->write(0x43+op_table[i],inst[1]); - opl->write(0x60+op_table[i],inst[6]); - opl->write(0x63+op_table[i],inst[2]); - opl->write(0x80+op_table[i],inst[7]); - opl->write(0x83+op_table[i],inst[3]); + for (j = 0; j < 8; j++) { + inst[i].value[j] = f->readInt(2); + } } maxnotes = f->readInt(2); + if (maxnotes < 1 || + // Larger values would need code changes to avoid integer overflows: + maxnotes > 0x7fff / (maxchannel + 1) || + // That's what gets actually accessed in update(): [yeah, it's weird] + maxnotes - 1 + 3 * maxchannel > (maxchannel + 1) * maxnotes) { + fp.close(f); + return false; + } + delete[] songbuf; songbuf = new short [(maxchannel+1)*maxnotes]; for(i = 0; i < maxchannel; i++) channel[i].defined = f->readInt(2); for(i = 0; i < (maxchannel + 1) * maxnotes; i++) songbuf[i] = f->readInt(2); + if (f->error()) { + fp.close(f); + return false; + } AdPlug_LogWrite("CmkjPlayer::load(\"%s\"): loaded file ver %.2f, %d channels," " %d notes/channel.\n", filename.c_str(), ver, maxchannel, maxnotes); @@ -109,18 +119,26 @@ case 15: opl->write(0xa0 + c,0x63); opl->write(0xb0 + c,0x22 + 4 * channel[c].octave); break; case 255: // delay channel[c].songptr += maxchannel; + if (songbuf[channel[c].songptr] < 0) + goto bad_data; // avoid integer overflow channel[c].pstat = songbuf[channel[c].songptr]; break; case 254: // set octave channel[c].songptr += maxchannel; + if ((songbuf[channel[c].songptr] | 7) != 7) + goto bad_data; // value out of range channel[c].octave = songbuf[channel[c].songptr]; break; case 253: // set speed channel[c].songptr += maxchannel; + if (songbuf[channel[c].songptr] < 0) + goto bad_data; // avoid integer overflow channel[c].speed = songbuf[channel[c].songptr]; break; case 252: // set waveform channel[c].songptr += maxchannel; + if ((songbuf[channel[c].songptr] - 300 | 0xff) != 0xff) + goto bad_data; // value out of range channel[c].waveform = songbuf[channel[c].songptr] - 300; if(c > 2) opl->write(0xe0 + c + (c+6),channel[c].waveform); @@ -128,6 +146,7 @@ opl->write(0xe0 + c,channel[c].waveform); break; case 251: // song end + bad_data: for(i = 0; i < maxchannel; i++) channel[i].songptr = i; songend = true; return false; @@ -147,12 +166,22 @@ { int i; + opl->init(); opl->write(1, 32); for(i = 0; i < maxchannel; i++) { channel[i].pstat = 0; channel[i].speed = 0; channel[i].waveform = 0; channel[i].songptr = i; channel[i].octave = 4; + // Set up channel instruments + opl->write(0x20+op_table[i],inst[i].value[4]); + opl->write(0x23+op_table[i],inst[i].value[0]); + opl->write(0x40+op_table[i],inst[i].value[5]); + opl->write(0x43+op_table[i],inst[i].value[1]); + opl->write(0x60+op_table[i],inst[i].value[6]); + opl->write(0x63+op_table[i],inst[i].value[2]); + opl->write(0x80+op_table[i],inst[i].value[7]); + opl->write(0x83+op_table[i],inst[i].value[3]); } songend = false; diff -Nru adplug-2.3.1+dfsg/src/mkj.h adplug-2.3.3+dfsg/src/mkj.h --- adplug-2.3.1+dfsg/src/mkj.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/mkj.h 2020-05-12 00:01:00.000000000 +0000 @@ -47,4 +47,8 @@ struct { short defined,songptr,octave,waveform,pstat,speed,delay; } channel[9]; + struct { + short value[8]; + } inst[9]; + }; diff -Nru adplug-2.3.1+dfsg/src/mtk.cpp adplug-2.3.3+dfsg/src/mtk.cpp --- adplug-2.3.1+dfsg/src/mtk.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/mtk.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -39,6 +39,8 @@ struct mtkdata { char songname[34],composername[34],instname[0x80][34]; unsigned char insts[0x80][12],order[0x80],dummy,patterns[0x32][0x40][9]; + // HSC pattern has different type and size from patterns, but that + // doesn't matter much since we memcpy() the data. Still confusing. } *data; unsigned char *cmp,*org; unsigned int i; @@ -51,8 +53,10 @@ header.size = f->readInt(2); // file validation section - if(strncmp(header.id,"mpu401tr\x92kk\xeer@data",18)) - { fp.close(f); return false; } + if (memcmp(header.id, "mpu401tr\x92kk\xeer@data", 18) || + header.size < sizeof(*data) - sizeof(data->patterns)) { + fp.close(f); return false; + } // load section cmpsize = fp.filesize(f) - 22; @@ -64,6 +68,7 @@ while(cmpptr < cmpsize) { // decompress ctrlmask >>= 1; if(!ctrlmask) { + if (cmpptr + 2 > cmpsize) goto err; ctrlbits = cmp[cmpptr] + (cmp[cmpptr + 1] << 8); cmpptr += 2; ctrlmask = 0x8000; @@ -81,37 +86,40 @@ cmd = (cmp[cmpptr] >> 4) & 0x0f; cnt = cmp[cmpptr] & 0x0f; cmpptr++; + if (cmpptr >= cmpsize) goto err; switch(cmd) { case 0: - if(orgptr + cnt > header.size) goto err; cnt += 3; + if (orgptr + cnt > header.size) goto err; memset(&org[orgptr],cmp[cmpptr],cnt); cmpptr++; orgptr += cnt; break; case 1: - if(orgptr + cnt > header.size) goto err; cnt += (cmp[cmpptr] << 4) + 19; + if (orgptr + cnt > header.size || cmpptr >= cmpsize) goto err; memset(&org[orgptr],cmp[++cmpptr],cnt); cmpptr++; orgptr += cnt; break; case 2: - if(orgptr + cnt > header.size) goto err; + if (cmpptr + 2 > cmpsize) goto err; offs = (cnt+3) + (cmp[cmpptr] << 4); cnt = cmp[++cmpptr] + 16; cmpptr++; + if (orgptr + cnt > header.size || offs > orgptr) goto err; memcpy(&org[orgptr],&org[orgptr - offs],cnt); orgptr += cnt; break; default: - if(orgptr + cmd > header.size) goto err; offs = (cnt+3) + (cmp[cmpptr++] << 4); + if (orgptr + cmd > header.size || offs > orgptr) goto err; memcpy(&org[orgptr],&org[orgptr-offs],cmd); orgptr += cmd; break; } } + // orgptr should match header.size; add a check? delete [] cmp; data = (struct mtkdata *) org; @@ -123,12 +131,14 @@ strncpy(instname[i],data->instname[i]+1,33); memcpy(instr,data->insts,0x80 * 12); memcpy(song,data->order,0x80); - memcpy(patterns,data->patterns,header.size-6084); for (i=0;i<128;i++) { // correct instruments instr[i][2] ^= (instr[i][2] & 0x40) << 1; instr[i][3] ^= (instr[i][3] & 0x40) << 1; instr[i][11] >>= 4; // make unsigned } + cnt = header.size - (sizeof(*data) - sizeof(data->patterns)); // was off by 1 + if (cnt > sizeof(patterns)) cnt = sizeof(patterns); // fail? + memcpy(patterns, data->patterns, cnt); delete [] org; rewind(0); diff -Nru adplug-2.3.1+dfsg/src/mtk.h adplug-2.3.3+dfsg/src/mtk.h --- adplug-2.3.1+dfsg/src/mtk.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/mtk.h 2020-05-12 00:01:00.000000000 +0000 @@ -43,7 +43,7 @@ unsigned int getinstruments() { return 128; }; std::string getinstrument(unsigned int n) - { return std::string(instname[n]); }; + { return n < 128 ? std::string(instname[n]) : std::string(); }; private: char title[34],composer[34],instname[0x80][34]; diff -Nru adplug-2.3.1+dfsg/src/mus.h adplug-2.3.3+dfsg/src/mus.h --- adplug-2.3.1+dfsg/src/mus.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/mus.h 2020-05-12 00:01:00.000000000 +0000 @@ -79,7 +79,7 @@ { if (data) delete [] data; if (insts) delete[] insts; - if (drv) drv->~CadlibDriver(); + if (drv) delete drv; }; bool load(const std::string &filename, const CFileProvider &fp); diff -Nru adplug-2.3.1+dfsg/src/nemuopl.cpp adplug-2.3.3+dfsg/src/nemuopl.cpp --- adplug-2.3.1+dfsg/src/nemuopl.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/nemuopl.cpp 2020-05-11 23:53:51.000000000 +0000 @@ -30,6 +30,7 @@ opl = new opl3_chip(); OPL3_Reset(opl, rate); currType = TYPE_OPL2; + samplerate = rate; } CNemuopl::~CNemuopl() @@ -47,4 +48,8 @@ OPL3_WriteRegBuffered(opl, (currChip << 8) | reg, val); } -void CNemuopl::init() {} +void CNemuopl::init() +{ + OPL3_Reset(opl, samplerate); + currChip = 0; +} diff -Nru adplug-2.3.1+dfsg/src/nemuopl.h adplug-2.3.3+dfsg/src/nemuopl.h --- adplug-2.3.1+dfsg/src/nemuopl.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/nemuopl.h 2020-05-11 23:53:51.000000000 +0000 @@ -40,6 +40,7 @@ private: opl3_chip* opl; + int samplerate; }; #endif diff -Nru adplug-2.3.1+dfsg/src/opl.h adplug-2.3.3+dfsg/src/opl.h --- adplug-2.3.1+dfsg/src/opl.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/opl.h 2020-05-12 00:01:00.000000000 +0000 @@ -41,7 +41,7 @@ virtual void write(int reg, int val) = 0; // combined register select + data write virtual void setchip(int n) // select OPL chip { - if(n < 2) + if(n >= 0 && n < 2) currChip = n; } @@ -60,6 +60,9 @@ // Emulation only: fill buffer virtual void update(short *buf, int samples) {} + + // Set surroundopl offset + virtual void set_offset(double offset) {} protected: int currChip; // currently selected OPL chip number diff -Nru adplug-2.3.1+dfsg/src/rad2.cpp adplug-2.3.3+dfsg/src/rad2.cpp --- adplug-2.3.1+dfsg/src/rad2.cpp 1970-01-01 00:00:00.000000000 +0000 +++ adplug-2.3.3+dfsg/src/rad2.cpp 2020-05-12 00:58:03.000000000 +0000 @@ -0,0 +1,1933 @@ +/* +* Adplug - Replayer for many OPL2/OPL3 audio file formats. +* Copyright (C) 1999 - 2007 Simon Peter, , et al. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* rad2.cpp - RAD v2 replayer class +* +* Aside from the Crad2Player wrapper class, all of the code in this file is based +* directly on the public domain RAD2 replayer source by Shayde/Reality, updated +* to also support the original RAD v1 format. It is otherwise modified as little +* as possible. +*/ + +#include "rad2.h" +#include "debug.h" +#include +#include +#include + +/* + +Code to check a RAD V2 tune file is valid. That is, it will check the tune +can be played without crashing the player. It doesn't exhaustively check +the tune except where needed to prevent a possible player crash. + +Call RADValidate with a pointer to your tune and the size in bytes. It +will return either NULL for all okay, or a pointer to a null-terminated +string describing what is wrong with the data. + +*/ + + +//================================================================================================== +// The error strings are all supplied here in case you want to translate them to another language +// (or supply your own more descriptive error messages). +//================================================================================================== +static const char *g_RADNotATuneFile = "Not a RAD tune file."; +static const char *g_RADNotAVersion21Tune = "Not a version 1.0 or 2.1 file format RAD tune."; +static const char *g_RADTruncated = "Tune file has been truncated and is incomplete."; +static const char *g_RADBadFlags = "Tune file has invalid flags."; +static const char *g_RADBadBPMValue = "Tune's BPM value is out of range."; +static const char *g_RADBadInstrument = "Tune file contains a bad instrument definition."; +static const char *g_RADUnknownMIDIVersion = "Tune file contains an unknown MIDI instrument version."; +static const char *g_RADOrderListTooLarge = "Order list in tune file is an invalid size."; +static const char *g_RADBadJumpMarker = "Order list jump marker is invalid."; +static const char *g_RADBadOrderEntry = "Order list entry is invalid."; +static const char *g_RADBadPattNum = "Tune file contains a bad pattern index."; +static const char *g_RADPattTruncated = "Tune file contains a truncated pattern."; +static const char *g_RADPattExtraData = "Tune file contains a pattern with extraneous data."; +static const char *g_RADPattBadLineNum = "Tune file contains a pattern with a bad line definition."; +static const char *g_RADPattBadChanNum = "Tune file contains a pattern with a bad channel definition."; +static const char *g_RADPattBadNoteNum = "Pattern contains a bad note number."; +static const char *g_RADPattBadInstNum = "Pattern contains a bad instrument number."; +static const char *g_RADPattBadEffect = "Pattern contains a bad effect and/or parameter."; +static const char *g_RADBadRiffNum = "Tune file contains a bad riff index."; +static const char *g_RADExtraBytes = "Tune file contains extra bytes."; + + + +//================================================================================================== +// Validate a RAD V2 (file format 2.1) tune file. Note, this uses no C++ standard library code. +//================================================================================================== +static const char *RADCheckPattern(const uint8_t *&s, const uint8_t *e, bool riff) { + + // Get pattern size + if (s + 2 > e) + return g_RADTruncated; + uint16_t pattsize = s[0] | (uint16_t(s[1]) << 8); + s += 2; + + // Calculate end of pattern + const uint8_t *pe = s + pattsize; + if (pe > e) + return g_RADTruncated; + + uint8_t linedef, chandef; + do { + + // Check line of pattern + if (s >= pe) + return g_RADPattTruncated; + linedef = *s++; + uint8_t linenum = linedef & 0x7F; + if (linenum >= 64) + return g_RADPattBadLineNum; + + do { + + // Check channel of pattern + if (s >= pe) + return g_RADPattTruncated; + chandef = *s++; + uint8_t channum = chandef & 0x0F; + if (!riff && channum >= 9) + return g_RADPattBadChanNum; + + // Check note + if (chandef & 0x40) { + if (s >= pe) + return g_RADPattTruncated; + uint8_t note = *s++; + uint8_t notenum = note & 15; + uint8_t octave = (note >> 4) & 7; + if (notenum == 0 || notenum == 13 || notenum == 14) + return g_RADPattBadNoteNum; + } + + // Check instrument. This shouldn't be supplied if bit 7 of the note byte is set, + // but it doesn't break anything if it is so we don't check for it + if (chandef & 0x20) { + if (s >= pe) + return g_RADPattTruncated; + uint8_t inst = *s++; + if (inst == 0 || inst >= 128) + return g_RADPattBadInstNum; + } + + // Check effect. A non-existent effect could be supplied, but it'll just be + // ignored by the player so we don't care + if (chandef & 0x10) { + if (s + 2 > pe) + return g_RADPattTruncated; + uint8_t effect = *s++; + uint8_t param = *s++; + if (effect > 31 || param > 99) + return g_RADPattBadEffect; + } + + } while (!(chandef & 0x80)); + + } while (!(linedef & 0x80)); + + if (s != pe) + return g_RADPattExtraData; + + return 0; +} +//-------------------------------------------------------------------------------------------------- +static const char *RADCheckPatternOld(const uint8_t *&s, const uint8_t *e) { + + if (s > e) + return g_RADTruncated; + + uint8_t linedef, chandef; + do { + + // Check line of pattern + if (s >= e) + return g_RADPattTruncated; + linedef = *s++; + uint8_t linenum = linedef & 0x7F; + if (linenum >= 64) + return g_RADPattBadLineNum; + + do { + + // Check channel of pattern + if (s >= e) + return g_RADPattTruncated; + chandef = *s++; + uint8_t channum = chandef & 0x0F; + if (channum >= 9) + return g_RADPattBadChanNum; + + // Check note + if (s >= e) + return g_RADPattTruncated; + uint8_t note = *s++; + uint8_t notenum = note & 15; + uint8_t octave = (note >> 4) & 7; + /* the replayer handles bad params already and some old tunes do contain them + if (notenum == 13 || notenum == 14) + return g_RADPattBadNoteNum; + */ + + // Check instrument + if (s >= e) + return g_RADPattTruncated; + uint8_t inst = *s++; + + // Check effect + if (inst & 0xf) { + if (s > e) + return g_RADPattTruncated; + uint8_t param = *s++; + /* the replayer handles bad params already and some old tunes do contain them + if (param > 99) + return g_RADPattBadEffect; + */ + } + + } while (!(chandef & 0x80)); + + } while (!(linedef & 0x80)); + + return 0; +} +//-------------------------------------------------------------------------------------------------- +static const char *RADValidate(const void *data, size_t data_size) { + + const uint8_t *s = (const uint8_t *)data; + const uint8_t *e = s + data_size; + + int Version; + + // Check header + if (data_size < 16) + return g_RADNotATuneFile; + + s += 16; + + // Check version + if (s >= e || (*s != 0x10 && *s != 0x21)) + return g_RADNotAVersion21Tune; + Version = (*s) >> 4; + s++; + + // Check flags + if (s >= e) + return g_RADTruncated; + + uint8_t flags = *s++; + if (Version >= 2 && flags & 0x80) + return g_RADBadFlags; // Bit 7 is unused in v2 + if (Version == 1 && flags & 0x20) + return g_RADBadFlags; // Bit 5 is unused in v1 + + if (Version >= 2 && flags & 0x20) { + if (s + 2 > e) + return g_RADTruncated; + uint16_t bpm = s[0] | (uint16_t(s[1]) << 8); + s += 2; + if (bpm < 46 || bpm > 300) + return g_RADBadBPMValue; + } + + // Check description. This is actually freeform text so there's not a lot to check, just that + // it's a null-terminated string + if (Version >= 2 || flags & 0x80) { + do { + if (s >= e) + return g_RADTruncated; + } while (*s++); + } + + // Check instruments. We don't actually validate the individual instrument fields as the tune + // file will still play with bad instrument data. We're only concerned that the tune file + // doesn't crash the player + uint8_t last_inst = 0; + while (1) { + + // Get instrument number, or 0 for end of instrument list + if (s >= e) + return g_RADTruncated; + uint8_t inst = *s++; + if (inst == 0) + break; + + // RAD always saves the instruments out in order + if (inst > 127 || inst <= last_inst) + return g_RADBadInstrument; + last_inst = inst; + + if (Version >= 2) { + // Check the name + if (s >= e) + return g_RADTruncated; + uint8_t namelen = *s++; + s += namelen; + + // Get algorithm + if (s > e) + return g_RADTruncated; + uint8_t alg = *s; + + if ((alg & 7) == 7) { + + // MIDI instrument. We need to check the version as this can affect the following + // data size + if (s + 7 > e) + return g_RADTruncated; + if (s[2] >> 4) + return g_RADUnknownMIDIVersion; + s += 7; + + } + else { + + s += 24; + if (s > e) + return g_RADTruncated; + } + + // Riff track supplied? + if (alg & 0x80) { + + const char *err = RADCheckPattern(s, e, false); + if (err) + return err; + } + } + else { + // skip version 1 instruments + s += 11; + } + + } + + // Get the order list + if (s >= e) + return g_RADTruncated; + uint8_t order_size = *s++; + const uint8_t *order_list = s; + if (order_size > 128) + return g_RADOrderListTooLarge; + s += order_size; + + for (uint8_t i = 0; i < order_size; i++) { + uint8_t order = order_list[i]; + + if (order & 0x80) { + + // Check jump marker + order &= 0x7F; + if (order >= order_size) + return g_RADBadJumpMarker; + } + else { + + // Check pattern number. It doesn't matter if there is no pattern with this number + // defined later, as missing patterns are treated as empty + if (Version >= 2 && order >= 100) + return g_RADBadOrderEntry; + if (Version == 1 && order >= 32) + return g_RADBadOrderEntry; + } + } + + // Check the patterns + if (Version >= 2) while (1) { + // Version 2 patterns + // Get pattern number + if (s >= e) + return g_RADTruncated; + uint8_t pattnum = *s++; + + // Last pattern? + if (pattnum == 0xFF) + break; + + if (pattnum >= 100) + return g_RADBadPattNum; + + const char *err = RADCheckPattern(s, e, false); + if (err) + return err; + } + else for (int i = 0; i < 32; i++) { + // Version 1 patterns + if (s + 2 > e) + return g_RADTruncated; + + int pos = s[0] | (int(s[1]) << 8); + s += 2; + if (pos) { + const uint8_t *patt = (uint8_t*)data + pos; + const char *err = RADCheckPatternOld(patt, e); + if (err) + return err; + } + } + + // Check the riffs + if (Version >= 2) while (1) { + + // Get riff number + if (s >= e) + return g_RADTruncated; + uint8_t riffnum = *s++; + + // Last riff? + if (riffnum == 0xFF) + break; + + uint8_t riffpatt = riffnum >> 4; + uint8_t riffchan = riffnum & 15; + if (riffpatt > 9 || riffchan == 0 || riffchan > 9) + return g_RADBadRiffNum; + + const char *err = RADCheckPattern(s, e, true); + if (err) + return err; + } + + // Tune file is all good + return 0; +} + +/* + +C++ player code for Reality Adlib Tracker 2.0a (file version 2.1). + +Please note, this is just the player code. This does no checking of the tune data before +it tries to play it, as most use cases will be a known tune being used in a production. +So if you're writing an application that loads unknown tunes in at run time then you'll +want to do more validity checking. + +To use: + +- Instantiate the RADPlayer object + +- Initialise player for your tune by calling the Init() method. Supply a pointer to the +tune file and a function for writing to the OPL3 registers. + +- Call the Update() method a number of times per second as returned by GetHertz(). If +your tune is using the default BPM setting you can safely just call it 50 times a +second, unless it's a legacy "slow-timer" tune then it'll need to be 18.2 times a +second. + +- When you're done, stop calling Update() and call the Stop() method to turn off all +sound and reset the OPL3 hardware. + +*/ + +#ifndef RAD_DETECT_REPEATS +#define RAD_DETECT_REPEATS 1 +#endif + +//================================================================================================== +// RAD player class. +//================================================================================================== +class RADPlayer { + + // Various constants + enum { + kTracks = 100, + kChannels = 9, + kTrackLines = 64, + kRiffTracks = 10, + kInstruments = 127, + + cmPortamentoUp = 0x1, + cmPortamentoDwn = 0x2, + cmToneSlide = 0x3, + cmToneVolSlide = 0x5, + cmVolSlide = 0xA, + cmSetVol = 0xC, + cmJumpToLine = 0xD, + cmSetSpeed = 0xF, + cmIgnore = ('I' - 55), + cmMultiplier = ('M' - 55), + cmRiff = ('R' - 55), + cmTranspose = ('T' - 55), + cmFeedback = ('U' - 55), + cmVolume = ('V' - 55), + }; + + enum e_Source { + SNone, SRiff, SIRiff, + }; + + enum { + fKeyOn = 1 << 0, + fKeyOff = 1 << 1, + fKeyedOn = 1 << 2, + }; + + struct CInstrument { + uint8_t Feedback[2]; + uint8_t Panning[2]; + uint8_t Algorithm; + uint8_t Detune; + uint8_t Volume; + uint8_t RiffSpeed; + uint8_t * Riff; + uint8_t Operators[4][5]; + char Name[256]; + }; + + struct CEffects { + int8_t PortSlide; + int8_t VolSlide; + uint16_t ToneSlideFreq; + uint8_t ToneSlideOct; + uint8_t ToneSlideSpeed; + int8_t ToneSlideDir; + }; + + struct CChannel { + uint8_t LastInstrument; + CInstrument * Instrument; + uint8_t Volume; + uint8_t DetuneA; + uint8_t DetuneB; + uint8_t KeyFlags; + uint16_t CurrFreq; + int8_t CurrOctave; + CEffects FX; + struct CRiff { + CEffects FX; + uint8_t * Track; + uint8_t * TrackStart; + uint8_t Line; + uint8_t Speed; + uint8_t SpeedCnt; + int8_t TransposeOctave; + int8_t TransposeNote; + uint8_t LastInstrument; + } Riff, IRiff; + }; + +public: + RADPlayer() : Initialised(false) {} + void Init(const void *tune, void(*opl3)(void *, uint16_t, uint8_t), void *arg); + void Stop(); + bool Update(); + int GetVersion() const { return Version; } + const uint8_t* GetDescription() const { return Description; } + float GetHertz() const { return Hertz; } + int GetPlayTimeInSeconds() const { return PlayTime / Hertz; } + int GetTunePos() const { return Order; } + int GetTuneLength() const { return OrderListSize; } + int GetTunePattern() const { return OrderList[Order]; } + int GetTunePatterns() const { return NumTracks; } + int GetTuneLine() const { return Line; } + const char* GetTuneInst(uint8_t inst) const { return Instruments[inst].Name; } + int GetTuneInsts() const { return NumInstruments; } + void SetMasterVolume(int vol) { MasterVol = vol; } + int GetMasterVolume() const { return MasterVol; } + int GetSpeed() const { return Speed; } + +#if RAD_DETECT_REPEATS + uint32_t ComputeTotalTime(); +#endif + +private: + bool UnpackNote(uint8_t *&s, uint8_t &last_instrument); + uint8_t * GetTrack(); + uint8_t * SkipToLine(uint8_t *trk, uint8_t linenum, bool chan_riff = false); + void PlayLine(); + void PlayNote(int channum, int8_t notenum, int8_t octave, uint16_t instnum, uint8_t cmd = 0, uint8_t param = 0, e_Source src = SNone, int op = 0); + void LoadInstrumentOPL3(int channum); + void PlayNoteOPL3(int channum, int8_t octave, int8_t note); + void ResetFX(CEffects *fx); + void TickRiff(int channum, CChannel::CRiff &riff, bool chan_riff); + void ContinueFX(int channum, CEffects *fx); + void SetVolume(int channum, uint8_t vol); + void GetSlideDir(int channum, CEffects *fx); + void LoadInstMultiplierOPL3(int channum, int op, uint8_t mult); + void LoadInstVolumeOPL3(int channum, int op, uint8_t vol); + void LoadInstFeedbackOPL3(int channum, int which, uint8_t fb); + void Portamento(uint16_t channum, CEffects *fx, int8_t amount, bool toneslide); + void Transpose(int8_t note, int8_t octave); + void SetOPL3(uint16_t reg, uint8_t val) { + OPL3Regs[reg] = val; + OPL3(OPL3Arg, reg, val); + } + uint8_t GetOPL3(uint16_t reg) const { + return OPL3Regs[reg]; + } + + void(*OPL3)(void *, uint16_t, uint8_t); + void * OPL3Arg; + int Version; + bool UseOPL3; + const uint8_t* Description; + CInstrument Instruments[kInstruments]; + int NumInstruments; + CChannel Channels[kChannels]; + uint32_t PlayTime; +#if RAD_DETECT_REPEATS + uint32_t OrderMap[4]; + bool Repeating; +#endif + float Hertz; + uint8_t * OrderList; + uint8_t * Tracks[kTracks]; + int NumTracks; + uint8_t * Riffs[kRiffTracks][kChannels]; + uint8_t * Track; + bool Initialised; + uint8_t Speed; + uint8_t OrderListSize; + uint8_t SpeedCnt; + uint8_t Order; + uint8_t Line; + int8_t Entrances; + uint8_t MasterVol; + int8_t LineJump; + uint8_t OPL3Regs[512]; + + // Values exported by UnpackNote() + int8_t NoteNum; + int8_t OctaveNum; + uint8_t InstNum; + uint8_t EffectNum; + uint8_t Param; + bool LastNote; + + static const int8_t NoteSize[]; + static const uint16_t ChanOffsets3[9], Chn2Offsets3[9]; + static const uint16_t NoteFreq[]; + static const uint16_t OpOffsets2[9][2]; + static const uint16_t OpOffsets3[9][4]; + static const bool AlgCarriers[7][4]; +}; +//-------------------------------------------------------------------------------------------------- +const int8_t RADPlayer::NoteSize[] = { 0, 2, 1, 3, 1, 3, 2, 4 }; +const uint16_t RADPlayer::ChanOffsets3[9] = { 0, 1, 2, 0x100, 0x101, 0x102, 6, 7, 8 }; // OPL3 first channel +const uint16_t RADPlayer::Chn2Offsets3[9] = { 3, 4, 5, 0x103, 0x104, 0x105, 0x106, 0x107, 0x108 }; // OPL3 second channel +const uint16_t RADPlayer::NoteFreq[] = { 0x16b,0x181,0x198,0x1b0,0x1ca,0x1e5,0x202,0x220,0x241,0x263,0x287,0x2ae }; +const uint16_t RADPlayer::OpOffsets2[9][2] = { + { 0x003, 0x000 }, + { 0x004, 0x001 }, + { 0x005, 0x002 }, + { 0x00B, 0x008 }, + { 0x00C, 0x009 }, + { 0x00D, 0x00A }, + { 0x013, 0x010 }, + { 0x014, 0x011 }, + { 0x015, 0x012 } +}; +const uint16_t RADPlayer::OpOffsets3[9][4] = { + { 0x00B, 0x008, 0x003, 0x000 }, + { 0x00C, 0x009, 0x004, 0x001 }, + { 0x00D, 0x00A, 0x005, 0x002 }, + { 0x10B, 0x108, 0x103, 0x100 }, + { 0x10C, 0x109, 0x104, 0x101 }, + { 0x10D, 0x10A, 0x105, 0x102 }, + { 0x113, 0x110, 0x013, 0x010 }, + { 0x114, 0x111, 0x014, 0x011 }, + { 0x115, 0x112, 0x015, 0x012 } +}; +const bool RADPlayer::AlgCarriers[7][4] = { + { true, false, false, false }, // 0 - 2op - op < op + { true, true, false, false }, // 1 - 2op - op + op + { true, false, false, false }, // 2 - 4op - op < op < op < op + { true, false, false, true }, // 3 - 4op - op < op < op + op + { true, false, true, false }, // 4 - 4op - op < op + op < op + { true, false, true, true }, // 5 - 4op - op < op + op + op + { true, true, true, true }, // 6 - 4op - op + op + op + op +}; + + + +//================================================================================================== +// Initialise a RAD tune for playback. This assumes the tune data is valid and does minimal data +// checking. +//================================================================================================== +void RADPlayer::Init(const void *tune, void(*opl3)(void *, uint16_t, uint8_t), void *arg) { + + Initialised = false; + + // Version check; we only support version 1.0 and 2.1 tune files + uint8_t ver = *((uint8_t *)tune + 0x10); + if (ver != 0x10 && ver != 0x21) { + Hertz = -1; + return; + } + Version = ver >> 4; + UseOPL3 = ver >= 2; + + // The OPL3 call-back + OPL3 = opl3; + OPL3Arg = arg; + + for (int i = 0; i < kTracks; i++) + Tracks[i] = 0; + + for (int i = 0; i < kRiffTracks; i++) + for (int j = 0; j < kChannels; j++) + Riffs[i][j] = 0; + + uint8_t *s = (uint8_t *)tune + 0x11; + + uint8_t flags = *s++; + Speed = flags & 0x1F; + + // Is BPM value present? + Hertz = 50.0f; + if (Version >= 2 && flags & 0x20) { + Hertz = (float)(s[0] | (int(s[1]) << 8)) * 2 / 5; + s += 2; + } + + // Slow timer tune? Return an approximate hz + if (flags & 0x40) + Hertz = 18.2f; + + // Skip any description + Description = 0; + if (Version >= 2 || flags & 0x80) { + Description = s; + while (*s) + s++; + s++; + } + + // Unpack the instruments + NumInstruments = 0; + while (1) { + + // Instrument number, 0 indicates end of list + uint8_t inst_num = *s++; + if (inst_num == 0) + break; + if (inst_num > NumInstruments) + NumInstruments = inst_num; + + CInstrument &inst = Instruments[inst_num - 1]; + + if (Version >= 2) { + // Version 2 instrument + // Read instrument name + uint8_t inst_namelen = *s++; + for (int i = 0; i < inst_namelen; i++) + inst.Name[i] = *s++; + inst.Name[inst_namelen] = '\0'; + + uint8_t alg = *s++; + inst.Algorithm = alg & 7; + inst.Panning[0] = (alg >> 3) & 3; + inst.Panning[1] = (alg >> 5) & 3; + + if (inst.Algorithm < 7) { + + uint8_t b = *s++; + inst.Feedback[0] = b & 15; + inst.Feedback[1] = b >> 4; + + b = *s++; + inst.Detune = b >> 4; + inst.RiffSpeed = b & 15; + + inst.Volume = *s++; + + for (int i = 0; i < 4; i++) { + uint8_t *op = inst.Operators[i]; + for (int j = 0; j < 5; j++) + op[j] = *s++; + } + + } + else { + + // Ignore MIDI instrument data + s += 6; + } + + // Instrument riff? + if (alg & 0x80) { + int size = s[0] | (int(s[1]) << 8); + s += 2; + inst.Riff = s; + s += size; + } + else + inst.Riff = 0; + } + else { + // Version 1 instrument + inst.Name[0] = '\0'; + + inst.Algorithm = s[8] & 1; + inst.Panning[0] = 0; + inst.Panning[1] = 0; + + inst.Feedback[0] = (s[8] >> 1) & 0x7; + inst.Feedback[1] = 0; + + inst.Detune = 0; + inst.RiffSpeed = 0; + + inst.Volume = 64; + + inst.Operators[0][0] = s[0]; + inst.Operators[1][0] = s[1]; + inst.Operators[2][0] = 0; + inst.Operators[3][0] = 0; + inst.Operators[0][1] = s[2]; + inst.Operators[1][1] = s[3]; + inst.Operators[2][1] = 0; + inst.Operators[3][1] = 0; + inst.Operators[0][2] = s[4]; + inst.Operators[1][2] = s[5]; + inst.Operators[2][2] = 0; + inst.Operators[3][2] = 0; + inst.Operators[0][3] = s[6]; + inst.Operators[1][3] = s[7]; + inst.Operators[2][3] = 0; + inst.Operators[3][3] = 0; + inst.Operators[0][4] = s[9]; + inst.Operators[1][4] = s[10]; + inst.Operators[2][4] = 0; + inst.Operators[3][4] = 0; + + inst.Riff = 0; + + s += 11; + } + } + + // Get order list + OrderListSize = *s++; + OrderList = s; + s += OrderListSize; + + // Locate the tracks + NumTracks = 0; + if (Version >= 2) while (1) { + // Version 2 tracks + // Track number + uint8_t track_num = *s++; + if (track_num >= kTracks) + break; + if (track_num + 1 > NumTracks) + NumTracks = track_num + 1; + + // Track size in bytes + int size = s[0] | (int(s[1]) << 8); + s += 2; + + Tracks[track_num] = s; + s += size; + } + else for (int i = 0; i < 32; i++) { + // Version 1 tracks + int pos = s[0] | (int(s[1]) << 8); + s += 2; + if (pos) { + NumTracks = i + 1; + Tracks[i] = (uint8_t*)tune + pos; + } + } + + // Locate the riffs + if (Version >= 2) while (1) { + + // Riff id + uint8_t riffid = *s++; + uint8_t riffnum = riffid >> 4; + uint8_t channum = riffid & 15; + if (riffnum >= kRiffTracks || channum > kChannels) + break; + + // Track size in bytes + int size = s[0] | (int(s[1]) << 8); + s += 2; + + Riffs[riffnum][channum - 1] = s; + s += size; + } + + // Done parsing tune, now set up for play + for (int i = 0; i < 512; i++) + OPL3Regs[i] = 255; + Stop(); + + Initialised = true; +} + + + +//================================================================================================== +// Stop all sounds and reset the tune. Tune will play from the beginning again if you continue to +// Update(). +//================================================================================================== +void RADPlayer::Stop() { + + // Clear all registers + for (uint16_t reg = 0x20; reg < 0xF6; reg++) { + + // Ensure envelopes decay all the way + uint8_t val = (reg >= 0x60 && reg < 0xA0) ? 0xFF : 0; + + SetOPL3(reg, val); + SetOPL3(reg + 0x100, val); + } + + // Configure OPL3 + SetOPL3(1, 0x20); // Allow waveforms + SetOPL3(8, 0); // No split point + SetOPL3(0xbd, 0); // No drums, etc. + SetOPL3(0x104, 0); // Everything 2-op by default + SetOPL3(0x105, 1); // OPL3 mode on + +#if RAD_DETECT_REPEATS + // The order map keeps track of which patterns we've played so we can detect when the tune + // starts to repeat. Jump markers can't be reliably used for this + PlayTime = 0; + Repeating = false; + for (int i = 0; i < 4; i++) + OrderMap[i] = 0; +#endif + + // Initialise play values + SpeedCnt = 1; + Order = 0; + Track = GetTrack(); + Line = 0; + Entrances = 0; + MasterVol = 64; + + // Initialise channels + for (int i = 0; i < kChannels; i++) { + CChannel &chan = Channels[i]; + chan.LastInstrument = 0; + chan.Instrument = 0; + chan.Volume = 0; + chan.DetuneA = 0; + chan.DetuneB = 0; + chan.KeyFlags = 0; + chan.Riff.SpeedCnt = 0; + chan.IRiff.SpeedCnt = 0; + } +} + + + +//================================================================================================== +// Playback update. Call BPM * 2 / 5 times a second. Use GetHertz() for this number after the +// tune has been initialised. Returns true if tune is starting to repeat. +//================================================================================================== +bool RADPlayer::Update() { + + if (!Initialised) + return false; + + // Run riffs + for (int i = 0; i < kChannels; i++) { + CChannel &chan = Channels[i]; + TickRiff(i, chan.IRiff, false); + TickRiff(i, chan.Riff, true); + } + + // Run main track + PlayLine(); + + // Run effects + for (int i = 0; i < kChannels; i++) { + CChannel &chan = Channels[i]; + ContinueFX(i, &chan.IRiff.FX); + ContinueFX(i, &chan.Riff.FX); + ContinueFX(i, &chan.FX); + } + + // Update play time. We convert to seconds when queried + PlayTime++; + +#if RAD_DETECT_REPEATS + return Repeating; +#else + return false; +#endif +} + + + +//================================================================================================== +// Unpacks a single RAD note. +//================================================================================================== +bool RADPlayer::UnpackNote(uint8_t *&s, uint8_t &last_instrument) { + + uint8_t chanid = *s++; + + InstNum = 0; + EffectNum = 0; + Param = 0; + + uint8_t note = 0; + + if (Version >= 2) { + // Version 2 notes + // Unpack note data + if (chanid & 0x40) { + uint8_t n = *s++; + note = n & 0x7F; + + // Retrigger last instrument? + if (n & 0x80) + InstNum = last_instrument; + } + + // Do we have an instrument? + if (chanid & 0x20) { + InstNum = *s++; + last_instrument = InstNum; + } + + // Do we have an effect? + if (chanid & 0x10) { + EffectNum = *s++; + Param = *s++; + } + } + else { + // Version 1 notes + // Unpack note data + uint8_t n = *s++; + note = n & 0x7f; + if (n & 0x80) + InstNum = 16; + + // Do we have an instrument? + n = *s++; + InstNum |= n >> 4; + if (InstNum) + last_instrument = InstNum; + + // Do we have an effect? + EffectNum = n & 0xf; + if (EffectNum) + Param = *s++; + } + + NoteNum = note & 15; + OctaveNum = note >> 4; + + return ((chanid & 0x80) != 0); +} + + + +//================================================================================================== +// Get current track as indicated by order list. +//================================================================================================== +uint8_t *RADPlayer::GetTrack() { + + // If at end of tune start again from beginning + if (Order >= OrderListSize) + Order = 0; + + uint8_t track_num = OrderList[Order]; + + // Jump marker? Note, we don't recognise multiple jump markers as that could put us into an + // infinite loop + if (track_num & 0x80) { + Order = track_num & 0x7F; + track_num = OrderList[Order] & 0x7F; + } + +#if RAD_DETECT_REPEATS + // Check for tune repeat, and mark order in order map + if (Order < 128) { + int byte = Order >> 5; + uint32_t bit = uint32_t(1) << (Order & 31); + if (OrderMap[byte] & bit) + Repeating = true; + else + OrderMap[byte] |= bit; + } +#endif + + return Tracks[track_num]; +} + + + +//================================================================================================== +// Skip through track till we reach the given line or the next higher one. Returns null if none. +//================================================================================================== +uint8_t *RADPlayer::SkipToLine(uint8_t *trk, uint8_t linenum, bool chan_riff) { + + while (1) { + + uint8_t lineid = *trk; + if ((lineid & 0x7F) >= linenum) + return trk; + if (lineid & 0x80) + break; + trk++; + + // Skip channel notes + uint8_t chanid; + do { + chanid = *trk++; + if (Version >= 2) + trk += NoteSize[(chanid >> 4) & 7]; + else if (trk[1] & 0xf) + // v1 note with param + trk += 3; + else + // v1 note without param + trk += 2; + } while (!(chanid & 0x80) && !chan_riff); + } + + return 0; +} + + + +//================================================================================================== +// Plays one line of current track and advances pointers. +//================================================================================================== +void RADPlayer::PlayLine() { + + SpeedCnt--; + if (SpeedCnt > 0) + return; + SpeedCnt = Speed; + + // Reset channel effects + for (int i = 0; i < kChannels; i++) + ResetFX(&Channels[i].FX); + + LineJump = -1; + + // At the right line? + uint8_t *trk = Track; + if (trk && (*trk & 0x7F) <= Line) { + uint8_t lineid = *trk++; + + // Run through channels + bool last; + do { + int channum = *trk & 15; + CChannel &chan = Channels[channum]; + last = UnpackNote(trk, chan.LastInstrument); + PlayNote(channum, NoteNum, OctaveNum, InstNum, EffectNum, Param); + } while (!last); + + // Was this the last line? + if (lineid & 0x80) + trk = 0; + + Track = trk; + } + + // Move to next line + Line++; + if (Line >= kTrackLines || LineJump >= 0) { + + if (LineJump >= 0) + Line = LineJump; + else + Line = 0; + + // Move to next track in order list + Order++; + Track = GetTrack(); + if (Line > 0) + Track = SkipToLine(Track, Line, false); + } +} + + + +//================================================================================================== +// Play a single note. Returns the line number in the next pattern to jump to if a jump command was +// found, or -1 if none. +//================================================================================================== +void RADPlayer::PlayNote(int channum, int8_t notenum, int8_t octave, uint16_t instnum, uint8_t cmd, uint8_t param, e_Source src, int op) { + CChannel &chan = Channels[channum]; + + // Recursion detector. This is needed as riffs can trigger other riffs, and they could end up + // in a loop + if (Entrances >= 8) + return; + Entrances++; + + // Select which effects source we're using + CEffects *fx = &chan.FX; + if (src == SRiff) + fx = &chan.Riff.FX; + else if (src == SIRiff) + fx = &chan.IRiff.FX; + + bool transposing = false; + + // For tone-slides the note is the target + if (cmd == cmToneSlide) { + if (notenum > 0 && notenum <= 12) { + fx->ToneSlideOct = octave; + fx->ToneSlideFreq = NoteFreq[notenum - 1]; + } + goto toneslide; + } + + // Playing a new instrument? + if (instnum > 0) { + CInstrument *oldinst = chan.Instrument; + CInstrument *inst = &Instruments[instnum - 1]; + chan.Instrument = inst; + + if (inst->Algorithm < 7) { + + LoadInstrumentOPL3(channum); + + // Bounce the channel + chan.KeyFlags |= fKeyOff | fKeyOn; + + ResetFX(&chan.IRiff.FX); + + if (src != SIRiff || inst != oldinst) { + + // Instrument riff? + if (inst->Riff && inst->RiffSpeed > 0) { + + chan.IRiff.Track = chan.IRiff.TrackStart = inst->Riff; + chan.IRiff.Line = 0; + chan.IRiff.Speed = inst->RiffSpeed; + chan.IRiff.LastInstrument = 0; + + // Note given with riff command is used to transpose the riff + if (notenum >= 1 && notenum <= 12) { + chan.IRiff.TransposeOctave = octave; + chan.IRiff.TransposeNote = notenum; + transposing = true; + } + else { + chan.IRiff.TransposeOctave = 3; + chan.IRiff.TransposeNote = 12; + } + + // Do first tick of riff + chan.IRiff.SpeedCnt = 1; + TickRiff(channum, chan.IRiff, false); + + } + else + chan.IRiff.SpeedCnt = 0; + } + } + else + // Ignore MIDI instruments + chan.Instrument = 0; + } + + // Starting a channel riff? + if (cmd == cmRiff || cmd == cmTranspose) { + + ResetFX(&chan.Riff.FX); + + uint8_t p0 = param / 10; + uint8_t p1 = param % 10; + chan.Riff.Track = p1 > 0 ? Riffs[p0][p1 - 1] : 0; + if (chan.Riff.Track) { + + chan.Riff.TrackStart = chan.Riff.Track; + chan.Riff.Line = 0; + chan.Riff.Speed = Speed; + chan.Riff.LastInstrument = 0; + + // Note given with riff command is used to transpose the riff + if (cmd == cmTranspose && notenum >= 1 && notenum <= 12) { + chan.Riff.TransposeOctave = octave; + chan.Riff.TransposeNote = notenum; + transposing = true; + } + else { + chan.Riff.TransposeOctave = 3; + chan.Riff.TransposeNote = 12; + } + + // Do first tick of riff + chan.Riff.SpeedCnt = 1; + TickRiff(channum, chan.Riff, true); + + } + else + chan.Riff.SpeedCnt = 0; + } + + // Play the note + if (!transposing && notenum > 0) { + + // Key-off? + if (notenum == 15) + chan.KeyFlags |= fKeyOff; + + if (!chan.Instrument || chan.Instrument->Algorithm < 7) + PlayNoteOPL3(channum, octave, notenum); + } + + // Process effect + switch (cmd) { + + case cmSetVol: + SetVolume(channum, param); + break; + + case cmSetSpeed: + if (src == SNone) { + Speed = param; + SpeedCnt = param; + } + else if (src == SRiff) { + chan.Riff.Speed = param; + chan.Riff.SpeedCnt = param; + } + else if (src == SIRiff) { + chan.IRiff.Speed = param; + chan.IRiff.SpeedCnt = param; + } + break; + + case cmPortamentoUp: + fx->PortSlide = param; + break; + + case cmPortamentoDwn: + fx->PortSlide = -int8_t(param); + break; + + case cmToneVolSlide: + case cmVolSlide: { + int8_t val = param; + if (val >= 50) + val = -(val - 50); + fx->VolSlide = val; + if (cmd != cmToneVolSlide) + break; + } + // Fall through! + + case cmToneSlide: { + toneslide: + uint8_t speed = param; + if (speed) + fx->ToneSlideSpeed = speed; + GetSlideDir(channum, fx); + break; + } + + case cmJumpToLine: { + if (param >= kTrackLines) + break; + + // Note: jump commands in riffs are checked for within TickRiff() + if (src == SNone) + LineJump = param; + + break; + } + + case cmMultiplier: { + if (src == SIRiff) + LoadInstMultiplierOPL3(channum, op, param); + break; + } + + case cmVolume: { + if (src == SIRiff) + LoadInstVolumeOPL3(channum, op, param); + break; + } + + case cmFeedback: { + if (src == SIRiff) { + uint8_t which = param / 10; + uint8_t fb = param % 10; + LoadInstFeedbackOPL3(channum, which, fb); + } + break; + } + } + + Entrances--; +} + + + +//================================================================================================== +// Sets the OPL3 registers for a given instrument. +//================================================================================================== +void RADPlayer::LoadInstrumentOPL3(int channum) { + CChannel &chan = Channels[channum]; + + const CInstrument *inst = chan.Instrument; + if (!inst) + return; + + uint8_t alg = inst->Algorithm; + chan.Volume = inst->Volume; + chan.DetuneA = (inst->Detune + 1) >> 1; + chan.DetuneB = inst->Detune >> 1; + + // Turn on 4-op mode for algorithms 2 and 3 (algorithms 4 to 6 are simulated with 2-op mode) + if (UseOPL3 && channum < 6) { + uint8_t mask = 1 << channum; + SetOPL3(0x104, (GetOPL3(0x104) & ~mask) | (alg == 2 || alg == 3 ? mask : 0)); + } + + // Left/right/feedback/algorithm + if (UseOPL3) { + SetOPL3(0xC0 + ChanOffsets3[channum], ((inst->Panning[1] ^ 3) << 4) | inst->Feedback[1] << 1 | (alg == 3 || alg == 5 || alg == 6 ? 1 : 0)); + SetOPL3(0xC0 + Chn2Offsets3[channum], ((inst->Panning[0] ^ 3) << 4) | inst->Feedback[0] << 1 | (alg == 1 || alg == 6 ? 1 : 0)); + } + else { + SetOPL3(0xC0 + channum, ((inst->Panning[0] ^ 3) << 4) | inst->Feedback[0] << 1 | (alg == 1 ? 1 : 0)); + } + + // Load the operators + for (int i = 0; i < (UseOPL3 ? 4 : 2); i++) { + + static const uint8_t blank[] = { 0, 0x3F, 0, 0xF0, 0 }; + const uint8_t *op = (alg < 2 && i >= 2) ? blank : inst->Operators[i]; + uint16_t reg = UseOPL3 ? OpOffsets3[channum][i] : OpOffsets2[channum][i]; + + uint16_t vol = ~op[1] & 0x3F; + + // Do volume scaling for carriers + if (AlgCarriers[alg][i]) { + vol = vol * inst->Volume / 64; + vol = vol * MasterVol / 64; + } + + SetOPL3(reg + 0x20, op[0]); + SetOPL3(reg + 0x40, (op[1] & 0xC0) | ((vol ^ 0x3F) & 0x3F)); + SetOPL3(reg + 0x60, op[2]); + SetOPL3(reg + 0x80, op[3]); + SetOPL3(reg + 0xE0, op[4]); + } +} + + + +//================================================================================================== +// Play note on OPL3 hardware. +//================================================================================================== +void RADPlayer::PlayNoteOPL3(int channum, int8_t octave, int8_t note) { + CChannel &chan = Channels[channum]; + + uint16_t o1, o2; + if (UseOPL3) { + o1 = ChanOffsets3[channum]; + o2 = Chn2Offsets3[channum]; + } + else { + o1 = 0; + o2 = channum; + } + + // Key off the channel + if (chan.KeyFlags & fKeyOff) { + chan.KeyFlags &= ~(fKeyOff | fKeyedOn); + if (UseOPL3) + SetOPL3(0xB0 + o1, GetOPL3(0xB0 + o1) & ~0x20); + SetOPL3(0xB0 + o2, GetOPL3(0xB0 + o2) & ~0x20); + } + + if (note > 12) + return; + + bool op4 = (UseOPL3 && chan.Instrument && chan.Instrument->Algorithm >= 2); + + uint16_t freq = NoteFreq[note - 1]; + uint16_t frq2 = freq; + + chan.CurrFreq = freq; + chan.CurrOctave = octave; + + // Detune. We detune both channels in the opposite direction so the note retains its tuning + freq += chan.DetuneA; + frq2 -= chan.DetuneB; + + // Frequency low byte + if (op4) + SetOPL3(0xA0 + o1, frq2 & 0xFF); + SetOPL3(0xA0 + o2, freq & 0xFF); + + // Frequency high bits + octave + key on + if (chan.KeyFlags & fKeyOn) + chan.KeyFlags = (chan.KeyFlags & ~fKeyOn) | fKeyedOn; + if (op4) + SetOPL3(0xB0 + o1, (frq2 >> 8) | (octave << 2) | ((chan.KeyFlags & fKeyedOn) ? 0x20 : 0)); + else if (UseOPL3) + SetOPL3(0xB0 + o1, 0); + SetOPL3(0xB0 + o2, (freq >> 8) | (octave << 2) | ((chan.KeyFlags & fKeyedOn) ? 0x20 : 0)); +} + + + +//================================================================================================== +// Prepare FX for new line. +//================================================================================================== +void RADPlayer::ResetFX(CEffects *fx) { + fx->PortSlide = 0; + fx->VolSlide = 0; + fx->ToneSlideDir = 0; +} + + + +//================================================================================================== +// Tick the channel riff. +//================================================================================================== +void RADPlayer::TickRiff(int channum, CChannel::CRiff &riff, bool chan_riff) { + uint8_t lineid; + + if (riff.SpeedCnt == 0) { + ResetFX(&riff.FX); + return; + } + + riff.SpeedCnt--; + if (riff.SpeedCnt > 0) + return; + riff.SpeedCnt = riff.Speed; + + uint8_t line = riff.Line++; + if (riff.Line >= kTrackLines) + riff.SpeedCnt = 0; + + ResetFX(&riff.FX); + + // Is this the current line in track? + uint8_t *trk = riff.Track; + if (trk && (*trk & 0x7F) == line) { + lineid = *trk++; + + if (chan_riff) { + + // Channel riff: play current note + UnpackNote(trk, riff.LastInstrument); + Transpose(riff.TransposeNote, riff.TransposeOctave); + PlayNote(channum, NoteNum, OctaveNum, InstNum, EffectNum, Param, SRiff); + + } + else { + + // Instrument riff: here each track channel is an extra effect that can run, but is not + // actually a different physical channel + bool last; + do { + int col = *trk & 15; + last = UnpackNote(trk, riff.LastInstrument); + if (EffectNum != cmIgnore) + Transpose(riff.TransposeNote, riff.TransposeOctave); + PlayNote(channum, NoteNum, OctaveNum, InstNum, EffectNum, Param, SIRiff, col > 0 ? (col - 1) & 3 : 0); + } while (!last); + } + + // Last line? + if (lineid & 0x80) + trk = 0; + + riff.Track = trk; + } + + // Special case; if next line has a jump command, run it now + if (!trk || (*trk++ & 0x7F) != riff.Line) + return; + + UnpackNote(trk, lineid); // lineid is just a dummy here + if (EffectNum == cmJumpToLine && Param < kTrackLines) { + riff.Line = Param; + riff.Track = SkipToLine(riff.TrackStart, Param, chan_riff); + } +} + + + +//================================================================================================== +// This continues any effects that operate continuously (eg. slides). +//================================================================================================== +void RADPlayer::ContinueFX(int channum, CEffects *fx) { + CChannel &chan = Channels[channum]; + + if (fx->PortSlide) + Portamento(channum, fx, fx->PortSlide, false); + + if (fx->VolSlide) { + int8_t vol = chan.Volume; + vol -= fx->VolSlide; + if (vol < 0) + vol = 0; + SetVolume(channum, vol); + } + + if (fx->ToneSlideDir) + Portamento(channum, fx, fx->ToneSlideDir, true); +} + + + +//================================================================================================== +// Sets the volume of given channel. +//================================================================================================== +void RADPlayer::SetVolume(int channum, uint8_t vol) { + CChannel &chan = Channels[channum]; + + // Ensure volume is within range + if (vol > 64) + vol = 64; + + chan.Volume = vol; + + // Scale volume to master volume + vol = vol * MasterVol / 64; + + CInstrument *inst = chan.Instrument; + if (!inst) + return; + uint8_t alg = inst->Algorithm; + + // Set volume of all carriers + for (int i = 0; i < 4; i++) { + uint8_t *op = inst->Operators[i]; + + // Is this operator a carrier? + if (!AlgCarriers[alg][i]) + continue; + + uint8_t opvol = uint16_t((op[1] & 63) ^ 63) * vol / 64; + uint16_t reg = 0x40 + (UseOPL3 ? OpOffsets3[channum][i] : OpOffsets2[channum][i]); + SetOPL3(reg, (GetOPL3(reg) & 0xC0) | (opvol ^ 0x3F)); + } +} + + + +//================================================================================================== +// Starts a tone-slide. +//================================================================================================== +void RADPlayer::GetSlideDir(int channum, CEffects *fx) { + CChannel &chan = Channels[channum]; + + int8_t speed = fx->ToneSlideSpeed; + if (speed > 0) { + uint8_t oct = fx->ToneSlideOct; + uint16_t freq = fx->ToneSlideFreq; + + uint16_t oldfreq = chan.CurrFreq; + uint8_t oldoct = chan.CurrOctave; + + if (oldoct > oct) + speed = -speed; + else if (oldoct == oct) { + if (oldfreq > freq) + speed = -speed; + else if (oldfreq == freq) + speed = 0; + } + } + + fx->ToneSlideDir = speed; +} + + + +//================================================================================================== +// Load multiplier value into operator. +//================================================================================================== +void RADPlayer::LoadInstMultiplierOPL3(int channum, int op, uint8_t mult) { + // Always assume OPL3 register numbering since this is not used in v1 tunes + uint16_t reg = 0x20 + OpOffsets3[channum][op]; + SetOPL3(reg, (GetOPL3(reg) & 0xF0) | (mult & 15)); +} + + + +//================================================================================================== +// Load volume value into operator. +//================================================================================================== +void RADPlayer::LoadInstVolumeOPL3(int channum, int op, uint8_t vol) { + // Always assume OPL3 register numbering since this is not used in v1 tunes + uint16_t reg = 0x40 + OpOffsets3[channum][op]; + SetOPL3(reg, (GetOPL3(reg) & 0xC0) | ((vol & 0x3F) ^ 0x3F)); +} + + + +//================================================================================================== +// Load feedback value into instrument. +//================================================================================================== +void RADPlayer::LoadInstFeedbackOPL3(int channum, int which, uint8_t fb) { + // Always assume OPL3 register numbering since this is not used in v1 tunes + if (which == 0) { + + uint16_t reg = 0xC0 + Chn2Offsets3[channum]; + SetOPL3(reg, (GetOPL3(reg) & 0x31) | ((fb & 7) << 1)); + + } + else if (which == 1) { + + uint16_t reg = 0xC0 + ChanOffsets3[channum]; + SetOPL3(reg, (GetOPL3(reg) & 0x31) | ((fb & 7) << 1)); + } +} + + + +//================================================================================================== +// This adjusts the pitch of the given channel's note. There may also be a limiting value on the +// portamento (for tone slides). +//================================================================================================== +void RADPlayer::Portamento(uint16_t channum, CEffects *fx, int8_t amount, bool toneslide) { + CChannel &chan = Channels[channum]; + + uint16_t freq = chan.CurrFreq; + uint8_t oct = chan.CurrOctave; + + freq += amount; + + if (freq < 0x156) { + + if (oct > 0) { + oct--; + freq += 0x2AE - 0x156; + } + else + freq = 0x156; + + } + else if (freq > 0x2AE) { + + if (oct < 7) { + oct++; + freq -= 0x2AE - 0x156; + } + else + freq = 0x2AE; + } + + if (toneslide) { + + if (amount >= 0) { + + if (oct > fx->ToneSlideOct || (oct == fx->ToneSlideOct && freq >= fx->ToneSlideFreq)) { + freq = fx->ToneSlideFreq; + oct = fx->ToneSlideOct; + } + + } + else { + + if (oct < fx->ToneSlideOct || (oct == fx->ToneSlideOct && freq <= fx->ToneSlideFreq)) { + freq = fx->ToneSlideFreq; + oct = fx->ToneSlideOct; + } + } + } + + chan.CurrFreq = freq; + chan.CurrOctave = oct; + + // Apply detunes + uint16_t frq2 = freq - chan.DetuneB; + freq += chan.DetuneA; + + // Write value back to OPL3 + uint16_t chan_offset = UseOPL3 ? Chn2Offsets3[channum] : channum; + SetOPL3(0xA0 + chan_offset, freq & 0xFF); + SetOPL3(0xB0 + chan_offset, (freq >> 8 & 3) | oct << 2 | (GetOPL3(0xB0 + chan_offset) & 0xE0)); + + if (UseOPL3) { + chan_offset = ChanOffsets3[channum]; + SetOPL3(0xA0 + chan_offset, frq2 & 0xFF); + SetOPL3(0xB0 + chan_offset, (frq2 >> 8 & 3) | oct << 2 | (GetOPL3(0xB0 + chan_offset) & 0xE0)); + } +} + + + +//================================================================================================== +// Transpose the note returned by UnpackNote(). +// Note: due to RAD's wonky legacy middle C is octave 3 note number 12. +//================================================================================================== +void RADPlayer::Transpose(int8_t note, int8_t octave) { + + if (NoteNum >= 1 && NoteNum <= 12) { + + int8_t toct = octave - 3; + if (toct != 0) { + OctaveNum += toct; + if (OctaveNum < 0) + OctaveNum = 0; + else if (OctaveNum > 7) + OctaveNum = 7; + } + + int8_t tnot = note - 12; + if (tnot != 0) { + NoteNum += tnot; + if (NoteNum < 1) { + NoteNum += 12; + if (OctaveNum > 0) + OctaveNum--; + else + NoteNum = 1; + } + } + } +} + + + +//================================================================================================== +// Compute total time of tune if it didn't repeat. Note, this stops the tune so should only be done +// prior to initial playback. +//================================================================================================== +#if RAD_DETECT_REPEATS +static void RADPlayerDummyOPL3(void *arg, uint16_t reg, uint8_t data) {} +//-------------------------------------------------------------------------------------------------- +uint32_t RADPlayer::ComputeTotalTime() { + + Stop(); + void(*old_opl3)(void *, uint16_t, uint8_t) = OPL3; + OPL3 = RADPlayerDummyOPL3; + + while (!Update()) + ; + uint32_t total = PlayTime; + + Stop(); + OPL3 = old_opl3; + + return total / Hertz; +} +#endif + +/* +* +* Start of RADPlayer wrapper for AdPlug +* +*/ + +static void writeOPL(void *arg, uint16_t reg, uint8_t val) { + Copl *opl = (Copl *)arg; + int chip = reg >> 8; + if (opl->getchip() != chip) + opl->setchip(chip); + opl->write(reg & 0xFF, val); +} + +CPlayer *Crad2Player::factory(Copl *newopl) { + return new Crad2Player(newopl); +} + +Crad2Player::Crad2Player(Copl *newopl) + : CPlayer(newopl) { + + rad = new RADPlayer(); + data = 0; +} + +Crad2Player::~Crad2Player() { + delete rad; + delete[] data; +} + +bool Crad2Player::load(const std::string &filename, const CFileProvider &fp) { + char *newdata; + size_t size; + const char *err; + + binistream *file = fp.open(filename); + if (!file) return false; + + char header[17]; + header[16] = '\0'; + file->readString(header, 16); + if (strncmp(header, "RAD by REALiTY!!", 16)) { + fp.close(file); + return false; + } + + file->seek(0, binio::End); + size = file->pos(); + + // some old tunes have a truncated final note for some reason + // add an extra empty byte at the end of the file so they still "work" + newdata = new char[size + 1]; + newdata[size] = '\0'; + file->seek(0); + file->readString(newdata, size); + fp.close(file); + + if (!(err = RADValidate(newdata, size + 1))) { + rad->Init(newdata, writeOPL, opl); + // playback timer is < 0 if load failed + if (rad->GetHertz() > 0) { + delete[] data; + data = newdata; + + // read description + desc.clear(); + const unsigned char *newdesc = rad->GetDescription(); + while (newdesc && *newdesc) { + unsigned char c = *newdesc++; + + if (c >= 0x20) + desc += c; + else if (c == 0x01) + desc += '\n'; + else for (int i = 0; i < c; i++) + desc += ' '; + } + + // done + return true; + } + } + else { + AdPlug_LogWrite("Crad2Player::load(\"%s\"): %s\n", filename.c_str(), err); + } + + delete[] newdata; + return false; +} + +bool Crad2Player::update() { return !rad->Update(); } +void Crad2Player::rewind(int) { rad->Stop(); } +float Crad2Player::getrefresh() { return rad->GetHertz(); } + +std::string Crad2Player::gettype() { + char type[64]; + sprintf(type, "Reality ADlib Tracker (version %d)", rad->GetVersion()); + return std::string(type); +} +unsigned int Crad2Player::getpatterns() { return rad->GetTunePatterns(); } +unsigned int Crad2Player::getpattern() { return rad->GetTunePattern(); } +unsigned int Crad2Player::getorders() { return rad->GetTuneLength(); } +unsigned int Crad2Player::getorder() { return rad->GetTunePos(); } +unsigned int Crad2Player::getrow() { return rad->GetTuneLine(); } +unsigned int Crad2Player::getspeed() { return rad->GetSpeed(); } +unsigned int Crad2Player::getinstruments() { return rad->GetTuneInsts(); } +std::string Crad2Player::getinstrument(unsigned int n) { return rad->GetTuneInst(n); } diff -Nru adplug-2.3.1+dfsg/src/rad2.h adplug-2.3.3+dfsg/src/rad2.h --- adplug-2.3.1+dfsg/src/rad2.h 1970-01-01 00:00:00.000000000 +0000 +++ adplug-2.3.3+dfsg/src/rad2.h 2020-05-12 00:58:03.000000000 +0000 @@ -0,0 +1,64 @@ +/* +* Adplug - Replayer for many OPL2/OPL3 audio file formats. +* Copyright (C) 1999 - 2007 Simon Peter, , et al. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* rad2.h - RAD v2 replayer class +*/ + +#ifndef H_ADPLUG_RAD2PLAYER +#define H_ADPLUG_RAD2PLAYER + +#include "player.h" + +class RADPlayer; + +class Crad2Player: public CPlayer +{ +public: + static CPlayer *factory(Copl *newopl); + + Crad2Player(Copl *newopl); + virtual ~Crad2Player(); + + /***** Operational methods *****/ + bool load(const std::string &filename, const CFileProvider &fp = CProvider_Filesystem()); + bool update(); + void rewind(int subsong = -1); + float getrefresh(); + + /***** Informational methods *****/ + std::string gettype(); + std::string getdesc() { return desc; } + + unsigned int getpatterns(); + unsigned int getinstruments(); + unsigned int getpattern(); + unsigned int getorders(); + unsigned int getorder(); + unsigned int getrow(); + unsigned int getspeed(); + std::string getinstrument(unsigned int n); + +protected: + RADPlayer *rad; + char *data; + + std::string desc; + +}; + +#endif diff -Nru adplug-2.3.1+dfsg/src/rad.cpp adplug-2.3.3+dfsg/src/rad.cpp --- adplug-2.3.1+dfsg/src/rad.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/rad.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ -/* - * Adplug - Replayer for many OPL2/OPL3 audio file formats. - * Copyright (C) 1999 - 2007 Simon Peter, , et al. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * rad.cpp - RAD Loader by Simon Peter - * - * BUGS: - * some volumes are dropped out - */ - -#include -#include "rad.h" - -CPlayer *CradLoader::factory(Copl *newopl) -{ - return new CradLoader(newopl); -} - -bool CradLoader::load(const std::string &filename, const CFileProvider &fp) -{ - binistream *f = fp.open(filename); if(!f) return false; - char id[16]; - unsigned char buf,ch,c,b,inp; - char bufstr[2] = "\0"; - unsigned int i,j; - unsigned short patofs[32]; - const unsigned char convfx[16] = {255,1,2,3,255,5,255,255,255,255,20,255,17,0xd,255,19}; - - // file validation section - f->readString(id, 16); version = f->readInt(1); - if(strncmp(id,"RAD by REALiTY!!",16) || version != 0x10) - { fp.close(f); return false; } - - // load section - radflags = f->readInt(1); - if(radflags & 128) { // description - memset(desc,0,80*22); - while((buf = f->readInt(1))) - if(buf == 1) - strcat(desc,"\n"); - else - if(buf >= 2 && buf <= 0x1f) - for(i=0;ireadInt(1))) { // instruments - buf--; - inst[buf].data[2] = f->readInt(1); inst[buf].data[1] = f->readInt(1); - inst[buf].data[10] = f->readInt(1); inst[buf].data[9] = f->readInt(1); - inst[buf].data[4] = f->readInt(1); inst[buf].data[3] = f->readInt(1); - inst[buf].data[6] = f->readInt(1); inst[buf].data[5] = f->readInt(1); - inst[buf].data[0] = f->readInt(1); - inst[buf].data[8] = f->readInt(1); inst[buf].data[7] = f->readInt(1); - } - length = f->readInt(1); - for(i = 0; i < length; i++) order[i] = f->readInt(1); // orderlist - for(i = 0; i < 32; i++) patofs[i] = f->readInt(2); // pattern offset table - init_trackord(); // patterns - for(i=0;i<32;i++) - if(patofs[i]) { - f->seek(patofs[i]); - do { - buf = f->readInt(1); b = buf & 127; - do { - ch = f->readInt(1); c = ch & 127; - inp = f->readInt(1); - tracks[i*9+c][b].note = inp & 127; - tracks[i*9+c][b].inst = (inp & 128) >> 3; - inp = f->readInt(1); - tracks[i*9+c][b].inst += inp >> 4; - tracks[i*9+c][b].command = inp & 15; - if(inp & 15) { - inp = f->readInt(1); - tracks[i*9+c][b].param1 = inp / 10; - tracks[i*9+c][b].param2 = inp % 10; - } - } while(!(ch & 128)); - } while(!(buf & 128)); - } else - memset(trackord[i],0,9*2); - fp.close(f); - - // convert replay data - for(i=0;i<32*9;i++) // convert patterns - for(j=0;j<64;j++) { - if(tracks[i][j].note == 15) - tracks[i][j].note = 127; - if(tracks[i][j].note > 16 && tracks[i][j].note < 127) - tracks[i][j].note -= 4 * (tracks[i][j].note >> 4); - if(tracks[i][j].note && tracks[i][j].note < 126) - tracks[i][j].note++; - tracks[i][j].command = convfx[tracks[i][j].command]; - } - restartpos = 0; initspeed = radflags & 31; - bpm = radflags & 64 ? 0 : 50; flags = Decimal; - - rewind(0); - return true; -} - -float CradLoader::getrefresh() -{ - if(tempo) - return (float) (tempo); - else - return 18.2f; -} diff -Nru adplug-2.3.1+dfsg/src/rad.h adplug-2.3.3+dfsg/src/rad.h --- adplug-2.3.1+dfsg/src/rad.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/rad.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - * Adplug - Replayer for many OPL2/OPL3 audio file formats. - * Copyright (C) 1999 - 2003 Simon Peter, , et al. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * rad.h - RAD Loader by Simon Peter - */ - -#include "protrack.h" - -class CradLoader: public CmodPlayer -{ -public: - static CPlayer *factory(Copl *newopl); - - CradLoader(Copl *newopl) - : CmodPlayer(newopl) - { *desc = '\0'; }; - - bool load(const std::string &filename, const CFileProvider &fp); - float getrefresh(); - - std::string gettype() - { return std::string("Reality ADlib Tracker"); }; - std::string getdesc() - { return std::string(desc); }; - -private: - unsigned char version,radflags; - char desc[80*22]; -}; diff -Nru adplug-2.3.1+dfsg/src/raw.cpp adplug-2.3.3+dfsg/src/raw.cpp --- adplug-2.3.1+dfsg/src/raw.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/raw.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -51,7 +51,9 @@ // load section this->clock = f->readInt(2); // clock speed - this->length = (fp.filesize(f) - 10) / 2; // Wraithverge: total data-size. + this->length = fp.filesize(f); + if (this->length <= 10) { fp.close (f); return false; } + this->length = (this->length - 10) / 2; // Wraithverge: total data-size. this->data = new Tdata [this->length]; bool tagdata = false; title[0] = 0; @@ -133,6 +135,7 @@ do { setspeed = false; + if (this->pos >= this->length) return false; switch(this->data[this->pos].command) { case 0: @@ -142,6 +145,7 @@ case 2: if (!this->data[this->pos].param) { pos++; + if (this->pos >= this->length) return false; this->speed = this->data[this->pos].param + (this->data[this->pos].command << 8); setspeed = true; } else diff -Nru adplug-2.3.1+dfsg/src/rix.cpp adplug-2.3.3+dfsg/src/rix.cpp --- adplug-2.3.1+dfsg/src/rix.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/rix.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -25,17 +25,9 @@ #include "rix.h" #include "debug.h" -#if defined(__hppa__) || \ - defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ - (defined(__MIPS__) && defined(__MISPEB__)) || \ - defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ - defined(__sparc__) - // big endian - #define RIX_SWAP32(a) (((a) << 24) | (((a) << 8) & 0x00FF0000) | (((a) >> 8) & 0x0000FF00) | ((a) >> 24)) -#else - // little endian - #define RIX_SWAP32(a) (a) -#endif +#define RIX_GET32(p, i) \ + ((uint32_t)p[4*i] | (uint32_t)p[4*i+1] << 8 | \ + (uint32_t)p[4*i+2] << 16 | (uint32_t)p[4*i + 3] << 24) const uint8_t CrixPlayer::adflag[] = {0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1}; const uint8_t CrixPlayer::reg_data[] = {0,1,2,3,4,5,8,9,10,11,12,13,16,17,18,19,20,21}; @@ -80,9 +72,8 @@ bool CrixPlayer::load(const std::string &filename, const CFileProvider &fp) { binistream *f = fp.open(filename); if(!f) return false; - uint32_t i=0; - if(stricmp(filename.substr(filename.length()-4,4).c_str(),".mkf")==0) + if (fp.extension(filename, ".mkf")) { flag_mkf=1; f->seek(0); @@ -90,11 +81,10 @@ f->seek(offset); } if(f->readInt(2)!=0x55aa){ fp.close(f);return false; } - file_buffer = new uint8_t [fp.filesize(f) + 1]; + length = pos = fp.filesize(f); + file_buffer = new uint8_t[length]; f->seek(0); - while(!f->eof()) - file_buffer[i++]=f->readInt(1); - length=i; + f->readString((char *)file_buffer, length); fp.close(f); if(!flag_mkf) rix_buf=file_buffer; @@ -122,7 +112,7 @@ bd_modify = 0; sustain = 0; play_end = 0; - pos = index = 0; + index = 0; memset(f_buffer, 0, sizeof(f_buffer)); memset(a0b0_data2, 0, sizeof(a0b0_data2)); @@ -133,15 +123,29 @@ memset(insbuf, 0, sizeof(insbuf)); memset(displace, 0, sizeof(displace)); memset(reg_bufs, 0, sizeof(reg_bufs)); - memset(for40reg, 0x7F, sizeof(for40reg)); + memset(for40reg, 0x7F, sizeof(for40reg)); // FIXME: !static - if(flag_mkf) + if (flag_mkf && subsong >= 0) { - uint32_t *buf_index=(uint32_t *)file_buffer; - int offset1=RIX_SWAP32(buf_index[subsong]),offset2; - while((offset2=RIX_SWAP32(buf_index[++subsong]))==offset1); - length=offset2-offset1+1; - rix_buf=file_buffer+offset1; + // changed to actually work and match numbering of getsubsongs() + uint32_t i, offset, next, table_end; + offset = RIX_GET32(file_buffer, 0); + table_end = offset / 4; + for (i = 1; i < table_end; i++) + { + next = RIX_GET32(file_buffer, i); + if (next != offset) + { + if (--subsong < 0) break; + offset = next; + } + } + // fix up bad/unknown offsets to end of file_buffer + if (offset > pos) offset = pos; + if (i >= table_end || next > pos || next < offset) next = pos; + // start and length of the subsong + rix_buf = file_buffer + offset; + length = next - offset; } opl->init(); opl->write(1,32); // go to OPL2 mode @@ -153,10 +157,10 @@ { if(flag_mkf) { - uint32_t *buf_index=(uint32_t *)file_buffer; - int songs=RIX_SWAP32(buf_index[0])/4,i=0; - for(i=0;i 0; i--) + if (RIX_GET32(file_buffer, i) == + RIX_GET32(file_buffer, i-1)) songs--; return songs; } @@ -192,10 +196,14 @@ } inline void CrixPlayer::data_initial() { - rhythm = rix_buf[2]; - mus_block = (rix_buf[0x0D]<<8)+rix_buf[0x0C]; - ins_block = (rix_buf[0x09]<<8)+rix_buf[0x08]; - I = mus_block+1; + if (0x0D < length) + { + rhythm = rix_buf[2]; + mus_block = (rix_buf[0x0D] << 8) + rix_buf[0x0C]; + ins_block = (rix_buf[0x09] << 8) + rix_buf[0x08]; + I = mus_block + 1; + } + else I = mus_block = length; // file too short; will stop playing immediately if(rhythm != 0) { // ad_a0b0_reg(6); @@ -273,7 +281,7 @@ uint8_t ctrl = 0; if(music_on == 0||pause_flag == 1) return 0; band = 0; - while(rix_buf[I] != 0x80 && I= length) return; + int i; uint8_t *baddr = (&rix_buf[ins_block])+(band_low<<6); @@ -306,6 +316,7 @@ /*--------------------------------------------------------------*/ inline void CrixPlayer::rix_90_pro(uint16_t ctrl_l) { + if (ctrl_l >= 11) return; // modify[] has size 28 if(rhythm == 0 || ctrl_l < 6) { ins_to_reg(modify[ctrl_l*2],insbuf,insbuf[26]); @@ -317,7 +328,7 @@ ins_to_reg(modify[ctrl_l*2+6],insbuf,insbuf[26]); return; } - else + else // same effect as 1st case, no need to handle separately { ins_to_reg(12,insbuf,insbuf[26]); ins_to_reg(15,insbuf+13,insbuf[27]); @@ -337,9 +348,10 @@ /*--------------------------------------------------------------*/ inline void CrixPlayer::prepare_a0b0(uint16_t index,uint16_t v) /* important !*/ { + if (index >= 11) return; short high = 0,low = 0; uint32_t res; int res1 = (v-0x2000)*0x19; - if(res1 == (int)0xff) return; + if(res1 == (int)0xff) return; // impossible low = res1/0x2000; if(low < 0) { @@ -367,12 +379,13 @@ /*--------------------------------------------------------------*/ inline void CrixPlayer::ad_a0b0l_reg(uint16_t index,uint16_t p2,uint16_t p3) { + if (index >= 11) return; uint16_t data; uint16_t i = p2+a0b0_data2[index]; a0b0_data4[index] = p3; a0b0_data3[index] = p2; i = ((signed short)i<=0x5F?i:0x5F); i = ((signed short)i>=0?i:0); - data = f_buffer[addrs_head[i]+displace[index]/2]; + data = f_buffer[addrs_head[i]+displace[index]/2]; // sum <= 11+24*24/2 < 300 ad_bop(0xA0+index,data); data = a0b0_data5[i]*4+(p3<1?0:0x20)+((data>>8)&3); ad_bop(0xB0+index,data); @@ -380,6 +393,7 @@ /*--------------------------------------------------------------*/ inline void CrixPlayer::rix_B0_pro(uint16_t ctrl_l,uint16_t index) { + if (ctrl_l >= 11) return; register int temp = 0; if(rhythm == 0 || ctrl_l < 6) temp = modify[ctrl_l*2+1]; else diff -Nru adplug-2.3.1+dfsg/src/rol.cpp adplug-2.3.3+dfsg/src/rol.cpp --- adplug-2.3.1+dfsg/src/rol.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/rol.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -615,11 +615,11 @@ //--------------------------------------------------------- void CrolPlayer::load_tempo_events(binistream *f) { - int16_t const num_tempo_events = static_cast(f->readInt(2)); + uint16_t const num_tempo_events = static_cast(f->readInt(2)); mTempoEvents.reserve(num_tempo_events); - for (int i=0; ierror()); if (time_of_last_note > mTimeOfLastNote) { @@ -698,17 +698,18 @@ void CrolPlayer::load_instrument_events(binistream *f, CVoiceData & voice, binistream *bnk_file, SBnkHeader const & bnk_header) { - int16_t const number_of_instrument_events = static_cast(f->readInt(2)); + uint16_t const number_of_instrument_events = static_cast(f->readInt(2)); TInstrumentEvents & instrument_events = voice.instrument_events; instrument_events.reserve(number_of_instrument_events); - for (int16_t i = 0; i < number_of_instrument_events; ++i) + for (uint16_t i = 0; i < number_of_instrument_events; ++i) { SInstrumentEvent event; event.time = static_cast(f->readInt(2)); f->readString(event.name, ROL_MAX_NAME_SIZE); + event.name[ROL_MAX_NAME_SIZE - 1] = 0; std::string event_name = event.name; if (std::find(usedInstruments.begin(), usedInstruments.end(), event_name) == usedInstruments.end()) @@ -725,13 +726,13 @@ //--------------------------------------------------------- void CrolPlayer::load_volume_events(binistream *f, CVoiceData & voice) { - int16_t const number_of_volume_events = static_cast(f->readInt(2)); + uint16_t const number_of_volume_events = static_cast(f->readInt(2)); TVolumeEvents & volume_events = voice.volume_events; volume_events.reserve(number_of_volume_events); - for (int i=0; i(f->readInt(2)); @@ -745,13 +746,13 @@ //--------------------------------------------------------- void CrolPlayer::load_pitch_events(binistream *f, CVoiceData & voice) { - int16_t const number_of_pitch_events = static_cast(f->readInt(2)); + uint16_t const number_of_pitch_events = static_cast(f->readInt(2)); TPitchEvents & pitch_events = voice.pitch_events; pitch_events.reserve(number_of_pitch_events); - for (int i=0; i(f->readInt(2)); @@ -785,6 +786,7 @@ instrument.index = static_cast(f->readInt(2)); instrument.record_used = static_cast(f->readInt(1)); f->readString(instrument.name, ROL_MAX_NAME_SIZE); + instrument.name[ROL_MAX_NAME_SIZE - 1] = 0; ins_name_list.push_back( instrument ); } @@ -816,7 +818,7 @@ if (range.first != range.second) { - int const seekOffs = header.abs_offset_of_data + (range.first->index * kSizeofDataRecord); + long int const seekOffs = header.abs_offset_of_data + (range.first->index * kSizeofDataRecord); f->seek(seekOffs, binio::Set); read_rol_instrument(f, usedInstrument.instrument); diff -Nru adplug-2.3.1+dfsg/src/rol.h adplug-2.3.3+dfsg/src/rol.h --- adplug-2.3.1+dfsg/src/rol.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/rol.h 2020-05-12 00:01:00.000000000 +0000 @@ -60,7 +60,7 @@ }; virtual std::string getinstrument(unsigned int n) { - return usedInstruments[n]; + return n < usedInstruments.size() ? usedInstruments[n] : std::string(); }; virtual std::string getdesc() { diff -Nru adplug-2.3.1+dfsg/src/sop.cpp adplug-2.3.3+dfsg/src/sop.cpp --- adplug-2.3.1+dfsg/src/sop.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/sop.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -164,6 +164,7 @@ } // event tracks track = new sop_trk[nTracks + 1]; + for (i = 0; i < nTracks + 1; i++) track[i].data = 0; for (i = 0; i < nTracks + 1; i++) { track[i].nEvents = f->readInt(2); diff -Nru adplug-2.3.1+dfsg/src/sop.h adplug-2.3.3+dfsg/src/sop.h --- adplug-2.3.1+dfsg/src/sop.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/sop.h 2020-05-12 00:01:00.000000000 +0000 @@ -168,7 +168,7 @@ } delete[] track; } - if (drv) drv->~Cad262Driver(); + if (drv) delete drv; }; bool load(const std::string &filename, const CFileProvider &fp); diff -Nru adplug-2.3.1+dfsg/src/surroundopl.cpp adplug-2.3.3+dfsg/src/surroundopl.cpp --- adplug-2.3.1+dfsg/src/surroundopl.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/surroundopl.cpp 2020-05-11 23:53:51.000000000 +0000 @@ -27,22 +27,34 @@ #include "surroundopl.h" #include "debug.h" -CSurroundopl::CSurroundopl(Copl *a, Copl *b, bool use16bit) - : use16bit(use16bit), - bufsize(4096), - a(a), b(b) +// Convert 8-bit to 16-bit +#define CV_8_16(a) ((((unsigned short)(a) << 8) | (a)) - 32768) + +// Convert 16-bit to 8-bit +#define CV_16_8(a) (((a) >> 8) + 128) + +CSurroundopl::CSurroundopl(COPLprops *a, COPLprops *b, bool output16bit) + : oplA(*a), + oplB(*b), + bufsize(4096), + output16bit(output16bit) { - currType = TYPE_OPL2; + // Report our type as the same as the first child OPL + currType = a->opl->gettype(); + this->lbuf = new short[this->bufsize]; this->rbuf = new short[this->bufsize]; + + // Default frequency offset for surroundopl is defined by FREQ_OFFSET. + this->offset = FREQ_OFFSET; }; CSurroundopl::~CSurroundopl() { delete[] this->rbuf; delete[] this->lbuf; - delete a; - delete b; + delete this->oplA.opl; + delete this->oplB.opl; } void CSurroundopl::update(short *buf, int samples) @@ -56,24 +68,45 @@ this->rbuf = new short[this->bufsize]; } - a->update(this->lbuf, samples); - b->update(this->rbuf, samples); + this->oplA.opl->update(this->lbuf, samples); + this->oplB.opl->update(this->rbuf, samples); // Copy the two mono OPL buffers into the stereo buffer for (int i = 0; i < samples; i++) { - if (this->use16bit) { - buf[i * 2] = this->lbuf[i]; - buf[i * 2 + 1] = this->rbuf[i]; + int offsetL = i, offsetR = i; + if (this->oplA.stereo) offsetL *= 2; + if (this->oplB.stereo) { offsetR *= 2; ++offsetR; } + + short l, r; + if (this->oplA.use16bit) { + l = this->lbuf[offsetL]; } else { - ((char *)buf)[i * 2] = ((char *)this->lbuf)[i]; - ((char *)buf)[i * 2 + 1] = ((char *)this->rbuf)[i]; + l = ((unsigned char *)this->lbuf)[offsetL]; + // If the synths are 8-bit, make the values 16-bit + l = CV_8_16(l); + } + if (this->oplB.use16bit) { + r = this->rbuf[offsetR]; + } else { + r = ((unsigned char *)this->rbuf)[offsetR]; + // If the synths are 8-bit, make the values 16-bit + r = CV_8_16(r); + } + + if (this->output16bit) { + buf[i * 2] = l; + buf[i * 2 + 1] = r; + } else { + // Convert back to 8-bit + ((unsigned char *)buf)[i * 2] = CV_16_8(l); + ((unsigned char *)buf)[i * 2 + 1] = CV_16_8(r); } } } void CSurroundopl::write(int reg, int val) { - a->write(reg, val); + this->oplA.opl->write(reg, val); // Transpose the other channel to produce the harmonic effect int iChannel = -1; @@ -97,7 +130,7 @@ // Adjust the frequency and calculate the new FNum //double dbNewFNum = (dbOriginalFreq+(dbOriginalFreq/FREQ_OFFSET)) / (50000.0 * pow(2, iNewBlock - 20)); //#define calcFNum() ((dbOriginalFreq+(dbOriginalFreq/FREQ_OFFSET)) / (50000.0 * pow(2, iNewBlock - 20))) - #define calcFNum() ((dbOriginalFreq+(dbOriginalFreq/FREQ_OFFSET)) / (49716.0 * pow(2.0, iNewBlock - 20))) + #define calcFNum() ((dbOriginalFreq+(dbOriginalFreq/this->offset)) / (49716.0 * pow(2.0, iNewBlock - 20))) double dbNewFNum = calcFNum(); // Make sure it's in range for the OPL chip @@ -159,7 +192,7 @@ // Need to write out low bits uint8_t iAdditionalReg = 0xA0 + iChannel; uint8_t iAdditionalValue = iNewFNum & 0xFF; - b->write(iAdditionalReg, iAdditionalValue); + this->oplB.opl->write(iAdditionalReg, iAdditionalValue); this->iTweakedFMReg[this->currChip][iAdditionalReg] = iAdditionalValue; } } else if ((iRegister >= 0xA0) && (iRegister <= 0xA8)) { @@ -177,7 +210,7 @@ iChannel, iFNum, iBlock, iNewFNum, iNewBlock); // The note is already playing, so we need to adjust the upper bits too uint8_t iAdditionalReg = 0xB0 + iChannel; - b->write(iAdditionalReg, iNewB0Value); + this->oplB.opl->write(iAdditionalReg, iNewB0Value); this->iTweakedFMReg[this->currChip][iAdditionalReg] = iNewB0Value; } // else the note is not playing, the upper bits will be set when the note is next played @@ -186,14 +219,14 @@ } // if (a register we're interested in) // Now write to the original register with a possibly modified value - b->write(iRegister, iValue); + this->oplB.opl->write(iRegister, iValue); this->iTweakedFMReg[this->currChip][iRegister] = iValue; } void CSurroundopl::init() { - a->init(); - b->init(); + this->oplA.opl->init(); + this->oplB.opl->init(); for (int c = 0; c < 2; c++) { for (int i = 0; i < 256; i++) { this->iFMReg[c][i] = 0; @@ -208,6 +241,14 @@ void CSurroundopl::setchip(int n) { - a->setchip(n); - b->setchip(n); + this->oplA.opl->setchip(n); + this->oplB.opl->setchip(n); } + +void CSurroundopl::set_offset(double offset) +{ + if (offset != 0) + { + this->offset = offset; + } +} \ No newline at end of file diff -Nru adplug-2.3.1+dfsg/src/surroundopl.h adplug-2.3.3+dfsg/src/surroundopl.h --- adplug-2.3.1+dfsg/src/surroundopl.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/surroundopl.h 2020-05-11 23:53:51.000000000 +0000 @@ -42,21 +42,29 @@ // one block is too high and the adjacent block is too low ;-) #define NEWBLOCK_LIMIT 32 +struct COPLprops { + Copl *opl; + bool use16bit; // false == 8bit + bool stereo; // false == mono +}; + class CSurroundopl: public Copl { private: - bool use16bit; + COPLprops oplA, oplB; short bufsize; short *lbuf, *rbuf; - Copl *a, *b; + bool output16bit; uint8_t iFMReg[2][256]; uint8_t iTweakedFMReg[2][256]; uint8_t iCurrentTweakedBlock[2][9]; // Current value of the Block in the tweaked OPL chip uint8_t iCurrentFNum[2][9]; // Current value of the FNum in the tweaked OPL chip + double offset; // User configurable frequency offset for surroundopl public: - CSurroundopl(Copl *a, Copl *b, bool use16bit); + // Takes ownership of a->opl and b->opl + CSurroundopl(COPLprops *a, COPLprops *b, bool output16bit); ~CSurroundopl(); void update(short *buf, int samples); @@ -64,6 +72,7 @@ void init(); void setchip(int n); + void set_offset(double offset); }; #endif diff -Nru adplug-2.3.1+dfsg/src/u6m.cpp adplug-2.3.3+dfsg/src/u6m.cpp --- adplug-2.3.1+dfsg/src/u6m.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/u6m.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -23,11 +23,7 @@ #include "u6m.h" // Makes security checks on output buffer before writing -#define SAVE_OUTPUT_ROOT(c, d, p) \ -if(p < d.size) \ - output_root(c, d.data, p); \ -else \ - return false; +#define SAVE_OUTPUT_ROOT(c, d, p) if(!output_root(c, d, p)) return false; CPlayer *Cu6mPlayer::factory(Copl *newopl) { @@ -38,7 +34,7 @@ { // file validation section // this section only checks a few *necessary* conditions - unsigned long filesize, decompressed_filesize; + size_t filesize, decompressed_filesize; binistream *f; f = fp.open(filename); if(!f) return false; @@ -66,6 +62,7 @@ } // load section + delete[] song_data; song_size = 0; song_data = new unsigned char[decompressed_filesize]; unsigned char* compressed_song_data = new unsigned char[filesize-3]; @@ -74,7 +71,6 @@ fp.close(f); // attempt to decompress the song data - // if unsuccessful, deallocate song_data[] on the spot, and return(false) data_block source, destination; source.size = filesize-4; source.data = compressed_song_data; @@ -84,13 +80,13 @@ if (!lzw_decompress(source,destination)) { delete[] compressed_song_data; - delete[] song_data; return(false); } // deallocation section delete[] compressed_song_data; + song_size = decompressed_filesize; rewind(0); return (true); } @@ -148,7 +144,6 @@ void Cu6mPlayer::rewind(int subsong) { - played_ticks = 0; songend = false; // set the driver's internal variables @@ -206,13 +201,13 @@ { bool end_marker_reached = false; int codeword_size = 9; - long bits_read = 0; + unsigned long bits_read = 0; int next_free_codeword = 0x102; int dictionary_size = 0x200; MyDict dictionary = MyDict(); std::stack root_stack; - long bytes_written = 0; + size_t bytes_written = 0; int cW; int pW; @@ -220,7 +215,7 @@ while (!end_marker_reached) { - cW = get_next_codeword(bits_read, source.data, codeword_size); + cW = get_next_codeword(bits_read, source, codeword_size); switch (cW) { // re-init the dictionary @@ -229,13 +224,16 @@ next_free_codeword = 0x102; dictionary_size = 0x200; dictionary.reset(); - cW = get_next_codeword(bits_read, source.data, codeword_size); + cW = get_next_codeword(bits_read, source, codeword_size); SAVE_OUTPUT_ROOT((unsigned char)cW, dest, bytes_written); break; // end of compressed file has been reached case 0x101: end_marker_reached = true; break; + // no next code word available, i.e., truncated or invalid data + case -1: + return false; // (cW <> 0x100) && (cW <> 0x101) default: if (cW < next_free_codeword) // codeword is already in the dictionary @@ -313,14 +311,20 @@ // Read the next code word from the source buffer -int Cu6mPlayer::get_next_codeword (long& bits_read, unsigned char *source, int codeword_size) +int Cu6mPlayer::get_next_codeword (unsigned long& bits_read, data_block& source, + int codeword_size) { unsigned char b0,b1,b2; int codeword; - - b0 = source[bits_read/8]; - b1 = source[bits_read/8+1]; - b2 = source[bits_read/8+2]; + + if (source.size - bits_read / 8 < 2 + (bits_read % 8 + codeword_size > 16)) + { + return -1; // source exhausted + } + + b0 = source.data[bits_read/8]; + b1 = source.data[bits_read/8+1]; + b2 = bits_read % 8 + codeword_size > 16 ? source.data[bits_read/8+2] : 0; codeword = ((b2 << 16) + (b1 << 8) + b0); codeword = codeword >> (bits_read % 8); @@ -349,10 +353,17 @@ // output a root to memory -void Cu6mPlayer::output_root(unsigned char root, unsigned char *destination, long& position) +bool Cu6mPlayer::output_root(unsigned char root, data_block& destination, + size_t& position) { - destination[position] = root; + if (position >= destination.size) + { + return false; + } + + destination.data[position] = root; position++; + return true; } @@ -388,7 +399,7 @@ // This function reads the song data and executes the embedded commands. void Cu6mPlayer::command_loop() { - unsigned char command_byte; // current command byte + int command_byte; // current command byte int command_nibble_hi; // command byte, bits 4-7 int command_nibble_lo; // command byte, bite 0-3 bool repeat_loop = true; // @@ -397,6 +408,11 @@ { // extract low and high command nibbles command_byte = read_song_byte(); // implicitly increments song_pos + if (command_byte < 0) // handle invalid position + { + songend = true; + break; + } command_nibble_hi = command_byte >> 4; command_nibble_lo = command_byte & 0xf; @@ -446,7 +462,10 @@ freq_byte = read_song_byte(); freq_word = expand_freq_byte(freq_byte); - set_adlib_freq(channel,freq_word); + if (channel < 9) + { + set_adlib_freq(channel, freq_word); + } } @@ -457,18 +476,19 @@ // --------------------------------------------------- void Cu6mPlayer::command_1(int channel) { - unsigned char freq_byte; - byte_pair freq_word; + unsigned char freq_byte = read_song_byte(); + byte_pair freq_word = expand_freq_byte(freq_byte); - vb_direction_flag[channel] = 0; - vb_current_value[channel] = 0; + if (channel < 9) + { + vb_direction_flag[channel] = 0; + vb_current_value[channel] = 0; - freq_byte = read_song_byte(); - freq_word = expand_freq_byte(freq_byte); - set_adlib_freq(channel,freq_word); + set_adlib_freq(channel, freq_word); - freq_word.hi = freq_word.hi | 0x20; // note on - set_adlib_freq(channel,freq_word); + freq_word.hi = freq_word.hi | 0x20; // note on + set_adlib_freq(channel, freq_word); + } } @@ -485,7 +505,10 @@ freq_byte = read_song_byte(); freq_word = expand_freq_byte(freq_byte); freq_word.hi = freq_word.hi | 0x20; // note on - set_adlib_freq(channel,freq_word); + if (channel < 9) + { + set_adlib_freq(channel, freq_word); + } } @@ -496,11 +519,13 @@ // -------------------------------------- void Cu6mPlayer::command_3(int channel) { - unsigned char mf_byte; + unsigned char mf_byte = read_song_byte(); - carrier_mf_signed_delta[channel] = 0; - mf_byte = read_song_byte(); - set_carrier_mf(channel,mf_byte); + if (channel < 9) + { + carrier_mf_signed_delta[channel] = 0; + set_carrier_mf(channel, mf_byte); // apply mask? + } } @@ -511,10 +536,12 @@ // ---------------------------------------- void Cu6mPlayer::command_4(int channel) { - unsigned char mf_byte; + unsigned char mf_byte = read_song_byte(); - mf_byte = read_song_byte(); - set_modulator_mf(channel,mf_byte); + if (channel < 9) + { + set_modulator_mf(channel, mf_byte); // apply mask? + } } @@ -525,7 +552,12 @@ // -------------------------------------------- void Cu6mPlayer::command_5(int channel) { - channel_freq_signed_delta[channel] = read_signed_song_byte(); + signed char delta = read_signed_song_byte(); + + if (channel < 9) + { + channel_freq_signed_delta[channel] = delta; + } } @@ -538,11 +570,13 @@ // -------------------------------------------- void Cu6mPlayer::command_6(int channel) { - unsigned char vb_parameters; + unsigned char vb_parameters = read_song_byte(); - vb_parameters = read_song_byte(); - vb_double_amplitude[channel] = vb_parameters >> 4; // high nibble - vb_multiplier[channel] = vb_parameters & 0xF; // low nibble + if (channel < 9) + { + vb_double_amplitude[channel] = vb_parameters >> 4; // high nibble + vb_multiplier[channel] = vb_parameters & 0xF; // low nibble + } } @@ -553,18 +587,23 @@ // ---------------------------------------- void Cu6mPlayer::command_7(int channel) { - int instrument_offset = instrument_offsets[read_song_byte()]; - out_adlib_opcell(channel, false, 0x20, *(song_data + instrument_offset+0)); - out_adlib_opcell(channel, false, 0x40, *(song_data + instrument_offset+1)); - out_adlib_opcell(channel, false, 0x60, *(song_data + instrument_offset+2)); - out_adlib_opcell(channel, false, 0x80, *(song_data + instrument_offset+3)); - out_adlib_opcell(channel, false, 0xE0, *(song_data + instrument_offset+4)); - out_adlib_opcell(channel, true, 0x20, *(song_data + instrument_offset+5)); - out_adlib_opcell(channel, true, 0x40, *(song_data + instrument_offset+6)); - out_adlib_opcell(channel, true, 0x60, *(song_data + instrument_offset+7)); - out_adlib_opcell(channel, true, 0x80, *(song_data + instrument_offset+8)); - out_adlib_opcell(channel, true, 0xE0, *(song_data + instrument_offset+9)); - out_adlib(0xC0+channel, *(song_data + instrument_offset+10)); + unsigned char instrument_number = read_song_byte(); + + if (channel < 9 && instrument_number < 9) + { + size_t instrument_offset = instrument_offsets[instrument_number]; + out_adlib_opcell(channel, false, 0x20, song_data[instrument_offset+0]); + out_adlib_opcell(channel, false, 0x40, song_data[instrument_offset+1]); + out_adlib_opcell(channel, false, 0x60, song_data[instrument_offset+2]); + out_adlib_opcell(channel, false, 0x80, song_data[instrument_offset+3]); + out_adlib_opcell(channel, false, 0xE0, song_data[instrument_offset+4]); + out_adlib_opcell(channel, true, 0x20, song_data[instrument_offset+5]); + out_adlib_opcell(channel, true, 0x40, song_data[instrument_offset+6]); + out_adlib_opcell(channel, true, 0x60, song_data[instrument_offset+7]); + out_adlib_opcell(channel, true, 0x80, song_data[instrument_offset+8]); + out_adlib_opcell(channel, true, 0xE0, song_data[instrument_offset+9]); + out_adlib(0xC0+channel, song_data[instrument_offset+10]); + } } @@ -580,9 +619,12 @@ subsong_info new_ss_info; new_ss_info.subsong_repetitions = read_song_byte(); - new_ss_info.subsong_start = read_song_byte(); new_ss_info.subsong_start += read_song_byte() << 8; + new_ss_info.subsong_start = read_song_byte(); + new_ss_info.subsong_start += read_song_byte() << 8; new_ss_info.continue_pos = song_pos; + // Since the new position is not validated, this could jump after the + // end of song_data. Handled by the usual checks. subsong_stack.push(new_ss_info); song_pos = new_ss_info.subsong_start; } @@ -607,8 +649,12 @@ void Cu6mPlayer::command_83() { unsigned char instrument_number = read_song_byte(); - instrument_offsets[instrument_number] = song_pos; - song_pos += 11; + + if (instrument_number < 9 && song_size > 11 && song_pos < song_size - 11) + { + instrument_offsets[instrument_number] = song_pos; + song_pos += 11; + } } @@ -623,9 +669,13 @@ unsigned char data_byte = read_song_byte(); int channel = data_byte >> 4; // high nibble unsigned char slide_delay = data_byte & 0xF; // low nibble - carrier_mf_signed_delta[channel] = +1; - carrier_mf_mod_delay[channel] = slide_delay + 1; - carrier_mf_mod_delay_backup[channel] = slide_delay + 1; + + if (channel < 9) + { + carrier_mf_signed_delta[channel] = +1; + carrier_mf_mod_delay[channel] = slide_delay + 1; + carrier_mf_mod_delay_backup[channel] = slide_delay + 1; + } } @@ -640,9 +690,13 @@ unsigned char data_byte = read_song_byte(); int channel = data_byte >> 4; // high nibble unsigned char slide_delay = data_byte & 0xF; // low nibble - carrier_mf_signed_delta[channel] = -1; - carrier_mf_mod_delay[channel] = slide_delay + 1; - carrier_mf_mod_delay_backup[channel] = slide_delay + 1; + + if (channel < 9) + { + carrier_mf_signed_delta[channel] = -1; + carrier_mf_mod_delay[channel] = slide_delay + 1; + carrier_mf_mod_delay_backup[channel] = slide_delay + 1; + } } @@ -699,31 +753,29 @@ // Returns the byte at the current song position. // Side effect: increments song_pos. -unsigned char Cu6mPlayer::read_song_byte() +int Cu6mPlayer::read_song_byte() { - unsigned char song_byte; - song_byte = song_data[song_pos]; - song_pos++; - return(song_byte); + if (song_pos < song_size) + { + return song_data[song_pos++]; + } + else + { + return -1; + } } // Same as read_song_byte(), except that it returns a signed byte signed char Cu6mPlayer::read_signed_song_byte() { - unsigned char song_byte; - int signed_value; - song_byte = *(song_data + song_pos); - song_pos++; - if (song_byte <= 127) - { - signed_value = song_byte; - } - else + int song_byte = read_song_byte(); + + if (song_byte >= 0x80) { - signed_value = (int)song_byte - 0x100; + song_byte -= 0x100; } - return((signed char)signed_value); + return song_byte; } diff -Nru adplug-2.3.1+dfsg/src/u6m.h adplug-2.3.3+dfsg/src/u6m.h --- adplug-2.3.1+dfsg/src/u6m.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/u6m.h 2020-05-12 00:01:00.000000000 +0000 @@ -32,7 +32,7 @@ public: static CPlayer *factory(Copl *newopl); - Cu6mPlayer(Copl *newopl) : CPlayer(newopl), song_data(0) + Cu6mPlayer(Copl *newopl) : CPlayer(newopl), song_data(0), song_size(0) { }; @@ -62,20 +62,20 @@ struct subsong_info // information about a subsong { - int continue_pos; + size_t continue_pos; + size_t subsong_start; int subsong_repetitions; - int subsong_start; }; struct dict_entry // dictionary entry { unsigned char root; - int codeword; + short int codeword; }; struct data_block // { - long size; + size_t size; unsigned char *data; }; @@ -101,17 +101,16 @@ // class variables - long played_ticks; - unsigned char* song_data; // the uncompressed .m file (the "song") + size_t song_size; // allocated size of song_data bool driver_active; // flag to prevent reentrancy - bool songend; // indicates song end - int song_pos; // current offset within the song - int loop_position; // position of the loop point + bool songend; // indicates song end + size_t song_pos; // current offset within the song + size_t loop_position; // position of the loop point int read_delay; // delay (in timer ticks) before further song data is read std::stack subsong_stack; - int instrument_offsets[9]; // offsets of the adlib instrument data + size_t instrument_offsets[9]; // offsets of the adlib instrument data // vibrato ("vb") unsigned char vb_current_value[9]; unsigned char vb_double_amplitude[9]; @@ -128,7 +127,7 @@ // protected functions used by update() void command_loop(); - unsigned char read_song_byte(); + int read_song_byte(); signed char read_signed_song_byte(); void dec_clip(int&); byte_pair expand_freq_byte(unsigned char); @@ -161,8 +160,8 @@ // protected functions used by load() bool lzw_decompress(data_block source, data_block dest); - int get_next_codeword (long& bits_read, unsigned char *source, int codeword_size); - void output_root(unsigned char root, unsigned char *destination, long& position); + int get_next_codeword(unsigned long& bits_read, data_block& source, int codeword_size); + bool output_root(unsigned char root, data_block& destination, size_t& position); void get_string(int codeword, MyDict& dictionary, std::stack& root_stack); }; diff -Nru adplug-2.3.1+dfsg/src/version.h adplug-2.3.3+dfsg/src/version.h --- adplug-2.3.1+dfsg/src/version.h 2018-04-22 09:12:52.000000000 +0000 +++ adplug-2.3.3+dfsg/src/version.h 2020-06-10 00:53:32.000000000 +0000 @@ -1 +1 @@ -#define ADPLUG_VERSION "2.3.1" +#define ADPLUG_VERSION "2.3.3" diff -Nru adplug-2.3.1+dfsg/src/wemuopl.h adplug-2.3.3+dfsg/src/wemuopl.h --- adplug-2.3.1+dfsg/src/wemuopl.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/wemuopl.h 2020-05-12 00:01:00.000000000 +0000 @@ -31,6 +31,7 @@ { public: CWemuopl(int rate, bool bit16, bool usestereo) + : use16bit(bit16), stereo(usestereo), sampleerate(rate) { opl.adlib_init(rate, usestereo ? 2 : 1, bit16 ? 2 : 1); currType = TYPE_OPL2; @@ -47,10 +48,15 @@ opl.adlib_write((currChip << 8) | reg, val); }; - void init() {}; + void init() { + opl.adlib_init(sampleerate, stereo ? 2 : 1, use16bit ? 2 : 1); + currChip = 0; + }; private: OPLChipClass opl; + bool use16bit,stereo; + int sampleerate; }; #endif diff -Nru adplug-2.3.1+dfsg/src/xad.cpp adplug-2.3.3+dfsg/src/xad.cpp --- adplug-2.3.1+dfsg/src/xad.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/xad.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -82,7 +82,13 @@ else { // get file size - tune_size = fp.filesize(f) - 80; + tune_size = fp.filesize(f); + if (tune_size <= 80) + { + fp.close(f); + return false; + } + tune_size -= 80; } // load() diff -Nru adplug-2.3.1+dfsg/src/xsm.cpp adplug-2.3.3+dfsg/src/xsm.cpp --- adplug-2.3.1+dfsg/src/xsm.cpp 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/xsm.cpp 2020-05-12 00:01:00.000000000 +0000 @@ -45,17 +45,9 @@ // read and set instruments for(i = 0; i < 9; i++) { - opl->write(0x20 + op_table[i], f->readInt(1)); - opl->write(0x23 + op_table[i], f->readInt(1)); - opl->write(0x40 + op_table[i], f->readInt(1)); - opl->write(0x43 + op_table[i], f->readInt(1)); - opl->write(0x60 + op_table[i], f->readInt(1)); - opl->write(0x63 + op_table[i], f->readInt(1)); - opl->write(0x80 + op_table[i], f->readInt(1)); - opl->write(0x83 + op_table[i], f->readInt(1)); - opl->write(0xe0 + op_table[i], f->readInt(1)); - opl->write(0xe3 + op_table[i], f->readInt(1)); - opl->write(0xc0 + op_table[i], f->readInt(1)); + for (j = 0; j < 11; j++) { + inst[i].value[j] = f->readInt(1); + } f->ignore(5); } @@ -98,8 +90,23 @@ void CxsmPlayer::rewind(int subsong) { + int i; notenum = last = 0; songend = false; + opl->init(); opl->write(1, 32); + for (i = 0; i < 9; i++) { + opl->write(0x20 + op_table[i], inst[i].value[0]); + opl->write(0x23 + op_table[i], inst[i].value[1]); + opl->write(0x40 + op_table[i], inst[i].value[2]); + opl->write(0x43 + op_table[i], inst[i].value[3]); + opl->write(0x60 + op_table[i], inst[i].value[4]); + opl->write(0x63 + op_table[i], inst[i].value[5]); + opl->write(0x80 + op_table[i], inst[i].value[6]); + opl->write(0x83 + op_table[i], inst[i].value[7]); + opl->write(0xe0 + op_table[i], inst[i].value[8]); + opl->write(0xe3 + op_table[i], inst[i].value[9]); + opl->write(0xc0 + op_table[i], inst[i].value[10]); + } } float CxsmPlayer::getrefresh() diff -Nru adplug-2.3.1+dfsg/src/xsm.h adplug-2.3.3+dfsg/src/xsm.h --- adplug-2.3.1+dfsg/src/xsm.h 2018-01-22 20:14:17.000000000 +0000 +++ adplug-2.3.3+dfsg/src/xsm.h 2020-05-12 00:01:00.000000000 +0000 @@ -41,6 +41,9 @@ char *music; unsigned int last, notenum; bool songend; + struct { + unsigned char value[11]; + } inst[9]; void play_note(int c, int note, int octv); }; diff -Nru adplug-2.3.1+dfsg/test-driver adplug-2.3.3+dfsg/test-driver --- adplug-2.3.1+dfsg/test-driver 2018-04-22 09:12:30.000000000 +0000 +++ adplug-2.3.3+dfsg/test-driver 2015-07-25 00:29:35.000000000 +0000 @@ -1,9 +1,9 @@ #! /bin/sh # test-driver - basic testsuite driver script. -scriptversion=2018-03-07.03; # UTC +scriptversion=2013-07-13.22; # UTC -# Copyright (C) 2011-2018 Free Software Foundation, Inc. +# Copyright (C) 2011-2014 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -140,9 +140,9 @@ # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'before-save-hook 'time-stamp) +# eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" +# time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: diff -Nru adplug-2.3.1+dfsg/texinfo.tex adplug-2.3.3+dfsg/texinfo.tex --- adplug-2.3.1+dfsg/texinfo.tex 2018-04-22 09:12:30.000000000 +0000 +++ adplug-2.3.3+dfsg/texinfo.tex 2017-11-21 23:32:08.000000000 +0000 @@ -3,11 +3,11 @@ % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % -\def\texinfoversion{2018-02-12.17} +\def\texinfoversion{2017-06-04.19} % % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, -% 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 +% 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 % Free Software Foundation, Inc. % % This texinfo.tex file is free software: you can redistribute it and/or @@ -21,7 +21,7 @@ % General Public License for more details. % % You should have received a copy of the GNU General Public License -% along with this program. If not, see . +% along with this program. If not, see . % % As a special exception, when this file is read by TeX when processing % a Texinfo source document, you may use the result without @@ -30,9 +30,9 @@ % % Please try the latest version of texinfo.tex before submitting bug % reports; you can get the latest version from: -% https://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or -% https://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or -% https://www.gnu.org/software/texinfo/ (the Texinfo home page) +% http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or +% http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or +% http://www.gnu.org/software/texinfo/ (the Texinfo home page) % The texinfo.tex in any given distribution could well be out % of date, so if that's what you're using, please check. % @@ -56,7 +56,7 @@ % extent. You can get the existing language-specific files from the % full Texinfo distribution. % -% The GNU Texinfo home page is https://www.gnu.org/software/texinfo. +% The GNU Texinfo home page is http://www.gnu.org/software/texinfo. \message{Loading texinfo [version \texinfoversion]:} @@ -182,7 +182,7 @@ % Hyphenation fixes. \hyphenation{ Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script - auto-ma-ti-cal-ly ap-pen-dix bit-map bit-maps + ap-pen-dix bit-map bit-maps data-base data-bases eshell fall-ing half-way long-est man-u-script man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces @@ -2235,20 +2235,6 @@ \font\smallersy=cmsy8 \def\smallerecsize{0800} -% Fonts for math mode superscripts (7pt). -\def\sevennominalsize{7pt} -\setfont\sevenrm\rmshape{7}{1000}{OT1} -\setfont\seventt\ttshape{10}{700}{OT1TT} -\setfont\sevenbf\bfshape{10}{700}{OT1} -\setfont\sevenit\itshape{7}{1000}{OT1IT} -\setfont\sevensl\slshape{10}{700}{OT1} -\setfont\sevensf\sfshape{10}{700}{OT1} -\setfont\sevensc\scshape{10}{700}{OT1} -\setfont\seventtsl\ttslshape{10}{700}{OT1TT} -\font\seveni=cmmi7 -\font\sevensy=cmsy7 -\def\sevenecsize{0700} - % Fonts for title page (20.4pt): \def\titlenominalsize{20pt} \setfont\titlerm\rmbshape{12}{\magstep3}{OT1} @@ -2383,20 +2369,6 @@ \font\smallersy=cmsy8 \def\smallerecsize{0800} -% Fonts for math mode superscripts (7pt). -\def\sevennominalsize{7pt} -\setfont\sevenrm\rmshape{7}{1000}{OT1} -\setfont\seventt\ttshape{10}{700}{OT1TT} -\setfont\sevenbf\bfshape{10}{700}{OT1} -\setfont\sevenit\itshape{7}{1000}{OT1IT} -\setfont\sevensl\slshape{10}{700}{OT1} -\setfont\sevensf\sfshape{10}{700}{OT1} -\setfont\sevensc\scshape{10}{700}{OT1} -\setfont\seventtsl\ttslshape{10}{700}{OT1TT} -\font\seveni=cmmi7 -\font\sevensy=cmsy7 -\def\sevenecsize{0700} - % Fonts for title page (20.4pt): \def\titlenominalsize{20pt} \setfont\titlerm\rmbshape{12}{\magstep3}{OT1} @@ -2531,20 +2503,13 @@ % In order for the font changes to affect most math symbols and letters, -% we have to define the \textfont of the standard families. -% We don't bother to reset \scriptscriptfont; awaiting user need. +% we have to define the \textfont of the standard families. We don't +% bother to reset \scriptfont and \scriptscriptfont; awaiting user need. % \def\resetmathfonts{% \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont \textfont\ttfam=\ttfont \textfont\sffam=\sffont - % - % Fonts for superscript. Note that the 7pt fonts are used regardless - % of the current font size. - \scriptfont0=\sevenrm \scriptfont1=\seveni \scriptfont2=\sevensy - \scriptfont\itfam=\sevenit \scriptfont\slfam=\sevensl - \scriptfont\bffam=\sevenbf \scriptfont\ttfam=\seventt - \scriptfont\sffam=\sevensf } % @@ -2554,9 +2519,6 @@ % to also set the current \fam for math mode. Our \STYLE (e.g., \rm) % commands hardwire \STYLEfont to set the current font. % -% The fonts used for \ifont are for "math italics" (\itfont is for italics -% in regular text). \syfont is also used in math mode only. -% % Each font-changing command also sets the names \lsize (one size lower) % and \lllsize (three sizes lower). These relative commands are used % in, e.g., the LaTeX logo and acronyms. @@ -2657,11 +2619,26 @@ % Markup style infrastructure. \defmarkupstylesetup\INITMACRO will % define and register \INITMACRO to be called on markup style changes. % \INITMACRO can check \currentmarkupstyle for the innermost -% style. +% style and the set of \ifmarkupSTYLE switches for all styles +% currently in effect. +\newif\ifmarkupvar +\newif\ifmarkupsamp +\newif\ifmarkupkey +%\newif\ifmarkupfile % @file == @samp. +%\newif\ifmarkupoption % @option == @samp. +\newif\ifmarkupcode +\newif\ifmarkupkbd +%\newif\ifmarkupenv % @env == @code. +%\newif\ifmarkupcommand % @command == @code. +\newif\ifmarkuptex % @tex (and part of @math, for now). +\newif\ifmarkupexample +\newif\ifmarkupverb +\newif\ifmarkupverbatim \let\currentmarkupstyle\empty \def\setupmarkupstyle#1{% + \csname markup#1true\endcsname \def\currentmarkupstyle{#1}% \markupstylesetup } @@ -2723,15 +2700,11 @@ % lilypond developers report. xpdf does work with the regular 0x27. % \def\codequoteright{% - \ifmonospace - \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax - \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax - '% - \else \char'15 \fi + \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax + \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax + '% \else \char'15 \fi - \else - '% - \fi + \else \char'15 \fi } % % and a similar option for the left quote char vs. a grave accent. @@ -2739,17 +2712,13 @@ % the code environments to do likewise. % \def\codequoteleft{% - \ifmonospace - \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax - \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax - % [Knuth] pp. 380,381,391 - % \relax disables Spanish ligatures ?` and !` of \tt font. - \relax`% - \else \char'22 \fi + \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax + \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax + % [Knuth] pp. 380,381,391 + % \relax disables Spanish ligatures ?` and !` of \tt font. + \relax`% \else \char'22 \fi - \else - \relax`% - \fi + \else \char'22 \fi } % Commands to set the quote options. @@ -5727,13 +5696,10 @@ \advance\dimen@ii by 1\dimen@i \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line \ifdim\dimen@ > 0.8\dimen@ii % due to long index text - % Try to split the text roughly evenly. \dimen@ will be the length of - % the first line. - \dimen@ = 0.7\dimen@ + \dimen@ = 0.7\dimen@ % Try to split the text roughly evenly \dimen@ii = \hsize \ifnum\dimen@>\dimen@ii - % If the entry is too long (for example, if it needs more than - % two lines), use all the space in the first line. + % If the entry is too long, use the whole line \dimen@ = \dimen@ii \fi \advance\leftskip by 0pt plus 1fill % ragged right @@ -5743,9 +5709,8 @@ % instead of using \parshape with explicit line lengths, but TeX % doesn't seem to provide a way to do such a thing. % - % Indent all lines but the first one. - \advance\leftskip by 1em - \advance\parindent by -1em + \leftskip = 1em + \parindent = -1em \fi\fi \indent % start paragraph \unhbox\boxA @@ -6000,30 +5965,24 @@ % Split the last of the double-column material. \savemarks \balancecolumns - }% - \eject % call the \output just set - \ifdim\pagetotal=0pt + % % Having called \balancecolumns once, we do not % want to call it again. Therefore, reset \output to its normal % definition right away. \global\output = {\onepageout{\pagecontents\PAGE}}% - % - \endgroup % started in \begindoublecolumns - \restoremarks - % Leave the double-column material on the current page, no automatic - % page break. - \box\balancedcolumns - % - % \pagegoal was set to the doubled \vsize above, since we restarted - % the current page. We're now back to normal single-column - % typesetting, so reset \pagegoal to the normal \vsize. - \global\vsize = \txipageheight % - \pagegoal = \txipageheight % - \else - % We had some left-over material. This might happen when \doublecolumnout - % is called in \balancecolumns. Try again. - \expandafter\enddoublecolumns - \fi + }% + \eject + \endgroup % started in \begindoublecolumns + \restoremarks + % Leave the double-column material on the current page, no automatic + % page break. + \box\balancedcolumns + % + % \pagegoal was set to the doubled \vsize above, since we restarted + % the current page. We're now back to normal single-column + % typesetting, so reset \pagegoal to the normal \vsize. + \global\vsize = \txipageheight % + \pagegoal = \txipageheight % } \newbox\balancedcolumns \setbox\balancedcolumns=\vbox{shouldnt see this}% @@ -6038,7 +5997,6 @@ \ifdim\dimen@<5\baselineskip % Don't split a short final column in two. \setbox2=\vbox{}% - \global\setbox\balancedcolumns=\vbox{\pagesofar}% \else \divide\dimen@ by 2 % target to split to \dimen@ii = \dimen@ @@ -6054,15 +6012,15 @@ \repeat }% % Now the left column is in box 1, and the right column in box 3. - % % Check whether the left column has come out higher than the page itself. % (Note that we have doubled \vsize for the double columns, so % the actual height of the page is 0.5\vsize). \ifdim2\ht1>\vsize - % It appears that we have been called upon to balance too much material. - % Output some of it with \doublecolumnout, leaving the rest on the page. - \setbox\PAGE=\box0 - \doublecolumnout + % Just split the last of the double column material roughly in half. + \setbox2=\box0 + \setbox0 = \vsplit2 to \dimen@ii + \setbox0=\vbox to \dimen@ii {\unvbox0\vfill}% + \setbox2=\vbox to \dimen@ii {\unvbox2\vfill}% \else % Compare the heights of the two columns. \ifdim4\ht1>5\ht3 @@ -6075,10 +6033,10 @@ \setbox2=\vbox to\ht1{\unvbox3\unskip}% \setbox0=\vbox to\ht1{\unvbox1\unskip}% \fi - \global\setbox\balancedcolumns=\vbox{\pagesofar}% \fi \fi % + \global\setbox\balancedcolumns=\vbox{\pagesofar}% } \catcode`\@ = \other @@ -6985,15 +6943,7 @@ % exist, with an empty box. Let's hope all the numbers have the same width. % Also ignore the page number, which is conventionally not printed. \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}} -\def\partentry#1#2#3#4{% - % Add stretch and a bonus for breaking the page before the part heading. - % This reduces the chance of the page being broken immediately after the - % part heading, before a following chapter heading. - \vskip 0pt plus 5\baselineskip - \penalty-300 - \vskip 0pt plus -5\baselineskip - \dochapentry{\numeralbox\labelspace#1}{}% -} +\def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}} % % Parts, in the short toc. \def\shortpartentry#1#2#3#4{% @@ -9484,7 +9434,7 @@ \newif\ifwarnednoepsf \newhelp\noepsfhelp{epsf.tex must be installed for images to work. It is also included in the Texinfo distribution, or you can get - it from https://ctan.org/texarchive/macros/texinfo/texinfo/doc/epsf.tex.} + it from ftp://tug.org/tex/epsf.tex.} % \def\image#1{% \ifx\epsfbox\thisisundefined @@ -11059,6 +11009,7 @@ \DeclareUnicodeCharacter{2113}{\ensuremath\ell}% \DeclareUnicodeCharacter{2118}{\ensuremath\wp}% \DeclareUnicodeCharacter{211C}{\ensuremath\Re}% + \DeclareUnicodeCharacter{2127}{\ensuremath\mho}% \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}% \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}% \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}% @@ -11074,6 +11025,7 @@ \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}% \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}% \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}% + \DeclareUnicodeCharacter{21BE}{\ensuremath\upharpoonright}% \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}% \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}% \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}% @@ -11082,6 +11034,8 @@ \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}% \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}% \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}% + \DeclareUnicodeCharacter{21DD}{\ensuremath\leadsto}% + \DeclareUnicodeCharacter{2201}{\ensuremath\complement}% \DeclareUnicodeCharacter{2202}{\ensuremath\partial}% \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}% \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}% @@ -11115,6 +11069,8 @@ \DeclareUnicodeCharacter{2283}{\ensuremath\supset}% \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}% \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}% + \DeclareUnicodeCharacter{228F}{\ensuremath\sqsubset}% + \DeclareUnicodeCharacter{2290}{\ensuremath\sqsupset}% \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}% \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}% \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}% @@ -11129,6 +11085,8 @@ \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}% \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}% \DeclareUnicodeCharacter{22A8}{\ensuremath\models}% + \DeclareUnicodeCharacter{22B4}{\ensuremath\unlhd}% + \DeclareUnicodeCharacter{22B5}{\ensuremath\unrhd}% \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}% \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}% \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}% @@ -11144,11 +11102,12 @@ \DeclareUnicodeCharacter{2322}{\ensuremath\frown}% \DeclareUnicodeCharacter{2323}{\ensuremath\smile}% % + \DeclareUnicodeCharacter{25A1}{\ensuremath\Box}% \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}% \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}% \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}% \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}% - \DeclareUnicodeCharacter{25C7}{\ensuremath\diamond}% + \DeclareUnicodeCharacter{25C7}{\ensuremath\Diamond}% \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}% \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}% \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}% @@ -11170,6 +11129,7 @@ \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}% \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}% \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}% + \DeclareUnicodeCharacter{2A1D}{\ensuremath\Join}% \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}% \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}% \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}% @@ -11463,11 +11423,9 @@ % \dimen0 = #1\relax \advance\dimen0 by \voffset - \advance\dimen0 by 1in % reference point for DVI is 1 inch from top of page % \dimen2 = \hsize \advance\dimen2 by \normaloffset - \advance\dimen2 by 1in % reference point is 1 inch from left edge of page % \internalpagesizes{#1}{\hsize}% {\voffset}{\normaloffset}%