1.1 --- a/templates/native/str.c Sun Feb 12 23:24:42 2017 +0100
1.2 +++ b/templates/native/str.c Mon Feb 13 18:54:59 2017 +0100
1.3 @@ -32,10 +32,12 @@
1.4 {
1.5 __attr * const _data = &__args[1];
1.6 __attr * const other = &__args[2];
1.7 + __attr * const _size = &__args[3];
1.8 + __attr * const othersize = &__args[4];
1.9 /* _data, other interpreted as string */
1.10 char *s = _data->strvalue;
1.11 char *o = other->strvalue;
1.12 - size_t ss = strlen(_data->strvalue), os = strlen(other->strvalue);
1.13 + int ss = _size->intvalue, os = othersize->intvalue;
1.14 int n = ss + os;
1.15 char *r = (char *) __ALLOCATE(n + 1, sizeof(char));
1.16
1.17 @@ -43,7 +45,7 @@
1.18 memcpy(r + ss, o, os);
1.19
1.20 /* Return a new string. */
1.21 - return __new_str(r);
1.22 + return __new_str(r, n);
1.23 }
1.24
1.25 __attr __fn_native_str_str_chr(__attr __args[])
1.26 @@ -54,7 +56,7 @@
1.27 char *s = (char *) __ALLOCATE(2, sizeof(char));
1.28
1.29 s[0] = (char) n;
1.30 - return __new_str(s);
1.31 + return __new_str(s, 1);
1.32 }
1.33
1.34 __attr __fn_native_str_str_lt(__attr __args[])
1.35 @@ -93,21 +95,6 @@
1.36 return strcmp(s, o) == 0 ? __builtins___boolean_True : __builtins___boolean_False;
1.37 }
1.38
1.39 -__attr __fn_native_str_str_len(__attr __args[])
1.40 -{
1.41 - __attr * const _data = &__args[1];
1.42 -
1.43 - /* Return the new integer. */
1.44 - return __new_int(strlen(_data->strvalue));
1.45 -}
1.46 -
1.47 -__attr __fn_native_str_str_nonempty(__attr __args[])
1.48 -{
1.49 - __attr * const _data = &__args[1];
1.50 -
1.51 - return _data->strvalue[0] ? __builtins___boolean_True : __builtins___boolean_False;
1.52 -}
1.53 -
1.54 __attr __fn_native_str_str_ord(__attr __args[])
1.55 {
1.56 __attr * const _data = &__args[1];
1.57 @@ -147,7 +134,7 @@
1.58 for (from = istart, to = 0; from > iend; from += istep, to++)
1.59 sub[to] = s[from];
1.60
1.61 - return __new_str(sub);
1.62 + return __new_str(sub, resultsize);
1.63 }
1.64
1.65 /* Module initialisation. */