Permalink
Browse files

* <many>: fix source code checks; move mu_msg_str_normalize to separa…

…te file
  • Loading branch information...
djcb committed Nov 20, 2010
1 parent 2c8bd10 commit 5818c40d7f6cc9c145ec45cb9f8151b3393c7795
Showing with 685 additions and 646 deletions.
  1. +7 −2 Makefile.am
  2. +1 −0 src/Makefile.am
  3. +18 −9 src/mu-cmd-find.c
  4. +13 −21 src/mu-msg-flags.c
  5. +644 −0 src/mu-msg-str-normalize.c
  6. +2 −614 src/mu-msg-str.c
View
@@ -32,13 +32,18 @@ tags:
# which is a sign that it needs some refactoring. requires the pmccabe
# tool. If all is fine, it outputs nothing
cc10:
- @$(PMCCABE) `find -name '*.c' -o -name '*.cc'` | sort -nr | awk '($$1 > 10)'
+ @$(PMCCABE) `find -name '*.c' -o -name '*.cc'` \
+ | grep -v mu-msg-str-normalize.c \
+ | sort -nr | awk '($$1 > 10)'
# this warns about functions that are over 33 non-comment lines long, which is a
# sign that they need some refactoring. requires the pmccabe tool. if
# all is fine, it outputs nothing
+# note, mu_msg_str_normalize is excempted from this rule.
line33:
- @$(PMCCABE) -c `find -name '*.c' -o -name '*.cc'` | awk '($$5 > 33)'
+ @$(PMCCABE) -c `find -name '*.c' -o -name '*.cc'` \
+ | grep -v mu-msg-str-normalize.c \
+ | awk '($$5 > 33)'
# get all todo/fixme messages
fixme:
View
@@ -80,6 +80,7 @@ libmu_la_SOURCES= \
mu-msg-part.c \
mu-msg-part.h \
mu-msg-str.c \
+ mu-msg-str-normalize.c \
mu-msg-str.h \
mu-msg.h \
mu-output-link.c \
View
@@ -243,6 +243,23 @@ get_query (MuConfigOptions *opts)
return query;
}
+static gboolean
+db_is_ready (const char *xpath)
+{
+ if (mu_util_db_is_empty (xpath)) {
+ g_warning ("Database is empty; use 'mu index' to "
+ "add messages");
+ return FALSE;
+ }
+
+ if (!mu_util_db_version_up_to_date (xpath)) {
+ update_warning ();
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
gboolean
mu_cmd_find (MuConfigOptions *opts)
@@ -259,16 +276,8 @@ mu_cmd_find (MuConfigOptions *opts)
return FALSE;
xpath = mu_runtime_xapian_dir ();
-
- if (mu_util_db_is_empty (xpath)) {
- g_warning ("Database is empty; use 'mu index' to add messages");
- return FALSE;
- }
-
- if (!mu_util_db_version_up_to_date (xpath)) {
- update_warning ();
+ if (!db_is_ready(xpath))
return FALSE;
- }
/* first param is 'query', search params are after that */
query = get_query (opts);
View
@@ -181,8 +181,10 @@ check_msg_type (const char* path, char **info)
* documentation at http://docs.python.org/lib/mailbox-maildir.html
* mentions the '!' as well as a 'popular choice'
*/
- dir = g_path_get_dirname (path);
- file = g_path_get_basename (path);
+
+ *info = NULL;
+ dir = g_path_get_dirname (path);
+ file = g_path_get_basename (path);
if (!(*info = strrchr(file, ':')))
*info = strrchr (file, '!'); /* Tinymail */
@@ -221,36 +223,26 @@ mu_msg_flags_from_file (const char* path)
MU_MSG_FLAG_NONE);
mtype = check_msg_type (path, &info);
-
- /* we ignore any flags for a new message */
- if (mtype == MSG_TYPE_NEW) {
+ if (mtype == MSG_TYPE_NEW) { /* we ignore any new-msg flags */
g_free (info);
return MU_MSG_FLAG_NEW;
}
- flags = 0;
+ flags = MU_MSG_FLAG_NONE;
if (mtype == MSG_TYPE_CUR || mtype == MSG_TYPE_OTHER) {
char *cursor = info;
/* only support the "2," format */
if (cursor && cursor[0]=='2' && cursor[1]==',') {
cursor += 2; /* jump past 2, */
- while (*cursor) {
+ for (; *cursor; ++cursor)
switch (*cursor) {
- case 'P': flags |= MU_MSG_FLAG_PASSED;
- break;
- case 'T': flags |= MU_MSG_FLAG_TRASHED;
- break;
- case 'R': flags |= MU_MSG_FLAG_REPLIED;
- break;
- case 'S': flags |= MU_MSG_FLAG_SEEN;
- break;
- case 'D': flags |= MU_MSG_FLAG_DRAFT;
- break;
- case 'F': flags |= MU_MSG_FLAG_FLAGGED;
- break;
+ case 'P': flags|= MU_MSG_FLAG_PASSED; break;
+ case 'T': flags|= MU_MSG_FLAG_TRASHED; break;
+ case 'R': flags|= MU_MSG_FLAG_REPLIED; break;
+ case 'S': flags|= MU_MSG_FLAG_SEEN; break;
+ case 'D': flags|= MU_MSG_FLAG_DRAFT;break;
+ case 'F': flags|= MU_MSG_FLAG_FLAGGED; break;
}
- ++cursor;
- }
}
}
g_free (info);
Oops, something went wrong.

0 comments on commit 5818c40

Please sign in to comment.