summaryrefslogtreecommitdiff
path: root/lib/padstr.c
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-03-27 11:39:12 -0400
committerFreya Murphy <freya@freyacat.org>2025-03-27 11:39:12 -0400
commit0ff301cda68669c59351e5854ce98f2cf460543f (patch)
treecfe8f976261962420ada64b821559b9da0a56841 /lib/padstr.c
parentadd compile_flags.txt for clangd lsp (diff)
downloadcomus-0ff301cda68669c59351e5854ce98f2cf460543f.tar.gz
comus-0ff301cda68669c59351e5854ce98f2cf460543f.tar.bz2
comus-0ff301cda68669c59351e5854ce98f2cf460543f.zip
pull upstream changes, add auto formatting
Diffstat (limited to 'lib/padstr.c')
-rw-r--r--lib/padstr.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/padstr.c b/lib/padstr.c
index b83229f..5806704 100644
--- a/lib/padstr.c
+++ b/lib/padstr.c
@@ -28,31 +28,32 @@
**
** NOTE: does NOT NUL-terminate the buffer
*/
-char *padstr( char *dst, char *str, int len, int width,
- int leftadjust, int padchar ) {
+char *padstr(char *dst, char *str, int len, int width, int leftadjust,
+ int padchar)
+{
int extra;
// determine the length of the string if we need to
- if( len < 0 ){
- len = strlen( str );
+ if (len < 0) {
+ len = strlen(str);
}
// how much filler must we add?
extra = width - len;
// add filler on the left if we're not left-justifying
- if( extra > 0 && !leftadjust ){
- dst = pad( dst, extra, padchar );
+ if (extra > 0 && !leftadjust) {
+ dst = pad(dst, extra, padchar);
}
// copy the string itself
- for( int i = 0; i < len; ++i ) {
+ for (int i = 0; i < len; ++i) {
*dst++ = str[i];
}
// add filler on the right if we are left-justifying
- if( extra > 0 && leftadjust ){
- dst = pad( dst, extra, padchar );
+ if (extra > 0 && leftadjust) {
+ dst = pad(dst, extra, padchar);
}
return dst;