On Fri, Jun 09, 2000 at 05:50:51PM +0300, Mikko Hnninen <[EMAIL PROTECTED]> wrote:
> I wonder if it would be possible to make Mutt always assume decimal, as
> I doubt anyone will be specifying dates in either octal or hex. :-)
>
> It's kind of cool though, a limit of ~r 011/6/0x7d0- actually works.
> :-)
The attached patch (patch-1.3.2.bbell.pattern.1) can be applied to
to force base 10 parsing of dates. It does not force base 10 everywhere.
I believe this patch is desirable as dates are often represented with
leading zeroes.
Looking at the (unpatched) code, there is a mix of using base 10
or not:
color.c:318: *col = strtol (s, &eptr, 10);
color.c:566: *ql = strtol(buf->data + 6, &eptr, 10);
handler.c:1245: strtol (length, NULL, 10));
hdrline.c:244: min_width = strtol (prefix, &p, 10);
hdrline.c:248: max_width = strtol (prefix, &p, 10);
init.c:1091: val = strtol (tmp->data, &t, 0);
pattern.c:269: pat->min = strtol (s->dptr + 1, &tmp, 0) + 1; /* exclusive range */
pattern.c:272: pat->min = strtol (s->dptr, &tmp, 0);
pattern.c:306: pat->max = strtol (tmp, &tmp, 0);
pattern.c:334: t->tm_mday = strtol (s, &p, 0);
pattern.c:348: t->tm_mon = strtol (p, &p, 0) - 1;
pattern.c:360: t->tm_year = strtol (p, &p, 0);
pattern.c:375: int offset = strtol (s, &ps, 0);
My patch patch-1.3.2.bbell.pattern.1 fixes pattern.c lines 334,
348, and 360 to work on dates only. If you want to throw octal and
hexadecimal parsing out the window entirely, you can apply
patch-1.3.2.bbell.strtol.1 instead. This is a little more consistent,
though you potentially lose some power.
I'll leave the decision up to someone else :-)
--
Bob Bell Compaq Computer Corporation
Software Engineer 110 Spit Brook Rd - ZKO3-3/U14
TruCluster Group Nashua, NH 03062-2698
[EMAIL PROTECTED] 603-884-0595
--- old/mutt-1.3.2/pattern.c Tue May 9 11:23:01 2000
+++ mutt-1.3.2/pattern.c Fri Jun 9 11:50:55 2000
@@ -331,7 +331,7 @@ static const char *getDate (const char *
time_t now = time (NULL);
struct tm *tm = localtime (&now);
- t->tm_mday = strtol (s, &p, 0);
+ t->tm_mday = strtol (s, &p, 10);
if (t->tm_mday < 1 || t->tm_mday > 31)
{
snprintf (err->data, err->dsize, _("Invalid day of month: %s"), s);
@@ -345,7 +345,7 @@ static const char *getDate (const char *
return p;
}
p++;
- t->tm_mon = strtol (p, &p, 0) - 1;
+ t->tm_mon = strtol (p, &p, 10) - 1;
if (t->tm_mon < 0 || t->tm_mon > 11)
{
snprintf (err->data, err->dsize, _("Invalid month: %s"), p);
@@ -357,7 +357,7 @@ static const char *getDate (const char *
return p;
}
p++;
- t->tm_year = strtol (p, &p, 0);
+ t->tm_year = strtol (p, &p, 10);
if (t->tm_year < 70) /* year 2000+ */
t->tm_year += 100;
else if (t->tm_year > 1900)
diff -rup old/mutt-1.3.2/init.c mutt-1.3.2/init.c
--- old/mutt-1.3.2/init.c Sat May 20 03:30:46 2000
+++ mutt-1.3.2/init.c Fri Jun 9 11:57:27 2000
@@ -1088,7 +1088,7 @@ static int parse_set (BUFFER *tmp, BUFFE
s->dptr++;
mutt_extract_token (tmp, s, 0);
- val = strtol (tmp->data, &t, 0);
+ val = strtol (tmp->data, &t, 10);
if (!*tmp->data || *t || (short) val != val)
{
diff -rup old/mutt-1.3.2/pattern.c mutt-1.3.2/pattern.c
--- old/mutt-1.3.2/pattern.c Tue May 9 11:23:01 2000
+++ mutt-1.3.2/pattern.c Fri Jun 9 11:57:56 2000
@@ -266,10 +266,10 @@ int eat_range (pattern_t *pat, BUFFER *s
if (*s->dptr == '>')
{
pat->max = M_MAXRANGE;
- pat->min = strtol (s->dptr + 1, &tmp, 0) + 1; /* exclusive range */
+ pat->min = strtol (s->dptr + 1, &tmp, 10) + 1; /* exclusive range */
}
else
- pat->min = strtol (s->dptr, &tmp, 0);
+ pat->min = strtol (s->dptr, &tmp, 10);
if (toupper (*tmp) == 'K') /* is there a prefix? */
{
pat->min *= 1024;
@@ -303,7 +303,7 @@ int eat_range (pattern_t *pat, BUFFER *s
if (isdigit ((unsigned char) *tmp))
{
/* range maximum */
- pat->max = strtol (tmp, &tmp, 0);
+ pat->max = strtol (tmp, &tmp, 10);
if (toupper (*tmp) == 'K')
{
pat->max *= 1024;
@@ -331,7 +331,7 @@ static const char *getDate (const char *
time_t now = time (NULL);
struct tm *tm = localtime (&now);
- t->tm_mday = strtol (s, &p, 0);
+ t->tm_mday = strtol (s, &p, 10);
if (t->tm_mday < 1 || t->tm_mday > 31)
{
snprintf (err->data, err->dsize, _("Invalid day of month: %s"), s);
@@ -345,7 +345,7 @@ static const char *getDate (const char *
return p;
}
p++;
- t->tm_mon = strtol (p, &p, 0) - 1;
+ t->tm_mon = strtol (p, &p, 10) - 1;
if (t->tm_mon < 0 || t->tm_mon > 11)
{
snprintf (err->data, err->dsize, _("Invalid month: %s"), p);
@@ -357,7 +357,7 @@ static const char *getDate (const char *
return p;
}
p++;
- t->tm_year = strtol (p, &p, 0);
+ t->tm_year = strtol (p, &p, 10);
if (t->tm_year < 70) /* year 2000+ */
t->tm_year += 100;
else if (t->tm_year > 1900)
@@ -372,7 +372,7 @@ static const char *getDate (const char *
static const char *get_offset (struct tm *tm, const char *s)
{
char *ps;
- int offset = strtol (s, &ps, 0);
+ int offset = strtol (s, &ps, 10);
switch (*ps)
{