[MPlayer-cvslog] r33138 - trunk/gui/util/string.c
ib
subversion at mplayerhq.hu
Tue Mar 29 10:15:01 CEST 2011
Author: ib
Date: Tue Mar 29 10:15:01 2011
New Revision: 33138
Log:
Simplify trim().
(A special return value for empty strings isn't needed.)
Modified:
trunk/gui/util/string.c
Modified: trunk/gui/util/string.c
==============================================================================
--- trunk/gui/util/string.c Tue Mar 29 00:18:56 2011 (r33137)
+++ trunk/gui/util/string.c Tue Mar 29 10:15:01 2011 (r33138)
@@ -16,9 +16,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <stddef.h>
-#include <string.h>
-
#include "string.h"
char *strswap(char *in, char from, char to)
@@ -37,23 +34,22 @@ char *strswap(char *in, char from, char
char *trim(char *in)
{
- int c = 0, id = 0, i;
+ char *src, *dest;
+ int freeze = 0;
- if (!*in)
- return NULL;
+ src = dest = in;
- while (c != (int)strlen(in)) {
- if (in[c] == '"')
- id = !id;
+ while (*src) {
+ if (*src == '"')
+ freeze = !freeze;
- if ((in[c] == ' ') && (!id)) {
- for (i = 0; i < (int)strlen(in) - c; i++)
- in[c + i] = in[c + i + 1];
- continue;
- }
+ if (freeze || (*src != ' '))
+ *dest++ = *src;
- c++;
+ src++;
}
+ *dest = 0;
+
return in;
}
More information about the MPlayer-cvslog
mailing list