strcmp.c 847 B

12345678910111213141516171819202122
  1. #include "api.h"
  2. /* Copyright © 2005-2014 Rich Felker, et al. */
  3. /* Permission is hereby granted, free of charge, to any person obtaining */
  4. /* a copy of this software and associated documentation files (the */
  5. /* "Software"), to deal in the Software without restriction, including */
  6. /* without limitation the rights to use, copy, modify, merge, publish, */
  7. /* distribute, sublicense, and/or sell copies of the Software, and to */
  8. /* permit persons to whom the Software is furnished to do so, subject to */
  9. /* the following conditions: */
  10. /* The above copyright notice and this permission notice shall be */
  11. /* included in all copies or substantial portions of the Software. */
  12. /* musl 1.1.24 */
  13. int strcmp(const char* l, const char* r) {
  14. for (; *l == *r && *l; l++, r++)
  15. ;
  16. return *(unsigned char*)l - *(unsigned char*)r;
  17. }