mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-05 19:42:04 +02:00
unify editorial comments
This commit is contained in:
parent
e7f87c9cb2
commit
fe126f9628
5 changed files with 14 additions and 8 deletions
|
@ -288,7 +288,7 @@ void stress_functions(mrmailbox_t* mailbox)
|
|||
|
||||
str = strdup("this is a little test string");
|
||||
mr_truncate_str(str, 16);
|
||||
assert( strcmp(str, "this is a " MR_ELLIPSE_STR)==0 );
|
||||
assert( strcmp(str, "this is a " MR_EDITORIAL_ELLIPSE)==0 );
|
||||
free(str);
|
||||
|
||||
str = strdup("1234");
|
||||
|
|
|
@ -1235,7 +1235,11 @@ static int mrmimeparser_parse_mime_recursive(mrmimeparser_t* ths, struct mailmim
|
|||
{
|
||||
mrmimepart_t* part = mrmimepart_new();
|
||||
part->m_type = MR_MSG_TEXT;
|
||||
part->m_msg = mrstock_str(MR_STR_CANTDECRYPT_MSG_BODY);
|
||||
|
||||
char* msg_body = mrstock_str(MR_STR_CANTDECRYPT_MSG_BODY);
|
||||
part->m_msg = mr_mprintf(MR_EDITORIAL_OPEN "%s" MR_EDITORIAL_CLOSE, msg_body);
|
||||
free(msg_body);
|
||||
|
||||
carray_add(ths->m_parts, (void*)part, NULL);
|
||||
any_part_added = 1;
|
||||
ths->m_decrypting_failed = 1;
|
||||
|
|
|
@ -252,7 +252,7 @@ static char* mrsimplify_simplify_plain_text(mrsimplify_t* ths, const char* buf_t
|
|||
mrstrbuilder_init(&ret, strlen(buf_terminated));
|
||||
|
||||
if( ths->m_is_cut_at_begin ) {
|
||||
mrstrbuilder_cat(&ret, MR_ELLIPSE_STR " ");
|
||||
mrstrbuilder_cat(&ret, MR_EDITORIAL_ELLIPSE " ");
|
||||
}
|
||||
|
||||
int pending_linebreaks = 0; /* we write empty lines only in case and non-empty line follows */
|
||||
|
@ -285,7 +285,7 @@ static char* mrsimplify_simplify_plain_text(mrsimplify_t* ths, const char* buf_t
|
|||
|
||||
if( ths->m_is_cut_at_end
|
||||
&& (!ths->m_is_cut_at_begin || content_lines_added) /* avoid two `[...]` without content */ ) {
|
||||
mrstrbuilder_cat(&ret, " " MR_ELLIPSE_STR);
|
||||
mrstrbuilder_cat(&ret, " " MR_EDITORIAL_ELLIPSE);
|
||||
}
|
||||
|
||||
mr_free_splitted_lines(lines);
|
||||
|
|
|
@ -359,7 +359,7 @@ void mr_truncate_n_unwrap_str(char* buf, int approx_characters, int do_unwrap)
|
|||
/* Function unwraps the given string and removes unnecessary whitespace.
|
||||
Function stops processing after approx_characters are processed.
|
||||
(as we're using UTF-8, for simplicity, we cut the string only at whitespaces). */
|
||||
const char* ellipse_utf8 = do_unwrap? " ..." : " " MR_ELLIPSE_STR; /* a single line is truncated `...` instead of `[...]` (the former is typically also used by the UI to fit strings in a rectangle) */
|
||||
const char* ellipse_utf8 = do_unwrap? " ..." : " " MR_EDITORIAL_ELLIPSE; /* a single line is truncated `...` instead of `[...]` (the former is typically also used by the UI to fit strings in a rectangle) */
|
||||
int lastIsCharacter = 0;
|
||||
unsigned char* p1 = (unsigned char*)buf; /* force unsigned - otherwise the `> ' '` comparison will fail */
|
||||
while( *p1 ) {
|
||||
|
@ -399,7 +399,7 @@ void mr_truncate_n_unwrap_str(char* buf, int approx_characters, int do_unwrap)
|
|||
|
||||
void mr_truncate_str(char* buf, int approx_chars)
|
||||
{
|
||||
if( approx_chars > 0 && strlen(buf) > approx_chars+strlen(MR_ELLIPSE_STR) )
|
||||
if( approx_chars > 0 && strlen(buf) > approx_chars+strlen(MR_EDITORIAL_ELLIPSE) )
|
||||
{
|
||||
char* p = &buf[approx_chars]; /* null-terminate string at the desired length */
|
||||
*p = 0;
|
||||
|
@ -411,7 +411,7 @@ void mr_truncate_str(char* buf, int approx_chars)
|
|||
}
|
||||
}
|
||||
|
||||
strcat(p, MR_ELLIPSE_STR);
|
||||
strcat(p, MR_EDITORIAL_ELLIPSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,9 @@ extern "C" {
|
|||
int mr_exactly_one_bit_set (int v);
|
||||
|
||||
/* string tools */
|
||||
#define MR_ELLIPSE_STR "[...]"
|
||||
#define MR_EDITORIAL_OPEN "["
|
||||
#define MR_EDITORIAL_CLOSE "]"
|
||||
#define MR_EDITORIAL_ELLIPSE MR_EDITORIAL_OPEN "..." MR_EDITORIAL_CLOSE
|
||||
char* safe_strdup (const char*); /* safe_strdup() returns empty string if NULL is given, never returns NULL (exists on errors) */
|
||||
char* strdup_keep_null (const char*); /* strdup(NULL) is undefined, safe_strdup_keep_null(NULL) returns NULL in this case */
|
||||
int atoi_null_is_0 (const char*);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue