From owner-freebsd-hackers@FreeBSD.ORG Sun Jul 3 20:52:14 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 915A0106564A; Sun, 3 Jul 2011 20:52:14 +0000 (UTC) (envelope-from lichray@gmail.com) Received: from mail-fx0-f44.google.com (mail-fx0-f44.google.com [209.85.161.44]) by mx1.freebsd.org (Postfix) with ESMTP id 0428F8FC08; Sun, 3 Jul 2011 20:52:13 +0000 (UTC) Received: by fxe6 with SMTP id 6so3819985fxe.17 for ; Sun, 03 Jul 2011 13:52:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=/9TbQxfHW4Pl3rMVygHDJvZWzxJhLDaV1hunHr+2muk=; b=u0SdJ2V+VRWPI7NKUVJxQdObo0LGz/dXeJ+QIvSmZx7Jh8XCbfuzePjaS6Fi3YazGZ K3TH4hTjptWLTkjG597pITrbtlq579mqfrD0AOrPmFSz8jSRhUwIypdi/ZjvXVyr2MPU uUSn8AJXo5vKkIiUN7AC9UUj0UKz0KSDY48fI= MIME-Version: 1.0 Received: by 10.223.1.201 with SMTP id 9mr8361556fag.91.1309724570359; Sun, 03 Jul 2011 13:22:50 -0700 (PDT) Received: by 10.223.96.205 with HTTP; Sun, 3 Jul 2011 13:22:50 -0700 (PDT) In-Reply-To: <20110703194908.GO71453@hoeg.nl> References: <20110703194908.GO71453@hoeg.nl> Date: Sun, 3 Jul 2011 15:22:50 -0500 Message-ID: From: Zhihao Yuan To: Ed Schouten Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org, Robert Millan , Ed Maste Subject: Re: [PATCH] build config(8) on GNU systems X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jul 2011 20:52:14 -0000 Programmers always want to make things "cooler". Just leave the ->d_namlen there :) On Sun, Jul 3, 2011 at 2:49 PM, Ed Schouten wrote: > * Robert Millan , 20110702 16:56: >> Index: usr.sbin/config/main.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- usr.sbin/config/main.c =C2=A0 =C2=A0(revision 223721) >> +++ usr.sbin/config/main.c =C2=A0 =C2=A0(working copy) >> @@ -591,7 +591,11 @@ >> =C2=A0 =C2=A0 =C2=A0 if ((dirp =3D opendir(p)) =3D=3D NULL) >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 err(EX_OSERR, "opendir = %s", p); >> =C2=A0 =C2=A0 =C2=A0 while ((dp =3D readdir(dirp)) !=3D NULL) { >> +#ifdef _DIRENT_HAVE_D_NAMLEN >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 i =3D dp->d_namlen - 2; >> +#else >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 i =3D strlen (dp->d_name) - = 2; >> +#endif >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* Skip non-headers */ >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (dp->d_name[i] !=3D = '.' || dp->d_name[i + 1] !=3D 'h') >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 continue; > > Why not simply use strlen() unconditionally? > > -- > =C2=A0Ed Schouten > =C2=A0WWW: http://80386.nl/ > --=20 Zhihao Yuan, nickname lichray The best way to predict the future is to invent it. ___________________________________________________ 4BSD -- http://4bsd.biz/