Lines Matching defs:front
101 char *back, *front, *string, *p;
149 if ((front = mmap(NULL, len,
152 back = front + len;
153 exit(look(string, front, back));
157 look(char *string, char *front, char *back)
173 front = binary_search(string, front, back);
174 front = linear_search(string, front, back);
176 if (front)
177 print_from(string, front, back);
178 return (front ? 0 : 1);
183 * Binary search for "string" in memory between "front" and "back".
190 * front points to the beginning of a line at or before the first
197 * front = NULL;
202 * p = first newline after halfway point from front to back.
205 * p is the new front. Otherwise it is the new back.
210 * since front is always at or before the line to print.
214 * (back - front), which in turn implies that a linear search will
224 binary_search(char *string, char *front, char *back)
228 p = front + (back - front) / 2;
235 while (p < back && back > front) {
237 front = p;
240 p = front + (back - front) / 2;
243 return (front);
247 * Find the first line that starts with string, linearly searching from front
254 * o front points at the first character in a line.
255 * o front is before or at the first line to be printed.
258 linear_search(char *string, char *front, char *back)
260 while (front < back) {
261 switch (compare(string, front, back)) {
263 return (front);
271 SKIP_PAST_NEWLINE(front, back);
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) {
283 for (; front < back && *front != '\n'; ++front)
284 if (putchar(*front) == EOF)