You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.4KB

  1. /* ---------------------------------------------------------------------------|
  2. *
  3. * Distributed under the CC0 public domain license.
  4. * By Alison G. Watson. Attribution is encouraged, though not required.
  5. * See licenses/cc0.txt for more information.
  6. *
  7. * ---------------------------------------------------------------------------|
  8. *
  9. * Various string functions.
  10. *
  11. * ---------------------------------------------------------------------------|
  12. */
  13. #include <GDCC.h>
  14. #include <stdio.h>
  15. #define Stringify(s) #s
  16. #define XStringify(s) Stringify(s)
  17. #define L(name) LanguageV(name)
  18. #define LC(name) LanguageVC(nil, name)
  19. #define StrParamBegin(...) (ACS_BeginPrint(), __nprintf(__VA_ARGS__))
  20. #define StrParam(...) (StrParamBegin(__VA_ARGS__), ACS_EndStrParam())
  21. #define Language(...) (StrParamBegin(__VA_ARGS__), LanguageV(ACS_EndStrParam()))
  22. #define LanguageC(...) LanguageCV(nil, __VA_ARGS__)
  23. #define PrintChars(s, n) ACS_PrintGlobalCharRange((i32)s, __GDCC__Sta, 0, n)
  24. #define PrintChrSt(s) ACS_PrintGlobalCharArray((i32)s, __GDCC__Sta)
  25. #define l_strndup(s, n) (ACS_BeginPrint(), PrintChars(s, n), ACS_EndStrParam())
  26. #define l_strdup(s) (ACS_BeginPrint(), PrintChrSt(s), ACS_EndStrParam())
  27. #define l_strcpy2(s1, s2) \
  28. (ACS_BeginPrint(), PrintChrSt(s1), PrintChrSt(s2), ACS_EndStrParam())
  29. #define fastmemset(p, s, c, ...) \
  30. for(register i32 _i = 0; _i < (c); _i++) ((byte __VA_ARGS__ *)(p))[_i] = s
  31. #define fastmemmove(lhs, rhs, s) \
  32. do { \
  33. register char *_lhs = (void *)(lhs); \
  34. register char const *_rhs = (void *)(rhs); \
  35. register size_t _s = (s); \
  36. if(_lhs < _rhs) { \
  37. while(_s--) \
  38. *_lhs++ = *_rhs++; \
  39. } else { \
  40. _lhs += _s; \
  41. _rhs += _s; \
  42. while(_s--) \
  43. *--_lhs = *--_rhs; \
  44. } \
  45. } while(0)
  46. str l_strupper(str in);
  47. u32 l_strhash(astr s);
  48. u32 lstrhash(cstr s);
  49. char *lstrcpy_str(char *dest, astr src);
  50. char *lstrcpy2(char *out, cstr s1, cstr s2);
  51. char *lstrcpy3(char *out, cstr s1, cstr s2, cstr s3);
  52. i32 lstrcmp_str(cstr s1, astr s2);
  53. i32 faststrcmp(cstr s1, cstr s2);
  54. i32 faststrcasecmp(cstr s1, cstr s2);
  55. cstr scoresep(i96 num);
  56. cstr alientext(i32 num);
  57. str LanguageV(str name);
  58. char *LanguageVC(char *out, cstr name);
  59. char *LanguageCV(char *out, cstr name, ...);
  60. str LanguageNull(cstr fmt, ...);
  61. cstr RemoveTextColors_str(astr s, i32 size);
  62. cstr RemoveTextColors (cstr s, i32 size);
  63. /* EOF */