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.
 
 
 
 

16 lines
405 B

  1. #include "fmt.h"
  2. size_t fmt_ulong0(char *dest,unsigned long i,size_t pad) {
  3. register unsigned int len;
  4. register unsigned long tmp;
  5. /* first count the number of bytes needed */
  6. for (len=1, tmp=i; tmp>9; ++len) tmp/=10;
  7. /* now see if we need to pad */
  8. if (dest) {
  9. while (len<pad) { *dest='0'; ++dest; ++len; }
  10. fmt_ulong(dest,i);
  11. return len;
  12. } else
  13. return (len<pad?pad:len);
  14. }