NetBSD Problem Report #48788

From jarmo.jaakkola@roskakori.fi  Tue May  6 18:37:10 2014
Return-Path: <jarmo.jaakkola@roskakori.fi>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id CFA2FA580B
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  6 May 2014 18:37:10 +0000 (UTC)
Message-Id: <20140506172142.B1616530F@roskakori.fi>
Date: Tue,  6 May 2014 20:21:42 +0300 (EEST)
From: Jarmo Jaakkola <jarmo.jaakkola@roskakori.fi>
Reply-To: Jarmo Jaakkola <jarmo.jaakkola@roskakori.fi>
To: gnats-bugs@gnats.NetBSD.org
Subject: getline()/getdelim() belongs to POSIX.1-2008, not ANSI C
X-Send-Pr-Version: 3.95

>Number:         48788
>Category:       standards
>Synopsis:       getline()/getdelim() belongs to POSIX.1-2008, not ANSI C
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kleink
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 06 18:40:00 +0000 2014
>Closed-Date:    Mon May 19 16:36:15 +0000 2014
>Last-Modified:  Tue Jun 03 14:00:01 +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:/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

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: standards-manager->kleink
Responsible-Changed-By: kleink@NetBSD.org
Responsible-Changed-When: Sun, 18 May 2014 13:37:41 +0000
Responsible-Changed-Why:
I'll handle this.


State-Changed-From-To: open->analyzed
State-Changed-By: kleink@NetBSD.org
State-Changed-When: Sun, 18 May 2014 13:37:41 +0000
State-Changed-Why:
Declarations are misplaced as described.


From: "Klaus Klein" <kleink@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48788 CVS commit: src/include
Date: Mon, 19 May 2014 16:04:10 +0000

 Module Name:	src
 Committed By:	kleink
 Date:		Mon May 19 16:04:10 UTC 2014

 Modified Files:
 	src/include: stdio.h

 Log Message:
 Move declarations of getdelim() and getline() from the (incorrect) ANSI C
 section to POSIX-2008.  From Jarmo Jaakkola in PR standards/48788.


 To generate a diff of this commit:
 cvs rdiff -u -r1.88 -r1.89 src/include/stdio.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: analyzed->closed
State-Changed-By: kleink@NetBSD.org
State-Changed-When: Mon, 19 May 2014 16:36:15 +0000
State-Changed-Why:
Fixed as suggested, thanks.  Also submitted for netbsd-6 [pullup-6 #1066].


From: "SAITOH Masanobu" <msaitoh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48788 CVS commit: [netbsd-6] src/include
Date: Tue, 3 Jun 2014 13:55:44 +0000

 Module Name:	src
 Committed By:	msaitoh
 Date:		Tue Jun  3 13:55:44 UTC 2014

 Modified Files:
 	src/include [netbsd-6]: stdio.h

 Log Message:
 Pull up following revision(s) (requested by kleink in ticket #1066):
 	src/include/stdio.h			1.89-1.90

 Move declarations of getdelim() and getline() from the (incorrect) ANSI C
 section to POSIX-2008.  From Jarmo Jaakkola in PR standards/48788.


 To generate a diff of this commit:
 cvs rdiff -u -r1.80 -r1.80.2.1 src/include/stdio.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.