1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-08-05 16:19:23 +02:00

Convert "`%s'" in format strings to "%s", and wrap each

corresponding argument in a `quote (...)' call.
Add more precise diagnostics.
This commit is contained in:
Jim Meyering
2000-07-30 16:16:16 +00:00
parent d4365673c5
commit b53d6da640
3 changed files with 33 additions and 24 deletions
+14 -11
View File
@@ -27,6 +27,7 @@
#include "error.h"
#include "lchown.h"
#include "group-member.h"
#include "quote.h"
#include "savedir.h"
#include "xstrtol.h"
@@ -137,7 +138,7 @@ describe_change (const char *file, enum Change_status changed)
if (changed == CH_NOT_APPLIED)
{
printf (_("neither symbolic link %s nor referent has been changed\n"),
file);
quote (file));
return;
}
@@ -155,7 +156,7 @@ describe_change (const char *file, enum Change_status changed)
default:
abort ();
}
printf (fmt, file, groupname);
printf (fmt, quote (file), groupname);
}
/* Set *G according to NAME. */
@@ -176,14 +177,14 @@ parse_group (const char *name, gid_t *g)
unsigned long int tmp_long;
if (!ISDIGIT (*name))
error (1, 0, _("invalid group name `%s'"), name);
error (1, 0, _("invalid group name %s"), quote (name));
s_err = xstrtoul (name, NULL, 0, &tmp_long, NULL);
if (s_err != LONGINT_OK)
STRTOL_FATAL_ERROR (name, _("group number"), s_err);
if (tmp_long > MAXGID)
error (1, 0, _("invalid group number `%s'"), name);
error (1, 0, _("invalid group number %s"), quote (name));
*g = tmp_long;
}
@@ -205,7 +206,7 @@ change_file_group (int cmdline_arg, const char *file, gid_t group)
if ((*xstat) (file, &file_stats))
{
if (force_silent == 0)
error (0, errno, "%s", file);
error (0, errno, _("getting attributes of %s"), quote (file));
return 1;
}
@@ -252,16 +253,18 @@ change_file_group (int cmdline_arg, const char *file, gid_t group)
of the specified group' errors. */
if (saved_errno == EPERM && !group_member (group))
{
error (0, saved_errno, _("you are not a member of group `%s'"),
groupname);
error (0, saved_errno, _("you are not a member of group %s"),
quote (groupname));
}
else if (saved_errno == EINVAL && group > MAXUID)
{
error (0, 0, _("%s: invalid group number"), groupname);
error (0, 0, _("%s: invalid group number"),
quote (groupname));
}
else
{
error (0, saved_errno, "%s", file);
error (0, saved_errno, _("changing group of %s"),
quote (file));
}
}
}
@@ -296,7 +299,7 @@ change_dir_group (const char *dir, gid_t group, const struct stat *statp)
if (name_space == NULL)
{
if (force_silent == 0)
error (0, errno, "%s", dir);
error (0, errno, "%s", quote (dir));
return 1;
}
@@ -423,7 +426,7 @@ main (int argc, char **argv)
{
struct stat ref_stats;
if (stat (reference_file, &ref_stats))
error (1, errno, "%s", reference_file);
error (1, errno, _("getting attributes of %s"), quote (reference_file));
group = ref_stats.st_gid;
}
+9 -6
View File
@@ -26,6 +26,7 @@
#include "error.h"
#include "filemode.h"
#include "modechange.h"
#include "quote.h"
#include "savedir.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -120,7 +121,8 @@ describe_change (const char *file, mode_t mode,
default:
abort ();
}
printf (fmt, file, (unsigned long) (mode & CHMOD_MODE_BITS), &perms[1]);
printf (fmt, quote (file),
(unsigned long) (mode & CHMOD_MODE_BITS), &perms[1]);
}
/* Change the mode of FILE according to the list of operations CHANGES.
@@ -139,7 +141,7 @@ change_file_mode (const char *file, const struct mode_change *changes,
if (lstat (file, &file_stats))
{
if (force_silent == 0)
error (0, errno, "%s", file);
error (0, errno, _("getting attributes of %s"), quote (file));
return 1;
}
#ifdef S_ISLNK
@@ -151,7 +153,7 @@ change_file_mode (const char *file, const struct mode_change *changes,
if (stat (file, &file_stats))
{
if (force_silent == 0)
error (0, errno, "%s", file);
error (0, errno, _("getting attributes of %s"), quote (file));
return 1;
}
}
@@ -170,7 +172,8 @@ change_file_mode (const char *file, const struct mode_change *changes,
if (fail)
{
if (force_silent == 0)
error (0, saved_errno, "%s", file);
error (0, saved_errno, _("changing permissions of %s"),
quote (file));
errors = 1;
}
}
@@ -202,7 +205,7 @@ change_dir_mode (const char *dir, const struct mode_change *changes,
if (name_space == NULL)
{
if (force_silent == 0)
error (0, errno, "%s", dir);
error (0, errno, "%s", quote (dir));
return 1;
}
@@ -352,7 +355,7 @@ main (int argc, char **argv)
else if (changes == MODE_MEMORY_EXHAUSTED)
error (1, 0, _("virtual memory exhausted"));
else if (changes == MODE_BAD_REFERENCE)
error (1, errno, "%s", reference_file);
error (1, errno, _("getting attributes of %s"), quote (reference_file));
for (; optind < argc; ++optind)
{
+10 -7
View File
@@ -38,6 +38,7 @@
#include "system.h"
#include "error.h"
#include "lchown.h"
#include "quote.h"
#include "savedir.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -144,7 +145,7 @@ describe_change (const char *file, enum Change_status changed)
if (changed == CH_NOT_APPLIED)
{
printf (_("neither symbolic link %s nor referent has been changed\n"),
file);
quote (file));
return;
}
@@ -186,7 +187,7 @@ change_file_owner (int cmdline_arg, const char *file, uid_t user, gid_t group,
if (lstat (file, &file_stats))
{
if (force_silent == 0)
error (0, errno, "%s", file);
error (0, errno, _("getting attributes of %s"), quote (file));
return 1;
}
@@ -231,7 +232,8 @@ change_file_owner (int cmdline_arg, const char *file, uid_t user, gid_t group,
if (fail)
{
if (force_silent == 0)
error (0, saved_errno, "%s", file);
error (0, saved_errno, _("changing ownership of %s"),
quote (file));
errors = 1;
}
}
@@ -268,7 +270,7 @@ change_dir_owner (const char *dir, uid_t user, gid_t group,
if (name_space == NULL)
{
if (force_silent == 0)
error (0, errno, "%s", dir);
error (0, errno, "%s", quote (dir));
return 1;
}
@@ -375,10 +377,11 @@ main (int argc, char **argv)
case FROM_OPTION:
{
char *u_dummy, *g_dummy;
const char *e = parse_user_spec (argv[optind], &old_user, &old_group,
const char *e = parse_user_spec (argv[optind],
&old_user, &old_group,
&u_dummy, &g_dummy);
if (e)
error (1, 0, "%s: %s", argv[optind], e);
error (1, 0, "%s: %s", quote (argv[optind]), e);
break;
}
case 'R':
@@ -414,7 +417,7 @@ main (int argc, char **argv)
struct stat ref_stats;
if (stat (reference_file, &ref_stats))
error (1, errno, "%s", reference_file);
error (1, errno, _("getting attributes of %s"), quote (reference_file));
user = ref_stats.st_uid;
group = ref_stats.st_gid;