commit libplist for openSUSE:Factory
Hello community, here is the log from the commit of package libplist for openSUSE:Factory checked in at Mon May 31 00:48:43 CEST 2010. -------- --- libplist/libplist.changes 2010-04-01 00:18:54.000000000 +0200 +++ /mounts/work_src_done/STABLE/libplist/libplist.changes 2010-04-27 12:47:15.000000000 +0200 @@ -1,0 +2,9 @@ +Tue Apr 27 11:20:20 CEST 2010 - opensuse@sukimashita.com + +- Update to version 1.3 + * Endianness, alignment and type-punning fixes + * Fix armel floating point endianess + * Allow compiling with mingw on Windows + * Minor bugfixes + +------------------------------------------------------------------- calling whatdependson for head-i586 Old: ---- libplist-1.2.tar.bz2 New: ---- libplist-1.3.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libplist.spec ++++++ --- /var/tmp/diff_new_pack.KRUmz0/_old 2010-05-31 00:48:30.000000000 +0200 +++ /var/tmp/diff_new_pack.KRUmz0/_new 2010-05-31 00:48:30.000000000 +0200 @@ -1,5 +1,5 @@ # -# spec file for package libplist (Version 1.2) +# spec file for package libplist (Version 1.3) # # Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany. # @@ -18,8 +18,8 @@ Name: libplist -Version: 1.2 -Release: 2 +Version: 1.3 +Release: 1 License: LGPL v2.1 or GPL v2 Summary: Library for handling Apple Binary and XML Property Lists Url: http://github.com/JonathanBeck/libplist ++++++ libplist-1.2.tar.bz2 -> libplist-1.3.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplist-1.2/CMakeLists.txt new/libplist-1.3/CMakeLists.txt --- old/libplist-1.2/CMakeLists.txt 2010-01-21 21:45:01.000000000 +0100 +++ new/libplist-1.3/CMakeLists.txt 2010-04-18 15:30:19.000000000 +0200 @@ -1,7 +1,7 @@ PROJECT( libplist ) SET( LIBPLIST_VERSION_MAJOR "1" ) -SET( LIBPLIST_VERSION_MINOR "2" ) +SET( LIBPLIST_VERSION_MINOR "3" ) SET( LIBPLIST_SOVERSION "1" ) SET( LIBPLIST_VERSION "${LIBPLIST_VERSION_MAJOR}.${LIBPLIST_VERSION_MINOR}" ) SET( LIBPLIST_LIBVERSION "${LIBPLIST_SOVERSION}.${LIBPLIST_VERSION}" ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplist-1.2/README new/libplist-1.3/README --- old/libplist-1.2/README 2010-01-21 21:45:01.000000000 +0100 +++ new/libplist-1.3/README 2010-04-18 15:30:19.000000000 +0200 @@ -29,18 +29,18 @@ == Who/what/where? == -wiki: - http://matt.colyer.name/projects/iphone-linux/index.php?title=Main_Page +Home: + http://www.libimobiledevice.org/ -code: +Code: git clone git://github.com/JonathanBeck/libplist.git -tickets: - http://libiphone.lighthouseapp.com/projects/27916-libiphone/tickets?q=all +Tickets: + http://libiphone.lighthouseapp.com/ Please tag libplist related bugs with 'libplist' -mailing list: - http://lists.mattcolyer.com/listinfo.cgi/iphone-linux-dev-mattcolyer.com +Mailing List: + http://lists.libimobiledevice.org/mailman/listinfo/libimobiledevice-devel updated: - 2009-03-27 + 2010-04-18 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplist-1.2/doxygen.cfg new/libplist-1.3/doxygen.cfg --- old/libplist-1.2/doxygen.cfg 2010-01-21 21:45:01.000000000 +0100 +++ new/libplist-1.3/doxygen.cfg 2010-04-18 15:30:19.000000000 +0200 @@ -31,7 +31,7 @@ # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 1.2 +PROJECT_NUMBER = 1.3 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplist-1.2/include/plist/Date.h new/libplist-1.3/include/plist/Date.h --- old/libplist-1.2/include/plist/Date.h 2010-01-21 21:45:01.000000000 +0100 +++ new/libplist-1.3/include/plist/Date.h 2010-04-18 15:30:19.000000000 +0200 @@ -25,7 +25,7 @@ #include <plist/Node.h> #include <ctime> -#ifdef _MSC_VER +#ifdef _WIN32 #include <Winsock2.h> #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplist-1.2/src/bplist.c new/libplist-1.3/src/bplist.c --- old/libplist-1.2/src/bplist.c 2010-01-21 21:45:01.000000000 +0100 +++ new/libplist-1.3/src/bplist.c 2010-04-18 15:30:19.000000000 +0200 @@ -63,6 +63,40 @@ BPLIST_MASK = 0xF0 }; +static void float_byte_convert(uint8_t * address, size_t size) +{ +#if G_BYTE_ORDER == G_LITTLE_ENDIAN && !defined (__VFP_FP__) + uint8_t i = 0, j = 0; + uint8_t tmp = 0; + + for (i = 0; i < (size / 2); i++) + { + tmp = address[i]; + j = ((size - 1) + 0) - i; + address[i] = address[j]; + address[j] = tmp; + } +#endif +} + +union plist_uint_ptr +{ + void *src; + uint8_t *u8ptr; + uint16_t *u16ptr; + uint32_t *u32ptr; + uint64_t *u64ptr; +}; + +#define get_unaligned(ptr) \ + ({ \ + struct __attribute__((packed)) { \ + typeof(*(ptr)) __v; \ + } *__p = (void *) (ptr); \ + __p->__v; \ + }) + + static void byte_convert(uint8_t * address, size_t size) { #if G_BYTE_ORDER == G_LITTLE_ENDIAN @@ -79,23 +113,36 @@ #endif } -static uint32_t uint24_from_be(char *buff) +static uint32_t uint24_from_be(union plist_uint_ptr buf) { + union plist_uint_ptr tmp; uint32_t ret = 0; - uint8_t *tmp = (uint8_t *) &ret; - memcpy(tmp + 1, buff, 3 * sizeof(char)); - byte_convert(tmp, sizeof(uint32_t)); + + tmp.src = &ret; + + memcpy(tmp.u8ptr + 1, buf.u8ptr, 3 * sizeof(char)); + + byte_convert(tmp.u8ptr, sizeof(uint32_t)); return ret; } #define UINT_TO_HOST(x, n) \ - (n == 8 ? GUINT64_FROM_BE( *(uint64_t *)(x) ) : \ - (n == 4 ? GUINT32_FROM_BE( *(uint32_t *)(x) ) : \ - (n == 3 ? uint24_from_be( (char*)x ) : \ - (n == 2 ? GUINT16_FROM_BE( *(uint16_t *)(x) ) : \ - *(uint8_t *)(x) )))) - -#define be64dec(x) GUINT64_FROM_BE( *(uint64_t*)(x) ) + ({ \ + union plist_uint_ptr __up; \ + __up.src = x; \ + (n == 8 ? GUINT64_FROM_BE( get_unaligned(__up.u64ptr) ) : \ + (n == 4 ? GUINT32_FROM_BE( get_unaligned(__up.u32ptr) ) : \ + (n == 3 ? uint24_from_be( __up ) : \ + (n == 2 ? GUINT16_FROM_BE( get_unaligned(__up.u16ptr) ) : \ + *__up.u8ptr )))); \ + }) + +#define be64dec(x) \ + ({ \ + union plist_uint_ptr __up; \ + __up.src = x; \ + GUINT64_FROM_BE( get_unaligned(__up.u64ptr) ); \ + }) #define get_needed_bytes(x) \ ( ((uint64_t)x) < (1ULL << 8) ? 1 : \ @@ -136,23 +183,27 @@ { plist_data_t data = plist_new_plist_data(); float floatval = 0.0; + uint8_t* buf; size = 1 << size; // make length less misleading + buf = malloc (size); + memcpy (buf, bnode, size); switch (size) { case sizeof(float): - floatval = *(float *) bnode; - byte_convert((uint8_t *) & floatval, sizeof(float)); + float_byte_convert(buf, size); + floatval = *(float *) buf; data->realval = floatval; break; case sizeof(double): - data->realval = *(double *) bnode; - byte_convert((uint8_t *) & (data->realval), sizeof(double)); + float_byte_convert(buf, size); + data->realval = *(double *) buf; break; default: free(data); return NULL; } + free (buf); data->type = PLIST_REAL; data->length = sizeof(double); @@ -626,6 +677,11 @@ //do not write 3bytes int node if (size == 3) size++; + +#if G_BYTE_ORDER == G_BIG_ENDIAN + val = val << ((sizeof(uint64_t) - size) * 8); +#endif + buff = (uint8_t *) malloc(sizeof(uint8_t) + size); buff[0] = BPLIST_UINT | Log2(size); memcpy(buff + 1, &val, size); @@ -636,7 +692,7 @@ static void write_real(GByteArray * bplist, double val) { - uint64_t size = get_real_bytes(*((uint64_t *) & val)); //cheat to know used space + uint64_t size = get_real_bytes(val); //cheat to know used space uint8_t *buff = (uint8_t *) malloc(sizeof(uint8_t) + size); buff[0] = BPLIST_REAL | Log2(size); if (size == sizeof(double)) @@ -648,7 +704,7 @@ float tmpval = (float) val; memcpy(buff + 1, &tmpval, size); } - byte_convert(buff + 1, size); + float_byte_convert(buff + 1, size); g_byte_array_append(bplist, buff, sizeof(uint8_t) + size); free(buff); } @@ -659,7 +715,7 @@ uint8_t *buff = (uint8_t *) malloc(sizeof(uint8_t) + size); buff[0] = BPLIST_DATE | Log2(size); memcpy(buff + 1, &val, size); - byte_convert(buff + 1, size); + float_byte_convert(buff + 1, size); g_byte_array_append(bplist, buff, sizeof(uint8_t) + size); free(buff); } @@ -728,6 +784,9 @@ for (i = 0, cur = node->children; cur && i < size; cur = cur->next, i++) { idx = *(uint64_t *) (g_hash_table_lookup(ref_table, cur)); +#if G_BYTE_ORDER == G_BIG_ENDIAN + idx = idx << ((sizeof(uint64_t) - dict_param_size) * 8); +#endif memcpy(buff + i * dict_param_size, &idx, dict_param_size); byte_convert(buff + i * dict_param_size, dict_param_size); } @@ -763,10 +822,16 @@ for (i = 0, cur = node->children; cur && i < size; cur = cur->next->next, i++) { idx1 = *(uint64_t *) (g_hash_table_lookup(ref_table, cur)); +#if G_BYTE_ORDER == G_BIG_ENDIAN + idx1 = idx1 << ((sizeof(uint64_t) - dict_param_size) * 8); +#endif memcpy(buff + i * dict_param_size, &idx1, dict_param_size); byte_convert(buff + i * dict_param_size, dict_param_size); idx2 = *(uint64_t *) (g_hash_table_lookup(ref_table, cur->next)); +#if G_BYTE_ORDER == G_BIG_ENDIAN + idx2 = idx2 << ((sizeof(uint64_t) - dict_param_size) * 8); +#endif memcpy(buff + (i + size) * dict_param_size, &idx2, dict_param_size); byte_convert(buff + (i + size) * dict_param_size, dict_param_size); } @@ -896,7 +961,12 @@ for (i = 0; i < num_objects; i++) { uint8_t *offsetbuff = (uint8_t *) malloc(offset_size); - memcpy(offsetbuff, offsets + i, offset_size); + +#if G_BYTE_ORDER == G_BIG_ENDIAN + offsets[i] = offsets[i] << ((sizeof(uint64_t) - offset_size) * 8); +#endif + + memcpy(offsetbuff, &offsets[i], offset_size); byte_convert(offsetbuff, offset_size); g_byte_array_append(bplist_buff, offsetbuff, offset_size); free(offsetbuff); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplist-1.2/src/xplist.c new/libplist-1.3/src/xplist.c --- old/libplist-1.2/src/xplist.c 2010-01-21 21:45:01.000000000 +0100 +++ new/libplist-1.3/src/xplist.c 2010-04-18 15:30:19.000000000 +0200 @@ -26,6 +26,7 @@ #include <stdio.h> #include <inttypes.h> +#include <locale.h> #include <libxml/parser.h> #include <libxml/tree.h> @@ -371,12 +372,33 @@ root_node = xmlDocGetRootElement(plist_doc); root.xml = root_node; + char *current_locale = setlocale(LC_NUMERIC, NULL); + char *saved_locale = NULL; + if (current_locale) { + saved_locale = strdup(current_locale); + } + if (saved_locale) { + setlocale(LC_NUMERIC, "POSIX"); + } node_to_xml(plist, &root); - xmlDocDumpMemory(plist_doc, (xmlChar **) plist_xml, &size); - if (size >= 0) + xmlChar* tmp = NULL; + xmlDocDumpMemory(plist_doc, &tmp, &size); + if (size >= 0 && tmp) + { + /* make sure to copy the terminating 0-byte */ + *plist_xml = (char*)malloc((size+1) * sizeof(char)); + memcpy(*plist_xml, tmp, size+1); *length = size; + xmlFree(tmp); + tmp = NULL; + } xmlFreeDoc(plist_doc); + + if (saved_locale) { + setlocale(LC_NUMERIC, saved_locale); + free(saved_locale); + } } void plist_from_xml(const char *plist_xml, uint32_t length, plist_t * plist) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org
participants (1)
-
root@hilbert.suse.de