OpenCoverage

freadahead.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/gnulib/lib/freadahead.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* Retrieve information about a FILE stream.-
2 Copyright (C) 2007-2018 Free Software Foundation, Inc.-
3-
4 This program is free software: you can redistribute it and/or modify-
5 it under the terms of the GNU General Public License as published by-
6 the Free Software Foundation; either version 3 of the License, or-
7 (at your option) any later version.-
8-
9 This program is distributed in the hope that it will be useful,-
10 but WITHOUT ANY WARRANTY; without even the implied warranty of-
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-
12 GNU General Public License for more details.-
13-
14 You should have received a copy of the GNU General Public License-
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */-
16-
17#include <config.h>-
18-
19/* Specification. */-
20#include "freadahead.h"-
21-
22#include <stdlib.h>-
23#include "stdio-impl.h"-
24-
25#if defined __DragonFly__-
26/* Defined in libc, but not declared in <stdio.h>. */-
27extern size_t __sreadahead (FILE *);-
28#endif-
29-
30size_t-
31freadahead (FILE *fp)-
32{-
33#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */-
34 if (fp->_IO_write_ptr > fp->_IO_write_base)
fp->_IO_write_..._IO_write_baseDescription
TRUEnever evaluated
FALSEevaluated 3074 times by 6 tests
Evaluated by:
  • cp
  • cut
  • ginstall
  • ln
  • mv
  • rm
0-3074
35 return 0;
never executed: return 0;
0
36 return (fp->_IO_read_end - fp->_IO_read_ptr)
executed 3074 times by 6 tests: return (fp->_IO_read_end - fp->_IO_read_ptr) + (fp->_flags & 0x100 ? fp->_IO_save_end - fp->_IO_save_base : 0);
Executed by:
  • cp
  • cut
  • ginstall
  • ln
  • mv
  • rm
3074
37 + (fp->_flags & _IO_IN_BACKUP ? fp->_IO_save_end - fp->_IO_save_base :
executed 3074 times by 6 tests: return (fp->_IO_read_end - fp->_IO_read_ptr) + (fp->_flags & 0x100 ? fp->_IO_save_end - fp->_IO_save_base : 0);
Executed by:
  • cp
  • cut
  • ginstall
  • ln
  • mv
  • rm
3074
38 0);
executed 3074 times by 6 tests: return (fp->_IO_read_end - fp->_IO_read_ptr) + (fp->_flags & 0x100 ? fp->_IO_save_end - fp->_IO_save_base : 0);
Executed by:
  • cp
  • cut
  • ginstall
  • ln
  • mv
  • rm
3074
39#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__-
40 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */-
41 if ((fp_->_flags & __SWR) != 0 || fp_->_r < 0)-
42 return 0;-
43# if defined __DragonFly__-
44 return __sreadahead (fp);-
45# else-
46 return fp_->_r-
47 + (HASUB (fp) ? fp_->_ur : 0);-
48# endif-
49#elif defined __EMX__ /* emx+gcc */-
50 if ((fp->_flags & _IOWRT) != 0)-
51 return 0;-
52 /* Note: fp->_ungetc_count > 0 implies fp->_rcount <= 0,-
53 fp->_ungetc_count = 0 implies fp->_rcount >= 0. */-
54 /* equivalent to-
55 (fp->_ungetc_count == 0 ? fp->_rcount : fp->_ungetc_count - fp->_rcount) */-
56 return (fp->_rcount > 0 ? fp->_rcount : fp->_ungetc_count - fp->_rcount);-
57#elif defined __minix /* Minix */-
58 if ((fp_->_flags & _IOWRITING) != 0)-
59 return 0;-
60 return fp_->_count;-
61#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, MSVC, NonStop Kernel, OpenVMS */-
62 if ((fp_->_flag & _IOWRT) != 0)-
63 return 0;-
64 return fp_->_cnt;-
65#elif defined __UCLIBC__ /* uClibc */-
66# ifdef __STDIO_BUFFERS-
67 if (fp->__modeflags & __FLAG_WRITING)-
68 return 0;-
69 return (fp->__bufread - fp->__bufpos)-
70 + (fp->__modeflags & __FLAG_UNGOT ? 1 : 0);-
71# else-
72 return 0;-
73# endif-
74#elif defined __QNX__ /* QNX */-
75 if ((fp->_Mode & 0x2000 /* _MWRITE */) != 0)-
76 return 0;-
77 /* fp->_Buf <= fp->_Next <= fp->_Rend,-
78 and fp->_Rend may be overridden by fp->_Rsave. */-
79 return ((fp->_Rsave ? fp->_Rsave : fp->_Rend) - fp->_Next)-
80 + (fp->_Mode & 0x4000 /* _MBYTE */-
81 ? (fp->_Back + sizeof (fp->_Back)) - fp->_Rback-
82 : 0);-
83#elif defined __MINT__ /* Atari FreeMiNT */-
84 if (!fp->__mode.__read)-
85 return 0;-
86 return (fp->__pushed_back-
87 ? fp->__get_limit - fp->__pushback_bufp + 1-
88 : fp->__get_limit - fp->__bufp);-
89#elif defined EPLAN9 /* Plan9 */-
90 if (fp->state == 4 /* WR */ || fp->rp >= fp->wp)-
91 return 0;-
92 return fp->wp - fp->rp;-
93#elif defined SLOW_BUT_NO_HACKS /* users can define this */-
94 abort ();-
95 return 0;-
96#else-
97 #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."-
98#endif-
99}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2