Deleted Added
full compact
options.c (206182) options.c (213811)
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 206182 2010-04-05 14:15:51Z jilles $");
39__FBSDID("$FreeBSD: head/bin/sh/options.c 213811 2010-10-13 22:18:03Z obrien $");
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"

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

64struct shparam shellparam; /* current positional parameters */
65char **argptr; /* argument list for builtin commands */
66char *shoptarg; /* set by nextopt (like getopt) */
67char *nextopt_optptr; /* used by nextopt */
68
69char *minusc; /* argument to -c option */
70
71
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"

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

64struct shparam shellparam; /* current positional parameters */
65char **argptr; /* argument list for builtin commands */
66char *shoptarg; /* set by nextopt (like getopt) */
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 **);
72static void options(int);
73static void minus_o(char *, int);
74static void setoption(int, int);
75static int getopts(char *, char *, char **, char ***, char **);
76
77
78/*
79 * Process the shell command line arguments.
80 */
81
82void
83procargs(int argc, char **argv)

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

133 setjobctl(mflag);
134}
135
136/*
137 * Process shell options. The global variable argptr contains a pointer
138 * to the argument list; we advance it past the options.
139 */
140
76
77
78/*
79 * Process the shell command line arguments.
80 */
81
82void
83procargs(int argc, char **argv)

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

133 setjobctl(mflag);
134}
135
136/*
137 * Process shell options. The global variable argptr contains a pointer
138 * to the argument list; we advance it past the options.
139 */
140
141STATIC void
141static void
142options(int cmdline)
143{
144 char *kp, *p;
145 int val;
146 int c;
147
148 if (cmdline)
149 minusc = NULL;

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

242 if (p != NULL && p[0] == '#' && p[1] == '\0') {
243 while (*argptr != NULL)
244 argptr++;
245 /* We need to keep the final argument */
246 argptr--;
247 }
248}
249
142options(int cmdline)
143{
144 char *kp, *p;
145 int val;
146 int c;
147
148 if (cmdline)
149 minusc = NULL;

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

242 if (p != NULL && p[0] == '#' && p[1] == '\0') {
243 while (*argptr != NULL)
244 argptr++;
245 /* We need to keep the final argument */
246 argptr--;
247 }
248}
249
250STATIC void
250static void
251minus_o(char *name, int val)
252{
253 int i;
254
255 if (name == NULL) {
256 if (val) {
257 /* "Pretty" output. */
258 out1str("Current option settings\n");

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

279 setoption(optlist[i].letter, val);
280 return;
281 }
282 error("Illegal option -o %s", name);
283 }
284}
285
286
251minus_o(char *name, int val)
252{
253 int i;
254
255 if (name == NULL) {
256 if (val) {
257 /* "Pretty" output. */
258 out1str("Current option settings\n");

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

279 setoption(optlist[i].letter, val);
280 return;
281 }
282 error("Illegal option -o %s", name);
283 }
284}
285
286
287STATIC void
287static void
288setoption(int flag, int val)
289{
290 int i;
291
292 for (i = 0; i < NOPTS; i++)
293 if (optlist[i].letter == flag) {
294 optlist[i].val = val;
295 if (val) {

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

446 shellparam.optptr = NULL;
447 shellparam.reset = 0;
448 }
449
450 return getopts(argv[1], argv[2], optbase, &shellparam.optnext,
451 &shellparam.optptr);
452}
453
288setoption(int flag, int val)
289{
290 int i;
291
292 for (i = 0; i < NOPTS; i++)
293 if (optlist[i].letter == flag) {
294 optlist[i].val = val;
295 if (val) {

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

446 shellparam.optptr = NULL;
447 shellparam.reset = 0;
448 }
449
450 return getopts(argv[1], argv[2], optbase, &shellparam.optnext,
451 &shellparam.optptr);
452}
453
454STATIC int
454static int
455getopts(char *optstr, char *optvar, char **optfirst, char ***optnext,
456 char **optptr)
457{
458 char *p, *q;
459 char c = '?';
460 int done = 0;
461 int ind = 0;
462 int err = 0;

--- 127 unchanged lines hidden ---
455getopts(char *optstr, char *optvar, char **optfirst, char ***optnext,
456 char **optptr)
457{
458 char *p, *q;
459 char c = '?';
460 int done = 0;
461 int ind = 0;
462 int err = 0;

--- 127 unchanged lines hidden ---