Jeremy Lea wrote:
> 
> Hi,
> 
> On Thu, May 09, 2002 at 08:33:22PM +0100, Mark Murray wrote:
> > /usr/sbin/pkg_version Jeremy Lea <[EMAIL PROTECTED]> - 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 [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to