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
531e6b77
Commit
531e6b77
authored
Jan 26, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eliminate package global name space
R=ken2 CC=golang-dev
https://golang.org/cl/194071
parent
19126320
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
13 deletions
+17
-13
go.y
src/cmd/gc/go.y
+5
-6
lex.c
src/cmd/gc/lex.c
+1
-3
go.c
src/cmd/ld/go.c
+11
-4
No files found.
src/cmd/gc/go.y
View file @
531e6b77
...
...
@@ -237,14 +237,13 @@ import_package:
importpkg
->
name
=
$
2
->
name
;
importpkg
->
direct
=
1
;
//
PGNS
:
fixme
//
NOTE
(
rsc
):
This
is
no
longer
a
technical
restriction
:
//
the
6
g
tool
chain
would
work
just
fine
without
giving
//
special
meaning
to
a
package
being
named
main
.
//
Other
implementations
might
need
the
restriction
//
(
gccgo
does
),
so
it
stays
in
the
language
and
the
compiler
.
if
(
strcmp
($
2
->
name
,
"main"
)
==
0
)
yyerror
(
"cannot import package main"
);
//
PGNS
:
This
should
go
away
once
we
get
//
rid
of
the
global
package
name
space
.
if
(
localpkg
->
name
&&
strcmp
($
2
->
name
,
localpkg
->
name
)
==
0
&&
!compiling_runtime)
yyerror
(
"package cannot import itself"
);
}
import_there
:
...
...
src/cmd/gc/lex.c
View file @
531e6b77
...
...
@@ -285,9 +285,7 @@ importfile(Val *f, int line)
Strlit
*
path
;
char
cleanbuf
[
1024
];
// TODO(rsc): don't bother reloading imports more than once
// PGNS: canonicalize import path for ./ imports in findpkg.
// TODO(rsc): don't bother reloading imports more than once?
if
(
f
->
ctype
!=
CTSTR
)
{
yyerror
(
"import statement not a string"
);
...
...
src/cmd/ld/go.c
View file @
531e6b77
...
...
@@ -73,7 +73,7 @@ static int parsepkgdata(char*, char*, char**, char*, char**, char**, char**);
void
ldpkg
(
Biobuf
*
f
,
char
*
pkg
,
int64
len
,
char
*
filename
)
{
char
*
data
,
*
p0
,
*
p1
;
char
*
data
,
*
p0
,
*
p1
,
*
name
;
if
(
debug
[
'g'
])
return
;
...
...
@@ -111,10 +111,18 @@ ldpkg(Biobuf *f, char *pkg, int64 len, char *filename)
return
;
}
p0
+=
8
;
while
(
*
p0
==
' '
||
*
p0
==
'\t'
||
*
p0
==
'\n'
)
while
(
p0
<
p1
&&
*
p0
==
' '
||
*
p0
==
'\t'
||
*
p0
==
'\n'
)
p0
++
;
while
(
*
p0
!=
' '
&&
*
p0
!=
'\t'
&&
*
p0
!=
'\n'
)
name
=
p0
;
while
(
p0
<
p1
&&
*
p0
!=
' '
&&
*
p0
!=
'\t'
&&
*
p0
!=
'\n'
)
p0
++
;
if
(
p0
<
p1
)
{
*
p0
++
=
'\0'
;
if
(
strcmp
(
pkg
,
"main"
)
==
0
&&
strcmp
(
name
,
"main"
)
!=
0
)
fprint
(
2
,
"%s: %s: not package main (package %s)
\n
"
,
argv0
,
filename
,
name
);
else
if
(
strcmp
(
pkg
,
"main"
)
!=
0
&&
strcmp
(
name
,
"main"
)
==
0
)
fprint
(
2
,
"%s: %s: importing %s, found package main"
,
argv0
,
filename
,
pkg
);
}
loadpkgdata
(
filename
,
pkg
,
p0
,
p1
-
p0
);
}
...
...
@@ -131,7 +139,6 @@ ldpkg(Biobuf *f, char *pkg, int64 len, char *filename)
return
;
}
// PGNS: Should be using import path, not pkg.
loadpkgdata
(
filename
,
pkg
,
p0
,
p1
-
p0
);
// look for dynld section
...
...
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