summaryrefslogtreecommitdiffstats
path: root/lib/libc/nls
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1998-07-14 18:27:43 +0000
committerache <ache@FreeBSD.org>1998-07-14 18:27:43 +0000
commit3d028a61c9cbd9e22735cc460d8472f1b8178854 (patch)
treee8ae80ce280c428b872aa47375495a6d5148e8f9 /lib/libc/nls
parentebd3e5432105fc0393e24be0cd3f347301a0a1c7 (diff)
downloadFreeBSD-src-3d028a61c9cbd9e22735cc460d8472f1b8178854.zip
FreeBSD-src-3d028a61c9cbd9e22735cc460d8472f1b8178854.tar.gz
Provide meaningful errno value on error return
Diffstat (limited to 'lib/libc/nls')
-rw-r--r--lib/libc/nls/msgcat.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/libc/nls/msgcat.c b/lib/libc/nls/msgcat.c
index b6ac8aa..ff0ddd6 100644
--- a/lib/libc/nls/msgcat.c
+++ b/lib/libc/nls/msgcat.c
@@ -1,4 +1,4 @@
-/* $Id: msgcat.c,v 1.16 1998/04/30 12:25:05 ache Exp $ */
+/* $Id: msgcat.c,v 1.17 1998/04/30 13:15:31 ache Exp $ */
/***********************************************************
Copyright 1990, by Alfalfa Software Incorporated, Cambridge, Massachusetts.
@@ -56,6 +56,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 <errno.h>
#include <fcntl.h>
#include <locale.h>
#include <stdio.h>
@@ -94,7 +95,10 @@ int type;
char *base, *cptr, *pathP;
struct stat sbuf;
- if (!name || !*name) return(NLERR);
+ if (!name || !*name) {
+ errno = EINVAL;
+ return(NLERR);
+ }
if (strchr(name, '/')) {
catpath = name;
@@ -146,7 +150,10 @@ int type;
}
free(base);
- if (!catpath) return(NLERR);
+ if (!catpath) {
+ errno = ENOENT;
+ return(NLERR);
+ }
}
return(loadCat(catpath));
@@ -273,7 +280,10 @@ nl_catd catd;
MCSetT *set;
int i;
- if (catd == NULL || catd == NLERR) return -1;
+ if (catd == NULL || catd == NLERR) {
+ errno = EBADF;
+ return -1;
+ }
if (cat->loadType != MCLoadAll) close(cat->fd);
for (i = 0; i < cat->numSets; ++i) {
@@ -295,7 +305,7 @@ 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(NLERR);}
+#define CORRUPT() {fprintf(stderr, "%s: corrupt file.\n", ERRNAME); free(cat); errno = EINVAL; return(NLERR);}
#define NOSPACE() {fprintf(stderr, "%s: no more memory.\n", ERRNAME); free(cat); return(NLERR);}
static nl_catd loadCat(catpath)
@@ -326,6 +336,7 @@ __const char *catpath;
free(cat);
fprintf(stderr, "%s: %s is version %ld, we need %ld.\n", ERRNAME,
catpath, header.majorVer, MCMajorVer);
+ errno = EINVAL;
return(NLERR);
}
@@ -333,6 +344,7 @@ __const char *catpath;
free(cat);
fprintf(stderr, "%s: %s has %ld sets!\n", ERRNAME, catpath,
header.numSets);
+ errno = EINVAL;
return(NLERR);
}
OpenPOWER on IntegriCloud