43
46
// Convert an integer to a string.
44
47
static GString *fromInt(int x);
49
// Create a formatted string. Similar to printf, but without the
50
// string overflow issues. Formatting elements consist of:
51
// {<arg>:[<width>][.<precision>]<type>}
53
// - <arg> is the argument number (arg 0 is the first argument
54
// following the format string) -- NB: args must be first used in
55
// order; they can be reused in any order
56
// - <width> is the field width -- negative to reverse the alignment;
57
// starting with a leading zero to zero-fill (for integers)
58
// - <precision> is the number of digits to the right of the decimal
59
// point (for floating point numbers)
60
// - <type> is one of:
61
// d, x, o, b -- int in decimal, hex, octal, binary
62
// ud, ux, uo, ub -- unsigned int
63
// ld, lx, lo, lb, uld, ulx, ulo, ulb -- long, unsigned long
66
// s -- string (char *)
68
// w -- blank space; arg determines width
69
// To get literal curly braces, use {{ or }}.
70
static GString *format(char *fmt, ...);
71
static GString *formatv(char *fmt, va_list argList);
67
94
GString *append(const char *str);
68
95
GString *append(const char *str, int lengthA);
97
// Append a formatted string.
98
GString *appendf(char *fmt, ...);
99
GString *appendfv(char *fmt, va_list argList);
70
101
// Insert a character or string.
71
102
GString *insert(int i, char c);
72
103
GString *insert(int i, GString *str);
94
125
void resize(int length1);
126
static void formatInt(long x, char *buf, int bufSize,
127
GBool zeroFill, int width, int base,
129
static void formatUInt(Gulong x, char *buf, int bufSize,
130
GBool zeroFill, int width, int base,
132
static void formatDouble(double x, char *buf, int bufSize, int prec,
133
GBool trim, char **p, int *len);