source: freewrt/package/rrdcollect/patches/rrdcollect-scan.patch@ 428f140

freewrt_1_0 freewrt_2_0
Last change on this file since 428f140 was 475ad56, checked in by Waldemar Brodkorb <wbx@…>, 20 years ago

add OpenWrt trunk revision 3830.

git-svn-id: svn://www.freewrt.org/trunk/freewrt@1 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 1.6 KB
  • rrdcollect-0.2.3

    diff -ruN rrdcollect-0.2.3.orig/src/scan.c rrdcollect-0.2.3/src/scan.c
    old new  
    7474                                                } while (isdigit(*fmt));
    7575                                        }
    7676
     77                                        /* skip white spaces like scanf does */
     78                                        if (strchr("difuoxX", *fmt))
     79                                                while (isspace(*buf))
     80                                                        buf++;
     81                                       
    7782                                        /* FIXME: we should check afterward:
    7883                                         * if (start == buf || start == '-' && buf-start == 1)
    7984                                         *      die("WTF???  zero-length number???");
     
    150155                                                                buf++, length--;
    151156                                                        }
    152157
    153                                                         /* ignore if value not found */
    154                                                         if(value == 0)
    155                                                                 return 0;
    156 
    157158                                                        if (!ignore)
    158                                                                 counter[i++]->value = valuedup(value);
     159                                                                counter[i++]->value = strndup(start, buf - start);
    159160                                                        break;
    160161                                                       
    161162                                                case 'c':
     163                                                        if (length < 0)
     164                                                             length = 1;        // default length is 1
     165                                                       
    162166                                                        while (*buf && length > 0) {
    163167                                                                buf++, length--;
    164168                                                        }
    165169                                                        if (length > 0)
    166170                                                                return 2;
    167171
    168                                                         /* ignore if value not found */
    169                                                         if(value == 0)
    170                                                                 return 0;
    171                                                        
    172172                                                        if (!ignore)
    173                                                                 counter[i++]->value = valuedup(value);
     173                                                                counter[i++]->value = strndup(start, buf - start);
    174174                                                        break;
    175175                                                       
    176176                                                       
     
    192192                        case '\f':
    193193                        case '\v':
    194194                                /* don't match if not at least one space */
    195                                 if(!isspace(*(buf)))
     195                                if(!isspace(*buf))
    196196                                        return 0;
    197197                                else
    198198                                        buf++;
     
    208208                                        case '\v':
    209209                                                break;
    210210                                        default:
    211                                                 while (isspace(*(buf)))
     211                                                while (isspace(*buf))
    212212                                                        buf++;
    213213                                }
    214214                                fmt++;
Note: See TracBrowser for help on using the repository browser.