Exemple #1
0
*/	REBYTE *Form_Int_Pad(REBYTE *buf, REBI64 val, REBINT max, REBINT len, REBYTE pad)
/*
**		Form an integer string in the given buffer with a min
**		width padded out with the given character. Len > 0 left
**		aligned. Len < 0 is right aligned.
**
**		If len = 0 and val = 0, a null string is formed.
**		Make sure you have room in your buffer before calling this!
**
***********************************************************************/
{
	REBYTE tmp[MAX_NUM_LEN];
	REBINT n;

	n = Form_Int_Len(tmp, val, max);
	if (n == 0) {
		strcpy(buf, "??");
		return buf;  // too long
	}

	if (len >= 0) {
		strcpy(buf, tmp);
		buf += n;
		for (; n < len; n++) *buf++ = pad;
	}
	else { // len < 0
		for (; n < -len; len++) *buf++ = pad;
		strcpy(buf, tmp);
		buf += n;
	}

	*buf = 0;
	return buf;
}
Exemple #2
0
//
//  Form_Int_Pad: C
//
// Form an integer string in the given buffer with a min
// width padded out with the given character. Len > 0 left
// aligned. Len < 0 is right aligned.
//
// If len = 0 and val = 0, a null string is formed.
// Make sure you have room in your buffer before calling this!
//
REBYTE *Form_Int_Pad(REBYTE *buf, REBI64 val, REBINT max, REBINT len, REBYTE pad)
{
    REBYTE tmp[MAX_NUM_LEN];
    REBINT n;

    n = Form_Int_Len(tmp, val, max + 1);
    if (n == 0) {
        strcpy(s_cast(buf), "??");
        return buf;  // too long
    }

    if (len >= 0) {
        strcpy(s_cast(buf), s_cast(tmp));
        buf += n;
        for (; n < len; n++) *buf++ = pad;
    }
    else { // len < 0
        for (; n < -len; len++) *buf++ = pad;
        strcpy(s_cast(buf), s_cast(tmp));
        buf += n;
    }

    *buf = 0;
    return buf;
}
Exemple #3
0
*/	REBYTE *Form_Int(REBYTE *buf, REBINT val)
/*
**		Form 32 bit integer string in the given buffer.
**		Make sure you have room in your buffer before calling this!
**
***********************************************************************/
{
	REBINT len = Form_Int_Len(buf, val, MAX_NUM_LEN);
	return buf + len;
}
Exemple #4
0
//
//  Form_Int: C
//
// Form 32 bit integer string in the given buffer.
// Make sure you have room in your buffer before calling this!
//
REBYTE *Form_Int(REBYTE *buf, REBINT val)
{
    REBINT len = Form_Int_Len(buf, val, MAX_NUM_LEN);
    return buf + len;
}