Skip to content

Commit

Permalink
Debug facility for the RTF output
Browse files Browse the repository at this point in the history
Debug facility for the RTF output, i.e.
- preserve temporary files
- show the conversion of names to labels as used in anchors.
  • Loading branch information
albert-github committed Jun 17, 2021
1 parent 6fc45ba commit 9073285
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ static std::map< std::string, Debug::DebugMask > s_labels =
{ "lex", Debug::Lex },
{ "plantuml", Debug::Plantuml },
{ "fortranfixed2free", Debug::FortranFixed2Free },
{ "cite", Debug::Cite }
{ "cite", Debug::Cite },
{ "rtf", Debug::Rtf }
};

//------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class Debug
Plantuml = 0x00004000,
FortranFixed2Free = 0x00008000,
Cite = 0x00010000,
NoLineNo = 0x00020000
NoLineNo = 0x00020000,
Rtf = 0x00040000
};
static void print(DebugMask mask,int prio,const char *fmt,...);

Expand Down
16 changes: 13 additions & 3 deletions src/rtfgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "namespacedef.h"
#include "dir.h"
#include "utf8.h"
#include "debug.h"


//#define DBG_RTF(x) x;
Expand Down Expand Up @@ -2428,6 +2429,7 @@ static void encodeForOutput(TextStream &t,const QCString &s)
*/
static bool preProcessFile(Dir &d,const QCString &infName, TextStream &t, bool bIncludeHeader=TRUE)
{
static bool rtfDebug = Debug::isFlagSet(Debug::Rtf);
std::ifstream f(infName.str(),std::ifstream::in);
if (!f.is_open())
{
Expand Down Expand Up @@ -2488,7 +2490,7 @@ static bool preProcessFile(Dir &d,const QCString &infName, TextStream &t, bool b
}
f.close();
// remove temporary file
d.remove(infName.str());
if (!rtfDebug) d.remove(infName.str());
return TRUE;
}

Expand Down Expand Up @@ -2640,6 +2642,7 @@ void testRTFOutput(const QCString &name)
*/
bool RTFGenerator::preProcessFileInplace(const QCString &path,const QCString &name)
{
static bool rtfDebug = Debug::isFlagSet(Debug::Rtf);
Dir d(path.str());
// store the original directory
if (!d.exists())
Expand Down Expand Up @@ -2670,15 +2673,22 @@ bool RTFGenerator::preProcessFileInplace(const QCString &path,const QCString &na
// it failed, remove the temp file
outt.flush();
f.close();
thisDir.remove(combinedName.str());
if (!rtfDebug) thisDir.remove(combinedName.str());
Dir::setCurrent(oldDir);
return FALSE;
}

// everything worked, move the files
outt.flush();
f.close();
thisDir.remove(mainRTFName.str());
if (!rtfDebug)
{
thisDir.remove(mainRTFName.str());
}
else
{
thisDir.rename(mainRTFName.str(),mainRTFName.str() + ".org");
}
thisDir.rename(combinedName.str(),mainRTFName.str());

testRTFOutput(mainRTFName);
Expand Down
2 changes: 1 addition & 1 deletion src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5233,7 +5233,7 @@ QCString rtfFormatBmkStr(const QCString &name)
}
}

//printf("Name = %s RTF_tag = %s\n",name,qPrint(*tag)));
Debug::print(Debug::Rtf,0,"Name = %s RTF_tag = %s\n",qPrint(name),qPrint(tag));
return tag;
}

Expand Down

0 comments on commit 9073285

Please sign in to comment.