Mark Kettenis wrote:
> It really is confusing to use off_t for something that's not a byte
> offset.  If integer overflow really is an issue you care about, use
> "long long".

ok for the below diff to update my grep change?

> Note that on many non-BSD systems off_t is still a 32-bit integer, at
> least by default.  So using off_t doesn't help portability.  Search
> the interwebs for "Large File Summit" for the full horror story!

Thanks for the reference.  :-)  Interesting read.


Index: grep.h
===================================================================
RCS file: /cvs/src/usr.bin/grep/grep.h,v
retrieving revision 1.23
diff -u -p -r1.23 grep.h
--- grep.h      7 Dec 2015 18:50:06 -0000       1.23
+++ grep.h      11 Dec 2015 02:18:02 -0000
@@ -43,7 +43,7 @@
 
 typedef struct {
        size_t           len;
-       off_t            line_no;
+       long long        line_no;
        off_t            off;
        char            *file;
        char            *dat;
Index: util.c
===================================================================
RCS file: /cvs/src/usr.bin/grep/util.c,v
retrieving revision 1.51
diff -u -p -r1.51 util.c
--- util.c      7 Dec 2015 18:50:06 -0000       1.51
+++ util.c      11 Dec 2015 02:18:02 -0000
@@ -623,7 +623,7 @@ printline(str_t *line, int sep, regmatch
        if (nflag) {
                if (n)
                        putchar(sep);
-               printf("%lld", (long long)line->line_no);
+               printf("%lld", line->line_no);
                ++n;
        }
        if (bflag) {

Reply via email to