PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/sdcc-221-pre1/sdcc/device/lib/z80/string.c

#
C | 34 lines | 26 code | 5 blank | 3 comment | 7 complexity | 349e55b3cfc0e9b6838871d71b8664ea MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, LGPL-2.1, GPL-3.0
  1. /* Dumb strings stub.
  2. Wanted a quick hack for now - will use the libc version later.
  3. */
  4. char *strcpy(char *dest, const char *source)
  5. {
  6. char *d = dest;
  7. const char *s = source;
  8. while (*d++ = *s++);
  9. return dest;
  10. }
  11. void *memcpy(void *dest, const void *source, int count)
  12. {
  13. char *d = dest;
  14. const char *s = source;
  15. while (count--)
  16. *d++ = *s++;
  17. return dest;
  18. }
  19. int strcmp(const char *s1, const char *s2)
  20. {
  21. char ret = 0;
  22. while (!(ret = *s1 - *s2) && *s2)
  23. ++s1, ++s2;
  24. if (ret < 0)
  25. return -1;
  26. else if (ret > 0)
  27. return 1;
  28. return 0;
  29. }