int global_use_regexp = 0;
int global_case_sensitive = 0;
char *global_title = 0;
+regex_t *global_prefix_regexp = 0;
int global_error_flash = 0;
int global_upper_caps_makes_case_sensitive = 0;
int global_show_long_lines = 0;
fprintf(out, " make a flash instead of a beep on an edition error\n");
fprintf(out, " --bash\n");
fprintf(out, " setting for bash history search, same as -b -i -d -v -w -l ${HISTSIZE}\n");
+ fprintf(out, " --delete-regexp <regexp>\n");
+ fprintf(out, " deletes in every line the portion matching the regexp\n");
fprintf(out, " --\n");
fprintf(out, " all following arguments are filenames\n");
fprintf(out, " -t <title>, --title <title>\n");
/*********************************************************************/
void store_line(struct hash_table_t *hash_table,
- const char *new_line,
+ char *new_line,
int *nb_lines, char **lines) {
int dup;
+ char *c, *d;
+ regmatch_t matches;
+
+ /* Remove some parts matching a regexp */
+
+ if(global_prefix_regexp && regexec(global_prefix_regexp, new_line, 1, &matches, 0) == 0) {
+ c = new_line + matches.rm_so;
+ d = new_line + matches.rm_eo;
+ while(*d) { *c++ = *d++; }
+ *c = 0;
+ }
/* Remove the zsh history prefix */
/* For long options that have no equivalent short option, use a
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
enum {
- OPT_BASH_MODE = CHAR_MAX + 1
+ OPT_BASH_MODE = CHAR_MAX + 1,
+ OPT_DELETE_REGEXP = CHAR_MAX + 2
};
static struct option long_options[] = {
{ "regexp", no_argument, 0, 'e' },
{ "case-sensitive", no_argument, 0, 'a' },
{ "show-long-lines", no_argument, 0, 'j'},
- { "show-hits", no_argument, 0, 'j'},
+ { "show-hits", no_argument, 0, 'y'},
{ "upper-case-makes-case-sensitive", no_argument, 0, 'u' },
{ "title", 1, 0, 't' },
{ "pattern", 1, 0, 'r' },
{ "number-of-lines", 1, 0, 'l' },
{ "colors", 1, 0, 'c' },
{ "bash", no_argument, 0, OPT_BASH_MODE },
+ { "delete-regexp", 1, 0, OPT_DELETE_REGEXP },
{ "help", no_argument, 0, 'h' },
{ 0, 0, 0, 0 }
};
strcpy(global_title, optarg);
break;
+ case OPT_DELETE_REGEXP:
+ free(global_prefix_regexp);
+ global_prefix_regexp = safe_malloc(sizeof(*global_prefix_regexp));
+ regcomp(global_prefix_regexp, optarg, 0);
+ break;
+
case 'r':
strcpy(pattern, optarg);
break;
free(labels);
free(lines);
free(global_title);
+ free(global_prefix_regexp);
exit(EXIT_SUCCESS);
}