char *realloc ();
#endif
+char *xstrdup ();
+
static int readname ();
/* List of shells to use if the shells file is missing. */
static int line_size = 0;
\f
/* Return an entry from the shells file, ignoring comment lines.
+ If the file doesn't exist, use the list in DEFAULT_SHELLS (above).
+ In any case, the returned string is in memory allocated through malloc.
Return NULL if there are no more entries. */
char *
{
if (default_shells[default_index])
/* Not at the end of the list yet. */
- return default_shells[default_index++];
+ return xstrdup (default_shells[default_index++]);
return NULL;
}
{
/* No shells file. Use the default list. */
default_index = 1;
- return default_shells[0];
+ return xstrdup (default_shells[0]);
}
}
/* Don't include stdlib.h for non-GNU C libraries because some of them
contain conflicting prototypes for getopt. */
#include <stdlib.h>
+#else
+char *malloc ();
#endif /* GNU C library. */
#ifndef STDC_HEADERS
char **new_environ = (char **) malloc ((size + 2) * sizeof (char *));
if (new_environ == NULL)
return -1;
- (void) bcopy ((char *) environ, (char *) new_environ, size * sizeof (char *));
+ (void) bcopy ((char *) environ, (char *) new_environ,
+ size * sizeof (char *));
new_environ[size] = (char *) string;
new_environ[size + 1] = NULL;
if (last_environ != NULL)
+Sun Oct 24 14:10:23 1993 Jim Meyering (meyering@comco.com)
+
+ * long-options.c: Save and restore optind, too.
+ * long-options.h: New file.
+ * long-options.c, echo.c, expr.c, printf.c, test.c, yes.c:
+ Include it instead of duplicating dcls.
+ * src/Makefile.in: Add dependencies for it.
+
+Tue Oct 19 00:26:27 1993 Jim Meyering (meyering@comco.com)
+
+ * expr.c [!__STDC__]: Don't define away `const'. configure alone
+ decides whether to do that. From Francois Pinard.
+
Sat Oct 16 22:32:54 1993 Jim Meyering (meyering@comco.com)
* whoami.c (main): Cast printf arg UID so it matches the type
program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
{
program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
#include <stdio.h>
#include <sys/types.h>
#include "system.h"
+#include "long-options.h"
/* echo [-neE] [arg ...]
Output the ARGs. If -n is specified, the trailing newline is
/* The name this program was run with. */
char *program_name;
-void parse_long_options ();
-
static void
usage (status)
int status;
program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
\n\
-u, --unset NAME remove variable from the environment\n\
-i, --ignore-environment start with an empty environment\n\
- --help display this help and exit\n\
- --version output version information and exit\n\
+ --help display this help and exit\n\
+ --version output version information and exit\n\
\n\
A mere - implies -i. If no COMMAND, print the resulting environment.\n\
");
#include "system.h"
#include "version.h"
+#include "long-option.h"
#if !defined (isascii) || defined (STDC_HEADERS)
#undef isascii
#define ISDIGIT(c) (isascii (c) && isdigit (c))
-#if !__STDC__
-#define const
-#endif
-
#define NEW(type) ((type *) xmalloc (sizeof (type)))
#define OLD(x) free ((char *) x)
char *xstrdup ();
char *strstr ();
char *xmalloc ();
-void parse_long_options ();
static VALUE *docolon ();
static VALUE *eval ();
program_name, program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
{
\n\
STRING : REGEXP anchored pattern match of REGEXP in STRING\n\
\n\
- ( EXPRESSION ) value of EXPRESSION\n\
+ match STRING REGEXP same as STRING : REGEXP\n\
+ substr STRING POS LENGTH substring of STRING, POS counted from 1\n\
+ index STRING CHARS index in STRING where any CHARS is found, or 0\n\
+ length STRING length of STRING\n\
+\n\
+ ( EXPRESSION ) value of EXPRESSION\n\
");
printf ("\
\n\
program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
\n\
-ADJUST increment priority by ADJUST first\n\
-n, --adjustment ADJUST same as -ADJUST\n\
- --help display this help and exit\n\
- --version output version information and exit\n\
+ --help display this help and exit\n\
+ --version output version information and exit\n\
\n\
With no COMMAND, print the current scheduling priority. ADJUST is 10\n\
by default. Range goes from -20 (highest priority) to 19 (lowest).\n\
program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
#include "system.h"
#include "version.h"
+#include "long-option.h"
#if !defined (isascii) || defined (STDC_HEADERS)
#undef isascii
char *xmalloc ();
void error ();
-void parse_long_options ();
static double xstrtod ();
static int print_esc ();
program_name, program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
{
program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
}
#if defined (TEST_STANDALONE)
-void parse_long_options ();
+#include "long-option.h"
static void
usage (status)
program_name, program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
{
program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else
program_name);
if (status != 0)
- fprintf (stderr, "\nTry `%s --help' for more information.\n",
+ fprintf (stderr, "Try `%s --help' for more information.\n",
program_name);
else