From c29ce7be615461066fa411d9097eaf75d435af68 Mon Sep 17 00:00:00 2001 From: Lyonel Vincent Date: Sun, 25 Nov 2012 17:23:39 +0100 Subject: [PATCH] do not complain when negating selection if we can't find a user/group --- ps/parser.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ps/parser.c b/ps/parser.c index 0fc28d23..6e6df517 100644 --- a/ps/parser.c +++ b/ps/parser.c @@ -95,10 +95,14 @@ static const char *parse_uid(char *str, sel_union *ret){ num = strtoul(str, &endp, 0); if(*endp != '\0'){ /* hmmm, try as login name */ passwd_data = getpwnam(str); - if(!passwd_data) return _("user name does not exist"); - num = passwd_data->pw_uid; + if(!passwd_data){ + if(!negate_selection) return _("user name does not exist"); + num = -1; + } + else + num = passwd_data->pw_uid; } - if(num > 0xfffffffeUL) return _("user ID out of range"); + if(!negate_selection && (num > 0xfffffffeUL)) return _("user ID out of range"); ret->uid = num; return 0; } @@ -110,10 +114,14 @@ static const char *parse_gid(char *str, sel_union *ret){ num = strtoul(str, &endp, 0); if(*endp != '\0'){ /* hmmm, try as login name */ group_data = getgrnam(str); - if(!group_data) return _("group name does not exist"); - num = group_data->gr_gid; + if(!group_data){ + if(!negate_selection) return _("group name does not exist"); + num = -1; + } + else + num = group_data->gr_gid; } - if(num > 0xfffffffeUL) return _("group ID out of range"); + if(!negate_selection && (num > 0xfffffffeUL)) return _("group ID out of range"); ret->gid = num; return 0; }