pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:2668:    val = -val;    } else if (flags & APPEND_POSITIVE) {    string_builder_putchar(s, '+');    }    if ((flags & APPEND_ZERO_PAD) && (precision < min_width)) {    precision = min_width;    }       tmp = val;    if (base & (base - 1)) { +  size_t cnt;    /* Calculate the output length.    * Use do-while to ensure that zero isn't output as an empty string.    */    len = 0;    do {    len++;    tmp /= base;    } while (tmp);       /* Precision is minimum number of digits. */
pike.git/src/stralloc.c:2689:       /* Perform padding. */    if (!(flags & APPEND_LEFT)) {    if (len < min_width) {    string_builder_fill(s, min_width - len, MKPCHARP(" ", 0),    4, 0);    }    min_width = 0;    }    +  cnt = len; +     tmp = val;    switch(s->s->size_shift) {    case 0:    {    p_wchar0 *p = string_builder_allocate(s, len, 0);    do { -  p[--len] = numbers[tmp%base]; +  p[--cnt] = numbers[tmp%base];    tmp /= base; -  } while (len); +  } while (cnt);    }    break;    case 1:    {    p_wchar1 *p = string_builder_allocate(s, len, 0);    do { -  p[--len] = numbers[tmp%base]; +  p[--cnt] = numbers[tmp%base];    tmp /= base; -  } while (len); +  } while (cnt);    }    break;    case 2:    {    p_wchar2 *p = string_builder_allocate(s, len, 0);    do { -  p[--len] = numbers[tmp%base]; +  p[--cnt] = numbers[tmp%base];    tmp /= base; -  } while (len); +  } while (cnt);    }    break;    }    } else {    /* base is a power of two, so we can do without    * the division and modulo operations.    */    int delta;    size_t shift;    unsigned int mask;