rrdcollect-scan.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. diff -ruN rrdcollect-0.2.3.orig/src/scan.c rrdcollect-0.2.3/src/scan.c
  2. --- rrdcollect-0.2.3.orig/src/scan.c 2005-01-20 18:42:17.000000000 +0100
  3. +++ rrdcollect-0.2.3/src/scan.c 2006-01-22 00:51:52.000000000 +0100
  4. @@ -74,6 +74,11 @@
  5. } while (isdigit(*fmt));
  6. }
  7. + /* skip white spaces like scanf does */
  8. + if (strchr("difuoxX", *fmt))
  9. + while (isspace(*buf))
  10. + buf++;
  11. +
  12. /* FIXME: we should check afterward:
  13. * if (start == buf || start == '-' && buf-start == 1)
  14. * die("WTF??? zero-length number???");
  15. @@ -150,27 +155,22 @@
  16. buf++, length--;
  17. }
  18. - /* ignore if value not found */
  19. - if(value == 0)
  20. - return 0;
  21. -
  22. if (!ignore)
  23. - counter[i++]->value = valuedup(value);
  24. + counter[i++]->value = strndup(start, buf - start);
  25. break;
  26. case 'c':
  27. + if (length < 0)
  28. + length = 1; // default length is 1
  29. +
  30. while (*buf && length > 0) {
  31. buf++, length--;
  32. }
  33. if (length > 0)
  34. return 2;
  35. - /* ignore if value not found */
  36. - if(value == 0)
  37. - return 0;
  38. -
  39. if (!ignore)
  40. - counter[i++]->value = valuedup(value);
  41. + counter[i++]->value = strndup(start, buf - start);
  42. break;
  43. @@ -192,7 +192,7 @@
  44. case '\f':
  45. case '\v':
  46. /* don't match if not at least one space */
  47. - if(!isspace(*(buf)))
  48. + if(!isspace(*buf))
  49. return 0;
  50. else
  51. buf++;
  52. @@ -208,7 +208,7 @@
  53. case '\v':
  54. break;
  55. default:
  56. - while (isspace(*(buf)))
  57. + while (isspace(*buf))
  58. buf++;
  59. }
  60. fmt++;