Text file importer: Initialise the total_is_exact variable.
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 16 Sep 2015 05:30:57 +0000 (07:30 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 16 Sep 2015 05:30:57 +0000 (07:30 +0200)
The text file importer was supposed to have a feature where the total number of lines
in the file was measured if the file was short, or estimated if it was long.  However
the variable which was supposed to hold this information was never initialised. This
change fixes that.

src/ui/gui/page-file.c

index 9280446b0f5ef103669175a7dda8341c8f7e8938..bf09902bf9e68c19cf3894f3d37ff504334a6a98 100644 (file)
@@ -138,17 +138,27 @@ init_file (struct import_assistant *ia, GtkWindow *parent_window)
        return false;
       }
 
+
     /* Estimate the number of lines in the file. */
     if (file->line_cnt < MAX_PREVIEW_LINES)
-      file->total_lines = file->line_cnt;
+      {
+       file->total_lines = file->line_cnt;
+       file->total_is_exact = true;
+      }
     else
       {
        struct stat s;
        off_t position = line_reader_tell (reader);
        if (fstat (line_reader_fileno (reader), &s) == 0 && position > 0)
-         file->total_lines = (double) file->line_cnt / position * s.st_size;
+         {
+           file->total_lines = (double) file->line_cnt / position * s.st_size;
+           file->total_is_exact = false;
+         }
        else
+         {
          file->total_lines = 0;
+         file->total_is_exact = true;
+         }
       }
 
     line_reader_close (reader);