- {
- while (start_byte > limit_byte)
- {
- ceiling = BUFFER_FLOOR_OF (start_byte - 1);
- ceiling = max (limit_byte, ceiling);
- ceiling_addr = BYTE_POS_ADDR (ceiling) - 1;
- base = (cursor = BYTE_POS_ADDR (start_byte - 1) + 1);
- while (1)
- {
- while (--cursor != ceiling_addr && *cursor != '\n')
- ;
-
- if (cursor != ceiling_addr)
- {
- if (++count == 0)
- {
- immediate_quit = old_immediate_quit;
- /* Return the position AFTER the match we found. */
- start_byte = start_byte + cursor - base + 1;
- start = BYTE_TO_CHAR (start_byte);
- TEMP_SET_PT_BOTH (start, start_byte);
- return 0;
- }
- }
- else
- break;
- }
- /* Here we add 1 to compensate for the last decrement
- of CURSOR, which took it past the valid range. */
- start_byte += cursor - base + 1;
- }
- }
-
- TEMP_SET_PT_BOTH (limit, limit_byte);
- immediate_quit = old_immediate_quit;
-
- return count * direction;