# HG changeset patch # User ib # Date 1301495051 0 # Node ID 334e19411421240e7145d2166192c80ac14d283b # Parent 036e8492be6155c4405befcd724f97df371e760a 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. diff -r 036e8492be61 -r 334e19411421 gui/skin/font.c --- a/gui/skin/font.c Wed Mar 30 13:47:33 2011 +0000 +++ b/gui/skin/font.c Wed Mar 30 14:24:11 2011 +0000 @@ -76,7 +76,6 @@ { 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 @@ 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; diff -r 036e8492be61 -r 334e19411421 gui/skin/skin.c --- a/gui/skin/skin.c Wed Mar 30 13:47:33 2011 +0000 +++ b/gui/skin/skin.c Wed Mar 30 14:24:11 2011 +0000 @@ -870,7 +870,6 @@ 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 @@ 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; diff -r 036e8492be61 -r 334e19411421 gui/util/string.c --- a/gui/util/string.c Wed Mar 30 13:47:33 2011 +0000 +++ b/gui/util/string.c Wed Mar 30 14:24:11 2011 +0000 @@ -67,3 +67,25 @@ 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; +} diff -r 036e8492be61 -r 334e19411421 gui/util/string.h --- a/gui/util/string.h Wed Mar 30 13:47:33 2011 +0000 +++ b/gui/util/string.h Wed Mar 30 14:24:11 2011 +0000 @@ -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);