From owner-freebsd-questions@FreeBSD.ORG Sun Feb 19 00:19:56 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 300D916A422 for ; Sun, 19 Feb 2006 00:19:56 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 732C643D55 for ; Sun, 19 Feb 2006 00:19:51 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from flame.pc (dialup158.ach.sch.gr [81.186.70.158]) (authenticated bits=128) by igloo.linux.gr (8.13.5/8.13.5/Debian-3) with ESMTP id k1J0JEpf016558 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 19 Feb 2006 02:19:29 +0200 Received: from flame.pc (flame [127.0.0.1]) by flame.pc (8.13.4/8.13.4) with ESMTP id k1IIL3Rr002663; Sat, 18 Feb 2006 20:21:33 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by flame.pc (8.13.4/8.13.4/Submit) id k1IIKWLd002662; Sat, 18 Feb 2006 20:20:32 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Sat, 18 Feb 2006 20:20:31 +0200 From: Giorgos Keramidas To: Tom Grove Message-ID: <20060218182031.GA2653@flame.pc> References: <43F68C7D.9010403@voidmain.net> <1140233843.982.21.camel@chaucer.jeays.ca> <43F74361.90109@voidmain.net> <43F75DF6.3050903@mac.com> <43F75F3C.7080903@voidmain.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <43F75F3C.7080903@voidmain.net> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (score=-3.388, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.81, BAYES_00 -2.60, DNS_FROM_RFC_ABUSE 0.20) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr Cc: freebsd-questions@freebsd.org Subject: Re: getline function X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Feb 2006 00:19:56 -0000 On 2006-02-18 12:54, Tom Grove wrote: >Chuck Swiger wrote: >>Tom Grove wrote: >>>Mike Jeays wrote: >>> That works and I had looked into that earlier...it seems like >>> it does a lot more than just one function from the man page. >>> I guess I can use that for now but I wonder why getline() is >>> broken in gcc on FreeBSD? >> >> getline() is not part of the standard C library. >> What makes you think gcc is broken...? > > Yeah...I see that after some more research. So, now I guess my > question is being that it's not standard and gets() is not safe > to use what should I use to grab lines? My gut tells me to > copy the getline() function from the K&R book but I'm not > totally sure that's a great idea either. Stupid strings always > causing problems! This is a frequently recurring question in comp.lang.c. There are perfectly portable ways to use only ANSI C functions to read a full line of text, allocating dynamically as much memory as needed. For example, a search in the archives of the newsgroup will provide easily pointers to safe ways to use fgets() to read a line.