mirror of https://github.com/djcb/mu.git
* optionally ignore invalid (unknown) message flag letters, update callers
This commit is contained in:
parent
7008e108ae
commit
895ab10a4b
|
@ -162,7 +162,8 @@ mu_flags_to_str_s (MuFlags flags, MuFlagType types)
|
|||
|
||||
|
||||
MuFlags
|
||||
mu_flags_from_str (const char *str, MuFlagType types)
|
||||
mu_flags_from_str (const char *str, MuFlagType types,
|
||||
gboolean ignore_invalid)
|
||||
{
|
||||
const char *cur;
|
||||
MuFlags flag;
|
||||
|
@ -174,6 +175,13 @@ mu_flags_from_str (const char *str, MuFlagType types)
|
|||
MuFlags f;
|
||||
|
||||
f = mu_flag_from_char (*cur);
|
||||
|
||||
if (f == MU_FLAG_INVALID) {
|
||||
if (ignore_invalid)
|
||||
continue;
|
||||
return MU_FLAG_INVALID;
|
||||
}
|
||||
|
||||
if (mu_flag_type (f) & types)
|
||||
flag |= f;
|
||||
}
|
||||
|
|
|
@ -115,13 +115,14 @@ const char* mu_flags_to_str_s (MuFlags flags, MuFlagType types);
|
|||
* Get the (OR'ed) flags corresponding to a string representation
|
||||
*
|
||||
* @param str the string representation
|
||||
* @param types the flag types to acceps (other will be ignored)
|
||||
* @param types the flag types to accept (other will be ignored)
|
||||
* @param ignore invalid if TRUE, ignore invalid flags, otherwise return
|
||||
* MU_FLAG_INVALID if an invalid flag is encountered
|
||||
*
|
||||
* @return the (OR'ed) flags
|
||||
*/
|
||||
MuFlags mu_flags_from_str (const char *str, MuFlagType types);
|
||||
|
||||
|
||||
MuFlags mu_flags_from_str (const char *str, MuFlagType types,
|
||||
gboolean ignore_invalid);
|
||||
|
||||
/**
|
||||
* Update #oldflags with the flags in #str, where #str consists of the
|
||||
|
|
|
@ -690,8 +690,9 @@ mu_maildir_get_flags_from_path (const char *path)
|
|||
(info[1] != ','))
|
||||
return MU_FLAG_NONE;
|
||||
else
|
||||
return mu_flags_from_str (&info[2],
|
||||
MU_FLAG_TYPE_MAILFILE);
|
||||
return mu_flags_from_str
|
||||
(&info[2], MU_FLAG_TYPE_MAILFILE,
|
||||
TRUE /*ignore invalid */);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -677,7 +677,7 @@ mu_msg_contact_foreach (MuMsg *msg, MuMsgContactForeachFunc func,
|
|||
|
||||
|
||||
static int
|
||||
cmp_str (const char* s1, const char *s2)
|
||||
cmp_str (const char *s1, const char *s2)
|
||||
{
|
||||
if (s1 == s2)
|
||||
return 0;
|
||||
|
|
|
@ -250,8 +250,8 @@ time_t mu_msg_get_date (MuMsg *msg);
|
|||
*
|
||||
* @param msg valid MuMsg* instance
|
||||
*
|
||||
* @return the fileflags as logically OR'd #Mu MsgFlags or 0 if
|
||||
* there are none.
|
||||
* @return the file/content flags as logically OR'd #MuMsgFlags or 0
|
||||
* if there are none. Non-standard flags are ignored.
|
||||
*/
|
||||
MuFlags mu_msg_get_flags (MuMsg *msg);
|
||||
|
||||
|
|
|
@ -832,7 +832,8 @@ get_flags (const char *path, const char *flagstr)
|
|||
return mu_flags_from_str_delta (flagstr, oldflags,
|
||||
MU_FLAG_TYPE_ANY);
|
||||
} else
|
||||
return mu_flags_from_str (flagstr, MU_FLAG_TYPE_ANY);
|
||||
return mu_flags_from_str (flagstr, MU_FLAG_TYPE_ANY,
|
||||
TRUE /*ignore invalid*/);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue