gnucash-htdocs master: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Sat Apr 1 16:47:25 EDT 2023


Updated	 via  https://github.com/Gnucash/gnucash-htdocs/commit/94fa9dbc (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/d7d2b3a5 (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/6f89905b (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/87d04cf1 (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/ea30bcff (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/0218933c (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/bc83b225 (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/447252ac (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/18b4710f (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/0e233f6e (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/a58681da (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/69e187fa (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/a546d2d5 (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/19f2e396 (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/670289c6 (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/e8b7e895 (commit)
	 via  https://github.com/Gnucash/gnucash-htdocs/commit/8b93f2e3 (commit)
	from  https://github.com/Gnucash/gnucash-htdocs/commit/1538a4ab (commit)



commit 94fa9dbc2e111829dfd36f23c3c99c59d0d20712
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Apr 1 13:40:47 2023 -0700

    Rename gnucash-help to gnucash-manual for major-stable release.

diff --git a/docs.phtml b/docs.phtml
index 9c2ec58..de60426 100644
--- a/docs.phtml
+++ b/docs.phtml
@@ -68,44 +68,44 @@
             <td><?php echo T_("English");?> :</td><td>
               <a href="<?=$top_dir;?>/viewdoc.phtml?rev=<?=$major_stable;?>&lang=C&doc=help">
                 <img class="docicon" alt="online" title="<?php echo T_($online);?>" src="<?=$top_dir;?>/images/icons/online_logo.png" /></a> |
-              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/C/gnucash-help.pdf">
+              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/C/gnucash-manual.pdf">
                 <img class="docicon" alt="pdf" title="<?php echo T_($pdf);?>" src="<?=$top_dir;?>/images/icons/pdf_logo.png" /></a> |
-              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/C/gnucash-help.epub">
+              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/C/gnucash-manual.epub">
                 <img class="docicon" alt="epub" title="<?php echo T_($epub);?>" src="<?=$top_dir;?>/images/icons/epub_logo.png" /></a> |
-              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/C/gnucash-help.mobi">
+              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/C/gnucash-manual.mobi">
                 <img class="docicon" alt="mobi" title="<?php echo T_($mobi);?>" src="<?=$top_dir;?>/images/icons/mobipocket_logo.png" /></a>
             </td></tr>
             <tr class="doctr">
             <td><?php echo T_("German");?> :</td><td>
               <a href="<?=$top_dir;?>/viewdoc.phtml?rev=<?=$major_stable;?>&lang=de&doc=help">
                 <img class="docicon" alt="online" title="<?php echo T_($online);?>" src="<?=$top_dir;?>/images/icons/online_logo.png" /></a> |
-              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/de/gnucash-help.pdf">
+              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/de/gnucash-manual.pdf">
                 <img class="docicon" alt="pdf" title="<?php echo T_($pdf);?>" src="<?=$top_dir;?>/images/icons/pdf_logo.png" /></a> |
-              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/de/gnucash-help.epub">
+              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/de/gnucash-manual.epub">
                 <img class="docicon" alt="epub" title="<?php echo T_($epub);?>" src="<?=$top_dir;?>/images/icons/epub_logo.png" /></a> |
-              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/de/gnucash-help.mobi">
+              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/de/gnucash-manual.mobi">
                 <img class="docicon" alt="mobi" title="<?php echo T_($mobi);?>" src="<?=$top_dir;?>/images/icons/mobipocket_logo.png" /></a>
             </td></tr>
             <tr class="doctr">
             <td><?php echo T_("Italian");?> :</td><td>
               <a href="<?=$top_dir;?>/viewdoc.phtml?rev=<?=$major_stable;?>&lang=it_IT&doc=help">
                 <img class="docicon" alt="online" title="<?php echo T_($online);?>" src="<?=$top_dir;?>/images/icons/online_logo.png" /></a> |
-              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/it/gnucash-help.pdf">
+              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/it/gnucash-manual.pdf">
                 <img class="docicon" alt="pdf" title="<?php echo T_($pdf);?>" src="<?=$top_dir;?>/images/icons/pdf_logo.png" /></a> |
-              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/it/gnucash-help.epub">
+              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/it/gnucash-manual.epub">
                 <img class="docicon" alt="epub" title="<?php echo T_($epub);?>" src="<?=$top_dir;?>/images/icons/epub_logo.png" /></a> |
-              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/it/gnucash-help.mobi">
+              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/it/gnucash-manual.mobi">
                 <img class="docicon" alt="mobi" title="<?php echo T_($mobi);?>" src="<?=$top_dir;?>/images/icons/mobipocket_logo.png" /></a>
             </td></tr>
             <tr class="doctr">
             <td><?php echo T_("Portuguese");?> :</td><td>
               <a href="<?=$top_dir;?>/viewdoc.phtml?rev=<?=$major_stable;?>&lang=pt&doc=help">
                 <img class="docicon" alt="online" title="<?php echo T_($online);?>" src="<?=$top_dir;?>/images/icons/online_logo.png" /></a> |
-              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/pt/gnucash-help.pdf">
+              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/pt/gnucash-manual.pdf">
                 <img class="docicon" alt="pdf" title="<?php echo T_($pdf);?>" src="<?=$top_dir;?>/images/icons/pdf_logo.png" /></a> |
-              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/pt/gnucash-help.epub">
+              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/pt/gnucash-manual.epub">
                 <img class="docicon" alt="epub" title="<?php echo T_($epub);?>" src="<?=$top_dir;?>/images/icons/epub_logo.png" /></a> |
-              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/pt/gnucash-help.mobi">
+              <a href="<?=$top_dir;?>/docs/v<?=$major_stable;?>/pt/gnucash-manual.mobi">
                 <img class="docicon" alt="mobi" title="<?php echo T_($mobi);?>" src="<?=$top_dir;?>/images/icons/mobipocket_logo.png" /></a>
             </td></tr>
           </tbody>

commit d7d2b3a58e2526ddcc93c9fe24dc673bd3010c2b
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Apr 1 13:26:02 2023 -0700

    Revert "Protect against empty arrays/NULL array references in gettext.php."
    
    This reverts commit ca5cb31803b3918ee79af6979e05ce38b074c2a1.

diff --git a/externals/gettext.php b/externals/gettext.php
index 633df2b..d3826d8 100644
--- a/externals/gettext.php
+++ b/externals/gettext.php
@@ -139,18 +139,16 @@ class gettext_reader {
    */
   function load_tables() {
     if (is_array($this->cache_translations) &&
-        is_array($this->table_originals) &&
-        is_array($this->table_translations))
+      is_array($this->table_originals) &&
+      is_array($this->table_translations))
       return;
 
     /* get original and translations tables */
-      if ($this->table_originals &&
-          !is_array($this->table_originals)) {
+    if (!is_array($this->table_originals)) {
       $this->STREAM->seekto($this->originals);
       $this->table_originals = $this->readintarray($this->total * 2);
     }
-      if ($this->table_translations &&
-          !is_array($this->table_translations)) {
+    if (!is_array($this->table_translations)) {
       $this->STREAM->seekto($this->translations);
       $this->table_translations = $this->readintarray($this->total * 2);
     }

commit 6f89905b8a61070eef113fdb2b94ecb47da842fd
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Apr 1 13:25:29 2023 -0700

    Revert "Check intermediate level of indirection (table_originals) for NULL."
    
    This reverts commit cd0f1892ce5f981b9e126d63754a86b89cd5af33.

diff --git a/externals/gettext.php b/externals/gettext.php
index 4c937ea..633df2b 100644
--- a/externals/gettext.php
+++ b/externals/gettext.php
@@ -160,8 +160,7 @@ class gettext_reader {
       /* read all strings in the cache */
       for ($i = 0; $i < $this->total; $i++) {
           $offset = $i * 2 + 2;
-          if (!($this && $this->table_oritinals &&
-                $this->table_originals[$offset])) {
+          if (!($this && $this->table_originals[$offset])) {
               continue;
           }
           $this->STREAM->seekto($this->table_originals[$offset]);

commit 87d04cf116a791859307163a042150c59e6f279f
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Apr 1 13:06:02 2023 -0700

    Revert "Fix typos"
    
    This reverts commit 87f8dc1f7125488287c15e9462823707d1580dfc.

diff --git a/externals/gettext.php b/externals/gettext.php
index 5d61269..4c937ea 100644
--- a/externals/gettext.php
+++ b/externals/gettext.php
@@ -160,7 +160,7 @@ class gettext_reader {
       /* read all strings in the cache */
       for ($i = 0; $i < $this->total; $i++) {
           $offset = $i * 2 + 2;
-          if (!($this && $this->table_originals &&
+          if (!($this && $this->table_oritinals &&
                 $this->table_originals[$offset])) {
               continue;
           }
diff --git a/lang.php b/lang.php
index 3afdc92..8d4896d 100644
--- a/lang.php
+++ b/lang.php
@@ -66,7 +66,7 @@ if ($locale == "") {
     {
         # tolower() => remove space => '-' -> '_'
         # "fr-ch;q=0.3, en, zh-cn;q=0.7" => "fr_ch;q=0.3,en,zh_cn;q=0.7"
-        $accept_language = filter_input(INPUT_SERVER, 'HTTP_ACCEPT_LANGUAGE', FILTER_SANITIZE_STRING);
+        $accept_language = filter_input(INPUT_SERVER, 'HTTP_ACCEPT_LANGUAGE', FILTER_SANITZE_STRING);
         $languages = str_replace('-','_', str_replace(' ', '', strtolower($accept_language)));
         $languages = explode(",", $languages);
         foreach ($languages as $item)

commit ea30bcff4adf3311727b7ad00329d59652d01117
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Apr 1 13:04:46 2023 -0700

    Revert "Move primary test out of loop."
    
    This reverts commit 1538a4ab763247972e0151a82dd36e108a90082b.

diff --git a/externals/gettext.php b/externals/gettext.php
index b09d4a6..5d61269 100644
--- a/externals/gettext.php
+++ b/externals/gettext.php
@@ -19,7 +19,7 @@
    along with PHP-gettext; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
- */
+*/
 
 /**
  * Provides a simple gettext replacement that works independently from
@@ -34,396 +34,395 @@
  * that you don't want to keep in memory)
  */
 class gettext_reader {
-    //public:
-    var $error = 0; // public variable that holds error code (0 if no error)
-
-    //private:
-    var $BYTEORDER = 0;        // 0: low endian, 1: big endian
-    var $STREAM = NULL;
-    var $short_circuit = false;
-    var $enable_cache = false;
-    var $originals = NULL;      // offset of original table
-    var $translations = NULL;    // offset of translation table
-    var $pluralheader = NULL;    // cache header field for plural forms
-    var $total = 0;          // total string count
-    var $table_originals = NULL;  // table for original strings (offsets)
-    var $table_translations = NULL;  // table for translated strings (offsets)
-    var $cache_translations = NULL;  // original -> translation mapping
-
-
-    /* Methods */
-
-
-    /**
-     * Reads a 32bit Integer from the Stream
-     *
-     * @access private
-     * @return Integer from the Stream
-     */
-    function readint() {
-        if ($this->BYTEORDER == 0) {
-            // low endian
-            $input=unpack('V', $this->STREAM->read(4));
-            return array_shift($input);
-        } else {
-            // big endian
-            $input=unpack('N', $this->STREAM->read(4));
-            return array_shift($input);
-        }
+  //public:
+   var $error = 0; // public variable that holds error code (0 if no error)
+
+   //private:
+  var $BYTEORDER = 0;        // 0: low endian, 1: big endian
+  var $STREAM = NULL;
+  var $short_circuit = false;
+  var $enable_cache = false;
+  var $originals = NULL;      // offset of original table
+  var $translations = NULL;    // offset of translation table
+  var $pluralheader = NULL;    // cache header field for plural forms
+  var $total = 0;          // total string count
+  var $table_originals = NULL;  // table for original strings (offsets)
+  var $table_translations = NULL;  // table for translated strings (offsets)
+  var $cache_translations = NULL;  // original -> translation mapping
+
+
+  /* Methods */
+
+
+  /**
+   * Reads a 32bit Integer from the Stream
+   *
+   * @access private
+   * @return Integer from the Stream
+   */
+  function readint() {
+      if ($this->BYTEORDER == 0) {
+        // low endian
+        $input=unpack('V', $this->STREAM->read(4));
+        return array_shift($input);
+      } else {
+        // big endian
+        $input=unpack('N', $this->STREAM->read(4));
+        return array_shift($input);
+      }
     }
 
-    function read($bytes) {
-        return $this->STREAM->read($bytes);
+  function read($bytes) {
+    return $this->STREAM->read($bytes);
+  }
+
+  /**
+   * Reads an array of Integers from the Stream
+   *
+   * @param int count How many elements should be read
+   * @return Array of Integers
+   */
+  function readintarray($count) {
+    if ($this->BYTEORDER == 0) {
+        // low endian
+        return unpack('V'.$count, $this->STREAM->read(4 * $count));
+      } else {
+        // big endian
+        return unpack('N'.$count, $this->STREAM->read(4 * $count));
+      }
+  }
+
+  /**
+   * Constructor
+   *
+   * @param object Reader the StreamReader object
+   * @param boolean enable_cache Enable or disable caching of strings (default on)
+   */
+  function gettext_reader($Reader, $enable_cache = true) {
+    // If there isn't a StreamReader, turn on short circuit mode.
+    if (! $Reader || isset($Reader->error) ) {
+      $this->short_circuit = true;
+      return;
     }
 
-    /**
-     * Reads an array of Integers from the Stream
-     *
-     * @param int count How many elements should be read
-     * @return Array of Integers
-     */
-    function readintarray($count) {
-        if ($this->BYTEORDER == 0) {
-            // low endian
-            return unpack('V'.$count, $this->STREAM->read(4 * $count));
-        } else {
-            // big endian
-            return unpack('N'.$count, $this->STREAM->read(4 * $count));
-        }
+    // Caching can be turned off
+    $this->enable_cache = $enable_cache;
+
+    $MAGIC1 = "\x95\x04\x12\xde";
+    $MAGIC2 = "\xde\x12\x04\x95";
+
+    $this->STREAM = $Reader;
+    $magic = $this->read(4);
+    if ($magic == $MAGIC1) {
+      $this->BYTEORDER = 1;
+    } elseif ($magic == $MAGIC2) {
+      $this->BYTEORDER = 0;
+    } else {
+      $this->error = 1; // not MO file
+      return false;
     }
 
-    /**
-     * Constructor
-     *
-     * @param object Reader the StreamReader object
-     * @param boolean enable_cache Enable or disable caching of strings (default on)
-     */
-    function gettext_reader($Reader, $enable_cache = true) {
-        // If there isn't a StreamReader, turn on short circuit mode.
-        if (! $Reader || isset($Reader->error) ) {
-            $this->short_circuit = true;
-            return;
-        }
-
-        // Caching can be turned off
-        $this->enable_cache = $enable_cache;
-
-        $MAGIC1 = "\x95\x04\x12\xde";
-        $MAGIC2 = "\xde\x12\x04\x95";
-
-        $this->STREAM = $Reader;
-        $magic = $this->read(4);
-        if ($magic == $MAGIC1) {
-            $this->BYTEORDER = 1;
-        } elseif ($magic == $MAGIC2) {
-            $this->BYTEORDER = 0;
-        } else {
-            $this->error = 1; // not MO file
-            return false;
-        }
-
-        // FIXME: Do we care about revision? We should.
-        $revision = $this->readint();
-
-        $this->total = $this->readint();
-        $this->originals = $this->readint();
-        $this->translations = $this->readint();
+    // FIXME: Do we care about revision? We should.
+    $revision = $this->readint();
+
+    $this->total = $this->readint();
+    $this->originals = $this->readint();
+    $this->translations = $this->readint();
+  }
+
+  /**
+   * Loads the translation tables from the MO file into the cache
+   * If caching is enabled, also loads all strings into a cache
+   * to speed up translation lookups
+   *
+   * @access private
+   */
+  function load_tables() {
+    if (is_array($this->cache_translations) &&
+        is_array($this->table_originals) &&
+        is_array($this->table_translations))
+      return;
+
+    /* get original and translations tables */
+      if ($this->table_originals &&
+          !is_array($this->table_originals)) {
+      $this->STREAM->seekto($this->originals);
+      $this->table_originals = $this->readintarray($this->total * 2);
     }
-
-    /**
-     * Loads the translation tables from the MO file into the cache
-     * If caching is enabled, also loads all strings into a cache
-     * to speed up translation lookups
-     *
-     * @access private
-     */
-    function load_tables() {
-        if (is_array($this->cache_translations) &&
-            is_array($this->table_originals) &&
-            is_array($this->table_translations))
-        return;
-
-        /* get original and translations tables */
-        if ($this->table_originals &&
-            !is_array($this->table_originals)) {
-            $this->STREAM->seekto($this->originals);
-            $this->table_originals = $this->readintarray($this->total * 2);
-        }
-        if ($this->table_translations &&
-            !is_array($this->table_translations)) {
-            $this->STREAM->seekto($this->translations);
-            $this->table_translations = $this->readintarray($this->total * 2);
-        }
-
-        if ($this->enable_cache) {
-            $this->cache_translations = array ();
-            /* read all strings in the cache */
-            if ($this && $this->table_originals) {
-                for ($i = 0; $i < $this->total; $i++) {
-                    $offset = $i * 2 + 2;
-                    if (!$this->table_originals[$offset]) {
-                        continue;
-                    }
-                    $this->STREAM->seekto($this->table_originals[$offset]);
-                    $original = $this->STREAM->read($this->table_originals[$offset - 1]);
-                    $this->STREAM->seekto($this->table_translations[$offset]);
-                    $translation = $this->STREAM->read($this->table_translations[$offset - 1]);
-                    $this->cache_translations[$original] = $translation;
-                }
-            }
-        }
+      if ($this->table_translations &&
+          !is_array($this->table_translations)) {
+      $this->STREAM->seekto($this->translations);
+      $this->table_translations = $this->readintarray($this->total * 2);
     }
 
-    /**
-     * Returns a string from the "originals" table
-     *
-     * @access private
-     * @param int num Offset number of original string
-     * @return string Requested string if found, otherwise ''
-     */
-    function get_original_string($num) {
-        $length = $this->table_originals[$num * 2 + 1];
-        $offset = $this->table_originals[$num * 2 + 2];
-        if (! $length)
-            return '';
-        $this->STREAM->seekto($offset);
-        $data = $this->STREAM->read($length);
-        return (string)$data;
+    if ($this->enable_cache) {
+      $this->cache_translations = array ();
+      /* read all strings in the cache */
+      for ($i = 0; $i < $this->total; $i++) {
+          $offset = $i * 2 + 2;
+          if (!($this && $this->table_originals &&
+                $this->table_originals[$offset])) {
+              continue;
+          }
+          $this->STREAM->seekto($this->table_originals[$offset]);
+          $original = $this->STREAM->read($this->table_originals[$offset - 1]);
+          $this->STREAM->seekto($this->table_translations[$offset]);
+          $translation = $this->STREAM->read($this->table_translations[$offset - 1]);
+          $this->cache_translations[$original] = $translation;
+      }
     }
-
-    /**
-     * Returns a string from the "translations" table
-     *
-     * @access private
-     * @param int num Offset number of original string
-     * @return string Requested string if found, otherwise ''
-     */
-    function get_translation_string($num) {
-        $length = $this->table_translations[$num * 2 + 1];
-        $offset = $this->table_translations[$num * 2 + 2];
-        if (! $length)
-            return '';
-        $this->STREAM->seekto($offset);
-        $data = $this->STREAM->read($length);
-        return (string)$data;
+  }
+
+  /**
+   * Returns a string from the "originals" table
+   *
+   * @access private
+   * @param int num Offset number of original string
+   * @return string Requested string if found, otherwise ''
+   */
+  function get_original_string($num) {
+    $length = $this->table_originals[$num * 2 + 1];
+    $offset = $this->table_originals[$num * 2 + 2];
+    if (! $length)
+      return '';
+    $this->STREAM->seekto($offset);
+    $data = $this->STREAM->read($length);
+    return (string)$data;
+  }
+
+  /**
+   * Returns a string from the "translations" table
+   *
+   * @access private
+   * @param int num Offset number of original string
+   * @return string Requested string if found, otherwise ''
+   */
+  function get_translation_string($num) {
+    $length = $this->table_translations[$num * 2 + 1];
+    $offset = $this->table_translations[$num * 2 + 2];
+    if (! $length)
+      return '';
+    $this->STREAM->seekto($offset);
+    $data = $this->STREAM->read($length);
+    return (string)$data;
+  }
+
+  /**
+   * Binary search for string
+   *
+   * @access private
+   * @param string string
+   * @param int start (internally used in recursive function)
+   * @param int end (internally used in recursive function)
+   * @return int string number (offset in originals table)
+   */
+  function find_string($string, $start = -1, $end = -1) {
+    if (($start == -1) or ($end == -1)) {
+      // find_string is called with only one parameter, set start end end
+      $start = 0;
+      $end = $this->total;
     }
-
-    /**
-     * Binary search for string
-     *
-     * @access private
-     * @param string string
-     * @param int start (internally used in recursive function)
-     * @param int end (internally used in recursive function)
-     * @return int string number (offset in originals table)
-     */
-    function find_string($string, $start = -1, $end = -1) {
-        if (($start == -1) or ($end == -1)) {
-            // find_string is called with only one parameter, set start end end
-            $start = 0;
-            $end = $this->total;
-        }
-        if (abs($start - $end) <= 1) {
-            // We're done, now we either found the string, or it doesn't exist
-            $txt = $this->get_original_string($start);
-            if ($string == $txt)
-                return $start;
-            else
-                return -1;
-        } else if ($start > $end) {
-            // start > end -> turn around and start over
-            return $this->find_string($string, $end, $start);
-        } else {
-            // Divide table in two parts
-            $half = (int)(($start + $end) / 2);
-            $cmp = strcmp($string, $this->get_original_string($half));
-            if ($cmp == 0)
-                // string is exactly in the middle => return it
-                return $half;
-            else if ($cmp < 0)
-                // The string is in the upper half
-                return $this->find_string($string, $start, $half);
-            else
-                // The string is in the lower half
-                return $this->find_string($string, $half, $end);
-        }
+    if (abs($start - $end) <= 1) {
+      // We're done, now we either found the string, or it doesn't exist
+      $txt = $this->get_original_string($start);
+      if ($string == $txt)
+        return $start;
+      else
+        return -1;
+    } else if ($start > $end) {
+      // start > end -> turn around and start over
+      return $this->find_string($string, $end, $start);
+    } else {
+      // Divide table in two parts
+      $half = (int)(($start + $end) / 2);
+      $cmp = strcmp($string, $this->get_original_string($half));
+      if ($cmp == 0)
+        // string is exactly in the middle => return it
+        return $half;
+      else if ($cmp < 0)
+        // The string is in the upper half
+        return $this->find_string($string, $start, $half);
+      else
+        // The string is in the lower half
+        return $this->find_string($string, $half, $end);
     }
-
-    /**
-     * Translates a string
-     *
-     * @access public
-     * @param string string to be translated
-     * @return string translated string (or original, if not found)
-     */
-    function translate($string) {
-        if ($this->short_circuit)
-            return $string;
-        $this->load_tables();
-
-        if ($this->enable_cache) {
-            // Caching enabled, get translated string from cache
-            if (array_key_exists($string, $this->cache_translations))
-                return $this->cache_translations[$string];
-            else
-                return $string;
-        } else {
-            // Caching not enabled, try to find string
-            $num = $this->find_string($string);
-            if ($num == -1)
-                return $string;
-            else
-                return $this->get_translation_string($num);
-        }
+  }
+
+  /**
+   * Translates a string
+   *
+   * @access public
+   * @param string string to be translated
+   * @return string translated string (or original, if not found)
+   */
+  function translate($string) {
+    if ($this->short_circuit)
+      return $string;
+    $this->load_tables();
+
+    if ($this->enable_cache) {
+      // Caching enabled, get translated string from cache
+      if (array_key_exists($string, $this->cache_translations))
+        return $this->cache_translations[$string];
+      else
+        return $string;
+    } else {
+      // Caching not enabled, try to find string
+      $num = $this->find_string($string);
+      if ($num == -1)
+        return $string;
+      else
+        return $this->get_translation_string($num);
     }
-
-    /**
-     * Sanitize plural form expression for use in PHP eval call.
-     *
-     * @access private
-     * @return string sanitized plural form expression
-     */
-    function sanitize_plural_expression($expr) {
-        // Get rid of disallowed characters.
-        $expr = preg_replace('@[^a-zA-Z0-9_:;\(\)\?\|\&=!<>+*/\%-]@', '', $expr);
-
-        // Add parenthesis for tertiary '?' operator.
-        $expr .= ';';
-        $res = '';
+  }
+
+  /**
+   * Sanitize plural form expression for use in PHP eval call.
+   *
+   * @access private
+   * @return string sanitized plural form expression
+   */
+  function sanitize_plural_expression($expr) {
+    // Get rid of disallowed characters.
+    $expr = preg_replace('@[^a-zA-Z0-9_:;\(\)\?\|\&=!<>+*/\%-]@', '', $expr);
+
+    // Add parenthesis for tertiary '?' operator.
+    $expr .= ';';
+    $res = '';
+    $p = 0;
+    for ($i = 0; $i < strlen($expr); $i++) {
+      $ch = $expr[$i];
+      switch ($ch) {
+      case '?':
+        $res .= ' ? (';
+        $p++;
+        break;
+      case ':':
+        $res .= ') : (';
+        break;
+      case ';':
+        $res .= str_repeat( ')', $p) . ';';
         $p = 0;
-        for ($i = 0; $i < strlen($expr); $i++) {
-            $ch = $expr[$i];
-            switch ($ch) {
-                case '?':
-                    $res .= ' ? (';
-                    $p++;
-                    break;
-                case ':':
-                    $res .= ') : (';
-                    break;
-                case ';':
-                    $res .= str_repeat( ')', $p) . ';';
-                    $p = 0;
-                    break;
-                default:
-                    $res .= $ch;
-            }
-        }
-        return $res;
+        break;
+      default:
+        $res .= $ch;
+      }
     }
-
-    /**
-     * Parse full PO header and extract only plural forms line.
-     *
-     * @access private
-     * @return string verbatim plural form header field
-     */
-    function extract_plural_forms_header_from_po_header($header) {
-        if (preg_match("/(^|\n)plural-forms: ([^\n]*)\n/i", $header, $regs))
-            $expr = $regs[2];
-        else
-            $expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
-        return $expr;
-    }
-
-    /**
-     * Get possible plural forms from MO header
-     *
-     * @access private
-     * @return string plural form header
-     */
-    function get_plural_forms() {
-        // lets assume message number 0 is header
-        // this is true, right?
-        $this->load_tables();
-
-        // cache header field for plural forms
-        if (! is_string($this->pluralheader)) {
-            if ($this->enable_cache) {
-                $header = $this->cache_translations[""];
-            } else {
-                $header = $this->get_translation_string(0);
-            }
-            $expr = $this->extract_plural_forms_header_from_po_header($header);
-            $this->pluralheader = $this->sanitize_plural_expression($expr);
-        }
-        return $this->pluralheader;
+    return $res;
+  }
+
+  /**
+   * Parse full PO header and extract only plural forms line.
+   *
+   * @access private
+   * @return string verbatim plural form header field
+   */
+  function extract_plural_forms_header_from_po_header($header) {
+    if (preg_match("/(^|\n)plural-forms: ([^\n]*)\n/i", $header, $regs))
+      $expr = $regs[2];
+    else
+      $expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
+    return $expr;
+  }
+
+  /**
+   * Get possible plural forms from MO header
+   *
+   * @access private
+   * @return string plural form header
+   */
+  function get_plural_forms() {
+    // lets assume message number 0 is header
+    // this is true, right?
+    $this->load_tables();
+
+    // cache header field for plural forms
+    if (! is_string($this->pluralheader)) {
+      if ($this->enable_cache) {
+        $header = $this->cache_translations[""];
+      } else {
+        $header = $this->get_translation_string(0);
+      }
+      $expr = $this->extract_plural_forms_header_from_po_header($header);
+      $this->pluralheader = $this->sanitize_plural_expression($expr);
     }
-
-    /**
-     * Detects which plural form to take
-     *
-     * @access private
-     * @param n count
-     * @return int array index of the right plural form
-     */
-    function select_string($n) {
-        $string = $this->get_plural_forms();
-        $string = str_replace('nplurals',"\$total",$string);
-        $string = str_replace("n",$n,$string);
-        $string = str_replace('plural',"\$plural",$string);
-
-        $total = 0;
-        $plural = 0;
-
-        eval("$string");
-        if ($plural >= $total) $plural = $total - 1;
+    return $this->pluralheader;
+  }
+
+  /**
+   * Detects which plural form to take
+   *
+   * @access private
+   * @param n count
+   * @return int array index of the right plural form
+   */
+  function select_string($n) {
+    $string = $this->get_plural_forms();
+    $string = str_replace('nplurals',"\$total",$string);
+    $string = str_replace("n",$n,$string);
+    $string = str_replace('plural',"\$plural",$string);
+
+    $total = 0;
+    $plural = 0;
+
+    eval("$string");
+    if ($plural >= $total) $plural = $total - 1;
+    return $plural;
+  }
+
+  /**
+   * Plural version of gettext
+   *
+   * @access public
+   * @param string single
+   * @param string plural
+   * @param string number
+   * @return translated plural form
+   */
+  function ngettext($single, $plural, $number) {
+    if ($this->short_circuit) {
+      if ($number != 1)
         return $plural;
+      else
+        return $single;
     }
 
-    /**
-     * Plural version of gettext
-     *
-     * @access public
-     * @param string single
-     * @param string plural
-     * @param string number
-     * @return translated plural form
-     */
-    function ngettext($single, $plural, $number) {
-        if ($this->short_circuit) {
-            if ($number != 1)
-                return $plural;
-            else
-                return $single;
-        }
-
-        // find out the appropriate form
-        $select = $this->select_string($number);
-
-        // this should contains all strings separated by NULLs
-        $key = $single . chr(0) . $plural;
-
-
-        if ($this->enable_cache) {
-            if (! array_key_exists($key, $this->cache_translations)) {
-                return ($number != 1) ? $plural : $single;
-            } else {
-                $result = $this->cache_translations[$key];
-                $list = explode(chr(0), $result);
-                return $list[$select];
-            }
-        } else {
-            $num = $this->find_string($key);
-            if ($num == -1) {
-                return ($number != 1) ? $plural : $single;
-            } else {
-                $result = $this->get_translation_string($num);
-                $list = explode(chr(0), $result);
-                return $list[$select];
-            }
-        }
+    // find out the appropriate form
+    $select = $this->select_string($number);
+
+    // this should contains all strings separated by NULLs
+    $key = $single . chr(0) . $plural;
+
+
+    if ($this->enable_cache) {
+      if (! array_key_exists($key, $this->cache_translations)) {
+        return ($number != 1) ? $plural : $single;
+      } else {
+        $result = $this->cache_translations[$key];
+        $list = explode(chr(0), $result);
+        return $list[$select];
+      }
+    } else {
+      $num = $this->find_string($key);
+      if ($num == -1) {
+        return ($number != 1) ? $plural : $single;
+      } else {
+        $result = $this->get_translation_string($num);
+        $list = explode(chr(0), $result);
+        return $list[$select];
+      }
     }
+  }
 
-    function pgettext($context, $msgid) {
-        $key = $context . chr(4) . $msgid;
-        return $this->translate($key);
-    }
+  function pgettext($context, $msgid) {
+    $key = $context . chr(4) . $msgid;
+    return $this->translate($key);
+  }
 
-    function npgettext($context, $singular, $plural, $number) {
-        $singular = $context . chr(4) . $singular;
-        return $this->ngettext($singular, $plural, $number);
-    }
+  function npgettext($context, $singular, $plural, $number) {
+    $singular = $context . chr(4) . $singular;
+    return $this->ngettext($singular, $plural, $number);
+  }
 }
 
 ?>

commit 0218933cbf7bba3d80bea828152e2281a66d398d
Merge: bc83b22 1538a4a
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Apr 1 12:46:54 2023 -0700

    Merge branch 'master' into beta


commit bc83b22506b658a0736c93d08b6b5a68e7f0dfc5
Merge: 447252a 9dae219
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Mar 28 15:18:33 2023 -0700

    Merge branch 'master' into beta


commit 447252ac8a52532ce0b4ab46a46ac2dd28c55ec3
Merge: 18b4710 3f15f0c
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun Mar 26 14:07:58 2023 -0700

    Merge branch 'master' into beta


commit 18b4710f39f864a73305de94ba38f0ebed87406b
Merge: 0e233f6 e575354
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Mar 25 10:13:57 2023 -0700

    Merge branch 'master' into beta


commit 0e233f6ef1610b2a2957a65b8d54b757f204fcb5
Merge: a58681d 10c182d
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun Mar 19 13:42:40 2023 -0700

    Merge branch 'master' into beta


commit a58681da25166d59b6c5f942ebb11a66ad07c729
Merge: 69e187f 3307329
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun Feb 19 15:26:12 2023 -0800

    Merge branch 'master' into beta


commit 69e187fa02fcfc3222115fd07658ab9f069cb5bf
Merge: a546d2d 3c2c3a7
Author: Frank H. Ellenberger <frank.h.ellenberger at gmail.com>
Date:   Sun Jan 22 11:48:46 2023 +0100

    Merge branch 'master' into beta


commit a546d2d598a16ffb17c3ca879cfd45583cb94f0a
Merge: 19f2e39 ca5cb31
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu Jan 12 13:56:11 2023 -0800

    Merge branch 'master' into beta


commit 19f2e396b094a590d9750e91997cd6e8d942852d
Merge: 670289c 4c96975
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Jan 10 14:15:55 2023 -0800

    Merge branch 'master' into beta


commit 670289c6cd78c85091e0becc8cc6be2237a9abef
Merge: e8b7e89 a656187
Author: Frank H. Ellenberger <frank.h.ellenberger at gmail.com>
Date:   Thu Sep 1 00:24:34 2022 +0200

    Merge branch 'master' into beta


commit e8b7e895043514a97ae254ef4fd5346019767c9e
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Mon Aug 22 19:03:46 2022 +0200

    Use gnucash-manual for newer documentation releases
    
    This should be done starting from gnucash 5.x (currently unreleased)

diff --git a/viewdoc.phtml b/viewdoc.phtml
index da2b093..efed74e 100644
--- a/viewdoc.phtml
+++ b/viewdoc.phtml
@@ -13,7 +13,7 @@ include("externals/menu.phtml");
 
 # Some base parameters used later on
 $basepath       = \DEFAULT_URL."docs";
-$helpdoc        = "gnucash-help/index.html";
+$helpdoc        = "gnucash-manual/index.html";
 $tcdoc          = "gnucash-guide/index.html";
 $current_stable = $major_stable;
 
@@ -71,7 +71,7 @@ if ($rev_to_show) {
             break;
     }
 
-    # Adjust name of gnucash-help start page for older versions
+    # Adjust name of gnucash-manual start page for older versions
     switch ($rev_to_show) {
         case "1.8":
         case "2.0":

commit 8b93f2e39d7275ee1bb846e35b00540b5c62f3ca
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Sat Aug 13 15:44:28 2022 +0200

    Adjust help document loading to accomodate ghelp2help changes in gnucash-docs
    
    The issue to deal with is that the help manual's main page gets renamed from help.html to index.html.
    But only for documentation from gnucash 5 and up.
    To handle this, delay document selection until after version selection.
    Use the version selection to set the proper name for the main page.

diff --git a/viewdoc.phtml b/viewdoc.phtml
index c37bca0..da2b093 100644
--- a/viewdoc.phtml
+++ b/viewdoc.phtml
@@ -13,7 +13,7 @@ include("externals/menu.phtml");
 
 # Some base parameters used later on
 $basepath       = \DEFAULT_URL."docs";
-$helpdoc        = "gnucash-help/help.html";
+$helpdoc        = "gnucash-help/index.html";
 $tcdoc          = "gnucash-guide/index.html";
 $current_stable = $major_stable;
 
@@ -32,23 +32,6 @@ if (in_array($get_lang, $doc_languages, true)) {
     $showlang = $locale;
 }
 
-
-# Parse requested document
-$doc_to_show = filter_input(INPUT_GET, 'doc', FILTER_SANITIZE_STRING);
-if ($doc_to_show) {
-    switch ($doc_to_show) {
-        case "help":
-            $showdoc = $helpdoc;
-            break;
-        case "guide":
-            $showdoc = $tcdoc;
-            break;
-        default:  /* unknown document requested, will present guide by default */
-            $req_doc_ok = false;
-            break;
-    }
-}
-
 # Parse requested version
 $rev_to_show = filter_input(INPUT_GET, 'rev', FILTER_SANITIZE_STRING);
 if ($rev_to_show) {
@@ -87,6 +70,40 @@ if ($rev_to_show) {
             $req_rev_ok = false;
             break;
     }
+
+    # Adjust name of gnucash-help start page for older versions
+    switch ($rev_to_show) {
+        case "1.8":
+        case "2.0":
+        case "2.2":
+        case "2.4":
+        case "2.6":
+        case "3":
+        case "4":
+        # Once gnucash 5 is out, the three cases below should be removed from the switch statement
+        case "current":
+        case "maint":
+        case "nightly":
+            $helpdoc = "gnucash-help/help.html";
+            break;
+    }
+}
+
+
+# Parse requested document
+$doc_to_show = filter_input(INPUT_GET, 'doc', FILTER_SANITIZE_STRING);
+if ($doc_to_show) {
+    switch ($doc_to_show) {
+        case "help":
+            $showdoc = $helpdoc;
+            break;
+        case "guide":
+            $showdoc = $tcdoc;
+            break;
+        default:  /* unknown document requested, will present guide by default */
+            $req_doc_ok = false;
+            break;
+    }
 }
 # Now check if the requested combination of doc, revision and language actually exists
 # If not, try the default C locale instead.



Summary of changes:
 docs.phtml            |  24 +-
 externals/gettext.php | 734 +++++++++++++++++++++++++-------------------------
 lang.php              |   2 +-
 3 files changed, 378 insertions(+), 382 deletions(-)



More information about the gnucash-changes mailing list