summaryrefslogtreecommitdiffstats
path: root/src/docparser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/docparser.cpp')
-rw-r--r--src/docparser.cpp693
1 files changed, 550 insertions, 143 deletions
diff --git a/src/docparser.cpp b/src/docparser.cpp
index a34f652..da1d808 100644
--- a/src/docparser.cpp
+++ b/src/docparser.cpp
@@ -27,6 +27,8 @@
#include "doxygen.h"
#include "debug.h"
+#include "util.h"
+#include "page.h"
#include "docparser.h"
#include "doctokenizer.h"
@@ -38,9 +40,67 @@
//---------------------------------------------------------------------------
+static QCString g_context;
+static bool g_inSeeBlock;
+static bool g_insideHtmlLink;
static QStack<DocNode> g_nodeStack;
static QStack<DocStyleChange> g_styleStack;
+struct DocParserContext
+{
+ QCString context;
+ bool inSeeBlock;
+ bool insideHtmlLink;
+ QStack<DocNode> nodeStack;
+ QStack<DocStyleChange> styleStack;
+};
+
+static QStack<DocParserContext> g_parserStack;
+
+//---------------------------------------------------------------------------
+
+static void docParserPushContext()
+{
+ doctokenizerYYpushContext();
+ DocParserContext *ctx = new DocParserContext;
+ ctx->context = g_context;
+ ctx->inSeeBlock = g_inSeeBlock;
+ ctx->insideHtmlLink = g_insideHtmlLink;
+ ctx->nodeStack = g_nodeStack;
+ ctx->styleStack = g_styleStack;
+ g_parserStack.push(ctx);
+}
+
+static void docParserPopContext()
+{
+ DocParserContext *ctx = g_parserStack.pop();
+ g_context = ctx->context;
+ g_inSeeBlock = ctx->inSeeBlock;
+ g_insideHtmlLink = ctx->insideHtmlLink;
+ g_nodeStack = ctx->nodeStack;
+ g_styleStack = ctx->styleStack;
+ delete ctx;
+ doctokenizerYYpopContext();
+}
+
+//---------------------------------------------------------------------------
+
+static QCString stripKnownExtensions(const char *text)
+{
+ QCString result=text;
+ if (result.right(4)==".tex")
+ {
+ result=result.left(result.length()-4);
+ }
+ else if (result.right(Doxygen::htmlFileExtension.length())==
+ Doxygen::htmlFileExtension)
+ {
+ result=result.left(result.length()-Doxygen::htmlFileExtension.length());
+ }
+ return result;
+}
+
+
//---------------------------------------------------------------------------
/*! Returns TRUE iff node n is a child of a preformatted node */
@@ -185,7 +245,7 @@ static void handlePendingStyleCommands(DocNode *parent,QList<DocNode> &children)
DocStyleChange *sc = g_styleStack.top();
while (sc && sc->position()>=g_nodeStack.count())
{ // there are unclosed style modifiers in the paragraph
- const char *cmd;
+ const char *cmd="";
switch (sc->style())
{
case DocStyleChange::Bold: cmd = "b"; break;
@@ -205,6 +265,39 @@ static void handlePendingStyleCommands(DocNode *parent,QList<DocNode> &children)
}
}
+static void handleLinkedWord(DocNode *parent,QList<DocNode> &children)
+{
+ Definition *compound=0;
+ MemberDef *member=0;
+ if (resolveRef(g_context,g_token->name,g_inSeeBlock,&compound,&member))
+ {
+ if (member) // member link
+ {
+ children.append(new
+ DocLinkedWord(parent,g_token->name,
+ compound->getReference(),
+ compound->getOutputFileBase(),
+ member->anchor()
+ )
+ );
+ }
+ else // compound link
+ {
+ children.append(new
+ DocLinkedWord(parent,g_token->name,
+ compound->getReference(),
+ compound->getOutputFileBase(),
+ ""
+ )
+ );
+ }
+ }
+ else // normal word
+ {
+ children.append(new DocWord(parent,g_token->name));
+ }
+}
+
/* Helper function that deals with the most common tokens allowed in
* title like sections.
* @param parent Parent node, owner of the children list passed as
@@ -220,7 +313,7 @@ static bool defaultHandleToken(DocNode *parent,int tok, QList<DocNode> &children
handleWord)
{
DBG(("token %s at %d",tokToString(tok),doctokenizerYYlineno));
- if (tok==TK_WORD || tok==TK_SYMBOL || tok==TK_URL ||
+ if (tok==TK_WORD || tok==TK_LNKWORD || tok==TK_SYMBOL || tok==TK_URL ||
tok==TK_COMMAND || tok==TK_HTMLTAG
)
{
@@ -285,7 +378,7 @@ static bool defaultHandleToken(DocNode *parent,int tok, QList<DocNode> &children
{
doctokenizerYYsetStateHtmlOnly();
int retval = doctokenizerYYlex();
- children.append(new DocVerbatim(parent,g_token->verb,DocVerbatim::HtmlOnly));
+ children.append(new DocVerbatim(parent,g_context,g_token->verb,DocVerbatim::HtmlOnly));
if (retval==0) printf("Error: htmlonly section ended without end marker at line %d\n",
doctokenizerYYlineno);
doctokenizerYYsetStatePara();
@@ -295,7 +388,7 @@ static bool defaultHandleToken(DocNode *parent,int tok, QList<DocNode> &children
{
doctokenizerYYsetStateLatexOnly();
int retval = doctokenizerYYlex();
- children.append(new DocVerbatim(parent,g_token->verb,DocVerbatim::LatexOnly));
+ children.append(new DocVerbatim(parent,g_context,g_token->verb,DocVerbatim::LatexOnly));
if (retval==0) printf("Error: latexonly section ended without end marker at line %d\n",
doctokenizerYYlineno);
doctokenizerYYsetStatePara();
@@ -307,6 +400,57 @@ static bool defaultHandleToken(DocNode *parent,int tok, QList<DocNode> &children
children.append(form);
}
break;
+ case CMD_ANCHOR:
+ {
+ int tok=doctokenizerYYlex();
+ if (tok!=TK_WHITESPACE)
+ {
+ printf("Error: expected whitespace after %s command at line %d\n",
+ tokenName.data(),doctokenizerYYlineno);
+ break;
+ }
+ tok=doctokenizerYYlex();
+ if (tok==0)
+ {
+ printf("Error: unexpected end of comment block at line %d while parsing the "
+ "argument of command %s\n",doctokenizerYYlineno, tokenName.data());
+ break;
+ }
+ else if (tok!=TK_WORD && tok!=TK_LNKWORD)
+ {
+ printf("Error: unexpected token %s as the argument of %s at line %d.\n",
+ tokToString(tok),tokenName.data(),doctokenizerYYlineno);
+ break;
+ }
+ DocAnchor *anchor = new DocAnchor(parent,g_token->name);
+ children.append(anchor);
+ }
+ break;
+ case CMD_INTERNALREF:
+ {
+ int tok=doctokenizerYYlex();
+ if (tok!=TK_WHITESPACE)
+ {
+ printf("Error: expected whitespace after %s command at line %d\n",
+ tokenName.data(),doctokenizerYYlineno);
+ break;
+ }
+ doctokenizerYYsetStateInternalRef();
+ tok=doctokenizerYYlex(); // get the reference id
+ DocInternalRef *ref=0;
+ if (tok!=TK_WORD && tok!=TK_LNKWORD)
+ {
+ printf("Error: unexpected token %s as the argument of %s at line %d.\n",
+ tokToString(tok),tokenName.data(),doctokenizerYYlineno);
+ doctokenizerYYsetStatePara();
+ break;
+ }
+ ref = new DocInternalRef(parent,g_token->name);
+ children.append(ref);
+ ref->parse();
+ doctokenizerYYsetStatePara();
+ }
+ break;
default:
return FALSE;
}
@@ -413,9 +557,19 @@ handlepara:
children.append(new DocWhiteSpace(parent,g_token->chars));
}
break;
+ case TK_LNKWORD:
+ if (handleWord)
+ {
+ handleLinkedWord(parent,children);
+ }
+ else
+ return FALSE;
+ break;
case TK_WORD:
if (handleWord)
+ {
children.append(new DocWord(parent,g_token->name));
+ }
else
return FALSE;
break;
@@ -483,6 +637,77 @@ DocSymbol::SymType DocSymbol::decodeSymbol(const QCString &symName,char *letter)
//---------------------------------------------------------------------------
+static int internalValidatingParseDoc(DocNode *parent,QList<DocNode> &children,
+ const QCString &doc)
+{
+ int retval = RetVal_OK;
+
+ doctokenizerYYinit(doc);
+
+ // first parse any number of paragraphs
+ bool isFirst=FALSE;
+ DocPara *lastPar=0;
+ do
+ {
+ DocPara *par = new DocPara(parent);
+ if (isFirst) { par->markFirst(); isFirst=FALSE; }
+ retval=par->parse();
+ if (!par->isEmpty())
+ {
+ children.append(par);
+ lastPar=par;
+ }
+ } while (retval==TK_NEWPARA);
+ if (lastPar) lastPar->markLast();
+
+ return retval;
+}
+
+//---------------------------------------------------------------------------
+
+void DocXRefItem::parse()
+{
+ QCString listName;
+ switch(m_type)
+ {
+ case Bug: listName="bug"; break;
+ case Test: listName="test"; break;
+ case Todo: listName="todo"; break;
+ case Deprecated: listName="deprecated"; break;
+ }
+ RefList *refList = Doxygen::specialLists->find(listName);
+ if (Config_getBool(refList->optionName())) // list is enabled
+ {
+ RefItem *item = refList->getRefItem(m_id);
+ ASSERT(item!=0);
+
+ m_file = refList->listName();
+ m_anchor = item->listAnchor;
+ m_title = refList->sectionTitle();
+
+ docParserPushContext();
+ internalValidatingParseDoc(this,m_children,item->text);
+ docParserPopContext();
+ }
+}
+
+//---------------------------------------------------------------------------
+
+DocFormula::DocFormula(DocNode *parent,int id) :
+ m_parent(parent)
+{
+ QCString formCmd;
+ formCmd.sprintf("\\form#%d",id);
+ Formula *formula=Doxygen::formulaNameDict[formCmd];
+ if (formula)
+ {
+ m_name.sprintf("form_%d",formula->getId());
+ m_text = formula->getFormulaText();
+ }
+}
+
+//---------------------------------------------------------------------------
+
int DocLanguage::parse()
{
int retval;
@@ -490,13 +715,17 @@ int DocLanguage::parse()
g_nodeStack.push(this);
// parse one or more paragraphs
+ bool isFirst=TRUE;
+ DocPara *par=0;
do
{
- DocPara *par = new DocPara(this);
+ par = new DocPara(this);
+ if (isFirst) { par->markFirst(); isFirst=FALSE; }
m_children.append(par);
retval=par->parse();
}
while (retval==TK_NEWPARA);
+ if (par) par->markLast();
DBG(("DocLanguage::parse() end\n"));
DocNode *n = g_nodeStack.pop();
@@ -568,7 +797,7 @@ void DocSecRefList::parse()
break;
}
tok=doctokenizerYYlex();
- if (tok!=TK_WORD)
+ if (tok!=TK_WORD && tok!=TK_LNKWORD)
{
printf("Error: unexpected token %s as the argument of \\refitem at line %d.\n",
tokToString(tok),doctokenizerYYlineno);
@@ -603,10 +832,98 @@ endsecreflist:
ASSERT(n==this);
}
+//---------------------------------------------------------------------------
+
+DocInternalRef::DocInternalRef(DocNode *parent,const QCString &ref)
+ : m_parent(parent)
+{
+ int i=ref.find('#');
+ if (i!=-1)
+ {
+ m_anchor = ref.right(ref.length()-i-1);
+ m_file = ref.left(i);
+ }
+ else
+ {
+ m_file = ref;
+ }
+}
+void DocInternalRef::parse()
+{
+ g_nodeStack.push(this);
+ DBG(("DocInternalRef::parse() start\n"));
+
+ int tok;
+ while ((tok=doctokenizerYYlex()))
+ {
+ if (!defaultHandleToken(this,tok,m_children))
+ {
+ switch (tok)
+ {
+ case TK_COMMAND:
+ printf("Error: Illegal command %s as part of a \\ref at line %d\n",
+ g_token->name.data(),doctokenizerYYlineno);
+ break;
+ case TK_SYMBOL:
+ printf("Error: Unsupported symbol %s found at line %d\n",
+ g_token->name.data(),doctokenizerYYlineno);
+ break;
+ default:
+ printf("Error: Unexpected token %s at line %d\n",
+ g_token->name.data(),doctokenizerYYlineno);
+ break;
+ }
+ }
+ }
+
+ handlePendingStyleCommands(this,m_children);
+ DBG(("DocInternalRef::parse() end\n"));
+ DocNode *n=g_nodeStack.pop();
+ ASSERT(n==this);
+}
//---------------------------------------------------------------------------
+DocRef::DocRef(DocNode *parent,const QCString &target) :
+ m_parent(parent), m_refToSection(FALSE), m_refToAnchor(FALSE)
+{
+ Definition *compound = 0;
+ MemberDef *member = 0;
+ ASSERT(!target.isEmpty());
+ SectionInfo *sec = Doxygen::sectionDict[target];
+ if (sec) // ref to section or anchor
+ {
+ m_text = sec->title;
+ if (m_text.isEmpty()) m_text = sec->label;
+
+ m_ref = sec->ref;
+ m_file = stripKnownExtensions(sec->fileName);
+ m_anchor = sec->label;
+ m_refToAnchor = sec->type==SectionInfo::Anchor;
+ m_refToSection = sec->type!=SectionInfo::Anchor;
+ }
+ else if (resolveRef(g_context,target,TRUE,&compound,&member))
+ {
+ if (member) // ref to member
+ {
+ m_file = compound->getOutputFileBase();
+ m_ref = compound->getReference();
+ m_anchor = member->anchor();
+ }
+ else // ref to compound
+ {
+ m_file = compound->getOutputFileBase();
+ m_ref = compound->getReference();
+ }
+ }
+ else // oops, bogus target
+ {
+ printf("Error: unable to resolve reference to `%s' for \\ref command at line %d\n",
+ target.data(),doctokenizerYYlineno);
+ }
+}
+
void DocRef::parse()
{
g_nodeStack.push(this);
@@ -643,6 +960,33 @@ void DocRef::parse()
//---------------------------------------------------------------------------
+DocLink::DocLink(DocNode *parent,const QCString &target) :
+ m_parent(parent)
+{
+ Definition *compound;
+ PageInfo *page;
+ if (resolveLink(g_context,stripKnownExtensions(target),g_inSeeBlock,
+ &compound,&page,m_anchor))
+ {
+ if (compound)
+ {
+ m_file = compound->getOutputFileBase();
+ m_ref = compound->getReference();
+ }
+ else if (page)
+ {
+ m_file = page->getOutputFileBase();
+ m_ref = page->getReference();
+ }
+ }
+ else // oops, bogus target
+ {
+ printf("Error: unable to resolve link to `%s' for \\link command at line %d\n",
+ target.data(),doctokenizerYYlineno);
+ }
+}
+
+
QCString DocLink::parse(bool isJavaLink)
{
QCString result;
@@ -944,16 +1288,24 @@ int DocInternal::parse()
DBG(("DocInternal::parse() start\n"));
// first parse any number of paragraphs
+ bool isFirst=FALSE;
+ DocPara *lastPar=0;
do
{
DocPara *par = new DocPara(this);
+ if (isFirst) { par->markFirst(); isFirst=FALSE; }
retval=par->parse();
- if (!par->isEmpty()) m_children.append(par);
+ if (!par->isEmpty())
+ {
+ m_children.append(par);
+ lastPar=par;
+ }
if (retval==TK_LISTITEM)
{
printf("Error: Invalid list item found at line %d!\n",doctokenizerYYlineno);
}
} while (retval!=0 && retval!=RetVal_Section);
+ if (lastPar) lastPar->markLast();
// then parse any number of level1 sections
while (retval==RetVal_Section)
@@ -1094,13 +1446,17 @@ int DocHtmlCell::parse()
DBG(("DocHtmlCell::parse() start\n"));
// parse one or more paragraphs
+ bool isFirst=FALSE;
+ DocPara *par=0;
do
{
- DocPara *par = new DocPara(this);
+ par = new DocPara(this);
+ if (isFirst) { par->markFirst(); isFirst=FALSE; }
m_children.append(par);
retval=par->parse();
}
while (retval==TK_NEWPARA);
+ if (par) par->markLast();
DBG(("DocHtmlCell::parse() end\n"));
DocNode *n=g_nodeStack.pop();
@@ -1311,13 +1667,17 @@ int DocHtmlDescData::parse()
g_nodeStack.push(this);
DBG(("DocHtmlDescData::parse() start\n"));
+ bool isFirst=FALSE;
+ DocPara *par=0;
do
{
- DocPara *par = new DocPara(this);
+ par = new DocPara(this);
+ if (isFirst) { par->markFirst(); isFirst=FALSE; }
m_children.append(par);
retval=par->parse();
}
while (retval==TK_NEWPARA);
+ if (par) par->markLast();
DBG(("DocHtmlDescData::parse() end\n"));
DocNode *n=g_nodeStack.pop();
@@ -1404,13 +1764,17 @@ int DocHtmlPre::parse()
int rv;
g_nodeStack.push(this);
+ bool isFirst=FALSE;
+ DocPara *par=0;
do
{
- DocPara *par = new DocPara(this);
+ par = new DocPara(this);
+ if (isFirst) { par->markFirst(); isFirst=FALSE; }
m_children.append(par);
rv=par->parse();
}
while (rv==TK_NEWPARA);
+ if (par) par->markLast();
DocNode *n=g_nodeStack.pop();
ASSERT(n==this);
@@ -1426,13 +1790,17 @@ int DocHtmlListItem::parse()
g_nodeStack.push(this);
// parse one or more paragraphs
+ bool isFirst=FALSE;
+ DocPara *par=0;
do
{
- DocPara *par = new DocPara(this);
+ par = new DocPara(this);
+ if (isFirst) { par->markFirst(); isFirst=FALSE; }
m_children.append(par);
retval=par->parse();
}
while (retval==TK_NEWPARA);
+ if (par) par->markLast();
DocNode *n=g_nodeStack.pop();
ASSERT(n==this);
@@ -1506,6 +1874,8 @@ int DocSimpleListItem::parse()
{
g_nodeStack.push(this);
int rv=m_paragraph->parse();
+ m_paragraph->markFirst();
+ m_paragraph->markLast();
DocNode *n=g_nodeStack.pop();
ASSERT(n==this);
return rv;
@@ -1535,6 +1905,8 @@ int DocAutoListItem::parse()
int retval = RetVal_OK;
g_nodeStack.push(this);
retval=m_paragraph->parse();
+ m_paragraph->markFirst();
+ m_paragraph->markLast();
DocNode *n=g_nodeStack.pop();
ASSERT(n==this);
return retval;
@@ -1602,24 +1974,23 @@ void DocTitle::parse()
//--------------------------------------------------------------------------
DocSimpleSect::DocSimpleSect(DocNode *parent,Type t) :
- m_parent(parent), m_type(t)
+ m_parent(parent), m_type(t)
{
- m_paragraph = new DocPara(this);
- //m_params.setAutoDelete(TRUE);
- m_title = 0;
+ m_title=0;
}
-DocSimpleSect::~DocSimpleSect()
+DocSimpleSect::~DocSimpleSect()
{
- delete m_paragraph;
- delete m_title;
+ delete m_title;
}
void DocSimpleSect::accept(DocVisitor *v)
{
v->visitPre(this);
if (m_title) m_title->accept(v);
- m_paragraph->accept(v);
+ QListIterator<DocNode> cli(m_children);
+ DocNode *n;
+ for (cli.toFirst();(n=cli.current());++cli) n->accept(v);
v->visitPost(this);
}
@@ -1635,34 +2006,38 @@ int DocSimpleSect::parse(bool userTitle)
m_title->parse();
}
- int retval = m_paragraph->parse();
+ // add new paragraph as child
+ DocPara *par = new DocPara(this);
+ if (m_children.isEmpty())
+ {
+ par->markFirst();
+ }
+ else
+ {
+ ASSERT(m_children.last()->kind()==DocNode::Kind_Para);
+ ((DocPara *)m_children.last())->markLast(FALSE);
+ }
+ par->markLast();
+ m_children.append(par);
+
+ // parse the contents of the paragraph
+ int retval = par->parse();
DBG(("DocSimpleSect::parse() end retval=%d\n",retval));
- DocNode *n = g_nodeStack.pop();
+ DocNode *n=g_nodeStack.pop();
ASSERT(n==this);
return retval; // 0==EOF, TK_NEWPARA, TK_LISTITEM, TK_ENDLIST, RetVal_SimpleSec
}
-void DocSimpleSect::addParam(const QCString &name)
-{
- m_params.append(name);
-}
-
//--------------------------------------------------------------------------
-int DocPara::handleSimpleSection(DocSimpleSect::Type t)
+int DocParamList::parse(const QCString &cmdName)
{
- DocSimpleSect *ss=new DocSimpleSect(this,t);
- m_children.append(ss);
- int rv = ss->parse(t==DocSimpleSect::User);
- return (rv!=TK_NEWPARA) ? rv : RetVal_OK;
-}
+ int retval=RetVal_OK;
+ DBG(("DocParamList::parse() start\n"));
+ g_nodeStack.push(this);
-int DocPara::handleParamSection(const QCString &cmdName,DocSimpleSect::Type t)
-{
int tok=doctokenizerYYlex();
- DocSimpleSect *ss=new DocSimpleSect(this,t);
- m_children.append(ss);
if (tok!=TK_WHITESPACE)
{
printf("Error: expected whitespace after %s command at line %d\n",
@@ -1670,12 +2045,12 @@ int DocPara::handleParamSection(const QCString &cmdName,DocSimpleSect::Type t)
}
doctokenizerYYsetStateParam();
tok=doctokenizerYYlex();
- doctokenizerYYsetStatePara();
while (tok==TK_WORD) /* there is a parameter name */
{
- ss->addParam(g_token->name);
+ m_params.append(g_token->name);
tok=doctokenizerYYlex();
}
+ doctokenizerYYsetStatePara();
if (tok==0) /* premature end of comment block */
{
printf("Error: unexpected end of comment block at line %d while parsing the "
@@ -1683,71 +2058,75 @@ int DocPara::handleParamSection(const QCString &cmdName,DocSimpleSect::Type t)
return 0;
}
ASSERT(tok==TK_WHITESPACE);
- int rv = ss->parse(FALSE);
- return (rv!=TK_NEWPARA) ? rv : RetVal_OK;
+
+ retval = m_paragraph->parse();
+ m_paragraph->markFirst();
+ m_paragraph->markLast();
+
+ DBG(("DocParamList::parse() end retval=%d\n",retval));
+ DocNode *n=g_nodeStack.pop();
+ ASSERT(n==this);
+ return retval;
}
-#if 0
-int DocPara::handleStyleArgument(const QCString &cmdName)
+//--------------------------------------------------------------------------
+
+int DocParamSect::parse(const QCString &cmdName)
{
- int tok=doctokenizerYYlex();
- if (tok!=TK_WHITESPACE)
+ int retval=RetVal_OK;
+ DBG(("DocParamSect::parse() start\n"));
+ g_nodeStack.push(this);
+
+ DocParamList *pl = new DocParamList(this);
+ m_children.append(pl);
+ retval = pl->parse(cmdName);
+
+ DBG(("DocParamSect::parse() end retval=%d\n",retval));
+ DocNode *n=g_nodeStack.pop();
+ ASSERT(n==this);
+ return retval;
+}
+
+//--------------------------------------------------------------------------
+
+int DocPara::handleSimpleSection(DocSimpleSect::Type t)
+{
+ DocSimpleSect *ss=0;
+ if (!m_children.isEmpty() && // previous element
+ m_children.last()->kind()==Kind_SimpleSect && // was a simple sect
+ ((DocSimpleSect *)m_children.last())->type()==t) // of same type
{
- printf("Error: expected whitespace after %s command at line %d\n",
- cmdName.data(),doctokenizerYYlineno);
- return;
+ // append to previous section
+ ss=(DocSimpleSect *)m_children.last();
}
- while ((tok=doctokenizerYYlex()) && tok!=TK_WHITESPACE && tok!=TK_NEWPARA)
+ else // start new section
{
- if (!defaultHandleToken(this,tok,m_children))
- {
- switch (tok)
- {
- case TK_COMMAND:
- printf("Error: Illegal command \\%s as the argument of a \\%s command at line %d\n",
- g_token->name.data(),cmdName.data(),doctokenizerYYlineno);
- break;
- case TK_SYMBOL:
- printf("Error: Unsupported symbol %s found at line %d\n",
- g_token->name.data(),doctokenizerYYlineno);
- break;
- default:
- printf("Error: Unexpected token %s at line %d\n",
- g_token->name.data(),doctokenizerYYlineno);
- break;
- }
- }
+ ss=new DocSimpleSect(this,t);
+ m_children.append(ss);
}
- return tok==TK_NEWPARA ? TK_NEWPARA : RetVal_OK;
-}
-
-void DocPara::handleStyleEnter(DocStyleChange::Style s)
-{
- DBG(("HandleStyleEnter\n"));
- DocStyleChange *sc= new DocStyleChange(this,g_nodeStack.count(),s,TRUE);
- m_children.append(sc);
- g_styleStack.push(sc);
+ int rv = ss->parse(t==DocSimpleSect::User);
+ return (rv!=TK_NEWPARA) ? rv : RetVal_OK;
}
-void DocPara::handleStyleLeave(DocStyleChange::Style s,const char *tagName)
+int DocPara::handleParamSection(const QCString &cmdName,DocParamSect::Type t)
{
- DBG(("HandleStyleLeave\n"));
- if (g_styleStack.isEmpty() || // no style change
- g_styleStack.top()->style()!=s || // wrong style change
- g_styleStack.top()->position()!=g_nodeStack.count() // wrong position
- )
+ DocParamSect *ps=0;
+
+ if (!m_children.isEmpty() && // previous element
+ m_children.last()->kind()==Kind_ParamSect && // was a param sect
+ ((DocParamSect *)m_children.last())->type()==t) // of same type
{
- printf("Error: found </%s> tag at line %d without matching <%s> in the same paragraph\n",
- tagName,doctokenizerYYlineno,tagName);
+ // append to previous section
+ ps=(DocParamSect *)m_children.last();
}
- else // end the section
+ else // start new section
{
- DocStyleChange *sc= new DocStyleChange(this,g_nodeStack.count(),s,FALSE);
- m_children.append(sc);
- g_styleStack.pop();
+ ps=new DocParamSect(this,t);
+ m_children.append(ps);
}
+ int rv=ps->parse(cmdName);
+ return (rv!=TK_NEWPARA) ? rv : RetVal_OK;
}
-#endif
int DocPara::handleXRefItem(DocXRefItem::Type t)
{
@@ -1757,7 +2136,9 @@ int DocPara::handleXRefItem(DocXRefItem::Type t)
retval=doctokenizerYYlex();
if (retval!=0)
{
- m_children.append(new DocXRefItem(this,g_token->id,t));
+ DocXRefItem *ref = new DocXRefItem(this,g_token->id,t);
+ m_children.append(ref);
+ ref->parse();
}
doctokenizerYYsetStatePara();
return retval;
@@ -1801,7 +2182,7 @@ void DocPara::handleImage(const QCString &cmdName)
return;
}
tok=doctokenizerYYlex();
- if (tok!=TK_WORD)
+ if (tok!=TK_WORD && tok!=TK_LNKWORD)
{
printf("Error: unexpected token %s as the argument of %s at line %d.\n",
tokToString(tok),cmdName.data(),doctokenizerYYlineno);
@@ -1937,7 +2318,7 @@ int DocPara::handleLanguageSwitch()
retval = tok;
goto endlang;
}
- else if (tok==TK_WORD)
+ else if (tok==TK_WORD || tok==TK_LNKWORD)
{
DocLanguage *dl = new DocLanguage(this,g_token->name);
m_children.append(dl);
@@ -2037,7 +2418,9 @@ int DocPara::handleCommand(const QCString &cmdName)
m_children.append(new DocSymbol(this,DocSymbol::Percent));
break;
case CMD_SA:
+ g_inSeeBlock=TRUE;
retval = handleSimpleSection(DocSimpleSect::See);
+ g_inSeeBlock=FALSE;
break;
case CMD_RETURN:
retval = handleSimpleSection(DocSimpleSect::Return);
@@ -2045,6 +2428,9 @@ int DocPara::handleCommand(const QCString &cmdName)
case CMD_AUTHOR:
retval = handleSimpleSection(DocSimpleSect::Author);
break;
+ case CMD_AUTHORS:
+ retval = handleSimpleSection(DocSimpleSect::Authors);
+ break;
case CMD_VERSION:
retval = handleSimpleSection(DocSimpleSect::Version);
break;
@@ -2102,7 +2488,7 @@ int DocPara::handleCommand(const QCString &cmdName)
"argument of command %s\n",doctokenizerYYlineno, cmdName.data());
break;
}
- else if (tok!=TK_WORD)
+ else if (tok!=TK_WORD && tok!=TK_LNKWORD)
{
printf("Error: unexpected token %s as the argument of %s at line %d.\n",
tokToString(tok),cmdName.data(),doctokenizerYYlineno);
@@ -2116,7 +2502,7 @@ int DocPara::handleCommand(const QCString &cmdName)
{
doctokenizerYYsetStateCode();
retval = doctokenizerYYlex();
- m_children.append(new DocVerbatim(this,g_token->verb,DocVerbatim::Code));
+ m_children.append(new DocVerbatim(this,g_context,g_token->verb,DocVerbatim::Code));
if (retval==0) printf("Error: code section ended without end marker at line %d\n",
doctokenizerYYlineno);
doctokenizerYYsetStatePara();
@@ -2126,7 +2512,7 @@ int DocPara::handleCommand(const QCString &cmdName)
{
doctokenizerYYsetStateHtmlOnly();
retval = doctokenizerYYlex();
- m_children.append(new DocVerbatim(this,g_token->verb,DocVerbatim::HtmlOnly));
+ m_children.append(new DocVerbatim(this,g_context,g_token->verb,DocVerbatim::HtmlOnly));
if (retval==0) printf("Error: htmlonly section ended without end marker at line %d\n",
doctokenizerYYlineno);
doctokenizerYYsetStatePara();
@@ -2136,7 +2522,7 @@ int DocPara::handleCommand(const QCString &cmdName)
{
doctokenizerYYsetStateLatexOnly();
retval = doctokenizerYYlex();
- m_children.append(new DocVerbatim(this,g_token->verb,DocVerbatim::LatexOnly));
+ m_children.append(new DocVerbatim(this,g_context,g_token->verb,DocVerbatim::LatexOnly));
if (retval==0) printf("Error: latexonly section ended without end marker at line %d\n",
doctokenizerYYlineno);
doctokenizerYYsetStatePara();
@@ -2146,7 +2532,7 @@ int DocPara::handleCommand(const QCString &cmdName)
{
doctokenizerYYsetStateVerbatim();
retval = doctokenizerYYlex();
- m_children.append(new DocVerbatim(this,g_token->verb,DocVerbatim::Verbatim));
+ m_children.append(new DocVerbatim(this,g_context,g_token->verb,DocVerbatim::Verbatim));
if (retval==0) printf("Error: verbatim section ended without end marker at line %d\n",
doctokenizerYYlineno);
doctokenizerYYsetStatePara();
@@ -2160,13 +2546,13 @@ int DocPara::handleCommand(const QCString &cmdName)
printf("Error: unexpected command %s at line %d\n",g_token->name.data(),doctokenizerYYlineno);
break;
case CMD_PARAM:
- retval = handleParamSection(cmdName,DocSimpleSect::Param);
+ retval = handleParamSection(cmdName,DocParamSect::Param);
break;
case CMD_RETVAL:
- retval = handleParamSection(cmdName,DocSimpleSect::RetVal);
+ retval = handleParamSection(cmdName,DocParamSect::RetVal);
break;
case CMD_EXCEPTION:
- retval = handleParamSection(cmdName,DocSimpleSect::Exception);
+ retval = handleParamSection(cmdName,DocParamSect::Exception);
break;
case CMD_BUG:
retval = handleXRefItem(DocXRefItem::Bug);
@@ -2202,7 +2588,7 @@ int DocPara::handleCommand(const QCString &cmdName)
"argument of command %s\n",doctokenizerYYlineno, cmdName.data());
break;
}
- else if (tok!=TK_WORD)
+ else if (tok!=TK_WORD && tok!=TK_LNKWORD)
{
printf("Error: unexpected token %s as the argument of %s at line %d.\n",
tokToString(tok),cmdName.data(),doctokenizerYYlineno);
@@ -2238,7 +2624,7 @@ int DocPara::handleCommand(const QCString &cmdName)
"argument of command %s\n",doctokenizerYYlineno, cmdName.data());
break;
}
- else if (tok!=TK_WORD)
+ else if (tok!=TK_WORD && tok!=TK_LNKWORD)
{
printf("Error: unexpected token %s as the argument of %s at line %d.\n",
tokToString(tok),cmdName.data(),doctokenizerYYlineno);
@@ -2309,6 +2695,9 @@ int DocPara::handleCommand(const QCString &cmdName)
case CMD_LANGSWITCH:
retval = handleLanguageSwitch();
break;
+ case CMD_INTERNALREF:
+ printf("Error: unexpected command %s at line %d\n",g_token->name.data(),doctokenizerYYlineno);
+ break;
default:
// we should not get here!
ASSERT(0);
@@ -2322,34 +2711,6 @@ int DocPara::handleCommand(const QCString &cmdName)
return retval;
}
-#if 0
-void DocPara::handlePendingStyleCommands()
-{
- if (!g_styleStack.isEmpty())
- {
- DocStyleChange *sc = g_styleStack.top();
- while (sc && sc->position()>=g_nodeStack.count())
- { // there are unclosed style modifiers in the paragraph
- const char *cmd;
- switch (sc->style())
- {
- case DocStyleChange::Bold: cmd = "b"; break;
- case DocStyleChange::Italic: cmd = "em"; break;
- case DocStyleChange::Code: cmd = "code"; break;
- case DocStyleChange::Center: cmd = "center"; break;
- case DocStyleChange::Small: cmd = "small"; break;
- case DocStyleChange::Subscript: cmd = "subscript"; break;
- case DocStyleChange::Superscript: cmd = "superscript"; break;
- }
- printf("Error: end of paragraph at line %d without end of style "
- "command </%s>\n",doctokenizerYYlineno,cmd);
- m_children.append(new DocStyleChange(this,g_nodeStack.count(),sc->style(),FALSE));
- g_styleStack.pop();
- sc = g_styleStack.top();
- }
- }
-}
-#endif
int DocPara::handleHtmlStartTag(const QCString &tagName,const QList<Option> &tagOptions)
{
@@ -2483,7 +2844,9 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const QList<Option> &tag
{
DocHRef *href = new DocHRef(this,opt->value);
m_children.append(href);
+ g_insideHtmlLink=TRUE;
retval = href->parse();
+ g_insideHtmlLink=FALSE;
break;
}
else // unsupport option for tag a
@@ -2689,7 +3052,7 @@ int DocPara::parse()
{
reparsetoken:
DBG(("token %s at %d",tokToString(tok),doctokenizerYYlineno));
- if (tok==TK_WORD || tok==TK_SYMBOL || tok==TK_URL ||
+ if (tok==TK_WORD || tok==TK_LNKWORD || tok==TK_SYMBOL || tok==TK_URL ||
tok==TK_COMMAND || tok==TK_HTMLTAG
)
{
@@ -2701,6 +3064,9 @@ reparsetoken:
case TK_WORD:
m_children.append(new DocWord(this,g_token->name));
break;
+ case TK_LNKWORD:
+ handleLinkedWord(this,m_children);
+ break;
case TK_URL:
m_children.append(new DocURL(this,g_token->name));
break;
@@ -2708,12 +3074,12 @@ reparsetoken:
// prevent leading whitespace and collapse multiple whitespace areas
if (insidePRE(this) || // all whitespace is relavant
( // keep only whitespace after words, URL or symbols
- !m_children.isEmpty() &&
- (
+ !m_children.isEmpty() /* &&
+ (
m_children.last()->kind()==DocNode::Kind_Word ||
m_children.last()->kind()==DocNode::Kind_URL ||
m_children.last()->kind()==DocNode::Kind_Symbol
- )
+ )*/
)
)
{
@@ -2803,7 +3169,13 @@ reparsetoken:
// see if we have to start a simple section
int cmd = CmdMapper::map(g_token->name);
DocNode *n=parent();
- while (n && n->kind()!=DocNode::Kind_SimpleSect) n=n->parent();
+ while (n &&
+ n->kind()!=DocNode::Kind_SimpleSect &&
+ n->kind()!=DocNode::Kind_ParamSect
+ )
+ {
+ n=n->parent();
+ }
if (cmd&SIMPLESECT_BIT)
{
if (n // already in a simple section
@@ -2880,7 +3252,20 @@ reparsetoken:
}
break;
case TK_SYMBOL:
- break;
+ {
+ char letter='\0';
+ DocSymbol::SymType s = DocSymbol::decodeSymbol(g_token->name,&letter);
+ if (s!=DocSymbol::Unknown)
+ {
+ m_children.append(new DocSymbol(this,s,letter));
+ }
+ else
+ {
+ printf("Error: Unsupported symbol %s found at line %d\n",
+ g_token->name.data(),doctokenizerYYlineno);
+ }
+ break;
+ }
case TK_NEWPARA:
retval=TK_NEWPARA;
goto endparagraph;
@@ -2910,16 +3295,24 @@ int DocSection::parse()
g_nodeStack.push(this);
// first parse any number of paragraphs
+ bool isFirst=FALSE;
+ DocPara *lastPar=0;
do
{
DocPara *par = new DocPara(this);
+ if (isFirst) { par->markFirst(); isFirst=FALSE; }
retval=par->parse();
- if (!par->isEmpty()) m_children.append(par);
+ if (!par->isEmpty())
+ {
+ m_children.append(par);
+ lastPar = par;
+ }
if (retval==TK_LISTITEM)
{
printf("Error: Invalid list item found at line %d!\n",doctokenizerYYlineno);
}
} while (retval!=0 && retval!=RetVal_Section && retval!=RetVal_Internal);
+ if (lastPar) lastPar->markLast();
// then parse any number of nested sections
while (retval==RetVal_Section) // more sections follow
@@ -2958,20 +3351,27 @@ void DocRoot::parse()
{
g_nodeStack.push(this);
doctokenizerYYsetStatePara();
- DocPara *par=0;
int retval=0;
// first parse any number of paragraphs
+ bool isFirst=FALSE;
+ DocPara *lastPar=0;
do
{
- par = new DocPara(this);
+ DocPara *par = new DocPara(this);
+ if (isFirst) { par->markFirst(); isFirst=FALSE; }
retval=par->parse();
- if (!par->isEmpty()) m_children.append(par);
+ if (!par->isEmpty())
+ {
+ m_children.append(par);
+ lastPar = par;
+ }
if (retval==TK_LISTITEM)
{
printf("Error: Invalid list item found at line %d!\n",doctokenizerYYlineno);
}
} while (retval!=0 && retval!=RetVal_Section && retval!=RetVal_Internal);
+ if (lastPar) lastPar->markLast();
// then parse any number of level1 sections
while (retval==RetVal_Section)
@@ -3004,12 +3404,19 @@ void DocRoot::parse()
//--------------------------------------------------------------------------
-void validatingParseDoc(const char *fileName,int startLine,const char *input)
+DocNode *validatingParseDoc(const char *fileName,int startLine,
+ const char *context,const char *input)
{
//printf("---------------- input --------------------\n%s\n----------- end input -------------------\n",input);
- //
+
printf("========== validating %s at line %d\n",fileName,startLine);
g_token = new TokenInfo;
+
+ g_context = context;
+ g_nodeStack.clear();
+ g_styleStack.clear();
+ g_inSeeBlock = FALSE;
+ g_insideHtmlLink = FALSE;
doctokenizerYYlineno=startLine;
doctokenizerYYinit(input);
@@ -3025,13 +3432,13 @@ void validatingParseDoc(const char *fileName,int startLine,const char *input)
root->accept(v);
}
- delete root;
-
delete g_token;
// TODO: These should be called at the end of the program.
//doctokenizerYYcleanup();
//CmdMapper::freeInstance();
//HtmlTagMapper::freeInstance();
+
+ return root;
}
='n1750' href='#n1750'>1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251
## Process this file with autoconf to produce configure.
##
## Copyright by The HDF Group.
## All rights reserved.
##
## This file is part of HDF5.  The full HDF5 copyright notice, including
## terms governing use, modification, and redistribution, is contained in
## the COPYING file, which can be found at the root of the source code
## distribution tree, or in https://www.hdfgroup.org/licenses.
## If you do not have access to either file, you may request a copy from
## help@hdfgroup.org.

## ----------------------------------------------------------------------
## Initialize configure.
##
AC_PREREQ([2.71])

## AC_INIT takes the name of the package, the version number, and an
## email address to report bugs. AC_CONFIG_SRCDIR takes a unique file
## as its argument.
##
## NOTE: Do not forget to change the version number here when we do a
## release!!!
##
AC_INIT([HDF5], [1.15.0], [help@hdfgroup.org])

AC_CONFIG_SRCDIR([src/H5.c])
AC_CONFIG_HEADERS([src/H5config.h])

AC_CONFIG_AUX_DIR([bin])
AC_CONFIG_MACRO_DIR([m4])

## AM_INIT_AUTOMAKE takes a list of options that should be applied to
## every Makefile.am when automake is run.
AM_INIT_AUTOMAKE([foreign subdir-objects])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) # use silent rules where available - automake 1.11

## AM_MAINTAINER_MODE determines the behavior of "rebuild rules" that contain
## dependencies for Makefile.in files, configure, src/H5config.h, etc. If
## AM_MAINTAINER_MODE is enabled, these files will be rebuilt if out of date.
## When disabled, the autotools build files can get out of sync and the build
## system will not complain or try to regenerate downstream files.
##
## The AM_MAINTAINER_MODE macro also determines whether the
## --(enable|disable)-maintainer-mode configure option is available. When the
## macro is present, with or without a parameter, the option will be added
## to the generated configure script.
##
## In summary:
##
##  AM_MAINTAINER_MODE([enable])
##      - Build dependencies ON by default
##      - Configure option exists
##
##  AM_MAINTAINER_MODE([disable])
##      - Build dependencies OFF by default
##      - Configure option exists
##
##  AM_MAINTAINER_MODE
##      - Build dependencies OFF by default
##      - Configure option exists
##
##  No AM_MAINTAINER_MODE macro
##      - Build dependencies ON by default
##      - No configure option to control build dependencies
##
## The biggest concern for us is that version control systems like git
## usually don't preserve dependencies between timestamps, so the build
## system will often think that upstream build files like Makefile.am are
## dirty and that rebuilding needs to occur when it doesn't. This is a problem
## in release branches where we provide the autotools-generated files. Users
## who don't have autoconf, automake, etc. will then have difficulty building
## release branches checked out from git.
##
## By default, maintainer mode is enabled in development branches and disabled
## in release branches.
AM_MAINTAINER_MODE([enable])

## ----------------------------------------------------------------------
## Set prefix default (install directory) to a directory in the build area.
## This allows multiple src-dir builds within one host.
AC_PREFIX_DEFAULT([`pwd`/hdf5])

## Run post processing on files created by configure
##
## src/H5pubconf.h:
## Generate src/H5pubconf.h from src/H5config.h by prepending H5_ to all
## macro names. This avoid name conflict between HDF5 macro names and those
## generated by another software package that uses the HDF5 library.
##
## src/libhdf5.settings:
## Remove all lines beginning with "#" which are generated by CONDITIONAL's
## of configure.
##
## src/H5build_settings.c
## Remove all lines beginning with "#" which are generated by CONDITIONAL's
## of configure. This uses a check for whitespace after the pound sign
## to avoid clobbering include statements.
AC_CONFIG_COMMANDS([pubconf], [
  echo "creating src/H5pubconf.h"
  sed 's/#define /#define H5_/' <src/H5config.h |\
    sed 's/#undef /#undef H5_/' >pubconf
  if test ! -f src/H5pubconf.h; then
    mv -f pubconf src/H5pubconf.h
  elif (diff pubconf src/H5pubconf.h >/dev/null); then
    rm -f pubconf
    echo "src/H5pubconf.h is unchanged"
  else
    mv -f pubconf src/H5pubconf.h
  fi
  echo "Post process src/libhdf5.settings"
  sed '/^#/d' < src/libhdf5.settings > libhdf5.settings.TMP
  cp libhdf5.settings.TMP src/libhdf5.settings
  rm -f libhdf5.settings.TMP
  echo "Post process src/H5build_settings.c"
  sed '/^# /d' < src/H5build_settings.c > H5build_settings.TMP
  cp H5build_settings.TMP src/H5build_settings.c
  rm -f H5build_settings.TMP
])

## It's possible to configure for a host other than the one on which
## configure is currently running by using the --host=foo flag.
## For machines on which HDF5 is often configured, it can be convenient
## to specify the name of the machine rather than its canonical type.
##
## There are currently no hosts, but if there were they would be
## listed by hostname and the alias would point to a file in
## the config directory:
##
##case $host_alias in
##  <some host>)
##    host_alias=<config file in config directory>
##    ;;
##esac

AC_CANONICAL_HOST
AC_SUBST([CPPFLAGS])
AC_SUBST([JNIFLAGS])
AC_SUBST([AR_FLAGS])

## H5_CFLAGS (and company) are for CFLAGS that should be used on HDF5, but
## not exported to h5cc (or h5fc, etc.)
##
AC_SUBST([H5_CFLAGS])
AC_SUBST([H5_CPPFLAGS])
AC_SUBST([H5_FCFLAGS])
AC_SUBST([H5_CXXFLAGS])
AC_SUBST([H5_JNIFLAGS])
AC_SUBST([H5_JAVACFLAGS])
AC_SUBST([H5_JAVAFLAGS])
AC_SUBST([H5_LDFLAGS])

## AM_CFLAGS (and company) are for CFLAGS that should be used on HDF5,
## and WILL be exported to h5cc (or h5fc, etc) if set by configure.
AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_FCFLAGS])
AC_SUBST([AM_CXXFLAGS])
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_JNIFLAGS])
AC_SUBST([AM_JAVACFLAGS])
AC_SUBST([AM_JAVAFLAGS])
AC_SUBST([AM_LDFLAGS])

## Make sure flags are initialized.
AM_CFLAGS="${AM_CFLAGS}"
AM_CXXFLAGS="${AM_CXXFLAGS}"
AM_FCFLAGS="${AM_FCFLAGS}"
AM_CPPFLAGS="${AM_CPPFLAGS}"
AM_JNIFLAGS="${AM_JNIFLAGS}"
AM_JAVACFLAGS="${AM_JAVACFLAGS}"
AM_JAVAFLAGS="${AM_JAVAFLAGS}"
AM_LDFLAGS="${AM_LDFLAGS}"

## Flags passed in by the user
CFLAGS="${CFLAGS}"
CXXFLAGS="${CXXFLAGS}"
FCFLAGS="${FCFLAGS}"
CPPFLAGS="${CPPFLAGS}"
JNIFLAGS="${JNIFLAGS}"
JAVACFLAGS="${JAVACFLAGS}"
JAVAFLAGS="${JAVAFLAGS}"
LDFLAGS="${LDFLAGS}"
AR_FLAGS="${AR_FLAGS}"

## Configure may need to alter any of the *FLAGS variables in order for
## various checks to work correctly. Save the user's value here so it
## can be restored once all configure checks are complete.
saved_user_CFLAGS="$CFLAGS"
saved_user_CXXFLAGS="$CXXFLAGS"
saved_user_FCFLAGS="$FCFLAGS"
saved_user_JAVACFLAGS="$JAVACFLAGS"
saved_user_JAVAFLAGS="$JAVAFLAGS"
saved_user_LDFLAGS="$LDFLAGS"
saved_user_CPPFLAGS="$CPPFLAGS"

## Strip out -Werror from CFLAGS since that can cause checks to fail when
## compiling the test program fails due to warnings
CFLAGS="`echo $CFLAGS | sed -e 's/-Werror//g'`"
CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-Werror//g'`"
FCFLAGS="`echo $FCFLAGS | sed -e 's/-Werror//g'`"
JAVACFLAGS="`echo $JAVACFLAGS | sed -e 's/-Werror//g'`"
CPPFLAGS="`echo $CPPFLAGS | sed -e 's/-Werror//g'`"

## Support F9X variable to define Fortran compiler if FC variable is
## not used.  This should be deprecated in the future.
if test "x" = "x$FC"; then
  FC=${F9X}
fi

## ----------------------------------------------------------------------
## Dump all shell variables values.
##
AC_MSG_CHECKING([shell variables initial values])
set >&AS_MESSAGE_LOG_FD
AC_MSG_RESULT([done])

## ----------------------------------------------------------------------
## Save system information for the library settings file.
##
AC_SUBST([UNAME_INFO])
UNAME_INFO=`uname -a`

## ----------------------------------------------------------------------
## Some platforms have broken basename, and/or xargs programs. Check
## that it actually does what it's supposed to do. Catch this early
## since configure and scripts relies upon them heavily and there's
## no use continuing if it's broken.
##
AC_MSG_CHECKING([if basename works])
BASENAME_TEST="`basename /foo/bar/baz/qux/basename_works`"
if test $BASENAME_TEST != "basename_works"; then
  AC_MSG_ERROR([basename program doesn't work])
else
  AC_MSG_RESULT([yes])
fi

## xargs basename used in configure to get the CC_BASENAME value
AC_MSG_CHECKING([if xargs works])
XARGS_TEST="`echo /foo/bar/baz/qux/xargs_works | xargs basename`"
if test $XARGS_TEST != "xargs_works"; then
  AC_MSG_ERROR([xargs program doesn't work])
else
  AC_MSG_RESULT([yes])
fi

## ----------------------------------------------------------------------
## Check that the cache file was build on the same host as what we're
## running on now.
##
AC_CACHE_CHECK([for cached host], [hdf5_cv_host], [hdf5_cv_host="none"]);
if test $hdf5_cv_host = "none"; then
  hdf5_cv_host=$host
elif test $hdf5_cv_host != $host; then
  AC_MSG_ERROR([
     The config.cache file was generated on $hdf5_cv_host but
     this is $host.  Please remove that file and try again.
     config.cache file is invalid])
fi

## ----------------------------------------------------------------------
## Check if we should consider certain compiler warnings as errors
##
## We have to set WARNINGS_AS_ERRORS before sourcing a $host_config
## file, below.
##
## These should NOT be on by default as the risk of breakage is high
## when compiling HDF5 on new (or new versions) of platforms and
## compilers. It can also cause failures when header files we have no
## control over (e.g. MPI, HDFS) raise warnings.
##
AC_MSG_CHECKING([enable warnings as errors])
AC_ARG_ENABLE([warnings-as-errors],
              [AS_HELP_STRING([--enable-warnings-as-errors],
                              [Determines whether certain warnings will be
                               considered errors. This is mainly for use
                               by HDF5 library developers.
                               [default=no]
                               ])],
              [WARNINGS_AS_ERRORS=$enableval])

## Set default
if test "X-$WARNINGS_AS_ERRORS" = X- ; then
  WARNINGS_AS_ERRORS=no
fi

case "X-$WARNINGS_AS_ERRORS" in
  X-yes|X-no)
    AC_MSG_RESULT([$WARNINGS_AS_ERRORS])
    ;;
  *)
    AC_MSG_ERROR([Unrecognized value: $WARNINGS_AS_ERRORS])
    ;;
esac

## ----------------------------------------------------------------------
## Source any special files that we need.  These files normally aren't
## present but can be used by the maintainers to fine tune things like
## turning on debug or profiling flags for the compiler.  The search order
## is:
##
##    CPU-VENDOR-OS
##    VENDOR-OS
##    CPU-OS
##    CPU-VENDOR
##    OS
##    VENDOR
##    CPU
##
## If the `OS' ends with a version number then remove it. For instance,
## `freebsd3.1' would become `freebsd'

case $host_os in
  aix*)
    host_os_novers=aix
    ;;
  freebsd*)
    host_os_novers=freebsd
    ;;
  netbsd*)
    host_os_novers=netbsd
    ;;
  solaris*)
    host_os_novers=solaris
    ;;
  *)
    host_os_novers=$host_os
    ;;
esac

host_config="none"
for f in $host_cpu-$host_vendor-$host_os \
         $host_cpu-$host_vendor-$host_os_novers \
         $host_vendor-$host_os \
         $host_vendor-$host_os_novers \
         $host_cpu-$host_os \
         $host_cpu-$host_os_novers \
         $host_cpu-$host_vendor \
         $host_os \
         $host_os_novers \
         $host_vendor \
         $host_cpu ; do
  AC_MSG_CHECKING([for config $f])
  if test -f "$srcdir/config/$f"; then
    host_config=$srcdir/config/$f
    AC_MSG_RESULT([found])
    break
  fi
  AC_MSG_RESULT([no])
done
if test "X$host_config" != "Xnone"; then
  CC_BASENAME="`echo $CC | cut -f1 -d' ' | xargs basename 2>/dev/null`"
  . $host_config
fi

## Source any special site-specific file
hname="`hostname`"
while test -n "$hname"; do
  file=$srcdir/config/site-specific/host-$hname
  AC_MSG_CHECKING([for config $file])
  if test -f "$file"; then
    . $file
    AC_MSG_RESULT([found])
    break
  fi
  AC_MSG_RESULT([no])
  hname_tmp=$hname
  hname="`echo $hname | cut -d. -f2-99`"
  test "$hname_tmp" = "$hname" && break
done

##
## Enable/disable sanitizer checks for clang compilers, initially address sanitizer
##
AC_MSG_CHECKING([for clang sanitizer checks])
AC_ARG_ENABLE([sanitize-checks],
              [AS_HELP_STRING([--enable-sanitize-checks=address],
                              [(clang/clang++ compilers only) Enable sanitize checks.
                               Address is useful for detecting issues dealing with
                               memory. See AddressSanitizer in config/sanitizer/README.md
                               for more information.
                               [default=none]
                               ])],
              [CLANG_SANITIZE_CHECKS=$enableval])

# Set default
if test "X-$CLANG_SANITIZE_CHECKS" = X- ; then
  CLANG_SANITIZE_CHECKS=none
fi

if test "X$CC_BASENAME" = "Xclang"; then
  AC_SUBST([CLANG_SANITIZE_CHECKS])

  # There are several sanitizer tools.  At present we are testing
  # and describing only -fsanitizer=address with autotools.
  case "X-$CLANG_SANITIZE_CHECKS" in
    X-no|X-none)
      CLANG_SANITIZE_CHECKS=none
      CLANG_SANITIZE_LIST=
      ;;
    *)
      CLANG_SANITIZE_LIST=$CLANG_SANITIZE_CHECKS
      ;;
  esac
  AC_MSG_RESULT([$CLANG_SANITIZE_CHECKS])

  # Other tools can be added to the list of checks
  # The clang compiler doesn't support some of them; they should be
  # checked before adding them to the list in the help message.
  # The sanitizers/sanitizers.cmake file lists these options:
  # address, memory, memoryWithOrigins, undefined, thread, leak,
  # 'address;undefined'.  Which and which combinations of these are
  #  supported varies by compiler version, but unsupported options
  # or combinations will result in configure errors reported in config.log.
  # Comma separated lists of sanitize options will be entered intact in
  # one -fsanitize=<list> flag.  Space separated lists will be entered in
  # separate -fsanitize=<item> flags.
  # NOTE: No sanity checking done here!
  if test -n "$CLANG_SANITIZE_LIST"; then
    H5_CFLAGS="$H5_CFLAGS -fno-omit-frame-pointer"
    H5_CXXFLAGS="$H5_CXXFLAGS -fno-omit-frame-pointer"
    for sanitizer in `echo $CLANG_SANITIZE_LIST`; do
      H5_CFLAGS="$H5_CFLAGS -fsanitize=${sanitizer}"
      H5_CXXFLAGS="$H5_CXXFLAGS -fsanitize=${sanitizer}"
    done
  fi
fi

## ----------------------------------------------------------------------
## Determine build mode (debug, production, clean).
## This has to be done early since the build mode is referred to
## frequently.
##
AC_MSG_CHECKING([build mode])
AC_ARG_ENABLE([build-mode],
              [AS_HELP_STRING([--enable-build-mode=(debug|production|clean)],
                              [Sets the build mode. Debug turns on symbols, API
                               tracing, asserts, and debug optimization,
                               as well as several other minor configure options
                               that aid in debugging.
                               Production turns high optimizations on.
                               Clean turns nothing on and disables optimization
                               (i.e.: a 'clean slate' configuration).
                               All these settings can be overridden by using
                               specific configure flags.
                               [default=debug]
                               ])],
              [BUILD_MODE=$enableval])

## Set the default
## Depends on branch, set via script at branch creation time
if test "X-$BUILD_MODE" = X- ; then
    BUILD_MODE=debug
fi

## Allow this variable to be substituted in
## other files (src/libhdf5.settings.in, etc.)
AC_SUBST([BUILD_MODE])

case "X-$BUILD_MODE" in
  X-clean)
    AC_MSG_RESULT([clean])
    ;;
  X-debug)
    AC_DEFINE([DEBUG_BUILD], [1], [Define if this is a debug build.])
    H5_CFLAGS="$H5_CFLAGS $DEBUG_CFLAGS"
    H5_CPPFLAGS="$H5_CPPFLAGS $DEBUG_CPPFLAGS"
    H5_CXXFLAGS="$H5_CXXFLAGS $DEBUG_CXXFLAGS"
    H5_FCFLAGS="$H5_FCFLAGS $DEBUG_FCFLAGS"
    AC_MSG_RESULT([debug])
    ;;
  X-production)
    H5_CFLAGS="$H5_CFLAGS $PROD_CFLAGS"
    H5_CPPFLAGS="$H5_CPPFLAGS $PROD_CPPFLAGS"
    H5_CXXFLAGS="$H5_CXXFLAGS $PROD_CXXFLAGS"
    H5_FCFLAGS="$H5_FCFLAGS $PROD_FCFLAGS"
    AC_MSG_RESULT([production])
    ;;
  *)
    AC_MSG_ERROR([Unrecognized build mode: $BUILD_MODE. Use debug, production, or clean.])
esac

## ----------------------------------------------------------------------
## Some built-in configure checks can only see CFLAGS (not AM_CFLAGS), so
## we need to add this in so configure works as intended. We will need to
## reset this value at the end of configure, to preserve the user's settings.
CFLAGS="${AM_CFLAGS} ${CFLAGS}"
FCFLAGS="${AM_FCFLAGS} ${FCFLAGS}"
JAVACFLAGS="${AM_JAVACFLAGS} ${JAVACFLAGS}"
JAVAFLAGS="${AM_JAVAFLAGS} ${JAVAFLAGS}"
CXXFLAGS="${AM_CXXFLAGS} ${CXXFLAGS}"
CPPFLAGS="${AM_CPPFLAGS} ${CPPFLAGS}"
LDFLAGS="${AM_LDFLAGS} ${LDFLAGS}"

## ----------------------------------------------------------------------
## Enable dependency tracking unless the configure options or a
## site-specific file told us not to.  This prevents configure from
## silently disabling dependencies for some compilers.
##
if test -z "${enable_dependency_tracking}"; then
  enable_dependency_tracking="yes"
fi

## ----------------------------------------------------------------------
## Check for programs.
##
AC_PROG_CC
CC_BASENAME="`echo $CC | cut -f1 -d' ' | xargs basename 2>/dev/null`"

## ----------------------------------------------------------------------------
## Configure disallows unsupported combinations of options. However, users
## may want to override and build with unsupported combinations for their
## own use. They can use the --enable-unsupported configure flag, which
## ignores any errors from configure due to incompatible flags.
AC_MSG_CHECKING([if unsupported combinations of configure options are allowed])
AC_ARG_ENABLE([unsupported],
              [AS_HELP_STRING([--enable-unsupported],
                              [Allow unsupported combinations of configure options])],
              [ALLOW_UNSUPPORTED=$enableval])

case "X-$ALLOW_UNSUPPORTED" in
  X-|X-no)
    AC_MSG_RESULT([no])
    ;;
  X-yes)
    AC_MSG_RESULT([yes])
    ;;
  *)
    ;;
esac

## ----------------------------------------------------------------------
## Data types and their sizes.
##
AC_TYPE_OFF_T
AC_CHECK_TYPE([ssize_t], [],
        [AC_DEFINE_UNQUOTED([ssize_t], [long],
                [Define to `long' if <sys/types.h> does not define.])])
AC_C_BIGENDIAN
AC_CHECK_SIZEOF([char])
AC_CHECK_SIZEOF([short])
AC_CHECK_SIZEOF([int])
AC_CHECK_SIZEOF([unsigned])
AC_CHECK_SIZEOF([long])
AC_CHECK_SIZEOF([long long])
AC_CHECK_SIZEOF([float])
AC_CHECK_SIZEOF([double])
AC_CHECK_SIZEOF([long double])

## ----------------------------------------------------------------------
## Check if the Fortran interface should be enabled
##

## This needs to be exposed for the library info file even if Fortran is disabled.
AC_SUBST([HDF_FORTRAN])

## Default is no Fortran
HDF_FORTRAN=no

AC_SUBST([HDF5_INTERFACES]) HDF5_INTERFACES=""
AC_MSG_CHECKING([if Fortran interface enabled])
AC_ARG_ENABLE([fortran],
              [AS_HELP_STRING([--enable-fortran],
                              [Compile the Fortran interface [default=no]])],
              [HDF_FORTRAN=$enableval])

AC_MSG_RESULT([$HDF_FORTRAN])

if test "X$HDF_FORTRAN" = "Xyes"; then

## ----------------------------------------------------------------------
## Check for non-standard extension __FLOAT128
##
  HAVE_FLOAT128=0
  HAVE_QUADMATH=0
  FLT128_DIG=0
  LDBL_DIG=0

  AC_CHECK_SIZEOF([__float128])
  AC_CHECK_SIZEOF([_Quad])
  AC_CHECK_HEADERS([quadmath.h], [HAVE_QUADMATH=1], [])
  PAC_FC_LDBL_DIG

  AC_SUBST([PAC_C_MAX_REAL_PRECISION])

  if test "$ac_cv_sizeof___float128" != 0 && test "$FLT128_DIG" != 0 ; then
    AC_DEFINE([HAVE_FLOAT128], [1], [Determine if __float128 is available])
    PAC_C_MAX_REAL_PRECISION=$FLT128_DIG
  else
    PAC_C_MAX_REAL_PRECISION=$LDBL_DIG
  fi
  AC_DEFINE_UNQUOTED([PAC_C_MAX_REAL_PRECISION], $PAC_C_MAX_REAL_PRECISION, [Determine the maximum decimal precision in C])
  AC_MSG_RESULT([$PAC_C_MAX_REAL_PRECISION])

## We will output an include file for Fortran, H5config_f.inc which
## contains various configure definitions used by the Fortran Library.
## Prepend H5_ to all macro names. This avoids name conflict between HDF5 macro
## names and those generated by another software package that uses the HDF5 library.
  AC_CONFIG_HEADERS([fortran/src/H5config_f.inc],
    [cat fortran/src/H5config_f.inc | sed '1d;s%^/\* \(.*\) \*/%\1%;s/#define /#define H5_/;s/#undef /#undef H5_/' >fortran/src/H5config_f.inc.tmp; mv -f fortran/src/H5config_f.inc.tmp fortran/src/H5config_f.inc])

  AC_SUBST([FC])

  HDF5_INTERFACES="$HDF5_INTERFACES fortran"

  ## --------------------------------------------------------------------
  ## HDF5 integer variables for the H5fortran_types.f90 file.
  ##
  AC_SUBST([R_LARGE])
  AC_SUBST([R_INTEGER])
  AC_SUBST([HADDR_T])
  AC_SUBST([HSIZE_T])
  AC_SUBST([HSSIZE_T])
  AC_SUBST([HID_T])
  AC_SUBST([SIZE_T])
  AC_SUBST([OBJECT_NAMELEN_DEFAULT_F])

  ## --------------------------------------------------------------------
  ## Fortran source extension
  ##
  AC_FC_SRCEXT([f90])

  AC_SUBST([F9XSUFFIXFLAG])
  AC_SUBST([FSEARCH_DIRS])

  ## --------------------------------------------------------------------
  ## Check for a Fortran compiler and how to include modules.
  ##
  AC_PROG_FC([PAC_FC_SEARCH_LIST],)
  AC_F9X_MODS

  ## Allow setting the fortran module install dir
  AC_ARG_WITH([fmoddir],
    [AS_HELP_STRING([--with-fmoddir=DIR], [Fortran module install directory])],
    [fmoddir=$withval],
    [fmoddir="\${includedir}"])
  AC_SUBST([fmoddir], [$fmoddir])

  ## Change to the Fortran 90 language
  AC_LANG_PUSH(Fortran)

  ## Checking if the compiler supports the required Fortran 2003 features and
  ## stopping if it does not.
  PAC_PROG_FC_HAVE_F2003_REQUIREMENTS

  if test "X$HAVE_F2003_REQUIREMENTS" = "Xno"; then
    AC_MSG_ERROR([Fortran compiler lacks required Fortran 2003 features; unsupported Fortran 2003 compiler, remove --enable-fortran])
  fi

  ## --------------------------------------------------------------------
  ## Define wrappers for the C compiler to use Fortran function names
  ##
  AC_FC_WRAPPERS

  ## --------------------------------------------------------------------
  ## See if the fortran compiler supports the intrinsic function "SIZEOF"
  PAC_PROG_FC_SIZEOF

  ## See if the fortran compiler supports the intrinsic function "C_SIZEOF"
  PAC_PROG_FC_C_SIZEOF

  ## See if the fortran compiler supports the intrinsic function "STORAGE_SIZE"
  PAC_PROG_FC_STORAGE_SIZE

  ## Set the sizeof function for use later in the fortran tests
  if test "X$HAVE_STORAGE_SIZE_FORTRAN" = "Xyes";then
    FC_SIZEOF_A="STORAGE_SIZE(a, c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t)"
    FC_SIZEOF_B="STORAGE_SIZE(b, c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t)"
    FC_SIZEOF_C="STORAGE_SIZE(c, c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t)"
  else
    if test "X$HAVE_SIZEOF_FORTRAN" = "Xyes";then
      FC_SIZEOF_A="SIZEOF(a)"
      FC_SIZEOF_B="SIZEOF(b)"
      FC_SIZEOF_C="SIZEOF(c)"
    else
      ## If neither intrinsic functions SIZEOF or STORAGE_SIZE is available then stop configure with an error
      AC_MSG_ERROR([Fortran compiler requires either intrinsic functions SIZEOF or STORAGE_SIZE])
    fi
  fi

  ## See if the fortran compiler supports the intrinsic module "ISO_FORTRAN_ENV"
  PAC_PROG_FC_ISO_FORTRAN_ENV
  ## Check KIND and size of native integer
  PAC_FC_NATIVE_INTEGER

  ## Find all available KINDs
  PAC_FC_AVAIL_KINDS
  ## Find all sizeofs for available KINDs
  PAC_FC_SIZEOF_INT_KINDS
  PAC_FC_SIZEOF_REAL_KINDS

  AC_SUBST([PAC_FC_ALL_REAL_KINDS])
  AC_SUBST([PAC_FC_MAX_REAL_PRECISION])
  AC_SUBST([PAC_FORTRAN_NUM_INTEGER_KINDS])
  AC_SUBST([PAC_FC_ALL_INTEGER_KINDS])
  AC_SUBST([PAC_FC_ALL_REAL_KINDS_SIZEOF])
  AC_SUBST([PAC_FC_ALL_INTEGER_KINDS_SIZEOF])
  AC_SUBST([PAC_FORTRAN_NATIVE_INTEGER_KIND])
  AC_SUBST([PAC_FORTRAN_NATIVE_INTEGER_SIZEOF])
  AC_SUBST([PAC_FORTRAN_NATIVE_REAL_KIND])
  AC_SUBST([PAC_FORTRAN_NATIVE_REAL_SIZEOF])
  AC_SUBST([PAC_FORTRAN_NATIVE_DOUBLE_KIND])
  AC_SUBST([PAC_FORTRAN_NATIVE_DOUBLE_SIZEOF])
  AC_SUBST([HAVE_Fortran_INTEGER_SIZEOF_16])
  AC_SUBST([FORTRAN_HAVE_C_LONG_DOUBLE])
  AC_SUBST([FORTRAN_C_LONG_DOUBLE_IS_UNIQUE])
  AC_SUBST([H5CONFIG_F_NUM_RKIND])
  AC_SUBST([H5CONFIG_F_RKIND])
  AC_SUBST([H5CONFIG_F_RKIND_SIZEOF])
  AC_SUBST([H5CONFIG_F_NUM_IKIND])
  AC_SUBST([H5CONFIG_F_IKIND])
  AC_SUBST([Fortran_COMPILER_ID])
  Fortran_COMPILER_ID=none
  AC_DEFINE_UNQUOTED([Fortran_COMPILER_ID], $Fortran_COMPILER_ID, [Define Fortran compiler ID])

  ## Setting definition if there is a 16 byte fortran integer
  if `echo $PAC_FC_ALL_INTEGER_KINDS_SIZEOF | grep '16' >/dev/null`; then
    HAVE_Fortran_INTEGER_SIZEOF_16="1"
    AC_DEFINE([HAVE_Fortran_INTEGER_SIZEOF_16], [1], [Determine if INTEGER*16 is available])
  else
    HAVE_Fortran_INTEGER_SIZEOF_16="0"
    AC_DEFINE([HAVE_Fortran_INTEGER_SIZEOF_16], [0], [Determine if INTEGER*16 is available])
  fi

  if test "X$HAVE_STORAGE_SIZE_FORTRAN" = "Xyes"; then
    AC_DEFINE([FORTRAN_HAVE_STORAGE_SIZE], [1], [Define if we have Fortran intrinsic STORAGE_SIZE])
  fi

  if test "X$HAVE_C_SIZEOF_FORTRAN" = "Xyes"; then
    AC_DEFINE([FORTRAN_HAVE_C_SIZEOF], [1], [Define if we have Fortran intrinsic C_SIZEOF])
  fi

  if test "X$HAVE_SIZEOF_FORTRAN" = "Xyes"; then
    AC_DEFINE([FORTRAN_HAVE_SIZEOF], [1], [Define if we have Fortran intrinsic SIZEOF])
  fi

  ## See if C_LONG_DOUBLE is available
  PAC_PROG_FC_HAVE_C_LONG_DOUBLE

  FORTRAN_HAVE_C_LONG_DOUBLE="0"
  if test "X$HAVE_C_LONG_DOUBLE_FORTRAN" = "Xyes"; then
    FORTRAN_HAVE_C_LONG_DOUBLE="1"
    AC_DEFINE([FORTRAN_HAVE_C_LONG_DOUBLE], [1], [Define if we have Fortran C_LONG_DOUBLE])
  fi

  ## Is C_LONG_DOUBLE different from C_DOUBLE
  FORTRAN_C_LONG_DOUBLE_IS_UNIQUE="0"
  if test "$FORTRAN_HAVE_C_LONG_DOUBLE" = "1"; then
    PAC_PROG_FC_C_LONG_DOUBLE_EQ_C_DOUBLE
    if test "X$C_LONG_DOUBLE_IS_UNIQUE_FORTRAN" = "Xyes"; then
      FORTRAN_C_LONG_DOUBLE_IS_UNIQUE="1"
      AC_DEFINE([FORTRAN_C_LONG_DOUBLE_IS_UNIQUE], [1], [Define if Fortran C_LONG_DOUBLE is different from C_DOUBLE])
    else
      FORTRAN_C_LONG_DOUBLE_IS_UNIQUE="0"
    fi
  fi

  FORTRAN_SIZEOF_LONG_DOUBLE=${ac_cv_sizeof_long_double}
  AC_DEFINE_UNQUOTED([FORTRAN_SIZEOF_LONG_DOUBLE], ["${ac_cv_sizeof_long_double}"], [Determine the size of C long double])

  dnl get the largest sizeof for REAL kinds
  max_real_fortran_sizeof="`echo $PAC_FC_ALL_REAL_KINDS_SIZEOF | sed -ne 's/.*,\([[0-9]]*\)}/\1/p'`"