Posted By

Zufolek on 05/20/09


Tagged

isalpha


Versions (?)

isalpha


 / Published in: C
 

several versions of isalpha

  1. inline const int isalpha2(char c){
  2. return c>='a' && c<='z' || c>='A' && c<='Z';
  3. }
  4.  
  5.  
  6. inline const int isalpha3(unsigned char c){
  7. return --c>>6==1 & (c&31)<26;
  8. }
  9.  
  10.  
  11. inline const int isalpha4(unsigned char c){
  12. unsigned char out;
  13. asm(
  14. "\n"
  15. "decb %1\n"
  16. "movb %1,%0\n"
  17. "shrb $6,%0\n"
  18. "cmpb $1,%0\n"
  19. "seteb %%al\n"
  20. "andb $31,%1\n"
  21. "cmpb $26,%1\n"
  22. "setlb %%ah\n"
  23. "cmpw $257,%%ax\n"
  24. "seteb %0\n"
  25. :"=q"(out)
  26. :"q"(c)
  27. :"ax"
  28. );
  29. return out;
  30. }

Report this snippet  

You need to login to post a comment.