Date: Tue, 14 May 2002 17:33:57 +0300 From: Maxim Sobolev <sobomax@FreeBSD.org> To: Jeremy Lea <reg@FreeBSD.ORG> Cc: "Bruce A. Mah" <bmah@FreeBSD.ORG>, current@FreeBSD.ORG, ports@FreeBSD.ORG Subject: Re: pkg_version in C [was: Re: Perl scripts that need rewriting - Progress!] Message-ID: <3CE12055.A4C17E0E@FreeBSD.org> References: <200205091933.g49JXMjV041629@grimreaper.grondar.org> <20020514145039.B13083@shale.csir.co.za> <3CE10EE1.27F9718@FreeBSD.org> <20020514160714.D13083@shale.csir.co.za>
next in thread | previous in thread | raw e-mail | index | archive | help
Jeremy Lea wrote: > > Hi, > > On Tue, May 14, 2002 at 04:19:29PM +0300, Maxim Sobolev wrote: > > > > +++ version/perform.c 14 May 2002 12:41:41 -0000 > > [...] > > + strlcpy(tmp, PORTS_DIR, PATH_MAX); > > + strlcat(tmp, "/INDEX", PATH_MAX); > > > > I'd suggest snprintf(3) > > Yeah. Like I said, it needs a bit of polishing. I tend to do things > this way while I'm developing because I find it easier to keep track of > what's going where in the string. There's also a bunch of places where > the 'l' versions aren't needed... Tastes differ, granted, but your version is inconsistent with the existing coding style of pkg_install, where snprintf's are used in such cases. > > > Why noy use matchinstalled() which do something similar? > > I looked at it, but it was taking more code to make it work than to > duplicate it because the -s flag is not a regex or a globing pattern. > It's a poorly designed interface... Now that it's working I'll look at > it again and see if I can get it to do the right thing. Simplifying > working code is a lot easier than building it. In this case you just need to call matchinstalled(MATCH_ALL, NULL, NULL) and iterate over results, just like you do with your fts_read() loop. This should make code a bit cleaner and more compact. > > + funny: > > + warnx("This is a very funny looking INDEX!"); > > + return 1; > > > > I don't think this is a good choice for an error message. > > ;-) -Maxim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3CE12055.A4C17E0E>