diff -pruN 0.9.1-2.2/debian/changelog 0.9.1-2.2ubuntu3/debian/changelog
--- 0.9.1-2.2/debian/changelog	2020-01-25 09:31:19.000000000 +0000
+++ 0.9.1-2.2ubuntu3/debian/changelog	2022-08-30 15:56:09.000000000 +0000
@@ -1,3 +1,38 @@
+presage (0.9.1-2.2ubuntu3) kinetic; urgency=medium
+
+  * d/p/c++17.patch: fix the build against GCC-11 by porting the code to C++17
+    (LP: #1988196)
+  * d/p/format-security.patch: fix insecure format strings in the demo code
+    (FTBFS on Ubuntu due to -Werror=format-security.patch)
+
+ -- Simon Chopin <schopin@ubuntu.com>  Tue, 30 Aug 2022 17:56:09 +0200
+
+presage (0.9.1-2.2ubuntu2) jammy; urgency=medium
+
+  * No-change rebuild against latest gdk-pixbuf
+
+ -- Jeremy Bicha <jeremy.bicha@canonical.com>  Wed, 09 Mar 2022 18:53:51 -0500
+
+presage (0.9.1-2.2ubuntu1) groovy; urgency=low
+
+  * Merge from Debian unstable.  Remaining changes:
+    - Remove python-wxgtk3.0 from Build-Depends
+    - debian/patches/ubuntu_dont_require_wxpython.patch: Do not check for wx
+      to enable pyprompter
+    - debian/patches/dont-tokenize-on-apostrophes.patch: Allow words with
+      apostrophes to be predicted
+    - debian/patches/use_presage_prefix_path_in_default_profile.patch:
+      Use the PRESAGE_PREFIX_PATH environment variable in the default
+      profile
+    - debian/patches/add-missing-online-learning-configuration-value.patch:
+      Add missing ONLINE_LEARNING configuration value to defaultProfile
+    - debian/patches/add_presage_config_environment_variable.patch:
+      Replace use_presage_prefix_path_in_default_profile.patch with a new
+      patch making sure all works in snap environments
+    - Explicitly use python2 instead of python in the build.
+
+ -- Steve Langasek <steve.langasek@ubuntu.com>  Wed, 06 May 2020 14:01:16 -0700
+
 presage (0.9.1-2.2) unstable; urgency=medium
 
   [ Aron Xu ]
@@ -10,6 +45,65 @@ presage (0.9.1-2.2) unstable; urgency=me
 
  -- Aron Xu <aron@debian.org>  Sat, 25 Jan 2020 09:31:19 +0000
 
+presage (0.9.1-2.1ubuntu9) focal; urgency=medium
+
+  * No-change rebuild with fixed binutils on arm64.
+
+ -- Matthias Klose <doko@ubuntu.com>  Sat, 08 Feb 2020 11:17:25 +0000
+
+presage (0.9.1-2.1ubuntu8) focal; urgency=medium
+
+  * No-change rebuild to generate dependencies on python2.
+
+ -- Matthias Klose <doko@ubuntu.com>  Sat, 11 Jan 2020 18:56:52 +0000
+
+presage (0.9.1-2.1ubuntu7) focal; urgency=medium
+
+  * Explicitly use python2 instead of python in the build.
+
+ -- Matthias Klose <doko@ubuntu.com>  Thu, 09 Jan 2020 15:50:36 +0100
+
+presage (0.9.1-2.1ubuntu6) focal; urgency=medium
+
+  * No-change rebuild to drop dependencies on python2.
+
+ -- Matthias Klose <doko@ubuntu.com>  Thu, 09 Jan 2020 13:50:47 +0100
+
+presage (0.9.1-2.1ubuntu5) cosmic; urgency=medium
+
+  * No-change rebuild for ncurses soname changes.
+
+ -- Matthias Klose <doko@ubuntu.com>  Thu, 03 May 2018 14:18:10 +0000
+
+presage (0.9.1-2.1ubuntu4) zesty; urgency=medium
+
+  * debian/patches/add_presage_config_environment_variable.patch:
+    - Replace use_presage_prefix_path_in_default_profile.patch with a new patch
+      making sure all works in snap environments
+
+ -- Łukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com>  Thu, 08 Dec 2016 10:54:00 +0100
+
+presage (0.9.1-2.1ubuntu3) zesty; urgency=medium
+
+  [ Michael Sheldon ]
+  * debian/patches/use_presage_prefix_path_in_default_profile.patch:
+    - Use the PRESAGE_PREFIX_PATH environment variable in the default profile
+  * debian/patches/add-missing-online-learning-configuration-value.patch:
+    - Add missing ONLINE_LEARNING configuration value to defaultProfile
+
+ -- Łukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com>  Fri, 04 Nov 2016 18:05:23 +0100
+
+presage (0.9.1-2.1ubuntu1) yakkety; urgency=medium
+
+  * Merge with Debian; remaining changes:
+    - Remove python-wxgtk3.0 from Build-Depends
+    - debian/patches/ubuntu_dont_require_wxpython.patch: Do not check for wx
+      to enable pyprompter
+    - debian/patches/dont-tokenize-on-apostrophes.patch: Allow words with
+      apostrophes to be predicted
+
+ -- Matthias Klose <doko@ubuntu.com>  Tue, 06 Sep 2016 13:56:40 +0200
+
 presage (0.9.1-2.1) unstable; urgency=medium
 
   * Non-maintainer upload.
@@ -17,6 +111,17 @@ presage (0.9.1-2.1) unstable; urgency=me
 
  -- Aron Xu <aron@debian.org>  Sun, 03 Jul 2016 20:56:47 +0800
 
+presage (0.9.1-2ubuntu1) yakkety; urgency=medium
+
+  * Merge with Debian; remaining changes:
+    - Remove python-wxgtk3.0 from Build-Depends
+    - debian/patches/ubuntu_dont_require_wxpython.patch: Do not check for wx
+      to enable pyprompter
+    - debian/patches/dont-tokenize-on-apostrophes.patch: Allow words with
+      apostrophes to be predicted
+
+ -- Matthias Klose <doko@ubuntu.com>  Thu, 19 May 2016 15:17:23 +0200
+
 presage (0.9.1-2) unstable; urgency=medium
 
   * Depend on swig instead of swig2.0 (Closes: #816999)
@@ -28,6 +133,29 @@ presage (0.9.1-2) unstable; urgency=medi
 
  -- Matteo Vescovi <matteo.vescovi@yahoo.co.uk>  Thu, 17 Mar 2016 13:06:19 +0100
 
+presage (0.9.1-1.1ubuntu2) xenial; urgency=medium
+
+  * No-change rebuild for ncurses6 transition.
+
+ -- Matthias Klose <doko@ubuntu.com>  Sun, 07 Feb 2016 09:45:05 +0000
+
+presage (0.9.1-1.1ubuntu1) xenial; urgency=low
+
+  * Merge from Debian unstable.  Remaining changes:
+    - debian/patches/lib_underlinkage.patch: Added missing lib to link,
+      fixing FTBFS.
+    - Remove python-wxgtk3.0 from Build-Depends
+    - debian/patches/ubuntu_dont_require_wxpython.patch: Do not check for wx
+      to enable pyprompter
+    - debian/patches/dont-tokenize-on-apostrophes.patch: Allow words with
+      apostrophes to be predicted
+    - Build-depend on swig (3.0) instead of swig2.0.
+  * Dropped changes, included in Debian:
+    - Build using GCC 5.
+    - Update symbols file.
+
+ -- Steve Langasek <steve.langasek@ubuntu.com>  Sat, 31 Oct 2015 22:10:08 -0700
+
 presage (0.9.1-1.1) unstable; urgency=medium
 
   * Non-maintainer upload.
@@ -42,6 +170,52 @@ presage (0.9.1-1) unstable; urgency=medi
 
  -- Aron Xu <aron@debian.org>  Sat, 15 Aug 2015 23:44:45 +0800
 
+presage (0.9.1-0ubuntu3) xenial; urgency=medium
+
+  * Build-depend on swig (3.0) instead of swig2.0.
+
+ -- Steve Langasek <steve.langasek@ubuntu.com>  Fri, 30 Oct 2015 13:09:52 -0700
+
+presage (0.9.1-0ubuntu2) wily; urgency=medium
+
+  * Build using GCC 5.
+
+ -- Matthias Klose <doko@ubuntu.com>  Wed, 15 Jul 2015 20:21:30 +0200
+
+presage (0.9.1-0ubuntu1) wily; urgency=medium
+
+  * New upstream version.
+    - No test failures with GCC 5.
+  * Update symbols file.
+
+ -- Matthias Klose <doko@ubuntu.com>  Wed, 15 Jul 2015 20:09:44 +0200
+
+presage (0.9-1ubuntu3) vivid; urgency=medium
+
+  * Remove python-wxgtk3.0 from Build-Depends (LP: #1430923)
+  * debian/patches/ubuntu_dont_require_wxpython.patch:
+    - Do not check for wx to enable pyprompter
+
+ -- Aron Xu <happyaron@ubuntu.com>  Thu, 12 Mar 2015 00:38:45 +0800
+
+presage (0.9-1ubuntu2) vivid; urgency=medium
+
+  * debian/patches/dont-tokenize-on-apostrophes.patch:
+    - Allow words with apostrophes to be predicted (lp: #1384800)
+
+ -- Michael Sheldon <michael.sheldon@canonical.com>  Wed, 04 Feb 2015 10:16:01 +0100
+
+presage (0.9-1ubuntu1) vivid; urgency=low
+
+  * Merge from Debian unstable.  Remaining changes:
+    - debian/patches/lib_underlinkage.patch:
+      + Added missing lib to link, fixing FTBFS. (Closes: #776720)
+  * Drop following patches, fixed upstream:
+    - debian/patches/automake-parallel.patch
+    - debian/patches/no-automake-werror.patch
+
+ -- Artur Rona <ari-tczew@ubuntu.com>  Sat, 31 Jan 2015 20:19:30 +0100
+
 presage (0.9-1) unstable; urgency=medium
 
   * New upstream release.
@@ -70,6 +244,28 @@ presage (0.8.9-1) unstable; urgency=low
 
  -- Matteo Vescovi <matteo.vescovi@yahoo.co.uk>  Wed, 02 OCt 2013 18:23:01 +0100
 
+presage (0.8.8-1ubuntu3) trusty; urgency=medium
+
+  * Use dh-autoreconf to update libtool for ppc64el.
+  * Disable automake -Werror.
+  * Make shell based test script compatible with automakes (new) default
+    parallel test runner.
+
+ -- Dimitri John Ledkov <xnox@ubuntu.com>  Tue, 24 Dec 2013 17:28:18 +0000
+
+presage (0.8.8-1ubuntu2) trusty; urgency=low
+
+  * Convert libpresage1, libpresage1-dbg, libpresage-data, and
+    libpresage-dev binary packages to multiarch.
+
+ -- Colin Watson <cjwatson@ubuntu.com>  Thu, 07 Nov 2013 14:19:59 +0000
+
+presage (0.8.8-1ubuntu1) raring; urgency=low
+
+  * Added missing lib to link, fixing FTBFS.
+
+ -- Daniel T Chen <crimsun@ubuntu.com>  Thu, 18 Apr 2013 16:10:04 -0400
+
 presage (0.8.8-1) unstable; urgency=low
 
   * New upstream release.
diff -pruN 0.9.1-2.2/debian/control 0.9.1-2.2ubuntu3/debian/control
--- 0.9.1-2.2/debian/control	2020-01-25 09:31:19.000000000 +0000
+++ 0.9.1-2.2ubuntu3/debian/control	2022-08-30 15:56:09.000000000 +0000
@@ -1,7 +1,8 @@
 Source: presage
 Section: devel
 Priority: optional
-Maintainer: Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+XSBC-Original-Maintainer: Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
 Build-Depends: debhelper (>= 9~),
  autotools-dev,
  dh-autoreconf,
diff -pruN 0.9.1-2.2/debian/patches/add-missing-online-learning-configuration-value.patch 0.9.1-2.2ubuntu3/debian/patches/add-missing-online-learning-configuration-value.patch
--- 0.9.1-2.2/debian/patches/add-missing-online-learning-configuration-value.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.9.1-2.2ubuntu3/debian/patches/add-missing-online-learning-configuration-value.patch	2016-11-07 15:47:51.000000000 +0000
@@ -0,0 +1,29 @@
+Description: Add missing ONLINE_LEARNING configuration value to defaultProfile
+ Fixes a crash in libpresage when a configuration file isn't found.
+Author: Michael Sheldon <michael.sheldon@canonical.com>
+
+Bug: https://sourceforge.net/p/presage/patches/3/
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/presage/+bug/1639251
+Forwarded: https://sourceforge.net/p/presage/patches/3/
+Last-Update: 28/10/2016
+
+--- presage-0.9.1.orig/src/lib/core/defaultProfile.cpp
++++ presage-0.9.1/src/lib/core/defaultProfile.cpp
+@@ -62,7 +62,16 @@ void DefaultProfile::build_xml_document
+ "        <!-- LOWERCASE_MODE"
+ "          Instruct context tracker to track text as lowercase"
+ "        -->"
+-"         <LOWERCASE_MODE>yes</LOWERCASE_MODE>"
++"        <LOWERCASE_MODE>yes</LOWERCASE_MODE>"
++"        <!-- ONLINE_LEARNING"
++"          Controls presage online machine learning feature."
++"          Presage is context-aware and capable of dynamic online learning."
++"          Setting this to yes/true will enable online learning mode."
++"          Setting this to no/false will disable online learning mode."
++"          When online learning mode is disabled, it is still"
++"          possible to instruct presage to learn through its API."
++"        -->"
++"        <ONLINE_LEARNING>yes</ONLINE_LEARNING>"
+ "    </ContextTracker>"
+ "    <Selector>"
+ "        <LOGGER>ERROR</LOGGER>"
diff -pruN 0.9.1-2.2/debian/patches/add_presage_config_environment_variable.patch 0.9.1-2.2ubuntu3/debian/patches/add_presage_config_environment_variable.patch
--- 0.9.1-2.2/debian/patches/add_presage_config_environment_variable.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.9.1-2.2ubuntu3/debian/patches/add_presage_config_environment_variable.patch	2016-12-08 09:05:24.000000000 +0000
@@ -0,0 +1,32 @@
+Description: Add PRESAGE_CONFIG environment variable
+ Provide an environment variable for setting the location that presage should
+ check for its system-wide configuration file. This allows for usage within
+ snap packages.
+Author: Michael Sheldon <michael.sheldon@canonical.com>
+Forwarded: no
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/presage/+bug/1639270
+Last-Update: 2016-12-07
+
+--- presage-0.9.1.orig/src/lib/core/profileManager.cpp
++++ presage-0.9.1/src/lib/core/profileManager.cpp
+@@ -121,10 +121,16 @@ void ProfileManager::init_profiles (cons
+     }
+ 
+ 
+-    // system etc directory
+-    profiles.push_back (get_system_etc_dir() + '/' + DefaultProfile::DEFAULT_PROFILE_FILENAME);
+-    // installation config directory
+-    profiles.push_back (static_cast<std::string>(sysconfdir) + '/' + DefaultProfile::DEFAULT_PROFILE_FILENAME);
++    // config specified by environment overrides system config
++    char *env_profile = getenv("PRESAGE_CONFIG");
++    if (env_profile != NULL) {
++        profiles.push_back(env_profile);
++    } else {
++        // system etc directory
++        profiles.push_back (get_system_etc_dir() + '/' + DefaultProfile::DEFAULT_PROFILE_FILENAME);
++        // installation config directory
++        profiles.push_back (static_cast<std::string>(sysconfdir) + '/' + DefaultProfile::DEFAULT_PROFILE_FILENAME);
++    }
+     // home dir dotfile
+     profiles.push_back (get_user_home_dir() + "/.presage/" + DefaultProfile::DEFAULT_PROFILE_FILENAME);
+     // user specified profile (if any)
diff -pruN 0.9.1-2.2/debian/patches/c++17.patch 0.9.1-2.2ubuntu3/debian/patches/c++17.patch
--- 0.9.1-2.2/debian/patches/c++17.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.9.1-2.2ubuntu3/debian/patches/c++17.patch	2022-08-30 15:56:09.000000000 +0000
@@ -0,0 +1,239 @@
+Description: Port the code to C++17
+Author: Simon Chopin <schopin@ubuntu.com>
+Origin: ubuntu
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=984297
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/presage/+bug/1988196
+Last-Update: 2022-08-30
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/src/lib/presage.h
++++ b/src/lib/presage.h
+@@ -112,7 +112,7 @@
+      * 
+      * Presage does not take ownership of the callback object.
+      */
+-    Presage(PresageCallback* callback) throw (PresageException);
++    Presage(PresageCallback* callback) noexcept(false);
+ 
+ 
+     /** Creates and initializes presage with supplied configuration.
+@@ -122,7 +122,7 @@
+      *
+      * Presage does not take ownership of the callback object.
+      */
+-    Presage(PresageCallback* callback, const std::string config) throw (PresageException);
++    Presage(PresageCallback* callback, const std::string config) noexcept(false);
+ 
+ 
+     /** Destroys presage.
+@@ -138,7 +138,7 @@
+      * context.
+      *
+      */
+-    std::vector<std::string> predict() throw (PresageException);
++    std::vector<std::string> predict() noexcept(false);
+ 
+     /** \brief Obtain a prediction that matches the supplied token
+      *         filter.
+@@ -153,7 +153,7 @@
+      * of the filter tokens.
+      *
+      */
+-    std::multimap<double, std::string> predict(std::vector<std::string> filter) throw (PresageException);
++    std::multimap<double, std::string> predict(std::vector<std::string> filter) noexcept(false);
+ 
+     /** \brief Learn from text offline.
+      *
+@@ -167,7 +167,7 @@
+      * \param text a text string to learn from.
+      *
+      */
+-    void learn(const std::string text) const throw (PresageException);
++    void learn(const std::string text) const noexcept(false);
+ 
+     /** \brief Callback getter/setter.
+      *
+@@ -176,7 +176,7 @@
+      *
+      * \return pointer to previously used callback
+      */
+-    PresageCallback* callback(PresageCallback* callback) throw (PresageException);
++    PresageCallback* callback(PresageCallback* callback) noexcept(false);
+ 
+     /** \brief Request presage to return the completion string for the given predicted token.
+      *
+@@ -190,26 +190,26 @@
+      *
+      * \return completion string
+      */
+-    std::string completion(std::string str) throw (PresageException);
++    std::string completion(std::string str) noexcept(false);
+ 
+     /** \brief Returns the text entered so far.
+      *
+      * \return context, text entered so far.
+      */
+-    std::string context() const throw (PresageException);
++    std::string context() const noexcept(false);
+ 
+     /** \brief Returns true if a context change occured.
+      *
+      * \return true if a context change occured after the last update
+      * or predict calls, or false otherwise.
+      */
+-    bool context_change() const throw (PresageException);
++    bool context_change() const noexcept(false);
+ 
+     /** \brief Returns the current prefix.
+      *
+      * \return prefix
+      */
+-    std::string prefix() const throw (PresageException);
++    std::string prefix() const noexcept(false);
+ 
+     /** \brief Gets the value of specified configuration variable.
+      *
+@@ -218,7 +218,7 @@
+      *
+      * \return value assigned to configuration variable.
+      */
+-    std::string config(const std::string variable) const throw (PresageException);
++    std::string config(const std::string variable) const noexcept(false);
+ 
+     /** \brief Sets the value of specified configuration variable.
+      *
+@@ -227,7 +227,7 @@
+      * from the configuration file in use.
+      *
+      */
+-    void config(const std::string variable, const std::string value) const throw (PresageException);
++    void config(const std::string variable, const std::string value) const noexcept(false);
+ 
+     /** \brief Save current configuration to file.
+      *
+@@ -236,7 +236,7 @@
+      * active XML profile.
+      *
+      */
+-    void save_config() const throw (PresageException);
++    void save_config() const noexcept(false);
+ 
+     /*
+      * Presage public API ends here
+--- a/src/lib/presage.cpp
++++ b/src/lib/presage.cpp
+@@ -31,7 +31,7 @@
+ #include "core/predictorActivator.h"
+ 
+ Presage::Presage (PresageCallback* callback)
+-    throw (PresageException)
++    noexcept(false)
+ {
+     profileManager = new ProfileManager();
+     configuration = profileManager->get_configuration();
+@@ -42,7 +42,7 @@
+ }
+ 
+ Presage::Presage (PresageCallback* callback, const std::string config_filename)
+-    throw (PresageException)
++    noexcept(false)
+ {
+     profileManager = new ProfileManager(config_filename);
+     configuration = profileManager->get_configuration();
+@@ -62,7 +62,7 @@
+ }
+ 
+ std::vector<std::string> Presage::predict ()
+-    throw (PresageException)
++    noexcept(false)
+ {
+     std::vector<std::string> result;
+ 
+@@ -88,7 +88,7 @@
+ }
+ 
+ std::multimap<double, std::string> Presage::predict (std::vector<std::string> filter)
+-    throw (PresageException)
++    noexcept(false)
+ {
+     std::multimap<double, std::string> result;
+ 
+@@ -137,20 +137,20 @@
+ }
+ 
+ void Presage::learn(const std::string text) const
+-    throw (PresageException)
++    noexcept(false)
+ {
+     contextTracker->learn(text); // TODO: can pass additional param to
+ 				 // learn to specify offline learning
+ }
+ 
+ PresageCallback* Presage::callback (PresageCallback* callback)
+-    throw (PresageException)
++    noexcept(false)
+ {
+     return const_cast<PresageCallback*>(contextTracker->callback(callback));
+ }
+ 
+ std::string Presage::completion (const std::string str)
+-    throw (PresageException)
++    noexcept(false)
+ {
+     // There are two types of completions: normal and erasing.
+     // normal_completion  = prefix + remainder
+@@ -198,37 +198,37 @@
+ }
+ 
+ std::string Presage::context () const
+-    throw (PresageException)
++    noexcept(false)
+ {
+     return contextTracker->getPastStream();
+ }
+ 
+ bool Presage::context_change () const
+-    throw (PresageException)
++    noexcept(false)
+ {
+     return contextTracker->contextChange();
+ }
+ 
+ std::string Presage::prefix () const
+-    throw (PresageException)
++    noexcept(false)
+ {
+     return contextTracker->getPrefix();
+ }
+ 
+ std::string Presage::config (const std::string variable) const
+-    throw (PresageException)
++    noexcept(false)
+ {
+     return configuration->find (variable)->get_value ();
+ }
+ 
+ void Presage::config (const std::string variable, const std::string value) const
+-    throw (PresageException)
++    noexcept(false)
+ {
+     configuration->insert (variable, value);
+ }
+ 
+ void Presage::save_config () const
+-    throw (PresageException)
++    noexcept(false)
+ {
+     profileManager->save_profile ();
+ }
+--- presage-0.9.1.orig/apps/gtk/gprompter/scintilla/gtk/ScintillaGTK.cxx
++++ presage-0.9.1/apps/gtk/gprompter/scintilla/gtk/ScintillaGTK.cxx
+@@ -1626,7 +1626,7 @@ void ScintillaGTK::ReceivedDrop(GtkSelec
+ 		drop.push_back('\0');
+ 		NotifyURIDropped(&drop[0]);
+ 	} else if ((TypeOfGSD(selection_data) == GDK_TARGET_STRING) || (TypeOfGSD(selection_data) == atomUTF8)) {
+-		if (TypeOfGSD(selection_data) > 0) {
++		if (TypeOfGSD(selection_data)) {
+ 			SelectionText selText;
+ 			GetGtkSelectionText(selection_data, selText);
+ 			DropAt(posDrop, selText.Data(), selText.Length(), false, selText.rectangular);
diff -pruN 0.9.1-2.2/debian/patches/dont-tokenize-on-apostrophes.patch 0.9.1-2.2ubuntu3/debian/patches/dont-tokenize-on-apostrophes.patch
--- 0.9.1-2.2/debian/patches/dont-tokenize-on-apostrophes.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.9.1-2.2ubuntu3/debian/patches/dont-tokenize-on-apostrophes.patch	2016-09-06 11:56:40.000000000 +0000
@@ -0,0 +1,54 @@
+Description: Allow words with apostrophes to be predicted
+ Stop the tokenizer from splitting based on apostrophes and allow for the
+ escaping of words containing apostrophes in the database connector.
+Author: Michael Sheldon <michael.sheldon@canonical.com>
+Forwarded: https://sourceforge.net/p/presage/patches/2/
+Bug-Ubuntu: https://launchpad.net/bugs/1384800
+Bug-Debian: https://bugs.debian.org/770831
+
+--- presage-0.9.orig/src/lib/core/charsets.h
++++ presage-0.9/src/lib/core/charsets.h
+@@ -180,7 +180,6 @@ const char DEFAULT_SEPARATOR_CHARS[]={
+     '$',
+     '%',
+     '&',
+-    '\'',
+     '(',
+     ')',
+     '*',
+--- presage-0.9.orig/src/lib/predictors/dbconnector/databaseConnector.cpp
++++ presage-0.9/src/lib/predictors/dbconnector/databaseConnector.cpp
+@@ -293,12 +293,16 @@ std::string DatabaseConnector::buildValu
+ 
+ std::string DatabaseConnector::sanitizeString(const std::string str) const
+ {
+-    // TODO
+-    // just return the string for the time being
+-    // REVISIT
+-    // TO BE DONE
+-    // TBD
+-    return str;
++    // Escape single quotes
++    std::size_t searchPos = 0;
++    std::size_t pos;
++    std::string result(str);
++    while((pos = result.find("'", searchPos)) != std::string::npos)
++    {
++          result.replace(pos, 1, "''");
++          searchPos = pos + 2;
++    }
++    return result;
+ }
+ 
+ int DatabaseConnector::extractFirstInteger(const NgramTable& table) const
+--- presage-0.9.orig/src/tools/text2ngram.cpp
++++ presage-0.9/src/tools/text2ngram.cpp
+@@ -174,7 +174,7 @@ int main(int argc, char* argv[])
+ 	std::ifstream infile(argv[i]);
+ 	ForwardTokenizer tokenizer(infile,
+ 				   " \f\n\r\t\v",
+-				   "`~!@#$%^&*()_-+=\\|]}[{'\";:/?.>,<");
++				   "`~!@#$%^&*()_-+=\\|]}[{\";:/?.>,<");
+ 	tokenizer.lowercaseMode(lowercase);
+ 
+ 	// take care of first N-1 tokens
diff -pruN 0.9.1-2.2/debian/patches/format-security.patch 0.9.1-2.2ubuntu3/debian/patches/format-security.patch
--- 0.9.1-2.2/debian/patches/format-security.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.9.1-2.2ubuntu3/debian/patches/format-security.patch	2022-08-30 15:56:09.000000000 +0000
@@ -0,0 +1,52 @@
+Description: Fix insecure format strings in the demo code
+Author: Simon Chopin <schopin@ubuntu.com>
+Origin: ubuntu
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/presage/+bug/1988196
+Last-Update: 2022-08-30
+--- a/src/tools/presageDemo.cpp
++++ b/src/tools/presageDemo.cpp
+@@ -173,7 +173,7 @@
+ 	    // key corresponding to desired token. selecting
+ 	    // suggestion.
+ 	    std::string message = "Last selected word: " + words[c - KEY_F0 - 1];
+-	    mvprintw(LINES - 3, 0, message.c_str());
++	    mvprintw(LINES - 3, 0, "%s", message.c_str());
+             clrtoeol();
+ 	    move(LINES, COLS);
+ 
+@@ -213,7 +213,7 @@
+ {
+     wclear( win );
+     box( win, 0, 0 );
+-    mvwprintw( win, 1, 1, str.c_str() );
++    mvwprintw( win, 1, 1, "%s", str.c_str() );
+     wrefresh( win );
+ }
+ 
+@@ -226,7 +226,7 @@
+     int i = 1;
+     std::vector<std::string>::const_iterator j = words.begin();
+     while( j != words.end() ) {
+-	mvwprintw( win, i, 1, j->c_str() );
++	mvwprintw( win, i, 1, "%s", j->c_str() );
+ 	i++;
+ 	j++;
+     }
+@@ -241,7 +241,7 @@
+     for (int i = 1; i <= atoi(suggestions.c_str()); i++) {
+         std::stringstream ss;
+         ss << 'F' << i;
+-        mvwprintw(win, i, 1, ss.str().c_str());
++        mvwprintw(win, i, 1, "%s", ss.str().c_str());
+     }
+     wrefresh(win);
+ }
+@@ -291,7 +291,7 @@
+ 	     strit != listit->end();
+ 	     strit++) {
+ 	    
+-	    mvwprintw(win, line, 1, strit->c_str());
++	    mvwprintw(win, line, 1, "%s", strit->c_str());
+ 	    line++;
+ 	}
+ 
diff -pruN 0.9.1-2.2/debian/patches/python.diff 0.9.1-2.2ubuntu3/debian/patches/python.diff
--- 0.9.1-2.2/debian/patches/python.diff	1970-01-01 00:00:00.000000000 +0000
+++ 0.9.1-2.2ubuntu3/debian/patches/python.diff	2020-01-09 14:50:34.000000000 +0000
@@ -0,0 +1,24 @@
+--- a/apps/dbus/presage_dbus_python_demo.in
++++ b/apps/dbus/presage_dbus_python_demo.in
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python2
+ 
+ ##########
+ #  Presage, an extensible predictive text entry system
+--- a/apps/dbus/presage_dbus_service
++++ b/apps/dbus/presage_dbus_service
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python2
+ 
+ ##########
+ #  Presage, an extensible predictive text entry system
+--- a/apps/dbus/presage_dbus_service.py
++++ b/apps/dbus/presage_dbus_service.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python2
+ 
+ ##########
+ #  Presage, an extensible predictive text entry system
diff -pruN 0.9.1-2.2/debian/patches/series 0.9.1-2.2ubuntu3/debian/patches/series
--- 0.9.1-2.2/debian/patches/series	2016-07-03 12:56:39.000000000 +0000
+++ 0.9.1-2.2ubuntu3/debian/patches/series	2022-08-30 15:52:55.000000000 +0000
@@ -1,2 +1,9 @@
 fix-bug-776720.patch
+dont-tokenize-on-apostrophes.patch
 fix-bug-811758-gcc6.patch
+ubuntu_dont_require_wxpython.patch
+add_presage_config_environment_variable.patch
+add-missing-online-learning-configuration-value.patch
+python.diff
+c++17.patch
+format-security.patch
diff -pruN 0.9.1-2.2/debian/patches/ubuntu_dont_require_wxpython.patch 0.9.1-2.2ubuntu3/debian/patches/ubuntu_dont_require_wxpython.patch
--- 0.9.1-2.2/debian/patches/ubuntu_dont_require_wxpython.patch	1970-01-01 00:00:00.000000000 +0000
+++ 0.9.1-2.2ubuntu3/debian/patches/ubuntu_dont_require_wxpython.patch	2016-09-06 11:56:40.000000000 +0000
@@ -0,0 +1,49 @@
+From: Aron Xu <happyaron@ubuntu.com>
+Subject: Do not check for wx to enable pyprompter
+ Do not check for wx during configure time to enable
+ pyprompter without adding python-wxgtk3.0 to build
+ dependency, which is not wanted in main.
+Index: presage-0.9/configure.ac
+===================================================================
+--- presage-0.9.orig/configure.ac
++++ presage-0.9/configure.ac
+@@ -341,38 +341,7 @@ AM_CONDITIONAL([ENABLE_PYPRESAGEMATE], [
+ dnl =====================
+ dnl Checks for pyprompter
+ dnl =====================
+-if test "$PYTHON" != :
+-then
+-    AC_MSG_CHECKING(for python wx module)
+-    $PYTHON -c "import wx" 2&>/dev/null
+-    if test $? -eq 0;
+-    then
+-    	have_python_wx=yes
+-    else
+-    	have_python_wx=no
+-    fi
+-    AC_MSG_RESULT($have_python_wx)
+-    
+-    
+-    AC_MSG_CHECKING(for python wx.stc module)
+-    $PYTHON -c "import wx.stc" 2&>/dev/null
+-    if test $? -eq 0;
+-    then
+-    	have_python_wx_stc=yes
+-    else
+-    	have_python_wx_stc=no
+-    fi
+-    AC_MSG_RESULT($have_python_wx_stc)
+-fi
+-
+-if test "$PYTHON" != : -a \
+-	"x$have_python_wx" = "xyes" -a \
+-	"x$have_python_wx_stc" = "xyes"
+-then
+-	enable_pyprompter=yes
+-else
+-	enable_pyprompter=no
+-fi
++enable_pyprompter=yes
+ AM_CONDITIONAL([ENABLE_PYPROMPTER], [test "x$enable_pyprompter" = "xyes"])
+ 
+ 
