mirror of
https://github.com/golang/go
synced 2024-11-22 03:54:39 -07:00
sys.stringtorune doesn't need a length parameter.
R=rsc DELTA=7 (0 added, 0 deleted, 7 changed) OCL=16600 CL=16630
This commit is contained in:
parent
74e2e087e2
commit
7ee60b174d
@ -76,7 +76,7 @@ export func goexit();
|
|||||||
export func readfile(string) (string, bool); // read file into string; boolean status
|
export func readfile(string) (string, bool); // read file into string; boolean status
|
||||||
export func writefile(string, string) (bool); // write string into file; boolean status
|
export func writefile(string, string) (bool); // write string into file; boolean status
|
||||||
export func bytestorune(*byte, int32, int32) (int32, int32); // convert bytes to runes
|
export func bytestorune(*byte, int32, int32) (int32, int32); // convert bytes to runes
|
||||||
export func stringtorune(string, int32, int32) (int32, int32); // convert bytes to runes
|
export func stringtorune(string, int32) (int32, int32); // convert bytes to runes
|
||||||
|
|
||||||
export func exit(int32);
|
export func exit(int32);
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
char *sysimport =
|
char *sysimport =
|
||||||
"package sys\n"
|
"package sys\n"
|
||||||
"type sys.any any\n"
|
"type sys.any any\n"
|
||||||
"type sys.uint32 uint32\n"
|
"type sys.uint32 uint32\n"
|
||||||
@ -66,7 +66,7 @@ char *sysimport =
|
|||||||
"export func sys.readfile (? sys.string) (? sys.string, ? sys.bool)\n"
|
"export func sys.readfile (? sys.string) (? sys.string, ? sys.bool)\n"
|
||||||
"export func sys.writefile (? sys.string, ? sys.string) (? sys.bool)\n"
|
"export func sys.writefile (? sys.string, ? sys.string) (? sys.bool)\n"
|
||||||
"export func sys.bytestorune (? *sys.uint8, ? sys.int32, ? sys.int32) (? sys.int32, ? sys.int32)\n"
|
"export func sys.bytestorune (? *sys.uint8, ? sys.int32, ? sys.int32) (? sys.int32, ? sys.int32)\n"
|
||||||
"export func sys.stringtorune (? sys.string, ? sys.int32, ? sys.int32) (? sys.int32, ? sys.int32)\n"
|
"export func sys.stringtorune (? sys.string, ? sys.int32) (? sys.int32, ? sys.int32)\n"
|
||||||
"export func sys.exit (? sys.int32)\n"
|
"export func sys.exit (? sys.int32)\n"
|
||||||
"\n"
|
"\n"
|
||||||
"$$\n";
|
"$$\n";
|
||||||
|
@ -235,9 +235,9 @@ sys·bytestorune(byte *str, int32 off, int32 length, int32 outrune, int32 outcou
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sys·stringtorune(string str, int32 off, int32 length, int32 outrune, int32 outcount)
|
sys·stringtorune(string str, int32 off, int32 outrune, int32 outcount)
|
||||||
{
|
{
|
||||||
outcount = charntorune(&outrune, str->str + off, length);
|
outcount = charntorune(&outrune, str->str + off, str->len - off);
|
||||||
FLUSH(&outrune);
|
FLUSH(&outrune);
|
||||||
FLUSH(&outcount);
|
FLUSH(&outcount);
|
||||||
}
|
}
|
||||||
|
@ -293,4 +293,4 @@ void sys·intstring(int64, string);
|
|||||||
*/
|
*/
|
||||||
void sys·readfile(string, string, bool);
|
void sys·readfile(string, string, bool);
|
||||||
void sys·bytestorune(byte*, int32, int32, int32, int32);
|
void sys·bytestorune(byte*, int32, int32, int32, int32);
|
||||||
void sys·stringtorune(string, int32, int32, int32, int32);
|
void sys·stringtorune(string, int32, int32, int32);
|
||||||
|
@ -21,7 +21,7 @@ func main() {
|
|||||||
var l = len(s);
|
var l = len(s);
|
||||||
for w, i, j := 0,0,0; i < l; i += w {
|
for w, i, j := 0,0,0; i < l; i += w {
|
||||||
var r int32;
|
var r int32;
|
||||||
r, w = sys.stringtorune(s, i, l);
|
r, w = sys.stringtorune(s, i);
|
||||||
if w == 0 { panic("zero width in string") }
|
if w == 0 { panic("zero width in string") }
|
||||||
if r != chars[j] { panic("wrong value from string") }
|
if r != chars[j] { panic("wrong value from string") }
|
||||||
j++;
|
j++;
|
||||||
|
Loading…
Reference in New Issue
Block a user