about summary refs log tree commit diff
path: root/misc
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-01-21 10:01:05 +0000
committerRoland McGrath <roland@gnu.org>1996-01-21 10:01:05 +0000
commitbbed653cda6007426e8291a5d32963552cc4f417 (patch)
tree881a95cad53014826d7906027926e00bc45dbca3 /misc
parenteb63bdd072eafe6aba40d254a71fd87285f497da (diff)
downloadglibc-bbed653cda6007426e8291a5d32963552cc4f417.tar.gz
glibc-bbed653cda6007426e8291a5d32963552cc4f417.tar.xz
glibc-bbed653cda6007426e8291a5d32963552cc4f417.zip
Sun Jan 21 00:55:25 1996 Roland McGrath <roland@churchy.gnu.ai.mit.edu> cvs/libc-960121
	* sysdeps/unix/sysv/linux/shmat.c: Include sys/shm.h instead of
	sys/sem.h.

	* stdlib/stdlib.h [__USE_SVID]: Declare a64l, l64a.

	* stdlib/l64a.c: Use 6-bit numbers as indices in CONV_TABLE, not
	literal byte values.

	* misc/bsd-compat.c (getpgrp): Define with prototype.

	* misc/init-misc.c (__progname_full): New variable.
	(program_invocation_name, program_invocation_short_name): New aliases.
	(__init_misc): Define with prototype.  Set __progname_full.
	* misc/progname.c: File removed.
	* misc/Makefile (aux): Remove progname.

	* misc/hsearch_r.c (isprime): Define with prototype.

	* sysdeps/unix/sysv/linux/seteuid.c: Just include unix/bsd version.
	* sysdeps/unix/bsd/seteuid.c: Disallow arg of -1.
	* sysdeps/unix/bsd/setegid.c: Likewise.
Diffstat (limited to 'misc')
-rw-r--r--misc/Makefile2
-rw-r--r--misc/bsd-compat.c5
-rw-r--r--misc/error.c21
-rw-r--r--misc/hsearch_r.c21
-rw-r--r--misc/init-misc.c16
-rw-r--r--misc/progname.c53
6 files changed, 33 insertions, 85 deletions
diff --git a/misc/Makefile b/misc/Makefile
index 775d6c6bb3..4a5546634e 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -53,7 +53,7 @@ routines := brk sbrk sstk ioctl \
 	    efgcvt efgcvt_r \
 	    hsearch hsearch_r tsearch \
 	    err error
-aux := progname init-misc
+aux := init-misc
 distribute := bsd-compat.c
 extra-objs := bsd-compat.o
 install-lib := libbsd-compat.a libg.a
diff --git a/misc/bsd-compat.c b/misc/bsd-compat.c
index 2bcef9f9d4..ad593b9e1c 100644
--- a/misc/bsd-compat.c
+++ b/misc/bsd-compat.c
@@ -1,6 +1,6 @@
 /* BSD-compatible versions of functions where BSD and POSIX.1 conflict.
 
-Copyright (C) 1991, 1992, 1994, 1995 Free Software Foundation, Inc.
+Copyright (C) 1991, 1992, 1994, 1995, 1996 Free Software Foundation, Inc.
 This file is part of the GNU C Library.
 
 The GNU C Library is free software; you can redistribute it and/or
@@ -25,8 +25,7 @@ Cambridge, MA 02139, USA.  */
 extern pid_t __getpgid __P ((pid_t));
 
 pid_t
-getpgrp (pid)
-     pid_t pid;
+getpgrp (pid_t pid)
 {
   return __getpgid (pid);
 }
diff --git a/misc/error.c b/misc/error.c
index da3c6ee1b2..cdba470656 100644
--- a/misc/error.c
+++ b/misc/error.c
@@ -1,5 +1,5 @@
 /* error.c -- error handler for noninteractive utilities
-   Copyright (C) 1990, 91, 92, 93, 94, 95 Free Software Foundation, Inc.
+   Copyright (C) 1990, 91, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
 
 This file is part of the GNU C Library.  Its master source is NOT part of
 the C library, however.  The master source lives in /gd/gnu/lib.
@@ -47,23 +47,27 @@ Cambridge, MA 02139, USA.  */
 void exit ();
 #endif
 
-/* This variable is incremented each time `error' is called.  */
-unsigned int error_message_count;
-
 /* If NULL, error will flush stdout, then print on stderr the program
    name, a colon and a space.  Otherwise, error will call this
    function without parameters instead.  */
-void (*error_print_progname) () = NULL;
+void (*error_print_progname) ();
+
+/* This variable is incremented each time `error' is called.  */
+unsigned int error_message_count;
 
 #ifdef _LIBC
+/* In the GNU C library, there is a predefined variable for this.  */
+
 #define program_name program_invocation_name
-#endif
+#include <errno.h>
+
+#else
 
 /* The calling program should define program_name and set it to the
    name of the executing program.  */
 extern char *program_name;
 
-#if HAVE_STRERROR || _LIBC
+#if HAVE_STRERROR
 # ifndef strerror		/* On some systems, strerror is a macro */
 char *strerror ();
 # endif
@@ -80,7 +84,8 @@ private_strerror (errnum)
   return "Unknown system error";
 }
 #define strerror private_strerror
-#endif
+#endif	/* HAVE_STRERROR */
+#endif	/* _LIBC */
 
 /* Print the program name and error message MESSAGE, which is a printf-style
    format string with optional args.
diff --git a/misc/hsearch_r.c b/misc/hsearch_r.c
index 5ea1d5e6c8..86dbe793c0 100644
--- a/misc/hsearch_r.c
+++ b/misc/hsearch_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
 Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>
 This file is part of the GNU C Library.
 
@@ -31,7 +31,7 @@ Boston, MA 02111-1307, USA.  */
    Instead the interface of all functions is extended to take an argument
    which describes the current status.  */
 typedef struct _ENTRY
-{ 
+{
   int   used;
   ENTRY entry;
 }
@@ -44,8 +44,7 @@ _ENTRY;
    a)  the code is (most probably) called a few times per program run and
    b)  the number is small because the table must fit in the core  */
 static int
-isprime (number)
-     unsigned int number;
+isprime (unsigned int number)
 {
   /* no even number will be passed */
   unsigned int div = 3;
@@ -61,7 +60,7 @@ isprime (number)
    Test for an existing table are done. We allocate one element
    more as the found prime number says. This is done for more effective
    indexing as explained in the comment for the hsearch function.
-   The contents of the table is zeroed, especially the field used 
+   The contents of the table is zeroed, especially the field used
    becomes zero.  */
 int
 hcreate_r (nel, htab)
@@ -114,7 +113,7 @@ hdestroy_r (htab)
     /* free used memory */
     free (htab->table);
 
-  /* the sign for an existing table is an value != NULL in htable */ 
+  /* the sign for an existing table is an value != NULL in htable */
   htab->table = NULL;
 }
 
@@ -124,7 +123,7 @@ hdestroy_r (htab)
    probably strings of chars. The function for generating a number of the
    strings is simple but fast. It can be replaced by a more complex function
    like ajw (see [Aho,Sethi,Ullman]) if the needs are shown.
-  
+
    We use an trick to speed up the lookup. The table is created by hcreate
    with one more element available. This enables us to use the index zero
    special. This index will never be used because we store the first hash
@@ -144,7 +143,7 @@ hsearch_r (item, action, retval, htab)
   unsigned int len = strlen (item.key);
   unsigned int idx;
 
-  /* If table is full and another entry should be entered return with 
+  /* If table is full and another entry should be entered return with
      error.  */
   if (action == ENTER && htab->filled == htab->size)
     {
@@ -178,7 +177,7 @@ hsearch_r (item, action, retval, htab)
       if (htab->table[idx].used == hval
 	  && strcmp (item.key, htab->table[idx].entry.key) == 0)
 	{
-          if (action == ENTER) 
+          if (action == ENTER)
 	    htab->table[idx].entry.data = item.data;
 
 	  *retval = &htab->table[idx].entry;
@@ -187,7 +186,7 @@ hsearch_r (item, action, retval, htab)
 
       /* Second hash function, as suggested in [Knuth] */
       hval2 = 1 + hval % (htab->size - 2);
-	
+
       do
 	{
 	  /* Because SIZE is prime this guarantees to step through all
@@ -201,7 +200,7 @@ hsearch_r (item, action, retval, htab)
           if (htab->table[idx].used == hval
 	      && strcmp (item.key, htab->table[idx].entry.key) == 0)
 	    {
-              if (action == ENTER) 
+              if (action == ENTER)
 	        htab->table[idx].entry.data = item.data;
 
 	      *retval = &htab->table[idx].entry;
diff --git a/misc/init-misc.c b/misc/init-misc.c
index 9fb876beb0..44531a5e77 100644
--- a/misc/init-misc.c
+++ b/misc/init-misc.c
@@ -1,5 +1,5 @@
 /* Define and initialize `__progname'.
-Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
 This file is part of the GNU C Library.
 
 The GNU C Library is free software; you can redistribute it and/or
@@ -18,14 +18,15 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
 #include <string.h>
+#include <errno.h>
 
+char *__progname_full = (char *) "";
 char *__progname = (char *) "";
+weak_alias (__progname_full, program_invocation_name)
+weak_alias (__progname, program_invocation_short_name)
 
 void
-__init_misc (argc, argv, envp)
-     int argc;
-     char **argv;
-     char **envp;
+__init_misc (int argc, char **argv, char **envp)
 {
   if (argv && argv[0])
     {
@@ -34,9 +35,6 @@ __init_misc (argc, argv, envp)
 	__progname = argv[0];
       else
 	__progname = p + 1;
+      __progname_full = argv[0];
     }
 }
-
-#ifdef HAVE_GNU_LD
-text_set_element (__libc_subinit, __init_misc);
-#endif
diff --git a/misc/progname.c b/misc/progname.c
deleted file mode 100644
index d4efac976d..0000000000
--- a/misc/progname.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
-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 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., 675 Mass Ave,
-Cambridge, MA 02139, USA.  */
-
-#ifdef	HAVE_GNU_LD
-
-#include <ansidecl.h>
-#include <string.h>
-
-/* These must be initialized data definitions.  Common definitions satisfy
-   references to these variables, but do not cause the whole file to be
-   linked in, and so omit the set-up function.  */
-char *program_invocation_name = NULL;
-char *program_invocation_short_name = NULL;
-
-static void
-DEFUN(set_progname, (argc, argv, envp),
-      int argc AND char **argv AND char **envp)
-{
-  char *p;
-
-  if (argv && argv[0])
-    {
-      program_invocation_name = argv[0];
-      p = strrchr (argv[0], '/');
-      if (p == NULL)
-	program_invocation_short_name = argv[0];
-      else
-	program_invocation_short_name = p + 1;
-    }
-  else
-    program_invocation_name = program_invocation_short_name = 0;
-
-  (void) &set_progname;		/* Avoid "defined but not used" warning.  */
-}
-
-text_set_element (__libc_subinit, set_progname);
-
-#endif