From b5cbb79d114ed13945bc882ac8eef1c2be967bbf Mon Sep 17 00:00:00 2001
From: Dimitri van Heesch <dimitri@stack.nl>
Date: Sun, 12 Aug 2001 16:26:14 +0000
Subject: Release-1.2.9-20010812

---
 INSTALL                            |   4 +-
 README                             |   4 +-
 VERSION                            |   2 +-
 addon/xmlparse/Doxyfile            |   6 +-
 addon/xmlparse/basehandler.h       |   2 +-
 addon/xmlparse/compoundhandler.cpp |   4 +
 addon/xmlparse/dochandler.cpp      |  76 +++++++++++-
 addon/xmlparse/dochandler.h        |  42 ++++++-
 addon/xmlparse/main.cpp            |  19 +--
 addon/xmlparse/memberhandler.cpp   |   4 +
 doc/commands.doc                   |  10 ++
 doc/config.doc                     |   7 ++
 doc/index.doc                      |   4 +-
 doc/preprocessing.doc              |  67 ++++++++---
 packages/rpm/doxygen.spec          |   2 +-
 qtools/qtools.pro.in               |   2 +-
 src/classdef.cpp                   | 123 ++++++++++++++++----
 src/classdef.h                     |  27 ++---
 src/config.l                       |   7 ++
 src/definition.cpp                 |   6 +-
 src/definition.h                   |   2 +-
 src/doc.l                          |   6 +-
 src/dot.cpp                        | 232 ++++++++-----------------------------
 src/dot.h                          |   4 +-
 src/doxygen.cpp                    | 161 +++++++++++++++----------
 src/entry.h                        |   3 +-
 src/htmlgen.cpp                    |   4 +-
 src/htmlgen.h                      |   7 +-
 src/index.cpp                      |  18 +--
 src/latexgen.h                     |   3 +-
 src/mangen.h                       |   2 +-
 src/memberdef.cpp                  |  52 +++++++--
 src/memberdef.h                    |   2 +-
 src/outputgen.h                    |   3 +-
 src/outputlist.cpp                 |   1 +
 src/outputlist.h                   |   5 +-
 src/rtfgen.h                       |   2 +-
 src/scanner.l                      |  33 ++++--
 src/util.cpp                       |   9 +-
 src/util.h                         |   4 +-
 src/xmlgen.cpp                     |  13 ++-
 tmake/lib/unix/generic.t           |   2 +-
 42 files changed, 592 insertions(+), 394 deletions(-)

diff --git a/INSTALL b/INSTALL
index e0809c2..d46236f 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,6 +1,6 @@
-DOXYGEN Version 1.2.9.1
+DOXYGEN Version 1.2.9-20010812
 
 Please read the installation section of the manual for instructions.
 
 --------
-Dimitri van Heesch (05 August 2001)
+Dimitri van Heesch (12 August 2001)
diff --git a/README b/README
index f6bbb72..03ddee8 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-DOXYGEN Version 1.2.9.1
+DOXYGEN Version 1.2.9_20010812
 
 Please read INSTALL for compilation instructions.
 
@@ -17,4 +17,4 @@ to subscribe to the lists or to visit the archives.
 
 Enjoy,
 
-Dimitri van Heesch (dimitri@stack.nl) (05 August 2001)
+Dimitri van Heesch (dimitri@stack.nl) (12 August 2001)
diff --git a/VERSION b/VERSION
index 140a505..cdb4ff7 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.2.9.1
+1.2.9-20010812
diff --git a/addon/xmlparse/Doxyfile b/addon/xmlparse/Doxyfile
index bec9537..7899f6b 100644
--- a/addon/xmlparse/Doxyfile
+++ b/addon/xmlparse/Doxyfile
@@ -3,7 +3,7 @@
 #---------------------------------------------------------------------------
 # General configuration options
 #---------------------------------------------------------------------------
-PROJECT_NAME           = dox2html
+PROJECT_NAME           = xmlparse
 PROJECT_NUMBER         = 
 OUTPUT_DIRECTORY       = doc
 OUTPUT_LANGUAGE        = English
@@ -145,8 +145,8 @@ INCLUDE_GRAPH          = YES
 INCLUDED_BY_GRAPH      = YES
 GRAPHICAL_HIERARCHY    = YES
 DOT_PATH               = 
-MAX_DOT_GRAPH_WIDTH    = 3024
-MAX_DOT_GRAPH_HEIGHT   = 3024
+MAX_DOT_GRAPH_WIDTH    = 1280
+MAX_DOT_GRAPH_HEIGHT   = 1024
 GENERATE_LEGEND        = YES
 DOT_CLEANUP            = YES
 #---------------------------------------------------------------------------
diff --git a/addon/xmlparse/basehandler.h b/addon/xmlparse/basehandler.h
index 0bf7c68..6129aa4 100644
--- a/addon/xmlparse/basehandler.h
+++ b/addon/xmlparse/basehandler.h
@@ -115,7 +115,7 @@ template<class T> class BaseHandler : public IBaseHandler,
 
     virtual ~BaseHandler() 
     {
-      delete m_fallBackHandler;
+      ASSERT(m_delegateHandler==0);
     }
 
     virtual bool startDocument() 
diff --git a/addon/xmlparse/compoundhandler.cpp b/addon/xmlparse/compoundhandler.cpp
index c299397..dd81a2a 100644
--- a/addon/xmlparse/compoundhandler.cpp
+++ b/addon/xmlparse/compoundhandler.cpp
@@ -21,6 +21,8 @@ CompoundHandler::CompoundHandler(IBaseHandler *parent)
   : m_parent(parent), m_brief(0), m_detailed(0)
 {
   m_superClasses.setAutoDelete(TRUE);
+  m_subClasses.setAutoDelete(TRUE);
+  m_sections.setAutoDelete(TRUE);
 
   addEndHandler("compounddef",this,&CompoundHandler::endCompound);
 
@@ -42,6 +44,8 @@ CompoundHandler::CompoundHandler(IBaseHandler *parent)
 
 CompoundHandler::~CompoundHandler()
 {
+  delete m_brief;
+  delete m_detailed;
 }
 
 void CompoundHandler::startSection(const QXmlAttributes& attrib)
diff --git a/addon/xmlparse/dochandler.cpp b/addon/xmlparse/dochandler.cpp
index 4e91d8f..7a72763 100644
--- a/addon/xmlparse/dochandler.cpp
+++ b/addon/xmlparse/dochandler.cpp
@@ -163,6 +163,8 @@ void MarkupHandler::endSuperscript()
 ListItemHandler::ListItemHandler(IBaseHandler *parent) 
   : DocNode(ListItem), m_parent(parent)
 {
+  m_children.setAutoDelete(TRUE);
+  
   addEndHandler("listitem",this,&ListItemHandler::endListItem);
 
   addStartHandler("para",this,&ListItemHandler::startParagraph);
@@ -236,6 +238,48 @@ void ListHandler::startListItem(const QXmlAttributes& attrib)
 // ParameterHandler
 //----------------------------------------------------------------------
 
+ParameterHandler::ParameterHandler(IBaseHandler *parent) : DocNode(Parameter),
+  m_parent(parent), m_description(0)
+{
+  addEndHandler("parametername",this,&ParameterHandler::endParameterName);
+  addEndHandler("parameterdescription",this,&ParameterHandler::endParameterDescription);
+  addStartHandler("para",this,&ParameterHandler::startParagraph);
+}
+
+ParameterHandler::~ParameterHandler()
+{
+  delete m_description;
+}
+
+void ParameterHandler::startParameterName(const QXmlAttributes& /*attrib*/)
+{
+  m_parent->setDelegate(this);
+}
+
+void ParameterHandler::endParameterName()
+{
+  m_name = m_curString;
+  printf("parameter %s\n",m_name.data());
+  m_curString="";
+  m_parent->setDelegate(0);
+}
+
+void ParameterHandler::startParameterDescription(const QXmlAttributes& /*attrib*/)
+{
+  m_parent->setDelegate(this);
+}
+
+void ParameterHandler::endParameterDescription()
+{
+  m_parent->setDelegate(0);
+}
+
+void ParameterHandler::startParagraph(const QXmlAttributes& attrib)
+{
+  ASSERT(m_description==0);
+  m_description = new ParagraphHandler(this);
+  m_description->startParagraph(attrib);
+}
 
 //----------------------------------------------------------------------
 // ParameterListHandler
@@ -245,6 +289,10 @@ ParameterListHandler::ParameterListHandler(IBaseHandler *parent)
   : DocNode(ParameterList), m_parent(parent)
 {
   addEndHandler("parameterlist",this,&ParameterListHandler::endParameterList);
+  addStartHandler("parametername",this,&ParameterListHandler::startParameterName);
+  addStartHandler("parameterdescription",this,&ParameterListHandler::startParameterDescription);
+  addStartHandler("title");
+  addEndHandler("title");
   m_parameters.setAutoDelete(TRUE);
   m_curParam=0;
 }
@@ -253,8 +301,17 @@ ParameterListHandler::~ParameterListHandler()
 {
 }
 
-void ParameterListHandler::startParameterList(const QXmlAttributes& /*attrib*/)
+void ParameterListHandler::startParameterList(const QXmlAttributes& attrib)
 {
+  QString kind = attrib.value("kind");
+  if (kind=="retval")         m_type=RetVal;
+  else if (kind=="exception") m_type=Exception;
+  else if (kind=="param")     m_type=Param;
+  else
+  {
+    printf("Error: invalid parameterlist type: %s\n",kind.data());
+  }
+  printf("parameterlist kind=%s\n",kind.data());
   m_parent->setDelegate(this);
 }
 
@@ -263,6 +320,19 @@ void ParameterListHandler::endParameterList()
   m_parent->setDelegate(0);
 }
 
+void ParameterListHandler::startParameterName(const QXmlAttributes& attrib)
+{
+  m_curParam = new ParameterHandler(this);
+  m_parameters.append(m_curParam);
+  m_curParam->startParameterName(attrib);
+}
+
+void ParameterListHandler::startParameterDescription(const QXmlAttributes& attrib)
+{
+  ASSERT(m_curParam!=0);
+  m_curParam->startParameterDescription(attrib);
+}
+
 //----------------------------------------------------------------------
 // ParagraphHandler
 //----------------------------------------------------------------------
@@ -279,10 +349,12 @@ ParagraphHandler::ParagraphHandler(IBaseHandler *parent)
 
   addStartHandler("itemizedlist",this,&ParagraphHandler::startItemizedList);
   addStartHandler("orderedlist",this,&ParagraphHandler::startOrderedList);
+  addStartHandler("parameterlist",this,&ParagraphHandler::startParameterList);
 }
 
 ParagraphHandler::~ParagraphHandler()
 {
+  delete m_markupHandler;
 }
 
 void ParagraphHandler::startParagraph(const QXmlAttributes& /*attrib*/)
@@ -339,6 +411,8 @@ void ParagraphHandler::addTextNode()
 
 DocHandler::DocHandler(IBaseHandler *parent) : m_parent(parent)
 {
+  m_children.setAutoDelete(TRUE);
+
   addEndHandler("briefdescription",this,&DocHandler::endDoc);
   addEndHandler("detaileddescription",this,&DocHandler::endDoc);
 
diff --git a/addon/xmlparse/dochandler.h b/addon/xmlparse/dochandler.h
index 376d6f8..0b11e25 100644
--- a/addon/xmlparse/dochandler.h
+++ b/addon/xmlparse/dochandler.h
@@ -51,7 +51,8 @@ class DocNode
       ItemizedList,
       OrderedList,
       ListItem,
-      ParameterList
+      ParameterList,
+      Parameter
     };
     DocNode(NodeKind k) : m_kind(k) {}
     virtual ~DocNode() {}
@@ -182,8 +183,11 @@ class ParameterHandler : public DocNode,
   public:
     ParameterHandler(IBaseHandler *parent);
     virtual ~ParameterHandler();
-    virtual void startParameterList(const QXmlAttributes& attrib);
-    virtual void endParameterList();
+    virtual void startParameterName(const QXmlAttributes& attrib);
+    virtual void endParameterName();
+    virtual void startParameterDescription(const QXmlAttributes& attrib);
+    virtual void endParameterDescription();
+    virtual void startParagraph(const QXmlAttributes& attrib);
 
   private:
     IBaseHandler     *m_parent;
@@ -201,15 +205,45 @@ class ParameterListHandler : public DocNode,
                              public BaseHandler<ParameterListHandler>
 {
   public:
+    enum Types { Param, RetVal, Exception };
     ParameterListHandler(IBaseHandler *parent);
     virtual ~ParameterListHandler();
     virtual void startParameterList(const QXmlAttributes& attrib);
     virtual void endParameterList();
+    virtual void startParameterName(const QXmlAttributes& attrib);
+    virtual void startParameterDescription(const QXmlAttributes& attrib);
 
   private:
     IBaseHandler            *m_parent;
     QList<ParameterHandler>  m_parameters;
     ParameterHandler        *m_curParam;
+    Types                    m_type;
+};
+
+//-----------------------------------------------------------------------------
+
+/* \brief Node representing a simple section with an unnumbered header.
+ *
+ */
+class SimpleSectHandler : public DocNode, 
+                          public BaseHandler<SimpleSectHandler>
+{
+  public:
+    enum Types { See, Return, Author, Version, 
+                 Since, Date, Bug, Note,
+                 Warning, Par, Deprecated, Pre, 
+                 Post, Invar, Remark, Attention 
+    };
+    SimpleSectHandler(IBaseHandler *parent);
+    virtual ~SimpleSectHandler();
+    virtual void startSimpleSect(const QXmlAttributes& attrib);
+    virtual void endSimpleSect();
+
+  private:
+    IBaseHandler            *m_parent;
+    ParameterHandler        *m_curParam;
+    Types                    m_type;
+    QString                  m_title;
 };
 
 //-----------------------------------------------------------------------------
@@ -252,7 +286,7 @@ class DocHandler : public BaseHandler<DocHandler>
     virtual ~DocHandler();
   private:
     IBaseHandler *m_parent;
-    QList<DocNode> m_children;
+    QList<ParagraphHandler> m_children;
 };
 
 #endif
diff --git a/addon/xmlparse/main.cpp b/addon/xmlparse/main.cpp
index 60f4142..7fdb60a 100644
--- a/addon/xmlparse/main.cpp
+++ b/addon/xmlparse/main.cpp
@@ -55,14 +55,17 @@ int main(int argc,char **argv)
     exit(1);
   }
 
-  QFile xmlFile(argv[1]);
-  MainHandler handler;
-  ErrorHandler errorHandler;
-  QXmlInputSource source( xmlFile );
-  QXmlSimpleReader reader;
-  reader.setContentHandler( &handler );
-  reader.setErrorHandler( &errorHandler );
-  reader.parse( source );
+  //for (;;)
+  //{
+    QFile xmlFile(argv[1]);
+    MainHandler handler;
+    ErrorHandler errorHandler;
+    QXmlInputSource source( xmlFile );
+    QXmlSimpleReader reader;
+    reader.setContentHandler( &handler );
+    reader.setErrorHandler( &errorHandler );
+    reader.parse( source );
+  //}
   
   return 0;
 }
diff --git a/addon/xmlparse/memberhandler.cpp b/addon/xmlparse/memberhandler.cpp
index 4cbe4a6..3198676 100644
--- a/addon/xmlparse/memberhandler.cpp
+++ b/addon/xmlparse/memberhandler.cpp
@@ -33,11 +33,15 @@ MemberHandler::MemberHandler(IBaseHandler *parent)
   addStartHandler("briefdescription",this,&MemberHandler::startBriefDesc);
 
   addStartHandler("detaileddescription",this,&MemberHandler::startDetailedDesc);
+
+  m_params.setAutoDelete(TRUE);
   
 }
 
 MemberHandler::~MemberHandler()
 {
+  delete m_brief;
+  delete m_detailed;
 }
 
 void MemberHandler::startMember(const QXmlAttributes& attrib)
diff --git a/doc/commands.doc b/doc/commands.doc
index cd2a634..d9cf37f 100644
--- a/doc/commands.doc
+++ b/doc/commands.doc
@@ -101,6 +101,7 @@ documentation:
 <li> \refitem cmdnote \note
 <li> \refitem cmdoverload \overload
 <li> \refitem cmdp \p
+<li> \refitem cmdpackage \package
 <li> \refitem cmdpage \page
 <li> \refitem cmdpar \par
 <li> \refitem cmdparam \param
@@ -406,6 +407,8 @@ doxygen. Unrecognized commands are treated as normal text.
  */
 \endverbatim
 
+ You can refer to the main page using \\ref index.
+
  \sa section \ref cmdsection "\\section", 
      section \ref cmdsubsection "\\subsection" and 
      section \ref cmdpage "\\page".
@@ -468,6 +471,13 @@ Public/Protected/Private/... section.
   \endhtmlonly
 
 <hr>
+\subsection cmdpackage \package <name>
+  
+  \addindex \package
+  Indicates that a comment block contains documentation for a
+  Java package with name \<name\>. 
+
+<hr>
 \subsection cmdpage \page <name> (title)
 
   \addindex \page
diff --git a/doc/config.doc b/doc/config.doc
index e4f021d..4d5b92f 100644
--- a/doc/config.doc
+++ b/doc/config.doc
@@ -171,6 +171,7 @@ followed by the descriptions of the tags grouped by category.
 <li> \refitem cfg_strip_from_path STRIP_FROM_PATH
 <li> \refitem cfg_tab_size TAB_SIZE
 <li> \refitem cfg_tagfiles TAGFILES
+<li> \refitem cfg_template_relations TEMPLATE_RELATIONS
 <li> \refitem cfg_toc_expand TOC_EXPAND
 <li> \refitem cfg_treeview_width TREEVIEW_WIDTH
 <li> \refitem cfg_verbatim_headers VERBATIM_HEADERS
@@ -1149,6 +1150,12 @@ TAGFILES = file1=loc1 "file2 = loc2" ... </pre>
  indirect implementation dependencies (inheritance, containment, and
  class references variables) of the class with other documented classes.
 
+\anchor cfg_template_relations
+<dt>\c TEMPLATE_RELATIONS <dd>
+ \addindex TEMPLATE_RELATIONS
+ If the \c TEMPLATE_RELATIONS and \c HAVE_DOT tags are set to \c YES then 
+ doxygen will show the relations between templates and their instances.
+
 \anchor cfg_include_graph
 <dt>\c INCLUDE_GRAPH <dd>
  \addindex INCLUDE_GRAPH 
diff --git a/doc/index.doc b/doc/index.doc
index 99e6d7c..9c030cb 100644
--- a/doc/index.doc
+++ b/doc/index.doc
@@ -173,8 +173,10 @@ Thanks go to:
     Boris Bralo, Nickolay Semyonov, Richard Kim, Földvári György,
     Grzegorz Kowal, and Wang Weihan 
     for providing translations into various languages.
+<li>Erik Jan Lingen of <a href="http://www.habanera.nl/">Habanera</a> for
+    donating money.
 <li>The Comms group of <a href="http://www.symbian.com">Symbian</a> for donating
-    me an ultra cool <a href="http://www.psion.com/revoplus>Revo plus</a> 
+    an ultra cool <a href="http://www.psion.com/revoplus>Revo plus</a> 
     organizer!
 <li>The band <a href="http://www.porcupinetree.com">Porcupine Tree</a> for 
     providing hours of great music to listen to while coding.
diff --git a/doc/preprocessing.doc b/doc/preprocessing.doc
index 19f730d..524f7c5 100644
--- a/doc/preprocessing.doc
+++ b/doc/preprocessing.doc
@@ -152,26 +152,57 @@ for class QList is to define:
 PREDEFINED = QListT:=QList
 \endverbatim
 
-Here is example provided by Valter Minute that helps doxygen to
-wade through the boilerplate code in Microsoft's ATL library:
+Here is an example provided by Valter Minute & Reyes Ponce that helps 
+doxygen to wade through the boilerplate code in Microsoft's ATL & MFC 
+libraries:
 
 \verbatim
-PREDEFINED = DECLARE_REGISTRY_RESOURCEID=// \                                   
-   DECLARE_PROTECT_FINAL_CONSTRUCT=// \                                         
-   BEGIN_COM_MAP=/* \                                    
-   END_COM_MAP=*/// \                                            
-   BEGIN_PROP_MAP=/* \                                   
-   END_PROP_MAP=*/// \                                        
-   BEGIN_MSG_MAP=/* \                                                     
-   END_MSG_MAP=*/// \                                                          
-   DECLARE_VIEW_STATUS=// \
-   "STDMETHOD(a)=HRESULT a" \                                                   
-   "ATL_NO_VTABLE= "\                                                      
-   "__declspec(a)= "\                                                  
-   BEGIN_CONNECTION_POINT_MAP=/* \
-   END_CONNECTION_POINT_MAP=*/// \
-   "DECLARE_AGGREGATABLE(Class)= " \
-   "DECLARE_REGISTRY_RESOURCEID(id)= " 
+PREDEFINED           = "DECLARE_INTERFACE(name)=class name" \
+                       "STDMETHOD(result,name)=virtual result name" \
+                       "PURE= = 0" \
+                       THIS_= \
+                       THIS= \
+                       DECLARE_REGISTRY_RESOURCEID=// \
+                       DECLARE_PROTECT_FINAL_CONSTRUCT=// \
+                       "DECLARE_AGGREGATABLE(Class)= " \
+                       "DECLARE_REGISTRY_RESOURCEID(Id)= " \
+                       DECLARE_MESSAGE_MAP = \
+                       BEGIN_MESSAGE_MAP=/* \
+                       END_MESSAGE_MAP=*/// \
+                       BEGIN_COM_MAP=/* \
+                       END_COM_MAP=*/// \
+                       BEGIN_PROP_MAP=/* \
+                       END_PROP_MAP=*/// \
+                       BEGIN_MSG_MAP=/* \
+                       END_MSG_MAP=*/// \
+                       BEGIN_PROPERTY_MAP=/* \
+                       END_PROPERTY_MAP=*/// \
+                       BEGIN_OBJECT_MAP=/* \
+                       END_OBJECT_MAP()=*/// \
+                       DECLARE_VIEW_STATUS=// \
+                       "STDMETHOD(a)=HRESULT a" \
+                       "ATL_NO_VTABLE= " \
+                       "__declspec(a)= " \
+                       BEGIN_CONNECTION_POINT_MAP=/* \
+                       END_CONNECTION_POINT_MAP=*/// \
+                       "DECLARE_DYNAMIC(class)= " \
+                       "IMPLEMENT_DYNAMIC(class1, class2)= " \
+                       "DECLARE_DYNCREATE(class)= " \
+                       "IMPLEMENT_DYNCREATE(class1, class2)= " \
+                       "IMPLEMENT_SERIAL(class1, class2, class3)= " \
+                       "DECLARE_MESSAGE_MAP()= " \
+                       TRY=try \
+                       "CATCH_ALL(e)= catch(...)" \
+                       END_CATCH_ALL= \
+                       "THROW_LAST()= throw"\
+                       "RUNTIME_CLASS(class)=class" \
+                       "MAKEINTRESOURCE(nId)=nId" \
+                       "IMPLEMENT_REGISTER(v, w, x, y, z)= " \
+                       "ASSERT(x)=assert(x)" \
+                       "ASSERT_VALID(x)=assert(x)" \
+                       "TRACE0(x)=printf(x)" \
+                       "OS_ERR(A,B)={ #A, B }" \
+                       __cplusplus
 \endverbatim
 
 As you can see doxygen's preprocessor is quite powerful, but if you want
diff --git a/packages/rpm/doxygen.spec b/packages/rpm/doxygen.spec
index c802b39..f1ab84e 100644
--- a/packages/rpm/doxygen.spec
+++ b/packages/rpm/doxygen.spec
@@ -1,5 +1,5 @@
 Name: doxygen
-Version: 1.2.9.1
+Version: 1.2.9_20010812
 Summary: documentation system for C, C++ and IDL
 Release: 4
 Source: doxygen-%{version}.src.tar.gz
diff --git a/qtools/qtools.pro.in b/qtools/qtools.pro.in
index f74d7db..57fc1ab 100644
--- a/qtools/qtools.pro.in
+++ b/qtools/qtools.pro.in
@@ -72,7 +72,7 @@ win32:SOURCES +=  qfile_win32.cpp \
 		  qfileinfo_win32.cpp
 
 INCLUDEPATH = .
-TMAKE_CXXFLAGS = -DQT_NO_CODECS -DQT_LITE_UNICODE
+TMAKE_CXXFLAGS += -DQT_NO_CODECS -DQT_LITE_UNICODE
 win32:TMAKE_CXXFLAGS += -DQT_NODLL
 OBJECTS_DIR = ../objects
 DESTDIR = ../lib
diff --git a/src/classdef.cpp b/src/classdef.cpp
index c0feb10..5f93e7a 100644
--- a/src/classdef.cpp
+++ b/src/classdef.cpp
@@ -98,7 +98,7 @@ ClassDef::ClassDef(
   //  m_scopelessName=name().right(name().length()-i-2);
   //}
   m_subGrouping=TRUE;
-  m_isTemplBaseClass=-1;
+  //m_isTemplBaseClass=-1;
   m_templateInstances = 0;
   m_templateMaster =0;
   m_templBaseClassNames = 0;
@@ -1408,13 +1408,34 @@ void ClassDef::setTemplateArguments(ArgumentList *al)
   }
 }
 
-
+/*! Returns \c TRUE iff this class or a class inheriting from this class
+ *  is \e not defined in an external tag file. 
+ */
 bool ClassDef::hasNonReferenceSuperClass()
 {
-  bool found=!isReference();
+  bool found=!isReference(); 
+  if (found) return TRUE; // we're done if this class is not a reference
   BaseClassListIterator bcli(*m_inheritedBy);
-  for ( ; bcli.current() && !found ; ++bcli )
-    found=found || bcli.current()->classDef->hasNonReferenceSuperClass();
+  for ( ; bcli.current() && !found ; ++bcli ) // for each super class
+  {
+    ClassDef *bcd=bcli.current()->classDef;
+    // recurse into the super class branch
+    found = found || bcd->hasNonReferenceSuperClass(); 
+    if (!found)
+    {
+      // look for template instances that might have non-reference super classes
+      QDict<ClassDef> *cil = bcd->getTemplateInstances();
+      if (cil)
+      {
+        QDictIterator<ClassDef> tidi(*cil);
+        for ( ; tidi.current() && !found ; ++tidi) // for each template instance
+        {
+          // recurse into the template instance branch
+          found = found || tidi.current()->hasNonReferenceSuperClass();
+        }
+      }
+    }
+  }
   return found;
 }
 
@@ -1512,28 +1533,50 @@ void ClassDef::writeDeclaration(OutputList &ol,MemberDef *md,bool inGroup)
 /*! a link to this class is possible within this project */
 bool ClassDef::isLinkableInProject() const
 { 
-  return !name().isEmpty() &&    /* no name */
-         m_isTemplBaseClass==-1 &&  /* template base class */
-         name().find('@')==-1 && /* anonymous compound */
-         (m_prot!=Private || Config_getBool("EXTRACT_PRIVATE")) && /* private */
-         hasDocumentation() &&   /* documented */ 
-         !isReference();         /* not an external reference */
+  if (m_templateMaster)
+  {
+    return m_templateMaster->isLinkableInProject();
+  }
+  else
+  {
+    return !name().isEmpty() &&    /* no name */
+      //m_isTemplBaseClass==-1 &&  /* template base class */
+      name().find('@')==-1 && /* anonymous compound */
+      (m_prot!=Private || Config_getBool("EXTRACT_PRIVATE")) && /* private */
+      hasDocumentation() &&   /* documented */ 
+      !isReference();         /* not an external reference */
+  }
+}
+
+bool ClassDef::isLinkable() const
+{
+  if (m_templateMaster)
+  {
+    return m_templateMaster->isLinkable();
+  }
+  else
+  {
+    return isLinkableInProject() || isReference();
+  }
 }
 
+
 /*! the class is visible in a class diagram, or class hierarchy */
 bool ClassDef::isVisibleInHierarchy() 
-{ return // show all classes or a subclass is visible
-    (Config_getBool("ALLEXTERNALS") || hasNonReferenceSuperClass()) &&
-    // and not an annonymous compound
-    name().find('@')==-1 &&
-    // not an artifically introduced class
-    !m_artificial &&
-    // and not an inherited template argument
-    //m_isTemplBaseClass==-1 && 
-    // and not privately inherited
-    (m_prot!=Private || Config_getBool("EXTRACT_PRIVATE")) &&
-    // documented or show anyway or documentation is external 
-    (hasDocumentation() || !Config_getBool("HIDE_UNDOC_CLASSES") || isReference());
+{ 
+    return // show all classes or a subclass is visible
+      (Config_getBool("ALLEXTERNALS") || hasNonReferenceSuperClass()) &&
+      // and not an annonymous compound
+      name().find('@')==-1 &&
+      // not an artifically introduced class
+      !m_artificial &&
+      // and not privately inherited
+      (m_prot!=Private || Config_getBool("EXTRACT_PRIVATE")) &&
+      // documented or shown anyway or documentation is external 
+      (hasDocumentation() || 
+       !Config_getBool("HIDE_UNDOC_CLASSES") || 
+       isReference()
+      );
 }
 
 bool ClassDef::hasDocumentation() const
@@ -1554,6 +1597,7 @@ bool ClassDef::isBaseClass(ClassDef *bcd)
   for ( ; bcli.current() && !found ; ++bcli)
   {
     ClassDef *ccd=bcli.current()->classDef;
+    if (ccd->templateMaster()) ccd=ccd->templateMaster();
     //printf("isBaseClass() baseclass %s\n",ccd->name().data());
     if (ccd==bcd) 
       found=TRUE;
@@ -2212,6 +2256,18 @@ QCString ClassDef::getReference() const
   }
 }
 
+bool ClassDef::isReference() const
+{
+  if (m_templateMaster)
+  {
+    return m_templateMaster->getReference();
+  }
+  else
+  {
+    return Definition::isReference();
+  }
+}
+
 void ClassDef::getTemplateParameterLists(QList<ArgumentList> &lists) const
 {
   Definition *d=getOuterScope();
@@ -2273,4 +2329,23 @@ QCString ClassDef::qualifiedNameWithTemplateParameters(
   return scName;
 }
 
-
+QCString ClassDef::className() const
+{
+  if (!m_className.isEmpty())
+  {
+    return m_className;
+  }
+  else
+  {
+    ClassDef *that = (ClassDef *)this; 
+    // m_className is a cache value, so we fake that this function is "const".
+    that->m_className=m_localName.copy();
+    Definition *p=getOuterScope();
+    while (p && p->definitionType()==TypeClass)
+    {
+      that->m_className.prepend(p->localName()+"::");
+      p=p->getOuterScope();
+    }
+    return m_className;
+  }
+};
diff --git a/src/classdef.h b/src/classdef.h
index 939cd90..51d0112 100644
--- a/src/classdef.h
+++ b/src/classdef.h
@@ -72,6 +72,7 @@ class ClassDef : public Definition
     QCString getFileBase() const;
     QCString getSourceFileBase() const; 
     QCString getReference() const;
+    bool isReference() const;
 
     bool hasDocumentation() const;
 
@@ -114,10 +115,7 @@ class ClassDef : public Definition
     /*! return TRUE iff a link to this class is possible (either within 
      *  this project, or as a cross-reference to another project).
      */
-    bool isLinkable() const
-    {
-      return isLinkableInProject() || isReference();
-    }
+    bool isLinkable() const;
 
     /*! the class is visible in a class diagram, or class hierarchy */
     bool isVisibleInHierarchy();
@@ -153,12 +151,6 @@ class ClassDef : public Definition
      */
     bool isBaseClass(ClassDef *bcd);
 
-    /*! Is this an artificial class that is the template argument of
-     *  a class. If so the argument number is returned, otherwise -1 
-     *  is returned.
-     */
-    int isTemplateBaseClass() const { return m_isTemplBaseClass; }
-
     /*! Returns a sorted dictionary with all template instances found for
      *  this template class. Returns 0 if not a template or no instances.
      */
@@ -200,6 +192,11 @@ class ClassDef : public Definition
      */
     bool isAbstract() const { return m_isAbstract; }
 
+    /*! returns the name of the class including outer classes, but not
+     *  including namespaces.
+     */
+    QCString className() const;
+
     /* member lists by protection */
     MemberList pubMembers;
     MemberList proMembers;
@@ -262,7 +259,6 @@ class ClassDef : public Definition
     void setProtection(Protection p) { m_prot=p; }
     void setGroupDefForAllMembers(GroupDef *g,Grouping::GroupPri_t pri,const QCString &fileName,int startLine,bool hasDocs);
     void addInnerCompound(Definition *d);
-    void setIsTemplateBaseClass(int num) { m_isTemplBaseClass = num; }
     void addUsedClass(ClassDef *cd,const char *accessName);
     //void initTemplateMapping();
     //void setTemplateArgumentMapping(const char *formal,const char *actual);
@@ -384,13 +380,6 @@ class ClassDef : public Definition
     UsesClassDict *m_usesImplClassDict;
     UsesClassDict *m_usesIntfClassDict;
 
-    /*! Is this a class that exists because of template class that 
-     *  inherited one of it's template arguments. If so that this
-     *  variable indicate the template argument number, otherwise
-     *  this is -1
-     */
-    int m_isTemplBaseClass;
-
     /*! Template instances that exists of this class, the key in the
      *  dictionary is the template argument list.
      */ 
@@ -410,6 +399,8 @@ class ClassDef : public Definition
 
     /*! Is this an abstact class? */
     bool m_isAbstract;
+
+    QCString m_className;
 };
 
 /*! \brief Class that contains information about a usage relation. 
diff --git a/src/config.l b/src/config.l
index 3a887a6..cdaeb66 100644
--- a/src/config.l
+++ b/src/config.l
@@ -2038,6 +2038,13 @@ void Config::create()
                  );
   cb->addDependency("HAVE_DOT");
   cb = addBool(
+                    "TEMPLATE_RELATIONS",
+		    "If set to YES, the inheritance and collaboration graphs will show the \n"
+		    "relations between templates and their instances. \n",
+                    TRUE
+                 );
+  cb->addDependency("HAVE_DOT");
+  cb = addBool(
                     "INCLUDE_GRAPH",
                     "If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT \n"
                     "tags are set to YES then doxygen will generate a graph for each documented \n"
diff --git a/src/definition.cpp b/src/definition.cpp
index fc764f7..06d4da7 100644
--- a/src/definition.cpp
+++ b/src/definition.cpp
@@ -34,7 +34,11 @@ Definition::Definition(const char *df,int dl,
   m_defFileName = df;
   m_defLine = dl;
   m_name=name; 
-  m_localName=stripScope(name);
+  if (m_name!="<globalScope>") 
+    m_localName=stripScope(name);
+  else
+    m_localName=name;
+  //printf("m_localName=%s\n",m_localName.data());
   m_brief=b; 
   m_doc=d; 
   m_sectionDict=0, 
diff --git a/src/definition.h b/src/definition.h
index c4ab29a..090dcd5 100644
--- a/src/definition.h
+++ b/src/definition.h
@@ -80,7 +80,7 @@ class Definition
     virtual bool isLinkable() const = 0;
     virtual QCString getReference() const { return m_ref; }
 
-    bool isReference() const { return !m_ref.isEmpty(); }
+    virtual bool isReference() const { return !m_ref.isEmpty(); }
     void setReference(const char *r) { m_ref=r; }
 
     /*! Add the list of anchors that mark the sections that are found in the 
diff --git a/src/doc.l b/src/doc.l
index 974f54b..683c219 100644
--- a/src/doc.l
+++ b/src/doc.l
@@ -1504,7 +1504,7 @@ OPMASK    ({B}*{OPNORM}({OPARG}?))|({OPCAST}{OPARG})
 					    if (inBlock()) endBlock();
 					    inParamBlock=TRUE;
 					    currentListIndent.push("D");
-					    outDoc->startParamList();
+					    outDoc->startParamList(BaseOutputDocInterface::Param);
 					    scanString(theTranslator->trParameters()+": ");
   					    outDoc->endDescTitle();
   					    outDoc->writeDescItem();
@@ -1528,7 +1528,7 @@ OPMASK    ({B}*{OPNORM}({OPARG}?))|({OPCAST}{OPARG})
 					    if (inBlock()) endBlock();
 					    inRetValBlock=TRUE;
 					    currentListIndent.push("D");
-					    outDoc->startParamList();
+					    outDoc->startParamList(BaseOutputDocInterface::RetVal);
 					    scanString(theTranslator->trReturnValues()+": ");
   					    outDoc->endDescTitle();
   					    outDoc->writeDescItem();
@@ -1552,7 +1552,7 @@ OPMASK    ({B}*{OPNORM}({OPARG}?))|({OPCAST}{OPARG})
 					    if (inBlock()) endBlock();
 					    inExceptionBlock=TRUE;
 					    currentListIndent.push("D");
-					    outDoc->startParamList();
+					    outDoc->startParamList(BaseOutputDocInterface::Exception);
 					    scanString(theTranslator->trExceptions()+": ");
   					    outDoc->endDescTitle();
 					    outDoc->writeDescItem();
diff --git a/src/dot.cpp b/src/dot.cpp
index 88e0571..bd13f75 100644
--- a/src/dot.cpp
+++ b/src/dot.cpp
@@ -40,7 +40,8 @@ static const char *edgeColorMap[] =
   "darkgreen",     // Protected
   "firebrick4",    // Private
   "darkorchid3",   // "use" relation
-  "grey75"         // Undocumented
+  "grey75",        // Undocumented
+  "orange"         // template relation
 };
 
 static const char *edgeStyleMap[] =
@@ -177,153 +178,6 @@ static bool isLeaf(ClassDef *cd)
   return TRUE;
 }
 
-#if 0
-/*! Builds a mapping from formal arguments of class \a tcd to the
- *  actual arguments stored in templSpec. To properly initialize
- *  the mapping with the default template values 
- *  ClassDef::initTemplateMapping() is called once for each class graph
- *  (the ClassDef::visited flag is used for this).
- */
-static void setTemplateInstance(QCString templSpec,ClassDef *tcd)
-{
-  //printf("====== setTemplateInstance(templ=%s,class=%s)\n",templSpec.data(),tcd->name().data());
-  if (!templSpec.isEmpty())
-  {
-    //if (!tcd->visited)
-    //{
-    //  tcd->visited=TRUE;
-    //}
-    ArgumentList *tempArgList = new ArgumentList;
-    stringToArgumentList(templSpec,tempArgList);
-    ArgumentListIterator ali(*tempArgList);
-    Argument *arg;
-    uint count=0;
-    for (ali.toFirst();(arg=ali.current());++ali,++count)
-    {
-      ArgumentList *formalArgList = tcd->templateArguments();
-      Argument *formalArg=0;
-      //printf("arg->type=%s count=%d formalArgList=%p\n",
-      //    arg->type.data(),count,formalArgList);
-      if (formalArgList && formalArgList->count()>count &&
-          (formalArg=formalArgList->at(count)))
-      {
-        if (formalArg->name!=arg->type)
-        {
-          tcd->setTemplateArgumentMapping(formalArg->name,arg->type);
-          //printf("%s->setTemplateInstantation(%s,%s)\n",tcd->name().data(),
-          //    formalArg->name.data(),arg->type.data());
-        }
-      }
-    }
-    delete tempArgList;
-  }
-}
-
-/*! Substitutes the formal template argument list \a templSpec 
- *  of class \a cd with the actual template arguments.
- *  The mapping from formal to actual template is assumed to be stored
- *  in \a cd using setTemplateInstance().
- */
-static QCString substituteTemplateSpec(ClassDef *cd,const QCString &templSpec)
-{
-  QCString result;
-  if (!templSpec.isEmpty())
-  {
-    ArgumentList *tempArgList = new ArgumentList;
-    stringToArgumentList(templSpec,tempArgList);
-    ArgumentListIterator ali(*tempArgList);
-    Argument *arg;
-    bool first=TRUE;
-    for (ali.toFirst();(arg=ali.current());)
-    {
-      if (first) result="<",first=FALSE;
-      QCString actual = cd->getTemplateArgumentMapping(arg->type);
-      if (!actual.isEmpty())
-      {
-        result+=actual;
-      }
-      else
-      {
-        result+=arg->type;
-      }
-      ++ali;
-      if (ali.current()) result+=","; else result+=">";
-    }
-    delete tempArgList;
-  }
-  //printf("substituteTemplateSpec(%s,%s)=`%s'\n",cd->name().data(),templSpec.data(),result.data());
-  return removeRedundantWhiteSpace(result);
-}
-
-/*! Determines the actual template instance of template class \a tcd that
- *  relates to class \a cd. The result is stored in \a tcd.
- *  \param cd A class
- *  \param tcd A template base class
- *  \param templSpec Actual template parameter list to be used for tcd
- *  \param result resulting instance class
- *  \param actualArg actual template instance name of the resulting class
- */
-static void computeTemplateInstance(
-                ClassDef *cd,ClassDef *tcd,const QCString templSpec,
-                ClassDef *&result,QCString &actualArg
-                                 
-                               )
-{
-  //printf("====== computeTemplateInstance(%s,base=%s,templ=%s)\n",
-  //           cd->name().data(),tcd->name().data(),templSpec.data());
-  // store the specific instance inside the class
-  setTemplateInstance(templSpec,tcd);
-  int tArgNum = tcd->isTemplateBaseClass();
-  if (tArgNum!=-1)
-  {
-    //printf("tArgNum=%d\n",tArgNum);
-    ArgumentList *formalArgList = cd->templateArguments();
-    if (formalArgList)
-    {
-      //printf("formalArgList=%p\n",formalArgList);
-      Argument *formalArg=formalArgList->at(tArgNum);
-      if (formalArg)
-      {
-        //printf("formalArg=%s\n",formalArg->name.data());
-        actualArg = cd->getTemplateArgumentMapping(formalArg->name);
-        //printf("ActualArg=%s\n",actualArg.data());
-        int pos=0;
-        QCString name;
-        QCString templSpec;
-        while (extractClassNameFromType(actualArg,pos,name,templSpec))
-        {
-          Definition *scopeDef = cd->getOuterScope();
-          QCString scopeName;
-          if (scopeDef) scopeName = scopeDef->qualifiedName();
-          //printf("name=%s templSpec=%s\n",name.data(),templSpec.data());
-          ClassDef *acd=0;
-         
-          // try with scope.
-          if (!scopeName.isEmpty()) 
-            acd = getResolvedClass(scopeName+"::"+name);
-          // try without scope.
-          // TODO: try intermediate scopes as well!
-          if (acd==0) acd = getResolvedClass(name);
-          if (acd && !templSpec.isEmpty()) 
-          {
-            // store specific template instance in the class
-            setTemplateInstance(templSpec,acd);
-          }
-          if (acd)
-          {
-            result = acd;
-            actualArg = acd->name()+templSpec;
-            return;
-          }
-        }
-      }
-    }
-  }
-  actualArg.resize(0);
-  result = 0;
-}
-#endif
-
 //--------------------------------------------------------------------
 
 class DotNodeList : public QList<DotNode>
@@ -932,7 +786,7 @@ int DotClassGraph::m_curNodeNumber;
 void DotClassGraph::addClass(ClassDef *cd,DotNode *n,int prot,
     const char *label,int distance,const char *usedName,const char *templSpec,bool base)
 {
-  int edgeStyle = label ? EdgeInfo::Dashed : EdgeInfo::Solid;
+  int edgeStyle = (label || prot==EdgeInfo::Orange) ? EdgeInfo::Dashed : EdgeInfo::Solid;
   QCString className;
   if (usedName) // name is a typedef
   {
@@ -997,34 +851,22 @@ void DotClassGraph::addClass(ClassDef *cd,DotNode *n,int prot,
 
 void DotClassGraph::buildGraph(ClassDef *cd,DotNode *n,int distance,bool base)
 {
+  // ---- Add inheritance relations
+
   BaseClassListIterator bcli(base ? *cd->baseClasses() : *cd->subClasses());
   BaseClassDef *bcd;
   for ( ; (bcd=bcli.current()) ; ++bcli )
   {
     //printf("-------- inheritance relation %s->%s templ=`%s'\n",
     //            cd->name().data(),bcd->classDef->name().data(),bcd->templSpecifiers.data());
-    //QCString templSpec; 
-    //if (base) templSpec = substituteTemplateSpec(
-    //                         cd,bcd->templSpecifiers);
-    //ClassDef *acd=0;
-    //QCString actualArg;
-    //computeTemplateInstance(cd,bcd->classDef,templSpec,acd,actualArg);
-    //printf("acd=%p actualArg=%s\n",acd,actualArg.data());
-    //if (acd)
-    //{
-    //  addClass(acd,n,bcd->prot,0,distance,actualArg, 
-    //           templSpec,base); 
-    //}
-    //else
-    //{
-    //  addClass(bcd->classDef,n,bcd->prot,0,distance,bcd->usedName,
-    //           templSpec,base); 
-    //}
     addClass(bcd->classDef,n,bcd->prot,0,distance,bcd->usedName,
                bcd->templSpecifiers,base); 
   }
   if (m_graphType != Inheritance)
   {
+
+    // ---- Add usage relations
+    
     UsesClassDict *dict = 
       m_graphType==Implementation ? cd->usedImplementationClasses() :
                                     cd->usedInterfaceClasses();
@@ -1050,30 +892,48 @@ void DotClassGraph::buildGraph(ClassDef *cd,DotNode *n,int distance,bool base)
             label+=QCString("\\n")+s;
           }
         }
-        //QCString actualArg;
-        //ClassDef *acd=0;
-        //printf("-------- usage relation %s->%s templ=`%s'\n",
-        //    cd->name().data(),ucd->classDef->name().data(),
-        //    ucd->templSpecifiers.data());
-        //QCString templSpec = substituteTemplateSpec(
-        //                             cd,ucd->templSpecifiers);
-        //computeTemplateInstance(cd,ucd->classDef, templSpec, acd,actualArg);
-        //if (acd)
-        //{
-        //  addClass(acd,n,EdgeInfo::Black,label,distance,actualArg,
-        //           templSpec,base); 
-        //}
-        //else
-        //{
-        //  //printf("Found label=`%s'\n",label.data());
-        //  addClass(ucd->classDef,n,EdgeInfo::Black,label,distance,0,
-        //           templSpec,base);
-        //}
-        addClass(ucd->classDef,n,EdgeInfo::Black,label,distance,0,
+        addClass(ucd->classDef,n,EdgeInfo::Purple,label,distance,0,
                  ucd->templSpecifiers,base);
       }
     }
   }
+
+  // ---- Add template instantiation relations
+
+  if (Config_getBool("TEMPLATE_RELATIONS"))
+  {
+    if (base) // template relations for base classes
+    {
+      ClassDef *templMaster=cd->templateMaster();
+      if (templMaster)
+      {
+        QDictIterator<ClassDef> cli(*templMaster->getTemplateInstances());
+        ClassDef *templInstance;
+        for (;(templInstance=cli.current());++cli)
+        {
+          if (templInstance==cd)
+          {
+            addClass(templMaster,n,EdgeInfo::Orange,cli.currentKey(),distance,0,
+                0,TRUE);
+          }
+        }
+      }
+    }
+    else // template relations for super classes
+    {
+      QDict<ClassDef> *templInstances = cd->getTemplateInstances();
+      if (templInstances)
+      {
+        QDictIterator<ClassDef> cli(*templInstances);
+        ClassDef *templInstance;
+        for (;(templInstance=cli.current());++cli)
+        {
+          addClass(templInstance,n,EdgeInfo::Orange,cli.currentKey(),distance,0,
+              0,FALSE);
+        }
+      }
+    }
+  }
 }
 
 DotClassGraph::DotClassGraph(ClassDef *cd,GraphType t,int maxRecursionDepth)
diff --git a/src/dot.h b/src/dot.h
index bfd518e..9b64998 100644
--- a/src/dot.h
+++ b/src/dot.h
@@ -30,7 +30,7 @@ enum GraphOutputFormat { GIF , EPS };
 
 struct EdgeInfo
 {
-  enum Colors { Blue=0, Green=1, Red=2, Black=3, Grey=4 };
+  enum Colors { Blue=0, Green=1, Red=2, Purple=3, Grey=4, Orange=5 };
   enum Styles { Solid=0, Dashed=1 };
   EdgeInfo() : m_color(0), m_style(0), m_labColor(0) {}
  ~EdgeInfo() {}
@@ -60,7 +60,7 @@ class DotNode
     DotNode(int n,const char *lab,const char *url,int distance = 0,bool rootNode=FALSE);
    ~DotNode();
     void addChild(DotNode *n,
-                  int edgeColor=EdgeInfo::Black,
+                  int edgeColor=EdgeInfo::Purple,
                   int edgeStyle=EdgeInfo::Solid,
                   const char *edgeLab=0,
                   const char *edgeURL=0,
diff --git a/src/doxygen.cpp b/src/doxygen.cpp
index 70f7d98..6771f9c 100644
--- a/src/doxygen.cpp
+++ b/src/doxygen.cpp
@@ -2527,7 +2527,7 @@ static void findUsedClassesForClass(Entry *root,
                   usedCd = new ClassDef(
                      masterCd->getDefFileName(),masterCd->getDefLine(),
                      usedName,ClassDef::Class);
-                  usedCd->setIsTemplateBaseClass(count);
+                  //usedCd->setIsTemplateBaseClass(count);
                   Doxygen::hiddenClasses.inSort(usedName,usedCd);
                 }
                 if (isArtificial) usedCd->setClassIsArtificial();
@@ -2599,36 +2599,43 @@ static void findBaseClassesForClass(
   BaseInfo *bi=0;
   for (bii.toFirst();(bi=bii.current());++bii)
   {
-    bool delTempNames=FALSE;
-    if (templateNames==0)
-    {
-      templateNames = getTemplateArgumentsInName(formalArgs,bi->name);
-      delTempNames=TRUE;
-    }
-    BaseInfo tbi(bi->name,bi->prot,bi->virt);
-    if (actualArgs) // substitute the formal template arguments of the base class
-    {
-      tbi.name = substituteTemplateArgumentsInString(bi->name,formalArgs,actualArgs);
-    }
+    //printf("masterCd=%s bi->name=%s\n",masterCd->localName().data(),bi->name.data());
+    //if ( masterCd->localName()!=bi->name.left(masterCd->localName().length()) 
+    //     || bi->name.at(masterCd->localName().length())!='<'
+    //   ) // to avoid recursive lock-up in cases like 
+    //     // template<typename T> class A : public A<typename T::B>
+    //{
+      bool delTempNames=FALSE;
+      if (templateNames==0)
+      {
+        templateNames = getTemplateArgumentsInName(formalArgs,bi->name);
+        delTempNames=TRUE;
+      }
+      BaseInfo tbi(bi->name,bi->prot,bi->virt);
+      if (actualArgs) // substitute the formal template arguments of the base class
+      {
+        tbi.name = substituteTemplateArgumentsInString(bi->name,formalArgs,actualArgs);
+      }
 
-    if (mode==DocumentedOnly)
-    {
-      // find a documented base class in the correct scope
-      if (!findClassRelation(root,instanceCd,&tbi,templateNames,DocumentedOnly,isArtificial))
+      if (mode==DocumentedOnly)
       {
-        // no documented base class -> try to find an undocumented one
-        findClassRelation(root,instanceCd,&tbi,templateNames,Undocumented,isArtificial);
+        // find a documented base class in the correct scope
+        if (!findClassRelation(root,instanceCd,&tbi,templateNames,DocumentedOnly,isArtificial))
+        {
+          // no documented base class -> try to find an undocumented one
+          findClassRelation(root,instanceCd,&tbi,templateNames,Undocumented,isArtificial);
+        }
       }
-    }
-    else if (mode==TemplateInstances)
-    {
-      findClassRelation(root,instanceCd,&tbi,templateNames,TemplateInstances,isArtificial);
-    }
-    if (delTempNames)
-    {
-      delete templateNames;
-      templateNames=0;
-    }  
+      else if (mode==TemplateInstances)
+      {
+        findClassRelation(root,instanceCd,&tbi,templateNames,TemplateInstances,isArtificial);
+      }
+      if (delTempNames)
+      {
+        delete templateNames;
+        templateNames=0;
+      }  
+    //}
   }
 }
 
@@ -2736,9 +2743,11 @@ static bool findClassRelation(
       //                     baseClass?baseClass->name().data():"<none>",
       //                     templSpec.data()
       //      );
-      if (baseClassName!=root->name) // Check for base class with the same name.
-                                     // If found then look in the outer scope for a match
-                                     // and prevent recursion.
+      if (baseClassName.left(root->name.length())!=root->name ||
+          baseClassName.at(root->name.length())!='<'
+         ) // Check for base class with the same name.
+           // If found then look in the outer scope for a match
+           // and prevent recursion.
       {
         Debug::print(
             Debug::Classes,0,"    class relation %s inherited by %s found (%s and %s)\n",
@@ -2942,17 +2951,17 @@ static bool findClassRelation(
           baseClass->insertUsedFile(root->fileName);
           // is this an inherited template argument?
           //printf("%s->setIsTemplateBaseClass(%d)\n",baseClass->name().data(),isTemplBaseClass);
-          if (isATemplateArgument)
-          {
-            baseClass->setIsTemplateBaseClass(*templateNames->find(bi->name));
-          }
+          //if (isATemplateArgument)
+          //{
+          //  baseClass->setIsTemplateBaseClass(*templateNames->find(bi->name));
+          //}
           // add class to the list
-          if (!isATemplateArgument)
-          {
-          }
-          else
-          {
-          }
+          //if (!isATemplateArgument)
+          //{
+          //}
+          //else
+          //{
+          //}
           return TRUE;
         }
         else
@@ -3117,10 +3126,6 @@ static void computeTemplateClassRelations()
       for (tdi.toFirst();(tcd=tdi.current());++tdi) // for each template instance
       {
         Debug::print(Debug::Classes,0,"    Template instance %s : \n",tcd->name().data());
-        //QCString templName = tcd->name();
-        //int index = templName.find('<');
-        //ASSERT(index!=-1);
-        //  templName.right(templName.length()-index);
         QCString templSpec = tdi.currentKey().data();
         ArgumentList *templArgs = new ArgumentList;
         stringToArgumentList(templSpec,templArgs);
@@ -3214,7 +3219,7 @@ static void computeMemberReferences()
 
 //----------------------------------------------------------------------
 
-static void addClassMemberTodoTestBufReferences(Definition *compound)
+static void addClassMemberTodoTestBugReferences(Definition *compound)
 {
   MemberNameListIterator mnli(Doxygen::memberNameList);
   MemberName *mn=0;
@@ -3229,7 +3234,7 @@ static void addClassMemberTodoTestBufReferences(Definition *compound)
       if (d) scopeName=d->name();
       if (d==0) d=md->getGroupDef();
       if (d==0) d=md->getFileDef();
-      if (compound==d || (compound==0 && d!=0 && !md->visited))
+      if (d!=0 && ((compound==0 && !md->visited) || compound==d))
       {
         QCString memLabel;
         md->visited=TRUE;
@@ -3247,7 +3252,7 @@ static void addClassMemberTodoTestBufReferences(Definition *compound)
   }
 }
 
-static void addFileMemberTodoTestBufReferences(Definition *compound)
+static void addFileMemberTodoTestBugReferences(Definition *compound)
 {
   MemberNameListIterator fnli(Doxygen::functionNameList);
   MemberName *mn=0;
@@ -3262,7 +3267,7 @@ static void addFileMemberTodoTestBufReferences(Definition *compound)
       if (d) scopeName=d->name();
       if (d==0) d=md->getGroupDef();
       if (d==0) d=md->getFileDef();
-      if (compound==d || (compound==0 && d!=0 && !md->visited))
+      if (d!=0 && ((compound==0 && !md->visited) || compound==d))
       {
         QCString memLabel;
         md->visited=TRUE;
@@ -3312,7 +3317,7 @@ static void addTodoTestBugReferences()
                theTranslator->trClass(TRUE,TRUE),
                cd->getOutputFileBase(),cd->name()
               );
-    addClassMemberTodoTestBufReferences(cd);
+    addClassMemberTodoTestBugReferences(cd);
   } 
   FileName *fn=Doxygen::inputNameList.first();
   while (fn)
@@ -3323,7 +3328,7 @@ static void addTodoTestBugReferences()
       addRefItem(fd->todoId(),fd->testId(),fd->bugId(),
                  theTranslator->trFile(TRUE,TRUE),
                  fd->getOutputFileBase(),fd->name());
-      addFileMemberTodoTestBufReferences(fd);
+      addFileMemberTodoTestBugReferences(fd);
       fd=fn->next();
     }
     fn=Doxygen::inputNameList.next();
@@ -3334,7 +3339,7 @@ static void addTodoTestBugReferences()
     addRefItem(nd->todoId(),nd->testId(),nd->bugId(),
                theTranslator->trNamespace(TRUE,TRUE),
                nd->getOutputFileBase(),nd->name());
-    addFileMemberTodoTestBufReferences(nd);
+    addFileMemberTodoTestBugReferences(nd);
     nd=Doxygen::namespaceList.next();
   }
   GroupDef *gd=Doxygen::groupList.first();
@@ -3343,7 +3348,7 @@ static void addTodoTestBugReferences()
     addRefItem(gd->todoId(),gd->testId(),gd->bugId(),
                theTranslator->trGroup(TRUE,TRUE),
                gd->getOutputFileBase(),gd->groupTitle());
-    addFileMemberTodoTestBufReferences(gd);
+    addFileMemberTodoTestBugReferences(gd);
     gd=Doxygen::groupList.next();
   }
   PageSDictIterator pdi(*Doxygen::pageSDict);
@@ -3354,8 +3359,8 @@ static void addTodoTestBugReferences()
                theTranslator->trPage(TRUE,TRUE),
                pi->name,pi->title);
   }
-  addClassMemberTodoTestBufReferences(0);
-  addFileMemberTodoTestBufReferences(0);
+  addClassMemberTodoTestBugReferences(0);
+  addFileMemberTodoTestBugReferences(0);
 }
 
 
@@ -5143,8 +5148,8 @@ static void generateClassDocs()
   {
     ClassDef *cd=cli.current();
     if ( cd->isLinkableInProject() && cd->templateMaster()==0 &&
-        (cd->getOuterScope()==0 || 
-         cd->getOuterScope()->definitionType()!=Definition::TypeClass
+        (cd->getOuterScope()==0 || // <-- should not happen
+         cd->getOuterScope()==Doxygen::globalScope
         )
        ) // skip external references, anonymous compounds and 
          // template instances and nested classes
@@ -5465,10 +5470,10 @@ static void findMainPage(Entry *root)
  */
 static void buildPackageList(Entry *root)
 {
-  if (root->section == Entry::PACKAGE_SEC)
+  if (root->section == Entry::PACKAGE_SEC || root->section == Entry::PACKAGEDOC_SEC && !root->name.isEmpty())
   {
     PackageDef *pd=0;
-    if (!root->name.isEmpty() && (pd=Doxygen::packageDict.find(root->name))==0)
+    if ((pd=Doxygen::packageDict.find(root->name))==0)
     {
       QCString tagName;
       if (root->tagInfo)
@@ -5477,16 +5482,26 @@ static void buildPackageList(Entry *root)
       }
       pd = new PackageDef(root->fileName,root->startLine,root->name,tagName);
       Doxygen::packageDict.inSort(root->name,pd);
+      pd->setDocumentation(root->doc);
+      pd->setBriefDescription(root->brief);
     } 
-    if (pd)
+    else
     {
-      bool ambig;
-      FileDef *fd=findFileDef(Doxygen::inputNameDict,root->fileName,ambig);
-      if (fd)
+      if (!pd->documentation() && !root->doc.isEmpty())
+      {
+        pd->setDocumentation(root->doc);
+      }
+      if (!pd->briefDescription() && !root->brief.isEmpty())
       {
-        fd->setPackageDef(pd);
+        pd->setBriefDescription(root->brief);
       }
     }
+    bool ambig;
+    FileDef *fd=findFileDef(Doxygen::inputNameDict,root->fileName,ambig);
+    if (fd)
+    {
+      fd->setPackageDef(pd);
+    }
   }
   EntryListIterator eli(*root->sublist);
   Entry *e;
@@ -5498,6 +5513,8 @@ static void buildPackageList(Entry *root)
 
 //----------------------------------------------------------------------------
 
+//----------------------------------------------------------------------------
+
 /*! Add Java classes to their respective packages */
 static void addClassesToPackages()
 {
@@ -5730,6 +5747,22 @@ static void generateNamespaceDocs()
       msg("Generating docs for namespace %s\n",nd->name().data());
       nd->writeDocumentation(*outputList);
     }
+    ClassSDict::Iterator cli(Doxygen::classSDict);
+    for ( ; cli.current() ; ++cli )
+    {
+      ClassDef *cd=cli.current();
+      if ( cd->getOuterScope()==nd &&
+           cd->isLinkableInProject() && 
+           cd->templateMaster()==0
+         ) // skip external references, anonymous compounds and 
+           // template instances and nested classes
+      {
+        msg("Generating docs for compound %s...\n",cd->name().data());
+
+        cd->writeDocumentation(*outputList);
+        cd->writeMemberList(*outputList);
+      }
+    }
   }
 }
 
diff --git a/src/entry.h b/src/entry.h
index 3a68808..146ce57 100644
--- a/src/entry.h
+++ b/src/entry.h
@@ -215,7 +215,8 @@ class Entry
       MAINPAGEDOC_SEC  = 0x01200000,
       MEMBERGRP_SEC    = 0x01300000,
       USINGDECL_SEC    = 0x01400000,
-      PACKAGE_SEC      = 0x01500000
+      PACKAGE_SEC      = 0x01500000,
+      PACKAGEDOC_SEC   = 0x01600000,
     };
     enum MemberSpecifier
     {
diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp
index da43e85..a69d631 100644
--- a/src/htmlgen.cpp
+++ b/src/htmlgen.cpp
@@ -899,7 +899,7 @@ void HtmlGenerator::endMemberDocName()
 void HtmlGenerator::startParameterList()
 {
   DBG_HTML(t << "<!-- startParameterList -->" << endl;)
-  t << "          <td class=\"md\">(&nbsp</td>" << endl;
+  t << "          <td class=\"md\">(&nbsp;</td>" << endl;
 }
 
 void HtmlGenerator::startParameterType(bool first)
@@ -948,7 +948,7 @@ void HtmlGenerator::endParameterName(bool last,bool emptyList)
       t << "        </tr>" << endl;
       t << "        <tr>" << endl;
       t << "          <td></td>" << endl;
-      t << "          <td class=\"md\">)&nbsp</td>" << endl;
+      t << "          <td class=\"md\">)&nbsp;</td>" << endl;
       t << "          <td class=\"md\" colspan=\"2\">";
     }
   }
diff --git a/src/htmlgen.h b/src/htmlgen.h
index 9bc9ffb..6f60593 100644
--- a/src/htmlgen.h
+++ b/src/htmlgen.h
@@ -176,11 +176,12 @@ class HtmlGenerator : public OutputGenerator
     void writeRing(char c)    { t << "&" << c << "ring;"; }
     void writeSharpS()        { t << "&szlig;"; }
     void writeCCedil(char c)  { t << "&" << c << "cedil;"; }
-    void startDescList()      { t << "<dl compact><dt>" << endl; }
+    void startDescList()      { t << "<dl compact><dt><b>" << endl; }
     void endDescList()        { t << "</dl>"; }
-    void startParamList()     { startDescList(); }
+    void startParamList(ParamListTypes)     
+                              { startDescList(); }
     void endParamList()       { endDescList(); }
-    void endDescTitle()       {}
+    void endDescTitle()       { t << "</b>"; }
     void writeDescItem()      { t << "<dd>" << endl; }
     void startSection(const char *,const char *,bool);
     void endSection(const char *,bool);
diff --git a/src/index.cpp b/src/index.cpp
index 5e3e53f..d1ea611 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -1194,10 +1194,10 @@ void writeAlphabeticalClassList(OutputList &ol)
   {
     if (cd->isLinkableInProject() && cd->templateMaster()==0)
     {
-      int index = getPrefixIndex(cd->localName());
-      if (toupper(cd->name().at(index))!=startLetter) // new begin letter => new header
+      int index = getPrefixIndex(cd->className());
+      if (toupper(cd->className().at(index))!=startLetter) // new begin letter => new header
       {
-        startLetter=toupper(cd->name().at(index));
+        startLetter=toupper(cd->className().at(index));
         headerItems++;
       }
     }
@@ -1227,11 +1227,11 @@ void writeAlphabeticalClassList(OutputList &ol)
   {
     if (cd->isLinkableInProject() && cd->templateMaster()==0)
     {
-      int index = getPrefixIndex(cd->localName());
-      if (toupper(cd->name().at(index))!=startLetter)
+      int index = getPrefixIndex(cd->className());
+      if (toupper(cd->className().at(index))!=startLetter)
       {
         // insert a new header using a dummy class pointer.
-        startLetter=toupper(cd->name().at(index));
+        startLetter=toupper(cd->className().at(index));
         colList[col].append((ClassDef *)8); // insert dummy for the header
         row++;
         if ( row >= rows + ((col<itemsInLastRow) ? 0 : -1)) 
@@ -1275,8 +1275,8 @@ void writeAlphabeticalClassList(OutputList &ol)
         if (cd)
         {
           //printf("head ClassDef=%p %s\n",cd,cd ? cd->name().data() : "<none>");
-          int index = getPrefixIndex(cd->localName());
-          startLetter=toupper(cd->name().at(index));
+          int index = getPrefixIndex(cd->className());
+          startLetter=toupper(cd->className().at(index));
           char s[2]; s[0]=startLetter; s[1]=0;
           ol.writeIndexHeading(s);
         }
@@ -1291,7 +1291,7 @@ void writeAlphabeticalClassList(OutputList &ol)
         }
         else
         {
-          extractNamespaceName(cd->name(),cname,namesp);
+          cname=cd->className();
         }
 
         ol.writeObjectLink(cd->getReference(),
diff --git a/src/latexgen.h b/src/latexgen.h
index f2fca5a..51d2b61 100644
--- a/src/latexgen.h
+++ b/src/latexgen.h
@@ -185,7 +185,8 @@ class LatexGenerator : public OutputGenerator
     void endMemberDescription() { t << "\\item\\end{CompactList}"; }
     void startDescList()     { t << "\\begin{Desc}\n\\item["; }
     void endDescList()       { t << "\\end{Desc}" << endl; }
-    void startParamList()    { startDescList(); }
+    void startParamList(ParamListTypes)    
+                             { startDescList(); }
     void endParamList()      { endDescList(); }
     void endDescTitle()      { t << "]"; }
     void writeDescItem()     { t << "\\par" << endl; }
diff --git a/src/mangen.h b/src/mangen.h
index 92fcc3a..4a03abb 100644
--- a/src/mangen.h
+++ b/src/mangen.h
@@ -172,7 +172,7 @@ class ManGenerator : public OutputGenerator
     void endMemberDescription()   { t << "\\fP\""; firstCol=FALSE; }
     void startDescList();
     void endDescList()        {}
-    void startParamList()     { startDescList(); }
+    void startParamList(ParamListTypes)     { startDescList(); }
     void endParamList()       { endDescList(); }
     void endDescTitle();
     void writeDescItem();
diff --git a/src/memberdef.cpp b/src/memberdef.cpp
index 9c04b94..f230ea6 100644
--- a/src/memberdef.cpp
+++ b/src/memberdef.cpp
@@ -359,10 +359,29 @@ MemberDef::~MemberDef()
   delete m_defTmpArgLists;
 }
 
+void MemberDef::setReimplements(MemberDef *md)   
+{ 
+  if (m_templateMaster) 
+  {
+    m_templateMaster->setReimplements(md);
+  }
+  else
+  {
+    redefines=md; 
+  }
+}
+
 void MemberDef::insertReimplementedBy(MemberDef *md)
 {
-  if (redefinedBy==0) redefinedBy = new MemberList;
-  redefinedBy->inSort(md);
+  if (m_templateMaster)
+  {
+    m_templateMaster->insertReimplementedBy(md);
+  }
+  else
+  {
+    if (redefinedBy==0) redefinedBy = new MemberList;
+    redefinedBy->inSort(md);
+  }
 }
 
 void MemberDef::insertEnumField(MemberDef *md)
@@ -1472,18 +1491,31 @@ void MemberDef::warnIfUndocumented()
 
 bool MemberDef::isLinkableInProject() const
 {
-  return !name().isEmpty() && name().at(0)!='@' &&
-         ((hasDocumentation() && !isReference())  
-         ) && 
-         (prot!=Private || Config_getBool("EXTRACT_PRIVATE") || 
-          mtype==Friend) && // not a hidden member due to protection
-         (classDef!=0 || Config_getBool("EXTRACT_STATIC") || 
-          !isStatic()); // not a static file/namespace member
+  if (m_templateMaster)
+  {
+    return m_templateMaster->isLinkableInProject();
+  }
+  else
+  {
+    return !name().isEmpty() && name().at(0)!='@' &&
+      (hasDocumentation() && !isReference()) && 
+      (prot!=Private || Config_getBool("EXTRACT_PRIVATE") || 
+      mtype==Friend) && // not a hidden member due to protection
+      (classDef!=0 || Config_getBool("EXTRACT_STATIC") || 
+      !isStatic()); // not a static file/namespace member
+  }
 }
 
 bool MemberDef::isLinkable() const
 {
-  return isLinkableInProject() || isReference();
+  if (m_templateMaster)
+  {
+    return m_templateMaster->isLinkable();
+  }
+  else
+  {
+    return isLinkableInProject() || isReference();
+  }
 }
 
 void MemberDef::setEnumDecl(OutputList &ed) 
diff --git a/src/memberdef.h b/src/memberdef.h
index 9f28afc..7e8c773 100644
--- a/src/memberdef.h
+++ b/src/memberdef.h
@@ -161,7 +161,7 @@ class MemberDef : public Definition
     void warnIfUndocumented();
     
     // relation to other members
-    void setReimplements(MemberDef *md)   { redefines=md; }
+    void setReimplements(MemberDef *md);
     void insertReimplementedBy(MemberDef *md);
     MemberDef  *reimplements() const      { return redefines; }
     MemberList *reimplementedBy() const   { return redefinedBy; }
diff --git a/src/outputgen.h b/src/outputgen.h
index 7253c11..8d05ef5 100644
--- a/src/outputgen.h
+++ b/src/outputgen.h
@@ -40,6 +40,7 @@ class DotGfxHierarchyTable;
 class BaseOutputDocInterface
 {
   public:
+    enum ParamListTypes { Param, RetVal, Exception };
 
     /*! Start of a bullet list: e.g. \c <ul> in html. writeListItem() is
      *  Used for the bullet items.
@@ -208,7 +209,7 @@ class BaseOutputDocInterface
     virtual void writeCCedil(char) = 0;
     virtual void startDescList() = 0;
     virtual void endDescList() = 0;
-    virtual void startParamList() = 0;
+    virtual void startParamList(ParamListTypes t) = 0;
     virtual void endParamList() = 0;
     virtual void endDescTitle() = 0;
     virtual void writeDescItem() = 0;
diff --git a/src/outputlist.cpp b/src/outputlist.cpp
index cba5c17..06d2ebc 100644
--- a/src/outputlist.cpp
+++ b/src/outputlist.cpp
@@ -261,6 +261,7 @@ FORALL1(int a1,a1)
 FORALL1(DotClassGraph &a1,a1)
 FORALL1(DotInclDepGraph &a1,a1)
 FORALL1(DotGfxHierarchyTable &a1,a1)
+FORALL1(ParamListTypes a1,a1)
 #if defined(HAS_BOOL_TYPE) || defined(Q_HAS_BOOL_TYPE)
 FORALL1(bool a1,a1)
 FORALL2(bool a1,int a2,a1,a2)
diff --git a/src/outputlist.h b/src/outputlist.h
index 065144a..b96fc80 100644
--- a/src/outputlist.h
+++ b/src/outputlist.h
@@ -310,8 +310,8 @@ class OutputList : public OutputDocInterface
     { forall(&OutputGenerator::startDescList); }
     void endDescList() 
     { forall(&OutputGenerator::endDescList); }
-    void startParamList() 
-    { forall(&OutputGenerator::startParamList); }
+    void startParamList(ParamListTypes t) 
+    { forall(&OutputGenerator::startParamList,t); }
     void endParamList() 
     { forall(&OutputGenerator::endParamList); }
     void endDescTitle() 
@@ -455,6 +455,7 @@ class OutputList : public OutputDocInterface
     FORALLPROTO1(DotClassGraph &);
     FORALLPROTO1(DotInclDepGraph &);
     FORALLPROTO1(DotGfxHierarchyTable &);
+    FORALLPROTO1(ParamListTypes);
 #if defined(HAS_BOOL_TYPE) || defined(Q_HAS_BOOL_TYPE)
     FORALLPROTO1(bool);
     FORALLPROTO2(bool,int);
diff --git a/src/rtfgen.h b/src/rtfgen.h
index d2189a8..16d2b35 100644
--- a/src/rtfgen.h
+++ b/src/rtfgen.h
@@ -168,7 +168,7 @@ class RTFGenerator : public OutputGenerator
     void endMemberDescription();
     void startDescList();
     void endDescList();
-    void startParamList() { startDescList(); }
+    void startParamList(ParamListTypes) { startDescList(); }
     void endParamList() { endDescList(); }
     void endDescTitle();
     void writeDescItem();
diff --git a/src/scanner.l b/src/scanner.l
index 9f60f21..52326e8 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -419,7 +419,7 @@ static int yyread(char *buf,int max_size)
 %}
 
 CMD	  ("\\"|"@")
-SECTIONCMD {CMD}("image"|"author"|"internal"|"version"|"date"|"deprecated"|"param"|"exception"|"return"[s]?|"retval"|"bug"|"warning"|"par"|"sa"|"see"|"pre"|"post"|"invariant"|"note"|"remark"[s]?|"todo"|"test"|"ingroup"|"latexonly"|"htmlonly"|"{"|"verbatim") 
+SECTIONCMD {CMD}("image"|"author"|"internal"|"version"|"date"|"deprecated"|"param"|"exception"|"return"[s]?|"retval"|"bug"|"warning"|"par"|"sa"|"see"|"pre"|"post"|"invariant"|"note"|"remark"[s]?|"todo"|"test"|"ingroup"|"latexonly"|"htmlonly"|"{"|"verbatim")
 BN        [ \t\n\r]
 BL        [ \t\r]*"\n"
 B         [ \t]
@@ -468,6 +468,7 @@ TITLE     [tT][iI][tT][lL][eE]
 %x	Using
 %x	UsingDirective
 %x	NameSpaceDocArg1
+%x	PackageDocArg1
 %x	SkipCurly
 %x	SkipCurlyCpp
 %x	SkipCurlyEndDoc
@@ -1086,21 +1087,12 @@ TITLE     [tT][iI][tT][lL][eE]
   					  *currentTemplateSpec+=*yytext; 
 					}
 <FindMembers,FindMemberName>{SCOPENAME}	{ 
-  					  // correct for misinterpreting return type as scope name: example: A<T> func()
-                                          //printf("YY_START=%d current->tArgList=%p current->mtArgList=%p\n",
-					  //       YY_START,current->tArgList,current->mtArgList);
-  					  //if (YY_START==FindMembers /*&& current->tArgList*/ && current->mtArgList==0)
-					  //{
-					  //  current->mtArgList=current->tArgList;
-					  //  current->tArgList=0;
-					  //  current->scopeSpec.resize(0);
-					  //}
 					  lineCount();
                                           if (insideIDL && yyleng==9 && strcmp(yytext,"cpp_quote")==0)
 					  {
 					    BEGIN(CppQuote);
 					  }
-					  else if (insideIDL && yyleng==6 && strcmp(yytext,"import")==0)
+					  else if ((insideIDL || insideJava) && yyleng==6 && strcmp(yytext,"import")==0)
 					  {
 					    BEGIN(NextSemi);
 					  }
@@ -2511,6 +2503,7 @@ TITLE     [tT][iI][tT][lL][eE]
 <Specialization>{BN}+			{ lineCount(); *specName +=' '; }
 <Specialization>"<<"			{ *specName += yytext; }
 <Specialization>">>"			{ *specName += yytext; }
+<Specialization>"typename"{BN}+		{ lineCount(); }
 <Specialization>.			{
   					  *specName += *yytext;
   					}
@@ -2766,6 +2759,12 @@ TITLE     [tT][iI][tT][lL][eE]
 					  current->startLine = yyLineNr;
   					  BEGIN( NameSpaceDocArg1 );
   					}
+<Doc,JavaDoc>{B}*{CMD}"package"{B}+	{
+  					  current->section = Entry::PACKAGEDOC_SEC;
+					  current->fileName = yyFileName;
+					  current->startLine = yyLineNr;
+  					  BEGIN( PackageDocArg1 );
+  					}
 <Doc,JavaDoc>{B}*{CMD}"class"{B}+  	{
   					  current->section = Entry::CLASSDOC_SEC;
 					  current->fileName = yyFileName;
@@ -2986,6 +2985,18 @@ TITLE     [tT][iI][tT][lL][eE]
                                               );
   					  yyLineNr++;
   					}
+<PackageDocArg1>{SCOPENAME}		{
+  					  current->name = yytext;
+					  newDocState();
+  					}
+<PackageDocArg1>"\\"{B}*"\n"		{ yyLineNr++; }
+<PackageDocArg1>"\n"			{
+  					  warn(yyFileName,yyLineNr,
+                                               "Warning: missing argument after "
+					       "\\package."
+                                              );
+  					  yyLineNr++;
+  					}
 <ClassDocArg1>{SCOPENAME}/"<"		{
 					  current->name = yytext;
 					  // prepend outer scope name 
diff --git a/src/util.cpp b/src/util.cpp
index e766b3f..24cfa66 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -2819,7 +2819,7 @@ QCString convertNameToFile(const char *name,bool allowDots)
     }
     else
     {
-      num = (int)value;
+      num = *(int*)&value;
     }
     QCString result;
     result.sprintf("a%05d",num); 
@@ -3109,10 +3109,13 @@ bool extractClassNameFromType(const QCString &type,int &pos,QCString &name,QCStr
 /*! Substitutes any occurrence of a formal argument from argument list
  *  \a formalArgs in \a name by the corresponding actual argument in
  *  argument list \a actualArgs. The result after substitution
- *  is returned as a string.
+ *  is returned as a string. The argument \a className is used to
+ *  prevent recursive substitution.
  */
 QCString substituteTemplateArgumentsInString(
-       const QCString &name,ArgumentList *formalArgs,ArgumentList *actualArgs)
+       const QCString &name,
+       ArgumentList *formalArgs,
+       ArgumentList *actualArgs)
 {
   //printf("substituteTemplateArgumentsInString(name=%s formal=%s actualArg=%s)\n",
   //    name.data(),argListToString(formalArgs).data(),argListToString(actualArgs).data());
diff --git a/src/util.h b/src/util.h
index 04fd752..c61bd33 100644
--- a/src/util.h
+++ b/src/util.h
@@ -153,7 +153,9 @@ void addMembersToMemberGroup(MemberList *ml,MemberGroupDict *memberGroupDict,
 bool extractClassNameFromType(const QCString &type,int &pos,
                               QCString &name,QCString &templSpec);
 QCString substituteTemplateArgumentsInString(
-       const QCString &name,ArgumentList *formalArgs,ArgumentList *actualArgs);
+       const QCString &name,
+       ArgumentList *formalArgs,
+       ArgumentList *actualArgs);
 
 ArgumentList *copyArgumentList(const ArgumentList *src);
 QList<ArgumentList> *copyArgumentLists(const QList<ArgumentList> *srcLists);
diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp
index 3b9d404..736ae0a 100644
--- a/src/xmlgen.cpp
+++ b/src/xmlgen.cpp
@@ -329,11 +329,16 @@ class XMLGenerator : public OutputDocInterface
       endNestedPar();
       m_t << "</simplesect>";
     }
-    void startParamList()      
+    void startParamList(ParamListTypes t)      
     { 
-      m_t << "<parameterlist><title>"; // non DocBook
-                                // TODO: what kind of list
-                                // param, retval, exception
+      QCString kind;
+      switch(t)
+      {
+        case Param:       kind="param";     break;
+        case RetVal:      kind="retval";    break;
+        case Exception:   kind="exception"; break;
+      }
+      m_t << "<parameterlist kind=\"" << kind << "\"><title>"; // non DocBook
       m_inParamList = TRUE;
     }
     void endParamList()        
diff --git a/tmake/lib/unix/generic.t b/tmake/lib/unix/generic.t
index 88b731a..53f4e0a 100755
--- a/tmake/lib/unix/generic.t
+++ b/tmake/lib/unix/generic.t
@@ -67,7 +67,7 @@
     if ( Config("moc") ) {
 	$moc_aware = 1;
     }
-    Project('TMAKE_LIBS += $$LIBS');
+    Project('TMAKE_LIBS = $$LIBS $$TMAKE_LIBS');
     if ( !Project("TMAKE_RUN_CC") ) {
 	Project('TMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -o $obj $src');
     }
-- 
cgit v0.12

