mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-07-06 02:20:25 +00:00
Makes qbs__trim a tad less thoughtful memory-wise. Addresses #56.
This commit is contained in:
parent
cdfa7e9cb9
commit
4ad9738b4d
|
@ -6726,20 +6726,7 @@ qbs *qbs_rtrim(qbs *str){
|
||||||
}
|
}
|
||||||
|
|
||||||
qbs *qbs__trim(qbs *str){
|
qbs *qbs__trim(qbs *str){
|
||||||
if (!str->len) return str;
|
return qbs_rtrim(qbs_ltrim(str));
|
||||||
if ((*str->chr!=32)&&(str->chr[str->len-1]!=32)) return str;//pass on
|
|
||||||
|
|
||||||
qbs *tqbs = NULL;
|
|
||||||
if (str->tmp&&!str->fixed&&!str->readonly&&!str->in_cmem) {
|
|
||||||
tqbs=str;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tqbs = qbs_new(str->len,1);
|
|
||||||
memcpy(tqbs->chr,str->chr,str->len);
|
|
||||||
}
|
|
||||||
qbs_set(tqbs,qbs_rtrim(qbs_ltrim(tqbs)));
|
|
||||||
if (tqbs!=str&&str->tmp) qbs_free(str);
|
|
||||||
return tqbs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 func__str_nc_compare(qbs *s1, qbs *s2) {
|
int32 func__str_nc_compare(qbs *s1, qbs *s2) {
|
||||||
|
|
Loading…
Reference in a new issue