changeset 33073:334e19411421

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.
author ib
date Wed, 30 Mar 2011 14:24:11 +0000
parents 036e8492be61
children 1241d9d7d551
files gui/skin/font.c gui/skin/skin.c gui/util/string.c gui/util/string.h
diffstat 4 files changed, 25 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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;
--- 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;
+}
--- 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);