Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
7ee60b17
Commit
7ee60b17
authored
Oct 07, 2008
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sys.stringtorune doesn't need a length parameter.
R=rsc DELTA=7 (0 added, 0 deleted, 7 changed) OCL=16600 CL=16630
parent
74e2e087
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
7 additions
and
7 deletions
+7
-7
sys.go
src/cmd/gc/sys.go
+1
-1
sysimport.c
src/cmd/gc/sysimport.c
+2
-2
rune.c
src/runtime/rune.c
+2
-2
runtime.h
src/runtime/runtime.h
+1
-1
utf.go
test/utf.go
+1
-1
No files found.
src/cmd/gc/sys.go
View file @
7ee60b17
...
...
@@ -76,7 +76,7 @@ export func goexit();
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
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
);
src/cmd/gc/sysimport.c
View file @
7ee60b17
char
*
sysimport
=
char
*
sysimport
=
"package sys
\n
"
"type sys.any any
\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.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.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
"
"
\n
"
"$$
\n
"
;
src/runtime/rune.c
View file @
7ee60b17
...
...
@@ -235,9 +235,9 @@ sys·bytestorune(byte *str, int32 off, int32 length, int32 outrune, int32 outcou
}
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
(
&
outcount
);
}
src/runtime/runtime.h
View file @
7ee60b17
...
...
@@ -293,4 +293,4 @@ void sys·intstring(int64, string);
*/
void
sys
·
readfile
(
string
,
string
,
bool
);
void
sys
·
bytestorune
(
byte
*
,
int32
,
int32
,
int32
,
int32
);
void
sys
·
stringtorune
(
string
,
int32
,
int32
,
int32
,
int32
);
void
sys
·
stringtorune
(
string
,
int32
,
int32
,
int32
);
test/utf.go
View file @
7ee60b17
...
...
@@ -21,7 +21,7 @@ func main() {
var
l
=
len
(
s
);
for
w
,
i
,
j
:=
0
,
0
,
0
;
i
<
l
;
i
+=
w
{
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
r
!=
chars
[
j
]
{
panic
(
"wrong value from string"
)
}
j
++
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment