diff options
author | albert-github <albert.tests@gmail.com> | 2020-09-15 10:30:40 (GMT) |
---|---|---|
committer | albert-github <albert.tests@gmail.com> | 2020-09-15 10:30:40 (GMT) |
commit | a88b298bee89f001072c80e32e04dfd855d05c58 (patch) | |
tree | 0a1d06808ba9db730e2016bd5150116e298c38c4 /src | |
parent | 0fc06d657d596adcc289a5f228973ea268efd66d (diff) | |
download | Doxygen-a88b298bee89f001072c80e32e04dfd855d05c58.zip Doxygen-a88b298bee89f001072c80e32e04dfd855d05c58.tar.gz Doxygen-a88b298bee89f001072c80e32e04dfd855d05c58.tar.bz2 |
Incorrect duplicate code for Fortran fixed/free recognition
There were 2 routines to recognize whether Fortran code was Fixed of Free format code, though the version in `commentcnv.l` didn't take the settings of `EXTENSION_MAPPING` into account which might lead to incorrect recognition of the format, this has been corrected.
Diffstat (limited to 'src')
-rw-r--r-- | src/commentcnv.l | 42 | ||||
-rw-r--r-- | src/doxygen.cpp | 6 | ||||
-rw-r--r-- | src/fortranscanner.h | 3 | ||||
-rw-r--r-- | src/fortranscanner.l | 43 | ||||
-rw-r--r-- | src/parserintf.h | 18 | ||||
-rw-r--r-- | src/util.cpp | 55 | ||||
-rw-r--r-- | src/util.h | 3 |
7 files changed, 76 insertions, 94 deletions
diff --git a/src/commentcnv.l b/src/commentcnv.l index c1ec170..2cf1a39 100644 --- a/src/commentcnv.l +++ b/src/commentcnv.l @@ -1108,45 +1108,6 @@ static void replaceComment(yyscan_t yyscanner,int offset) } } -// simplified way to know if this is fixed form -// duplicate in fortrancode.l -static bool recognizeFixedForm(const char* contents) -{ - int column=0; - bool skipLine=FALSE; - - for(int i=0;;i++) { - column++; - - switch(contents[i]) { - case '\n': - column=0; - skipLine=FALSE; - break; - case ' ': - break; - case '\000': - return FALSE; - case 'C': - case 'c': - case '*': - if(column==1) return TRUE; - if(skipLine) break; - return FALSE; - case '!': - if(column>1 && column<7) return FALSE; - skipLine=TRUE; - break; - default: - if(skipLine) break; - if(column==7) return TRUE; - return FALSE; - } - } - return FALSE; -} - - /*! This function does three things: * -# It converts multi-line C++ style comment blocks (that are aligned) * to C style comment blocks (if MULTILINE_CPP_IS_BRIEF is set to NO). @@ -1183,7 +1144,8 @@ void convertCppComments(BufStr *inBuf,BufStr *outBuf,const char *fileName) yyextra->isFixedForm = FALSE; if (yyextra->lang==SrcLangExt_Fortran) { - yyextra->isFixedForm = recognizeFixedForm(inBuf->data()); + FortranFormat fmt = convertFileNameFortranParserCode(fileName); + yyextra->isFixedForm = recognizeFixedForm(inBuf->data(),fmt); } if (yyextra->lang==SrcLangExt_Markdown) diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 0832e5c..a8cda22 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -10838,14 +10838,14 @@ void parseInput() if (!dir.mkdir(outputDirectory)) { err("tag OUTPUT_DIRECTORY: Output directory '%s' does not " - "exist and cannot be created\n",outputDirectory.data()); + "exist and cannot be created\n",outputDirectory.data()); cleanUpDoxygen(); exit(1); } else { - msg("Notice: Output directory '%s' does not exist. " - "I have created it for you.\n", outputDirectory.data()); + msg("Notice: Output directory '%s' does not exist. " + "I have created it for you.\n", outputDirectory.data()); } dir.cd(outputDirectory); } diff --git a/src/fortranscanner.h b/src/fortranscanner.h index 3133820..0fbba89 100644 --- a/src/fortranscanner.h +++ b/src/fortranscanner.h @@ -53,9 +53,6 @@ class FortranOutlineParserFixed : public FortranOutlineParser FortranOutlineParserFixed() : FortranOutlineParser(FortranFormat_Fixed) { } }; -bool recognizeFixedForm(const char* contents, FortranFormat format); - const char* prepassFixedForm(const char* contents, int *hasContLine); - #endif diff --git a/src/fortranscanner.l b/src/fortranscanner.l index ed41d81..dfca1f8 100644 --- a/src/fortranscanner.l +++ b/src/fortranscanner.l @@ -1498,49 +1498,6 @@ void truncatePrepass(yyscan_t yyscanner,int index) yyextra->inputStringPrepass.truncate(index); } -// simplified way to know if this is fixed form -bool recognizeFixedForm(const char* contents, FortranFormat format) -{ - int column=0; - bool skipLine=FALSE; - - if (format == FortranFormat_Fixed) return TRUE; - if (format == FortranFormat_Free) return FALSE; - - for(int i=0;;i++) { - column++; - - switch(contents[i]) { - case '\n': - column=0; - skipLine=FALSE; - break; - case ' ': - break; - case '\000': - return FALSE; - case '#': - skipLine=TRUE; - break; - case 'C': - case 'c': - case '*': - if (column==1) return TRUE; - if (skipLine) break; - return FALSE; - case '!': - if (column>1 && column<7) return FALSE; - skipLine=TRUE; - break; - default: - if (skipLine) break; - if (column>=7) return TRUE; - return FALSE; - } - } - return FALSE; -} - /* This function assumes that contents has at least size=length+1 */ static void insertCharacter(char *contents, int length, int pos, char c) { diff --git a/src/parserintf.h b/src/parserintf.h index 911b707..3087aa3 100644 --- a/src/parserintf.h +++ b/src/parserintf.h @@ -149,18 +149,19 @@ class ParserManager struct ParserPair { - ParserPair(OutlineParserFactory opf, std::unique_ptr<CodeParserInterface> cpi) - : outlineParserFactory(opf), codeParserInterface(std::move(cpi)) + ParserPair(OutlineParserFactory opf, std::unique_ptr<CodeParserInterface> cpi, const QCString pn) + : outlineParserFactory(opf), codeParserInterface(std::move(cpi)), parserName(pn) { } OutlineParserFactory outlineParserFactory; std::unique_ptr<CodeParserInterface> codeParserInterface; + QCString parserName; }; ParserManager(OutlineParserFactory outlineParserFactory, std::unique_ptr<CodeParserInterface> codeParserInterface) - : m_defaultParsers(outlineParserFactory,std::move(codeParserInterface)) + : m_defaultParsers(outlineParserFactory,std::move(codeParserInterface), "") { } @@ -176,7 +177,7 @@ class ParserManager std::unique_ptr<CodeParserInterface> codeParserInterface) { m_parsers.emplace(std::string(name), - ParserPair(outlineParserFactory,std::move(codeParserInterface))); + ParserPair(outlineParserFactory,std::move(codeParserInterface),name)); } /** Registers a file \a extension with a parser with name \a parserName. @@ -216,6 +217,15 @@ class ParserManager return *getParsers(extension).codeParserInterface; } + /** Gets the name of the parser associated with given \a extension. + * If there is no parser explicitly registered for the supplied extension, + * te empty string will be reurned. + */ + QCString getParserName(const char *extension) + { + return getParsers(extension).parserName; + } + private: ParserPair &getParsers(const char *extension) { diff --git a/src/util.cpp b/src/util.cpp index 0581b5f..38cb5c9 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1828,7 +1828,7 @@ QCString removeRedundantWhiteSpace(const QCString &s) { if (nc != '=') // avoid splitting operator&= - { + { *dst++=' '; } } @@ -8474,3 +8474,56 @@ int usedTableLevels() } //------------------------------------------------------ +// simplified way to know if this is fixed form +bool recognizeFixedForm(const char* contents, FortranFormat format) +{ + int column=0; + bool skipLine=FALSE; + + if (format == FortranFormat_Fixed) return TRUE; + if (format == FortranFormat_Free) return FALSE; + + for(int i=0;;i++) { + column++; + + switch(contents[i]) { + case '\n': + column=0; + skipLine=FALSE; + break; + case ' ': + break; + case '\000': + return FALSE; + case '#': + skipLine=TRUE; + break; + case 'C': + case 'c': + case '*': + if (column==1) return TRUE; + if (skipLine) break; + return FALSE; + case '!': + if (column>1 && column<7) return FALSE; + skipLine=TRUE; + break; + default: + if (skipLine) break; + if (column>=7) return TRUE; + return FALSE; + } + } + return FALSE; +} + +FortranFormat convertFileNameFortranParserCode(QCString fn) +{ + QCString ext = getFileNameExtension(fn); + QCString parserName = Doxygen::parserManager->getParserName(ext.data()); + + if (parserName == "fortranfixed") return FortranFormat_Fixed; + else if (parserName == "fortranfree") return FortranFormat_Free; + + return FortranFormat_Unknown; +} @@ -502,4 +502,7 @@ int usedTableLevels(); void incUsedTableLevels(); void decUsedTableLevels(); +bool recognizeFixedForm(const char* contents, FortranFormat format); +FortranFormat convertFileNameFortranParserCode(QCString fn); + #endif |