Revision: 1680
http://gtkpod.svn.sourceforge.net/gtkpod/?rev=1680&view=rev
Author: jcsjcs
Date: 2007-08-17 21:14:21 -0700 (Fri, 17 Aug 2007)
Log Message:
-----------
* src/itdb_itunesdb.c: make calls to utf16_strlen()
unnecessary. Thanks to Javier Kohen for the patch.
Modified Paths:
--------------
libgpod/trunk/ChangeLog
libgpod/trunk/src/itdb_itunesdb.c
Modified: libgpod/trunk/ChangeLog
===================================================================
--- libgpod/trunk/ChangeLog 2007-08-18 04:04:08 UTC (rev 1679)
+++ libgpod/trunk/ChangeLog 2007-08-18 04:14:21 UTC (rev 1680)
@@ -3,10 +3,15 @@
* src/db-artwork-writer.c (write_mhod_type_3): don't assume that
length of a utf16 string is twice the length of a utf8 string
(even though this was safe here because the strings in question
- were ASCII).
+ were ASCII). Thanks to Javier Kohen for the patch.
+
(write_mhod_type_1), (write_mhod_type_3):
- Don't pad by 4 bytes as this achieves nothing.
+ Don't pad by 4 bytes as this achieves nothing. Thanks to Javier
+ Kohen to point this out.
+ * src/itdb_itunesdb.c: make calls to utf16_strlen()
+ unnecessary. Thanks to Javier Kohen for the patch.
+
2007-08-07 Nicholas Piper <nicholas at users.sourceforge.net>
* bindings/python/gpod.i.in: Return an integer for time_t (note,
Modified: libgpod/trunk/src/itdb_itunesdb.c
===================================================================
--- libgpod/trunk/src/itdb_itunesdb.c 2007-08-18 04:04:08 UTC (rev 1679)
+++ libgpod/trunk/src/itdb_itunesdb.c 2007-08-18 04:14:21 UTC (rev 1680)
@@ -282,16 +282,7 @@
return q;
}
-/* Get length of utf16 string in number of characters (words) */
-static guint32 utf16_strlen (gunichar2 *utf16)
-{
- guint32 i=0;
- if (utf16)
- while (utf16[i] != 0) ++i;
- return i;
-}
-
/* Read the contents of @filename and return a FContents
struct. Returns NULL in case of error and @error is set
accordingly */
@@ -817,7 +808,7 @@
gint32 i;
if (utf16_string)
{
- for(i=0; i<utf16_strlen(utf16_string); i++)
+ for(i=0; utf16_string[i]; i++)
{
utf16_string[i] = GUINT16_SWAP_LE_BE (utf16_string[i]);
}
@@ -834,7 +825,7 @@
gint32 i;
if (utf16_string)
{
- for(i=0; i<utf16_strlen(utf16_string); i++)
+ for(i=0; utf16_string[i]; i++)
{
utf16_string[i] = GUINT16_SWAP_LE_BE (utf16_string[i]);
}
@@ -3848,20 +3839,20 @@
if (!cts->reversed)
{
/* convert to utf16 */
+ glong len;
gunichar2 *entry_utf16 = g_utf8_to_utf16 (mhod->data.string, -1,
- NULL, NULL, NULL);
- guint32 len = utf16_strlen (entry_utf16);
+ NULL, &len, NULL);
fixup_little_utf16 (entry_utf16);
put_header (cts, "mhod"); /* header */
put32lint (cts, 24); /* size of header */
- put32lint (cts, 2*len+40); /* size of header + body */
+ put32lint (cts, sizeof (gunichar2)*len+40); /* size of header + body
*/
put32lint (cts, mhod->type);/* type of the mhod */
put32_n0 (cts, 2); /* unknown */
/* end of header, start of data */
put32lint (cts, 1); /* string type UTF16 */
- put32lint (cts, 2*len); /* size of string */
+ put32lint (cts, sizeof (gunichar2)*len); /* size of string
*/
put32_n0 (cts, 2); /* unknown */
- put_data (cts, (gchar *)entry_utf16, 2*len);/* the string */
+ put_data (cts, (gchar *)entry_utf16, sizeof (gunichar2)*len);/* the
string */
g_free (entry_utf16);
}
else
@@ -3969,7 +3960,7 @@
{
Itdb_SPLRule *splr = gl->data;
ItdbSPLFieldType ft;
- gint len;
+ glong len;
gunichar2 *entry_utf16;
g_return_if_fail (splr);
ft = itdb_splr_get_field_type (splr);
@@ -3982,15 +3973,15 @@
{
case ITDB_SPLFT_STRING:
/* write string-type rule */
+ len = 0;
entry_utf16 = NULL;
/* splr->string may be NULL */
if (splr->string)
entry_utf16 = g_utf8_to_utf16 (splr->string,
- -1,NULL,NULL,NULL);
- len = utf16_strlen (entry_utf16);
+ -1,NULL,&len,NULL);
fixup_big_utf16 (entry_utf16);
- put32bint (cts, 2*len); /* length of string */
- put_data (cts, (gchar *)entry_utf16, 2*len);
+ put32bint (cts, sizeof (gunichar2)*len); /* length of string
*/
+ put_data (cts, (gchar *)entry_utf16, sizeof (gunichar2)*len);
g_free (entry_utf16);
break;
case ITDB_SPLFT_DATE:
@@ -5203,7 +5194,7 @@
Itdb_Track *tr = gl->data;
gchar *path;
gunichar2 *path_utf16;
- guint32 pathlen;
+ glong pathlen;
gchar *mp3_desc[] = {"MPEG", "MP3", "mpeg", "mp3", NULL};
gchar *mp4_desc[] = {"AAC", "MP4", "aac", "mp4", NULL};
gchar *wav_desc[] = {"WAV", "wav", NULL};
@@ -5245,11 +5236,10 @@
/* shuffle uses forward slash separator, not colon */
path = g_strdup (tr->ipod_path);
itdb_filename_ipod2fs (path);
- path_utf16 = g_utf8_to_utf16 (path, -1, NULL, NULL, NULL);
- pathlen = utf16_strlen (path_utf16);
+ path_utf16 = g_utf8_to_utf16 (path, -1, NULL, &pathlen, NULL);
if (pathlen > 261) pathlen = 261;
fixup_little_utf16 (path_utf16);
- put_data (cts, (gchar *)path_utf16, 2*pathlen);
+ put_data (cts, (gchar *)path_utf16, sizeof (gunichar2)*pathlen);
/* pad to 522 bytes */
put16_n0 (cts, 261-pathlen);
g_free(path);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2