diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 1998-04-30 16:49:02 +0000 |
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 1998-04-30 16:49:02 +0000 |
| commit | 21358676967547a6ca449cc9d1fb5a5438354e16 (patch) | |
| tree | 7c01e1bb97910b8929e00d9492cb39911deef883 /lib | |
| parent | 64824728db5291fe75fbad24a28ef7fa55ddf353 (diff) | |
Notes
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libc/nls/catclose.3 | 4 | ||||
| -rw-r--r-- | lib/libc/nls/catclose.c | 2 | ||||
| -rw-r--r-- | lib/libc/nls/catgets.3 | 7 | ||||
| -rw-r--r-- | lib/libc/nls/catgets.c | 6 | ||||
| -rw-r--r-- | lib/libc/nls/catopen.3 | 26 | ||||
| -rw-r--r-- | lib/libc/nls/catopen.c | 2 | ||||
| -rw-r--r-- | lib/libc/nls/msgcat.c | 57 |
7 files changed, 64 insertions, 40 deletions
diff --git a/lib/libc/nls/catclose.3 b/lib/libc/nls/catclose.3 index fc9c9afc41eb..1e79e5972363 100644 --- a/lib/libc/nls/catclose.3 +++ b/lib/libc/nls/catclose.3 @@ -1,4 +1,4 @@ -.\" $Id: catclose.3,v 1.4 1997/02/22 15:00:44 peter Exp $ +.\" $Id: catclose.3,v 1.5 1998/04/30 11:06:11 ache Exp $ .\" .\" Copyright (c) 1994 Winning Strategies, Inc. .\" All rights reserved. @@ -50,5 +50,5 @@ function closes the message catalog specified by the argument The .Fn catclose function conforms to -.St -xpg3 . +.St -xpg4 . diff --git a/lib/libc/nls/catclose.c b/lib/libc/nls/catclose.c index 341f6643aa80..46a09104d5eb 100644 --- a/lib/libc/nls/catclose.c +++ b/lib/libc/nls/catclose.c @@ -1,4 +1,4 @@ -/* $Id$ */ +/* $Id: catclose.c,v 1.3 1997/02/22 15:00:45 peter Exp $ */ /* * Written by J.T. Conklin, 10/05/94 diff --git a/lib/libc/nls/catgets.3 b/lib/libc/nls/catgets.3 index 186ea00599ff..0c27740b0231 100644 --- a/lib/libc/nls/catgets.3 +++ b/lib/libc/nls/catgets.3 @@ -1,4 +1,4 @@ -.\" $Id: catgets.3,v 1.1 1995/03/30 12:47:23 jkh Exp $ +.\" $Id: catgets.3,v 1.5 1998/04/30 11:06:12 ache Exp $ .\" .\" Copyright (c) 1994 Winning Strategies, Inc. .\" All rights reserved. @@ -37,7 +37,7 @@ .Sh SYNOPSIS .Fd #include <nl_types.h> .Ft char * -.Fn catgets "nl_catd catd" "int set_id" "int msg_id" "char *s" +.Fn catgets "nl_catd catd" "int set_id" "int msg_id" "const char *s" .Sh DESCRIPTION The .Fn catgets @@ -63,4 +63,5 @@ otherwise it returns .Sh STANDARDS The .Fn catgets -function conforms to \fBxpg3\fR. +function conforms to +.St -xpg4 . diff --git a/lib/libc/nls/catgets.c b/lib/libc/nls/catgets.c index c29cf6468414..1089ef168d5e 100644 --- a/lib/libc/nls/catgets.c +++ b/lib/libc/nls/catgets.c @@ -1,4 +1,4 @@ -/* $Id$ */ +/* $Id: catgets.c,v 1.4 1998/04/30 10:14:54 ache Exp $ */ /* * Written by J.T. Conklin, 10/05/94 @@ -13,14 +13,14 @@ __indr_reference(_catgets,catgets); #include <nl_types.h> -extern char * _catgets __P((nl_catd, int, int, char *)); +extern char * _catgets __P((nl_catd, int, int, __const char *)); char * catgets(catd, set_id, msg_id, s) nl_catd catd; int set_id; int msg_id; - char *s; + __const char *s; { return _catgets(catd, set_id, msg_id, s); } diff --git a/lib/libc/nls/catopen.3 b/lib/libc/nls/catopen.3 index 109829f0ddf3..6fa02d9fbf0c 100644 --- a/lib/libc/nls/catopen.3 +++ b/lib/libc/nls/catopen.3 @@ -1,4 +1,4 @@ -.\" $Id: catopen.3,v 1.1 1995/03/30 12:47:24 jkh Exp $ +.\" $Id: catopen.3,v 1.6 1998/04/30 16:11:50 ache Exp $ .\" .\" Copyright (c) 1994 Winning Strategies, Inc. .\" All rights reserved. @@ -57,9 +57,24 @@ is used with .Fa name substituted for %N. .Pp -The +If the +.Fa oflag +argument is set to the +.Dv NL_CAT_LOCALE +constant, +.Dv LC_MESSAGES +locale category used to open the message catalog; using +.Dv NL_CAT_LOCALE +conforms to the +.St -xpg4 +standard. You can specify 0 for compatibility with +.St -xpg3 ; +when .Fa oflag -argument is reserved for future use and should be set to zero. +is set to 0, the +.Ev LANG +environment variable +determines the message catalog locale. .Sh RETURN VALUE Upon successful completion, .Fn catopen @@ -74,9 +89,10 @@ Insufficient memory is available. .El .Sh SEE ALSO .Xr catclose 3 , -.Xr catgets 3 +.Xr catgets 3 , +.Xr setlocale 3 .Sh STANDARDS The .Fn catopen function conforms to -.St -xpg3 . +.St -xpg4 . diff --git a/lib/libc/nls/catopen.c b/lib/libc/nls/catopen.c index 5dfb727c5812..3e047fb8e9ed 100644 --- a/lib/libc/nls/catopen.c +++ b/lib/libc/nls/catopen.c @@ -1,4 +1,4 @@ -/* $Id$ */ +/* $Id: catopen.c,v 1.3 1997/02/22 15:00:49 peter Exp $ */ /* * Written by J.T. Conklin, 10/05/94 diff --git a/lib/libc/nls/msgcat.c b/lib/libc/nls/msgcat.c index 1b42edca6eae..9cb7b007a157 100644 --- a/lib/libc/nls/msgcat.c +++ b/lib/libc/nls/msgcat.c @@ -1,4 +1,4 @@ -/* $Id: msgcat.c,v 1.5.2.1 1997/05/14 00:17:50 ache Exp $ */ +/* $Id: msgcat.c,v 1.17 1998/04/30 13:15:31 ache Exp $ */ /*********************************************************** Copyright 1990, by Alfalfa Software Incorporated, Cambridge, Massachusetts. @@ -57,6 +57,7 @@ static char *rcsid = "$NetBSD: msgcat.c,v 1.11 1995/02/27 13:06:51 cgd Exp $"; #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> +#include <locale.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -79,7 +80,7 @@ static char *rcsid = "$NetBSD: msgcat.c,v 1.11 1995/02/27 13:06:51 cgd Exp $"; #define NLERR ((nl_catd) -1) static nl_catd loadCat(); -static nl_catd loadSet(); +static int loadSet(); nl_catd _catopen( name, type) __const char *name; @@ -97,10 +98,14 @@ int type; if (strchr(name, '/')) { catpath = name; - if (stat(catpath, &sbuf)) return(0); + if (stat(catpath, &sbuf)) return(NLERR); } else { - if ((lang = (char *) getenv("LANG")) == NULL) - lang = "C"; + if (type == NL_CAT_LOCALE) + lang = setlocale(LC_MESSAGES, NULL); + else { + if ((lang = (char *) getenv("LANG")) == NULL) + lang = "C"; + } if ((nlspath = (char *) getenv("NLSPATH")) == NULL #ifndef __NETBSD_SYSCALLS || issetugid() @@ -109,7 +114,7 @@ int type; nlspath = "/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L:/usr/local/share/nls/%L/%N.cat:/usr/local/share/nls/%N/%L"; len = strlen(nlspath); - base = cptr = (char *) malloc(len + 2); + base = cptr = malloc(len + 2); if (!base) return(NLERR); strcpy(cptr, nlspath); cptr[len] = ':'; @@ -141,10 +146,10 @@ int type; } free(base); - if (!catpath) return(0); + if (!catpath) return(NLERR); } - return(loadCat(catpath, type)); + return(loadCat(catpath)); } /* @@ -200,7 +205,8 @@ int setId; if (hi - lo == 1) cur += dir; else cur += ((hi - lo) / 2) * dir; } - if (set->invalid) loadSet(cat, set); + if (set->invalid) + (void) loadSet(cat, set); return(set); } @@ -241,20 +247,22 @@ int msgId; return(msg); } -char *_catgets( catd, setId, msgId, dflt) +char *_catgets( catd, setId, msgId, dflt) nl_catd catd; int setId; int msgId; -char *dflt; +__const char *dflt; { MCMsgT *msg; MCCatT *cat = (MCCatT *) catd; - char *cptr; + __const char *cptr; + if (catd == NULL || catd == NLERR) + return((char *)dflt); msg = MCGetMsg(MCGetSet(cat, setId), msgId); if (msg) cptr = msg->msg.str; else cptr = dflt; - return(cptr); + return((char *)cptr); } @@ -265,7 +273,7 @@ nl_catd catd; MCSetT *set; int i; - if (!cat) return -1; + if (catd == NULL || catd == NLERR) return -1; if (cat->loadType != MCLoadAll) close(cat->fd); for (i = 0; i < cat->numSets; ++i) { @@ -287,12 +295,11 @@ nl_catd catd; /* Note that only malloc failures are allowed to return an error */ #define ERRNAME "Message Catalog System" -#define CORRUPT() {fprintf(stderr, "%s: corrupt file.\n", ERRNAME); free(cat); return(0);} +#define CORRUPT() {fprintf(stderr, "%s: corrupt file.\n", ERRNAME); free(cat); return(NLERR);} #define NOSPACE() {fprintf(stderr, "%s: no more memory.\n", ERRNAME); free(cat); return(NLERR);} -static nl_catd loadCat( catpath, type) +static nl_catd loadCat(catpath) __const char *catpath; -int type; { MCHeaderT header; MCCatT *cat; @@ -302,11 +309,11 @@ int type; cat = (MCCatT *) malloc(sizeof(MCCatT)); if (!cat) return(NLERR); - cat->loadType = type; + cat->loadType = MCLoadBySet; if ((cat->fd = open(catpath, O_RDONLY)) < 0) { free(cat); - return(0); + return(NLERR); } (void)fcntl(cat->fd, F_SETFD, FD_CLOEXEC); @@ -319,14 +326,14 @@ int type; free(cat); fprintf(stderr, "%s: %s is version %ld, we need %ld.\n", ERRNAME, catpath, header.majorVer, MCMajorVer); - return(0); + return(NLERR); } if (header.numSets <= 0) { free(cat); fprintf(stderr, "%s: %s has %ld sets!\n", ERRNAME, catpath, header.numSets); - return(0); + return(NLERR); } cat->numSets = header.numSets; @@ -370,7 +377,7 @@ int type; } if (cat->loadType == MCLoadAll) { - nl_catd res; + int res; if ((res = loadSet(cat, set)) <= 0) { for (j = 0; j < i; j++) { @@ -381,7 +388,7 @@ int type; } } free(cat->sets); - if (res == -1) NOSPACE(); + if (res < 0) NOSPACE(); CORRUPT(); } } else set->invalid = True; @@ -394,7 +401,7 @@ int type; return((nl_catd) cat); } -static nl_catd loadSet( cat, set) +static int loadSet(cat, set) MCCatT *cat; MCSetT *set; { @@ -403,7 +410,7 @@ MCSetT *set; /* Get the data */ if (lseek(cat->fd, set->data.off, 0) == -1) return(0); - if ((set->data.str = (char *) malloc(set->dataLen)) == NULL) return(-1); + if ((set->data.str = malloc(set->dataLen)) == NULL) return(-1); if (read(cat->fd, set->data.str, set->dataLen) != set->dataLen) { free(set->data.str); return(0); } |
