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
613a5c8b
Commit
613a5c8b
authored
Oct 31, 2008
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
\x00 for NUL in type string.
R=rsc DELTA=14 (9 added, 0 deleted, 5 changed) OCL=18281 CL=18281
parent
8a1ad756
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
5 deletions
+14
-5
test.go
src/lib/reflect/test.go
+1
-1
tostring.go
src/lib/reflect/tostring.go
+1
-1
type.go
src/lib/reflect/type.go
+12
-3
No files found.
src/lib/reflect/test.go
View file @
613a5c8b
...
...
@@ -119,7 +119,7 @@ func main() {
typedump
(
"struct {a int8; b int8; c int8; d int8; b int32}"
,
"struct{a int8; b int8; c int8; d int8; b int32}"
);
typedump
(
"struct {a int8; b int8; c int8; d int8; e int8; b int32}"
,
"struct{a int8; b int8; c int8; d int8; e int8; b int32}"
);
typedump
(
"struct {a int8
\"
hi there
\"
; }"
,
"struct{a int8
\"
hi there
\"
}"
);
typedump
(
"struct {a int8
\"
hi
\\
0there
\\
t
\\
n
\\\"\\\\\"
; }"
,
"struct{a int8
\"
hi
\\
0there
\\
t
\\
n
\\\"\\\\\"
}"
);
typedump
(
"struct {a int8
\"
hi
\\
x00there
\\
t
\\
n
\\\"\\\\\"
; }"
,
"struct{a int8
\"
hi
\\
x0
0there
\\
t
\\
n
\\\"\\\\\"
}"
);
valuedump
(
"int8"
,
"8"
);
valuedump
(
"int16"
,
"16"
);
...
...
src/lib/reflect/tostring.go
View file @
613a5c8b
...
...
@@ -25,7 +25,7 @@ func DoubleQuote(s string) string {
case
'\t'
:
out
+=
`\t`
;
case
'\x00'
:
out
+=
`\0`
;
out
+=
`\
x0
0`
;
case
'"'
:
out
+=
`\"`
;
case
'\\'
:
...
...
src/lib/reflect/type.go
View file @
613a5c8b
...
...
@@ -453,7 +453,7 @@ func init() {
typename =
name '.' name
doublequotedstring =
string in " "; escapes are \0 (NUL) \n \t \" \\
string in " "; escapes are \
x0
0 (NUL) \n \t \" \\
fieldlist =
[ field { [ ',' | ';' ] field } ]
field =
...
...
@@ -492,6 +492,10 @@ func special(c uint8) bool {
return
false
;
}
func
hex00
(
s
string
,
i
int
)
bool
{
return
i
+
2
<
len
(
s
)
&&
s
[
i
]
==
'0'
&&
s
[
i
+
1
]
==
'0'
}
// Process backslashes. String known to be well-formed.
// Initial double-quote is left in, as an indication this token is a string.
func
unescape
(
s
string
,
backslash
bool
)
string
{
...
...
@@ -509,8 +513,13 @@ func unescape(s string, backslash bool) string {
c
=
'\n'
;
case
't'
:
c
=
'\t'
;
case
'0'
:
// it's not a legal go string but \0 means NUL
c
=
'\x00'
;
case
'x'
:
if
hex00
(
s
,
i
+
1
)
{
i
+=
2
;
c
=
0
;
break
;
}
// otherwise just put an 'x'; erroneous but safe.
// default is correct already; \\ is \; \" is "
}
}
...
...
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