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
80bce97e
Commit
80bce97e
authored
Nov 03, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gc, ld: sync pathtoprefix + add comments
R=lvd, lvd CC=golang-dev
https://golang.org/cl/5332051
parent
d6ff3c11
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
subr.c
src/cmd/gc/subr.c
+2
-0
lib.c
src/cmd/ld/lib.c
+11
-3
No files found.
src/cmd/gc/subr.c
View file @
80bce97e
...
...
@@ -2916,6 +2916,8 @@ ngotype(Node *n)
* non-7-bit clean bytes turn into %xx. The period needs escaping
* only in the last segment of the path, and it makes for happier
* users if we escape that as little as possible.
*
* If you edit this, edit ../ld/lib.c:/^pathtoprefix copy too.
*/
static
char
*
pathtoprefix
(
char
*
s
)
...
...
src/cmd/ld/lib.c
View file @
80bce97e
...
...
@@ -903,18 +903,26 @@ unmal(void *v, uint32 n)
* Convert raw string to the prefix that will be used in the symbol table.
* Invalid bytes turn into %xx. Right now the only bytes that need
* escaping are %, ., and ", but we escape all control characters too.
*
* Must be same as ../gc/subr.c:/^pathtoprefix.
*/
static
char
*
pathtoprefix
(
char
*
s
)
{
static
char
hex
[]
=
"0123456789abcdef"
;
char
*
p
,
*
r
,
*
w
;
char
*
p
,
*
r
,
*
w
,
*
l
;
int
n
;
// find first character past the last slash, if any.
l
=
s
;
for
(
r
=
s
;
*
r
;
r
++
)
if
(
*
r
==
'/'
)
l
=
r
+
1
;
// check for chars that need escaping
n
=
0
;
for
(
r
=
s
;
*
r
;
r
++
)
if
(
*
r
<=
' '
||
*
r
==
'.'
||
*
r
==
'%'
||
*
r
==
'"'
)
if
(
*
r
<=
' '
||
(
*
r
==
'.'
&&
r
>=
l
)
||
*
r
==
'%'
||
*
r
==
'"'
||
*
r
>=
0x7f
)
n
++
;
// quick exit
...
...
@@ -924,7 +932,7 @@ pathtoprefix(char *s)
// escape
p
=
mal
((
r
-
s
)
+
1
+
2
*
n
);
for
(
r
=
s
,
w
=
p
;
*
r
;
r
++
)
{
if
(
*
r
<=
' '
||
*
r
==
'.'
||
*
r
==
'%'
||
*
r
==
'"'
)
{
if
(
*
r
<=
' '
||
(
*
r
==
'.'
&&
r
>=
l
)
||
*
r
==
'%'
||
*
r
==
'"'
||
*
r
>=
0x7f
)
{
*
w
++
=
'%'
;
*
w
++
=
hex
[(
*
r
>>
4
)
&
0xF
];
*
w
++
=
hex
[
*
r
&
0xF
];
...
...
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