Blame doxywizard-missing-config.patch

Than Ngo 14bb3a
diff -Nur doxygen-1.6.2-20100208.orig/addon/doxywizard/config.h doxygen-1.6.2-20100208/addon/doxywizard/config.h
Than Ngo 14bb3a
--- doxygen-1.6.2-20100208.orig/addon/doxywizard/config.h	1970-01-01 01:00:00.000000000 +0100
Than Ngo 14bb3a
+++ doxygen-1.6.2-20100208/addon/doxywizard/config.h	2008-11-21 12:30:03.000000000 +0100
Than Ngo 14bb3a
@@ -0,0 +1,18 @@
Than Ngo 14bb3a
+#ifndef CONFIG_H
Than Ngo 14bb3a
+#define CONFIG_H
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+#include <QHash>
Than Ngo 14bb3a
+#include <QString>
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+class Input;
Than Ngo 14bb3a
+class QTextStream;
Than Ngo 14bb3a
+class QTextCodec;
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+bool parseConfig(
Than Ngo 14bb3a
+      const QString &fileName,
Than Ngo 14bb3a
+      const QHash<QString,Input *> &options
Than Ngo 14bb3a
+    );
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+void writeStringValue(QTextStream &t,QTextCodec *codec,const QString &s);
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+#endif
Than Ngo 14bb3a
diff -Nur doxygen-1.6.2-20100208.orig/addon/doxywizard/config.l doxygen-1.6.2-20100208/addon/doxywizard/config.l
Than Ngo 14bb3a
--- doxygen-1.6.2-20100208.orig/addon/doxywizard/config.l	1970-01-01 01:00:00.000000000 +0100
Than Ngo 14bb3a
+++ doxygen-1.6.2-20100208/addon/doxywizard/config.l	2009-02-15 16:48:43.000000000 +0100
Than Ngo 14bb3a
@@ -0,0 +1,539 @@
Than Ngo 14bb3a
+/******************************************************************************
Than Ngo 14bb3a
+ *
Than Ngo 14bb3a
+ * $Id: config_templ.l,v 1.8 2001/01/01 10:15:16 root Exp $
Than Ngo 14bb3a
+ *
Than Ngo 14bb3a
+ * Copyright (C) 1997-2007 by Dimitri van Heesch.
Than Ngo 14bb3a
+ *
Than Ngo 14bb3a
+ * Permission to use, copy, modify, and distribute this software and its
Than Ngo 14bb3a
+ * documentation under the terms of the GNU General Public License is hereby 
Than Ngo 14bb3a
+ * granted. No representations are made about the suitability of this software 
Than Ngo 14bb3a
+ * for any purpose. It is provided "as is" without express or implied warranty.
Than Ngo 14bb3a
+ * See the GNU General Public License for more details.
Than Ngo 14bb3a
+ *
Than Ngo 14bb3a
+ */
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+%{
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+/*
Than Ngo 14bb3a
+ *	includes
Than Ngo 14bb3a
+ */
Than Ngo 14bb3a
+#include "config.h"
Than Ngo 14bb3a
+#include "input.h"
Than Ngo 14bb3a
+#include <QtCore>
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+#define MAX_INCLUDE_DEPTH 10
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+/* -----------------------------------------------------------------
Than Ngo 14bb3a
+ *
Than Ngo 14bb3a
+ *	static variables
Than Ngo 14bb3a
+ */
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+struct ConfigFileState
Than Ngo 14bb3a
+{
Than Ngo 14bb3a
+  int lineNr;
Than Ngo 14bb3a
+  FILE *file;
Than Ngo 14bb3a
+  YY_BUFFER_STATE oldState;
Than Ngo 14bb3a
+  YY_BUFFER_STATE newState;
Than Ngo 14bb3a
+  QString fileName;
Than Ngo 14bb3a
+};  
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+static const QHash<QString,Input*>   *g_options;
Than Ngo 14bb3a
+static FILE                          *g_file;
Than Ngo 14bb3a
+static QString                        g_yyFileName;
Than Ngo 14bb3a
+static QString                        g_includeName;
Than Ngo 14bb3a
+static QVariant                       g_includePathList;
Than Ngo 14bb3a
+static QStack<ConfigFileState*>       g_includeStack;  
Than Ngo 14bb3a
+static int                            g_includeDepth;
Than Ngo 14bb3a
+static QVariant                      *g_arg;
Than Ngo 14bb3a
+static Input                         *g_curOption=0;
Than Ngo 14bb3a
+static QString                        g_elemStr;
Than Ngo 14bb3a
+static QTextCodec                    *g_codec     = QTextCodec::codecForName("UTF-8");
Than Ngo 14bb3a
+static QString                        g_codecName = QString::fromAscii("UTF-8");
Than Ngo 14bb3a
+static int                            g_lastState;
Than Ngo 14bb3a
+static QByteArray                     g_tmpString;
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+/* -----------------------------------------------------------------
Than Ngo 14bb3a
+ */
Than Ngo 14bb3a
+#undef	YY_INPUT
Than Ngo 14bb3a
+#define	YY_INPUT(buf,result,max_size) result=yyread(buf,max_size);
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+static int yyread(char *buf,int maxSize)
Than Ngo 14bb3a
+{
Than Ngo 14bb3a
+    // no file included
Than Ngo 14bb3a
+    if (g_includeStack.isEmpty()) 
Than Ngo 14bb3a
+    {
Than Ngo 14bb3a
+      return fread(buf,1,maxSize,g_file);
Than Ngo 14bb3a
+    } 
Than Ngo 14bb3a
+    else 
Than Ngo 14bb3a
+    {
Than Ngo 14bb3a
+      return fread(buf,1,maxSize,g_includeStack.top()->file);
Than Ngo 14bb3a
+    }
Than Ngo 14bb3a
+}
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+void config_err(const char *fmt, ...)
Than Ngo 14bb3a
+{
Than Ngo 14bb3a
+  va_list args;
Than Ngo 14bb3a
+  va_start(args, fmt);
Than Ngo 14bb3a
+  vfprintf(stderr, fmt, args);
Than Ngo 14bb3a
+  va_end(args); 
Than Ngo 14bb3a
+}
Than Ngo 14bb3a
+void config_warn(const char *fmt, ...)
Than Ngo 14bb3a
+{
Than Ngo 14bb3a
+  va_list args;
Than Ngo 14bb3a
+  va_start(args, fmt);
Than Ngo 14bb3a
+  vfprintf(stderr, fmt, args);
Than Ngo 14bb3a
+  va_end(args);
Than Ngo 14bb3a
+}
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+static void substEnvVarsInStrList(QStringList &sl);
Than Ngo 14bb3a
+static void substEnvVarsInString(QString &s);
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+static void checkEncoding()
Than Ngo 14bb3a
+{
Than Ngo 14bb3a
+  Input *option = g_options->value(QString::fromAscii("DOXYFILE_ENCODING"));
Than Ngo 14bb3a
+  if (option && option->value().toString()!=g_codecName)
Than Ngo 14bb3a
+  {
Than Ngo 14bb3a
+    QTextCodec *newCodec = QTextCodec::codecForName(option->value().toString().toAscii());
Than Ngo 14bb3a
+    if (newCodec)
Than Ngo 14bb3a
+    {
Than Ngo 14bb3a
+      g_codec = newCodec;
Than Ngo 14bb3a
+      g_codecName = option->value().toString();
Than Ngo 14bb3a
+    }
Than Ngo 14bb3a
+  }
Than Ngo 14bb3a
+}
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+static FILE *tryPath(const QString &path,const QString &fileName)
Than Ngo 14bb3a
+{
Than Ngo 14bb3a
+  QString absName=!path.isEmpty() ? path+QString::fromAscii("/")+fileName : fileName;
Than Ngo 14bb3a
+  QFileInfo fi(absName);
Than Ngo 14bb3a
+  if (fi.exists() && fi.isFile())
Than Ngo 14bb3a
+  {
Than Ngo 14bb3a
+    FILE *f = fopen(absName.toLocal8Bit(),"r");
Than Ngo 14bb3a
+    if (f==NULL)
Than Ngo 14bb3a
+      config_err("Error: could not open file %s for reading\n",absName.toLatin1().data());
Than Ngo 14bb3a
+    else 
Than Ngo 14bb3a
+      return f;
Than Ngo 14bb3a
+  }
Than Ngo 14bb3a
+  return NULL;
Than Ngo 14bb3a
+}
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+static FILE *findFile(const QString &fileName)
Than Ngo 14bb3a
+{
Than Ngo 14bb3a
+  if (QFileInfo(fileName).isAbsolute()) // absolute path
Than Ngo 14bb3a
+  {
Than Ngo 14bb3a
+    return tryPath(QString(), fileName);
Than Ngo 14bb3a
+  }
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+  // relative path, try with include paths in the list
Than Ngo 14bb3a
+  QStringList sl = g_includePathList.toStringList();
Than Ngo 14bb3a
+  substEnvVarsInStrList(sl);
Than Ngo 14bb3a
+  foreach (QString s, sl) 
Than Ngo 14bb3a
+  {
Than Ngo 14bb3a
+    FILE *f = tryPath(s,fileName);
Than Ngo 14bb3a
+    if (f) return f;
Than Ngo 14bb3a
+  }
Than Ngo 14bb3a
+  // try cwd if g_includePathList fails
Than Ngo 14bb3a
+  return tryPath(QString::fromAscii("."),fileName);
Than Ngo 14bb3a
+}
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+static void readIncludeFile(const QString &incName)
Than Ngo 14bb3a
+{
Than Ngo 14bb3a
+  if (g_includeDepth==MAX_INCLUDE_DEPTH) 
Than Ngo 14bb3a
+  {
Than Ngo 14bb3a
+    config_err("Error: maximum include depth (%d) reached, %s is not included. Aborting...\n",
Than Ngo 14bb3a
+	MAX_INCLUDE_DEPTH,qPrintable(incName));
Than Ngo 14bb3a
+    exit(1);
Than Ngo 14bb3a
+  } 
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+  QString inc = incName;
Than Ngo 14bb3a
+  substEnvVarsInString(inc);
Than Ngo 14bb3a
+  inc = inc.trimmed();
Than Ngo 14bb3a
+  uint incLen = inc.length();
Than Ngo 14bb3a
+  if (inc.at(0)==QChar::fromAscii('"') && 
Than Ngo 14bb3a
+      inc.at(incLen-1)==QChar::fromAscii('"')) // strip quotes
Than Ngo 14bb3a
+  {
Than Ngo 14bb3a
+    inc=inc.mid(1,incLen-2);
Than Ngo 14bb3a
+  }
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+  FILE *f = findFile(inc);
Than Ngo 14bb3a
+  if (f) // see if the include file can be found
Than Ngo 14bb3a
+  {
Than Ngo 14bb3a
+    // For debugging
Than Ngo 14bb3a
+#if SHOW_INCLUDES
Than Ngo 14bb3a
+    for (i=0;i
Than Ngo 14bb3a
+    msg("@INCLUDE = %s: parsing...\n",inc.toLatin1().data());
Than Ngo 14bb3a
+#endif
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+    // store the state of the old file 
Than Ngo 14bb3a
+    ConfigFileState *fs=new ConfigFileState;
Than Ngo 14bb3a
+    fs->oldState=YY_CURRENT_BUFFER;
Than Ngo 14bb3a
+    fs->fileName=g_yyFileName;
Than Ngo 14bb3a
+    fs->file=f;
Than Ngo 14bb3a
+    // push the state on the stack
Than Ngo 14bb3a
+    g_includeStack.push(fs);
Than Ngo 14bb3a
+    // set the scanner to the include file
Than Ngo 14bb3a
+    yy_switch_to_buffer(yy_create_buffer(f, YY_BUF_SIZE));
Than Ngo 14bb3a
+    fs->newState=YY_CURRENT_BUFFER;
Than Ngo 14bb3a
+    g_yyFileName=inc;
Than Ngo 14bb3a
+    g_includeDepth++;
Than Ngo 14bb3a
+  } 
Than Ngo 14bb3a
+  else
Than Ngo 14bb3a
+  {
Than Ngo 14bb3a
+    config_err("Error: @INCLUDE = %s: not found!\n",inc.toLatin1().data());
Than Ngo 14bb3a
+    exit(1);
Than Ngo 14bb3a
+  }
Than Ngo 14bb3a
+}
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+%}
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+%option nounput
Than Ngo 14bb3a
+%option noyywrap
Than Ngo 14bb3a
+%option yylineno
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+%x      Start
Than Ngo 14bb3a
+%x	SkipComment
Than Ngo 14bb3a
+%x      SkipInvalid
Than Ngo 14bb3a
+%x      GetString
Than Ngo 14bb3a
+%x      GetStrList
Than Ngo 14bb3a
+%x      GetQuotedString
Than Ngo 14bb3a
+%x      GetEnvVar
Than Ngo 14bb3a
+%x      Include
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+%%
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+<*>\0x0d
Than Ngo 14bb3a
+<Start,GetString,GetStrList,SkipInvalid>"#"	 { BEGIN(SkipComment); }
Than Ngo 14bb3a
+<Start>[a-z_A-Z][a-z_A-Z0-9]*[ \t]*"="	 { QString cmd = g_codec->toUnicode(yytext);
Than Ngo 14bb3a
+                                           cmd=cmd.left(cmd.length()-1).trimmed(); 
Than Ngo 14bb3a
+					   g_curOption = g_options->value(cmd);
Than Ngo 14bb3a
+					   if (g_curOption==0) // oops not known
Than Ngo 14bb3a
+					   {
Than Ngo 14bb3a
+					     config_err("Warning: ignoring unsupported tag `%s' at line %d, file %s\n",
Than Ngo 14bb3a
+						 qPrintable(cmd),yylineno,qPrintable(g_yyFileName)); 
Than Ngo 14bb3a
+					     BEGIN(SkipInvalid);
Than Ngo 14bb3a
+					   }
Than Ngo 14bb3a
+					   else // known tag
Than Ngo 14bb3a
+					   {
Than Ngo 14bb3a
+					     //option->setEncoding(encoding);
Than Ngo 14bb3a
+					     g_arg = &g_curOption->value();
Than Ngo 14bb3a
+					     switch(g_curOption->kind())
Than Ngo 14bb3a
+					     {
Than Ngo 14bb3a
+					       case Input::StrList:
Than Ngo 14bb3a
+						 g_elemStr = QString();
Than Ngo 14bb3a
+						 *g_arg = QStringList();
Than Ngo 14bb3a
+					         BEGIN(GetStrList);
Than Ngo 14bb3a
+					         break;
Than Ngo 14bb3a
+					       case Input::String:
Than Ngo 14bb3a
+					         BEGIN(GetString);
Than Ngo 14bb3a
+					         break;
Than Ngo 14bb3a
+					       case Input::Int:
Than Ngo 14bb3a
+					         BEGIN(GetString);
Than Ngo 14bb3a
+					         break;
Than Ngo 14bb3a
+					       case Input::Bool:
Than Ngo 14bb3a
+					         BEGIN(GetString);
Than Ngo 14bb3a
+						 break;
Than Ngo 14bb3a
+					       case Input::Obsolete:
Than Ngo 14bb3a
+					         config_err("Warning: Tag `%s' at line %d of file %s has become obsolete.\n"
Than Ngo 14bb3a
+						            "To avoid this warning please update your configuration "
Than Ngo 14bb3a
+							    "file using \"doxygen -u\"\n", qPrintable(cmd),
Than Ngo 14bb3a
+							    yylineno,qPrintable(g_yyFileName)); 
Than Ngo 14bb3a
+					         BEGIN(SkipInvalid);
Than Ngo 14bb3a
+						 break;
Than Ngo 14bb3a
+					     }
Than Ngo 14bb3a
+					   }
Than Ngo 14bb3a
+					}
Than Ngo 14bb3a
+<Start>[a-z_A-Z][a-z_A-Z0-9]*[ \t]*"+="	{ QString cmd=g_codec->toUnicode(yytext);
Than Ngo 14bb3a
+                                          cmd=cmd.left(cmd.length()-2).trimmed(); 
Than Ngo 14bb3a
+					  g_curOption = g_options->value(cmd);
Than Ngo 14bb3a
+					  if (g_curOption==0) // oops not known
Than Ngo 14bb3a
+					  {
Than Ngo 14bb3a
+					    config_err("Warning: ignoring unsupported tag `%s' at line %d, file %s\n",
Than Ngo 14bb3a
+						yytext,yylineno,qPrintable(g_yyFileName)); 
Than Ngo 14bb3a
+					    BEGIN(SkipInvalid);
Than Ngo 14bb3a
+					  }
Than Ngo 14bb3a
+					  else // known tag
Than Ngo 14bb3a
+					  {
Than Ngo 14bb3a
+					    switch(g_curOption->kind())
Than Ngo 14bb3a
+					    {
Than Ngo 14bb3a
+					      case Input::StrList:
Than Ngo 14bb3a
+						g_arg = &g_curOption->value();
Than Ngo 14bb3a
+						g_elemStr=QString();
Than Ngo 14bb3a
+					        BEGIN(GetStrList);
Than Ngo 14bb3a
+					        break;
Than Ngo 14bb3a
+					      case Input::String:
Than Ngo 14bb3a
+					      case Input::Int:
Than Ngo 14bb3a
+					      case Input::Bool:
Than Ngo 14bb3a
+					        config_err("Warning: operator += not supported for `%s'. Ignoring line at line %d, file %s\n",
Than Ngo 14bb3a
+						    yytext,yylineno,qPrintable(g_yyFileName)); 
Than Ngo 14bb3a
+					        BEGIN(SkipInvalid);
Than Ngo 14bb3a
+						break;
Than Ngo 14bb3a
+					      case Input::Obsolete:
Than Ngo 14bb3a
+					         config_err("Warning: Tag `%s' at line %d of file %s has become obsolete.\n"
Than Ngo 14bb3a
+						            "To avoid this warning please update your configuration "
Than Ngo 14bb3a
+							    "file using \"doxygen -u\"\n", 
Than Ngo 14bb3a
+							    qPrintable(cmd),yylineno,qPrintable(g_yyFileName)); 
Than Ngo 14bb3a
+					         BEGIN(SkipInvalid);
Than Ngo 14bb3a
+						 break;
Than Ngo 14bb3a
+					     }
Than Ngo 14bb3a
+					   }
Than Ngo 14bb3a
+					}
Than Ngo 14bb3a
+<Start>"@INCLUDE_PATH"[ \t]*"=" 	{ BEGIN(GetStrList); g_arg=&g_includePathList; *g_arg = QStringList(); g_elemStr=QString(); }
Than Ngo 14bb3a
+  /* include a config file */
Than Ngo 14bb3a
+<Start>"@INCLUDE"[ \t]*"="     		{ BEGIN(Include);}
Than Ngo 14bb3a
+<Include>([^ \"\t\r\n]+)|("\""[^\n\"]+"\"") { 
Than Ngo 14bb3a
+  					  readIncludeFile(g_codec->toUnicode(yytext)); 
Than Ngo 14bb3a
+  					  BEGIN(Start);
Than Ngo 14bb3a
+					}
Than Ngo 14bb3a
+<<EOF>>					{
Than Ngo 14bb3a
+                                          //printf("End of include file\n");
Than Ngo 14bb3a
+					  //printf("Include stack depth=%d\n",g_includeStack.count());
Than Ngo 14bb3a
+                                          if (g_includeStack.isEmpty())
Than Ngo 14bb3a
+					  {
Than Ngo 14bb3a
+					    //printf("Terminating scanner!\n");
Than Ngo 14bb3a
+					    yyterminate();
Than Ngo 14bb3a
+					  }
Than Ngo 14bb3a
+					  else
Than Ngo 14bb3a
+					  {
Than Ngo 14bb3a
+					    ConfigFileState *fs = g_includeStack.pop();
Than Ngo 14bb3a
+					    fclose(fs->file);
Than Ngo 14bb3a
+					    YY_BUFFER_STATE oldBuf = YY_CURRENT_BUFFER;
Than Ngo 14bb3a
+					    yy_switch_to_buffer( fs->oldState );
Than Ngo 14bb3a
+					    yy_delete_buffer( oldBuf );
Than Ngo 14bb3a
+					    g_yyFileName=fs->fileName;
Than Ngo 14bb3a
+					    delete fs; 
Than Ngo 14bb3a
+                                            g_includeDepth--;
Than Ngo 14bb3a
+					  }
Than Ngo 14bb3a
+  					}
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+<Start>[a-z_A-Z0-9]+			{ config_err("Warning: ignoring unknown tag `%s' at line %d, file %s\n",yytext,yylineno,qPrintable(g_yyFileName)); }
Than Ngo 14bb3a
+<GetString,SkipInvalid>\n	        { BEGIN(Start); }
Than Ngo 14bb3a
+<GetStrList>\n				{ 
Than Ngo 14bb3a
+					  if (!g_elemStr.isEmpty())
Than Ngo 14bb3a
+					  {
Than Ngo 14bb3a
+					    //printf("elemStr1=`%s'\n",elemStr.toLatin1().data());
Than Ngo 14bb3a
+					    *g_arg = QVariant(g_arg->toStringList() << g_elemStr);
Than Ngo 14bb3a
+					  }
Than Ngo 14bb3a
+					  BEGIN(Start); 
Than Ngo 14bb3a
+					}
Than Ngo 14bb3a
+<GetStrList>[ \t]+			{
Than Ngo 14bb3a
+  				          if (!g_elemStr.isEmpty())
Than Ngo 14bb3a
+					  {
Than Ngo 14bb3a
+					    //printf("elemStr2=`%s'\n",elemStr.toLatin1().data());
Than Ngo 14bb3a
+  					    *g_arg = QVariant(g_arg->toStringList() << g_elemStr);
Than Ngo 14bb3a
+					  }
Than Ngo 14bb3a
+					  g_elemStr = QString();
Than Ngo 14bb3a
+  					}
Than Ngo 14bb3a
+<GetString>[^ \"\t\r\n]+		{ 
Than Ngo 14bb3a
+                                          *g_arg = QVariant(g_codec->toUnicode(yytext)); 
Than Ngo 14bb3a
+                                          checkEncoding();
Than Ngo 14bb3a
+                                        }
Than Ngo 14bb3a
+<GetString,GetStrList,SkipInvalid>"\""	{ g_lastState=YY_START;
Than Ngo 14bb3a
+  					  BEGIN(GetQuotedString); 
Than Ngo 14bb3a
+                                          g_tmpString="";
Than Ngo 14bb3a
+					}
Than Ngo 14bb3a
+<GetQuotedString>"\""|"\n" 		{ 
Than Ngo 14bb3a
+                                          // we add a bogus space to signal that the string was quoted. This space will be stripped later on.
Than Ngo 14bb3a
+                                          g_tmpString+=" ";
Than Ngo 14bb3a
+  					  //printf("Quoted String = `%s'\n",tmpString.toLatin1().data());
Than Ngo 14bb3a
+  					  if (g_lastState==GetString)
Than Ngo 14bb3a
+					  {
Than Ngo 14bb3a
+					    *g_arg = g_codec->toUnicode(g_tmpString);
Than Ngo 14bb3a
+                                            checkEncoding();
Than Ngo 14bb3a
+					  }
Than Ngo 14bb3a
+					  else
Than Ngo 14bb3a
+					  {
Than Ngo 14bb3a
+					    g_elemStr+=g_codec->toUnicode(g_tmpString);
Than Ngo 14bb3a
+					  }
Than Ngo 14bb3a
+					  if (*yytext=='\n')
Than Ngo 14bb3a
+					  {
Than Ngo 14bb3a
+					    config_err("Warning: Missing end quote (\") on line %d, file %s\n",yylineno,
Than Ngo 14bb3a
+                                                qPrintable(g_yyFileName));
Than Ngo 14bb3a
+					  }
Than Ngo 14bb3a
+					  BEGIN(g_lastState);
Than Ngo 14bb3a
+  					}
Than Ngo 14bb3a
+<GetQuotedString>"\\\""			{
Than Ngo 14bb3a
+  					  g_tmpString+='"';
Than Ngo 14bb3a
+  					}
Than Ngo 14bb3a
+<GetQuotedString>.			{ g_tmpString+=*yytext; }
Than Ngo 14bb3a
+<GetStrList>[^ \#\"\t\r\n]+		{
Than Ngo 14bb3a
+  					  g_elemStr+=g_codec->toUnicode(yytext);
Than Ngo 14bb3a
+  					}
Than Ngo 14bb3a
+<SkipComment>\n				{ BEGIN(Start); }
Than Ngo 14bb3a
+<SkipComment>\\[ \r\t]*\n		{ BEGIN(Start); }
Than Ngo 14bb3a
+<*>\\[ \r\t]*\n				{ }
Than Ngo 14bb3a
+<*>\n
Than Ngo 14bb3a
+<*>.					
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+%%
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+/*@ ----------------------------------------------------------------------------
Than Ngo 14bb3a
+ */
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+static void substEnvVarsInString(QString &s)
Than Ngo 14bb3a
+{
Than Ngo 14bb3a
+  static QRegExp re(QString::fromAscii("\\$\\([a-z_A-Z0-9]+\\)"));
Than Ngo 14bb3a
+  if (s.isEmpty()) return;
Than Ngo 14bb3a
+  int p=0;
Than Ngo 14bb3a
+  int i,l;
Than Ngo 14bb3a
+  //printf("substEnvVarInString(%s) start\n",s.toLatin1().data());
Than Ngo 14bb3a
+  while ((i=re.indexIn(s,p))!=-1)
Than Ngo 14bb3a
+  {
Than Ngo 14bb3a
+    l = re.matchedLength();
Than Ngo 14bb3a
+    //printf("Found environment var s.mid(%d,%d)=`%s'\n",i+2,l-3,s.mid(i+2,l-3).toLatin1().data());
Than Ngo 14bb3a
+    QString env=g_codec->toUnicode(getenv(s.mid(i+2,l-3).toLatin1()));
Than Ngo 14bb3a
+    substEnvVarsInString(env); // recursively expand variables if needed.
Than Ngo 14bb3a
+    s = s.left(i)+env+s.right(s.length()-i-l);
Than Ngo 14bb3a
+    p=i+env.length(); // next time start at the end of the expanded string
Than Ngo 14bb3a
+  }
Than Ngo 14bb3a
+  s=s.trimmed(); // to strip the bogus space that was added when an argument
Than Ngo 14bb3a
+                         // has quotes
Than Ngo 14bb3a
+  //printf("substEnvVarInString(%s) end\n",s.toLatin1().data());
Than Ngo 14bb3a
+}
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+static void substEnvVarsInStrList(QStringList &sl)
Than Ngo 14bb3a
+{
Than Ngo 14bb3a
+  QStringList out;
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+  foreach (QString result, sl)
Than Ngo 14bb3a
+  {
Than Ngo 14bb3a
+    // an argument with quotes will have an extra space at the end, so wasQuoted will be TRUE.
Than Ngo 14bb3a
+    bool wasQuoted = (result.indexOf(QChar::fromAscii(' '))!=-1) || 
Than Ngo 14bb3a
+                     (result.indexOf(QChar::fromAscii('\t'))!=-1);
Than Ngo 14bb3a
+    // here we strip the quote again
Than Ngo 14bb3a
+    substEnvVarsInString(result);
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+    //printf("Result %s was quoted=%d\n",result.toLatin1().data(),wasQuoted);
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+    if (!wasQuoted) /* as a result of the expansion, a single string
Than Ngo 14bb3a
+		       may have expanded into a list, which we'll
Than Ngo 14bb3a
+		       add to sl. If the orginal string already 
Than Ngo 14bb3a
+		       contained multiple elements no further 
Than Ngo 14bb3a
+		       splitting is done to allow quoted items with spaces! */
Than Ngo 14bb3a
+    {
Than Ngo 14bb3a
+      int l=result.length();
Than Ngo 14bb3a
+      int i,p=0;
Than Ngo 14bb3a
+      // skip spaces
Than Ngo 14bb3a
+      // search for a "word"
Than Ngo 14bb3a
+      for (i=0;i
Than Ngo 14bb3a
+      {
Than Ngo 14bb3a
+	QChar c=0;
Than Ngo 14bb3a
+	// skip until start of new word
Than Ngo 14bb3a
+	while (i
Than Ngo 14bb3a
+	p=i; // p marks the start index of the word
Than Ngo 14bb3a
+	// skip until end of a word
Than Ngo 14bb3a
+	while (i
Than Ngo 14bb3a
+	              c!=QChar::fromAscii('\t') && 
Than Ngo 14bb3a
+		      c!=QChar::fromAscii('"'))) i++;
Than Ngo 14bb3a
+	if (i
Than Ngo 14bb3a
+	{
Than Ngo 14bb3a
+	  if (c==QChar::fromAscii('"')) // word within quotes
Than Ngo 14bb3a
+	  {
Than Ngo 14bb3a
+	    p=i+1;
Than Ngo 14bb3a
+	    for (i++;i
Than Ngo 14bb3a
+	    {
Than Ngo 14bb3a
+	      c=result.at(i);
Than Ngo 14bb3a
+	      if (c==QChar::fromAscii('"')) // end quote
Than Ngo 14bb3a
+	      {
Than Ngo 14bb3a
+                out += result.mid(p,i-p);
Than Ngo 14bb3a
+		p=i+1;
Than Ngo 14bb3a
+		break; 
Than Ngo 14bb3a
+	      }
Than Ngo 14bb3a
+	      else if (c==QChar::fromAscii('\\')) // skip escaped stuff
Than Ngo 14bb3a
+	      {
Than Ngo 14bb3a
+		i++;
Than Ngo 14bb3a
+	      }
Than Ngo 14bb3a
+	    }
Than Ngo 14bb3a
+	  }
Than Ngo 14bb3a
+	  else if (c==QChar::fromAscii(' ') || c==QChar::fromAscii('\t')) // separator
Than Ngo 14bb3a
+	  {
Than Ngo 14bb3a
+            out += result.mid(p,i-p);
Than Ngo 14bb3a
+	    p=i+1;
Than Ngo 14bb3a
+	  }
Than Ngo 14bb3a
+	}
Than Ngo 14bb3a
+      }
Than Ngo 14bb3a
+      if (p!=l) // add the leftover as a string
Than Ngo 14bb3a
+      {
Than Ngo 14bb3a
+        out += result.right(l-p);
Than Ngo 14bb3a
+      }
Than Ngo 14bb3a
+    }
Than Ngo 14bb3a
+    else // just goto the next element in the list
Than Ngo 14bb3a
+    {
Than Ngo 14bb3a
+      out += result;
Than Ngo 14bb3a
+    }
Than Ngo 14bb3a
+  }
Than Ngo 14bb3a
+  sl = out;
Than Ngo 14bb3a
+}
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+//--------------------------------------------------------------------------
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+bool parseConfig(
Than Ngo 14bb3a
+      const QString &fileName,
Than Ngo 14bb3a
+      const QHash<QString,Input *> &options
Than Ngo 14bb3a
+    )
Than Ngo 14bb3a
+{
Than Ngo 14bb3a
+  g_file = fopen(fileName.toLocal8Bit(),"r");
Than Ngo 14bb3a
+  if (g_file==NULL) return false;
Than Ngo 14bb3a
+  g_options       = &options;
Than Ngo 14bb3a
+  g_yyFileName    = fileName;
Than Ngo 14bb3a
+  g_includeStack.clear();
Than Ngo 14bb3a
+  g_includeDepth  = 0;
Than Ngo 14bb3a
+  configrestart( configin );
Than Ngo 14bb3a
+  BEGIN( Start );
Than Ngo 14bb3a
+  configlex();
Than Ngo 14bb3a
+  QHashIterator<QString, Input*> i(options);
Than Ngo 14bb3a
+  while (i.hasNext()) 
Than Ngo 14bb3a
+  {
Than Ngo 14bb3a
+    i.next();
Than Ngo 14bb3a
+    if (i.value())
Than Ngo 14bb3a
+    {
Than Ngo 14bb3a
+      //printf("Updating: %s\n",qPrintable(i.key()));
Than Ngo 14bb3a
+      i.value()->update();
Than Ngo 14bb3a
+    }
Than Ngo 14bb3a
+    else
Than Ngo 14bb3a
+    {
Than Ngo 14bb3a
+      printf("Invalid option: %s\n",qPrintable(i.key()));
Than Ngo 14bb3a
+    }
Than Ngo 14bb3a
+  } 
Than Ngo 14bb3a
+  fclose(g_file);
Than Ngo 14bb3a
+  return true;
Than Ngo 14bb3a
+}
Than Ngo 14bb3a
+
Than Ngo 14bb3a
+void writeStringValue(QTextStream &t,QTextCodec *codec,const QString &s)
Than Ngo 14bb3a
+{
Than Ngo 14bb3a
+  QChar c;
Than Ngo 14bb3a
+  bool needsEscaping=FALSE;
Than Ngo 14bb3a
+  // convert the string back to it original encoding
Than Ngo 14bb3a
+  //QByteArray se = codec->fromUnicode(s);
Than Ngo 14bb3a
+  t.setCodec(codec);
Than Ngo 14bb3a
+  const QChar *p=s.data();
Than Ngo 14bb3a
+  if (!s.isEmpty() && !p->isNull())
Than Ngo 14bb3a
+  {
Than Ngo 14bb3a
+    while (!(c=*p++).isNull() && !needsEscaping) 
Than Ngo 14bb3a
+    {
Than Ngo 14bb3a
+      needsEscaping = (c==QChar::fromAscii(' ')  || 
Than Ngo 14bb3a
+	               c==QChar::fromAscii('\n') || 
Than Ngo 14bb3a
+		       c==QChar::fromAscii('\t') || 
Than Ngo 14bb3a
+		       c==QChar::fromAscii('"'));
Than Ngo 14bb3a
+    }
Than Ngo 14bb3a
+    if (needsEscaping)
Than Ngo 14bb3a
+    { 
Than Ngo 14bb3a
+      t << "\"";
Than Ngo 14bb3a
+      p=s.data();
Than Ngo 14bb3a
+      while (!p->isNull())
Than Ngo 14bb3a
+      {
Than Ngo 14bb3a
+	if (*p   ==QChar::fromAscii(' ') && 
Than Ngo 14bb3a
+	   *(p+1)==QChar::fromAscii('\0')) break; // skip inserted space at the end
Than Ngo 14bb3a
+	if (*p   ==QChar::fromAscii('"')) t << "\\"; // escape quotes
Than Ngo 14bb3a
+	t << *p++;
Than Ngo 14bb3a
+      }
Than Ngo 14bb3a
+      t << "\"";
Than Ngo 14bb3a
+    }
Than Ngo 14bb3a
+    else
Than Ngo 14bb3a
+    {
Than Ngo 14bb3a
+      t << s;
Than Ngo 14bb3a
+    }
Than Ngo 14bb3a
+  }
Than Ngo 14bb3a
+}
Than Ngo 14bb3a
+