NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
standards/48788: getline()/getdelim() belongs to POSIX.1-2008, not ANSI C
>Number: 48788
>Category: standards
>Synopsis: getline()/getdelim() belongs to POSIX.1-2008, not ANSI C
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: standards-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue May 06 18:40:00 +0000 2014
>Originator: Jarmo Jaakkola
>Release: NetBSD 6.1.2_PATCH
>Organization:
>Environment:
System: NetBSD kotoisa.roskakori.fi 6.1.2_PATCH NetBSD 6.1.2_PATCH (KOTOISA)
#5: Mon Jan 20 17:01:44 EET 2014
jammuli%kotoisa.roskakori.fi@localhost:/usr/src/sys/arch/amd64/compile/KOTOISA
amd64
Architecture: x86_64
Machine: amd64
>Description:
The functions getline() and getdelim() in /usr/include/stdio.h are defined
for ANSI C source code, which is wrong. They should be defined for
POSIX.1-2008 code instead.
>How-To-Repeat:
Try to compile
#include <stdio.h>
void getline(void) { }
int main(char** argv, int argc) {
getline();
}
with command
gcc -ansi -o example example.c
>Fix:
Move the definitions into proper section of the header.
--- stdio.h 2013-09-28 06:19:02.000000000 +0300
+++ stdio.h 2014-05-06 19:57:10.000000000 +0300
@@ -241,9 +241,6 @@
size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict);
int getc(FILE *);
int getchar(void);
-ssize_t getdelim(char ** __restrict, size_t * __restrict, int,
- FILE * __restrict);
-ssize_t getline(char ** __restrict, size_t * __restrict, FILE *
__restrict);
void perror(const char *);
int printf(const char * __restrict, ...)
__printflike(1, 2);
@@ -516,6 +513,9 @@
#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \
defined(_NETBSD_SOURCE)
FILE *fmemopen(void * __restrict, size_t, const char * __restrict);
+ssize_t getdelim(char ** __restrict, size_t * __restrict, int,
+ FILE * __restrict);
+ssize_t getline(char ** __restrict, size_t * __restrict, FILE *
__restrict);
#endif
#if _FORTIFY_SOURCE > 0
Home |
Main Index |
Thread Index |
Old Index