Commit 6db99de6 authored by Rob Pike's avatar Rob Pike

add bytestorune and stringtorune to sys.

SVN=126321
parent 5352306f
...@@ -45,6 +45,8 @@ func mapassign1(hmap *map[any]any, key any, val any); ...@@ -45,6 +45,8 @@ func mapassign1(hmap *map[any]any, key any, val any);
func mapassign2(hmap *map[any]any, key any, val any, pres bool); func mapassign2(hmap *map[any]any, key any, val any, pres bool);
func readfile(string) (string, bool); // read file into string; boolean status func readfile(string) (string, bool); // read file into string; boolean status
func bytestorune(*byte, int32, int32) (int32, int32); // convert bytes to runes
func stringtorune(string, int32, int32) (int32, int32); // convert bytes to runes
func exit(int32); func exit(int32);
...@@ -94,6 +96,10 @@ export ...@@ -94,6 +96,10 @@ export
// files // files
readfile readfile
// runes and utf-8
bytestorune
stringtorune
// system calls // system calls
exit exit
; ;
This diff is collapsed.
...@@ -222,3 +222,22 @@ runetochar(byte *str, int32 rune) /* note: in original, arg2 was pointer */ ...@@ -222,3 +222,22 @@ runetochar(byte *str, int32 rune) /* note: in original, arg2 was pointer */
str[3] = Tx | (c & Maskx); str[3] = Tx | (c & Maskx);
return 4; return 4;
} }
/*
* Wrappers for calling from go
*/
void
sys·bytestorune(byte *str, int32 off, int32 length, int32 outrune, int32 outcount)
{
outcount = charntorune(&outrune, str + off, length);
FLUSH(&outrune);
FLUSH(&outcount);
}
void
sys·stringtorune(string str, int32 off, int32 length, int32 outrune, int32 outcount)
{
outcount = charntorune(&outrune, str->str + off, length);
FLUSH(&outrune);
FLUSH(&outcount);
}
...@@ -142,4 +142,10 @@ void sys·intstring(int64, string); ...@@ -142,4 +142,10 @@ void sys·intstring(int64, string);
void sys·ifaces2i(Sigi*, Sigs*, Map*, void*); void sys·ifaces2i(Sigi*, Sigs*, Map*, void*);
void sys·ifacei2i(Sigi*, Map*, void*); void sys·ifacei2i(Sigi*, Map*, void*);
void sys·ifacei2s(Sigs*, Map*, void*); void sys·ifacei2s(Sigs*, Map*, void*);
/*
* User go-called
*/
void sys·readfile(string, string, bool); void sys·readfile(string, string, bool);
void sys·bytestorune(byte*, int32, int32, int32, int32);
void sys·stringtorune(string, int32, int32, int32, int32);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment