[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6711] fix anchor positions for nodeline variable
From: |
Gavin D. Smith |
Subject: |
[6711] fix anchor positions for nodeline variable |
Date: |
Mon, 19 Oct 2015 18:17:23 +0000 |
Revision: 6711
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6711
Author: gavin
Date: 2015-10-19 18:17:21 +0000 (Mon, 19 Oct 2015)
Log Message:
-----------
fix anchor positions for nodeline variable
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/info-utils.c
trunk/info/nodes.c
trunk/info/nodes.h
trunk/info/search.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2015-10-17 19:53:30 UTC (rev 6710)
+++ trunk/ChangeLog 2015-10-19 18:17:21 UTC (rev 6711)
@@ -1,3 +1,18 @@
+2015-10-19 Gavin Smith <address@hidden>
+
+ * info/info-utils.c (parse_top_node_line): Adjust
+ output_bytes_difference and node_offset according to how much of
+ the nodeline was printed.
+ (scan_node_contents) <not rewriting node>: Adjust anchors with
+ output_bytes_difference.
+ (scan_reference_marker): Avoid referring to output_bytes_difference.
+ (copy_input_to_output): Formatting change.
+
+ * info/nodes.h (NODE): Change type of 'display_pos' to signed.
+ * info/nodes.c (info_node_of_tag): Check if the anchor position
+ we ended up has gone negative, and if so, set it to 0.
+ * info/search.c (skip_node_separator): Comment changed.
+
2015-10-17 Gavin Smith <address@hidden>
* doc/info.texi: Remove file, as it is distributed with Emacs.
Modified: trunk/info/info-utils.c
===================================================================
--- trunk/info/info-utils.c 2015-10-17 19:53:30 UTC (rev 6710)
+++ trunk/info/info-utils.c 2015-10-19 18:17:21 UTC (rev 6711)
@@ -607,10 +607,12 @@
a result of byte counts changing due to character encoding conversion or
inserted/deleted text. */
static TAG **anchor_to_adjust;
-static int node_offset; /* Offset within file buffer of first byte of node. */
+/* Offset within file buffer of first byte of node, used for anchor
+ adjustment. */
+static int node_offset;
-/* Difference between the number of bytes input in the file and
- bytes output. If !rewrite_p, this should stay 0. */
+/* Difference so far between the number of bytes input in the file and
+ bytes output. Used to adjust the values of anchors in nodes. */
static long int output_bytes_difference;
/* Whether we are converting the character encoding of the file. */
@@ -970,8 +972,8 @@
if (anchor_to_adjust)
{
- char *first_anchor = input_start - node_offset
- + (*anchor_to_adjust)->nodestart;
+ char *first_anchor = input_start
+ + (*anchor_to_adjust)->nodestart - node_offset;
/* If there is an anchor in the input: */
if (first_anchor < inptr + bytes_left)
@@ -1172,11 +1174,15 @@
}
if (display_start)
{
+ output_bytes_difference = display_start - node->contents;
+ node_offset += output_bytes_difference;
node->nodelen -= display_start - node->contents;
node->contents = display_start;
}
else if (nodeline_print == NO_NODELINE)
{
+ output_bytes_difference = ptr - node->contents;
+ node_offset += output_bytes_difference;
node->nodelen -= ptr - node->contents;
node->contents = ptr;
}
@@ -1191,7 +1197,12 @@
/* When preprocess_nodes is Off, we position the cursor on
the "*" when moving between references. */
if (!preprocess_nodes_p)
- entry->start = inptr - input_start - output_bytes_difference;
+ {
+ if (rewrite_p)
+ entry->start = text_buffer_off(&output_buf);
+ else
+ entry->start = inptr - input_start;
+ }
/* Check what we found based on first character of match */
if (inptr[0] == '\n')
@@ -1743,7 +1754,8 @@
tag_ptr++;
while (*tag_ptr && (*tag_ptr)->cache.nodelen == 0)
{
- (*tag_ptr)->nodestart_adjusted = (*tag_ptr)->nodestart;
+ (*tag_ptr)->nodestart_adjusted = (*tag_ptr)->nodestart
+ - output_bytes_difference;
tag_ptr++;
}
}
Modified: trunk/info/nodes.c
===================================================================
--- trunk/info/nodes.c 2015-10-17 19:53:30 UTC (rev 6710)
+++ trunk/info/nodes.c 2015-10-19 18:17:21 UTC (rev 6711)
@@ -1453,6 +1453,8 @@
the screen), which looks wrong. */
if (node->display_pos >= (unsigned long) node->nodelen)
node->display_pos = node->nodelen - 1;
+ else if (node->display_pos < 0)
+ node->display_pos = 0; /* Shouldn't happen. */
}
return node;
Modified: trunk/info/nodes.h
===================================================================
--- trunk/info/nodes.h 2015-10-17 19:53:30 UTC (rev 6710)
+++ trunk/info/nodes.h 2015-10-19 18:17:21 UTC (rev 6711)
@@ -45,7 +45,7 @@
char *nodename; /* The name of this node. */
char *contents; /* Characters appearing in this node. */
long nodelen; /* The length of the CONTENTS member. */
- unsigned long display_pos; /* Where to display at, if nonzero. */
+ long display_pos; /* Where to display at, if nonzero. */
long body_start; /* Offset of the actual node body */
int flags; /* See immediately below. */
REFERENCE **references; /* Cross-references or menu items in node.
Modified: trunk/info/search.c
===================================================================
--- trunk/info/search.c 2015-10-17 19:53:30 UTC (rev 6710)
+++ trunk/info/search.c 2015-10-19 18:17:21 UTC (rev 6711)
@@ -491,8 +491,8 @@
return -1;
}
-/* Return the length of the node separator characters that BODY is
- currently pointing at. */
+/* Return the length of the node separator characters that BODY is currently
+ pointing at. If it's not pointing at a node separator, return 0. */
int
skip_node_separator (char *body)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6711] fix anchor positions for nodeline variable,
Gavin D. Smith <=