diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2000-05-01 17:40:49 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-05-01 17:40:49 +0000 |
commit | e3aefe8d26ea28583c7b9c8fbe7c1d9e8b526458 (patch) | |
tree | f5006647e3ac3a5d05f05d00e1723eb12728af4b /pp_sys.c | |
parent | 8ebeeb789c7e07e6a4705622485f7c35d66b3eac (diff) | |
download | perl-e3aefe8d26ea28583c7b9c8fbe7c1d9e8b526458.tar.gz |
Rewrite the pwent/spent logic to be a little bit more clearer.
p4raw-id: //depot/cfgperl@6033
Diffstat (limited to 'pp_sys.c')
-rw-r--r-- | pp_sys.c | 46 |
1 files changed, 22 insertions, 24 deletions
@@ -4769,39 +4769,37 @@ PP(pp_gpwent) #ifdef HAS_PASSWD I32 which = PL_op->op_type; register SV *sv; - struct passwd *pwent; STRLEN n_a; -#if defined(HAS_GETSPENT) || defined(HAS_GETSPNAM) - struct spwd *spwent = NULL; + struct passwd *pwent = NULL; +/* We do not use HAS_GETSPENT in pp_gpwent() but leave it here in the case + * somebody wants to write an XS to access the shadow passwords. --jhi */ +#ifdef HAS_GETSPNAM + struct spwd *spwent = NULL; #endif - if (which == OP_GPWNAM) - pwent = getpwnam(POPpx); - else if (which == OP_GPWUID) - pwent = getpwuid(POPi); - else + switch (which) { + case OP_GPWNAM: + pwent = getpwnam(POPpx); +#ifdef HAS_GETSPNAM + if (pwent) + spwent = getspnam(pwent->pw_name); +#endif + break; + case OP_GPWUID: + pwent = getpwuid((Uid_t)POPi); + break; + case OP_GPWENT: #ifdef HAS_GETPWENT - pwent = (struct passwd *)getpwent(); + pwent = getpwent(); #else - DIE(aTHX_ PL_no_func, "getpwent"); + DIE(aTHX_ PL_no_fun, "getpwent"); #endif - #ifdef HAS_GETSPNAM - if (which == OP_GPWNAM) { if (pwent) spwent = getspnam(pwent->pw_name); - } -# ifdef HAS_GETSPUID /* AFAIK there isn't any anywhere. --jhi */ - else if (which == OP_GPWUID) { - if (pwent) - spwent = getspnam(pwent->pw_name); - } -# endif -# ifdef HAS_GETSPENT - else - spwent = (struct spwd *)getspent(); -# endif #endif + break; + } EXTEND(SP, 10); if (GIMME != G_ARRAY) { @@ -4825,7 +4823,7 @@ PP(pp_gpwent) PUSHs(sv = sv_mortalcopy(&PL_sv_no)); #ifdef PWPASSWD -# if defined(HAS_GETSPENT) || defined(HAS_GETSPNAM) +# ifdef HAS_GETSPNAM if (spwent) sv_setpv(sv, spwent->sp_pwdp); else |