Change calls to error_msg.* and strerror to use perror_msg.*.

This commit is contained in:
Matt Kraai
2000-12-18 03:57:16 +00:00
parent 0dab829977
commit 1fa1adea2a
52 changed files with 185 additions and 204 deletions

View File

@@ -38,7 +38,7 @@ int chroot_main(int argc, char **argv)
argv++;
if (chroot(*argv) || (chdir("/"))) {
error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno));
perror_msg_and_die("cannot change root directory to %s", *argv);
}
argc--;
@@ -57,7 +57,7 @@ int chroot_main(int argc, char **argv)
return EXIT_SUCCESS;
#endif
}
error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno));
perror_msg_and_die("cannot execute %s", prog);
}

View File

@@ -234,7 +234,7 @@ extern int cut_main(int argc, char **argv)
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
error_msg("%s: %s\n", argv[i], strerror(errno));
perror_msg("%s", argv[i]);
} else {
cut_file(file);
fclose(file);

View File

@@ -80,7 +80,7 @@ int head_main(int argc, char **argv)
}
head(len, fp);
if (errno) {
error_msg("%s: %s\n", argv[optind], strerror(errno));
perror_msg("%s", argv[optind]);
status = EXIT_FAILURE;
errno = 0;
}

View File

@@ -181,7 +181,7 @@ static int my_stat(struct dnode *cur)
#ifdef BB_FEATURE_LS_FOLLOWLINKS
if (follow_links == TRUE) {
if (stat(cur->fullname, &cur->dstat)) {
error_msg("%s: %s\n", cur->fullname, strerror(errno));
perror_msg("%s", cur->fullname);
status = EXIT_FAILURE;
free(cur->fullname);
free(cur);
@@ -190,7 +190,7 @@ static int my_stat(struct dnode *cur)
} else
#endif
if (lstat(cur->fullname, &cur->dstat)) {
error_msg("%s: %s\n", cur->fullname, strerror(errno));
perror_msg("%s", cur->fullname);
status = EXIT_FAILURE;
free(cur->fullname);
free(cur);
@@ -511,7 +511,7 @@ struct dnode **list_dir(char *path)
nfiles= 0;
dir = opendir(path);
if (dir == NULL) {
error_msg("%s: %s\n", path, strerror(errno));
perror_msg("%s", path);
status = EXIT_FAILURE;
return(NULL); /* could not open the dir */
}

View File

@@ -651,13 +651,13 @@ static int md5_file(const char *filename,
} else {
fp = fopen(filename, OPENOPTS(binary));
if (fp == NULL) {
error_msg("%s: %s\n", filename, strerror(errno));
perror_msg("%s", filename);
return FALSE;
}
}
if (md5_stream(fp, md5_result)) {
error_msg("%s: %s\n", filename, strerror(errno));
perror_msg("%s", filename);
if (fp != stdin)
fclose(fp);
@@ -665,7 +665,7 @@ static int md5_file(const char *filename,
}
if (fp != stdin && fclose(fp) == EOF) {
error_msg("%s: %s\n", filename, strerror(errno));
perror_msg("%s", filename);
return FALSE;
}
@@ -689,7 +689,7 @@ static int md5_check(const char *checkfile_name)
} else {
checkfile_stream = fopen(checkfile_name, "r");
if (checkfile_stream == NULL) {
error_msg("%s: %s\n", checkfile_name, strerror(errno));
perror_msg("%s", checkfile_name);
return FALSE;
}
}
@@ -775,7 +775,7 @@ static int md5_check(const char *checkfile_name)
}
if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
error_msg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
perror_msg("md5sum: %s", checkfile_name);
return FALSE;
}

View File

@@ -31,8 +31,8 @@ extern int pwd_main(int argc, char **argv)
char buf[BUFSIZ + 1];
if (getcwd(buf, sizeof(buf)) == NULL)
error_msg_and_die("%s\n", strerror(errno));
perror_msg_and_die("getcwd");
printf("%s\n", buf);
puts(buf);
return EXIT_SUCCESS;
}

View File

@@ -47,7 +47,7 @@ tee_main(int argc, char **argv)
while (optind < argc) {
if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
nfiles--;
error_msg("%s: %s\n", argv[optind-1], strerror(errno));
perror_msg("%s", argv[optind-1]);
status = 1;
}
}

View File

@@ -257,7 +257,7 @@ static int decode (const char *inname,
&& (freopen (outname, "w", stdout) == NULL
|| chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
)) {
error_msg("%s: %s %s\n", outname, inname, strerror(errno)); /* */
perror_msg("%s", outname); /* */
return FALSE;
}
@@ -302,7 +302,7 @@ int uudecode_main (int argc,
if (decode (argv[optind], outname) != 0)
exit_status = FALSE;
} else {
error_msg("%s: %s\n", argv[optind], strerror(errno));
perror_msg("%s", argv[optind]);
exit_status = EXIT_FAILURE;
}
optind++;

View File

@@ -160,15 +160,12 @@ int uuencode_main (int argc,
trans_ptr = uu_std; /* Standard encoding is old uu format */
/* Parse any options */
while ((opt = getopt (argc, argv, "m")) != EOF) {
while ((opt = getopt (argc, argv, "m")) > 0) {
switch (opt) {
case 'm':
trans_ptr = uu_base64;
break;
case 0:
break;
default:
usage(uuencode_usage);
}
@@ -178,7 +175,7 @@ int uuencode_main (int argc,
case 2:
/* Optional first argument is input file. */
if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
error_msg("%s: %s\n", argv[optind], strerror(errno));
perror_msg("%s", argv[optind]);
return EXIT_FAILURE;
}
mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);