]> granicus.if.org Git - pgbadger/commitdiff
Fix wrong size/offset of log files with unicode characters that was breaking incremen...
authorDarold Gilles <gilles@darold.net>
Fri, 15 Jan 2016 12:46:33 +0000 (13:46 +0100)
committerDarold Gilles <gilles@darold.net>
Fri, 15 Jan 2016 12:46:33 +0000 (13:46 +0100)
pgbadger

index a26da2a49fa684e5c9d76dcdf4f7b082ee657dbe..0c9f751425c921eabcfa94b40070bf6f496b8dbd 100755 (executable)
--- a/pgbadger
+++ b/pgbadger
@@ -2284,6 +2284,10 @@ sub process_file
 
                        $line =~ s/\r//;
 
+                       # Set current size and offset
+                       $cursize += bytes($line);
+                       $current_offset += bytes($line);
+
                        # Start to exclude from parsing any desired lines
                        if ($has_exclusion >= 0) {
 
@@ -2293,9 +2297,6 @@ sub process_file
                                next if ($ef);
                        }
 
-                       $cursize += length($line);
-                       $current_offset += length($line);
-
                        chomp($line);
                        $nlines++;
                        next if (!$line);
@@ -2880,6 +2881,12 @@ sub check_file_changed
        return (1, "reach the end of check_file_changed() with start date: $saved_date and file size: $totalsize") ;
 }
 
+# Return real size of ascii and unicode string.
+sub bytes($)
+{
+       use bytes;
+       return length shift;
+}
 
 # Method used to check if we have already reached the last parsing position in incremental mode
 # This position should have been saved in the incremental file and read in the $last_parsed at