From: John Darrington Date: Wed, 16 Sep 2015 05:30:57 +0000 (+0200) Subject: Text file importer: Initialise the total_is_exact variable. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b4b93cf05b9488e3048c40125c2d344a72f9e2f;p=pspp Text file importer: Initialise the total_is_exact variable. 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. --- diff --git a/src/ui/gui/page-file.c b/src/ui/gui/page-file.c index 9280446b0f..bf09902bf9 100644 --- a/src/ui/gui/page-file.c +++ b/src/ui/gui/page-file.c @@ -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);