|
|
@ -8,12 +8,14 @@ size_t fmt_fill(char* dest,size_t srclen,size_t padlen,size_t maxlen) {
|
|
|
|
long todo;
|
|
|
|
long todo;
|
|
|
|
char* olddest=dest;
|
|
|
|
char* olddest=dest;
|
|
|
|
char* max=dest+maxlen;
|
|
|
|
char* max=dest+maxlen;
|
|
|
|
|
|
|
|
if ((long)padlen<0 || (long)maxlen<0) return 0;
|
|
|
|
|
|
|
|
if (srclen>maxlen) return maxlen;
|
|
|
|
if (dest==0) {
|
|
|
|
if (dest==0) {
|
|
|
|
unsigned long sum=srclen>padlen?srclen:padlen;
|
|
|
|
unsigned long sum=srclen>padlen?srclen:padlen;
|
|
|
|
return sum>maxlen?maxlen:sum;
|
|
|
|
return sum>maxlen?maxlen:sum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dest+=srclen;
|
|
|
|
dest+=srclen;
|
|
|
|
for (todo=padlen-srclen; todo>0; --todo) {
|
|
|
|
for (todo=(long)(padlen-srclen); todo>0; --todo) {
|
|
|
|
if (dest>max) break;
|
|
|
|
if (dest>max) break;
|
|
|
|
*dest=' '; ++dest;
|
|
|
|
*dest=' '; ++dest;
|
|
|
|
}
|
|
|
|
}
|
|
|
|