Deleted Added
full compact
options.c (200956) options.c (201053)
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 22 unchanged lines hidden (view full) ---

31 */
32
33#ifndef lint
34#if 0
35static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 5/4/95";
36#endif
37#endif /* not lint */
38#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 22 unchanged lines hidden (view full) ---

31 */
32
33#ifndef lint
34#if 0
35static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 5/4/95";
36#endif
37#endif /* not lint */
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: head/bin/sh/options.c 200956 2009-12-24 18:41:14Z jilles $");
39__FBSDID("$FreeBSD: head/bin/sh/options.c 201053 2009-12-27 18:04:05Z jilles $");
40
41#include <signal.h>
42#include <unistd.h>
43#include <stdlib.h>
44
45#include "shell.h"
46#define DEFINE_OPTIONS
47#include "options.h"

--- 11 unchanged lines hidden (view full) ---

59#ifndef NO_HISTORY
60#include "myhistedit.h"
61#endif
62
63char *arg0; /* value of $0 */
64struct shparam shellparam; /* current positional parameters */
65char **argptr; /* argument list for builtin commands */
66char *shoptarg; /* set by nextopt (like getopt) */
40
41#include <signal.h>
42#include <unistd.h>
43#include <stdlib.h>
44
45#include "shell.h"
46#define DEFINE_OPTIONS
47#include "options.h"

--- 11 unchanged lines hidden (view full) ---

59#ifndef NO_HISTORY
60#include "myhistedit.h"
61#endif
62
63char *arg0; /* value of $0 */
64struct shparam shellparam; /* current positional parameters */
65char **argptr; /* argument list for builtin commands */
66char *shoptarg; /* set by nextopt (like getopt) */
67char *optptr; /* used by nextopt */
67char *nextopt_optptr; /* used by nextopt */
68
69char *minusc; /* argument to -c option */
70
71
72STATIC void options(int);
73STATIC void minus_o(char *, int);
74STATIC void setoption(int, int);
75STATIC int getopts(char *, char *, char **, char ***, char **);

--- 479 unchanged lines hidden (view full) ---

555
556int
557nextopt(const char *optstring)
558{
559 char *p;
560 const char *q;
561 char c;
562
68
69char *minusc; /* argument to -c option */
70
71
72STATIC void options(int);
73STATIC void minus_o(char *, int);
74STATIC void setoption(int, int);
75STATIC int getopts(char *, char *, char **, char ***, char **);

--- 479 unchanged lines hidden (view full) ---

555
556int
557nextopt(const char *optstring)
558{
559 char *p;
560 const char *q;
561 char c;
562
563 if ((p = optptr) == NULL || *p == '\0') {
563 if ((p = nextopt_optptr) == NULL || *p == '\0') {
564 p = *argptr;
565 if (p == NULL || *p != '-' || *++p == '\0')
566 return '\0';
567 argptr++;
568 if (p[0] == '-' && p[1] == '\0') /* check for "--" */
569 return '\0';
570 }
571 c = *p++;

--- 4 unchanged lines hidden (view full) ---

576 q++;
577 }
578 if (*++q == ':') {
579 if (*p == '\0' && (p = *argptr++) == NULL)
580 error("No arg for -%c option", c);
581 shoptarg = p;
582 p = NULL;
583 }
564 p = *argptr;
565 if (p == NULL || *p != '-' || *++p == '\0')
566 return '\0';
567 argptr++;
568 if (p[0] == '-' && p[1] == '\0') /* check for "--" */
569 return '\0';
570 }
571 c = *p++;

--- 4 unchanged lines hidden (view full) ---

576 q++;
577 }
578 if (*++q == ':') {
579 if (*p == '\0' && (p = *argptr++) == NULL)
580 error("No arg for -%c option", c);
581 shoptarg = p;
582 p = NULL;
583 }
584 optptr = p;
584 nextopt_optptr = p;
585 return c;
586}
585 return c;
586}