texinfo-commits
[Top][All Lists]
Advanced

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

[5583] simplify + improve logic slightly; don' t exit pseudotty on read


From: Gavin D. Smith
Subject: [5583] simplify + improve logic slightly; don' t exit pseudotty on read error
Date: Sun, 18 May 2014 22:52:05 +0000

Revision: 5583
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5583
Author:   gavin
Date:     2014-05-18 22:52:04 +0000 (Sun, 18 May 2014)
Log Message:
-----------
simplify + improve logic slightly; don't exit pseudotty on read error

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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-05-18 19:17:11 UTC (rev 5582)
+++ trunk/ChangeLog     2014-05-18 22:52:04 UTC (rev 5583)
@@ -1,5 +1,17 @@
 2014-05-18  Gavin Smith  <address@hidden>
 
+       * info/info-utils.c (scan_reference_label): Simpler logic for
+       setting start and end fields of reference.
+       (skip_input): Don't touch output_bytes_difference if not rewriting
+       node.
+
+       * info/info-utils.c (scan_reference_target): [preprocess_nodes=On]
+       Better condition for which line to output file specifier on.
+
+       * info/pseudotty.c: Don't exit on a read error.
+
+2014-05-18  Gavin Smith  <address@hidden>
+
        * info/dir.c (build_dir_node): Unused local variable deleted.
        * info/indices.c (info_next_index_match): Unused local variable
        deleted.

Modified: trunk/info/info-utils.c
===================================================================
--- trunk/info/info-utils.c     2014-05-18 19:17:11 UTC (rev 5582)
+++ trunk/info/info-utils.c     2014-05-18 22:52:04 UTC (rev 5583)
@@ -596,7 +596,7 @@
 static int nodestart;
 
 /* Difference between the number of bytes input in the file and
-   bytes output. */
+   bytes output.  If !rewrite_p, this should stay 0. */
 static long int output_bytes_difference;
 
 /* Whether we are converting the character encoding of the file. */
@@ -965,16 +965,20 @@
 static void
 skip_input (long n)
 {
-  if (preprocess_nodes_p || !rewrite_p)
+  if (preprocess_nodes_p)
     {
       inptr += n;
       output_bytes_difference += n;
     }
   else if (rewrite_p)
     {
-      /* We are expanding tags only.  Do not skip output. */
+      /* We are expanding tags only.  Do not skip input. */
       copy_input_to_output (n);
     }
+  else
+    {
+      inptr += n;
+    }
 }
 
 static void
@@ -1125,21 +1129,10 @@
 
   /* Point reference to where we will put the displayed reference,
      which could be after whitespace. */
-  if (rewrite_p)
-    {
-      /* This condition is mainly for indices so that the cursor
-         is on the * when tabbing.
-         FIXME: A nicer way of handling the possibilities
-         (rewrite_p, preprocess_nodes_p) */
-      if (preprocess_nodes_p)
-        entry->start = text_buffer_off (&output_buf);
-      else
-        entry->start = start_of_reference - output_bytes_difference;
-    }
+  if (preprocess_nodes_p)
+    entry->start = text_buffer_off (&output_buf);
   else
-    {
-      entry->start = start_of_reference;
-    }
+    entry->start = start_of_reference - output_bytes_difference;
 
 #ifdef QUOTE_NODENAMES
   if (inptr[0] == '\177')
@@ -1176,19 +1169,10 @@
   /* Colon after label. */
   skip_input (1);
 
-  /* Set entry->end. */
-  if (rewrite_p)
-    {
-      /* TODO: Just use the second of these two always? */
-      if (preprocess_nodes_p)
-        entry->end = text_buffer_off (&output_buf);
-      else
-        entry->end = entry->start + label_len - output_bytes_difference;
-    }
+  if (preprocess_nodes_p)
+    entry->end = text_buffer_off (&output_buf);
   else
-    {
-      entry->end = entry->start + label_len;
-    }
+    entry->end = entry->start + label_len;
 
   return entry;
 }
@@ -1238,6 +1222,7 @@
         {
           char saved_char;
           char *nl_off;
+          int space_at_start_of_line = 0;
 
           /* Skip any following spaces after the ":". */
           skip_input (skip_whitespace (inptr));
@@ -1249,21 +1234,23 @@
           inptr[length] = '\0';
           nl_off = strchr (inptr, '\n');
           inptr[length] = saved_char;
+
+          if (nl_off)
+            space_at_start_of_line = skip_whitespace (nl_off + 1);
           
           if (info_parsed_filename)
             {
               /* Rough heuristic of whether it's worth outputing a newline
                  now or later. */
-              if (nl_off && nl_off - inptr < strlen (info_parsed_filename) + 8)
+              if (nl_off
+                  && nl_off < inptr + (length - space_at_start_of_line) / 2)
                 {
-                  int i, j = skip_whitespace (nl_off + 1);
+                  int i;
                   write_extra_bytes_to_output ("\n", 1);
 
-                  /* Don't allow any spaces in the input to mess up
-                     the margin. */
-                  skip_input (strspn (inptr, " "));
-                  for (i = 0; i < j; i++)
+                  for (i = 0; i < space_at_start_of_line; i++)
                     write_extra_bytes_to_output (" ", 1);
+                  skip_input (strspn (inptr, " "));
                   nl_off = 0;
                 }
               else if (inptr[-1] != '\n')
@@ -1276,7 +1263,7 @@
             }
 
           /* Output terminating punctuation, unless we are in a reference
-             like (*note Label:(file)node.). */
+             like "(*note Label:(file)node.)". */
           if (!in_parentheses)
             skip_input (length);
           else
@@ -1289,14 +1276,12 @@
              a paragraph. */
           if (nl_off && *inptr != '\n')
             { 
-              int i, j = skip_whitespace (nl_off + 1);
-              write_extra_bytes_to_output ("\n", 1);
+              int i;
 
-              /* Don't allow any spaces in the input to mess up
-                 the margin. */
-              skip_input (strspn (inptr, " "));
-              for (i = 0; i < j; i++)
+              write_extra_bytes_to_output ("\n", 1);
+              for (i = 0; i < space_at_start_of_line; i++)
                 write_extra_bytes_to_output (" ", 1);
+              skip_input (strspn (inptr, " "));
             }
         }
 
@@ -1305,6 +1290,7 @@
            messing up left edge of second column of menu. */
         for (i = 0; i < length; i++)
           write_extra_bytes_to_output (" ", 1);
+
       if (info_parsed_filename)
         entry->filename = xstrdup (info_parsed_filename);
 

Modified: trunk/info/pseudotty.c
===================================================================
--- trunk/info/pseudotty.c      2014-05-18 19:17:11 UTC (rev 5582)
+++ trunk/info/pseudotty.c      2014-05-18 22:52:04 UTC (rev 5583)
@@ -50,6 +50,10 @@
   fclose (stdout);
 
   error (0, 0, "entering main loop");
-  while (read (master, &dummy, 1) > 0)
-    ;
+  while (1)
+    if (read (master, &dummy, 1) <= 0)
+      {
+        error (0, 0, "read error");
+        sleep (1); /* Don't flood stderr with error messages. */
+      }
 }




reply via email to

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