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.
 
 
 
 

22 lines
593 B

  1. #include "fmt.h"
  2. /* "foo" -> "foo "
  3. * append padlen-srclen spaces after dest, if that is >= 0. Truncate
  4. * only if total length is larger than maxlen. Return number of
  5. * characters written. */
  6. unsigned long fmt_fill(char* dest,unsigned long srclen,unsigned long padlen,unsigned long maxlen) {
  7. long todo;
  8. char* olddest=dest;
  9. char* max=dest+maxlen;
  10. if (dest==0) {
  11. int sum=srclen>padlen?srclen:padlen;
  12. return sum>maxlen?maxlen:sum;
  13. }
  14. dest+=srclen;
  15. for (todo=padlen-srclen; todo>0; --todo) {
  16. if (dest>max) break;
  17. *dest=' '; ++dest;
  18. }
  19. return dest-olddest;
  20. }