* rename mu_msg_str => mu_str

This commit is contained in:
Dirk-Jan C. Binnema 2010-11-23 00:44:18 +02:00
parent 89b85cf7f7
commit 0f2b4e2d3c
16 changed files with 98 additions and 101 deletions

View File

@ -80,9 +80,9 @@ libmu_la_SOURCES= \
mu-msg-iter.h \ mu-msg-iter.h \
mu-msg-part.c \ mu-msg-part.c \
mu-msg-part.h \ mu-msg-part.h \
mu-msg-str.c \ mu-str.c \
mu-msg-str-normalize.c \ mu-str-normalize.c \
mu-msg-str.h \ mu-str.h \
mu-msg.h \ mu-msg.h \
mu-output-link.c \ mu-output-link.c \
mu-output-link.h \ mu-output-link.h \

View File

@ -25,7 +25,6 @@
#include "mu-msg.h" #include "mu-msg.h"
#include "mu-msg-part.h" #include "mu-msg-part.h"
#include "mu-msg-str.h"
#include "mu-cmd.h" #include "mu-cmd.h"
#include "mu-util.h" #include "mu-util.h"

View File

@ -33,7 +33,6 @@
#include "mu-index.h" #include "mu-index.h"
#include "mu-query.h" #include "mu-query.h"
#include "mu-msg-iter.h" #include "mu-msg-iter.h"
#include "mu-msg-str.h"
#include "mu-bookmarks.h" #include "mu-bookmarks.h"
#include "mu-runtime.h" #include "mu-runtime.h"

View File

@ -26,7 +26,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "mu-msg.h" #include "mu-msg.h"
#include "mu-msg-str.h" #include "mu-str.h"
#include "mu-cmd.h" #include "mu-cmd.h"
#include "mu-util.h" #include "mu-util.h"
@ -57,7 +57,7 @@ view_file (const gchar *path, const gchar *fields, size_t summary_len)
g_print ("Subject: %s\n", field); g_print ("Subject: %s\n", field);
if ((date = mu_msg_get_date (msg))) if ((date = mu_msg_get_date (msg)))
g_print ("Date: %s\n", mu_msg_str_date_s ("%c", date)); g_print ("Date: %s\n", mu_str_date_s ("%c", date));
if (summary_len > 0) { if (summary_len > 0) {
field = mu_msg_get_summary (msg, summary_len); field = mu_msg_get_summary (msg, summary_len);

View File

@ -27,7 +27,7 @@
#include <ctype.h> #include <ctype.h>
#include "mu-util.h" #include "mu-util.h"
#include "mu-msg-str.h" #include "mu-str.h"
#include "mu-msg-priv.h" /* include before mu-msg.h */ #include "mu-msg-priv.h" /* include before mu-msg.h */
#include "mu-msg.h" #include "mu-msg.h"
@ -763,7 +763,7 @@ mu_msg_get_summary (MuMsg *msg, size_t max_lines)
return NULL; /* there was no text body */ return NULL; /* there was no text body */
return msg->_fields[SUMMARY_FIELD] = return msg->_fields[SUMMARY_FIELD] =
mu_msg_str_summarize (body, max_lines); mu_str_summarize (body, max_lines);
} }

View File

@ -30,7 +30,6 @@
#include "mu-maildir.h" #include "mu-maildir.h"
#include "mu-index.h" #include "mu-index.h"
#include "mu-msg-iter.h" #include "mu-msg-iter.h"
#include "mu-msg-str.h"
#include "mu-util.h" #include "mu-util.h"
#include "mu-output-link.h" #include "mu-output-link.h"

View File

@ -30,7 +30,7 @@
#include "mu-maildir.h" #include "mu-maildir.h"
#include "mu-index.h" #include "mu-index.h"
#include "mu-msg-iter.h" #include "mu-msg-iter.h"
#include "mu-msg-str.h" #include "mu-str.h"
/* #include "mu-util.h" */ /* #include "mu-util.h" */
/* #include "mu-util-db.h" */ /* #include "mu-util-db.h" */
@ -55,17 +55,17 @@ display_field (MuMsgIter *iter, MuMsgFieldId mfid)
return mu_msg_prio_name ((MuMsgPrio)val); return mu_msg_prio_name ((MuMsgPrio)val);
} else if (mfid == MU_MSG_FIELD_ID_FLAGS) { } else if (mfid == MU_MSG_FIELD_ID_FLAGS) {
val = mu_msg_iter_get_field_numeric (iter, mfid); val = mu_msg_iter_get_field_numeric (iter, mfid);
return mu_msg_str_flags_s ((MuMsgFlags)val); return mu_str_flags_s ((MuMsgFlags)val);
} else /* as string */ } else /* as string */
return mu_msg_iter_get_field (iter, mfid); return mu_msg_iter_get_field (iter, mfid);
case MU_MSG_FIELD_TYPE_TIME_T: case MU_MSG_FIELD_TYPE_TIME_T:
val = mu_msg_iter_get_field_numeric (iter, mfid); val = mu_msg_iter_get_field_numeric (iter, mfid);
return mu_msg_str_date_s ("%c", (time_t)val); return mu_str_date_s ("%c", (time_t)val);
case MU_MSG_FIELD_TYPE_BYTESIZE: case MU_MSG_FIELD_TYPE_BYTESIZE:
val = mu_msg_iter_get_field_numeric (iter, mfid); val = mu_msg_iter_get_field_numeric (iter, mfid);
return mu_msg_str_size_s ((unsigned)val); return mu_str_size_s ((unsigned)val);
default: default:
g_return_val_if_reached (NULL); g_return_val_if_reached (NULL);
} }

View File

@ -35,7 +35,7 @@
#include "mu-util.h" #include "mu-util.h"
#include "mu-util-db.h" #include "mu-util-db.h"
#include "mu-msg-str.h" #include "mu-str.h"
/* /*
* a xapian value date processor with the following properties: * a xapian value date processor with the following properties:
@ -391,7 +391,7 @@ mu_query_preprocess (const char *query)
* will fixes some of the false-negatives. A full fix * will fixes some of the false-negatives. A full fix
* probably requires some custom query parser. * probably requires some custom query parser.
*/ */
my_query = mu_msg_str_normalize(query, TRUE); my_query = mu_str_normalize(query, TRUE);
for (cur = my_query; *cur; ++cur) { for (cur = my_query; *cur; ++cur) {
if (*cur == ':') /* we found a ':' */ if (*cur == ':') /* we found a ':' */

View File

@ -29,7 +29,7 @@
#include "mu-msg-contact.h" #include "mu-msg-contact.h"
#include "mu-store.h" #include "mu-store.h"
#include "mu-util.h" #include "mu-util.h"
#include "mu-msg-str.h" #include "mu-str.h"
#include "mu-msg-flags.h" #include "mu-msg-flags.h"
/* number of new messages after which we commit to the database */ /* number of new messages after which we commit to the database */
@ -325,7 +325,7 @@ add_terms_values_string (Xapian::Document& doc, MuMsg *msg,
if (mu_msg_field_xapian_index (mfid)) { if (mu_msg_field_xapian_index (mfid)) {
Xapian::TermGenerator termgen; Xapian::TermGenerator termgen;
gchar *norm (mu_msg_str_normalize(str, TRUE)); gchar *norm (mu_str_normalize(str, TRUE));
termgen.set_document (doc); termgen.set_document (doc);
termgen.index_text_without_positions (norm, 1, prefix); termgen.index_text_without_positions (norm, 1, prefix);
g_free(norm); g_free(norm);
@ -334,7 +334,7 @@ add_terms_values_string (Xapian::Document& doc, MuMsg *msg,
if (mu_msg_field_xapian_term(mfid)) { if (mu_msg_field_xapian_term(mfid)) {
/* add a normalized version (accents removed, /* add a normalized version (accents removed,
* lowercase) */ * lowercase) */
gchar *norm = mu_msg_str_normalize(str, TRUE); gchar *norm = mu_str_normalize(str, TRUE);
doc.add_term (std::string (prefix + std::string(norm), 0, doc.add_term (std::string (prefix + std::string(norm), 0,
MU_STORE_MAX_TERM_LENGTH)); MU_STORE_MAX_TERM_LENGTH));
g_free (norm); g_free (norm);
@ -366,7 +366,7 @@ add_terms_values_body (Xapian::Document& doc, MuMsg *msg,
Xapian::TermGenerator termgen; Xapian::TermGenerator termgen;
termgen.set_document(doc); termgen.set_document(doc);
norm = mu_msg_str_normalize (str, TRUE); norm = mu_str_normalize (str, TRUE);
termgen.index_text_without_positions termgen.index_text_without_positions
(norm, 1, (norm, 1,
std::string(1, mu_msg_field_xapian_prefix(mfid))); std::string(1, mu_msg_field_xapian_prefix(mfid)));
@ -435,7 +435,7 @@ each_contact_info (MuMsgContact *contact, MsgDoc *data)
if (contact->name && strlen(contact->name) > 0) { if (contact->name && strlen(contact->name) > 0) {
Xapian::TermGenerator termgen; Xapian::TermGenerator termgen;
termgen.set_document (*data->_doc); termgen.set_document (*data->_doc);
char *norm = mu_msg_str_normalize (contact->name, TRUE); char *norm = mu_str_normalize (contact->name, TRUE);
termgen.index_text_without_positions (norm, 1, *pfxp); termgen.index_text_without_positions (norm, 1, *pfxp);
g_free (norm); g_free (norm);
} }

View File

@ -26,16 +26,16 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "mu-msg-str.h" #include "mu-str.h"
static char* normalize_in_place_downcase (char *str); static char* normalize_in_place_downcase (char *str);
char* char*
mu_msg_str_normalize (const char *str, gboolean downcase) mu_str_normalize (const char *str, gboolean downcase)
{ {
g_return_val_if_fail (str, NULL); g_return_val_if_fail (str, NULL);
return mu_msg_str_normalize_in_place (g_strdup(str), downcase); return mu_str_normalize_in_place (g_strdup(str), downcase);
} }
/* we can normalize in-place, as the normalized string will never be /* we can normalize in-place, as the normalized string will never be
@ -44,7 +44,7 @@ mu_msg_str_normalize (const char *str, gboolean downcase)
* original 0xc3 0x9f * original 0xc3 0x9f
*/ */
char* char*
mu_msg_str_normalize_in_place (char *str, gboolean downcase) mu_str_normalize_in_place (char *str, gboolean downcase)
{ {
const guchar *cur; const guchar *cur;
int i; int i;

View File

@ -27,12 +27,12 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "mu-msg-str.h" #include "mu-str.h"
#include "mu-msg-flags.h" #include "mu-msg-flags.h"
const char* const char*
mu_msg_str_date_s (const char* frm, time_t t) mu_str_date_s (const char* frm, time_t t)
{ {
struct tm *tmbuf; struct tm *tmbuf;
static char buf[128]; static char buf[128];
@ -47,15 +47,15 @@ mu_msg_str_date_s (const char* frm, time_t t)
} }
char* char*
mu_msg_str_date (const char *frm, time_t t) mu_str_date (const char *frm, time_t t)
{ {
return g_strdup (mu_msg_str_date_s(frm, t)); return g_strdup (mu_str_date_s(frm, t));
} }
const char* const char*
mu_msg_str_display_date_s (time_t t) mu_str_display_date_s (time_t t)
{ {
time_t now; time_t now;
static const time_t SECS_IN_DAY = 24 * 60 * 60; static const time_t SECS_IN_DAY = 24 * 60 * 60;
@ -63,13 +63,13 @@ mu_msg_str_display_date_s (time_t t)
now = time (NULL); now = time (NULL);
if (ABS(now - t) > SECS_IN_DAY) if (ABS(now - t) > SECS_IN_DAY)
return mu_msg_str_date_s ("%x", t); return mu_str_date_s ("%x", t);
else else
return mu_msg_str_date_s ("%X", t); return mu_str_date_s ("%X", t);
} }
const char* const char*
mu_msg_str_size_s (size_t s) mu_str_size_s (size_t s)
{ {
static char buf[32]; static char buf[32];
@ -94,25 +94,25 @@ mu_msg_str_size_s (size_t s)
} }
char* char*
mu_msg_str_size (size_t s) mu_str_size (size_t s)
{ {
return g_strdup (mu_msg_str_size_s(s)); return g_strdup (mu_str_size_s(s));
} }
const char* const char*
mu_msg_str_flags_s (MuMsgFlags flags) mu_str_flags_s (MuMsgFlags flags)
{ {
return mu_msg_flags_str_s (flags); return mu_msg_flags_str_s (flags);
} }
char* char*
mu_msg_str_flags (MuMsgFlags flags) mu_str_flags (MuMsgFlags flags)
{ {
return g_strdup (mu_msg_str_flags_s(flags)); return g_strdup (mu_str_flags_s(flags));
} }
char* char*
mu_msg_str_summarize (const char* str, size_t max_lines) mu_str_summarize (const char* str, size_t max_lines)
{ {
char *summary; char *summary;
size_t nl_seen; size_t nl_seen;
@ -154,7 +154,7 @@ mu_msg_str_summarize (const char* str, size_t max_lines)
const char* const char*
mu_msg_str_display_contact_s (const char *str) mu_str_display_contact_s (const char *str)
{ {
static gchar contact[255]; static gchar contact[255];
gchar *c, *c2; gchar *c, *c2;
@ -180,9 +180,9 @@ mu_msg_str_display_contact_s (const char *str)
} }
char* char*
mu_msg_str_display_contact (const char *str) mu_str_display_contact (const char *str)
{ {
g_return_val_if_fail (str, NULL); g_return_val_if_fail (str, NULL);
return g_strdup (mu_msg_str_display_contact_s (str)); return g_strdup (mu_str_display_contact_s (str));
} }

View File

@ -17,8 +17,8 @@
** **
*/ */
#ifndef __MU_MSG_STR_H__ #ifndef __MU_STR_H__
#define __MU_MSG_STR_H__ #define __MU_STR_H__
#include <time.h> #include <time.h>
#include <sys/types.h> #include <sys/types.h>
@ -31,8 +31,8 @@ G_BEGIN_DECLS
/** /**
* get a string for a given time_t * get a string for a given time_t
* *
* mu_msg_str_date_s returns a ptr to a static buffer, * mu_str_date_s returns a ptr to a static buffer,
* while mu_msg_str_date returns dynamically allocated * while mu_str_date returns dynamically allocated
* memory that must be freed after use. * memory that must be freed after use.
* *
* @param frm the format of the string (in strftime(3) format) * @param frm the format of the string (in strftime(3) format)
@ -43,8 +43,8 @@ G_BEGIN_DECLS
* format is too long, the value will be truncated. in practice this * format is too long, the value will be truncated. in practice this
* should not happen. * should not happen.
*/ */
const char* mu_msg_str_date_s (const char* frm, time_t t) G_GNUC_CONST; const char* mu_str_date_s (const char* frm, time_t t) G_GNUC_CONST;
char* mu_msg_str_date (const char* frm, time_t t) G_GNUC_WARN_UNUSED_RESULT; char* mu_str_date (const char* frm, time_t t) G_GNUC_WARN_UNUSED_RESULT;
/** /**
@ -52,13 +52,13 @@ char* mu_msg_str_date (const char* frm, time_t t) G_GNUC_WARN_UNUSED_RES
* 24h from the current time, we display the time, otherwise the date, * 24h from the current time, we display the time, otherwise the date,
* using the preferred date/time for the current locale * using the preferred date/time for the current locale
* *
* mu_msg_str_display_date_s returns a ptr to a static buffer, * mu_str_display_date_s returns a ptr to a static buffer,
* *
* @param t the time as time_t * @param t the time as time_t
* *
* @return a string representation of the time/date * @return a string representation of the time/date
*/ */
const char* mu_msg_str_display_date_s (time_t t); const char* mu_str_display_date_s (time_t t);
/** /**
@ -69,8 +69,8 @@ const char* mu_msg_str_display_date_s (time_t t);
* Foo Bar * Foo Bar
* Note that this is based on some simple heuristics. Max length is 255 bytes. * Note that this is based on some simple heuristics. Max length is 255 bytes.
* *
* mu_msg_str_display_contact_s returns a statically allocated * mu_str_display_contact_s returns a statically allocated
* buffer (ie, non-reentrant), while mu_msg_str_display_contact * buffer (ie, non-reentrant), while mu_str_display_contact
* returns a newly allocated string that you must free with g_free * returns a newly allocated string that you must free with g_free
* when done with it. * when done with it.
* *
@ -78,8 +78,8 @@ const char* mu_msg_str_display_date_s (time_t t);
* *
* @return a newly allocated string with a display contact * @return a newly allocated string with a display contact
*/ */
const char* mu_msg_str_display_contact_s (const char *str); const char* mu_str_display_contact_s (const char *str);
char *mu_msg_str_display_contact (const char *str); char *mu_str_display_contact (const char *str);
/** /**
@ -87,8 +87,8 @@ char *mu_msg_str_display_contact (const char *str);
* 1000*1000, k for smaller sizes. Note: this function use the * 1000*1000, k for smaller sizes. Note: this function use the
* 10-based SI units, _not_ the powers-of-2 based ones. * 10-based SI units, _not_ the powers-of-2 based ones.
* *
* mu_msg_str_size_s returns a ptr to a static buffer, * mu_str_size_s returns a ptr to a static buffer,
* while mu_msg_str_size returns dynamically allocated * while mu_str_size returns dynamically allocated
* memory that must be freed after use. * memory that must be freed after use.
* *
* @param t the size as an size_t * @param t the size as an size_t
@ -96,8 +96,8 @@ char *mu_msg_str_display_contact (const char *str);
* @return a string representation of the size; see above * @return a string representation of the size; see above
* for what to do with it * for what to do with it
*/ */
const char* mu_msg_str_size_s (size_t s) G_GNUC_CONST; const char* mu_str_size_s (size_t s) G_GNUC_CONST;
char* mu_msg_str_size (size_t s) G_GNUC_WARN_UNUSED_RESULT; char* mu_str_size (size_t s) G_GNUC_WARN_UNUSED_RESULT;
/** /**
* get a display string for a given set of flags, OR'ed in * get a display string for a given set of flags, OR'ed in
@ -105,8 +105,8 @@ char* mu_msg_str_size (size_t s) G_GNUC_WARN_UNUSED_RESULT;
* D=draft,F=flagged,N=new,P=passed,R=replied,S=seen,T=trashed * D=draft,F=flagged,N=new,P=passed,R=replied,S=seen,T=trashed
* a=has-attachment,s=signed, x=encrypted * a=has-attachment,s=signed, x=encrypted
* *
* mu_msg_str_file_flags_s returns a ptr to a static buffer, * mu_str_file_flags_s returns a ptr to a static buffer,
* while mu_msg_str_file_flags returns dynamically allocated * while mu_str_file_flags returns dynamically allocated
* memory that must be freed after use. * memory that must be freed after use.
* *
* @param flags file flags * @param flags file flags
@ -114,8 +114,8 @@ char* mu_msg_str_size (size_t s) G_GNUC_WARN_UNUSED_RESULT;
* @return a string representation of the flags; see above * @return a string representation of the flags; see above
* for what to do with it * for what to do with it
*/ */
const char* mu_msg_str_flags_s (MuMsgFlags flags) G_GNUC_CONST; const char* mu_str_flags_s (MuMsgFlags flags) G_GNUC_CONST;
char* mu_msg_str_flags (MuMsgFlags flags) G_GNUC_WARN_UNUSED_RESULT; char* mu_str_flags (MuMsgFlags flags) G_GNUC_WARN_UNUSED_RESULT;
/** /**
@ -127,7 +127,7 @@ char* mu_msg_str_flags (MuMsgFlags flags) G_GNUC_WARN_UNUSED_RESULT;
* *
* @return a newly allocated string with the summary. use g_free to free it. * @return a newly allocated string with the summary. use g_free to free it.
*/ */
char* mu_msg_str_summarize (const char* str, char* mu_str_summarize (const char* str,
size_t max_lines) G_GNUC_WARN_UNUSED_RESULT; size_t max_lines) G_GNUC_WARN_UNUSED_RESULT;
@ -142,22 +142,22 @@ char* mu_msg_str_summarize (const char* str,
* *
* @return the normalize string, or NULL in case of error or str was NULL * @return the normalize string, or NULL in case of error or str was NULL
*/ */
char* mu_msg_str_normalize (const char *str, gboolean downcase); char* mu_str_normalize (const char *str, gboolean downcase);
/** /**
* normalize a string (ie., collapse accented characters etc.), and * normalize a string (ie., collapse accented characters etc.), and
* optionally, downcase it. this happen by changing the string; if * optionally, downcase it. this happen by changing the string; if
* that is not desired, use mu_msg_str_normalize * that is not desired, use mu_str_normalize
* *
* @param str a valid utf8 string or NULL * @param str a valid utf8 string or NULL
* @param downcase if TRUE, convert the string to lowercase * @param downcase if TRUE, convert the string to lowercase
* *
* @return the normalize string, or NULL in case of error or str was NULL * @return the normalize string, or NULL in case of error or str was NULL
*/ */
char* mu_msg_str_normalize_in_place (char *str, gboolean downcase); char* mu_str_normalize_in_place (char *str, gboolean downcase);
G_END_DECLS G_END_DECLS
#endif /*__MU_MSG_STR_H__*/ #endif /*__MU_STR_H__*/

View File

@ -40,9 +40,9 @@ TEST_PROGS += test-mu-util
test_mu_util_SOURCES= test-mu-util.c test_mu_util_SOURCES= test-mu-util.c
test_mu_util_LDADD= libtestmucommon.la test_mu_util_LDADD= libtestmucommon.la
TEST_PROGS += test-mu-msg-str TEST_PROGS += test-mu-str
test_mu_msg_str_SOURCES= test-mu-msg-str.c test_mu_str_SOURCES= test-mu-str.c
test_mu_msg_str_LDADD= libtestmucommon.la test_mu_str_LDADD= libtestmucommon.la
TEST_PROGS += test-mu-maildir TEST_PROGS += test-mu-maildir
test_mu_maildir_SOURCES= test-mu-maildir.c test_mu_maildir_SOURCES= test-mu-maildir.c

View File

@ -29,11 +29,11 @@
#include <locale.h> #include <locale.h>
#include "test-mu-common.h" #include "test-mu-common.h"
#include "src/mu-msg-str.h" #include "src/mu-str.h"
#include "src/mu-msg-prio.h" #include "src/mu-msg-prio.h"
static void static void
test_mu_msg_str_date_01 (void) test_mu_str_date_01 (void)
{ {
struct tm *tmbuf; struct tm *tmbuf;
char buf[64]; char buf[64];
@ -45,13 +45,13 @@ test_mu_msg_str_date_01 (void)
strftime (buf, 64, "%x", tmbuf); strftime (buf, 64, "%x", tmbuf);
/* $ date -ud@1234567890; Fri Feb 13 23:31:30 UTC 2009 */ /* $ date -ud@1234567890; Fri Feb 13 23:31:30 UTC 2009 */
g_assert_cmpstr (mu_msg_str_date_s ("%x", some_time), ==, buf); g_assert_cmpstr (mu_str_date_s ("%x", some_time), ==, buf);
/* date -ud@987654321 Thu Apr 19 04:25:21 UTC 2001 */ /* date -ud@987654321 Thu Apr 19 04:25:21 UTC 2001 */
some_time = 987654321; some_time = 987654321;
tmbuf = localtime (&some_time); tmbuf = localtime (&some_time);
strftime (buf, 64, "%c", tmbuf); strftime (buf, 64, "%c", tmbuf);
tmp = mu_msg_str_date ("%c", some_time); tmp = mu_str_date ("%c", some_time);
g_assert_cmpstr (tmp, ==, buf); g_assert_cmpstr (tmp, ==, buf);
g_free (tmp); g_free (tmp);
@ -60,7 +60,7 @@ test_mu_msg_str_date_01 (void)
static void static void
test_mu_msg_str_size_01 (void) test_mu_str_size_01 (void)
{ {
struct lconv *lc; struct lconv *lc;
char *tmp2; char *tmp2;
@ -68,22 +68,22 @@ test_mu_msg_str_size_01 (void)
lc = localeconv(); lc = localeconv();
tmp2 = g_strdup_printf ("0%s0 kB", lc->decimal_point); tmp2 = g_strdup_printf ("0%s0 kB", lc->decimal_point);
g_assert_cmpstr (mu_msg_str_size_s (0), ==, tmp2); g_assert_cmpstr (mu_str_size_s (0), ==, tmp2);
g_free (tmp2); g_free (tmp2);
tmp2 = g_strdup_printf ("100%s0 kB", lc->decimal_point); tmp2 = g_strdup_printf ("100%s0 kB", lc->decimal_point);
g_assert_cmpstr (mu_msg_str_size_s (100000), ==, tmp2); g_assert_cmpstr (mu_str_size_s (100000), ==, tmp2);
g_free (tmp2); g_free (tmp2);
tmp2 = g_strdup_printf ("1%s1 MB", lc->decimal_point); tmp2 = g_strdup_printf ("1%s1 MB", lc->decimal_point);
g_assert_cmpstr (mu_msg_str_size_s (1100*1000), ==, tmp2); g_assert_cmpstr (mu_str_size_s (1100*1000), ==, tmp2);
g_free (tmp2); g_free (tmp2);
} }
static void static void
test_mu_msg_str_size_02 (void) test_mu_str_size_02 (void)
{ {
struct lconv *lc; struct lconv *lc;
char *tmp1, *tmp2; char *tmp1, *tmp2;
@ -91,7 +91,7 @@ test_mu_msg_str_size_02 (void)
lc = localeconv(); lc = localeconv();
tmp2 = g_strdup_printf ("1%s0 MB", lc->decimal_point); tmp2 = g_strdup_printf ("1%s0 MB", lc->decimal_point);
tmp1 = mu_msg_str_size (999999); tmp1 = mu_str_size (999999);
g_assert_cmpstr (tmp1, !=, tmp2); g_assert_cmpstr (tmp1, !=, tmp2);
g_free (tmp1); g_free (tmp1);
@ -101,7 +101,7 @@ test_mu_msg_str_size_02 (void)
static void static void
test_mu_msg_str_prio_01 (void) test_mu_str_prio_01 (void)
{ {
g_assert_cmpstr(mu_msg_prio_name(MU_MSG_PRIO_LOW), ==, "low"); g_assert_cmpstr(mu_msg_prio_name(MU_MSG_PRIO_LOW), ==, "low");
g_assert_cmpstr(mu_msg_prio_name(MU_MSG_PRIO_NORMAL), ==, "normal"); g_assert_cmpstr(mu_msg_prio_name(MU_MSG_PRIO_NORMAL), ==, "normal");
@ -118,7 +118,7 @@ ignore_error (const char* log_domain, GLogLevelFlags log_level,
static void static void
test_mu_msg_str_prio_02 (void) test_mu_str_prio_02 (void)
{ {
/* this must fail */ /* this must fail */
g_test_log_set_fatal_handler ((GTestLogFatalFunc)ignore_error, NULL); g_test_log_set_fatal_handler ((GTestLogFatalFunc)ignore_error, NULL);
@ -128,7 +128,7 @@ test_mu_msg_str_prio_02 (void)
static void static void
test_mu_msg_str_normalize_01 (void) test_mu_str_normalize_01 (void)
{ {
int i; int i;
struct { struct {
@ -145,7 +145,7 @@ test_mu_msg_str_normalize_01 (void)
for (i = 0; i != G_N_ELEMENTS(words); ++i) { for (i = 0; i != G_N_ELEMENTS(words); ++i) {
gchar *str; gchar *str;
str = mu_msg_str_normalize (words[i].word, TRUE); str = mu_str_normalize (words[i].word, TRUE);
g_assert_cmpstr (str, ==, words[i].norm); g_assert_cmpstr (str, ==, words[i].norm);
g_free (str); g_free (str);
} }
@ -160,28 +160,28 @@ main (int argc, char *argv[])
{ {
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
/* mu_msg_str_date */ /* mu_str_date */
g_test_add_func ("/mu-msg-str/mu-msg-str-date", g_test_add_func ("/mu-msg-str/mu-msg-str-date",
test_mu_msg_str_date_01); test_mu_str_date_01);
/* mu_msg_str_size */ /* mu_str_size */
g_test_add_func ("/mu-msg-str/mu-msg-str-size-01", g_test_add_func ("/mu-msg-str/mu-msg-str-size-01",
test_mu_msg_str_size_01); test_mu_str_size_01);
g_test_add_func ("/mu-msg-str/mu-msg-str-size-02", g_test_add_func ("/mu-msg-str/mu-msg-str-size-02",
test_mu_msg_str_size_02); test_mu_str_size_02);
/* mu_msg_str_prio */ /* mu_str_prio */
g_test_add_func ("/mu-msg-str/mu-msg-str-prio-01", g_test_add_func ("/mu-msg-str/mu-msg-str-prio-01",
test_mu_msg_str_prio_01); test_mu_str_prio_01);
g_test_add_func ("/mu-msg-str/mu-msg-str-prio-02", g_test_add_func ("/mu-msg-str/mu-msg-str-prio-02",
test_mu_msg_str_prio_02); test_mu_str_prio_02);
/* mu_msg_str_normalize */ /* mu_str_normalize */
g_test_add_func ("/mu-msg-str/mu-msg-str-normalize-01", g_test_add_func ("/mu-msg-str/mu-msg-str-normalize-01",
test_mu_msg_str_normalize_01); test_mu_str_normalize_01);
/* FIXME: add tests for mu_msg_str_flags; but note the /* FIXME: add tests for mu_str_flags; but note the
* function simply calls mu_msg_field_str */ * function simply calls mu_msg_field_str */
g_log_set_handler (NULL, g_log_set_handler (NULL,

View File

@ -19,7 +19,7 @@
#include "mug-msg-list-view.h" #include "mug-msg-list-view.h"
#include "mu-query.h" #include "mu-query.h"
#include "mu-msg-str.h" #include "mu-str.h"
/* include other impl specific header files */ /* include other impl specific header files */
/* 'private'/'protected' functions */ /* 'private'/'protected' functions */
@ -298,7 +298,7 @@ empty_or_display_contact (const gchar* str)
if (!str || *str == '\0') if (!str || *str == '\0')
return g_strdup ("-"); return g_strdup ("-");
else else
return mu_msg_str_display_contact (str); return mu_str_display_contact (str);
} }
@ -334,7 +334,7 @@ add_row (GtkListStore *store, MuMsgIter *iter)
time_t date; time_t date;
date = mu_msg_iter_get_date (iter); date = mu_msg_iter_get_date (iter);
datestr = date == 0 ? "-" : mu_msg_str_display_date_s (date); datestr = date == 0 ? "-" : mu_str_display_date_s (date);
from = empty_or_display_contact (mu_msg_iter_get_from(iter)); from = empty_or_display_contact (mu_msg_iter_get_from(iter));
to = empty_or_display_contact (mu_msg_iter_get_to(iter)); to = empty_or_display_contact (mu_msg_iter_get_to(iter));
flagstr = mu_msg_flags_str_s(mu_msg_iter_get_flags (iter)); flagstr = mu_msg_flags_str_s(mu_msg_iter_get_flags (iter));

View File

@ -20,7 +20,7 @@
#include "mug-msg-view.h" #include "mug-msg-view.h"
#include "mu-msg.h" #include "mu-msg.h"
#include "mu-msg-str.h" #include "mu-str.h"
/* 'private'/'protected' functions */ /* 'private'/'protected' functions */
static void mug_msg_view_class_init (MugMsgViewClass *klass); static void mug_msg_view_class_init (MugMsgViewClass *klass);
@ -243,10 +243,10 @@ fill_header (MugMsgViewPrivate *priv, MuMsg* msg)
case HEADER_ROW_MSGID: val = mu_msg_get_msgid(msg); break; case HEADER_ROW_MSGID: val = mu_msg_get_msgid(msg); break;
case HEADER_ROW_CC: val = mu_msg_get_cc (msg); break; case HEADER_ROW_CC: val = mu_msg_get_cc (msg); break;
case HEADER_ROW_PATH: val = mu_msg_get_path (msg); break; case HEADER_ROW_PATH: val = mu_msg_get_path (msg); break;
case HEADER_ROW_DATE: val = mu_msg_str_date_s( case HEADER_ROW_DATE: val = mu_str_date_s(
"%c", mu_msg_get_date (msg)); "%c", mu_msg_get_date (msg));
break; break;
case HEADER_ROW_SIZE: val = mu_msg_str_size_s (mu_msg_get_size(msg)); case HEADER_ROW_SIZE: val = mu_str_size_s (mu_msg_get_size(msg));
break; break;
default: val = NULL; default: val = NULL;
} }