[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/2] userspec: no need for static vars
From: |
Paul Eggert |
Subject: |
[PATCH 1/2] userspec: no need for static vars |
Date: |
Thu, 24 Feb 2022 17:11:58 -0800 |
* lib/userspec.c (parse_with_separator): Simplify.
---
ChangeLog | 5 +++++
lib/userspec.c | 10 +++-------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9748e5ab50..dda27c7eb9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2022-02-24 Paul Eggert <eggert@cs.ucla.edu>
+
+ userspec: no need for static vars
+ * lib/userspec.c (parse_with_separator): Simplify.
+
2022-02-22 Benno Schulenberg <bensberg@telfort.nl> (tiny change)
doc: add two missing closing parentheses
diff --git a/lib/userspec.c b/lib/userspec.c
index f05ccbe635..e75feb255d 100644
--- a/lib/userspec.c
+++ b/lib/userspec.c
@@ -103,10 +103,6 @@ parse_with_separator (char const *spec, char const
*separator,
uid_t *uid, gid_t *gid,
char **username, char **groupname)
{
- static const char *E_invalid_user = N_("invalid user");
- static const char *E_invalid_group = N_("invalid group");
- static const char *E_bad_spec = N_("invalid spec");
-
const char *error_msg;
struct passwd *pwd;
struct group *grp;
@@ -167,7 +163,7 @@ parse_with_separator (char const *spec, char const
*separator,
{
/* If there is no group,
then there may not be a trailing ":", either. */
- error_msg = E_bad_spec;
+ error_msg = N_("invalid spec");
}
else
{
@@ -176,7 +172,7 @@ parse_with_separator (char const *spec, char const
*separator,
&& tmp <= MAXUID && (uid_t) tmp != (uid_t) -1)
unum = tmp;
else
- error_msg = E_invalid_user;
+ error_msg = N_("invalid user");
}
}
else
@@ -209,7 +205,7 @@ parse_with_separator (char const *spec, char const
*separator,
&& tmp <= MAXGID && (gid_t) tmp != (gid_t) -1)
gnum = tmp;
else
- error_msg = E_invalid_group;
+ error_msg = N_("invalid group");
}
else
gnum = grp->gr_gid;
--
2.35.1
- [PATCH 1/2] userspec: no need for static vars,
Paul Eggert <=