- if (p == last)
- {
- yield = FALSE;
- goto END_FORMAT;
- }
- if (p >= last - width)
- {
- yield = FALSE;
- width = precision = last - p - 1;
- if (width < 0) width = 0;
- if (precision < 0) precision = 0;
+ else
+ width = precision = slen;
+
+ if (!extend)
+ {
+ if (g->ptr == lim) return NULL;
+ if (g->ptr >= lim - width)
+ {
+ truncated = TRUE;
+ width = precision = lim - g->ptr - 1;
+ if (width < 0) width = 0;
+ if (precision < 0) precision = 0;
+ }
+ }
+ else if (g->ptr >= lim - width)
+ {
+ gstring_grow(g, g->ptr, width - (lim - g->ptr));
+ lim = g->size - 1;
+ gp = CS g->s + g->ptr;
+ }
+
+ g->ptr += sprintf(gp, "%*.*s", width, precision, s);
+ if (fp[-1] == 'S')
+ while (*gp) { *gp = tolower(*gp); gp++; }
+ else if (fp[-1] == 'T')
+ while (*gp) { *gp = toupper(*gp); gp++; }
+
+ if (truncated) return NULL;
+ break;