Blame gl/ftell.c

Packit Service 4684c1
/* An ftell() function that works around platform bugs.
Packit Service 4684c1
   Copyright (C) 2007-2020 Free Software Foundation, Inc.
Packit Service 4684c1
Packit Service 4684c1
   This program is free software: you can redistribute it and/or modify
Packit Service 4684c1
   it under the terms of the GNU Lesser General Public License as published by
Packit Service 4684c1
   the Free Software Foundation; either version 2.1 of the License, or
Packit Service 4684c1
   (at your option) any later version.
Packit Service 4684c1
Packit Service 4684c1
   This program is distributed in the hope that it will be useful,
Packit Service 4684c1
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 4684c1
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 4684c1
   GNU Lesser General Public License for more details.
Packit Service 4684c1
Packit Service 4684c1
   You should have received a copy of the GNU Lesser General Public License
Packit Service 4684c1
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit Service 4684c1
Packit Service 4684c1
#include <config.h>
Packit Service 4684c1
Packit Service 4684c1
/* Specification.  */
Packit Service 4684c1
#include <stdio.h>
Packit Service 4684c1
Packit Service 4684c1
#include <errno.h>
Packit Service 4684c1
#include <limits.h>
Packit Service 4684c1
Packit Service 4684c1
long
Packit Service 4684c1
ftell (FILE *fp)
Packit Service 4684c1
{
Packit Service 4684c1
  /* Use the replacement ftello function with all its workarounds.  */
Packit Service 4684c1
  off_t offset = ftello (fp);
Packit Service 4684c1
  if (LONG_MIN <= offset && offset <= LONG_MAX)
Packit Service 4684c1
    return /* (long) */ offset;
Packit Service 4684c1
  else
Packit Service 4684c1
    {
Packit Service 4684c1
      errno = EOVERFLOW;
Packit Service 4684c1
      return -1;
Packit Service 4684c1
    }
Packit Service 4684c1
}