• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-13-stable/usr.bin/look/

Lines Matching refs:front

108 	unsigned char *back, *front;
158 if ((front = mmap(NULL, (size_t)sb.st_size, PROT_READ, MAP_SHARED, fd, (off_t)0)) == MAP_FAILED)
160 back = front + sb.st_size;
161 match *= (look(key, front, back));
200 look(wchar_t *string, unsigned char *front, unsigned char *back)
203 front = binary_search(string, front, back);
204 front = linear_search(string, front, back);
206 if (front)
207 print_from(string, front, back);
208 return (front ? 0 : 1);
213 * Binary search for "string" in memory between "front" and "back".
220 * front points to the beginning of a line at or before the first
227 * front = NULL;
232 * p = first newline after halfway point from front to back.
235 * p is the new front. Otherwise it is the new back.
240 * since front is always at or before the line to print.
244 * (back - front), which in turn implies that a linear search will
254 binary_search(wchar_t *string, unsigned char *front, unsigned char *back)
258 p = front + (back - front) / 2;
265 while (p < back && back > front) {
267 front = p;
270 p = front + (back - front) / 2;
273 return (front);
277 * Find the first line that starts with string, linearly searching from front
284 * o front points at the first character in a line.
285 * o front is before or at the first line to be printed.
288 linear_search(wchar_t *string, unsigned char *front, unsigned char *back)
290 while (front < back) {
291 switch (compare(string, front, back)) {
293 return (front);
299 SKIP_PAST_NEWLINE(front, back);
305 * Print as many lines as match string, starting at front.
308 print_from(wchar_t *string, unsigned char *front, unsigned char *back)
310 for (; front < back && compare(string, front, back) == EQUAL; ++front) {
311 for (; front < back && *front != '\n'; ++front)
312 if (putchar(*front) == EOF)