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
446 B

  1. #include "scan.h"
  2. #include <ctype.h>
  3. size_t scan_whitenskip(const char *s,size_t limit) {
  4. register const char *t=s;
  5. register const char *u=t+limit;
  6. while (t<u && isspace(*t)) ++t;
  7. return (size_t)(t-s);
  8. }
  9. #ifdef UNITTEST
  10. #include <assert.h>
  11. int main() {
  12. assert(scan_whitenskip("foo",3)==0);
  13. assert(scan_whitenskip(" foo",4)==1);
  14. assert(scan_whitenskip(" foo",1)==1);
  15. assert(scan_whitenskip(" foo",2)==2);
  16. return 0;
  17. }
  18. #endif