#endif
}
+/* I can't const this further without getting warnings about the types of
+ various arrays passed in from structures. */
+static SV *
+S_space_join_names_mortal(pTHX_ char *const *array)
+{
+ SV *target = sv_2mortal(newSVpvs(""));
+
+ if (array && *array) {
+ while (1) {
+ sv_catpv(target, *array);
+ if (!*++array)
+ break;
+ sv_catpvs(target, " ");
+ }
+ }
+ return target;
+}
+
/* Get system info. */
PP(pp_ghostent)
if (hent) {
PUSHs(sv = sv_mortalcopy(&PL_sv_no));
sv_setpv(sv, (char*)hent->h_name);
- PUSHs(sv = sv_mortalcopy(&PL_sv_no));
- for (elem = hent->h_aliases; elem && *elem; elem++) {
- sv_catpv(sv, *elem);
- if (elem[1])
- sv_catpvs(sv, " ");
- }
+ PUSHs(S_space_join_names_mortal(aTHX_ hent->h_aliases));
PUSHs(sv = sv_mortalcopy(&PL_sv_no));
sv_setiv(sv, (IV)hent->h_addrtype);
PUSHs(sv = sv_mortalcopy(&PL_sv_no));
#if defined(HAS_GETNETBYNAME) || defined(HAS_GETNETBYADDR) || defined(HAS_GETNETENT)
dVAR; dSP;
I32 which = PL_op->op_type;
- register char **elem;
register SV *sv;
#ifndef HAS_GETNET_PROTOS /* XXX Do we need individual probes? */
struct netent *getnetbyaddr(Netdb_net_t, int);
if (nent) {
PUSHs(sv = sv_mortalcopy(&PL_sv_no));
sv_setpv(sv, nent->n_name);
- PUSHs(sv = sv_mortalcopy(&PL_sv_no));
- for (elem = nent->n_aliases; elem && *elem; elem++) {
- sv_catpv(sv, *elem);
- if (elem[1])
- sv_catpvs(sv, " ");
- }
+ PUSHs(S_space_join_names_mortal(aTHX_ nent->n_aliases));
PUSHs(sv = sv_mortalcopy(&PL_sv_no));
sv_setiv(sv, (IV)nent->n_addrtype);
PUSHs(sv = sv_mortalcopy(&PL_sv_no));
#if defined(HAS_GETPROTOBYNAME) || defined(HAS_GETPROTOBYNUMBER) || defined(HAS_GETPROTOENT)
dVAR; dSP;
I32 which = PL_op->op_type;
- register char **elem;
register SV *sv;
#ifndef HAS_GETPROTO_PROTOS /* XXX Do we need individual probes? */
struct protoent *getprotobyname(Netdb_name_t);
if (pent) {
PUSHs(sv = sv_mortalcopy(&PL_sv_no));
sv_setpv(sv, pent->p_name);
- PUSHs(sv = sv_mortalcopy(&PL_sv_no));
- for (elem = pent->p_aliases; elem && *elem; elem++) {
- sv_catpv(sv, *elem);
- if (elem[1])
- sv_catpvs(sv, " ");
- }
+ PUSHs(S_space_join_names_mortal(aTHX_ pent->p_aliases));
PUSHs(sv = sv_mortalcopy(&PL_sv_no));
sv_setiv(sv, (IV)pent->p_proto);
}
#if defined(HAS_GETSERVBYNAME) || defined(HAS_GETSERVBYPORT) || defined(HAS_GETSERVENT)
dVAR; dSP;
I32 which = PL_op->op_type;
- register char **elem;
register SV *sv;
#ifndef HAS_GETSERV_PROTOS /* XXX Do we need individual probes? */
struct servent *getservbyname(Netdb_name_t, Netdb_name_t);
if (sent) {
PUSHs(sv = sv_mortalcopy(&PL_sv_no));
sv_setpv(sv, sent->s_name);
- PUSHs(sv = sv_mortalcopy(&PL_sv_no));
- for (elem = sent->s_aliases; elem && *elem; elem++) {
- sv_catpv(sv, *elem);
- if (elem[1])
- sv_catpvs(sv, " ");
- }
+ PUSHs(S_space_join_names_mortal(aTHX_ sent->s_aliases));
PUSHs(sv = sv_mortalcopy(&PL_sv_no));
#ifdef HAS_NTOHS
sv_setiv(sv, (IV)PerlSock_ntohs(sent->s_port));
if (grent) {
SV *sv;
- char **elem;
PUSHs(sv = sv_mortalcopy(&PL_sv_no));
sv_setpv(sv, grent->gr_name);
sv_setiv(sv, (IV)grent->gr_gid);
#if !(defined(_CRAYMPP) && defined(USE_REENTRANT_API))
- PUSHs(sv = sv_mortalcopy(&PL_sv_no));
/* In UNICOS/mk (_CRAYMPP) the multithreading
* versions (getgrnam_r, getgrgid_r)
* seem to return an illegal pointer
* but the gr_mem is poisonous anyway.
* So yes, you cannot get the list of group
* members if building multithreaded in UNICOS/mk. */
- for (elem = grent->gr_mem; elem && *elem; elem++) {
- sv_catpv(sv, *elem);
- if (elem[1])
- sv_catpvs(sv, " ");
- }
+ PUSHs(S_space_join_names_mortal(aTHX_ grent->gr_mem));
#endif
}