aboutsummaryrefslogtreecommitdiff
path: root/hurd
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-05-01 13:55:18 +0000
committerRoland McGrath <roland@gnu.org>1996-05-01 13:55:18 +0000
commit75cd5204dd829d849a6e41380a64cf61d7f406d0 (patch)
tree8d821a60b9fd42bf4965b49faf5e6d13f7cebee3 /hurd
parent5bd44955948a63ea9a71726fb2b8b54b970aeb66 (diff)
downloadglibc-75cd5204dd829d849a6e41380a64cf61d7f406d0.tar
glibc-75cd5204dd829d849a6e41380a64cf61d7f406d0.tar.gz
glibc-75cd5204dd829d849a6e41380a64cf61d7f406d0.tar.bz2
glibc-75cd5204dd829d849a6e41380a64cf61d7f406d0.zip
Wed May 1 09:10:04 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* time/strftime.c: Use canonical autoconf nugget for time.h+sys/time.h include. Mon Apr 29 02:48:26 1996 Ulrich Drepper <drepper@cygnus.com> * ctype/ctype-info.c: (__ctype_width): New variable. (__ctype_names): Initialize correctly without offset. * locale/C-collate.c, locale/C-ctype.c, locale/C-messages.c, locale/C-monetary.c, locale/C-numeric.c, locale/C-time.c: Change copyright. * locale/C-ctype.c (_nl_C_LC_CTYPE_class32): Correct endianess for initialization value. * locale/lc-ctype.c (current): Add parameter for offset. (__ctype32_b, __ctype_width): Add initialization for these variables. * locale/programs/charmap.c: Finish support for WIDTH information. (new_width): New function. * locale/programs/charset.h (width_rule): new data structure. (charset_t): Add elements for width information. * locale/programs/ld-ctype.c (locale_ctype_t): Add element for width information. (allocate_arrays): Add new argument for charset. (ctype_finish): Make sure all characters named in charset width table are known to name table. (ctype_output): Correct handling of class and map name information and write out width information. (find_idx): Prepare for being called with NULL pointer as TABLE argument. This means only allocate name entry. (allocate_arrays): Correct handling of array element -1. Because EOF == -1 the value of element 127 must *not* be mirrored here. Fill width information from charset tables. * locale/programs/localedef.c (main): Correct loop over all categories after change of order from Thu Mar 28 14:22:51 1996. Add new charset argument to call of `write_all_categories'. * locale/programs/locales.h (ctype_finish, ctype_output): New charset argument. * locale/programs/locfile.c (write_all_categories): Call `ctype_output' with additional argument charset. * posix/getconf.c (vars): Add _POSIX_SYNC_IO, _POSIX_ASYNC_IO, and _POSIX_PRIO_IO definitions. * posix/posix2_lim.h: Add definition of _POSIX2_CHARCLASS_NAME_MAX and CHARCLASS_NAME_MAX. * posix/unistd.h: Document _POSIX_SYNC_IO, _POSIX_ASYNC_IO, and _POSIX_PRIO_IO. * stdlib/grouping.h: Prepare for use in wide string functions. * stdlib/stdlib.h: Correct prototypes for __strto*_internal functions. * stdlib/strtod.c: Extend for use as `wcsto{f,d,ld}'. * stdlib/strtol.c: Extend for use as `wcsto{l,ul,q,uq}'. * string/strcoll.c: Extend for use as `wcscoll'. * string/strxfrm.c: Extend for use as `wcsxfrm'. * sysdeps/generic/confname.h: Add definition of _PC_SYNC_IO, _PC_ASYNC_IO, _PC_PRIO_IO and _SC_CHARCLASS_NAME_MAX. * sysdeps/generic/stpncpy.c: Correct return value. * sysdeps/posix/fpathconf.c: Add handling of _PC_SYNC_IO, _PC_ASYNC_IO, and _PC_PRIO_IO. * sysdeps/posix/sysconf.c: Add handling of _SC_REALTIME_SIGNALS, _SC_PRIORITY_SCHEDULING, _SC_TIMERS, _SC_ASYNCHRONOUS_IO, _SC_PRIORITIZED_IO, _SC_SYNCHRONIZED_IO, _SC_FSYNC, _SC_MAPPED_FILES, _SC_MEMLOCK, _SC_MEMLOCK_RANGE, _SC_MEMORY_PROTECTION, _SC_MESSAGE_PASSING, _SC_SEMAPHORES, _SC_SHARED_MEMORY_OBJECTS, and _SC_CHARCLASS_NAME_MAX. * sysdeps/stub/sysconf.c: Ditto. * sysdeps/unix/sysv/sysv4/sysconf.c: Ditto. * sysdeps/unix/sysv/linux/Dist: Add sys/sysctl.h. * sysdeps/unix/sysv/linux/Makefile [subdir == misc] (sysdep_routines): Add s_sysctl and sysctl. * sysdeps/unix/sysv/linux/sys/mman.h: Add declaration of mremap. * sysdeps/unix/sysv/linux/sys/socket.h: New file. Wrapper around kernel header. * sysdeps/unix/sysv/linux/sys/sysctl.h: New file. Define interface to `sysctl' function. * sysdeps/unix/sysv/linux/syscalls.list: Add mremap and _sysctl. * sysdeps/unix/sysv/linux/sysconf.c: Add handling of _SC_CHARCLASS_NAME_MAX. * sysdeps/unix/sysv/linux/sysctl.c: new file. Implement caller of _sysctl system call. * sysvipc/Makefile (routines): Add ftok. * sysvipc/ftok.c: use variable `proj_id' not `id'. Patch by David Mosberger-Tang. * wcsmbs/Makefile (routines): Add wcpcpy, wcpncpy, wcstol, wcstoul, wcstoq, wcstouq, wcstod, wcstold, wcstof, wcscoll, wcsxfrm, wcwidth, and wcswidth. * wcsmbs/wchar.h: Add declarations for wcpcpy, wcpncpy, wcstol, wcstoul, wcstoq, wcstouq, wcstod, wcstold, wcstof, wcscoll, wcsxfrm, wcwidth, and wcswidth. Declare internal interfaces for wcsto* functions. [OPTIMIZE]: Define inline functions for wcsto* functions to call internal interface functions. * wcsmbs/wcpcpy.c, wcsmbs/wcpncpy.c: New files. Implement non- standard function equivalent to stpcpy/stpncpy. * wcsmbs/wcscoll.c: Implement `wcscoll' function by using `strcoll' implementation. * wcsmbs/wcscpy.c, wcsmbs/wcsncpy.c: Use wint_t instead of wchar_t. * wcsmbs/wcstod.c: Implement `wcstod' function by using `strtod' implementation. * wcsmbs/wcstof.c: Same for `wcstof'. * wcsmbs/wcstold.c: Same for `strtold'. * wcsmbs/wcstol.c: Implement `wcstol' function by using `strtol' implementation. * wcsmbs/wcstoq.c: Same for `wcstoq'. * wcsmbs/wcstoul.c: Same for `wcstoul'. * wcsmbs/wcstouq.c: Same for `wcstouq'. * wcsmbs/wcswidth.c: Implement `wcswidth' function from X/Open CAE. * wcsmbs/wcwidth.c: Ditto for `wcwidth'. * wcsmbs/wcwidth.h: Common function for definitions of above two functions. * wcsmbs/wcsxfrm.c: Implement `wcsxfrm function by using `strxfrm implementation. * wctype/wctype.c: Remove case for `wctype_t' being 16 bit type. * wctype/wctype.h (wint_t): Protect against multiple definition. (wctype_t): Always define as `unsigned long int'. * wctype.h: New file. Wrapper around wctype/wctype.h. * hurd/hurdstartup.c (_hurd_split_args): Function removed. (_hurd_startup): Use argz functions. * hurd/hurdexec.c: Use argz functions.
Diffstat (limited to 'hurd')
-rw-r--r--hurd/hurdexec.c43
-rw-r--r--hurd/hurdstartup.c46
2 files changed, 17 insertions, 72 deletions
diff --git a/hurd/hurdexec.c b/hurd/hurdexec.c
index 149e95ccec..7893c9177b 100644
--- a/hurd/hurdexec.c
+++ b/hurd/hurdexec.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 94, 95, 96 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,6 +25,7 @@ Cambridge, MA 02139, USA. */
#include <hurd.h>
#include <hurd/fd.h>
#include <hurd/signal.h>
+#include <argz.h>
/* Overlay TASK, executing FILE with arguments ARGV and environment ENVP.
If TASK == mach_task_self (), some ports are dealloc'd by the exec server.
@@ -47,36 +48,10 @@ _hurd_exec (task_t task, file_t file,
struct hurd_sigstate *ss;
mach_port_t *please_dealloc, *pdp;
-
- /* Pack the arguments into an array with nulls separating the elements. */
- argslen = 0;
- if (argv != NULL)
- {
- p = argv;
- while (*p != NULL)
- argslen += strlen (*p++) + 1;
- args = __alloca (argslen);
- ap = args;
- for (p = argv; *p != NULL; ++p)
- ap = __memccpy (ap, *p, '\0', ULONG_MAX);
- }
- else
- args = NULL;
-
- /* Pack the environment into an array with nulls separating elements. */
- envlen = 0;
- if (envp != NULL)
- {
- p = envp;
- while (*p != NULL)
- envlen += strlen (*p++) + 1;
- env = __alloca (envlen);
- ap = env;
- for (p = envp; *p != NULL; ++p)
- ap = __memccpy (ap, *p, '\0', ULONG_MAX);
- }
- else
- env = NULL;
+ if (err = __argz_create (argv, &args, &argslen))
+ return err;
+ if (err = __argz_create (envp, &env, &envlen))
+ goto outargs;
/* Load up the ports to give to the new program. */
for (i = 0; i < _hurd_nports; ++i)
@@ -88,7 +63,7 @@ _hurd_exec (task_t task, file_t file,
{
while (--i > 0)
_hurd_port_free (&_hurd_ports[i], &ulink_ports[i], ports[i]);
- return err;
+ goto outenv;
}
}
else
@@ -254,5 +229,9 @@ _hurd_exec (task_t task, file_t file,
__msg_sig_post (_hurd_msgport, 0, __mach_task_self ());
}
+ outargs:
+ free (args);
+ outenv:
+ free (env);
return err;
}
diff --git a/hurd/hurdstartup.c b/hurd/hurdstartup.c
index ca44737ce3..17a7705847 100644
--- a/hurd/hurdstartup.c
+++ b/hurd/hurdstartup.c
@@ -1,5 +1,5 @@
/* Initial program startup for running under the GNU Hurd.
-Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+Copyright (C) 1991, 92, 93, 94, 95, 96 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
@@ -30,6 +30,7 @@ Cambridge, MA 02139, USA. */
#include "set-hooks.h"
#include "hurdmalloc.h" /* XXX */
#include "hurdstartup.h"
+#include <argz.h>
mach_port_t *_hurd_init_dtable;
mach_msg_type_number_t _hurd_init_dtablesize;
@@ -45,9 +46,6 @@ unsigned long int *__hurd_sigthread_variables;
extern void __mach_init (void);
-int _hurd_split_args (char *, size_t, char **);
-
-
/* Entry point. This is the first thing in the text segment.
The exec server started the initial thread in our task with this spot the
@@ -125,9 +123,9 @@ _hurd_startup (void **argptr, void (*main) (int *data))
arguments and environment into vectors of pointers to strings. */
/* Count up the arguments so we can allocate ARGV. */
- argc = _hurd_split_args (args, argslen, NULL);
+ argc = __argz_count (args, argslen);
/* Count up the environment variables so we can allocate ENVP. */
- envc = _hurd_split_args (env, envlen, NULL);
+ envc = __argz_count (env, envlen);
/* There were some arguments. Allocate space for the vectors of
pointers and fill them in. We allocate the space for the
@@ -138,11 +136,11 @@ _hurd_startup (void **argptr, void (*main) (int *data))
sizeof (struct hurd_startup_data));
*argcptr = argc;
argv = (void *) (argcptr + 1);
- _hurd_split_args (args, argslen, argv);
+ __argz_extract (args, argslen, argv);
/* There was some environment. */
envp = &argv[argc + 1];
- _hurd_split_args (env, envlen, envp);
+ __argz_extract (env, envlen, envp);
}
if (err || in_bootstrap == MACH_PORT_NULL)
@@ -197,35 +195,3 @@ _hurd_startup (void **argptr, void (*main) (int *data))
LOSE;
abort ();
}
-
-/* Split ARGSLEN bytes at ARGS into words, breaking at NUL characters. If
- ARGV is not a null pointer, store a pointer to the start of each word in
- ARGV[n], and null-terminate ARGV. Return the number of words split. */
-
-int
-_hurd_split_args (char *args, size_t argslen, char **argv)
-{
- char *p = args;
- size_t n = argslen;
- int argc = 0;
-
- while (n > 0)
- {
- char *end = memchr (p, '\0', n);
-
- if (argv)
- argv[argc] = p;
- ++argc;
-
- if (end == NULL)
- /* The last argument is unterminated. */
- break;
-
- n -= end + 1 - p;
- p = end + 1;
- }
-
- if (argv)
- argv[argc] = NULL;
- return argc;
-}