-#ifdef CONFIG_FEATURE_LESS_REGEXP
-/* The below two regular expression handler functions NEED development. */
-
-/* Get a regular expression from the user, and then go through the current
- file line by line, running a processing regex function on each one. */
-static void regex_process() {
-
- char uncomp_regex[100];
- char current_line[256];
- int i;
- int j = 0;
- regex_t *pattern;
-
- /* Reset variables */
- match_lines[0] = -1;
- match_pos = 0;
- num_matches = 0;
- match_found = 0;
-
- pattern = (regex_t *) malloc(sizeof(regex_t));
- memset(pattern, 0, sizeof(regex_t));
-
- /* Get the uncompiled regular expression from the user */
- clear_line();
- if (match_backwards)
- printf("?");
- else
- printf("/");
- scanf("%s", uncomp_regex);
-
- /* Compile the regex and check for errors */
- xregcomp(pattern, uncomp_regex, 0);
-
- /* Run the regex on each line of the current file here */
- for (i = 0; i <= num_flines; i++) {
- strcpy(current_line, process_regex_on_line(flines[i], pattern));
- flines[i] = (char *) bb_xstrndup(current_line, sizeof(char) * (strlen(current_line)+1));
-
- if (match_found) {
- match_lines[j] = i;
- j++;
- }
- }
-
- num_matches = j;
-
- if ((match_lines[0] != -1) && (num_flines > height - 2))
- buffer_line(match_lines[0]);
- else
- buffer_init();
-}
-
-char *process_regex_on_line(char *line, regex_t *pattern) {
- /* This function takes the regex and applies it to the line.
- Each part of the line that matches has the HIGHLIGHT
- and NORMAL escape sequences placed around it by
- insert_highlights, and then the line is returned. */
-
- int match_status;
- char *line2 = (char *) malloc((sizeof(char) * (strlen(line) + 1)) + 64);
- char sub_line[256];
- int prev_eo = 0;
- memset(sub_line, 0, 256);
- strcpy(line2, line);
- regmatch_t match_structs;
-
- match_found = 0;
- match_status = regexec(pattern, line2, 1, &match_structs, 0);
-
- while (match_status == 0) {
-
- memset(sub_line, 0, 256);
-
- if (match_found == 0)
- match_found = 1;
-
- line2 = insert_highlights(line2, match_structs.rm_so + prev_eo, match_structs.rm_eo + prev_eo);
- if (match_structs.rm_eo + 11 + prev_eo < strlen(line2))
- strcat(sub_line, line2 + match_structs.rm_eo + 11 + prev_eo);
-
- prev_eo += match_structs.rm_eo + 11;
- match_status = regexec(pattern, sub_line, 1, &match_structs, REG_NOTBOL);
- }
-
- return line2;
-}
-
-char *insert_highlights (char *line, int start, int end) {
-
- char *new_line = (char *) malloc((sizeof(char) * (strlen(line) + 1)) + 10);
- memset(new_line, 0, ((sizeof(char) * (strlen(line) + 1)) + 10));
- strncat(new_line, line, start);
- strcat(new_line, HIGHLIGHT);
- strncat(new_line, line + start, end - start);
- strcat(new_line, NORMAL);
- strncat(new_line, line + end, strlen(line) - end);
-
- return new_line;
-}
-
-static void goto_match(int match) {
-
- /* This goes to a specific match - all line positions of matches are
- stored within the match_lines[] array. */
- if ((match < num_matches) && (match >= 0)) {
- buffer_line(match_lines[match]);
- match_pos = match;
- }
-}
-
-static void search_backwards() {
-
- int current_linepos = line_pos;
- int i;
-
- match_backwards = 1;
- regex_process();
-
- for (i = 0; i < num_matches; i++) {
- if (match_lines[i] > current_linepos) {
- buffer_line(match_lines[i - num_back_match]);
- break;
- }
- }
-
- /* Reset variables */
- match_backwards = 0;
- num_back_match = 1;
-
-}
-#endif