StrPad
Description
Pad o with ASCII spaces so its total length reaches width. content_len is the length already considered “content” (typically StrLen(o) at call time, or the length the caller plans to fill in afterwards). Padding lands on the left, right, or both sides depending on align. If content_len >= width the call is a no-op.
Parameters
| Name | Direction | Description |
|---|---|---|
o |
in,out | Str to pad. Grows through its inline allocator. |
width |
in | Target minimum width. |
align |
in | ALIGN_LEFT / ALIGN_RIGHT / ALIGN_CENTER. |
content_len |
in | Current content length to anchor padding against. |
Success
Returns true. o carries the requested padding.
Failure
Returns false on allocator OOM mid-pad. o may be left partially padded.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Io.c:289:
}
bool StrPad(Str *o, size width, Alignment align, size content_len) {
if (content_len >= width)
return true;- In
Io.c:1721:
if (fmt_info->width > 0) {
size content_len = o->length - start_len;
if (!StrPad(o, fmt_info->width, fmt_info->align, content_len)) {
return false;
}- In
Io.c:1813:
if (fmt_info->width > 0) {
size content_len = o->length - start_len;
if (!StrPad(o, fmt_info->width, fmt_info->align, content_len)) {
return false;
}- In
Io.c:1885:
return false;
}
} else if (!StrPad(o, fmt_info->width, fmt_info->align, content_len)) {
return false;
}- In
Io.c:1990:
return false;
}
} else if (!StrPad(o, fmt_info->width, fmt_info->align, content_len)) {
return false;
}- In
Io.c:2117:
if (fmt_info->width > 0) {
size content_len = o->length - start_len;
if (!StrPad(o, fmt_info->width, fmt_info->align, content_len)) {
return false;
}- In
Io.c:2192:
if (fmt_info->width > 0) {
size content_len = o->length - start_len;
if (!StrPad(o, fmt_info->width, fmt_info->align, content_len)) {
return false;
}- In
Io.c:3466:
if (fmt_info->width > 0) {
size content_len = o->length - start_len;
if (!StrPad(o, fmt_info->width, fmt_info->align, content_len)) {
return false;
}- In
Io.c:3530:
if (fmt_info->width > 0) {
size content_len = o->length - start_len;
if (!StrPad(o, fmt_info->width, fmt_info->align, content_len)) {
return false;
}
Last updated on