changeset 32803:fff5aa81d90e

Simplify input preparation and allow semicolon to be defined as a font character instead of crashing.
author ib
date Fri, 11 Feb 2011 14:43:28 +0000
parents e310b1833cbe
children b0df43398401
files gui/skin/font.c
diffstat 1 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/gui/skin/font.c	Fri Feb 11 13:17:08 2011 +0000
+++ b/gui/skin/font.c	Fri Feb 11 14:43:28 2011 +0000
@@ -68,7 +68,6 @@
  unsigned char * ptmp;
  unsigned char   command[32];
  unsigned char   param[256];
- int             c;
  int             id = fntAddNewFont( fname );
 
  if ( id < 0 ) return id;
@@ -86,14 +85,14 @@
   {
    // remove any kind of newline, if any
    tmp[strcspn(tmp, "\n\r")] = 0;
-   for ( c=0;c < (int)strlen( tmp );c++ )
-     if ( tmp[c] == ';' ) { tmp[c]=0; break; }
-   if ( !tmp[0] ) continue;
-   ptmp=trimleft( tmp );
-   if ( !ptmp[0] ) continue;
-   ptmp=strswap( ptmp,'\t',' ' );
-   ptmp=trim( ptmp );
-   cutItem( ptmp,command,'=',0 ); cutItem( ptmp,param,'=',1 );
+   strswap( tmp,'\t',' ' );
+   trim( tmp );
+   if ((ptmp = strchr(tmp, ';')))
+   {
+     if (ptmp != tmp + 1 || tmp[0] != '"' || tmp[2] != '"') *ptmp = '\0';
+   }
+   if (!*tmp) continue;
+   cutItem( tmp,command,'=',0 ); cutItem( tmp,param,'=',1 );
    if ( command[0] == '"' )
     {
      int i;