Advertisement
Guest User

Untitled

a guest
Mar 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #define CC_CHAR_IS_DELIMITER(c) ((c)<=' ')
  2.  
  3. int ccStrParseInt64( char *str, int64_t *retint )
  4. {
  5. int negflag;
  6. char c;
  7. int64_t workint;
  8. *retint = 0;
  9. if( !str )
  10. return 0;
  11. negflag = 0;
  12. if( *str == '-' )
  13. negflag = 1;
  14. str += negflag;
  15. workint = 0;
  16. for( ; ; str++ )
  17. {
  18. c = *str;
  19. if( ( c >= '0' ) && ( c <= '9' ) )
  20. {
  21. if( workint >= (int64_t)0xcccccccccccccccLL )
  22. return 0;
  23. workint = ( workint * 10 ) + ( c - '0' );
  24. }
  25. else if( CC_CHAR_IS_DELIMITER( c ) )
  26. break;
  27. else
  28. return 0;
  29. }
  30. if( negflag )
  31. workint = -workint;
  32. *retint = workint;
  33. return 1;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement