1.1 --- a/templates/native/str.c Sat Oct 30 23:09:57 2021 +0200
1.2 +++ b/templates/native/str.c Sun Oct 31 01:01:10 2021 +0200
1.3 @@ -1,6 +1,6 @@
1.4 /* Native functions for string operations.
1.5
1.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk>
1.7 +Copyright (C) 2016, 2017, 2021 Paul Boddie <paul@boddie.org.uk>
1.8
1.9 This program is free software; you can redistribute it and/or modify it under
1.10 the terms of the GNU General Public License as published by the Free Software
1.11 @@ -34,8 +34,8 @@
1.12 char *s = _data.strvalue;
1.13 char *o = other.strvalue;
1.14 /* _size, othersize interpreted as int */
1.15 - int ss = __TOINT(_size), os = __TOINT(othersize);
1.16 - int n = ss + os;
1.17 + __int ss = __TOINT(_size), os = __TOINT(othersize);
1.18 + __int n = ss + os;
1.19 char *r = (char *) __ALLOCATE(n + 1, sizeof(char));
1.20
1.21 memcpy(r, s, ss);
1.22 @@ -90,7 +90,7 @@
1.23 /* _data interpreted as string.__data__ */
1.24 char *s = _data.strvalue;
1.25
1.26 - return __new_int((unsigned int) s[0]);
1.27 + return __new_int((__int) s[0]);
1.28 }
1.29
1.30 __attr __fn_native_str_str_substr(__attr __self, __attr _data, __attr start, __attr end, __attr step)
1.31 @@ -98,15 +98,15 @@
1.32 /* _data interpreted as string.__data__ */
1.33 char *s = _data.strvalue, *sub;
1.34 /* start interpreted as int */
1.35 - int istart = __TOINT(start);
1.36 + __int istart = __TOINT(start);
1.37 /* end interpreted as int */
1.38 - int iend = __TOINT(end);
1.39 + __int iend = __TOINT(end);
1.40 /* step interpreted as int */
1.41 - int istep = __TOINT(step);
1.42 + __int istep = __TOINT(step);
1.43
1.44 /* Calculate the size of the substring. */
1.45 size_t resultsize = ((iend - istart - (istep > 0 ? 1 : -1)) / istep) + 1;
1.46 - int to, from;
1.47 + size_t to, from;
1.48
1.49 /* Reserve space for a new string. */
1.50 sub = (char *) __ALLOCATE(resultsize + 1, sizeof(char));