[MPlayer-cvslog] r33160 - in trunk/gui: skin/font.c skin/skin.c util/string.c util/string.h
ib
subversion at mplayerhq.hu
Wed Mar 30 16:24:11 CEST 2011
Author: ib
Date: Wed Mar 30 16:24:11 2011
New Revision: 33160
Log:
Improve handling of the comment character.
The comment character is safe now between (double) quotation marks.
This simplifies handling in the font description file and allows it
to be used in label texts.
Modified:
trunk/gui/skin/font.c
trunk/gui/skin/skin.c
trunk/gui/util/string.c
trunk/gui/util/string.h
Modified: trunk/gui/skin/font.c
==============================================================================
--- trunk/gui/skin/font.c Wed Mar 30 15:47:33 2011 (r33159)
+++ trunk/gui/skin/font.c Wed Mar 30 16:24:11 2011 (r33160)
@@ -76,7 +76,6 @@ int fntRead(char *path, char *fname)
{
FILE *f;
unsigned char tmp[512];
- unsigned char *ptmp;
unsigned char command[32];
unsigned char param[256];
int id, n, i;
@@ -100,10 +99,7 @@ int fntRead(char *path, char *fname)
tmp[strcspn(tmp, "\n\r")] = 0; // remove any kind of newline, if any
strswap(tmp, '\t', ' ');
trim(tmp);
- ptmp = strchr(tmp, ';');
-
- if (ptmp && !(ptmp == tmp + 1 && tmp[0] == '"' && tmp[2] == '"'))
- *ptmp = 0;
+ decomment(tmp);
if (!*tmp)
continue;
Modified: trunk/gui/skin/skin.c
==============================================================================
--- trunk/gui/skin/skin.c Wed Mar 30 15:47:33 2011 (r33159)
+++ trunk/gui/skin/skin.c Wed Mar 30 16:24:11 2011 (r33160)
@@ -870,7 +870,6 @@ int skinRead(char *dname)
char *fn;
FILE *skinFile;
unsigned char tmp[256];
- unsigned char *ptmp;
unsigned char command[32];
unsigned char param[256];
unsigned int i;
@@ -898,10 +897,7 @@ int skinRead(char *dname)
tmp[strcspn(tmp, "\n\r")] = 0; // remove any kind of newline, if any
strswap(tmp, '\t', ' ');
trim(tmp);
- ptmp = strchr(tmp, ';');
-
- if (ptmp)
- *ptmp = 0;
+ decomment(tmp);
if (!*tmp)
continue;
Modified: trunk/gui/util/string.c
==============================================================================
--- trunk/gui/util/string.c Wed Mar 30 15:47:33 2011 (r33159)
+++ trunk/gui/util/string.c Wed Mar 30 16:24:11 2011 (r33160)
@@ -67,3 +67,25 @@ char *trim(char *in)
return in;
}
+
+char *decomment(char *in)
+{
+ char *p;
+ int nap = 0;
+
+ p = in;
+
+ while (*p) {
+ if (*p == '"')
+ nap = !nap;
+
+ if ((*p == ';') && !nap) {
+ *p = 0;
+ break;
+ }
+
+ p++;
+ }
+
+ return in;
+}
Modified: trunk/gui/util/string.h
==============================================================================
--- trunk/gui/util/string.h Wed Mar 30 15:47:33 2011 (r33159)
+++ trunk/gui/util/string.h Wed Mar 30 16:24:11 2011 (r33160)
@@ -19,6 +19,7 @@
#ifndef MPLAYER_GUI_STRING_H
#define MPLAYER_GUI_STRING_H
+char *decomment(char *in);
char *strlower(char *in);
char *strswap(char *in, char from, char to);
char *trim(char *in);
More information about the MPlayer-cvslog
mailing list