code:
Source: https://git.archlinux.org/svntogit/community.git/plain/trunk/boost-1.68.patch?h=packages/aegisub
From d8336d2fed73c72d1227b343d6acfb991bc1651b Mon Sep 17 00:00:00 2001
From: Jan Beich <jbeich@FreeBSD.org>
Date: Mon, 9 Jul 2018 20:15:29 +0000
Subject: [PATCH] Keep using std::distance after Boost 1.68

src/search_replace_engine.cpp:256:14: error: call to
      'distance' is ambiguous
                                count += distance(
                                         ^~~~~~~~
/usr/include/c++/v1/iterator:511:1: note: candidate function [with _InputIter =
      boost::u32regex_iterator<std::__1::__wrap_iter<const char *> >]
distance(_InputIter __first, _InputIter __last)
^
/usr/local/include/boost/iterator/distance.hpp:49:9: note: candidate function [with SinglePassIterator =
      boost::u32regex_iterator<std::__1::__wrap_iter<const char *> >]
        distance(SinglePassIterator first, SinglePassIterator last)
        ^
---
 src/search_replace_engine.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/search_replace_engine.cpp b/src/search_replace_engine.cpp
index 594c21e5e..14c71680d 100644
--- a/src/search_replace_engine.cpp
+++ b/src/search_replace_engine.cpp
@@ -253,7 +253,7 @@ bool SearchReplaceEngine::ReplaceAll() {
 			if (MatchState ms = matches(&diag, 0)) {
 				auto& diag_field = diag.*get_dialogue_field(settings.field);
 				std::string const& text = diag_field.get();
-				count += distance(
+				count += std::distance(
 					boost::u32regex_iterator<std::string::const_iterator>(begin(text), end(text), *ms.re),
 					boost::u32regex_iterator<std::string::const_iterator>());
 				diag_field = u32regex_replace(text, *ms.re, settings.replace_with);


code:
This patch adds an include needed since icu59:
Source: https://git.archlinux.org/svntogit/community.git/plain/trunk/icu59.patch?h=packages/aegisub
--- aegisub-3.2.2/src/utils.cpp	2014-12-08 02:07:09.000000000 +0200
+++ aegisub-3.2.2/src/utils.cpp	2017-04-26 11:11:15.438239182 +0300
@@ -44,6 +44,7 @@
 #include <boost/filesystem/path.hpp>
 #include <map>
 #include <unicode/locid.h>
+#include <unicode/unistr.h>
 #include <wx/clipbrd.h>
 #include <wx/filedlg.h>
 #include <wx/stdpaths.h>

license: mit


code:
Fix build with GNU Make 4.3:

https://github.com/Aegisub/Aegisub/issues/171

Patch taken from upstream:

https://github.com/Aegisub/Aegisub/commit/6bd3f4c26b8fc1f76a8b797fcee11e7611d59a39

diff --git a/Makefile.target b/Makefile.target
--- a/Makefile.target
+++ b/Makefile.target
@@ -112,7 +112,7 @@ POST_FLAGS = $($@_FLAGS) -c -o $@ $<
 # Libraries contain all object files they depend on (but they may depend on other files)
 # Not using libtool on OS X because it has an unsilenceable warning about a
 # compatibility issue with BSD 4.3 (wtf)
-lib%.a: $$($$*_OBJ)
+lib%.a: $$($$(*F)_OBJ)
 	@$(BIN_MKDIR_P) $(dir $@)
 	$(BIN_AR) cru $@ $(filter %.o,$^)
 	$(BIN_RANLIB) $@


code:
AM_C_PROTOTYPES is no longer supported.

https://lists.gnu.org/archive/html/automake-patches/2011-06/msg00082.html

Failure without patch:

starting phase `autoreconf'
aclocal: warning: autoconf input should be named 'configure.ac', not 'configure.in'
configure.in:11: error: automatic de-ANSI-fication support has been removed
/gnu/store/…-automake-1.15/share/aclocal-1.15/obsolete.m4:26: AM_C_PROTOTYPES is expanded from...
configure.in:11: the top level

Upstream is dead.
--- a/configure.in	2015-03-15 18:59:12.557417149 +0100
+++ b/configure.in	2015-03-15 18:59:29.273416518 +0100
@@ -8,7 +8,6 @@
 AC_PROG_CC
 AC_PROG_CXX
 AC_ISC_POSIX
-AM_C_PROTOTYPES
 if test "x$U" != "x"; then
   AC_MSG_ERROR(Compiler not ANSI compliant)
 fi


code:
From bc018b4bc816a3b51deb9739bedbf8a2268d0684 Mon Sep 17 00:00:00 2001
From: gnidorah <gnidorah@users.noreply.github.com>
Date: Fri, 22 Dec 2017 17:36:03 +0300
Subject: [PATCH] Revert "Make Akonadi installation properly relocatable"

This reverts commit b2bb55f13f2ac783f89cc414de8c39f62fa2096a.
---
 CMakeLists.txt            | 3 ---
 KF5AkonadiConfig.cmake.in | 6 +++---
 2 files changed, 3 insertions(+), 6 deletions(-)

Index: akonadi-19.08.0/CMakeLists.txt
===================================================================
--- akonadi-19.08.0.orig/CMakeLists.txt
+++ akonadi-19.08.0/CMakeLists.txt
@@ -306,9 +306,6 @@ configure_package_config_file(
     "${CMAKE_CURRENT_SOURCE_DIR}/KF5AkonadiConfig.cmake.in"
     "${CMAKE_CURRENT_BINARY_DIR}/KF5AkonadiConfig.cmake"
     INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
-    PATH_VARS AKONADI_DBUS_INTERFACES_INSTALL_DIR
-              AKONADI_INCLUDE_DIR
-              KF5Akonadi_DATA_DIR
 )

 install(FILES
Index: akonadi-19.08.0/KF5AkonadiConfig.cmake.in
===================================================================
--- akonadi-19.08.0.orig/KF5AkonadiConfig.cmake.in
+++ akonadi-19.08.0/KF5AkonadiConfig.cmake.in
@@ -26,8 +26,8 @@ if(BUILD_TESTING)
     find_dependency(Qt5Test "@QT_REQUIRED_VERSION@")
 endif()

-set_and_check(AKONADI_DBUS_INTERFACES_DIR  "@PACKAGE_AKONADI_DBUS_INTERFACES_INSTALL_DIR@")
-set_and_check(AKONADI_INCLUDE_DIR          "@PACKAGE_AKONADI_INCLUDE_DIR@")
+set_and_check(AKONADI_DBUS_INTERFACES_DIR  "@AKONADI_DBUS_INTERFACES_INSTALL_DIR@")
+set_and_check(AKONADI_INCLUDE_DIR          "@AKONADI_INCLUDE_DIR@")

 find_dependency(Boost "@Boost_MINIMUM_VERSION@")

@@ -35,7 +35,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/KF5Ako
 include(${CMAKE_CURRENT_LIST_DIR}/KF5AkonadiMacros.cmake)

 # The directory where akonadi-xml.xsd and kcfg2dbus.xsl are installed
-set(KF5Akonadi_DATA_DIR "@PACKAGE_KF5Akonadi_DATA_DIR@")
+set(KF5Akonadi_DATA_DIR "@KF5Akonadi_DATA_DIR@")

 ####################################################################################
 # CMAKE_AUTOMOC


code:
This is based on the respectve patch from NixPkgs, but with the parts pinning
mysql and postgresql executables removed. The our package definition on why.

diff --git a/src/akonadicontrol/agentmanager.cpp b/src/akonadicontrol/agentmanager.cpp
--- a/src/akonadicontrol/agentmanager.cpp
+++ b/src/akonadicontrol/agentmanager.cpp
@@ -61,7 +61,7 @@ public:
                 []() {
                     QCoreApplication::instance()->exit(255);
                 });
-        start(QStringLiteral("akonadiserver"), args, RestartOnCrash);
+        start(QLatin1String(NIX_OUT "/bin/akonadiserver"), args, RestartOnCrash);
     }

     ~StorageProcessControl() override
@@ -84,7 +84,7 @@ public:
                 []() {
                     qCCritical(AKONADICONTROL_LOG) << "Failed to start AgentServer!";
                 });
-        start(QStringLiteral("akonadi_agent_server"), args, RestartOnCrash);
+        start(QLatin1String(NIX_OUT "/bin/akonadi_agent_server"), args, RestartOnCrash);
     }

     ~AgentServerProcessControl() override
diff --git a/src/akonadicontrol/agentprocessinstance.cpp b/src/akonadicontrol/agentprocessinstance.cpp
--- a/src/akonadicontrol/agentprocessinstance.cpp
+++ b/src/akonadicontrol/agentprocessinstance.cpp
@@ -62,7 +62,7 @@ bool AgentProcessInstance::start(const AgentType &agentInfo)
     } else {
         Q_ASSERT(agentInfo.launchMethod == AgentType::Launcher);
         const QStringList arguments = QStringList() << executable << identifier();
-        const QString agentLauncherExec = Akonadi::StandardDirs::findExecutable(QStringLiteral("akonadi_agent_launcher"));
+        const QString agentLauncherExec = QLatin1String(NIX_OUT "/bin/akonadi_agent_launcher");
         mController->start(agentLauncherExec, arguments);
     }
     return true;
diff --git a/src/server/storage/dbconfigmysql.cpp b/src/server/storage/dbconfigmysql.cpp
--- a/src/server/storage/dbconfigmysql.cpp
+++ b/src/server/storage/dbconfigmysql.cpp
@@ -209,7 +209,7 @@ bool DbConfigMysql::startInternalServer()
 #endif

     // generate config file
-    const QString globalConfig = StandardDirs::locateResourceFile("config", QStringLiteral("mysql-global.conf"));
+    const QString globalConfig = QLatin1String(NIX_OUT "/etc/xdg/akonadi/mysql-global.conf");
     const QString localConfig  = StandardDirs::locateResourceFile("config", QStringLiteral("mysql-local.conf"));
     const QString actualConfig = StandardDirs::saveDir("data") + QLatin1String("/mysql.conf");
     if (globalConfig.isEmpty()) {


code:
Index: akonadi-19.08.0/src/server/storage/dbconfigmysql.cpp
===================================================================
--- akonadi-19.08.0.orig/src/server/storage/dbconfigmysql.cpp
+++ akonadi-19.08.0/src/server/storage/dbconfigmysql.cpp
@@ -235,8 +235,7 @@ bool DbConfigMysql::startInternalServer(
     bool confUpdate = false;
     QFile actualFile(actualConfig);
     // update conf only if either global (or local) is newer than actual
-    if ((QFileInfo(globalConfig).lastModified() > QFileInfo(actualFile).lastModified()) ||
-            (QFileInfo(localConfig).lastModified()  > QFileInfo(actualFile).lastModified())) {
+    if (true) {
         QFile globalFile(globalConfig);
         QFile localFile(localConfig);
         if (globalFile.open(QFile::ReadOnly) && actualFile.open(QFile::WriteOnly)) {


code:
Fixes compilation with Mesa >= 18.2.5.

Taken from upstream:

https://github.com/liballeg/allegro5/commit/a40d30e21802ecf5c9382cf34af9b01bd3781e47

diff --git a/include/allegro5/allegro_opengl.h b/include/allegro5/allegro_opengl.h
index 0f86a6768..652dd024e 100644
--- a/include/allegro5/allegro_opengl.h
+++ b/include/allegro5/allegro_opengl.h
@@ -103,10 +103,14 @@

 /* HACK: Prevent both Mesa and SGI's broken headers from screwing us */
 #define __glext_h_
+#define __gl_glext_h_
 #define __glxext_h_
+#define __glx_glxext_h_
 #include <GL/gl.h>
 #undef  __glext_h_
+#undef  __gl_glext_h_
 #undef  __glxext_h_
+#undef  __glx_glxext_h_

 #endif /* ALLEGRO_MACOSX */

diff --git a/include/allegro5/opengl/GLext/glx_ext_defs.h b/include/allegro5/opengl/GLext/glx_ext_defs.h
index 49c502091..fba8aea5d 100644
--- a/include/allegro5/opengl/GLext/glx_ext_defs.h
+++ b/include/allegro5/opengl/GLext/glx_ext_defs.h
@@ -1,7 +1,9 @@
 /* HACK: Prevent both Mesa and SGI's broken headers from screwing us */
 #define __glxext_h_
+#define __glx_glxext_h_
 #include <GL/glx.h>
 #undef __glxext_h_
+#undef __glx_glxext_h_

 #ifndef GLX_VERSION_1_3
 #define _ALLEGRO_GLX_VERSION_1_3
--
2.20.0


code:
This patch was taken from Debian.
https://salsa.debian.org/multimedia-team/ams/-/raw/master/debian/patches/0007-Make-vocoder-module-compatible-to-C-11.patch

From: Guido Scholz <gscholz@users.sourceforge.net>
Date: Tue, 6 Nov 2018 21:55:38 +0100
Subject: Make vocoder module compatible to C++11

---
 src/m_vocoder.cpp | 218 +++++++++++++++++++++++++++---------------------------
 src/m_vocoder.h   |  31 ++++----
 2 files changed, 124 insertions(+), 125 deletions(-)

diff --git a/src/m_vocoder.cpp b/src/m_vocoder.cpp
index 572cf65..371e2cf 100644
--- a/src/m_vocoder.cpp
+++ b/src/m_vocoder.cpp
@@ -18,10 +18,6 @@
   along with ams.  If not, see <http://www.gnu.org/licenses/>.
 */

-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <math.h>
 #include <qwidget.h>
 #include <qstring.h>
 #include <qslider.h>
@@ -36,16 +32,13 @@
 #include "synthdata.h"
 #include "midicheckbox.h"
 #include "midislider.h"
-// For FFTW to be happy we must include complex.h before fftw3.h
-#include <complex.h>
-#include <fftw3.h>
 #include "port.h"
 #include "m_vocoder.h"

 //   Window function - One way to make the FFT behave
 //   and give more continuous results over edge steps.

-float M_vocoder::windowcurve (int windowfunc, int len, int elem, float alpha)
+float M_vocoder::windowcurve (int windowfunc, unsigned int len, int elem, float alpha)
 {
   float out;
   out = 1.0;
@@ -98,6 +91,7 @@ float M_vocoder::windowcurve (int windowfunc, int len, int elem, float alpha)
   return (out);
 }

+
 M_vocoder::M_vocoder(QWidget* parent, int id)
   : Module(M_type_vocoder, id, 5, parent, tr("FFT Vocoder"))
 {
@@ -160,6 +154,7 @@ M_vocoder::M_vocoder(QWidget* parent, int id)
     modbuf[l1] = (float *)malloc( fftsize * sizeof(float));
     memset( modbuf[l1], 0, fftsize * sizeof(float));
   }
+
   carrbuf = (float **)malloc(synthdata->poly * sizeof(float *));
   for (l1 = 0; l1 < synthdata->poly; l1++) {
     carrbuf[l1] = (float *)malloc( fftsize * sizeof(float));
@@ -175,38 +170,48 @@ M_vocoder::M_vocoder(QWidget* parent, int id)
     window[l2] = windowcurve (whichwin, fftsize, l2, 0.25);

   //  FFTW setup stuff
-  carrinforward = (fftw_complex *) fftw_malloc (sizeof (fftw_complex)
-					    * fftsize);
-  carrinbackward = (fftw_complex *) fftw_malloc (sizeof (fftw_complex)
-					     * fftsize);
-  carroutforward = (fftw_complex *) fftw_malloc (sizeof (fftw_complex)
-					     * fftsize);
-  carroutbackward = (fftw_complex *) fftw_malloc (sizeof (fftw_complex)
-					      * fftsize);
-  modinforward = (fftw_complex *) fftw_malloc (sizeof (fftw_complex)
-					    * fftsize);
-  modinbackward = (fftw_complex *) fftw_malloc (sizeof (fftw_complex)
-					     * fftsize);
-  modoutforward = (fftw_complex *) fftw_malloc (sizeof (fftw_complex)
-					     * fftsize);
-  modoutbackward = (fftw_complex *) fftw_malloc (sizeof (fftw_complex)
-					      * fftsize);
-  fftw_set_timelimit (5.0);
-  planmodforward = fftw_plan_dft_1d (fftsize, modinforward,
-				  modoutforward, FFTW_FORWARD, FFTW_MEASURE);
-  planmodbackward = fftw_plan_dft_1d (fftsize, modinbackward,
- 				  modoutbackward, FFTW_BACKWARD, FFTW_MEASURE);
-  plancarrforward = fftw_plan_dft_1d (fftsize, carrinforward,
-				  carroutforward, FFTW_FORWARD, FFTW_MEASURE);
-  plancarrbackward = fftw_plan_dft_1d (fftsize, carrinbackward,
- 				  carroutbackward, FFTW_BACKWARD, FFTW_MEASURE);
+  carrinforward.reserve(fftsize);
+  carrinbackward.reserve(fftsize);
+  carroutforward.reserve(fftsize);
+  carroutbackward.reserve(fftsize);
+  modinforward.reserve(fftsize);
+  modinbackward.reserve(fftsize);
+  modoutforward.reserve(fftsize);
+  modoutbackward.reserve(fftsize);
+
+  fftw_set_timelimit(5.0);
+
+  planmodforward = fftw_plan_dft_1d(fftsize,
+          reinterpret_cast<fftw_complex*> (modinforward.data()),
+          reinterpret_cast<fftw_complex*> (modoutforward.data()),
+          FFTW_FORWARD, FFTW_MEASURE);
+
+  planmodbackward = fftw_plan_dft_1d(fftsize,
+          reinterpret_cast<fftw_complex*> (modinbackward.data()),
+          reinterpret_cast<fftw_complex*> (modoutbackward.data()),
+          FFTW_BACKWARD, FFTW_MEASURE);
+
+  plancarrforward = fftw_plan_dft_1d(fftsize,
+          reinterpret_cast<fftw_complex*> (carrinforward.data()),
+          reinterpret_cast<fftw_complex*> (carroutforward.data()),
+          FFTW_FORWARD, FFTW_MEASURE);
+
+  plancarrbackward = fftw_plan_dft_1d(fftsize,
+          reinterpret_cast<fftw_complex*> (carrinbackward.data()),
+          reinterpret_cast<fftw_complex*> (carroutbackward.data()),
+          FFTW_BACKWARD, FFTW_MEASURE);
 }

+
 M_vocoder::~M_vocoder() {

-  int l1;
+  //    Clean up FFTW stuff.
+  fftw_destroy_plan (plancarrforward);
+  fftw_destroy_plan (plancarrbackward);
+  fftw_destroy_plan (planmodforward);
+  fftw_destroy_plan (planmodbackward);

-  for (l1 = 0; l1 < synthdata->poly; l1++) {
+  for (int l1 = 0; l1 < synthdata->poly; l1++) {
     free(modbuf[l1]);
     free(carrbuf[l1]);
   }
@@ -215,29 +220,14 @@ M_vocoder::~M_vocoder() {
   free (window);
   free (modmap);
   free (armodmap);
-
-  //#define FFTW_CLEANUP
-#ifdef FFTW_CLEANUP
-  //    Clean up FFTW stuff.
-  fftw_destroy_plan (plancarrforward);
-  fftw_destroy_plan (plancarrbackward);
-  fftw_destroy_plan (planmodforward);
-  fftw_destroy_plan (planmodbackward);
-  fftw_free (carrinforward);
-  fftw_free (carrinbackward);
-  fftw_free (carroutforward);
-  fftw_free (carroutbackward);
-  fftw_free (modinforward);
-  fftw_free (modinbackward);
-  fftw_free (modoutforward);
-  fftw_free (modoutbackward);
-#endif
 }

+
 void M_vocoder::generateCycle() {

   int l1;  //  l1 indexes along polyphony.
   unsigned int l2;  // l2 indexes along the cycle
+  const std::complex<double> I(0.0, 1.0);

   inModulator = port_M_modulator->getinputdata();
   inPitchShift = port_M_pitchshift->getinputdata();
@@ -272,7 +262,7 @@ void M_vocoder::generateCycle() {
   //   Did the user change the FFT windowing function?
   if (myFFTWindowFunc != whichwin) {
     whichwin = myFFTWindowFunc;
-    for (l2 = 0; l2 < (unsigned int) fftsize; l2++)
+    for (l2 = 0; l2 < fftsize; l2++)
       window[l2] = windowcurve (whichwin, fftsize, l2, 0.25);
   }

@@ -294,7 +284,7 @@ void M_vocoder::generateCycle() {
     }

     //    window the input buffer to modinforward
-    for (l2 = 0; l2 < (unsigned int)fftsize ; l2++) {
+    for (l2 = 0; l2 < fftsize ; l2++) {
       modinforward[l2] = modbuf[l1][l2] * window[l2];
     }

@@ -310,17 +300,18 @@ void M_vocoder::generateCycle() {
     fftw_execute (planmodforward);

     //    copy the FFT of the modulator to modinbackward.
-    for (l2 = 0; l2 < (unsigned int)fftsize; l2++)
-      modinbackward[l2] = modoutforward[l2];
+    //for (l2 = 0; l2 < fftsize; l2++)
+    //  modinbackward[l2] = modoutforward[l2];
+    modinbackward = modoutforward;

     //     Send the FFT of the modulator to the output for giggles
     //     and get an approximation of the first harmonic too.
     float firstharmonicval;
     int firstharmonicindex;
     firstharmonicval = 0.0;
-    firstharmonicindex = 1.0;
+    firstharmonicindex = 1;
     for (l2 = 1; l2 < (unsigned int) synthdata->cyclesize; l2++) {
-      data[2][l1][l2] = logf(fabs (creal (modoutforward[l2])) + 1.0);
+      data[2][l1][l2] = logf(fabs(modoutforward[l2].real()) + 1.0);
       if (data[2][l1][l2] > firstharmonicval) {
 	firstharmonicindex = l2;
 	firstharmonicval  = data[2][l1][l2] ;
@@ -333,35 +324,38 @@ void M_vocoder::generateCycle() {

     //   intermediate frequency-domain munging of modulator
     //   Frequency (additive, Bode-style) shifting first
-    for (l2 = 0; l2 < (unsigned int)fftsize; l2++)
-      modinbackward[l2] = 0;
+    for (l2 = 0; l2 < fftsize; l2++)
+      modinbackward[l2] = 0.0;
+
     int lclfrq;
-    for (l2 = 0; l2 < (unsigned int)fftsize/2; l2++) {
+    for (l2 = 0; l2 < fftsize/2; l2++) {
       //   positive frequencies (first half) of the FFT result
       lclfrq = l2 + (int)freqshift + vcfreqshift * inFreqShift[l1][0];
       lclfrq = lclfrq > 0 ? lclfrq : 0;
-      lclfrq = lclfrq < ((fftsize/2)-1) ? lclfrq : (fftsize/2)-1;
+      lclfrq = lclfrq < (int)((fftsize/2)-1) ? lclfrq : (fftsize/2)-1;
       modinbackward [lclfrq] = modoutforward [l2];
       //   Negative frequencies (second half of the fft result)
-      modinbackward [fftsize - lclfrq] = modoutforward [ fftsize - l2];
+      modinbackward [fftsize - lclfrq] = modoutforward [fftsize - l2];
     }

-    //    Pitchshifting (multiplicative, harmonic-retaining) shifting.
-    //    Note that we reuse the modoutforward as working space
-    for (l2 = 0; l2 < (unsigned int) fftsize; l2++) {
-      modoutforward[l2] = modinbackward[l2];
-    };
-    for (l2 = 0; l2 < (unsigned int)fftsize; l2++)
-      modinbackward[l2] = 0;
+    // Pitchshifting (multiplicative, harmonic-retaining) shifting.
+    // Note that we reuse the modoutforward as working space
+    //for (l2 = 0; l2 < fftsize; l2++) {
+    //  modoutforward[l2] = modinbackward[l2];
+    //};
+    modoutforward = modinbackward;
+
+    for (l2 = 0; l2 < fftsize; l2++)
+      modinbackward[l2] = 0.0;

     float psmod, psfactor;
     psmod = (pitchshift + vcpitch * inPitchShift[l1][0]);
     psfactor = pow (2.0, psmod);
-    for (l2 = 0; l2 < (unsigned int)fftsize/2; l2++) {
+    for (l2 = 0; l2 < fftsize/2; l2++) {
       //   positive frequencies (first half) of the FFT result
       lclfrq = l2 * psfactor;
       lclfrq = lclfrq > 0 ? lclfrq : 0;
-      lclfrq = lclfrq < ((fftsize/2)-1) ? lclfrq : (fftsize/2)-1;
+      lclfrq = lclfrq < (int)((fftsize/2)-1) ? lclfrq : (fftsize/2)-1;
       //   Old way to pitch shift: just move the bucket.  But this puts
       //   nulls wherever the energy is split between two buckets with
       //   a 180 degree phase difference.
@@ -375,12 +369,12 @@ void M_vocoder::generateCycle() {
 	  //   Better way: move freq. bin, multiply angle by octave motion.
 	  //
 	  modinbackward[lclfrq] +=
-	    cabs (modoutforward [l2])
-	    * cexp (I * ( carg (modoutforward [l2])
+	    std::abs(modoutforward[l2])
+	    * std::exp (I * ( std::arg (modoutforward [l2])
 			  + (l2 * phaseshift * psfactor)));
 	  modinbackward[fftsize - lclfrq] +=
-	    cabs (modoutforward [ fftsize - l2])
-	    * cexp (I * ( carg (modoutforward [ fftsize - l2])
+	    std::abs (modoutforward [ fftsize - l2])
+	    * std::exp (I * ( std::arg (modoutforward [ fftsize - l2])
 			  + (l2 * phaseshift * psfactor)));
 	};
     }
@@ -389,9 +383,9 @@ void M_vocoder::generateCycle() {
     fftw_execute (planmodbackward);

     //   renormalize the time-domain modulator output
-    for (l2 = 0; l2 < (unsigned)fftsize; l2++) {
-      modoutbackward [l2] = modoutbackward[l2] / float (fftsize) ;
-      modoutbackward [l2] = modoutbackward[l2] / window[l2];
+    for (l2 = 0; l2 < fftsize; l2++) {
+      modoutbackward [l2] = modoutbackward[l2] / (double) fftsize;
+      modoutbackward [l2] = modoutbackward[l2] / (double) window[l2];
     }

     unsigned int i;
@@ -400,13 +394,11 @@ void M_vocoder::generateCycle() {

     //     Splicing the new output to the results
-    if (dynsplice == 0.0)
-      {
+    if (dynsplice == 0.0) {
 	//   output it as the altered modulator.
 	for (l2 = 0; l2 < synthdata->cyclesize; l2++) {
-	  data[0][l1][l2] = creal ( modoutbackward [l2 +
-						    fftsize/2 -
-						    synthdata->cyclesize/2 ]);
+	  data[0][l1][l2] =
+              modoutbackward[l2 + fftsize/2 - synthdata->cyclesize/2].real();
 	}
 	clomatch_index = fftsize - synthdata->cyclesize;
       }
@@ -421,18 +413,21 @@ void M_vocoder::generateCycle() {
 	float tval, dtval;
 	int searchstart;
 	float spliceval, dspliceval;
-	searchstart = fftsize/2 - synthdata->cyclesize;
-	if (searchstart < 1) searchstart = 1;
-	clomatch_index = searchstart;
+
+        searchstart = fftsize/2 - synthdata->cyclesize;
+        if (searchstart < 1)
+            searchstart = 1;
+
+        clomatch_index = searchstart;
 	spliceval = data[0][l1][synthdata->cyclesize - 1];
 	dspliceval = spliceval - data[0][l1][synthdata->cyclesize - 2];
-	clov_sofar= fabs(creal(modoutbackward[clomatch_index])-spliceval );
+	clov_sofar= fabs(modoutbackward[clomatch_index].real()-spliceval);
 	for (l2 = searchstart;
 	     l2 < (searchstart + synthdata->cyclesize);
 	     l2++)
 	  {
-	    tval = creal (modoutbackward[l2]);
-	    dtval = tval - creal (modoutbackward [l2-1]);
+	    tval = modoutbackward[l2].real();
+	    dtval = tval - modoutbackward [l2-1].real();
 	    if (
 		((fabs (tval - spliceval )) < clov_sofar )
 		&& ((dtval * dspliceval ) >= 0)
@@ -445,15 +440,15 @@ void M_vocoder::generateCycle() {
 	  };
 	//  fprintf (stderr, "%d %f %f ",
 	//      clomatch_index, clov_sofar, clodv_sofar);
-
+
 	//   What's our residual error, so that we can splice this
 	//   with minimal "click"?
-	residual = + spliceval - creal( modoutbackward[clomatch_index]);
+	residual = + spliceval - modoutbackward[clomatch_index].real();

 	//  Move our wave, with the best match so far established, to
 	//   the output buffer area.
 	for (l2 = 0; l2 < synthdata->cyclesize; l2++) {
-	  data[0][l1][l2] = creal ( modoutbackward [ clomatch_index + l2])
+	  data[0][l1][l2] = modoutbackward[clomatch_index + l2].real()
 	    + ((1.0 - (float(l2) / float(synthdata->cyclesize))) * residual);
 	};

@@ -466,17 +461,18 @@ void M_vocoder::generateCycle() {
     for (l2 = 0; l2 < fftsize - synthdata->cyclesize; l2++) {
       carrbuf [l1][l2] = carrbuf [l1][l2 + synthdata->cyclesize];
     }
+
     for (l2 = 0; l2 < synthdata->cyclesize; l2++) {
       carrbuf [l1][l2 + fftsize - synthdata->cyclesize] = inCarrier[l1][l2];
     }

-    for (l2 = 0; l2 <  unsigned (fftsize); l2++) {
+    for (l2 = 0; l2 < fftsize; l2++) {
       carrinforward [l2] = carrbuf [l1][l2] * window[l2];
     }

     fftw_execute (plancarrforward);

-    for (l2 = 0; l2 < (unsigned) fftsize; l2++) {
+    for (l2 = 0; l2 < fftsize; l2++) {
       carrinbackward[l2] = carroutforward[l2];
     };

@@ -486,34 +482,37 @@ void M_vocoder::generateCycle() {
     //   Group the modulator into channels, and multipy the channels
     //   over the carrier.

-    int localchannels;
-    localchannels = channels + vcchannels * inChannels[l1][0];
-    if (localchannels < 1) localchannels = 1;
-    if (localchannels > fftsize - 1) localchannels = fftsize - 1;
-    for (l2 = 0; l2 < (unsigned) fftsize; l2++) {
+    unsigned int localchannels = channels + vcchannels * inChannels[l1][0];
+    if (localchannels < 1)
+        localchannels = 1;
+
+    if (localchannels > fftsize - 1)
+        localchannels = fftsize - 1;
+
+    for (l2 = 0; l2 < fftsize; l2++) {
       modmap[l2] = 0;
       //       initial conditions...
       if (l2 == 0)
 	for (i = 0; i < channels; i++)
-	  modmap[l2] += cabs (modoutforward[l2 + i]);
+	  modmap[l2] += std::abs(modoutforward[l2 + i]);
       else
 	modmap [l2] = modmap[l2 - 1];

       //    add the heads, subtract the tails
       i = l2 + channels;
-      if (l2 < (unsigned)fftsize - 2)
-	modmap[l2] += cabs( modoutforward [i] );
+      if (l2 < fftsize - 2)
+	modmap[l2] += std::abs(modoutforward[i]);
       i = l2 - channels;
       if (l2 >= channels)
-	modmap[l2] -= cabs( modoutforward [i] );
+	modmap[l2] -= std::abs(modoutforward[i]);
     }

     //   Normalize the modmap
-    for (l2 = 0; l2 < (unsigned) fftsize; l2++)
+    for (l2 = 0; l2 < fftsize; l2++)
       modmap[l2] = modmap[l2] / localchannels;

     //   Do attack/release
-    for (l2 = 0; l2 < (unsigned) fftsize; l2++) {
+    for (l2 = 0; l2 < fftsize; l2++) {
       if (modmap [l2] > armodmap[l2])
 	armodmap [l2] += (1 - attack) * (modmap[l2] - armodmap[l2]);
       if (modmap [l2] < armodmap[l2])
@@ -521,8 +520,8 @@ void M_vocoder::generateCycle() {
     }

     //   multiply the carrier by the modulation map.
-    for (l2 = 0; l2 < (unsigned) fftsize; l2++) {
-      carrinbackward[l2] = carroutforward[l2] * armodmap[l2];
+    for (l2 = 0; l2 < fftsize; l2++) {
+      carrinbackward[l2] = carroutforward[l2] * (double) armodmap[l2];
     }

     //   reverse transform to final output, and renormalize by 1/fftsize.
@@ -532,8 +531,7 @@ void M_vocoder::generateCycle() {
     for (l2 = 0; l2 < synthdata->cyclesize; l2++) {
       offset = l2 + (fftsize/2) - (synthdata->cyclesize / 2);
       data[1][l1][l2]=
-	(creal(carroutbackward[offset]/window[offset])) / (fftsize * 100);
+	(carroutbackward[offset].real()/window[offset]) / (fftsize * 100);
     };
   };
 }
-
diff --git a/src/m_vocoder.h b/src/m_vocoder.h
index 38eac58..32c8521 100644
--- a/src/m_vocoder.h
+++ b/src/m_vocoder.h
@@ -1,4 +1,4 @@
-/*
+/*
   Vocoder - derived from m_delay.cpp

   Copyright (C) 2011 Bill Yerazunis <yerazunis@yahoo.com>
@@ -22,7 +22,9 @@
 #define M_VOCODER_H

 #include "module.h"
-#include <complex.h>
+
+#include <vector>
+#include <ccomplex>
 #include <fftw3.h>

 #define MODULE_VOCODER_WIDTH                 105
@@ -30,7 +32,7 @@

 class M_vocoder : public Module
 {
-    Q_OBJECT
+    Q_OBJECT

     float channels, vcchannels;
     float attack, release;
@@ -42,21 +44,20 @@ class M_vocoder : public Module

     Port *port_M_modulator, *port_M_pitchshift, *port_M_freqshift,
       *port_M_channels, *port_M_carrier;
+
     Port *port_modfft_out, *port_firstharmonic_out,
-      *port_altmodulator_out,
-      *port_vocoder_out;
+      *port_altmodulator_out, *port_vocoder_out;

-    fftw_plan planmodforward, planmodbackward,
+    fftw_plan planmodforward, planmodbackward,
       plancarrforward, plancarrbackward;

-    fftw_complex *carrinforward, *carroutforward,
-      *carrinbackward, *carroutbackward,
-      *modinforward, *modoutforward,
-      *modinbackward, *modoutbackward;
+    std::vector<std::complex<double>> carrinforward, carroutforward,
+        carrinbackward, carroutbackward,
+        modinforward, modoutforward,
+        modinbackward, modoutbackward;

-  public:
-    int fftsize;
-    float **inModulator, **inPitchShift, **inFreqShift,
+    unsigned int fftsize;
+    float **inModulator, **inPitchShift, **inFreqShift,
       **inChannels, **inCarrier;
     // the previous time-based samples, for overlapping
     float **modbuf, **carrbuf;
@@ -68,10 +69,10 @@ class M_vocoder : public Module
     float *armodmap;

   public:
-    float windowcurve (int windowfunc, int len, int elem, float alpha );
+    float windowcurve (int windowfunc, unsigned int len, int elem, float alpha );
     M_vocoder(QWidget* parent=0, int id = 0);
     ~M_vocoder();
     void generateCycle();
 };
-
+
 #endif


code:
From d1d1368c7909ffd8423730afaa811ce7b6a3a8aa Mon Sep 17 00:00:00 2001
From: Tommy Jerry Mairo <tommy.mairo@gmail.com>
Date: Sun, 4 Feb 2018 12:42:00 -0800
Subject: [PATCH 1/2] Bugfix: API mismatch with crypto++ 6.0.0

---
 src/ClientCreditsList.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/ClientCreditsList.cpp b/src/ClientCreditsList.cpp
index 3bea9fe2d..a7ae1e34c 100644
--- a/src/ClientCreditsList.cpp
+++ b/src/ClientCreditsList.cpp
@@ -312,7 +312,7 @@ void CClientCreditsList::InitalizeCrypting()
 		// calculate and store public key
 		CryptoPP::RSASSA_PKCS1v15_SHA_Verifier pubkey(*static_cast<CryptoPP::RSASSA_PKCS1v15_SHA_Signer *>(m_pSignkey));
 		CryptoPP::ArraySink asink(m_abyMyPublicKey, 80);
-		pubkey.DEREncode(asink);
+		pubkey.AccessMaterial().Save(asink);
 		m_nMyPublicKeyLen = asink.TotalPutLength();
 		asink.MessageEnd();
 	} catch (const CryptoPP::Exception& e) {

From 88ba0ac952b78382445f2fff73c6792c0474dc62 Mon Sep 17 00:00:00 2001
From: Tommy Jerry Mairo <tommy.mairo@gmail.com>
Date: Wed, 21 Mar 2018 11:56:28 -0700
Subject: [PATCH 2/2] Update: Change AccessMaterial to GetMaterial

---
 src/ClientCreditsList.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/ClientCreditsList.cpp b/src/ClientCreditsList.cpp
index a7ae1e34c..69e881fd8 100644
--- a/src/ClientCreditsList.cpp
+++ b/src/ClientCreditsList.cpp
@@ -312,7 +312,7 @@ void CClientCreditsList::InitalizeCrypting()
 		// calculate and store public key
 		CryptoPP::RSASSA_PKCS1v15_SHA_Verifier pubkey(*static_cast<CryptoPP::RSASSA_PKCS1v15_SHA_Signer *>(m_pSignkey));
 		CryptoPP::ArraySink asink(m_abyMyPublicKey, 80);
-		pubkey.AccessMaterial().Save(asink);
+		pubkey.GetMaterial().Save(asink);
 		m_nMyPublicKeyLen = asink.TotalPutLength();
 		asink.MessageEnd();
 	} catch (const CryptoPP::Exception& e) {


code:
Modified from upstream commit:
https://github.com/ankitects/anki/commit/ccd715013609133c55e83924734efa78abc03326
Fixes mpv argument syntax (support for old syntax removed in mpv 0.31):
https://anki.tenderapp.com/discussions/ankidesktop/38186-mpvprocesserror-unable-to-start-process
Necessary because we are currently unable to upgrade anki to the
latest version in guix (NPM dependencies currently unpackaged).
---
 anki/mpv.py   | 4 ++--
 anki/sound.py | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/anki/mpv.py b/anki/mpv.py
index f53d9d0..563fddc 100644
--- a/anki/mpv.py
+++ b/anki/mpv.py
@@ -104,9 +104,9 @@ class MPVBase:
         """
         self.argv = [self.executable]
         self.argv += self.default_argv
-        self.argv += ["--input-ipc-server", self._sock_filename]
+        self.argv += ["--input-ipc-server="+self._sock_filename]
         if self.window_id is not None:
-            self.argv += ["--wid", str(self.window_id)]
+            self.argv += ["--wid="+str(self.window_id)]

     def _start_process(self):
         """Start the mpv process.
diff --git a/anki/sound.py b/anki/sound.py
index aa3431b..a5fce44 100644
--- a/anki/sound.py
+++ b/anki/sound.py
@@ -124,7 +124,6 @@ class MpvManager(MPV):
 def setMpvConfigBase(base):
     mpvConfPath = os.path.join(base, "mpv.conf")
     MpvManager.default_argv += [
-        "--no-config",
         "--include="+mpvConfPath,
     ]

--
2.25.1


code:
Description: Add check for buffer overflow with malformed input files
 This was later re-found and became CVE-2014-8123.
Author: <eriks@debian.org>
Bug-Debian: http://bugs.debian.org/407015
Bug-Debian: https://bugs.debian.org/771768
Forwarded: http://seclists.org/oss-sec/2014/q4/870
Last-Update: 2016-01-11

--- antiword-0.37~/wordole.c	2005-08-26 21:49:57.000000000 +0200
+++ antiword-0.37/wordole.c	2009-06-03 22:31:15.948014682 +0200
@@ -259,6 +259,10 @@
 		}
 		tNameSize = (size_t)usGetWord(0x40, aucBytes);
 		tNameSize = (tNameSize + 1) / 2;
+		if ( tNameSize > sizeof(atPPSlist[iIndex].szName)) {
+			werr(0, "Name Size of PPS %d is too large", iIndex);
+			tNameSize = sizeof(atPPSlist[iIndex].szName);
+		}
 		vName2String(atPPSlist[iIndex].szName, aucBytes, tNameSize);
 		atPPSlist[iIndex].ucType = ucGetByte(0x42, aucBytes);
 		if (atPPSlist[iIndex].ucType == 5) {


code:
Based on the upstream fix for the java8 compilation issue.
Simplified patch.
Upstream version of patch does not work with this source tree.

The issue is that in java8 it is an error to pass null to
removeAll. Results in null pointer exception. java7
behaviour was to return the list unmodified.

From db2a350c6d90efaa8dde949fa76005c2c5af45c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A1bor=20Boskovits?= <boskovits@gmail.com>
Date: Fri, 5 Jan 2018 17:05:31 +0100
Subject: [PATCH] Fix java8 compilation.

---
 src/org/antlr/tool/CompositeGrammar.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/org/antlr/tool/CompositeGrammar.java b/src/org/antlr/tool/CompositeGrammar.java
index f1408e7..7e02431 100644
--- a/src/org/antlr/tool/CompositeGrammar.java
+++ b/src/org/antlr/tool/CompositeGrammar.java
@@ -218,7 +218,9 @@ public class CompositeGrammar {
 	public List<Grammar> getIndirectDelegates(Grammar g) {
 		List<Grammar> direct = getDirectDelegates(g);
 		List<Grammar> delegates = getDelegates(g);
-		delegates.removeAll(direct);
+		if (direct != null) {
+			delegates.removeAll(direct);
+		}
 		return delegates;
 	}

--
2.15.1


code:
Based on the upstream fix for the java8 compilation issue.
Simplified patch.
Upstream version of patch does not work with this source tree.

The issue is that in java8 it is an error to pass null to
removeAll. Results in null pointer exception. java7
behaviour was to return the list unmodified.

From 43867d50c05d1c06ab7220eb974a8874ae10c308 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A1bor=20Boskovits?= <boskovits@gmail.com>
Date: Fri, 5 Jan 2018 19:08:24 +0100
Subject: [PATCH] Fix java8 complilation error.

---
 tool/src/main/java/org/antlr/tool/CompositeGrammar.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tool/src/main/java/org/antlr/tool/CompositeGrammar.java b/tool/src/main/java/org/antlr/tool/CompositeGrammar.java
index f34ea73..63740a6 100644
--- a/tool/src/main/java/org/antlr/tool/CompositeGrammar.java
+++ b/tool/src/main/java/org/antlr/tool/CompositeGrammar.java
@@ -226,7 +226,9 @@ public class CompositeGrammar {
 	public List<Grammar> getIndirectDelegates(Grammar g) {
 		List<Grammar> direct = getDirectDelegates(g);
 		List<Grammar> delegates = getDelegates(g);
-		delegates.removeAll(direct);
+		if(direct != null) {
+		        delegates.removeAll(direct);
+		}
 		return delegates;
 	}

--
2.15.1


code:
--- test/testsock.c	2013-01-24 06:57:21.000000000 +0100
+++ test/testsock.c	2013-01-24 17:24:54.000000000 +0100
@@ -90,16 +90,22 @@
     rv = apr_sockaddr_info_get(&sa, NULL, APR_UNSPEC, 0, 0, p);
     APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv);

+    /* /etc/services is not available while compiling, so apr_getservbyname
+     * will always return APR_ENOENT. */
+#if 0
     rv = apr_getservbyname(sa, "ftp");
     APR_ASSERT_SUCCESS(tc, "Problem getting ftp service", rv);
     ABTS_INT_EQUAL(tc, 21, sa->port);
+#endif

     rv = apr_getservbyname(sa, "complete_and_utter_rubbish");
     APR_ASSERT_SUCCESS(tc, "Problem getting non-existent service", !rv);

+#if 0
     rv = apr_getservbyname(sa, "telnet");
     APR_ASSERT_SUCCESS(tc, "Problem getting telnet service", rv);
     ABTS_INT_EQUAL(tc, 23, sa->port);
+#endif
 }

 static apr_socket_t *setup_socket(abts_case *tc)


code:
This patch changes the default value of 'dict-dir' to correspond
to ~/.guix-profile/lib/aspell rather than $prefix/lib/aspell-X.Y.

This is not strictly necessary for the 'aspell' program itself since
one can simply set "ASPELL_CONF=dict-dir $HOME/.guix-profile/lib/aspell".
However it is necessary for applications that use libaspell since
'ASPELL_CONF' is not honored in this case.  See <https://bugs.gnu.org/25836>.

--- a/common/config.cpp
+++ b/common/config.cpp
@@ -651,7 +651,20 @@ namespace acommon {
 	  } else { // sep == '|'
 	    assert(replace[0] == '$');
 	    const char * env = getenv(replace.c_str()+1);
-	    final_str += env ? env : second;
+	    if (env) {
+	      final_str += env;
+	    } else if (second[0] == '$') {
+	      // Expand the right-hand side of '|', which starts with a
+	      // reference to an environment variable.
+	      auto slash = second.find('/');
+	      String variable = second.substr(1, slash - 1);
+	      const char * env = getenv(variable.c_str());
+	      String value = env ? String(env) : "";
+	      value += second.substr(slash, second.size() - slash);
+	      final_str += value;
+	    } else {
+	      final_str += second;
+	    }
 	  }
 	  replace = "";
 	  in_replace = false;
@@ -1349,6 +1349,9 @@ namespace acommon {
 #  define REPL     ".aspell.<lang>.prepl"
 #endif

+#undef DICT_DIR
+#define DICT_DIR "<$ASPELL_DICT_DIR|$HOME/.guix-profile/lib/aspell>"
+
   static const KeyInfo config_keys[] = {
     // the description should be under 50 chars
     {"actual-dict-dir", KeyInfoString, "<dict-dir^master>", 0}


code:
This GCC patch is from the ath9k-htc-firmware repository (version 1.3.2).
Not applying it (apparently) leads to miscompiled firmware, and loading it
fails with a "Target is unresponsive" message from the 'ath9k_htc' module.

From c7162b8a3db42e7faf47606d3aa3dd61e64aea17 Mon Sep 17 00:00:00 2001
From: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Date: Mon, 7 Jan 2013 16:06:28 +0530
Subject: [PATCH] gcc: AR9271/AR7010 config

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
---
 include/xtensa-config.h | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/include/xtensa-config.h b/include/xtensa-config.h
index 30f4f41..fe9b051 100644
--- a/include/xtensa-config.h
+++ b/include/xtensa-config.h
@@ -44,10 +44,7 @@
 #define XCHAL_HAVE_L32R			1

 #undef XSHAL_USE_ABSOLUTE_LITERALS
-#define XSHAL_USE_ABSOLUTE_LITERALS	0
-
-#undef XSHAL_HAVE_TEXT_SECTION_LITERALS
-#define XSHAL_HAVE_TEXT_SECTION_LITERALS 1 /* Set if there is some memory that allows both code and literals.  */
+#define XSHAL_USE_ABSOLUTE_LITERALS	1

 #undef XCHAL_HAVE_MAC16
 #define XCHAL_HAVE_MAC16		0
@@ -59,10 +56,10 @@
 #define XCHAL_HAVE_MUL32		1

 #undef XCHAL_HAVE_MUL32_HIGH
-#define XCHAL_HAVE_MUL32_HIGH		0
+#define XCHAL_HAVE_MUL32_HIGH		1

 #undef XCHAL_HAVE_DIV32
-#define XCHAL_HAVE_DIV32		1
+#define XCHAL_HAVE_DIV32		0

 #undef XCHAL_HAVE_NSA
 #define XCHAL_HAVE_NSA			1
@@ -103,8 +100,6 @@
 #undef XCHAL_HAVE_FP_RSQRT
 #define XCHAL_HAVE_FP_RSQRT		0

-#undef XCHAL_HAVE_DFP_accel
-#define XCHAL_HAVE_DFP_accel			0
 #undef XCHAL_HAVE_WINDOWED
 #define XCHAL_HAVE_WINDOWED		1

@@ -119,32 +114,32 @@

 #undef XCHAL_ICACHE_SIZE
-#define XCHAL_ICACHE_SIZE		16384
+#define XCHAL_ICACHE_SIZE		0

 #undef XCHAL_DCACHE_SIZE
-#define XCHAL_DCACHE_SIZE		16384
+#define XCHAL_DCACHE_SIZE		0

 #undef XCHAL_ICACHE_LINESIZE
-#define XCHAL_ICACHE_LINESIZE		32
+#define XCHAL_ICACHE_LINESIZE		16

 #undef XCHAL_DCACHE_LINESIZE
-#define XCHAL_DCACHE_LINESIZE		32
+#define XCHAL_DCACHE_LINESIZE		16

 #undef XCHAL_ICACHE_LINEWIDTH
-#define XCHAL_ICACHE_LINEWIDTH		5
+#define XCHAL_ICACHE_LINEWIDTH		4

 #undef XCHAL_DCACHE_LINEWIDTH
-#define XCHAL_DCACHE_LINEWIDTH		5
+#define XCHAL_DCACHE_LINEWIDTH		4

 #undef XCHAL_DCACHE_IS_WRITEBACK
-#define XCHAL_DCACHE_IS_WRITEBACK	1
+#define XCHAL_DCACHE_IS_WRITEBACK	0

 #undef XCHAL_HAVE_MMU
 #define XCHAL_HAVE_MMU			1

 #undef XCHAL_MMU_MIN_PTE_PAGE_SIZE
-#define XCHAL_MMU_MIN_PTE_PAGE_SIZE	12
+#define XCHAL_MMU_MIN_PTE_PAGE_SIZE	29

 #undef XCHAL_HAVE_DEBUG
@@ -157,8 +152,11 @@
 #define XCHAL_NUM_DBREAK		2

 #undef XCHAL_DEBUGLEVEL
-#define XCHAL_DEBUGLEVEL		6
+#define XCHAL_DEBUGLEVEL		4
+

+#undef XCHAL_EXCM_LEVEL
+#define XCHAL_EXCM_LEVEL                3

 #undef XCHAL_MAX_INSTRUCTION_SIZE
 #define XCHAL_MAX_INSTRUCTION_SIZE	3
--
1.8.1


code:
The firmware is cross-compiled, but the build system ends up using
'objcopy' instead of 'xtensa-elf-objcopy' by default.  Force it to
use the right one.

--- source/target_firmware/configure	2014-10-28 20:57:26.834436561 +0100
+++ source/target_firmware/configure	2014-10-28 20:57:29.666436530 +0100
@@ -11,6 +11,7 @@ mkdir -p build
 cat > "$TOOLCHAIN_FILE" <<EOF
 INCLUDE(CMakeForceCompiler)

+SET(CMAKE_OBJCOPY xtensa-elf-objcopy)
 SET(CMAKE_SYSTEM_PROCESSOR xtensa)
 SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/$TARGET)
 SET(CMAKE_STRIP :)


code:
Downloaded from here:
https://sourceforge.net/p/audacity/mailman/message/36106562/

Modified for use on later versions of audacity.

>From 5f9482a191359f2c477763a36d2c865c5f186602 Mon Sep 17 00:00:00 2001
From: Antonio Ospite <ao2@ao2.it>
Date: Tue, 7 Nov 2017 13:06:33 +0100
Subject: [PATCH] Fix building against the system portaudio library

Building against the system portaudio results in this error:

./src/AudioIO.cpp:983: undefined reference to `PaUtil_GetTime'
audacity-AudioIO.o: In function `audacityAudioCallback(void const*, void*,
unsigned long, PaStreamCallbackTimeInfo const*, unsigned long, void*)':
./src/AudioIO.cpp:4630: undefined reference to `PaUtil_GetTime'
collect2: error: ld returned 1 exit status
Makefile:2349: recipe for target 'audacity' failed
make[3]: *** [audacity] Error 1

This is because PaUtil_GetTime is declared as a C symbol in pa_util.h
but is resolved as a C++ symbol at link time.

Audacity fixes this in the local tree with this change:
https://github.com/audacity/audacity/commit/38fd97b8e26060332ab3e9e000a8882326a70ba7

However this is not general enough for the portaudio debian package.

Since PaUtil_GetTime() is the only function causing problems, just copy
over the code where it's used.
---
 src/AudioIO.cpp | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp
index 48715869c..bb4bf472c 100644
--- a/src/AudioIO.cpp
+++ b/src/AudioIO.cpp
@@ -480,9 +480,22 @@ time warp info and AudioIOListener and whether the playback is looped.
    #define ROUND(x) (int) ((x)+0.5)
    //#include <string.h>
 //   #include "../lib-src/portmidi/pm_common/portmidi.h"
-   #include "../lib-src/portaudio-v19/src/common/pa_util.h"
    #include "NoteTrack.h"
 #endif
+PaTime PaUtil_GetTime( void )
+{
+#ifdef HAVE_MACH_ABSOLUTE_TIME
+    return mach_absolute_time() * machSecondsConversionScaler_;
+#elif defined(HAVE_CLOCK_GETTIME)
+    struct timespec tp;
+    clock_gettime(CLOCK_REALTIME, &tp);
+    return (PaTime)(tp.tv_sec + tp.tv_nsec * 1e-9);
+#else
+    struct timeval tv;
+    gettimeofday( &tv, NULL );
+    return (PaTime) tv.tv_usec * 1e-6 + tv.tv_sec;
+#endif
+}

 #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
    #define LOWER_BOUND 0.0


code:
Description: fix buffer overflow when changing both sample format and
 number of channels
Origin: https://github.com/mpruett/audiofile/pull/25
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/audiofile/+bug/1502721
Bug-Debian: https://bugs.debian.org/801102

--- a/libaudiofile/modules/ModuleState.cpp
+++ b/libaudiofile/modules/ModuleState.cpp
@@ -402,7 +402,7 @@ status ModuleState::arrange(AFfilehandle
 		addModule(new Transform(outfc, in.pcm, out.pcm));

 	if (in.channelCount != out.channelCount)
-		addModule(new ApplyChannelMatrix(infc, isReading,
+		addModule(new ApplyChannelMatrix(outfc, isReading,
 			in.channelCount, out.channelCount,
 			in.pcm.minClip, in.pcm.maxClip,
 			track->channelMatrix));
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -26,6 +26,7 @@ TESTS = \
 	VirtualFile \
 	floatto24 \
 	query2 \
+	sixteen-stereo-to-eight-mono \
 	sixteen-to-eight \
 	testchannelmatrix \
 	testdouble \
@@ -139,6 +140,7 @@ printmarkers_SOURCES = printmarkers.c
 printmarkers_LDADD = $(LIBAUDIOFILE) -lm

 sixteen_to_eight_SOURCES = sixteen-to-eight.c TestUtilities.cpp TestUtilities.h
+sixteen_stereo_to_eight_mono_SOURCES = sixteen-stereo-to-eight-mono.c TestUtilities.cpp TestUtilities.h

 testchannelmatrix_SOURCES = testchannelmatrix.c TestUtilities.cpp TestUtilities.h

--- /dev/null
+++ b/test/sixteen-stereo-to-eight-mono.c
@@ -0,0 +1,118 @@
+/*
+	Audio File Library
+
+	Copyright 2000, Silicon Graphics, 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
+	the Free Software Foundation; either version 2 of the License, or
+	(at your option) any later version.
+
+	This program is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	GNU General Public License for more details.
+
+	You should have received a copy of the GNU General Public License along
+	with this program; if not, write to the Free Software Foundation, Inc.,
+	51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+/*
+	sixteen-stereo-to-eight-mono.c
+
+	This program tests the conversion from 2-channel 16-bit integers to
+	1-channel 8-bit	integers.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+
+#include <audiofile.h>
+
+#include "TestUtilities.h"
+
+int main (int argc, char **argv)
+{
+	AFfilehandle file;
+	AFfilesetup setup;
+	int16_t frames16[] = {14298, 392, 3923, -683, 958, -1921};
+	int8_t frames8[] = {28, 6, -2};
+	int i, frameCount = 3;
+	int8_t byte;
+	AFframecount result;
+
+	setup = afNewFileSetup();
+
+	afInitFileFormat(setup, AF_FILE_WAVE);
+
+	afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
+	afInitChannels(setup, AF_DEFAULT_TRACK, 2);
+
+	char *testFileName;
+	if (!createTemporaryFile("sixteen-to-eight", &testFileName))
+	{
+		fprintf(stderr, "Could not create temporary file.\n");
+		exit(EXIT_FAILURE);
+	}
+
+	file = afOpenFile(testFileName, "w", setup);
+	if (file == AF_NULL_FILEHANDLE)
+	{
+		fprintf(stderr, "could not open file for writing\n");
+		exit(EXIT_FAILURE);
+	}
+
+	afFreeFileSetup(setup);
+
+	afWriteFrames(file, AF_DEFAULT_TRACK, frames16, frameCount);
+
+	afCloseFile(file);
+
+	file = afOpenFile(testFileName, "r", AF_NULL_FILESETUP);
+	if (file == AF_NULL_FILEHANDLE)
+	{
+		fprintf(stderr, "could not open file for reading\n");
+		exit(EXIT_FAILURE);
+	}
+
+	afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 8);
+	afSetVirtualChannels(file, AF_DEFAULT_TRACK, 1);
+
+	for (i=0; i<frameCount; i++)
+	{
+		/* Read one frame. */
+		result = afReadFrames(file, AF_DEFAULT_TRACK, &byte, 1);
+
+		if (result != 1)
+			break;
+
+		/* Compare the byte read with its precalculated value. */
+		if (memcmp(&byte, &frames8[i], 1) != 0)
+		{
+			printf("error\n");
+			printf("expected %d, got %d\n", frames8[i], byte);
+			exit(EXIT_FAILURE);
+		}
+		else
+		{
+#ifdef DEBUG
+			printf("got what was expected: %d\n", byte);
+#endif
+		}
+	}
+
+	afCloseFile(file);
+	unlink(testFileName);
+	free(testFileName);
+
+	exit(EXIT_SUCCESS);
+}


code:
From fde6d79fb8363c4a329a184ef0b107156602b225 Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
Date: Thu, 27 Sep 2018 10:48:45 +0200
Subject: [PATCH] ModuleState: handle compress/decompress init failure

When the unit initcompress or initdecompress function fails,
m_fileModule is NULL. Return AF_FAIL in that case instead of
causing NULL pointer dereferences later.

Fixes #49
---
 libaudiofile/modules/ModuleState.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libaudiofile/modules/ModuleState.cpp b/libaudiofile/modules/ModuleState.cpp
index 0c29d7a..070fd9b 100644
--- a/libaudiofile/modules/ModuleState.cpp
+++ b/libaudiofile/modules/ModuleState.cpp
@@ -75,6 +75,9 @@ status ModuleState::initFileModule(AFfilehandle file, Track *track)
 		m_fileModule = unit->initcompress(track, file->m_fh, file->m_seekok,
 			file->m_fileFormat == AF_FILE_RAWDATA, &chunkFrames);

+	if (!m_fileModule)
+		return AF_FAIL;
+
 	if (unit->needsRebuffer)
 	{
 		assert(unit->nativeSampleFormat == AF_SAMPFMT_TWOSCOMP);


code:
From 822b732fd31ffcb78f6920001e9b1fbd815fa712 Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
Date: Thu, 27 Sep 2018 12:11:12 +0200
Subject: [PATCH] SimpleModule: set output chunk framecount after pull

After pulling the data, set the output chunk to the amount of
frames we pulled so that the next module in the chain has the correct
frame count.

Fixes #50 and #51
---
 libaudiofile/modules/SimpleModule.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libaudiofile/modules/SimpleModule.cpp b/libaudiofile/modules/SimpleModule.cpp
index 2bae1eb..e87932c 100644
--- a/libaudiofile/modules/SimpleModule.cpp
+++ b/libaudiofile/modules/SimpleModule.cpp
@@ -26,6 +26,7 @@
 void SimpleModule::runPull()
 {
 	pull(m_outChunk->frameCount);
+	m_outChunk->frameCount = m_inChunk->frameCount;
 	run(*m_inChunk, *m_outChunk);
 }


code:
From: Antonio Larrosa <larrosa@kde.org>
Date: Mon, 6 Mar 2017 12:51:22 +0100
Subject: Always check the number of coefficients

When building the library with NDEBUG, asserts are eliminated
so it's better to always check that the number of coefficients
is inside the array range.

This fixes the 00191-audiofile-indexoob issue in #41
---
 libaudiofile/WAVE.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libaudiofile/WAVE.cpp b/libaudiofile/WAVE.cpp
index 9dd8511..0fc48e8 100644
--- a/libaudiofile/WAVE.cpp
+++ b/libaudiofile/WAVE.cpp
@@ -281,6 +281,12 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)

 			/* numCoefficients should be at least 7. */
 			assert(numCoefficients >= 7 && numCoefficients <= 255);
+			if (numCoefficients < 7 || numCoefficients > 255)
+			{
+				_af_error(AF_BAD_HEADER,
+						"Bad number of coefficients");
+				return AF_FAIL;
+			}

 			m_msadpcmNumCoefficients = numCoefficients;


code:
From: Antonio Larrosa <larrosa@kde.org>
Date: Mon, 6 Mar 2017 18:59:26 +0100
Subject: Actually fail when error occurs in parseFormat

When there's an unsupported number of bits per sample or an invalid
number of samples per block, don't only print an error message using
the error handler, but actually stop parsing the file.

This fixes #35 (also reported at
https://bugzilla.opensuse.org/show_bug.cgi?id=1026983 and
https://blogs.gentoo.org/ago/2017/02/20/audiofile-heap-based-buffer-overflow-in-imadecodeblockwave-ima-cpp/
)
---
 libaudiofile/WAVE.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libaudiofile/WAVE.cpp b/libaudiofile/WAVE.cpp
index 0fc48e8..d04b796 100644
--- a/libaudiofile/WAVE.cpp
+++ b/libaudiofile/WAVE.cpp
@@ -332,6 +332,7 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
 			{
 				_af_error(AF_BAD_NOT_IMPLEMENTED,
 					"IMA ADPCM compression supports only 4 bits per sample");
+				return AF_FAIL;
 			}

 			int bytesPerBlock = (samplesPerBlock + 14) / 8 * 4 * channelCount;
@@ -339,6 +340,7 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
 			{
 				_af_error(AF_BAD_CODEC_CONFIG,
 					"Invalid samples per block for IMA ADPCM compression");
+				return AF_FAIL;
 			}

 			track->f.sampleWidth = 16;


code:
From: Antonio Larrosa <larrosa@kde.org>
Date: Mon, 6 Mar 2017 18:02:31 +0100
Subject: clamp index values to fix index overflow in IMA.cpp

This fixes #33
(also reported at https://bugzilla.opensuse.org/show_bug.cgi?id=1026981
and https://blogs.gentoo.org/ago/2017/02/20/audiofile-global-buffer-overflow-in-decodesample-ima-cpp/)
---
 libaudiofile/modules/IMA.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libaudiofile/modules/IMA.cpp b/libaudiofile/modules/IMA.cpp
index 7476d44..df4aad6 100644
--- a/libaudiofile/modules/IMA.cpp
+++ b/libaudiofile/modules/IMA.cpp
@@ -169,7 +169,7 @@ int IMA::decodeBlockWAVE(const uint8_t *encoded, int16_t *decoded)
 		if (encoded[1] & 0x80)
 			m_adpcmState[c].previousValue -= 0x10000;

-		m_adpcmState[c].index = encoded[2];
+		m_adpcmState[c].index = clamp(encoded[2], 0, 88);

 		*decoded++ = m_adpcmState[c].previousValue;

@@ -210,7 +210,7 @@ int IMA::decodeBlockQT(const uint8_t *encoded, int16_t *decoded)
 			predictor -= 0x10000;

 		state.previousValue = clamp(predictor, MIN_INT16, MAX_INT16);
-		state.index = encoded[1] & 0x7f;
+		state.index = clamp(encoded[1] & 0x7f, 0, 88);
 		encoded += 2;

 		for (int n=0; n<m_framesPerPacket; n+=2)


code:
From: Antonio Larrosa <larrosa@kde.org>
Date: Mon, 6 Mar 2017 13:54:52 +0100
Subject: Check for multiplication overflow in sfconvert

Checks that a multiplication doesn't overflow when
calculating the buffer size, and if it overflows,
reduce the buffer size instead of failing.

This fixes the 00192-audiofile-signintoverflow-sfconvert case
in #41
---
 sfcommands/sfconvert.c | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/sfcommands/sfconvert.c b/sfcommands/sfconvert.c
index 80a1bc4..970a3e4 100644
--- a/sfcommands/sfconvert.c
+++ b/sfcommands/sfconvert.c
@@ -45,6 +45,33 @@ void printusage (void);
 void usageerror (void);
 bool copyaudiodata (AFfilehandle infile, AFfilehandle outfile, int trackid);

+int firstBitSet(int x)
+{
+        int position=0;
+        while (x!=0)
+        {
+                x>>=1;
+                ++position;
+        }
+        return position;
+}
+
+#ifndef __has_builtin
+#define __has_builtin(x) 0
+#endif
+
+int multiplyCheckOverflow(int a, int b, int *result)
+{
+#if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow))
+	return __builtin_mul_overflow(a, b, result);
+#else
+	if (firstBitSet(a)+firstBitSet(b)>31) // int is signed, so we can't use 32 bits
+		return true;
+	*result = a * b;
+	return false;
+#endif
+}
+
 int main (int argc, char **argv)
 {
 	if (argc == 2)
@@ -323,8 +350,11 @@ bool copyaudiodata (AFfilehandle infile, AFfilehandle outfile, int trackid)
 {
 	int frameSize = afGetVirtualFrameSize(infile, trackid, 1);

-	const int kBufferFrameCount = 65536;
-	void *buffer = malloc(kBufferFrameCount * frameSize);
+	int kBufferFrameCount = 65536;
+	int bufferSize;
+	while (multiplyCheckOverflow(kBufferFrameCount, frameSize, &bufferSize))
+		kBufferFrameCount /= 2;
+	void *buffer = malloc(bufferSize);

 	AFframecount totalFrames = afGetFrameCount(infile, AF_DEFAULT_TRACK);
 	AFframecount totalFramesWritten = 0;


code:
From: Antonio Larrosa <larrosa@kde.org>
Date: Mon, 6 Mar 2017 13:43:53 +0100
Subject: Check for multiplication overflow in MSADPCM decodeSample

Check for multiplication overflow (using __builtin_mul_overflow
if available) in MSADPCM.cpp decodeSample and return an empty
decoded block if an error occurs.

This fixes the 00193-audiofile-signintoverflow-MSADPCM case of #41
---
 libaudiofile/modules/BlockCodec.cpp |  5 ++--
 libaudiofile/modules/MSADPCM.cpp    | 47 +++++++++++++++++++++++++++++++++----
 2 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/libaudiofile/modules/BlockCodec.cpp b/libaudiofile/modules/BlockCodec.cpp
index 45925e8..4731be1 100644
--- a/libaudiofile/modules/BlockCodec.cpp
+++ b/libaudiofile/modules/BlockCodec.cpp
@@ -52,8 +52,9 @@ void BlockCodec::runPull()
 	// Decompress into m_outChunk.
 	for (int i=0; i<blocksRead; i++)
 	{
-		decodeBlock(static_cast<const uint8_t *>(m_inChunk->buffer) + i * m_bytesPerPacket,
-			static_cast<int16_t *>(m_outChunk->buffer) + i * m_framesPerPacket * m_track->f.channelCount);
+		if (decodeBlock(static_cast<const uint8_t *>(m_inChunk->buffer) + i * m_bytesPerPacket,
+			static_cast<int16_t *>(m_outChunk->buffer) + i * m_framesPerPacket * m_track->f.channelCount)==0)
+			break;

 		framesRead += m_framesPerPacket;
 	}
diff --git a/libaudiofile/modules/MSADPCM.cpp b/libaudiofile/modules/MSADPCM.cpp
index 8ea3c85..ef9c38c 100644
--- a/libaudiofile/modules/MSADPCM.cpp
+++ b/libaudiofile/modules/MSADPCM.cpp
@@ -101,24 +101,60 @@ static const int16_t adaptationTable[] =
 	768, 614, 512, 409, 307, 230, 230, 230
 };

+int firstBitSet(int x)
+{
+        int position=0;
+        while (x!=0)
+        {
+                x>>=1;
+                ++position;
+        }
+        return position;
+}
+
+#ifndef __has_builtin
+#define __has_builtin(x) 0
+#endif
+
+int multiplyCheckOverflow(int a, int b, int *result)
+{
+#if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow))
+	return __builtin_mul_overflow(a, b, result);
+#else
+	if (firstBitSet(a)+firstBitSet(b)>31) // int is signed, so we can't use 32 bits
+		return true;
+	*result = a * b;
+	return false;
+#endif
+}
+
+
 // Compute a linear PCM value from the given differential coded value.
 static int16_t decodeSample(ms_adpcm_state &state,
-	uint8_t code, const int16_t *coefficient)
+	uint8_t code, const int16_t *coefficient, bool *ok=NULL)
 {
 	int linearSample = (state.sample1 * coefficient[0] +
 		state.sample2 * coefficient[1]) >> 8;
+	int delta;

 	linearSample += ((code & 0x08) ? (code - 0x10) : code) * state.delta;

 	linearSample = clamp(linearSample, MIN_INT16, MAX_INT16);

-	int delta = (state.delta * adaptationTable[code]) >> 8;
+	if (multiplyCheckOverflow(state.delta, adaptationTable[code], &delta))
+	{
+                if (ok) *ok=false;
+		_af_error(AF_BAD_COMPRESSION, "Error decoding sample");
+		return 0;
+	}
+	delta >>= 8;
 	if (delta < 16)
 		delta = 16;

 	state.delta = delta;
 	state.sample2 = state.sample1;
 	state.sample1 = linearSample;
+	if (ok) *ok=true;

 	return static_cast<int16_t>(linearSample);
 }
@@ -212,13 +248,16 @@ int MSADPCM::decodeBlock(const uint8_t *encoded, int16_t *decoded)
 	{
 		uint8_t code;
 		int16_t newSample;
+		bool ok;

 		code = *encoded >> 4;
-		newSample = decodeSample(*state[0], code, coefficient[0]);
+		newSample = decodeSample(*state[0], code, coefficient[0], &ok);
+		if (!ok) return 0;
 		*decoded++ = newSample;

 		code = *encoded & 0x0f;
-		newSample = decodeSample(*state[1], code, coefficient[1]);
+		newSample = decodeSample(*state[1], code, coefficient[1], &ok);
+		if (!ok) return 0;
 		*decoded++ = newSample;

 		encoded++;


code:
From: Antonio Larrosa <larrosa@kde.org>
Date: Thu, 9 Mar 2017 10:21:18 +0100
Subject: Check for division by zero in BlockCodec::runPull

---
 libaudiofile/modules/BlockCodec.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libaudiofile/modules/BlockCodec.cpp b/libaudiofile/modules/BlockCodec.cpp
index 4731be1..eb2fb4d 100644
--- a/libaudiofile/modules/BlockCodec.cpp
+++ b/libaudiofile/modules/BlockCodec.cpp
@@ -47,7 +47,7 @@ void BlockCodec::runPull()

 	// Read the compressed data.
 	ssize_t bytesRead = read(m_inChunk->buffer, m_bytesPerPacket * blockCount);
-	int blocksRead = bytesRead >= 0 ? bytesRead / m_bytesPerPacket : 0;
+	int blocksRead = (bytesRead >= 0 && m_bytesPerPacket > 0) ? bytesRead / m_bytesPerPacket : 0;

 	// Decompress into m_outChunk.
 	for (int i=0; i<blocksRead; i++)


code:
Based on (hunks for changelog and Identy.cpp removed)
From ecbc07f0ed336187cc9a67c3363f89681b8b8f52 Mon Sep 17 00:00:00 2001
From: Michael Pruett <michael@68k.org>
Date: Tue, 5 Jul 2016 23:26:16 -0500
Subject: [PATCH] Fix type of test data arrays.

---
 ChangeLog         | 6 ++++++
 test/Identify.cpp | 3 ++-
 test/NeXT.cpp     | 7 ++++---
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/test/NeXT.cpp b/test/NeXT.cpp
index 7e39850..29af877 100644
--- a/test/NeXT.cpp
+++ b/test/NeXT.cpp
@@ -30,6 +30,7 @@
 #include <audiofile.h>
 #include <fcntl.h>
 #include <gtest/gtest.h>
+#include <stdint.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
@@ -37,7 +38,7 @@

 #include "TestUtilities.h"

-const char kDataUnspecifiedLength[] =
+const uint8_t kDataUnspecifiedLength[] =
 {
 	'.', 's', 'n', 'd',
 	0, 0, 0, 24, // offset of 24 bytes
@@ -57,7 +58,7 @@ const char kDataUnspecifiedLength[] =
 	0, 55
 };

-const char kDataTruncated[] =
+const uint8_t kDataTruncated[] =
 {
 	'.', 's', 'n', 'd',
 	0, 0, 0, 24, // offset of 24 bytes
@@ -152,7 +153,7 @@ TEST(NeXT, Truncated)
 	ASSERT_EQ(::unlink(testFileName.c_str()), 0);
 }

-const char kDataZeroChannels[] =
+const uint8_t kDataZeroChannels[] =
 {
 	'.', 's', 'n', 'd',
 	0, 0, 0, 24, // offset of 24 bytes


code:
Based on (hunk for changelog removed)
From b62c902dd258125cac86cd2df21fc898035a43d3 Mon Sep 17 00:00:00 2001
From: Michael Pruett <michael@68k.org>
Date: Mon, 29 Aug 2016 23:08:26 -0500
Subject: [PATCH] Fix undefined behavior in sign conversion.

---
 ChangeLog                           | 5 +++++
 libaudiofile/modules/SimpleModule.h | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libaudiofile/modules/SimpleModule.h b/libaudiofile/modules/SimpleModule.h
index 03c6c69..bad85ad 100644
--- a/libaudiofile/modules/SimpleModule.h
+++ b/libaudiofile/modules/SimpleModule.h
@@ -123,7 +123,8 @@ struct signConverter
 	typedef typename IntTypes<Format>::UnsignedType UnsignedType;

 	static const int kScaleBits = (Format + 1) * CHAR_BIT - 1;
-	static const int kMinSignedValue = -1 << kScaleBits;
+	static const int kMaxSignedValue = (((1 << (kScaleBits - 1)) - 1) << 1) + 1;
+	static const int kMinSignedValue = -kMaxSignedValue - 1;

 	struct signedToUnsigned : public std::unary_function<SignedType, UnsignedType>
 	{


code:
Description: Remove usage of PATH_MAX in tests to fix FTBFS on Hurd.
 jcowgill: Removed Changelog changes
Author: Pino Toscano <toscano.pino@tiscali.it>
Origin: backport, https://github.com/mpruett/audiofile/commit/34c261034f1193a783196618f0052112e00fbcfe
Bug: https://github.com/mpruett/audiofile/pull/17
Bug-Debian: https://bugs.debian.org/762595
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/

--- a/test/TestUtilities.cpp
+++ b/test/TestUtilities.cpp
@@ -21,8 +21,8 @@
 #include "TestUtilities.h"

 #include <limits.h>
-#include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>

 bool createTemporaryFile(const std::string &prefix, std::string *path)
@@ -35,12 +35,12 @@ bool createTemporaryFile(const std::stri
 	return true;
 }

-bool createTemporaryFile(const char *prefix, char *path)
+bool createTemporaryFile(const char *prefix, char **path)
 {
-	snprintf(path, PATH_MAX, "/tmp/%s-XXXXXX", prefix);
-	int fd = ::mkstemp(path);
-	if (fd < 0)
-		return false;
-	::close(fd);
-	return true;
+	*path = NULL;
+	std::string pathString;
+	bool result = createTemporaryFile(prefix, &pathString);
+	if (result)
+		*path = ::strdup(pathString.c_str());
+	return result;
 }
--- a/test/TestUtilities.h
+++ b/test/TestUtilities.h
@@ -53,7 +53,7 @@ extern "C" {

 #include <stdbool.h>

-bool createTemporaryFile(const char *prefix, char *path);
+bool createTemporaryFile(const char *prefix, char **path);

 #ifdef __cplusplus
 }
--- a/test/floatto24.c
+++ b/test/floatto24.c
@@ -86,8 +86,8 @@ int main (int argc, char **argv)
 	afInitChannels(setup, AF_DEFAULT_TRACK, 1);
 	afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_FLOAT, 32);

-	char testFileName[PATH_MAX];
-	if (!createTemporaryFile("floatto24", testFileName))
+	char *testFileName;
+	if (!createTemporaryFile("floatto24", &testFileName))
 	{
 		fprintf(stderr, "Could not create temporary file.\n");
 		exit(EXIT_FAILURE);
@@ -182,6 +182,7 @@ int main (int argc, char **argv)
 	}

 	unlink(testFileName);
+	free(testFileName);

 	exit(EXIT_SUCCESS);
 }
--- a/test/sixteen-to-eight.c
+++ b/test/sixteen-to-eight.c
@@ -57,8 +57,8 @@ int main (int argc, char **argv)
 	afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_UNSIGNED, 8);
 	afInitChannels(setup, AF_DEFAULT_TRACK, 1);

-	char testFileName[PATH_MAX];
-	if (!createTemporaryFile("sixteen-to-eight", testFileName))
+	char *testFileName;
+	if (!createTemporaryFile("sixteen-to-eight", &testFileName))
 	{
 		fprintf(stderr, "Could not create temporary file.\n");
 		exit(EXIT_FAILURE);
@@ -113,6 +113,7 @@ int main (int argc, char **argv)

 	afCloseFile(file);
 	unlink(testFileName);
+	free(testFileName);

 	exit(EXIT_SUCCESS);
 }
--- a/test/testchannelmatrix.c
+++ b/test/testchannelmatrix.c
@@ -39,7 +39,7 @@

 #include "TestUtilities.h"

-static char sTestFileName[PATH_MAX];
+static char *sTestFileName;

 const short samples[] = {300, -300, 515, -515, 2315, -2315, 9154, -9154};
 #define SAMPLE_COUNT (sizeof (samples) / sizeof (short))
@@ -47,7 +47,11 @@ const short samples[] = {300, -300, 515,

 void cleanup (void)
 {
-	unlink(sTestFileName);
+	if (sTestFileName)
+	{
+		unlink(sTestFileName);
+		free(sTestFileName);
+	}
 }

 void ensure (int condition, const char *message)
@@ -76,7 +80,7 @@ int main (void)
 	afInitFileFormat(setup, AF_FILE_AIFFC);

 	/* Write stereo data to test file. */
-	ensure(createTemporaryFile("testchannelmatrix", sTestFileName),
+	ensure(createTemporaryFile("testchannelmatrix", &sTestFileName),
 		"could not create temporary file");
 	file = afOpenFile(sTestFileName, "w", setup);
 	ensure(file != AF_NULL_FILEHANDLE, "could not open file for writing");
--- a/test/testdouble.c
+++ b/test/testdouble.c
@@ -38,7 +38,7 @@

 #include "TestUtilities.h"

-static char sTestFileName[PATH_MAX];
+static char *sTestFileName;

 const double samples[] =
 	{1.0, 0.6, -0.3, 0.95, 0.2, -0.6, 0.9, 0.4, -0.22, 0.125, 0.1, -0.4};
@@ -48,7 +48,11 @@ void testdouble (int fileFormat);

 void cleanup (void)
 {
-	unlink(sTestFileName);
+	if (sTestFileName)
+	{
+		unlink(sTestFileName);
+		free(sTestFileName);
+	}
 }

 void ensure (int condition, const char *message)
@@ -96,7 +100,7 @@ void testdouble (int fileFormat)
 	afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_DOUBLE, 64);
 	afInitChannels(setup, AF_DEFAULT_TRACK, 2);

-	ensure(createTemporaryFile("testdouble", sTestFileName),
+	ensure(createTemporaryFile("testdouble", &sTestFileName),
 		"could not create temporary file");
 	file = afOpenFile(sTestFileName, "w", setup);
 	ensure(file != AF_NULL_FILEHANDLE, "could not open file for writing");
--- a/test/testfloat.c
+++ b/test/testfloat.c
@@ -38,7 +38,7 @@

 #include "TestUtilities.h"

-static char sTestFileName[PATH_MAX];
+static char *sTestFileName;

 const float samples[] =
 	{1.0, 0.6, -0.3, 0.95, 0.2, -0.6, 0.9, 0.4, -0.22, 0.125, 0.1, -0.4};
@@ -48,7 +48,11 @@ void testfloat (int fileFormat);

 void cleanup (void)
 {
-	unlink(sTestFileName);
+	if (sTestFileName)
+	{
+		unlink(sTestFileName);
+		free(sTestFileName);
+	}
 }

 void ensure (int condition, const char *message)
@@ -96,7 +100,7 @@ void testfloat (int fileFormat)
 	afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_FLOAT, 32);
 	afInitChannels(setup, AF_DEFAULT_TRACK, 2);

-	ensure(createTemporaryFile("testfloat", sTestFileName),
+	ensure(createTemporaryFile("testfloat", &sTestFileName),
 		"could not create temporary file");
 	file = afOpenFile(sTestFileName, "w", setup);
 	ensure(file != AF_NULL_FILEHANDLE, "could not open file for writing");
--- a/test/testmarkers.c
+++ b/test/testmarkers.c
@@ -32,15 +32,19 @@

 #include "TestUtilities.h"

-static char sTestFileName[PATH_MAX];
+static char *sTestFileName;

 #define FRAME_COUNT 200

 void cleanup (void)
 {
+	if (sTestFileName)
+	{
 #ifndef DEBUG
-	unlink(sTestFileName);
+		unlink(sTestFileName);
 #endif
+		free(sTestFileName);
+	}
 }

 void ensure (int condition, const char *message)
@@ -127,7 +131,7 @@ int testmarkers (int fileformat)

 int main (void)
 {
-	ensure(createTemporaryFile("testmarkers", sTestFileName),
+	ensure(createTemporaryFile("testmarkers", &sTestFileName),
 		"could not create temporary file");

 	testmarkers(AF_FILE_AIFF);
--- a/test/twentyfour.c
+++ b/test/twentyfour.c
@@ -71,8 +71,8 @@ int main (int argc, char **argv)
 	afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 24);
 	afInitChannels(setup, AF_DEFAULT_TRACK, 1);

-	char testFileName[PATH_MAX];
-	if (!createTemporaryFile("twentyfour", testFileName))
+	char *testFileName;
+	if (!createTemporaryFile("twentyfour", &testFileName))
 	{
 		fprintf(stderr, "could not create temporary file\n");
 		exit(EXIT_FAILURE);
@@ -239,6 +239,7 @@ int main (int argc, char **argv)
 		exit(EXIT_FAILURE);
 	}
 	unlink(testFileName);
+	free(testFileName);

 	exit(EXIT_SUCCESS);
 }
--- a/test/twentyfour2.c
+++ b/test/twentyfour2.c
@@ -45,15 +45,19 @@

 #include "TestUtilities.h"

-static char sTestFileName[PATH_MAX];
+static char *sTestFileName;

 #define FRAME_COUNT 10000

 void cleanup (void)
 {
+	if (sTestFileName)
+	{
 #ifndef DEBUG
-	unlink(sTestFileName);
+		unlink(sTestFileName);
 #endif
+		free(sTestFileName);
+	}
 }

 void ensure (int condition, const char *message)
@@ -78,7 +82,7 @@ int main (void)
 	afInitChannels(setup, AF_DEFAULT_TRACK, 1);
 	afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 24);

-	ensure(createTemporaryFile("twentyfour2", sTestFileName),
+	ensure(createTemporaryFile("twentyfour2", &sTestFileName),
 		"could not create temporary file");
 	file = afOpenFile(sTestFileName, "w", setup);
 	ensure(file != NULL, "could not open test file for writing");
--- a/test/writealaw.c
+++ b/test/writealaw.c
@@ -53,7 +53,7 @@

 #include "TestUtilities.h"

-static char sTestFileName[PATH_MAX];
+static char *sTestFileName;

 #define FRAME_COUNT 16
 #define SAMPLE_COUNT FRAME_COUNT
@@ -62,9 +62,13 @@ void testalaw (int fileFormat);

 void cleanup (void)
 {
+	if (sTestFileName)
+	{
 #ifndef DEBUG
-	unlink(sTestFileName);
+		unlink(sTestFileName);
 #endif
+		free(sTestFileName);
+	}
 }

 void ensure (int condition, const char *message)
@@ -113,7 +117,7 @@ void testalaw (int fileFormat)
 	afInitFileFormat(setup, fileFormat);
 	afInitChannels(setup, AF_DEFAULT_TRACK, 1);

-	ensure(createTemporaryFile("writealaw", sTestFileName),
+	ensure(createTemporaryFile("writealaw", &sTestFileName),
 		"could not create temporary file");
 	file = afOpenFile(sTestFileName, "w", setup);
 	afFreeFileSetup(setup);
--- a/test/writeraw.c
+++ b/test/writeraw.c
@@ -44,13 +44,17 @@

 #include "TestUtilities.h"

-static char sTestFileName[PATH_MAX];
+static char *sTestFileName;

 void cleanup (void)
 {
+	if (sTestFileName)
+	{
 #ifndef DEBUG
-	unlink(sTestFileName);
+		unlink(sTestFileName);
 #endif
+		free(sTestFileName);
+	}
 }

 void ensure (int condition, const char *message)
@@ -84,7 +88,7 @@ int main (int argc, char **argv)
 	afInitChannels(setup, AF_DEFAULT_TRACK, 1);
 	afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);

-	ensure(createTemporaryFile("writeraw", sTestFileName),
+	ensure(createTemporaryFile("writeraw", &sTestFileName),
 		"could not create temporary file");
 	file = afOpenFile(sTestFileName, "w", setup);
 	ensure(file != AF_NULL_FILEHANDLE, "unable to open file for writing");
--- a/test/writeulaw.c
+++ b/test/writeulaw.c
@@ -53,7 +53,7 @@

 #include "TestUtilities.h"

-static char sTestFileName[PATH_MAX];
+static char *sTestFileName;

 #define FRAME_COUNT 16
 #define SAMPLE_COUNT FRAME_COUNT
@@ -62,9 +62,13 @@ void testulaw (int fileFormat);

 void cleanup (void)
 {
+	if (sTestFileName)
+	{
 #ifndef DEBUG
-	unlink(sTestFileName);
+		unlink(sTestFileName);
 #endif
+		free(sTestFileName);
+	}
 }

 void ensure (int condition, const char *message)
@@ -113,7 +117,7 @@ void testulaw (int fileFormat)
 	afInitFileFormat(setup, fileFormat);
 	afInitChannels(setup, AF_DEFAULT_TRACK, 1);

-	ensure(createTemporaryFile("writeulaw", sTestFileName),
+	ensure(createTemporaryFile("writeulaw", &sTestFileName),
 		"could not create temporary file");
 	file = afOpenFile(sTestFileName, "w", setup);
 	afFreeFileSetup(setup);


code:
From: Antonio Larrosa <larrosa@kde.org>
Date: Fri, 10 Mar 2017 15:40:02 +0100
Subject: Fix signature of multiplyCheckOverflow. It returns a bool, not an int

---
 libaudiofile/modules/MSADPCM.cpp | 2 +-
 sfcommands/sfconvert.c           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libaudiofile/modules/MSADPCM.cpp b/libaudiofile/modules/MSADPCM.cpp
index ef9c38c..d8c9553 100644
--- a/libaudiofile/modules/MSADPCM.cpp
+++ b/libaudiofile/modules/MSADPCM.cpp
@@ -116,7 +116,7 @@ int firstBitSet(int x)
 #define __has_builtin(x) 0
 #endif

-int multiplyCheckOverflow(int a, int b, int *result)
+bool multiplyCheckOverflow(int a, int b, int *result)
 {
 #if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow))
 	return __builtin_mul_overflow(a, b, result);
diff --git a/sfcommands/sfconvert.c b/sfcommands/sfconvert.c
index 970a3e4..367f7a5 100644
--- a/sfcommands/sfconvert.c
+++ b/sfcommands/sfconvert.c
@@ -60,7 +60,7 @@ int firstBitSet(int x)
 #define __has_builtin(x) 0
 #endif

-int multiplyCheckOverflow(int a, int b, int *result)
+bool multiplyCheckOverflow(int a, int b, int *result)
 {
 #if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow))
 	return __builtin_mul_overflow(a, b, result);


code:
Skip tests that rely on the `amhello' tarball that comes with Automake.
That tarball's `configure' uses #!/bin/sh, but we can't easily patch it.

diff --git a/t/amhello-binpkg.sh b/t/amhello-binpkg.sh
index fa88cc6..d988cee 100755
--- a/t/amhello-binpkg.sh
+++ b/t/amhello-binpkg.sh
@@ -17,6 +17,7 @@
 # Test an example from the manual about the 'amhello' package:
 # using DESTDIR to build simple, no-frills binary packages.

+exit 77
 am_create_testdir=empty
 . ./defs || exit 1

diff --git a/t/amhello-cflags.sh b/t/amhello-cflags.sh
index 666011f..2a95e3c 100755
--- a/t/amhello-cflags.sh
+++ b/t/amhello-cflags.sh
@@ -18,6 +18,7 @@
 # using VPATH builds to configure the same package with different
 # options.

+exit 77
 am_create_testdir=empty
 required=gcc
 . ./defs || exit 1
diff --git a/t/amhello-cross-compile.sh b/t/amhello-cross-compile.sh
index 708abda..2ee4292 100755
--- a/t/amhello-cross-compile.sh
+++ b/t/amhello-cross-compile.sh
@@ -17,6 +17,7 @@
 # Test an example from the manual about the 'amhello' package:
 # cross-compiling a package from Linux/Unix to MinGW.

+exit 77
 am_create_testdir=empty
 required=i586-mingw32msvc-gcc
 . ./defs || exit 1


code:
Don't "mkdir $(localstatedir)" since we can't do it (/var).

--- avahi-0.6.27/avahi-daemon/Makefile.in	2010-07-13 05:06:35.000000000 +0200
+++ avahi-0.6.27/avahi-daemon/Makefile.in	2010-07-13 18:03:45.000000000 +0200
@@ -1625,7 +1625,6 @@
 	done

 install-data-local:
-	test -z "$(avahi_runtime_dir)" || $(MKDIR_P) "$(DESTDIR)$(avahi_runtime_dir)"

 update-systemd:
 	curl http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.c > sd-daemon.c


code:
Patch by Andreas Enge to force installation of libraries into lib
independently of the architecture, instead of lib32 or lib64.
On x86_64, the C library path coded in CMAKE_C_IMPLICIT_LINK_DIRECTORIES
contains a library (jack) installed into lib64, which forces lib64
for avidemux with the original code.

diff -u -r avidemux_2.6.8.orig/cmake/admInstallDir.cmake avidemux_2.6.8/cmake/admInstallDir.cmake
--- avidemux_2.6.8.orig/cmake/admInstallDir.cmake	2014-03-12 07:15:23.000000000 +0100
+++ avidemux_2.6.8/cmake/admInstallDir.cmake	2015-07-26 14:31:10.418459984 +0200
@@ -16,13 +16,7 @@
                 MESSAGE(STATUS "No install dir provided, using /usr/local")
         ENDIF(NOT AVIDEMUX_INSTALL_DIR )
         SET(AVIDEMUX_BIN_DIR ${AVIDEMUX_INSTALL_DIR}/bin)
-        IF(CMAKE_C_IMPLICIT_LINK_DIRECTORIES MATCHES "\\/lib64([; ]|$)")
-                SET(AVIDEMUX_RELATIVE_LIB_DIR lib64)
-        ELSEIF(CMAKE_C_IMPLICIT_LINK_DIRECTORIES MATCHES "\\/lib32([; ]|$)")
-                SET(AVIDEMUX_RELATIVE_LIB_DIR lib32)
-        ELSE(CMAKE_C_IMPLICIT_LINK_DIRECTORIES MATCHES "\\/lib64([; ]|$)")
-                SET(AVIDEMUX_RELATIVE_LIB_DIR lib)
-        ENDIF(CMAKE_C_IMPLICIT_LINK_DIRECTORIES MATCHES "\\/lib64([; ]|$)")
+        SET(AVIDEMUX_RELATIVE_LIB_DIR lib)
         SET(AVIDEMUX_LIB_DIR ${AVIDEMUX_INSTALL_DIR}/${AVIDEMUX_RELATIVE_LIB_DIR})
 ENDIF(WIN32)
 SET(AVIDEMUX_INCLUDE_DIR ${AVIDEMUX_INSTALL_DIR}/include)


code:
Index: avogadro-1.2.0/libavogadro/src/pythonengine_p.h
===================================================================
--- avogadro-1.2.0.orig/libavogadro/src/pythonengine_p.h
+++ avogadro-1.2.0/libavogadro/src/pythonengine_p.h
@@ -31,7 +31,9 @@

 #include <avogadro/global.h>
 #include <avogadro/engine.h>
+#ifndef Q_MOC_RUN
 #include <boost/python.hpp>
+#endif

 namespace Avogadro {

Index: avogadro-1.2.0/libavogadro/src/pythonextension_p.h
===================================================================
--- avogadro-1.2.0.orig/libavogadro/src/pythonextension_p.h
+++ avogadro-1.2.0/libavogadro/src/pythonextension_p.h
@@ -33,7 +33,9 @@
 #include <avogadro/extension.h>
 #include <avogadro/primitive.h>
 #include <avogadro/glwidget.h>
+#ifndef Q_MOC_RUN
 #include <boost/python.hpp>
+#endif

 #include <QWidget>
 #include <QList>
Index: avogadro-1.2.0/libavogadro/src/pythontool_p.h
===================================================================
--- avogadro-1.2.0.orig/libavogadro/src/pythontool_p.h
+++ avogadro-1.2.0/libavogadro/src/pythontool_p.h
@@ -31,7 +31,9 @@

 #include <avogadro/global.h>
 #include <avogadro/tool.h>
+#ifndef Q_MOC_RUN
 #include <boost/python.hpp>
+#endif

 #include <QObject>
 #include <QAction>
Index: avogadro-1.2.0/libavogadro/src/pythoninterpreter.h
===================================================================
--- avogadro-1.2.0.orig/libavogadro/src/pythoninterpreter.h
+++ avogadro-1.2.0/libavogadro/src/pythoninterpreter.h
@@ -26,7 +26,9 @@
 #define PYTHONINTERPRETER_H

 #include <avogadro/global.h>
+#ifndef Q_MOC_RUN
 #include <boost/python.hpp>
+#endif
 #include <avogadro/primitive.h>
 #include <QString>

Index: avogadro-1.2.0/libavogadro/src/pythonscript.h
===================================================================
--- avogadro-1.2.0.orig/libavogadro/src/pythonscript.h
+++ avogadro-1.2.0/libavogadro/src/pythonscript.h
@@ -27,6 +27,8 @@
 #define PYTHONSCRIPT_H

 #include <avogadro/global.h>
+#ifndef Q_MOC_RUN
 #include <boost/python.hpp>
+#endif

 #include "pythonerror.h"