- strncpy (hdr->ar_fmag, ARFMAG, 2);
-
- /* Goddamned sprintf doesn't permit MAXIMUM field lengths */
- sprintf ((hdr->ar_date), "%-12ld", (long) status.st_mtime);
- sprintf ((hdr->ar_uid), "%ld", (long) status.st_uid);
- sprintf ((hdr->ar_gid), "%ld", (long) status.st_gid);
- sprintf ((hdr->ar_mode), "%-8o", (unsigned int) status.st_mode);
- sprintf ((hdr->ar_size), "%-10ld", (long) status.st_size);
- /* Correct for a lossage in sprintf whereby it null-terminates. I cannot
- understand how these C losers could design such a ramshackle bunch of
- IO operations */
- temp = (char *) hdr;
- temp1 = temp + sizeof (struct ar_hdr) - 2;
- for (; temp < temp1; temp++)
- {
- if (*temp == '\0')
- *temp = ' ';
- }
- strncpy (hdr->ar_fmag, ARFMAG, 2);
+ _bfd_ar_spacepad (hdr->ar_date, sizeof (hdr->ar_date), "%-12ld",
+ status.st_mtime);
+#ifdef HPUX_LARGE_AR_IDS
+ /* HP has a very "special" way to handle UID/GID's with numeric values
+ > 99999. */
+ if (status.st_uid > 99999)
+ hpux_uid_gid_encode (hdr->ar_uid, (long) status.st_uid);
+ else
+#endif
+ _bfd_ar_spacepad (hdr->ar_uid, sizeof (hdr->ar_uid), "%ld",
+ status.st_uid);
+#ifdef HPUX_LARGE_AR_IDS
+ /* HP has a very "special" way to handle UID/GID's with numeric values
+ > 99999. */
+ if (status.st_gid > 99999)
+ hpux_uid_gid_encode (hdr->ar_gid, (long) status.st_gid);
+ else
+#endif
+ _bfd_ar_spacepad (hdr->ar_gid, sizeof (hdr->ar_gid), "%ld",
+ status.st_gid);
+ _bfd_ar_spacepad (hdr->ar_mode, sizeof (hdr->ar_mode), "%-8lo",
+ status.st_mode);
+ _bfd_ar_spacepad (hdr->ar_size, sizeof (hdr->ar_size), "%-10ld",
+ status.st_size);
+ memcpy (hdr->ar_fmag, ARFMAG, 2);