static void
fmtfp(char **sbuffer,
      char **buffer,
      size_t *currlen,
      size_t *maxlen, LDOUBLE fvalue, int min, int max, int flags)
{
    int signvalue = 0;
    LDOUBLE ufvalue;
    char iconvert[20];
    char fconvert[20];
    int iplace = 0;
    int fplace = 0;
    int padlen = 0;
    int zpadlen = 0;
    int caps = 0;
    long intpart;
    long fracpart;
    long max10;
    if (max < 0)
        max = 6;
    ufvalue = abs_val(fvalue);
    if (fvalue < 0)
        signvalue = '-';
    else if (flags & DP_F_PLUS)
        signvalue = '+';
    else if (flags & DP_F_SPACE)
        signvalue = ' ';
    intpart = (long)ufvalue;
    if (max > 9)
        max = 9;
    max10 = roundv(pow_10(max));
    fracpart = roundv(pow_10(max) * (ufvalue - intpart));
    if (fracpart >= max10) {
        intpart++;
        fracpart -= max10;
    }
    do {
        iconvert[iplace++] =
            (caps ? "0123456789ABCDEF" : "0123456789abcdef")[intpart % 10];
        intpart = (intpart / 10);
    } while (intpart && (iplace < (int)sizeof(iconvert)));
    if (iplace == sizeof iconvert)
        iplace--;
    iconvert[iplace] = 0;
    do {
        fconvert[fplace++] =
            (caps ? "0123456789ABCDEF" : "0123456789abcdef")[fracpart % 10];
        fracpart = (fracpart / 10);
    } while (fplace < max);
    if (fplace == sizeof fconvert)
        fplace--;
    fconvert[fplace] = 0;
    padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
    zpadlen = max - fplace;
    if (zpadlen < 0)
        zpadlen = 0;
    if (padlen < 0)
        padlen = 0;
    if (flags & DP_F_MINUS)
        padlen = -padlen;
    if ((flags & DP_F_ZERO) && (padlen > 0)) {
        if (signvalue) {
            doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue);
            --padlen;
            signvalue = 0;
        }
        while (padlen > 0) {
            doapr_outch(sbuffer, buffer, currlen, maxlen, '0');
            --padlen;
        }
    }
    while (padlen > 0) {
        doapr_outch(sbuffer, buffer, currlen, maxlen, ' ');
        --padlen;
    }
    if (signvalue)
        doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue);
    while (iplace > 0)
        doapr_outch(sbuffer, buffer, currlen, maxlen, iconvert[--iplace]);
    if (max > 0 || (flags & DP_F_NUM)) {
        doapr_outch(sbuffer, buffer, currlen, maxlen, '.');
        while (fplace > 0)
            doapr_outch(sbuffer, buffer, currlen, maxlen, fconvert[--fplace]);
    }
    while (zpadlen > 0) {
        doapr_outch(sbuffer, buffer, currlen, maxlen, '0');
        --zpadlen;
    }
    while (padlen < 0) {
        doapr_outch(sbuffer, buffer, currlen, maxlen, ' ');
        ++padlen;
    }
}
['static void\nfmtfp(char **sbuffer,\n      char **buffer,\n      size_t *currlen,\n      size_t *maxlen, LDOUBLE fvalue, int min, int max, int flags)\n{\n    int signvalue = 0;\n    LDOUBLE ufvalue;\n    char iconvert[20];\n    char fconvert[20];\n    int iplace = 0;\n    int fplace = 0;\n    int padlen = 0;\n    int zpadlen = 0;\n    int caps = 0;\n    long intpart;\n    long fracpart;\n    long max10;\n    if (max < 0)\n        max = 6;\n    ufvalue = abs_val(fvalue);\n    if (fvalue < 0)\n        signvalue = \'-\';\n    else if (flags & DP_F_PLUS)\n        signvalue = \'+\';\n    else if (flags & DP_F_SPACE)\n        signvalue = \' \';\n    intpart = (long)ufvalue;\n    if (max > 9)\n        max = 9;\n    max10 = roundv(pow_10(max));\n    fracpart = roundv(pow_10(max) * (ufvalue - intpart));\n    if (fracpart >= max10) {\n        intpart++;\n        fracpart -= max10;\n    }\n    do {\n        iconvert[iplace++] =\n            (caps ? "0123456789ABCDEF" : "0123456789abcdef")[intpart % 10];\n        intpart = (intpart / 10);\n    } while (intpart && (iplace < (int)sizeof(iconvert)));\n    if (iplace == sizeof iconvert)\n        iplace--;\n    iconvert[iplace] = 0;\n    do {\n        fconvert[fplace++] =\n            (caps ? "0123456789ABCDEF" : "0123456789abcdef")[fracpart % 10];\n        fracpart = (fracpart / 10);\n    } while (fplace < max);\n    if (fplace == sizeof fconvert)\n        fplace--;\n    fconvert[fplace] = 0;\n    padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);\n    zpadlen = max - fplace;\n    if (zpadlen < 0)\n        zpadlen = 0;\n    if (padlen < 0)\n        padlen = 0;\n    if (flags & DP_F_MINUS)\n        padlen = -padlen;\n    if ((flags & DP_F_ZERO) && (padlen > 0)) {\n        if (signvalue) {\n            doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue);\n            --padlen;\n            signvalue = 0;\n        }\n        while (padlen > 0) {\n            doapr_outch(sbuffer, buffer, currlen, maxlen, \'0\');\n            --padlen;\n        }\n    }\n    while (padlen > 0) {\n        doapr_outch(sbuffer, buffer, currlen, maxlen, \' \');\n        --padlen;\n    }\n    if (signvalue)\n        doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue);\n    while (iplace > 0)\n        doapr_outch(sbuffer, buffer, currlen, maxlen, iconvert[--iplace]);\n    if (max > 0 || (flags & DP_F_NUM)) {\n        doapr_outch(sbuffer, buffer, currlen, maxlen, \'.\');\n        while (fplace > 0)\n            doapr_outch(sbuffer, buffer, currlen, maxlen, fconvert[--fplace]);\n    }\n    while (zpadlen > 0) {\n        doapr_outch(sbuffer, buffer, currlen, maxlen, \'0\');\n        --zpadlen;\n    }\n    while (padlen < 0) {\n        doapr_outch(sbuffer, buffer, currlen, maxlen, \' \');\n        ++padlen;\n    }\n}', 'static LDOUBLE abs_val(LDOUBLE value)\n{\n    LDOUBLE result = value;\n    if (value < 0)\n        result = -value;\n    return result;\n}']