mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 01:31:08 +00:00
bugfix for byte swapping
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37196 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8276ff4171
commit
d86cd7382b
2 changed files with 7 additions and 25 deletions
|
@ -1,3 +1,7 @@
|
|||
2013-10-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSTimeZone.m: Fix bug with byte swapping ... use NSByteOrder.h
|
||||
|
||||
2013-10-01 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* config/config.align.c: Try to more reliably detect whether word
|
||||
|
|
|
@ -296,30 +296,6 @@ static NSRecursiveLock *zone_mutex = nil;
|
|||
static Class NSTimeZoneClass;
|
||||
static Class GSPlaceholderTimeZoneClass;
|
||||
|
||||
/* Decode the four bytes at PTR as a signed integer in network byte order.
|
||||
Based on code included in the GNU C Library 2.0.3. */
|
||||
static inline int
|
||||
decode (const void *ptr)
|
||||
{
|
||||
#if defined(WORDS_BIGENDIAN) && SIZEOF_INT == 4
|
||||
#if NEED_WORD_ALIGNMENT
|
||||
int value;
|
||||
memcpy(&value, ptr, sizeof(NSInteger));
|
||||
return value;
|
||||
#else
|
||||
return *(const NSInteger*) ptr;
|
||||
#endif
|
||||
#else /* defined(WORDS_BIGENDIAN) && SIZEOF_INT == 4 */
|
||||
const unsigned char *p = ptr;
|
||||
int result = *p & (1 << (CHAR_BIT - 1)) ? ~0 : 0;
|
||||
|
||||
result = (result << 8) | *p++;
|
||||
result = (result << 8) | *p++;
|
||||
result = (result << 8) | *p++;
|
||||
result = (result << 8) | *p;
|
||||
return result;
|
||||
#endif /* defined(WORDS_BIGENDIAN) && SIZEOF_INT == 4 */
|
||||
}
|
||||
|
||||
/* Return path to a TimeZone directory file */
|
||||
static NSString *_time_zone_path(NSString *subpath, NSString *type)
|
||||
|
@ -3113,10 +3089,12 @@ newDetailInZoneForType(GSTimeZone *zone, TypeInfo *type)
|
|||
for (i = 0; i < n_types; i++)
|
||||
{
|
||||
struct ttinfo *ptr = (struct ttinfo*)(bytes + pos);
|
||||
uint32_t off;
|
||||
|
||||
types[i].isdst = (ptr->isdst != 0 ? YES : NO);
|
||||
types[i].abbr_idx = ptr->abbr_idx;
|
||||
types[i].offset = decode(ptr->offset);
|
||||
memcpy(&off, ptr->offset, 4);
|
||||
types[i].offset = GSSwapBigI32ToHost(off);
|
||||
pos += sizeof(struct ttinfo);
|
||||
}
|
||||
abbr = (unsigned char*)(bytes + pos);
|
||||
|
|
Loading…
Reference in a new issue