X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Flib%2Fstring.qh;h=47a8175cac598554b3f2965a7dfc83db5429d2f5;hp=ef1c00c62c3c5c0d2714327f8d649b16120fc5ef;hb=f72821fdcebe3ca01181a99727a06198de65ea08;hpb=678a61b45f332fcd560083b01e6b0bf5a5ae268c diff --git a/qcsrc/lib/string.qh b/qcsrc/lib/string.qh index ef1c00c62..47a8175ca 100644 --- a/qcsrc/lib/string.qh +++ b/qcsrc/lib/string.qh @@ -1,5 +1,4 @@ -#ifndef STRING_H -#define STRING_H +#pragma once #include "nil.qh" #include "sort.qh" @@ -17,7 +16,6 @@ } #endif -// TODO: macro string seconds_tostring(float sec) { float minutes = floor(sec / 60); @@ -105,6 +103,9 @@ bool startsWithNocase(string haystack, string needle) return strcasecmp(substring(haystack, 0, strlen(needle)), needle) == 0; } +noref string _endsWith_suffix; +#define endsWith(this, suffix) (_endsWith_suffix = suffix, substring(this, -strlen(_endsWith_suffix), -1) == _endsWith_suffix) + /** unzone the string, and return it as tempstring. Safe to be called on string_null */ string fstrunzone(string s) { @@ -323,5 +324,3 @@ const string HEXDIGITS = "0123456789ABCDEF0123456789abcdef"; #define HEXDIGIT_TO_DEC_RAW(d) (strstrofs(HEXDIGITS, (d), 0)) #define HEXDIGIT_TO_DEC(d) ((HEXDIGIT_TO_DEC_RAW(d) | 0x10) - 0x10) #define DEC_TO_HEXDIGIT(d) (substring(HEXDIGITS, (d), 1)) - -#endif