Subject: Does "ar -tv" work on little-endian machines?
To: None <current-users@netbsd.org>
From: Greg Earle <earle@isolar.Tujunga.CA.US>
List: current-users
Date: 10/11/1994 11:46:43
This would ordinarily be a trivial bug report for "send-pr", but it's got my
curiosity piqued.

The code that handles "ar -tv" output - /usr/src/usr.bin/ar/contents.c - has
been the same since December of last year.

Meanwhile, the "size" field in the archive header went through the transition
to off_t sometime since then.

Because of this, under NetBSD/SPARC, "ar -tv" yields file sizes of "0" for
every archive element:

netbsd4me# ar -tv /usr/lib/libc.a | head -5
rw-r--r--       0/0             0 Aug  1 12:33 1994 __.SYMDEF
rwxr-xr-x       0/10            0 Jul 29 01:17 1994 truncate.o
rwxr-xr-x       0/10            0 Jul 29 01:17 1994 syscall.o
rwxr-xr-x       0/10            0 Jul 29 01:17 1994 sigreturn.o
rwxr-xr-x       0/10            0 Jul 29 01:17 1994 sigpending.o

Now, it's really a simple fix, e.g.:

netbsd4me# diff -rc1 contents.c.orig contents.c
*** contents.c.orig     Thu Dec 16 23:04:39 1993
--- contents.c  Tue Oct 11 05:49:08 1994
***************
*** 78,80 ****
                        (void)strmode(chdr.mode, buf);
!                       (void)printf("%s %6d/%-6d %8ld ",
                            buf + 1, chdr.uid, chdr.gid, chdr.size);
--- 78,80 ----
                        (void)strmode(chdr.mode, buf);
!                       (void)printf("%s %6d/%-6d %16qd ",
                            buf + 1, chdr.uid, chdr.gid, chdr.size);

... but what's got me curious is that I can't imagine that I'm the only
person in the whole NetBSD world who's done an "ar -tv" on an archive library
in the past N months since the off_t change.  (-:

This leads me to wonder if the "%8ld" in the printf() above is still yielding
correct results on little-endian machines.  If you're on an x86 NetBSD system,
does "ar -tv /usr/lib/libc.a" show you correct file sizes?

BTW, while investigating this, I also stumbled upon:

- "man 3 printf" still gave me printf(1) and not printf(3):

...
 26757 man      NAMI  "/etc/man.conf"
...
 26757 man      NAMI  "/usr/share/man/cat1/sparc/"
 26757 man      RET   open -1 errno 2 No such file or directory
...
 26757 man      NAMI  "/usr/share/man/cat1/"
...
 26757 man      NAMI  "/usr/share/man/cat1/printf.0"

- The optional character "q" qualifier is not documented in printf(3), unlike
  its older brethren, "l"

	- Greg