off by one error in limit for general sockaddr.
[unix-history] / usr / src / usr.bin / more / option.c
CommitLineData
bfe13c81
KB
1/*
2 * Copyright (c) 1988 Mark Nudleman
3 * Copyright (c) 1988 Regents of the University of California.
4 * All rights reserved.
5 *
bfe13c81
KB
6 * Redistribution and use in source and binary forms are permitted
7 * provided that the above copyright notice and this paragraph are
8 * duplicated in all such forms and that any documentation,
9 * advertising materials, and other materials related to such
10 * distribution and use acknowledge that the software was developed
a942b40b
KB
11 * by Mark Nudleman and the University of California, Berkeley. The
12 * name of Mark Nudleman or the
bfe13c81
KB
13 * University may not be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 */
19
20#ifndef lint
ab46231c 21static char sccsid[] = "@(#)option.c 5.10 (Berkeley) %G%";
bfe13c81
KB
22#endif /* not lint */
23
966c6ec0
KB
24#include <stdio.h>
25#include <less.h>
26
27int top_scroll; /* Repaint screen from top */
28int bs_mode; /* How to process backspaces */
29int caseless; /* Do "caseless" searches */
30int cbufs = 10; /* Current number of buffers */
31int linenums = 1; /* Use line numbers */
32int quit_at_eof;
33int squeeze; /* Squeeze multiple blank lines into one */
34int tabstop = 8; /* Tab settings */
35int tagoption;
966c6ec0
KB
36
37char *firstsearch;
38extern int sc_height;
39
40option(argc, argv)
41 int argc;
42 char **argv;
bfe13c81 43{
966c6ec0
KB
44 extern char *optarg;
45 extern int optind;
46 static int sc_window_set = 0;
47 int ch;
48 char *p;
49
56c4581e
KB
50 /* backward compatible processing for "+/search" */
51 char **a;
52 for (a = argv; *a; ++a)
53 if ((*a)[0] == '+' && (*a)[1] == '/')
54 (*a)[0] = '-';
55
966c6ec0 56 optind = 1; /* called twice, re-init getopt. */
ab46231c 57 while ((ch = getopt(argc, argv, "0123456789/:ceinst:ux:f")) != EOF)
966c6ec0
KB
58 switch((char)ch) {
59 case '0': case '1': case '2': case '3': case '4':
60 case '5': case '6': case '7': case '8': case '9':
bfe13c81 61 /*
966c6ec0
KB
62 * kludge: more was originally designed to take
63 * a number after a dash.
bfe13c81 64 */
966c6ec0
KB
65 if (!sc_window_set) {
66 p = argv[optind - 1];
67 if (p[0] == '-' && p[1] == ch && !p[2])
68 sc_height = atoi(++p);
69 else
70 sc_height = atoi(argv[optind] + 1);
71 sc_window_set = 1;
bfe13c81 72 }
966c6ec0
KB
73 break;
74 case '/':
75 firstsearch = optarg;
76 break;
77 case 'c':
78 top_scroll = 1;
79 break;
80 case 'e':
81 quit_at_eof = 1;
82 break;
83 case 'i':
84 caseless = 1;
85 break;
86 case 'n':
87 linenums = 0;
88 break;
966c6ec0
KB
89 case 's':
90 squeeze = 1;
91 break;
92 case 't':
93 tagoption = 1;
94 findtag(optarg);
95 break;
96 case 'u':
97 bs_mode = 1;
98 break;
99 case 'x':
100 tabstop = atoi(optarg);
101 if (tabstop <= 0)
102 tabstop = 8;
103 break;
ab46231c
MT
104 case 'f': /* ignore -f, compatability with old more */
105 break;
966c6ec0
KB
106 case '?':
107 default:
108 fprintf(stderr,
750ed434 109 "usage: more [-ceinus] [-t tag] [-x tabs] [-/ pattern] [-#] [file ...]\n");
966c6ec0
KB
110 exit(1);
111 }
112 return(optind);
bfe13c81 113}