diff options
author | Eduardo Chappa <chappa@washington.edu> | 2015-04-09 00:28:00 -0600 |
---|---|---|
committer | Eduardo Chappa <chappa@washington.edu> | 2015-04-09 00:28:00 -0600 |
commit | bf49fb6584bfd8c4cfae5bab4c5f46b155bcb5a7 (patch) | |
tree | fd2331aed583538bab27f28dca105ee37b654327 /pith | |
parent | ec605304db0b92d68e151574ab0f80babee6d4a6 (diff) | |
download | alpine-bf49fb6584bfd8c4cfae5bab4c5f46b155bcb5a7.tar.xz |
* When sending a message, allow for 512 characters of consecutive non-white
space before folding the subject line.
Diffstat (limited to 'pith')
-rw-r--r-- | pith/pine.hlp | 3 | ||||
-rw-r--r-- | pith/send.c | 12 | ||||
-rw-r--r-- | pith/string.c | 24 | ||||
-rw-r--r-- | pith/string.h | 1 |
4 files changed, 38 insertions, 2 deletions
diff --git a/pith/pine.hlp b/pith/pine.hlp index 6815233f..4f57b688 100644 --- a/pith/pine.hlp +++ b/pith/pine.hlp @@ -220,6 +220,9 @@ Additions include: <LI> For a multipart/alternative message, the Take Address command will work on the part that is being read. + + <LI> When sending a message, allow for 512 characters of consecutive non-white + space before folding the subject line. </UL> diff --git a/pith/send.c b/pith/send.c index 5495a80b..c0337aea 100644 --- a/pith/send.c +++ b/pith/send.c @@ -2981,6 +2981,7 @@ pine_header_line(char *field, METAENV *header, char *text, soutr_t f, void *s, int writehdr, int localcopy) { int ret = 1; + int flags; int big = 10000; char *value, *folded = NULL, *cs; char *converted; @@ -3026,15 +3027,22 @@ pine_header_line(char *field, METAENV *header, char *text, soutr_t f, void *s, * We upped the references folding from 75 to 256 because we were * encountering longer-than-75 message ids, and to break one line * in references is to break them all. + * + * Also, some users are adding long text without spaces to the subject + * line (e.g. URLs) so we up that number too. For the moment this is + * going to 512 (a url that is about 6 lines long.) */ - if(field && !strucmp("Subject", field)) + flags = FLD_CRLF; + if(field && !strucmp("Subject", field)){ fold_by = 75; + flags |= FLD_NEXTSPC; + } else if(field && !strucmp("References", field)) fold_by = 256; else fold_by = big; - folded = fold(value, fold_by, big, actual_field, " ", FLD_CRLF); + folded = fold(value, fold_by, big, actual_field, " ", flags); if(actual_field) fs_give((void **)&actual_field); diff --git a/pith/string.c b/pith/string.c index b3413561..c7ef310c 100644 --- a/pith/string.c +++ b/pith/string.c @@ -1588,6 +1588,18 @@ fold(char *src, int width, int maxwidth, char *first_indent, char *indent, unsig } } + if(winner == -1 && (flags & FLD_NEXTSPC)){ + for(i = starting_point; winner == -1 && i <= strlen(next_piece) != '\0' && i < 512; i++){ + endptr = utf8_count_forw_width(next_piece, i, &got_width); + if(endptr && got_width == i && isspace((unsigned char) *endptr)) + winner = (int) i; + } + if(winner == -1){ + winner = got_width < 512 ? got_width : 512; + endptr = NULL; + } + } + if(winner == -1){ /* if no good folding spot, fold at width */ winner = starting_point; endptr = NULL; @@ -1652,6 +1664,18 @@ fold(char *src, int width, int maxwidth, char *first_indent, char *indent, unsig } } + if(winner == -1 && (flags & FLD_NEXTSPC)){ + for(i = starting_point; winner == -1 && i <= strlen(next_piece) && i < 512; i++){ + endptr = utf8_count_forw_width(next_piece, i, &got_width); + if(endptr && got_width == i && isspace((unsigned char) *endptr)) + winner = (int) i; + } + if(winner == -1){ + winner = got_width < 512 ? got_width : 512; + endptr = NULL; + } + } + if(winner == -1){ /* if no good folding spot, fold at width */ winner = starting_point; endptr = NULL; diff --git a/pith/string.h b/pith/string.h index dce84d56..5382484a 100644 --- a/pith/string.h +++ b/pith/string.h @@ -40,6 +40,7 @@ #define FLD_NONE 0x00 #define FLD_CRLF 0x01 /* use CRLF end of line instead of LF */ #define FLD_PWS 0x02 /* preserve whitespace when folding */ +#define FLD_NEXTSPC 0x04 /* fold at next available space after given length */ typedef enum {FrontDots, MidDots, EndDots} WhereDots; |