]> git.eshelyaron.com Git - emacs.git/commitdiff
exit inner copying loop at the start of a new file entry
authorTom Tromey <tom@tromey.com>
Sat, 20 Jan 2018 23:53:12 +0000 (16:53 -0700)
committerDmitry Gutov <dgutov@yandex.ru>
Tue, 8 Dec 2020 20:54:02 +0000 (22:54 +0200)
lib-src/etags.c

index 92cc190f3e6ce2a485c106fcf770e30687f312ae..1fa0447791b26f2e84a06c22c78164bd895f8119 100644 (file)
@@ -1680,21 +1680,21 @@ static void
 copy_entries_from_old_file (FILE *old_file, const char *old_filename, FILE *out_file)
 {
   linebuffer line;
+  bool keep_going = true;
 
   need_filebuf = false;
 
   linebuffer_init (&line);
-  while (true)
+
+  if (readline_internal (&line, old_file, old_filename) <= 0
+      || line.len < 1 || !strneq (line.buffer, "\f", 1))
+    goto error;
+
+  while (keep_going)
     {
       char *comma, *filename;
       bool should_copy;
 
-      if (readline_internal (&line, old_file, old_filename) <= 0)
-       break;
-
-      if (line.len < 1 || !strneq (line.buffer, "\f", 1))
-       goto error;
-
       if (readline_internal (&line, old_file, old_filename) <= 0)
        goto error;
 
@@ -1716,13 +1716,19 @@ copy_entries_from_old_file (FILE *old_file, const char *old_filename, FILE *out_
       while (true)
        {
          if (readline_internal (&line, old_file, old_filename) <= 0)
-           break;
+           {
+             keep_going = false;
+             break;
+           }
 
          if (should_copy)
            {
              fwrite (line.buffer, line.len, 1, out_file);
              fputs ("\n", out_file);
            }
+
+         if (line.len < 0 || strneq (line.buffer, "\f", 1))
+           break;
        }
     }