Subject: catopen doesn't work on NetBSD/Alpha
To: None <port-alpha@NetBSD.ORG>
From: John Birrell <cimaxp1!jb@melb.werple.net.au>
List: port-alpha
Date: 05/28/1996 12:58:12
G'day,
The latest changes to catopen have broken message catalog support on
NetBSD/Alpha. The magic number check fails. There are also a number of
places where the function _catopen (and hence catopen) returns (nl_catd) 0
instead of (nl_catd) -1 as the man page says it should.
Attached are diffs to fix these problems.
Regards,
--
John Birrell CIMlogic Pty Ltd
jb@cimlogic.com.au 119 Cecil Street
Ph +61 3 9690 6900 South Melbourne Vic 3205
Fax +61 3 9690 6650 Australia
Mob +61 18 353 137
=========================================================================
*** src/lib/libc/nls/catopen.c Tue May 14 21:43:43 1996
--- locsrc/lib/libc/nls/catopen.c Tue May 28 12:43:34 1996
***************
*** 70,76 ****
/* absolute or relative path? */
if (strchr (name, '/')) {
if (stat (name, &st)) {
! return (nl_catd) 0;
}
path = name;
} else {
--- 70,76 ----
/* absolute or relative path? */
if (strchr (name, '/')) {
if (stat (name, &st)) {
! return (nl_catd) -1;
}
path = name;
} else {
***************
*** 113,133 ****
}
}
! return (nl_catd) 0;
}
load_msgcat:
if ((fd = open (path, O_RDONLY)) == -1)
! return (nl_catd) 0;
if (fstat(fd, &st) != 0) {
close (fd);
! return (nl_catd) 0;
}
if ((catd = malloc (sizeof (*catd))) == 0) {
close (fd);
! return (nl_catd) 0;
}
catd->__data = mmap(0, (size_t) st.st_size, PROT_READ, MAP_SHARED, fd, 0);
--- 113,133 ----
}
}
! return (nl_catd) -1;
}
load_msgcat:
if ((fd = open (path, O_RDONLY)) == -1)
! return (nl_catd) -1;
if (fstat(fd, &st) != 0) {
close (fd);
! return (nl_catd) -1;
}
if ((catd = malloc (sizeof (*catd))) == 0) {
close (fd);
! return (nl_catd) -1;
}
catd->__data = mmap(0, (size_t) st.st_size, PROT_READ, MAP_SHARED, fd, 0);
***************
*** 135,141 ****
if (catd->__data == (void *) -1) {
free (catd);
! return (nl_catd) 0;
}
catd->__size = st.st_size;
--- 135,141 ----
if (catd->__data == (void *) -1) {
free (catd);
! return (nl_catd) -1;
}
catd->__size = st.st_size;
***************
*** 143,149 ****
if (ntohl(cat_hdr->__magic) != _NLS_MAGIC) {
free (catd);
close (fd);
! return (nl_catd) 0;
}
return catd;
--- 143,149 ----
if (ntohl(cat_hdr->__magic) != _NLS_MAGIC) {
free (catd);
close (fd);
! return (nl_catd) -1;
}
return catd;
*** src/include/nl_types.h Tue May 14 21:41:18 1996
--- locsrc/include/nl_types.h Tue May 28 12:44:56 1996
***************
*** 57,63 ****
#define _NLS_MAGIC 0xff88ff89
struct _nls_cat_hdr {
! int32_t __magic;
int32_t __nsets;
int32_t __mem;
int32_t __msg_hdr_offset;
--- 57,63 ----
#define _NLS_MAGIC 0xff88ff89
struct _nls_cat_hdr {
! u_int32_t __magic;
int32_t __nsets;
int32_t __mem;
int32_t __msg_hdr_offset;