I realize I'm being annoying and pedantic, but I just wanted to clarify
the issue.  The problem is a difference in standard libraries:
    * baselibc: isdigit() is a function.
    * newlib: isdigit() is a macro.

There is no problem when baselibc is used, because the argument gets
promoted to an integer as required by the C standard.  With newlibc, no 
promotion occurs because macro invocations just translate to token substitution.

Normally this wouldn't be a problem either, but gcc can be configured to
raise an odd warning when a char is used to index an array
(-Wchar-subscripts).  I am really not sure of the rationale for this
warning...

Chris


On Mon, Mar 07, 2016 at 08:12:44PM +0000, [email protected] wrote:
> Repository: incubator-mynewt-larva
> Updated Branches:
>   refs/heads/master db0e97b1e -> faa7814db
> 
> 
> MYNEWT-230
> 
> explictely cast to an integer since some compilers don't like to implicitelty
> cast a char to an int
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
> Commit: 
> http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/faa7814d
> Tree: 
> http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/faa7814d
> Diff: 
> http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/faa7814d
> 
> Branch: refs/heads/master
> Commit: faa7814db73f712ffa46cf4522c22b821e32cce7
> Parents: db0e97b
> Author: Paul Dietrich <[email protected]>
> Authored: Thu Mar 3 17:11:13 2016 -0800
> Committer: wes3 <[email protected]>
> Committed: Mon Mar 7 11:53:13 2016 -0800
> 
> ----------------------------------------------------------------------
>  libs/util/src/datetime.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/faa7814d/libs/util/src/datetime.c
> ----------------------------------------------------------------------
> diff --git a/libs/util/src/datetime.c b/libs/util/src/datetime.c
> index 902eb55..fe4fb38 100644
> --- a/libs/util/src/datetime.c
> +++ b/libs/util/src/datetime.c
> @@ -211,7 +211,7 @@ parse_number(const char *str, int digits, int *val)
>      cp = str;
>      end = str + digits;
>      while (cp < end) {
> -        if (!isdigit(*cp)) {
> +        if (!isdigit((int) *cp)) {
>              return (NULL);
>          }
>          *val *= 10;
> @@ -277,7 +277,7 @@ parse_datetime(const char *input, struct os_timeval *tv, 
> struct os_timezone *tz)
>      /* parse fractional seconds if specified */
>      if (*cp == '.') {
>          ep = ++cp;
> -        while (isdigit(*ep)) {
> +        while (isdigit((int) *ep)) {
>              ep++;
>          }
>          digits = ep - cp;
> 

Reply via email to