- if (val == 0 && strlen(buf) == 0) {
- strcat(buf, "0 secs");
- } else if (val != 0) {
- sprintf(mybuf, "%d sec%s", (uint32_t)val, val>1?"s":"");
- strcat(buf, mybuf);
- }
- return buf;
-}
-
-/*
- * Check if specified string is a number or not.
- * Taken from SQLite, cool, thanks.
- */
-int is_a_number(const char *n)
-{
- int digit_seen = 0;
-
- if( *n == '-' || *n == '+' ) {
- n++;
- }
- while (ISDIGIT(*n)) {
- digit_seen = 1;
- n++;
- }
- if (digit_seen && *n == '.') {
- n++;
- while (ISDIGIT(*n)) { n++; }
- }
- if (digit_seen && (*n == 'e' || *n == 'E')
- && (ISDIGIT(n[1]) || ((n[1]=='-' || n[1] == '+') && ISDIGIT(n[2])))) {
- n += 2; /* skip e- or e+ or e digit */
- while (ISDIGIT(*n)) { n++; }
- }
- return digit_seen && *n==0;
-}
-
-
-/*
- * Edit an integer number with commas, the supplied buffer
- * must be at least 27 bytes long. The incoming number
- * is always widened to 64 bits.
- */
-char *edit_uint64_with_commas(uint64_t val, char *buf)
-{
- sprintf(buf, "%" lld, val);
- return add_commas(buf, buf);
-}
-
-/*
- * Edit an integer number, the supplied buffer
- * must be at least 27 bytes long. The incoming number
- * is always widened to 64 bits.
- */
-char *edit_uint64(uint64_t val, char *buf)
-{
- sprintf(buf, "%" lld, val);
- return buf;
-}
-
-
-/*
- * Add commas to a string, which is presumably
- * a number.
- */
-char *add_commas(char *val, char *buf)
-{
- int len, nc;
- char *p, *q;
- int i;
-
- if (val != buf) {
- strcpy(buf, val);
- }
- len = strlen(buf);
- if (len < 1) {
- len = 1;
- }
- nc = (len - 1) / 3;
- p = buf+len;
- q = p + nc;
- *q-- = *p--;
- for ( ; nc; nc--) {
- for (i=0; i < 3; i++) {
- *q-- = *p--;