m4-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] src/freeze.c (GET_NUMBER): Fix a typo.


From: Jim Meyering
Subject: [PATCH] src/freeze.c (GET_NUMBER): Fix a typo.
Date: Sun, 11 May 2008 15:00:23 +0200

"Eric Blake" <address@hidden> wrote:
...
> +      unsigned int n = 0;                                    \
> +      while (isdigit (character) && n <= INT_MAX / 10)               \
>       {                                                       \
> -       (Number) = 10 * (Number) + character - '0';           \
> +       n = 10 * n + character - '0';                         \
>         GET_CHARACTER;                                        \
>       }                                                       \
> +      if (((AllowNeg) ? INT_MIN: INT_MAX) < n                        \
> +       || isdigit (character))                               \
> +     m4_error (context, EXIT_FAILURE, 0, NULL,               \
> +               _("integer overflow in frozen file"));        \
> +      (Number) = n;                                          \

Hi Eric,

Thanks for humoring me ;-)
Maybe the test suite never exercises this case?
If it does, I'd expect a bogus "integer overflow in frozen file"
diagnostic.  Here's a patch:

>From 3119ecc64bfb086ccddf68acb8ef421413cd181d Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 11 May 2008 14:56:30 +0200
Subject: [PATCH] * src/freeze.c (GET_NUMBER): Fix a typo.

---
 src/freeze.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/freeze.c b/src/freeze.c
index 186b69b..af40544 100644
--- a/src/freeze.c
+++ b/src/freeze.c
@@ -391,7 +391,7 @@ reload_frozen_state (m4 *context, const char *name)
          n = 10 * n + character - '0';                         \
          GET_CHARACTER;                                        \
        }                                                       \
-      if (((AllowNeg) ? INT_MIN: INT_MAX) < n                  \
+      if (((AllowNeg) ? -INT_MIN : INT_MAX) < n                        \
          || isdigit (character))                               \
        m4_error (context, EXIT_FAILURE, 0, NULL,               \
                  _("integer overflow in frozen file"));        \
--
1.5.5.1.179.gdc42




reply via email to

[Prev in Thread] Current Thread [Next in Thread]