[PATCH] - Alias definition and arguments can now contain "{" and "}"

Stefan Oberhumer <[email protected]>
Newsgroups gmane.text.doxygen.devel
Organization obssys.com
Message-ID <[email protected]>
Its not possible
   to pass a "{" as an argument to an alias or
   to put a "{" into a alias definition.

eg:
Doxyfile:
	ALIASES                = "MACRO_ARGV1{1}=\1"
	ALIASES               += "MACRO_ARGV2{1}=\{\1"
	ALIASES               += "MACRO_ARGV3{1}=\{\1\}"
	ALIASES               += "MACRO_ARGV4{1}=\1\}"

example page:
/*! @page page_argv ARGV Macros

Test of ARGV macros with { and }\n
@MACRO_ARGV1{ABCD\{ab\}cd}\n
@MACRO_ARGV2{ABCD\{ab\}cd}\n
@MACRO_ARGV3{ABCD\{ab\}cd}\n
@MACRO_ARGV4{ABCD\{ab\}cd}\n
*/

After applying the attached patch escaping of brackets works.
Use "\{" and "\}".



Best regards

Stefan

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf

_______________________________________________
Doxygen-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/doxygen-develop
brackets_in_alias_arguments.patch (text/plain, 3 KB)
Index: b/src/commentcnv.l
===================================================================
--- a/src/commentcnv.l
+++ b/src/commentcnv.l
@@ -67,6 +67,7 @@
 
 static QCString g_aliasString;
 static int      g_blockCount;
+static int      g_lastEscaped;
 static int      g_lastBlockContext;
 static bool     g_pythonDocString;
 
@@ -691,30 +692,41 @@
                                      g_lastBlockContext=YY_START;
 				     g_blockCount=1;
 				     g_aliasString=yytext;
+				     g_lastEscaped=0;
 				     BEGIN( ReadAliasArgs );
   				   }
-<ReadAliasArgs>[^{}\n\*]+	   {
+<ReadAliasArgs>[^{}\n\\\*]+	   {
+                                     g_aliasString+=yytext;
+				     g_lastEscaped=0;
+  				   }
+<ReadAliasArgs>"\\"		   {
+				     if (g_lastEscaped)  g_lastEscaped=0;
+				     else                g_lastEscaped=1;
                                      g_aliasString+=yytext;
   				   }
 <ReadAliasArgs>\n		   {
                                      g_aliasString+=yytext;
                                      g_lineNr++;
+				     g_lastEscaped=0;
   				   }
 <ReadAliasArgs>"{"		   {
                                      g_aliasString+=yytext;
-                                     g_blockCount++;
+                                     if (!g_lastEscaped)  g_blockCount++;
+                                     g_lastEscaped=0;
                                    }
 <ReadAliasArgs>"}"		   {
                                      g_aliasString+=yytext;
-                                     g_blockCount--;
+                                     if (!g_lastEscaped)  g_blockCount--;
 				     if (g_blockCount==0)
 				     {
 				       replaceAliases(g_aliasString);
 				       BEGIN( g_lastBlockContext );
 				     }
+                                     g_lastEscaped=0;
   			           }
 <ReadAliasArgs>.		   {
                                      g_aliasString+=yytext;
+				     g_lastEscaped=0;
   				   }
 <ReadLine>.			   {
   				     copyToOutput(yytext,yyleng);
Index: b/src/util.cpp
===================================================================
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -6707,6 +6707,8 @@
     }
   }
   result+=aliasValue.right(aliasValue.length()-p);
+  result = substitute(result,"\\{","{");
+  result = substitute(result,"\\}","}");
   result = expandAliasRec(substitute(result,"\\,",","));
   //printf("replaceAliasArgument('%s',%d,'%s')->%s\n",
   //    aliasValue.data(),paramNum,paramValue.data(),result.data());
@@ -6750,12 +6752,19 @@
 {
   int i;
   int bc=0;
+  char prev_char=0;
   if (args.at(pos)=='{') // alias has argument
   {
     for (i=pos;i<(int)args.length();i++)
     {
-      if (args.at(i)=='{') bc++;
-      if (args.at(i)=='}') bc--;
+      if (prev_char != '\\')
+      {
+        if (args.at(i)=='{') bc++;
+        if (args.at(i)=='}') bc--;
+        prev_char=args.at(i);
+      }
+      else
+        prev_char=0;
       if (bc==0)
       {
         //printf("extractAliasArgs('%s')->'%s'\n",args.data(),args.mid(pos+1,i-pos-1).data());
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.