Added comment explaining why we are using a different algorithm than
what was adopted in tzcode95c to solve the problem of the first char detzcode() extracts requiring sign extention (this is needed for machines with 64 bit longs). Our implementation is a bit more efficent, but requires a new macro, SIGN_EXTEND_CHAR(), and a conditional to set it appropriately). One minor enhancement for machines without ANSI compilers that have 32 bit longs would be to define SIGN_EXTEND_CHAR() to be the identity macro.
This commit is contained in:
parent
15642dad87
commit
3924aee202
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: localtime.c,v 1.3 1995/03/10 05:57:35 jtc Exp $ */
|
||||
/* $NetBSD: localtime.c,v 1.4 1995/03/16 19:14:16 jtc Exp $ */
|
||||
|
||||
#ifndef lint
|
||||
#ifndef NOID
|
||||
@ -191,7 +191,20 @@ const char * const codep;
|
||||
{
|
||||
register long result;
|
||||
|
||||
result = (codep[0] << 24) \
|
||||
/*
|
||||
** The first character must be sign extended on systems with >32bit
|
||||
** longs. This was solved differently in the master tzcode sources
|
||||
** (the fix first appeared in tzcode95c.tar.gz). But I believe
|
||||
** that this implementation is superior.
|
||||
*/
|
||||
|
||||
#ifdef __STDC__
|
||||
#define SIGN_EXTEND_CHAR(x) ((signed char) x)
|
||||
#else
|
||||
#define SIGN_EXTEND_CHAR(x) ((x & 0x80) ? ((~0 << 8) | x) : x)
|
||||
#endif
|
||||
|
||||
result = (SIGN_EXTEND_CHAR(codep[0]) << 24) \
|
||||
| (codep[1] & 0xff) << 16 \
|
||||
| (codep[2] & 0xff) << 8
|
||||
| (codep[3] & 0xff);
|
||||
|
Loading…
Reference in New Issue
Block a user