ekiga r7780 - trunk/lib/engine/protocol
- From: jpuydt svn gnome org
- To: svn-commits-list gnome org
- Subject: ekiga r7780 - trunk/lib/engine/protocol
- Date: Tue, 17 Mar 2009 20:28:22 +0000 (UTC)
Author: jpuydt
Date: Tue Mar 17 20:28:22 2009
New Revision: 7780
URL: http://svn.gnome.org/viewvc/ekiga?rev=7780&view=rev
Log:
Fixed #574998 (don't use strtok)
Modified:
trunk/lib/engine/protocol/codec-description.cpp
Modified: trunk/lib/engine/protocol/codec-description.cpp
==============================================================================
--- trunk/lib/engine/protocol/codec-description.cpp (original)
+++ trunk/lib/engine/protocol/codec-description.cpp Tue Mar 17 20:28:22 2009
@@ -56,17 +56,22 @@
bool _active)
: name (_name), rate (_rate), active (_active), audio (_audio)
{
- char *pch = NULL;
+ gchar** prots = NULL;
- pch = strtok ((char *) _protocols.c_str (), ",");
- while (pch != NULL) {
+ prots = g_strsplit (_protocols.c_str (), ", ", -1);
- std::string protocol = pch;
- protocol = protocol.substr (protocol.find_first_not_of (" "));
- protocols.push_back (protocol);
- pch = strtok (NULL, ",");
+ for (gchar** ptr = prots;
+ *ptr != NULL;
+ ptr++) {
+
+ if ((*ptr)[0] != '\0') { // not the empty string
+
+ protocols.push_back (*ptr);
+ }
}
+ g_strfreev (prots);
+
protocols.unique ();
protocols.sort ();
}
@@ -75,29 +80,30 @@
CodecDescription::CodecDescription (std::string codec)
{
int i = 0;
- char *pch = NULL;
-
+ gchar** vect = NULL;
std::string tmp [5];
- pch = strtok ((char *) codec.c_str (), "*");
- while (pch != NULL) {
+ vect = g_strsplit (codec.c_str (), "*", -1);
- tmp [i] = pch;
- pch = strtok (NULL, "*");
+ for (gchar** ptr = vect; *ptr != NULL; ptr++) {
+ tmp[i] = *ptr;
i++;
}
+ g_strfreev (vect);
+
if (i < 4)
return;
- pch = strtok ((char *) tmp [3].c_str (), " ");
- while (pch != NULL) {
+ vect = g_strsplit (tmp[3].c_str (), " ", -1);
+ for (gchar** ptr = vect; *ptr != NULL; ptr++) {
- protocols.push_back (pch);
- pch = strtok (NULL, " ");
+ protocols.push_back (*ptr);
}
+ g_strfreev (vect);
+
name = tmp [0];
rate = atoi (tmp [1].c_str ());
audio = atoi (tmp [2].c_str ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]