texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[5725] copy_converting anchor positions


From: Gavin D. Smith
Subject: [5725] copy_converting anchor positions
Date: Sun, 27 Jul 2014 17:05:14 +0000

Revision: 5725
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5725
Author:   gavin
Date:     2014-07-27 17:05:12 +0000 (Sun, 27 Jul 2014)
Log Message:
-----------
copy_converting anchor positions

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/Makefile.am
    trunk/info/info-utils.c

Added Paths:
-----------
    trunk/info/t/anchor-positions.sh
    trunk/info/t/infodir/anchor-positions.info

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-07-27 12:52:12 UTC (rev 5724)
+++ trunk/ChangeLog     2014-07-27 17:05:12 UTC (rev 5725)
@@ -9,6 +9,12 @@
        * info/t/search-skip-screen.sh: New test.
        * info/t/infodir/search.info: New file.
 
+       * info/info-utils.c (copy_input_to_output): Use < instead of <= to
+       avoid adjusting anchor just outside of range.  Check if a count of
+       bytes went negative by mistake.
+       * info/t/anchor-positions.sh: New test.
+       * info/t/infodir/anchor-positions.info: New file.
+
 2014-07-26  Gavin Smith  <address@hidden>
 
        * info/session.c (info_search_1): Unused 'key' argument removed.

Modified: trunk/info/Makefile.am
===================================================================
--- trunk/info/Makefile.am      2014-07-27 12:52:12 UTC (rev 5724)
+++ trunk/info/Makefile.am      2014-07-27 17:05:12 UTC (rev 5725)
@@ -119,6 +119,7 @@
        t/relative-reference.sh \
        t/resize-in-completions.sh \
        t/search-skip-screen.sh \
+       t/anchor-positions.sh \
        t/quoted-label-as-target.sh \
        t/quoted-target.sh \
        t/quoted-label-and-target.sh \

Modified: trunk/info/info-utils.c
===================================================================
--- trunk/info/info-utils.c     2014-07-27 12:52:12 UTC (rev 5724)
+++ trunk/info/info-utils.c     2014-07-27 17:05:12 UTC (rev 5725)
@@ -944,7 +944,7 @@
 {
   if (rewrite_p)
     {
-      size_t bytes_left;
+      long bytes_left;
 
       bytes_left = n;
       while (bytes_left > 0)
@@ -956,26 +956,34 @@
             }
           else
             {
-              size_t bytes_to_convert;
-              size_t extra_written;
+              long bytes_to_convert;
+              long extra_written;
 
+              bytes_to_convert = bytes_left;
+
               if (anchor_to_adjust)
                 {
                   char *first_anchor = input_start - node_offset
                                        + (*anchor_to_adjust)->nodestart;
 
                   /* If there is an anchor in the input: */
-                  if (first_anchor <= inptr + bytes_left)
-                    /* Convert enough to pass the first anchor in input. */
-                    bytes_to_convert = first_anchor - inptr + 1;
-                  else
-                    bytes_to_convert = bytes_left;
+                  if (first_anchor < inptr + bytes_left)
+                    {
+                      /* Convert enough to pass the first anchor in input. */
+                      bytes_to_convert = first_anchor - inptr + 1;
+
+                      /* Shouldn't happen because we should have already
+                         have adjusted this anchor. */
+                      if (bytes_to_convert < 0)
+                        {
+                          anchor_to_adjust = 0; /* Abandon anchor adjustment.*/
+                          bytes_to_convert = bytes_left;
+                        }
+                    }
                 }
-              else
-                bytes_to_convert = bytes_left;
 
               /* copy_converting may read more than bytes_to_convert
-                 bytes its input ends in an incomplete byte sequence. */
+                 bytes if its input ends in an incomplete byte sequence. */
               extra_written = copy_converting (bytes_to_convert);
 
               bytes_left -= bytes_to_convert + extra_written;

Added: trunk/info/t/anchor-positions.sh
===================================================================
--- trunk/info/t/anchor-positions.sh                            (rev 0)
+++ trunk/info/t/anchor-positions.sh    2014-07-27 17:05:12 UTC (rev 5725)
@@ -0,0 +1,29 @@
+#!/bin/sh
+# Copyright (C) 2014 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, 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, see <http://www.gnu.org/licenses/>.
+
+srcdir=${srcdir:-.}
+. $srcdir/t/Init-test.inc
+. $t/Init-inter.inc
+
+# Open a UTF-8 file with anchors in various positions.  Check that character
+# encoding conversion doesn't cause the program to freeze.
+export LANG=en_US.iso8859-1
+run_ginfo -f anchor-positions
+printf q >$PTY_TYPE
+
+. $t/Timeout-test.inc
+. $t/Cleanup.inc
+


Property changes on: trunk/info/t/anchor-positions.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/info/t/infodir/anchor-positions.info
===================================================================
(Binary files differ)


Property changes on: trunk/info/t/infodir/anchor-positions.info
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream




reply via email to

[Prev in Thread] Current Thread [Next in Thread]