rune.c 857 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <u.h>
  10. #include <libc.h>
  11. #include <bio.h>
  12. #include <mp.h>
  13. #include <libsec.h>
  14. #include "iso9660.h"
  15. Rune*
  16. strtorune(Rune *r, char *s)
  17. {
  18. Rune *or;
  19. if(s == nil)
  20. return nil;
  21. or = r;
  22. while(*s)
  23. s += chartorune(r++, s);
  24. *r = L'\0';
  25. return or;
  26. }
  27. Rune*
  28. runechr(Rune *s, Rune c)
  29. {
  30. for(; *s; s++)
  31. if(*s == c)
  32. return s;
  33. return nil;
  34. }
  35. int
  36. runecmp(Rune *s, Rune *t)
  37. {
  38. while(*s && *t && *s == *t)
  39. s++, t++;
  40. return *s - *t;
  41. }