texinfo-commits
[Top][All Lists]
Advanced

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

[7011] nodeline hiding in calculate_line_starts


From: Gavin D. Smith
Subject: [7011] nodeline hiding in calculate_line_starts
Date: Sat, 13 Feb 2016 18:42:30 +0000

Revision: 7011
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7011
Author:   gavin
Date:     2016-02-13 18:41:58 +0000 (Sat, 13 Feb 2016)
Log Message:
-----------
nodeline hiding in calculate_line_starts

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/info-utils.c
    trunk/info/window.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2016-02-13 15:41:56 UTC (rev 7010)
+++ trunk/ChangeLog     2016-02-13 18:41:58 UTC (rev 7011)
@@ -1,5 +1,14 @@
 2016-02-13  Gavin Smith  <address@hidden>
 
+       * info/info-utils.c (nodeline_print): Move to info/window.c.
+       (parse_top_node_line): Remove code altering start of node 
+       depending on value of nodeline_print.
+       * info/window.c (calculate_line_starts): Use nodeline variable 
+       to decide where to start displaying the node.
+       (window_line_of_point): Comments changed.
+
+2016-02-13  Gavin Smith  <address@hidden>
+
        * info/nodes.c (info_node_of_tag_ext): Don't save a pointer into 
        the file buffer in the tag table, because it could continue 
        after the file buffer was garbage collected.  Change the logic 

Modified: trunk/info/info-utils.c
===================================================================
--- trunk/info/info-utils.c     2016-02-13 15:41:56 UTC (rev 7010)
+++ trunk/info/info-utils.c     2016-02-13 18:41:58 UTC (rev 7011)
@@ -1103,19 +1103,13 @@
     }
 }
 
-#define NO_NODELINE 0
-#define PRINT_NODELINE 1
-#define NODELINE_POINTERS_ONLY 2
-int nodeline_print = 2;
-
 /* Read first line of node and set next, prev and up. */
 static void
 parse_top_node_line (NODE *node)
 {
   char **store_in = 0;
   char *nodename;
-  char *ptr, *ptr2;
-  char *display_start = 0;
+  char *ptr;
   int value_length;
 
   /* If the first line is empty, leave it in.  This is the case
@@ -1135,44 +1129,38 @@
       /* Check what field we are looking at */
       if (!strncasecmp (ptr, INFO_FILE_LABEL, strlen(INFO_FILE_LABEL)))
         {
-          ptr2 = ptr + strlen (INFO_FILE_LABEL);
+          ptr += strlen (INFO_FILE_LABEL);
         }
       else if (!strncasecmp (ptr, INFO_NODE_LABEL, strlen(INFO_NODE_LABEL)))
         {
-          ptr2 = ptr + strlen (INFO_NODE_LABEL);
+          ptr += strlen (INFO_NODE_LABEL);
         }
       else if (!strncasecmp (ptr, INFO_PREV_LABEL, strlen(INFO_PREV_LABEL)))
         {
-          ptr2 = ptr + strlen (INFO_PREV_LABEL);
+          ptr += strlen (INFO_PREV_LABEL);
           store_in = &node->prev;
         }
       else if (!strncasecmp (ptr, INFO_ALTPREV_LABEL, 
                              strlen(INFO_ALTPREV_LABEL)))
         {
-          ptr2 = ptr + strlen (INFO_ALTPREV_LABEL);
+          ptr += strlen (INFO_ALTPREV_LABEL);
           store_in = &node->prev;
         }
       else if (!strncasecmp (ptr, INFO_NEXT_LABEL, strlen(INFO_NEXT_LABEL)))
         {
-          ptr2 = ptr + strlen (INFO_NEXT_LABEL);
+          ptr += strlen (INFO_NEXT_LABEL);
           store_in = &node->next;
         }
       else if (!strncasecmp (ptr, INFO_UP_LABEL, strlen(INFO_UP_LABEL)))
         {
-          ptr2 = ptr + strlen (INFO_UP_LABEL);
+          ptr += strlen (INFO_UP_LABEL);
           store_in = &node->up;
         }
       else 
         {
-          ptr2 = ptr;
           store_in = 0;
           /* Not recognized - code below will skip to next comma */
         }
-        
-      if (nodeline_print==NODELINE_POINTERS_ONLY && !display_start && store_in)
-        display_start = ptr;
-      ptr = ptr2;
-
       ptr += skip_whitespace (ptr);
 
       if (*ptr != '(')
@@ -1202,20 +1190,6 @@
 
       ptr += 1; /* Point after field terminator */
     }
-  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;
-    }
 }
 
 /* Output, replace or hide text introducing a reference.  INPTR starts on

Modified: trunk/info/window.c
===================================================================
--- trunk/info/window.c 2016-02-13 15:41:56 UTC (rev 7010)
+++ trunk/info/window.c 2016-02-13 18:41:58 UTC (rev 7011)
@@ -825,8 +825,8 @@
   if (!window->line_starts)
     calculate_line_starts (window);
 
-  /* Try to optimize.  Check to see if point is past the pagetop for
-     this window, and if so, start searching forward from there. */
+  /* Check if point is past the pagetop for this window, and if so, start 
+     searching forward from there. */
   if (window->pagetop > -1 && window->pagetop < window->line_count
       && window->line_starts[window->pagetop] <= window->point)
     start = window->pagetop;
@@ -837,13 +837,10 @@
         break;
     }
 
-  /* Something is wrong with the above logic as it allows a negative
-     index to be returned for small windows.  Until someone figures it
-     out, at least don&#39;t core dump. */
   if (i > 0)
     return i - 1;
   else
-    return 0;
+    return 0; /* Shouldn't happen */
 }
 
 /* Get and return the printed column offset of the cursor in this window. */
@@ -1153,6 +1150,11 @@
   win->log_line_no[win->line_count - 1] = ll_num;
 }
 
+#define NO_NODELINE 0
+#define PRINT_NODELINE 1
+#define NODELINE_POINTERS_ONLY 2
+int nodeline_print = 2;
+
 /* Calculate a list of line starts for the node belonging to WINDOW.  The
    line starts are offsets within WINDOW->node->contents.
 
@@ -1162,7 +1164,7 @@
 calculate_line_starts (WINDOW *win)
 {
   long pl_chars = 0;     /* Number of characters in line so far. */
-  long pl_start = 0;     /* Offset of start of current physical line. */
+  long pl_start;         /* Offset of start of current physical line. */
   long ll_num = 0;       /* Number of logical lines */
   mbi_iterator_t iter;
 
@@ -1177,7 +1179,32 @@
   if (!win->node)
     return;
 
-  for (mbi_init (iter, win->node->contents, win->node->nodelen);
+  pl_start = 0;
+  if (nodeline_print != PRINT_NODELINE
+      && !memcmp (win->node->contents, "File:", strlen ("File:")))
+    {
+      char *s;
+      if (nodeline_print == NO_NODELINE)
+        {
+          s = strchr (win->node->contents, '\n');
+          if (s)
+            pl_start = s - win->node->contents + 1;
+        }
+      else if (nodeline_print == NODELINE_POINTERS_ONLY)
+        {
+          s = strstr (win->node->contents, "Next: ");
+          if (!s)
+            s = strstr (win->node->contents, "Prev: ");
+          if (!s)
+            s = strstr (win->node->contents, "Up: ");
+          if (s)
+            pl_start = s - win->node->contents;
+        }
+    }
+
+  for (mbi_init (iter,
+                 win->node->contents + pl_start,
+                 win->node->nodelen - pl_start);
        mbi_avail (iter);
        mbi_advance (iter))
     {




reply via email to

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