mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-17 13:29:28 +08:00
re PR fastjar/9532 (jar -C flag is incompatible with Sun's (fastjar uses nonportable feature of getcwd))
PR java/9532 * jartool.c (main) Give proper error messages with -C, and check for missing arguments properly. Send error messages to stderr. * jartool.c (add_to_jar): Make getcwd() call portable, and check for error return. From-SVN: r67985
This commit is contained in:
parent
3d57a5ccfe
commit
a55a78d134
@ -1,3 +1,12 @@
|
||||
2003-06-15 Nathanael Nerode <neroden@gcc.gnu.org>
|
||||
|
||||
PR java/9532
|
||||
* jartool.c (main) Give proper error messages with -C, and
|
||||
check for missing arguments properly. Send error messages
|
||||
to stderr.
|
||||
* jartool.c (add_to_jar): Make getcwd() call portable,
|
||||
and check for error return.
|
||||
|
||||
2003-03-30 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* fastjar.texi: Remove @ at start of file.
|
||||
|
@ -507,15 +507,19 @@ int main(int argc, char **argv){
|
||||
if(!strcmp(arg, "-C")){
|
||||
const char *dir_to_change = get_next_arg ();
|
||||
const char *file_to_add = get_next_arg ();
|
||||
if(!dir_to_change
|
||||
|| !file_to_add
|
||||
|| add_to_jar(jarfd, dir_to_change, file_to_add)){
|
||||
printf("Error adding %s to jar archive!\n", arg);
|
||||
if (!dir_to_change || !file_to_add) {
|
||||
fprintf(stderr, "Error: missing argument for -C.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (add_to_jar(jarfd, dir_to_change, file_to_add)) {
|
||||
fprintf(stderr,
|
||||
"Error adding %s (in directory %s) to jar archive!\n",
|
||||
file_to_add, dir_to_change);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
if(add_to_jar(jarfd, NULL, arg)){
|
||||
printf("Error adding %s to jar archive!\n", arg);
|
||||
fprintf(stderr, "Error adding %s to jar archive!\n", arg);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -817,8 +821,8 @@ int add_to_jar(int fd, const char *new_dir, const char *file){
|
||||
struct dirent *de;
|
||||
zipentry *ze;
|
||||
int stat_return;
|
||||
char *old_dir = NULL;
|
||||
|
||||
char old_dir[MAXPATHLEN];
|
||||
|
||||
/* This is a quick compatibility fix -- Simon Weijgers <simon@weijgers.com>
|
||||
* It fixes this:
|
||||
* "normal" jar : org/apache/java/io/LogRecord.class
|
||||
@ -830,10 +834,12 @@ int add_to_jar(int fd, const char *new_dir, const char *file){
|
||||
file+=2;
|
||||
|
||||
/* If new_dir isn't null, we need to change to that directory. However,
|
||||
we also need to return to the old directory when we're done */
|
||||
we also need to return to the old directory when we're done. See below.*/
|
||||
if(new_dir != NULL){
|
||||
old_dir = getcwd(NULL, 0);
|
||||
|
||||
if (getcwd(old_dir, MAXPATHLEN) == NULL) {
|
||||
perror("getcwd");
|
||||
return 1;
|
||||
}
|
||||
if(chdir(new_dir) == -1){
|
||||
perror(new_dir);
|
||||
return 1;
|
||||
@ -957,11 +963,13 @@ int add_to_jar(int fd, const char *new_dir, const char *file){
|
||||
fprintf(stderr, "Illegal file specified: %s\n", file);
|
||||
}
|
||||
|
||||
if(old_dir != NULL){
|
||||
if(chdir(old_dir))
|
||||
/* If (and only if!) new_dir != NULL, we switched directories, so
|
||||
we have to switch back to the old directory. */
|
||||
if (new_dir != NULL) {
|
||||
if (chdir(old_dir) == -1) {
|
||||
perror(old_dir);
|
||||
|
||||
free(old_dir);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user