summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pttbbs/include/proto.h1
-rw-r--r--pttbbs/mbbsd/edit.c26
-rw-r--r--pttbbs/mbbsd/kaede.c18
3 files changed, 21 insertions, 24 deletions
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h
index 2d7ef749..472008d4 100644
--- a/pttbbs/include/proto.h
+++ b/pttbbs/include/proto.h
@@ -334,6 +334,7 @@ void outmsg(const char *msg);
void out_lines(const char *str, int line, int col);
#define HAVE_EXPAND_ESC_STAR
int expand_esc_star(char *buf, const char *src, int szbuf);
+void strip_ansi_movecmd(char *s);
/* lovepaper */
int x_love(void);
diff --git a/pttbbs/mbbsd/edit.c b/pttbbs/mbbsd/edit.c
index f22acc3b..76e96464 100644
--- a/pttbbs/mbbsd/edit.c
+++ b/pttbbs/mbbsd/edit.c
@@ -1440,28 +1440,6 @@ quote_strip_ansi_inline(unsigned char *is)
*os = 0;
}
-static int
-process_ansi_movecmd(char *s, int replace) {
- const char *pattern_movecmd = "ABCDfjHJRu";
- const char *pattern_ansi_code = "0123456789;,[";
-
- while (*s) {
- char *esc = strchr(s, ESC_CHR);
- if (!esc)
- return 0;
- s = ++esc;
- while (*esc && strchr(pattern_ansi_code, *esc))
- esc++;
- if (strchr(pattern_movecmd, *esc)) {
- if (replace == YEA)
- *esc = 's';
- else
- return 1;
- }
- }
- return 0;
-}
-
static void
do_quote(void)
{
@@ -1818,7 +1796,7 @@ browse_sigs:
fputs("\n--\n", fp);
for (i = 0; i < MAX_SIGLINES &&
fgets(buf, sizeof(buf), fs); i++) {
- process_ansi_movecmd(buf, YEA);
+ strip_ansi_movecmd(buf);
fputs(buf, fp);
}
fclose(fs);
@@ -1986,7 +1964,7 @@ write_file(const char *fpath, int saveheader, int *islocal, char mytitle[STRLEN]
continue;
trim(msg);
- process_ansi_movecmd(msg, YEA);
+ strip_ansi_movecmd(msg);
line++;
/* check crosspost */
diff --git a/pttbbs/mbbsd/kaede.c b/pttbbs/mbbsd/kaede.c
index 628f51df..9a594311 100644
--- a/pttbbs/mbbsd/kaede.c
+++ b/pttbbs/mbbsd/kaede.c
@@ -42,6 +42,24 @@ expand_esc_star(char *buf, const char *src, int szbuf)
return 0;
}
+void
+strip_ansi_movecmd(char *s) {
+ const char *pattern_movecmd = "ABCDfjHJRu";
+ const char *pattern_ansi_code = "0123456789;,[";
+
+ while (*s) {
+ char *esc = strchr(s, ESC_CHR);
+ if (!esc)
+ return;
+ s = ++esc;
+ while (*esc && strchr(pattern_ansi_code, *esc))
+ esc++;
+ if (strchr(pattern_movecmd, *esc)) {
+ *esc = 's';
+ }
+ }
+}
+
char *
Ptt_prints(char *str, size_t size, int mode)
{