Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
33b6d46a
Commit
33b6d46a
authored
Jan 30, 2012
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/pack: change gopack to pack in error messages
R=golang-dev, bradfitz CC=golang-dev
https://golang.org/cl/5598051
parent
1f7128e1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
35 deletions
+34
-35
src/cmd/pack/ar.c
src/cmd/pack/ar.c
+34
-35
No files found.
src/cmd/pack/ar.c
View file @
33b6d46a
...
@@ -227,12 +227,12 @@ main(int argc, char *argv[])
...
@@ -227,12 +227,12 @@ main(int argc, char *argv[])
case
'S'
:
Sflag
=
1
;
break
;
case
'S'
:
Sflag
=
1
;
break
;
case
'P'
:
Pflag
=
1
;
break
;
case
'P'
:
Pflag
=
1
;
break
;
default:
default:
fprint
(
2
,
"
go
pack: bad option `%c'
\n
"
,
*
cp
);
fprint
(
2
,
"pack: bad option `%c'
\n
"
,
*
cp
);
exits
(
"error"
);
exits
(
"error"
);
}
}
}
}
if
(
aflag
&&
bflag
)
{
if
(
aflag
&&
bflag
)
{
fprint
(
2
,
"
go
pack: only one of 'a' and 'b' can be specified
\n
"
);
fprint
(
2
,
"pack: only one of 'a' and 'b' can be specified
\n
"
);
usage
();
usage
();
}
}
if
(
aflag
||
bflag
)
{
if
(
aflag
||
bflag
)
{
...
@@ -244,7 +244,7 @@ main(int argc, char *argv[])
...
@@ -244,7 +244,7 @@ main(int argc, char *argv[])
}
}
if
(
Pflag
)
{
if
(
Pflag
)
{
if
(
argc
<
4
)
{
if
(
argc
<
4
)
{
fprint
(
2
,
"
go
pack: P flag requires prefix argument
\n
"
);
fprint
(
2
,
"pack: P flag requires prefix argument
\n
"
);
usage
();
usage
();
}
}
prefix
=
argv
[
2
];
prefix
=
argv
[
2
];
...
@@ -253,7 +253,7 @@ main(int argc, char *argv[])
...
@@ -253,7 +253,7 @@ main(int argc, char *argv[])
}
}
if
(
comfun
==
0
)
{
if
(
comfun
==
0
)
{
if
(
uflag
==
0
)
{
if
(
uflag
==
0
)
{
fprint
(
2
,
"
go
pack: one of [%s] must be specified
\n
"
,
man
);
fprint
(
2
,
"pack: one of [%s] must be specified
\n
"
,
man
);
usage
();
usage
();
}
}
setcom
(
rcmd
);
setcom
(
rcmd
);
...
@@ -267,7 +267,7 @@ main(int argc, char *argv[])
...
@@ -267,7 +267,7 @@ main(int argc, char *argv[])
cp
=
0
;
cp
=
0
;
while
(
argc
--
)
{
while
(
argc
--
)
{
if
(
*
argv
)
{
if
(
*
argv
)
{
fprint
(
2
,
"
go
pack: %s not found
\n
"
,
*
argv
);
fprint
(
2
,
"pack: %s not found
\n
"
,
*
argv
);
cp
=
"error"
;
cp
=
"error"
;
}
}
argv
++
;
argv
++
;
...
@@ -284,7 +284,7 @@ setcom(void (*fun)(char *, int, char**))
...
@@ -284,7 +284,7 @@ setcom(void (*fun)(char *, int, char**))
{
{
if
(
comfun
!=
0
)
{
if
(
comfun
!=
0
)
{
fprint
(
2
,
"
go
pack: only one of [%s] allowed
\n
"
,
man
);
fprint
(
2
,
"pack: only one of [%s] allowed
\n
"
,
man
);
usage
();
usage
();
}
}
comfun
=
fun
;
comfun
=
fun
;
...
@@ -345,7 +345,7 @@ rcmd(char *arname, int count, char **files)
...
@@ -345,7 +345,7 @@ rcmd(char *arname, int count, char **files)
bfile
=
Bopen
(
file
,
OREAD
);
bfile
=
Bopen
(
file
,
OREAD
);
if
(
!
bfile
)
{
if
(
!
bfile
)
{
if
(
count
!=
0
)
{
if
(
count
!=
0
)
{
fprint
(
2
,
"
go
pack: cannot open %s
\n
"
,
file
);
fprint
(
2
,
"pack: cannot open %s
\n
"
,
file
);
errors
++
;
errors
++
;
}
}
scanobj
(
&
bar
,
ap
,
bp
->
size
);
scanobj
(
&
bar
,
ap
,
bp
->
size
);
...
@@ -354,7 +354,7 @@ rcmd(char *arname, int count, char **files)
...
@@ -354,7 +354,7 @@ rcmd(char *arname, int count, char **files)
}
}
d
=
dirfstat
(
Bfildes
(
bfile
));
d
=
dirfstat
(
Bfildes
(
bfile
));
if
(
d
==
nil
)
if
(
d
==
nil
)
fprint
(
2
,
"
go
pack: cannot stat %s: %r
\n
"
,
file
);
fprint
(
2
,
"pack: cannot stat %s: %r
\n
"
,
file
);
if
(
uflag
&&
(
d
==
nil
||
d
->
mtime
<=
bp
->
date
))
{
if
(
uflag
&&
(
d
==
nil
||
d
->
mtime
<=
bp
->
date
))
{
scanobj
(
&
bar
,
ap
,
bp
->
size
);
scanobj
(
&
bar
,
ap
,
bp
->
size
);
arcopy
(
&
bar
,
ap
,
bp
);
arcopy
(
&
bar
,
ap
,
bp
);
...
@@ -379,7 +379,7 @@ rcmd(char *arname, int count, char **files)
...
@@ -379,7 +379,7 @@ rcmd(char *arname, int count, char **files)
files
[
i
]
=
0
;
files
[
i
]
=
0
;
bfile
=
Bopen
(
file
,
OREAD
);
bfile
=
Bopen
(
file
,
OREAD
);
if
(
!
bfile
)
{
if
(
!
bfile
)
{
fprint
(
2
,
"
go
pack: cannot open %s
\n
"
,
file
);
fprint
(
2
,
"pack: cannot open %s
\n
"
,
file
);
errors
++
;
errors
++
;
}
else
{
}
else
{
mesg
(
'a'
,
file
);
mesg
(
'a'
,
file
);
...
@@ -447,7 +447,7 @@ xcmd(char *arname, int count, char **files)
...
@@ -447,7 +447,7 @@ xcmd(char *arname, int count, char **files)
mode
=
strtoul
(
bp
->
hdr
.
mode
,
0
,
8
)
&
0777
;
mode
=
strtoul
(
bp
->
hdr
.
mode
,
0
,
8
)
&
0777
;
f
=
create
(
file
,
OWRITE
,
mode
);
f
=
create
(
file
,
OWRITE
,
mode
);
if
(
f
<
0
)
{
if
(
f
<
0
)
{
fprint
(
2
,
"
go
pack: %s cannot create
\n
"
,
file
);
fprint
(
2
,
"pack: %s cannot create
\n
"
,
file
);
skip
(
&
bar
,
bp
->
size
);
skip
(
&
bar
,
bp
->
size
);
}
else
{
}
else
{
mesg
(
'x'
,
file
);
mesg
(
'x'
,
file
);
...
@@ -541,7 +541,7 @@ mcmd(char *arname, int count, char **files)
...
@@ -541,7 +541,7 @@ mcmd(char *arname, int count, char **files)
}
}
close
(
fd
);
close
(
fd
);
if
(
poname
[
0
]
&&
aend
==
0
)
if
(
poname
[
0
]
&&
aend
==
0
)
fprint
(
2
,
"
go
pack: %s not found - files moved to end.
\n
"
,
poname
);
fprint
(
2
,
"pack: %s not found - files moved to end.
\n
"
,
poname
);
install
(
arname
,
astart
,
amiddle
,
aend
,
0
);
install
(
arname
,
astart
,
amiddle
,
aend
,
0
);
}
}
void
void
...
@@ -574,13 +574,13 @@ qcmd(char *arname, int count, char **files)
...
@@ -574,13 +574,13 @@ qcmd(char *arname, int count, char **files)
Biobuf
*
bfile
;
Biobuf
*
bfile
;
if
(
aflag
||
bflag
)
{
if
(
aflag
||
bflag
)
{
fprint
(
2
,
"
go
pack: abi not allowed with q
\n
"
);
fprint
(
2
,
"pack: abi not allowed with q
\n
"
);
exits
(
"error"
);
exits
(
"error"
);
}
}
fd
=
openar
(
arname
,
ORDWR
,
1
);
fd
=
openar
(
arname
,
ORDWR
,
1
);
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
if
(
!
cflag
)
if
(
!
cflag
)
fprint
(
2
,
"
go
pack: creating %s
\n
"
,
arname
);
fprint
(
2
,
"pack: creating %s
\n
"
,
arname
);
fd
=
arcreate
(
arname
);
fd
=
arcreate
(
arname
);
}
}
Binit
(
&
bar
,
fd
,
OREAD
);
Binit
(
&
bar
,
fd
,
OREAD
);
...
@@ -594,7 +594,7 @@ qcmd(char *arname, int count, char **files)
...
@@ -594,7 +594,7 @@ qcmd(char *arname, int count, char **files)
files
[
i
]
=
0
;
files
[
i
]
=
0
;
bfile
=
Bopen
(
file
,
OREAD
);
bfile
=
Bopen
(
file
,
OREAD
);
if
(
!
bfile
)
{
if
(
!
bfile
)
{
fprint
(
2
,
"
go
pack: cannot open %s
\n
"
,
file
);
fprint
(
2
,
"pack: cannot open %s
\n
"
,
file
);
errors
++
;
errors
++
;
}
else
{
}
else
{
mesg
(
'q'
,
file
);
mesg
(
'q'
,
file
);
...
@@ -680,13 +680,13 @@ scanobj(Biobuf *b, Arfile *ap, long size)
...
@@ -680,13 +680,13 @@ scanobj(Biobuf *b, Arfile *ap, long size)
}
}
if
(
!
gflag
||
strcmp
(
file
,
pkgdef
)
!=
0
)
{
/* don't clear allobj if it's pkg defs */
if
(
!
gflag
||
strcmp
(
file
,
pkgdef
)
!=
0
)
{
/* don't clear allobj if it's pkg defs */
fprint
(
2
,
"
go
pack: non-object file %s
\n
"
,
file
);
fprint
(
2
,
"pack: non-object file %s
\n
"
,
file
);
errors
++
;
errors
++
;
allobj
=
0
;
allobj
=
0
;
}
}
d
=
dirfstat
(
Bfildes
(
b
));
d
=
dirfstat
(
Bfildes
(
b
));
if
(
d
!=
nil
&&
d
->
length
==
0
)
{
if
(
d
!=
nil
&&
d
->
length
==
0
)
{
fprint
(
2
,
"
go
pack: zero length file %s
\n
"
,
file
);
fprint
(
2
,
"pack: zero length file %s
\n
"
,
file
);
errors
++
;
errors
++
;
}
}
free
(
d
);
free
(
d
);
...
@@ -709,7 +709,7 @@ scanobj(Biobuf *b, Arfile *ap, long size)
...
@@ -709,7 +709,7 @@ scanobj(Biobuf *b, Arfile *ap, long size)
Bseek
(
b
,
offset1
,
0
);
Bseek
(
b
,
offset1
,
0
);
if
(
p
==
nil
||
strncmp
(
p
,
"go object "
,
10
)
!=
0
)
{
if
(
p
==
nil
||
strncmp
(
p
,
"go object "
,
10
)
!=
0
)
{
fprint
(
2
,
"
go
pack: malformed object file %s
\n
"
,
file
);
fprint
(
2
,
"pack: malformed object file %s
\n
"
,
file
);
errors
++
;
errors
++
;
Bseek
(
b
,
offset
,
0
);
Bseek
(
b
,
offset
,
0
);
free
(
p
);
free
(
p
);
...
@@ -717,7 +717,7 @@ scanobj(Biobuf *b, Arfile *ap, long size)
...
@@ -717,7 +717,7 @@ scanobj(Biobuf *b, Arfile *ap, long size)
}
}
if
(
!
matchhdr
(
p
,
&
objhdr
))
{
if
(
!
matchhdr
(
p
,
&
objhdr
))
{
fprint
(
2
,
"
go
pack: inconsistent object file %s: [%s] vs [%s]
\n
"
,
file
,
p
,
objhdr
);
fprint
(
2
,
"pack: inconsistent object file %s: [%s] vs [%s]
\n
"
,
file
,
p
,
objhdr
);
errors
++
;
errors
++
;
allobj
=
0
;
allobj
=
0
;
free
(
p
);
free
(
p
);
...
@@ -727,7 +727,7 @@ scanobj(Biobuf *b, Arfile *ap, long size)
...
@@ -727,7 +727,7 @@ scanobj(Biobuf *b, Arfile *ap, long size)
// Old check. Should be impossible since objhdrs match, but keep the check anyway.
// Old check. Should be impossible since objhdrs match, but keep the check anyway.
if
(
lastobj
>=
0
&&
obj
!=
lastobj
)
{
if
(
lastobj
>=
0
&&
obj
!=
lastobj
)
{
fprint
(
2
,
"
go
pack: inconsistent object file %s
\n
"
,
file
);
fprint
(
2
,
"pack: inconsistent object file %s
\n
"
,
file
);
errors
++
;
errors
++
;
allobj
=
0
;
allobj
=
0
;
return
;
return
;
...
@@ -735,7 +735,7 @@ scanobj(Biobuf *b, Arfile *ap, long size)
...
@@ -735,7 +735,7 @@ scanobj(Biobuf *b, Arfile *ap, long size)
lastobj
=
obj
;
lastobj
=
obj
;
if
(
!
readar
(
b
,
obj
,
offset
+
size
,
0
))
{
if
(
!
readar
(
b
,
obj
,
offset
+
size
,
0
))
{
fprint
(
2
,
"
go
pack: invalid symbol reference in file %s
\n
"
,
file
);
fprint
(
2
,
"pack: invalid symbol reference in file %s
\n
"
,
file
);
errors
++
;
errors
++
;
allobj
=
0
;
allobj
=
0
;
Bseek
(
b
,
offset
,
0
);
Bseek
(
b
,
offset
,
0
);
...
@@ -825,7 +825,7 @@ scanpkg(Biobuf *b, long size)
...
@@ -825,7 +825,7 @@ scanpkg(Biobuf *b, long size)
continue
;
continue
;
goto
foundstart
;
goto
foundstart
;
}
}
// fprint(2, "
go
pack: warning: no package import section in %s\n", file);
// fprint(2, "pack: warning: no package import section in %s\n", file);
if
(
b
!=
&
bar
||
!
pkgdefsafe
)
if
(
b
!=
&
bar
||
!
pkgdefsafe
)
safe
=
0
;
// non-Go file (C or assembly)
safe
=
0
;
// non-Go file (C or assembly)
return
;
return
;
...
@@ -875,7 +875,7 @@ foundstart:
...
@@ -875,7 +875,7 @@ foundstart:
free
(
line
);
free
(
line
);
}
}
bad:
bad:
fprint
(
2
,
"
go
pack: bad package import section in %s
\n
"
,
file
);
fprint
(
2
,
"pack: bad package import section in %s
\n
"
,
file
);
errors
++
;
errors
++
;
return
;
return
;
...
@@ -885,7 +885,7 @@ foundend:
...
@@ -885,7 +885,7 @@ foundend:
if
(
end
==
0
)
if
(
end
==
0
)
goto
bad
;
goto
bad
;
if
(
importblock
!=
nil
)
{
if
(
importblock
!=
nil
)
{
fprint
(
2
,
"
go
pack: multiple Go object files
\n
"
);
fprint
(
2
,
"pack: multiple Go object files
\n
"
);
errors
++
;
errors
++
;
return
;
return
;
}
}
...
@@ -893,7 +893,7 @@ foundend:
...
@@ -893,7 +893,7 @@ foundend:
data
=
armalloc
(
end
-
start
+
1
);
data
=
armalloc
(
end
-
start
+
1
);
Bseek
(
b
,
start
,
0
);
Bseek
(
b
,
start
,
0
);
if
(
Bread
(
b
,
data
,
pkgsize
)
!=
pkgsize
)
{
if
(
Bread
(
b
,
data
,
pkgsize
)
!=
pkgsize
)
{
fprint
(
2
,
"
go
pack: error reading package import section in %s
\n
"
,
file
);
fprint
(
2
,
"pack: error reading package import section in %s
\n
"
,
file
);
errors
++
;
errors
++
;
return
;
return
;
}
}
...
@@ -993,11 +993,11 @@ openar(char *arname, int mode, int errok)
...
@@ -993,11 +993,11 @@ openar(char *arname, int mode, int errok)
fd
=
open
(
arname
,
mode
);
fd
=
open
(
arname
,
mode
);
if
(
fd
>=
0
){
if
(
fd
>=
0
){
if
(
read
(
fd
,
mbuf
,
SARMAG
)
!=
SARMAG
||
strncmp
(
mbuf
,
ARMAG
,
SARMAG
))
{
if
(
read
(
fd
,
mbuf
,
SARMAG
)
!=
SARMAG
||
strncmp
(
mbuf
,
ARMAG
,
SARMAG
))
{
fprint
(
2
,
"
go
pack: %s not in archive format
\n
"
,
arname
);
fprint
(
2
,
"pack: %s not in archive format
\n
"
,
arname
);
exits
(
"error"
);
exits
(
"error"
);
}
}
}
else
if
(
!
errok
){
}
else
if
(
!
errok
){
fprint
(
2
,
"
go
pack: cannot open %s: %r
\n
"
,
arname
);
fprint
(
2
,
"pack: cannot open %s: %r
\n
"
,
arname
);
exits
(
"error"
);
exits
(
"error"
);
}
}
return
fd
;
return
fd
;
...
@@ -1013,7 +1013,7 @@ arcreate(char *arname)
...
@@ -1013,7 +1013,7 @@ arcreate(char *arname)
fd
=
create
(
arname
,
OWRITE
,
0664
);
fd
=
create
(
arname
,
OWRITE
,
0664
);
if
(
fd
<
0
){
if
(
fd
<
0
){
fprint
(
2
,
"
go
pack: cannot create %s: %r
\n
"
,
arname
);
fprint
(
2
,
"pack: cannot create %s: %r
\n
"
,
arname
);
exits
(
"error"
);
exits
(
"error"
);
}
}
if
(
write
(
fd
,
ARMAG
,
SARMAG
)
!=
SARMAG
)
if
(
write
(
fd
,
ARMAG
,
SARMAG
)
!=
SARMAG
)
...
@@ -1027,28 +1027,28 @@ arcreate(char *arname)
...
@@ -1027,28 +1027,28 @@ arcreate(char *arname)
void
void
wrerr
(
void
)
wrerr
(
void
)
{
{
perror
(
"
go
pack: write error"
);
perror
(
"pack: write error"
);
exits
(
"error"
);
exits
(
"error"
);
}
}
void
void
rderr
(
void
)
rderr
(
void
)
{
{
perror
(
"
go
pack: read error"
);
perror
(
"pack: read error"
);
exits
(
"error"
);
exits
(
"error"
);
}
}
void
void
phaseerr
(
int
offset
)
phaseerr
(
int
offset
)
{
{
fprint
(
2
,
"
go
pack: phase error at offset %d
\n
"
,
offset
);
fprint
(
2
,
"pack: phase error at offset %d
\n
"
,
offset
);
exits
(
"error"
);
exits
(
"error"
);
}
}
void
void
usage
(
void
)
usage
(
void
)
{
{
fprint
(
2
,
"usage:
go
pack [%s][%s][P prefix] archive files ...
\n
"
,
opt
,
man
);
fprint
(
2
,
"usage: pack [%s][%s][P prefix] archive files ...
\n
"
,
opt
,
man
);
exits
(
"error"
);
exits
(
"error"
);
}
}
...
@@ -1092,7 +1092,7 @@ armove(Biobuf *b, Arfile *ap, Armember *bp)
...
@@ -1092,7 +1092,7 @@ armove(Biobuf *b, Arfile *ap, Armember *bp)
d
=
dirfstat
(
Bfildes
(
b
));
d
=
dirfstat
(
Bfildes
(
b
));
if
(
d
==
nil
)
{
if
(
d
==
nil
)
{
fprint
(
2
,
"
go
pack: cannot stat %s
\n
"
,
file
);
fprint
(
2
,
"pack: cannot stat %s
\n
"
,
file
);
return
;
return
;
}
}
...
@@ -1193,7 +1193,7 @@ install(char *arname, Arfile *astart, Arfile *amiddle, Arfile *aend, int createf
...
@@ -1193,7 +1193,7 @@ install(char *arname, Arfile *astart, Arfile *amiddle, Arfile *aend, int createf
rfork
(
RFNOTEG
);
rfork
(
RFNOTEG
);
if
(
createflag
)
if
(
createflag
)
fprint
(
2
,
"
go
pack: creating %s
\n
"
,
arname
);
fprint
(
2
,
"pack: creating %s
\n
"
,
arname
);
fd
=
arcreate
(
arname
);
fd
=
arcreate
(
arname
);
if
(
allobj
)
if
(
allobj
)
...
@@ -1593,7 +1593,6 @@ page(Arfile *ap)
...
@@ -1593,7 +1593,6 @@ page(Arfile *ap)
int
int
getspace
(
void
)
getspace
(
void
)
{
{
fprint
(
2
,
"IN GETSPACE
\n
"
);
if
(
astart
&&
astart
->
head
&&
page
(
astart
))
if
(
astart
&&
astart
->
head
&&
page
(
astart
))
return
1
;
return
1
;
if
(
amiddle
&&
amiddle
->
head
&&
page
(
amiddle
))
if
(
amiddle
&&
amiddle
->
head
&&
page
(
amiddle
))
...
@@ -1638,7 +1637,7 @@ armalloc(int n)
...
@@ -1638,7 +1637,7 @@ armalloc(int n)
return
cp
;
return
cp
;
}
}
}
while
(
getspace
());
}
while
(
getspace
());
fprint
(
2
,
"
go
pack: out of memory
\n
"
);
fprint
(
2
,
"pack: out of memory
\n
"
);
exits
(
"malloc"
);
exits
(
"malloc"
);
return
0
;
return
0
;
}
}
...
...
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