diff options
author | Larry Wall <lwall@netlabs.com> | 1991-11-11 03:50:16 +0000 |
---|---|---|
committer | Larry Wall <lwall@netlabs.com> | 1991-11-11 03:50:16 +0000 |
commit | 988174c19bcf26f6c6e0551f1dfbba78203bc2ce (patch) | |
tree | 7918e82dffc7e46c520ab9fafb727f369b32e8d9 /util.c | |
parent | 55204971972392ce5a252fbbd6d78b1c48ed70e3 (diff) | |
download | perl-988174c19bcf26f6c6e0551f1dfbba78203bc2ce.tar.gz |
perl 4.0 patch 19: (combined patch)
Ok, here's the cleanup patch I suggested you wait for. Have at it...
Subject: added little-endian pack/unpack options
This is the only enhancement in this patch, but it seemed unlikely
to bust anything else, and added functionality that it was very
difficult to do any other way. Compliments of David W. Sanderson.
Subject: op/regexp.t failed from missing arg to bcmp()
Subject: study was busted by 4.018
Subject: sort $subname was busted by changes in 4.018
Subject: default arg for shift was wrong after first subroutine definition
Things that broke in 4.018. Shame on me.
Subject: do {$foo ne "bar";} returned wrong value
A bug of long standing. How come nobody saw this one? Or if you
did, why didn't you report it before now? Or if you did, why did
I ignore you? :-)
Subject: some machines need -lsocket before -lnsl
Subject: some earlier patches weren't propagated to alternate 286 code
Subject: compile in the x2p directory couldn't find cppstdin
Subject: more hints for aix, isc, hp, sco, uts
Subject: installperl no longer updates unchanged library files
Subject: uts wrongly defines S_ISDIR() et al
Subject: too many preprocessors can't expand a macro right in #if
The usual pastiche of portability kludges.
Subject: deleted some unused functions from usersub.c
And fixed the spelling of John Macdonald's name, and included his
suggested workaround for a certain vendor's stdio bug...
Subject: added readdir test
Subject: made op/groups.t more reliable
Subject: added test for sort $subname to op/sort.t
Subject: added some hacks to op/stat.t for weird filesystem architectures
Improvements (hopefully) to the regression tests.
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 103 |
1 files changed, 79 insertions, 24 deletions
@@ -1,4 +1,4 @@ -/* $RCSfile: util.c,v $$Revision: 4.0.1.3 $$Date: 91/11/05 19:18:26 $ +/* $RCSfile: util.c,v $$Revision: 4.0.1.4 $$Date: 91/11/11 16:48:54 $ * * Copyright (c) 1991, Larry Wall * @@ -6,6 +6,10 @@ * License or the Artistic License, as specified in the README file. * * $Log: util.c,v $ + * Revision 4.0.1.4 91/11/11 16:48:54 lwall + * patch19: study was busted by 4.018 + * patch19: added little-endian pack/unpack options + * * Revision 4.0.1.3 91/11/05 19:18:26 lwall * patch11: safe malloc code now integrated into Perl's malloc when possible * patch11: index("little", "longer string") could visit faraway places @@ -685,12 +689,8 @@ STR *littlestr; #ifdef POINTERRIGOR if (littlestr->str_pok & SP_CASEFOLD) { /* case insignificant? */ do { -#ifndef lint - while (big[pos-previous] != first && big[pos-previous] != fold[first] - && (pos += screamnext[pos]) ) - /*SUPPRESS 530*/ - ; -#endif + if (big[pos-previous] != first && big[pos-previous] != fold[first]) + continue; for (x=big+pos+1-previous,s=little; s < littleend; /**/ ) { if (x >= bigend) return Nullch; @@ -715,11 +715,8 @@ STR *littlestr; } else { do { -#ifndef lint - while (big[pos-previous] != first && (pos += screamnext[pos])) - /*SUPPRESS 530*/ - ; -#endif + if (big[pos-previous] != first) + continue; for (x=big+pos+1-previous,s=little; s < littleend; /**/ ) { if (x >= bigend) return Nullch; @@ -746,12 +743,8 @@ STR *littlestr; big -= previous; if (littlestr->str_pok & SP_CASEFOLD) { /* case insignificant? */ do { -#ifndef lint - while (big[pos] != first && big[pos] != fold[first] - && (pos += screamnext[pos]) ) - /*SUPPRESS 530*/ - ; -#endif + if (big[pos] != first && big[pos] != fold[first]) + continue; for (x=big+pos+1,s=little; s < littleend; /**/ ) { if (x >= bigend) return Nullch; @@ -776,11 +769,8 @@ STR *littlestr; } else { do { -#ifndef lint - while (big[pos] != first && (pos += screamnext[pos])) - /*SUPPRESS 530*/ - ; -#endif + if (big[pos] != first) + continue; for (x=big+pos+1,s=little; s < littleend; /**/ ) { if (x >= bigend) return Nullch; @@ -1236,6 +1226,14 @@ char *pat, *args; #endif /* HAS_VPRINTF */ #endif /* I_VARARGS */ +/* + * I think my_swap(), htonl() and ntohl() have never been used. + * perl.h contains last-chance references to my_swap(), my_htonl() + * and my_ntohl(). I presume these are the intended functions; + * but htonl() and ntohl() have the wrong names. There are no + * functions my_htonl() and my_ntohl() defined anywhere. + * -DWS + */ #ifdef MYSWAP #if BYTEORDER != 0x4321 short @@ -1315,7 +1313,64 @@ register long l; } #endif /* BYTEORDER != 0x4321 */ -#endif /* HAS_HTONS */ +#endif /* MYSWAP */ + +/* + * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'. + * If these functions are defined, + * the BYTEORDER is neither 0x1234 nor 0x4321. + * However, this is not assumed. + * -DWS + */ + +#define HTOV(name,type) \ + type \ + name (n) \ + register type n; \ + { \ + union { \ + type value; \ + char c[sizeof(type)]; \ + } u; \ + register int i; \ + register int s; \ + for (i = 0, s = 0; i < sizeof(u.c); i++, s += 8) { \ + u.c[i] = (n >> s) & 0xFF; \ + } \ + return u.value; \ + } + +#define VTOH(name,type) \ + type \ + name (n) \ + register type n; \ + { \ + union { \ + type value; \ + char c[sizeof(type)]; \ + } u; \ + register int i; \ + register int s; \ + u.value = n; \ + n = 0; \ + for (i = 0, s = 0; i < sizeof(u.c); i++, s += 8) { \ + n += (u.c[i] & 0xFF) << s; \ + } \ + return n; \ + } + +#if defined(HAS_HTOVS) && !defined(htovs) +HTOV(htovs,short) +#endif +#if defined(HAS_HTOVL) && !defined(htovl) +HTOV(htovl,long) +#endif +#if defined(HAS_VTOHS) && !defined(vtohs) +VTOH(vtohs,short) +#endif +#if defined(HAS_VTOHL) && !defined(vtohl) +VTOH(vtohl,long) +#endif #ifndef MSDOS FILE * |