/nsprpub/lib/libc/src/strcmp.c

https://github.com/MoonchildProductions/UXP · C · 33 lines · 24 code · 5 blank · 4 comment · 10 complexity · d42a89951bd37fa64946992a6a497ed5 MD5 · raw file

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "plstr.h"
  6. #include <string.h>
  7. PR_IMPLEMENT(PRIntn)
  8. PL_strcmp(const char *a, const char *b)
  9. {
  10. if( (const char *)0 == a ) {
  11. return ((const char *)0 == b) ? 0 : -1;
  12. }
  13. if( (const char *)0 == b ) {
  14. return 1;
  15. }
  16. return (PRIntn)strcmp(a, b);
  17. }
  18. PR_IMPLEMENT(PRIntn)
  19. PL_strncmp(const char *a, const char *b, PRUint32 max)
  20. {
  21. if( (const char *)0 == a ) {
  22. return ((const char *)0 == b) ? 0 : -1;
  23. }
  24. if( (const char *)0 == b ) {
  25. return 1;
  26. }
  27. return (PRIntn)strncmp(a, b, (size_t)max);
  28. }