about summary refs log tree commit diff
path: root/catgets
diff options
context:
space:
mode:
Diffstat (limited to 'catgets')
-rw-r--r--catgets/catgets.c43
-rw-r--r--catgets/nl_types.h32
-rw-r--r--catgets/open_catalog.c28
3 files changed, 57 insertions, 46 deletions
diff --git a/catgets/catgets.c b/catgets/catgets.c
index 7c45b4569a..ab7d28a682 100644
--- a/catgets/catgets.c
+++ b/catgets/catgets.c
@@ -1,23 +1,24 @@
 /* Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
 
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Library General Public License for more details.
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 #include <alloca.h>
+#include <errno.h>
 #include <nl_types.h>
 #include <stdlib.h>
 #include <string.h>
@@ -45,6 +46,7 @@ catopen (const char *cat_name, int flag)
   if (result->cat_name == NULL)
     {
       free (result);
+      __set_errno (ENOMEM);
       return (nl_catd) -1;
     }
 
@@ -76,6 +78,7 @@ catopen (const char *cat_name, int flag)
 	{
 	  free ((void *) result->cat_name);
 	  free ((void *) result);
+	  __set_errno (ENOMEM);
 	  return (nl_catd) -1;
 	}
 
@@ -89,6 +92,7 @@ catopen (const char *cat_name, int flag)
 	  free ((void *) result->cat_name);
 	  free ((void *) result->env_var);
 	  free ((void *) result);
+	  __set_errno (ENOMEM);
 	  return (nl_catd) -1;
 	}
     }
@@ -120,7 +124,10 @@ catgets (nl_catd catalog_desc, int set, int message, const char *string)
     __open_catalog (catalog, 1);
 
   if (catalog->status == nonexisting)
-    return (char *) string;
+    {
+      __set_errno (EBADF);
+      return (char *) string;
+    }
 
   idx = ((set * message) % catalog->plane_size) * 3;
   cnt = 0;
@@ -134,6 +141,7 @@ catgets (nl_catd catalog_desc, int set, int message, const char *string)
     }
   while (++cnt < catalog->plane_depth);
 
+  __set_errno (ENOMSG);
   return (char *) string;
 }
 
@@ -151,7 +159,10 @@ catclose (nl_catd catalog_desc)
   else if (catalog->status == malloced)
     free ((void *) catalog->file_ptr);
   else if (catalog->status != closed && catalog->status != nonexisting)
-    return -1;
+    {
+      __set_errno (EBADF);
+      return -1;
+    }
 
   if (catalog->nlspath)
     free ((void *) catalog->nlspath);
diff --git a/catgets/nl_types.h b/catgets/nl_types.h
index 9f78d67468..40fb965508 100644
--- a/catgets/nl_types.h
+++ b/catgets/nl_types.h
@@ -1,20 +1,20 @@
 /* Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
 
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Library General Public License for more details.
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 #ifndef _NL_TYPES_H
 #define _NL_TYPES_H 1
@@ -26,12 +26,12 @@ Boston, MA 02111-1307, USA.  */
 /* Value for FLAG parameter of `catgets' to say we want XPG4 compliance.  */
 #define NL_CAT_LOCALE 1
 
-/* Message catalog descriptor type.  */
-typedef void *nl_catd;
-
 
 __BEGIN_DECLS
 
+/* Message catalog descriptor type.  */
+typedef void *nl_catd;
+
 /* Open message catalog for later use, returning descriptor.  */
 extern nl_catd catopen __P ((__const char *__cat_name, int __flag));
 
diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
index 2a52877bbe..5335b433c7 100644
--- a/catgets/open_catalog.c
+++ b/catgets/open_catalog.c
@@ -1,21 +1,21 @@
 /* Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
 
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Library General Public License for more details.
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
 
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 #include <endian.h>
 #include <fcntl.h>