NEWS.stable: log cherry-pick [ae006b4]->[4a9738e] strtoimax: Avoid link error on...
[gnulib.git] / lib / ftell.c
index 79083fb..74ec986 100644 (file)
 #include <stdio.h>
 
 #include <errno.h>
-/* Get off_t.  */
-#include <unistd.h>
+#include <limits.h>
 
 long
 ftell (FILE *fp)
 {
   /* Use the replacement ftello function with all its workarounds.  */
   off_t offset = ftello (fp);
-  if (offset == (long)offset)
-    return (long)offset;
+  if (LONG_MIN <= offset && offset <= LONG_MAX)
+    return /* (long) */ offset;
   else
     {
       errno = EOVERFLOW;