[PATCH] Make VERBATIM_*_REGEX user configurable
Michael Bienia <[email protected]>
| Newsgroups | gmane.network.tin.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello, the attached patch makes VERBATIM_*_REGEX user configurable. Michael
patch-20060414.diff
(text/plain, 8.1 KB)
doc/TODO | 2 +-
include/extern.h | 2 ++
include/tin.h | 4 ++--
include/tinrc.h | 2 ++
src/config.c | 14 ++++++++++++++
src/init.c | 12 +++++++++---
src/lang.c | 14 ++++++++++++++
src/options_menu.c | 18 ++++++++++++++++++
src/tincfg.tbl | 2 ++
9 files changed, 64 insertions(+), 6 deletions(-)
diff -Nurp tin-1.9.1/doc/TODO tin-1.9.1.patched/doc/TODO
--- tin-1.9.1/doc/TODO 2006-03-16 16:10:26.000000000 +0100
+++ tin-1.9.1.patched/doc/TODO 2006-04-14 14:03:41.451597779 +0200
@@ -177,7 +177,7 @@ o allow bold, underline, italic, ... as
[20030218 Serge Matveev <[email protected]>]
o add 'M'enu option to turn on/off slrn '#v+'/'#v-' verbatim mark handling.
- (and make the VERBATIM_*_REGEXs user configurable; add a verbatim_color; ...)
+ (and add a verbatim_color; ...)
[20060311 Urs Janssen <[email protected]>]
o hierarchical 'M'enu, e.g. put all art_marked_*into a 'submenu', ...
diff -Nurp tin-1.9.1/include/extern.h tin-1.9.1.patched/include/extern.h
--- tin-1.9.1/include/extern.h 2006-03-11 11:29:56.000000000 +0100
+++ tin-1.9.1.patched/include/extern.h 2006-04-14 13:27:23.893413656 +0200
@@ -1582,6 +1582,8 @@ extern struct opttxt txt_unlink_article;
extern struct opttxt txt_url_handler;
extern struct opttxt txt_url_highlight;
extern struct opttxt txt_use_mouse;
+extern struct opttxt txt_verbatim_begin_regex;
+extern struct opttxt txt_verbatim_end_regex;
extern struct opttxt txt_wildcard;
extern struct opttxt txt_word_highlight;
extern struct opttxt txt_word_h_display_marks;
diff -Nurp tin-1.9.1/include/tin.h tin-1.9.1.patched/include/tin.h
--- tin-1.9.1/include/tin.h 2006-03-11 11:26:22.000000000 +0100
+++ tin-1.9.1.patched/include/tin.h 2006-04-14 13:17:59.650125130 +0200
@@ -599,8 +599,8 @@ enum rc_state { RC_IGNORE, RC_CHECK, RC_
#define SHAR_REGEX "\\#(?:!\\s?(?:/usr)?/bin/sh|\\s?(?i)this\\sis\\sa\\sshell\\sarchive)"
/* slrn verbatim marks, case sensitive & ^-anchored */
-#define VERBATIM_BEGIN_REGEX "#v+"
-#define VERBATIM_END_REGEX "#v-"
+#define DEFAULT_VERBATIM_BEGIN_REGEX "#v+"
+#define DEFAULT_VERBATIM_END_REGEX "#v-"
/*
* URL related regexs:
diff -Nurp tin-1.9.1/include/tinrc.h tin-1.9.1.patched/include/tinrc.h
--- tin-1.9.1/include/tinrc.h 2006-02-15 19:44:37.000000000 +0100
+++ tin-1.9.1.patched/include/tinrc.h 2006-04-14 13:13:29.247491780 +0200
@@ -117,6 +117,8 @@ struct t_config {
char sigfile[PATH_LEN];
char strip_re_regex[LEN]; /* regex used to find and remove 'Re:'-like strings */
char strip_was_regex[LEN]; /* regex used to find and remove '(was:.*'-like strings */
+ char verbatim_begin_regex[LEN]; /* regex used to find the begin of a verbatim block */
+ char verbatim_end_regex[LEN]; /* regex used to find the end of a verbatim block */
char savedir[PATH_LEN]; /* directory to save articles to */
char spamtrap_warning_addresses[LEN];
char url_handler[LEN]; /* Helper app for opening URL's */
diff -Nurp tin-1.9.1/src/config.c tin-1.9.1.patched/src/config.c
--- tin-1.9.1/src/config.c 2006-02-15 22:19:37.000000000 +0100
+++ tin-1.9.1.patched/src/config.c 2006-04-14 14:02:01.857034233 +0200
@@ -761,6 +761,15 @@ read_config_file(
break;
+ case 'v':
+ if (match_string(buf, "verbatim_begin_regex=", tinrc.verbatim_begin_regex, sizeof(tinrc.verbatim_begin_regex)))
+ break;
+
+ if (match_string(buf, "verbatim_end_regex=", tinrc.verbatim_end_regex, sizeof(tinrc.verbatim_end_regex)))
+ break;
+
+ break;
+
case 'w':
if (match_integer(buf, "wildcard=", &tinrc.wildcard, 2))
break;
@@ -1055,6 +1064,11 @@ write_config_file(
fprintf(fp, _(txt_strip_was_regex.tinrc));
fprintf(fp, "strip_was_regex=%s\n\n", tinrc.strip_was_regex);
+ fprintf(fp, _(txt_verbatim_begin_regex.tinrc));
+ fprintf(fp, "verbatim_begin_regex=%s\n\n", tinrc.verbatim_begin_regex);
+ fprintf(fp, _(txt_verbatim_end_regex.tinrc));
+ fprintf(fp, "verbatim_end_regex=%s\n\n", tinrc.verbatim_end_regex);
+
fprintf(fp, _(txt_show_signatures.tinrc));
fprintf(fp, "show_signatures=%s\n\n", print_boolean(tinrc.show_signatures));
diff -Nurp tin-1.9.1/src/init.c tin-1.9.1.patched/src/init.c
--- tin-1.9.1/src/init.c 2006-03-11 11:29:08.000000000 +0100
+++ tin-1.9.1.patched/src/init.c 2006-04-14 13:17:07.548251858 +0200
@@ -261,6 +261,8 @@ struct t_config tinrc = {
"", /* sigfile */
"", /* strip_re_regex */
"", /* strip_was_regex */
+ "", /* verbatim_begin_regex */
+ "", /* verbatim_end_regex */
"", /* savedir */
"", /* spamtrap_warning_addresses */
DEFAULT_URL_HANDLER, /* url_handler */
@@ -976,12 +978,16 @@ postinit_regexp(
STRCPY(tinrc.underscores_regex, DEFAULT_UNDERSCORES_REGEX);
compile_regex(tinrc.underscores_regex, &underscores_regex, PCRE_CASELESS);
+ if (!strlen(tinrc.verbatim_begin_regex))
+ STRCPY(tinrc.verbatim_begin_regex, DEFAULT_VERBATIM_BEGIN_REGEX);
+ compile_regex(tinrc.verbatim_begin_regex, &verbatim_begin_regex, PCRE_ANCHORED);
+ if (!strlen(tinrc.verbatim_end_regex))
+ STRCPY(tinrc.verbatim_end_regex, DEFAULT_VERBATIM_END_REGEX);
+ compile_regex(tinrc.verbatim_end_regex, &verbatim_end_regex, PCRE_ANCHORED);
+
compile_regex(UUBEGIN_REGEX, &uubegin_regex, PCRE_ANCHORED);
compile_regex(UUBODY_REGEX, &uubody_regex, PCRE_ANCHORED);
- compile_regex(VERBATIM_BEGIN_REGEX, &verbatim_begin_regex, PCRE_ANCHORED);
- compile_regex(VERBATIM_END_REGEX, &verbatim_end_regex, PCRE_ANCHORED);
-
compile_regex(URL_REGEX, &url_regex, PCRE_CASELESS);
compile_regex(MAIL_REGEX, &mail_regex, PCRE_CASELESS);
compile_regex(NEWS_REGEX, &news_regex, PCRE_CASELESS);
diff -Nurp tin-1.9.1/src/lang.c tin-1.9.1.patched/src/lang.c
--- tin-1.9.1/src/lang.c 2006-02-15 22:03:44.000000000 +0100
+++ tin-1.9.1.patched/src/lang.c 2006-04-14 13:51:42.610497207 +0200
@@ -1741,6 +1741,20 @@ struct opttxt txt_strip_was_regex = {
# which will be removed when replying or posting followup.\n")
};
+struct opttxt txt_verbatim_begin_regex = {
+ N_("A regex used to find the begin of a verbatim block."),
+ N_("Regex for begin of a verbatim block"),
+ N_("# A regular expression that tin will use to find the begin of\n\
+# a verbatim block.\n")
+};
+
+struct opttxt txt_verbatim_end_regex = {
+ N_("A regex used to find the end of a verbatim block."),
+ N_("Regex for end of a verbatim block"),
+ N_("# A regular expression that tin will use to find the end of\n\
+# a verbatim block.\n")
+};
+
struct opttxt txt_metamail_prog = {
N_("Enter name and options for external MIME viewer, --internal for built-in viewer"),
N_("MIME binary content viewer"),
diff -Nurp tin-1.9.1/src/options_menu.c tin-1.9.1.patched/src/options_menu.c
--- tin-1.9.1/src/options_menu.c 2006-02-15 19:44:37.000000000 +0100
+++ tin-1.9.1.patched/src/options_menu.c 2006-04-14 13:55:54.149456608 +0200
@@ -1385,6 +1385,24 @@ change_config_file(
compile_regex(tinrc.strip_was_regex, &strip_was_regex, 0);
break;
+ case OPT_VERBATIM_BEGIN_REGEX:
+ prompt_option_string(option);
+ FreeIfNeeded(verbatim_begin_regex.re);
+ FreeIfNeeded(verbatim_begin_regex.extra);
+ if (!strlen(tinrc.verbatim_begin_regex))
+ STRCPY(tinrc.verbatim_begin_regex, DEFAULT_VERBATIM_BEGIN_REGEX);
+ compile_regex(tinrc.verbatim_begin_regex, &verbatim_begin_regex, PCRE_ANCHORED);
+ break;
+
+ case OPT_VERBATIM_END_REGEX:
+ prompt_option_string(option);
+ FreeIfNeeded(verbatim_end_regex.re);
+ FreeIfNeeded(verbatim_end_regex.extra);
+ if (!strlen(tinrc.verbatim_end_regex))
+ STRCPY(tinrc.verbatim_end_regex, DEFAULT_VERBATIM_END_REGEX);
+ compile_regex(tinrc.verbatim_end_regex, &verbatim_end_regex, PCRE_ANCHORED);
+ break;
+
case OPT_DATE_FORMAT:
prompt_option_string(option);
if (!strlen(tinrc.date_format)) {
diff -Nurp tin-1.9.1/src/tincfg.tbl tin-1.9.1.patched/src/tincfg.tbl
--- tin-1.9.1/src/tincfg.tbl 2006-02-15 19:44:38.000000000 +0100
+++ tin-1.9.1.patched/src/tincfg.tbl 2006-04-14 13:56:32.271781976 +0200
@@ -199,6 +199,8 @@
underscores_regex OPT_STRING
strip_re_regex OPT_STRING
strip_was_regex OPT_STRING
+ verbatim_begin_regex OPT_STRING
+ verbatim_end_regex OPT_STRING
force_screen_redraw OPT_ON_OFF
start_editor_offset OPT_ON_OFF
editor_format OPT_STRING