mirror of /home/gitosis/repositories/libowfat.git
Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat
https://www.fefe.de/libowfat/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
588 B
21 lines
588 B
#include "fmt.h" |
|
|
|
/* "foo" -> "foo " |
|
* append padlen-srclen spaces after dest, if that is >= 0. Truncate |
|
* only if total length is larger than maxlen. Return number of |
|
* characters written. */ |
|
unsigned int fmt_fill(char* dest,unsigned int srclen,unsigned int padlen,unsigned int maxlen) { |
|
int todo; |
|
char* olddest=dest; |
|
char* max=dest+maxlen; |
|
if (dest==0) { |
|
int sum=srclen>padlen?srclen:padlen; |
|
return sum>maxlen?maxlen:sum; |
|
} |
|
dest+=srclen; |
|
for (todo=padlen-srclen; todo>0; --todo) { |
|
if (dest>max) break; |
|
*dest=' '; ++dest; |
|
} |
|
return dest-olddest; |
|
}
|
|
|