Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 May 2002 16:19:29 +0300
From:      Maxim Sobolev <sobomax@FreeBSD.org>
To:        Jeremy Lea <reg@FreeBSD.ORG>
Cc:        Mark Murray <mark@grondar.za>, "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:  <3CE10EE1.27F9718@FreeBSD.org>
References:  <200205091933.g49JXMjV041629@grimreaper.grondar.org> <20020514145039.B13083@shale.csir.co.za>

next in thread | previous in thread | raw e-mail | index | archive | help
Jeremy Lea wrote:
> 
> Hi,
> 
> On Thu, May 09, 2002 at 08:33:22PM +0100, Mark Murray wrote:
> > /usr/sbin/pkg_version Jeremy Lea <reg@FreeBSD.ORG> - re
> 
> OK, the first revision is attached.  It appears to work for me...  It
> needs some spit and polish, and probably a few more people to test.
> 
> I've not implemented the -d flag since it sort of became unneeded, and
> it's not really the way things are done in the rest of pkg_*.  I've also
> not implemented -c.  There were enough warnings that it wasn't really
> useful, and portupgrade does a much better job...

Cool! Few notes:

+++ 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)

[...]
+    ftsp = fts_open((char * const *)(uintptr_t)paths, FTS_LOGICAL |
FTS_NOCHDIR | FTS_NOSTAT, fname_cmp);
+    if (ftsp != NULL) {
+       while ((f = fts_read(ftsp)) != NULL) {
+           if (f->fts_info == FTS_D && f->fts_level == 1) {
+               fts_set(ftsp, f, FTS_SKIP);
+               if (MatchName == NULL || strstr(f->fts_name,
MatchName))
+                       err_cnt += pkg_do(f->fts_name);
+           }
+       }
+       fts_close(ftsp);
+    }

Why noy use matchinstalled() which do something similar?

[...]
+    strlcpy(tmp, LOG_DIR, PATH_MAX);
+    strlcat(tmp, "/", PATH_MAX);
+    strlcat(tmp, pkg, PATH_MAX);
+    strlcat(tmp, "/", PATH_MAX);
+    strlcat(tmp, CONTENTS_FNAME, PATH_MAX);

I'd suggest snprintf(3)

[...]
+       strlcpy(tmp, PORTS_DIR, PATH_MAX);
+       strlcat(tmp, "/", PATH_MAX);
+       strlcat(tmp, plist.origin, PATH_MAX);

snprintf(3)

[...]
+ funny:
+    warnx("This is a very funny looking INDEX!");
+    return 1;

I don't think this is a good choice for an error message.

[...]
+static int
+fname_cmp(const FTSENT **a, const FTSENT **b)
+{
+    return strcmp((*a)->fts_name, (*b)->fts_name);
+}

Could be routed to /dev/null if matchinstalled() is used.

-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?3CE10EE1.27F9718>