line-reader: Fix bad math when size_t is bigger than off_t.
[pspp] / src / libpspp / line-reader.c
index 6f90b502cd856dd64db366ce1bb36561141648f0..56a368da2965f08f6c7d9c43aa69ae5cfca155d9 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2010, 2011, 2014 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -311,9 +311,9 @@ off_t
 line_reader_tell (const struct line_reader *r)
 {
   off_t pos = lseek (r->fd, 0, SEEK_CUR);
-  if (pos >= 0)
-    pos = MAX (0, pos - r->length);
-  return pos;
+  return (pos < 0 ? pos
+          : pos >= r->length ? pos - r->length
+          : 0);
 }
 
 /* Returns true if end of file has been encountered reading R. */