Lines Matching defs:string
66 #include <string.h>
101 char *back, *front, *string, *p;
105 string = NULL;
128 string = *argv++;
133 string = *argv;
139 if (termchar != '\0' && (p = strchr(string, termchar)) != NULL)
153 exit(look(string, front, back));
157 look(char *string, char *front, char *back)
162 /* Reformat string string to avoid doing it multiple times later. */
163 for (readp = writep = string; (ch = *readp++) != 0; ) {
173 front = binary_search(string, front, back);
174 front = linear_search(string, front, back);
177 print_from(string, front, back);
183 * Binary search for "string" in memory between "front" and "back".
186 * *or before* the first word matching "string". Relaxing the constraint
191 * matching string.
204 * If the string at "p" is not greater than the string to match,
213 * implies that there exists a string is least half as long as
215 * be no more expensive than the cost of simply printing a string or two.
224 binary_search(char *string, char *front, char *back)
236 if (compare(string, p, back) == GREATER)
247 * Find the first line that starts with string, linearly searching from front
258 linear_search(char *string, char *front, char *back)
261 switch (compare(string, front, back)) {
265 case LESS: /* No such string. */
277 * Print as many lines as match string, starting at front.
280 print_from(char *string, char *front, char *back)
282 for (; front < back && compare(string, front, back) == EQUAL; ++front) {
301 * The string "s1" is null terminated. The string s2 is '\n' terminated (or
329 (void)fprintf(stderr, "usage: look [-df] [-t char] string [file]\n");