Skip to content

Commit

Permalink
* mu-msg-str: deal with size 0, and add add 'b' for byte in size: que…
Browse files Browse the repository at this point in the history
…ry params
  • Loading branch information
djcb committed May 20, 2011
1 parent 3aa034f commit 84662ef
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/mu-str.c
Expand Up @@ -325,19 +325,20 @@ mu_str_date_parse_hdwmy (const char* str)
guint64
mu_str_size_parse_kmg (const char* str)
{
guint64 num;
gint64 num;
char *end;

g_return_val_if_fail (str, G_MAXUINT64);

num = strtol (str, &end, 10);
if (num <= 0)
if (num < 0)
return G_MAXUINT64;

if (!end || end[1] != '\0')
return G_MAXUINT64;

switch (tolower(end[0])) {
case 'b': return num; /* bytes */
case 'k': return num * 1000; /* kilobyte */
case 'm': return num * 1000 * 1000; /* megabyte */
/* case 'g': return num * 1000 * 1000 * 1000; /\* gigabyte *\/ */
Expand All @@ -360,7 +361,7 @@ mu_str_ascii_xapian_escape_in_place (char *query)
replace_dot = (g_strstr_len(query, -1, "@") != NULL);

for (cur = query; *cur; ++cur) {
if (*cur == '@')
if (*cur == '@' || *cur == '-')
*cur = '_';

else if (replace_dot && *cur == '.') {
Expand Down

0 comments on commit 84662ef

Please sign in to comment.