string_nocasecmp.c 832 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * string_nocasecmp.c
  3. */
  4. #include "private.h"
  5. #include "lub/ctype.h"
  6. /*--------------------------------------------------------- */
  7. int lub_string_nocasecmp(const char *cs, const char *ct)
  8. {
  9. int result = 0;
  10. while ((0 == result) && *cs && *ct) {
  11. /*lint -e155 Ignoring { }'ed sequence within an expression, 0 assumed
  12. * MACRO implementation uses braces to prevent multiple increments
  13. * when called.
  14. */
  15. int s = lub_ctype_tolower(*cs++);
  16. int t = lub_ctype_tolower(*ct++);
  17. result = s - t;
  18. }
  19. /*lint -e774 Boolean within 'if' always evealuates to True
  20. * not the case because of tolower() evaluating to 0 under lint
  21. * (see above)
  22. */
  23. if (0 == result) {
  24. /* account for different string lengths */
  25. result = *cs - *ct;
  26. }
  27. return result;
  28. }
  29. /*--------------------------------------------------------- */