X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Fstring.qh;h=c4b594d40fd846cf81b6e5e20de920abbb110642;hb=45d8904a100765555e622598a39967963733df1d;hp=812eb72c8424bf2ab19f3d04fc30bf01522f3213;hpb=d01c567581179df7cc68bcdc8dce58efad911bc4;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/string.qh b/qcsrc/lib/string.qh index 812eb72c8..c4b594d40 100644 --- a/qcsrc/lib/string.qh +++ b/qcsrc/lib/string.qh @@ -4,6 +4,25 @@ #include "sort.qh" #include "oo.qh" +// string logic +// +// true: is truthy +// == "": is equal to "" +// is "": has the same string index as the string constant "" +// strunzone: can be strunzoned +// +// | | true | == "" | is "" | strunzone | +// | :----------: | :--: | :---: | :---: | :-------: | +// | nil | | yes | | | +// | strcat(nil) | yes | yes | | | +// | strzone(nil) | yes | yes | | yes | +// | "" | yes | yes | yes | | +// | strcat("") | yes | yes | | | +// | strzone("") | yes | yes | | yes | +// | "s" | yes | | | | +// | strcat("s") | yes | | | | +// | strzone("s") | yes | | | yes | + #ifdef CSQC float stringwidth_colors(string s, vector theSize) { @@ -27,6 +46,20 @@ } #endif +#define strcpy(this, s) MACRO_BEGIN \ + if (this) { \ + strunzone(this); \ + } \ + this = strzone(s); \ +MACRO_END + +#define strfree(this) MACRO_BEGIN \ + if (this) { \ + strunzone(this); \ + } \ + this = string_null; \ +MACRO_END + ERASEABLE string seconds_tostring(float sec) { @@ -264,7 +297,7 @@ int u8_strsize(string s) return l; } -//List of Unicode spaces: https://www.cs.tut.fi/~jkorpela/chars/spaces.html +// List of Unicode spaces: http://jkorpela.fi/chars/spaces.html ERASEABLE bool isInvisibleString(string s) {