summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2013-07-02 18:58:09 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2013-07-02 18:58:09 (GMT)
commita7da2bd6fa144dc469aa4f74138adf162c0a2c7f (patch)
treee78626552b8645b46b7c1bd64c02b17eefd84619 /src
parent4c50bd75c871e9997c58fac732c719d2d67eedd1 (diff)
downloadDoxygen-a7da2bd6fa144dc469aa4f74138adf162c0a2c7f.zip
Doxygen-a7da2bd6fa144dc469aa4f74138adf162c0a2c7f.tar.gz
Doxygen-a7da2bd6fa144dc469aa4f74138adf162c0a2c7f.tar.bz2
Bug 702491 - UTF-16LE BOM not handled by source browser and \snippet
Diffstat (limited to 'src')
-rw-r--r--src/util.cpp22
-rw-r--r--src/util.h3
2 files changed, 20 insertions, 5 deletions
diff --git a/src/util.cpp b/src/util.cpp
index f207430..9fbcdfa 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -2420,6 +2420,19 @@ QCString fileToString(const char *name,bool filter,bool isSourceCode)
err("file `%s' not found\n",name);
return "";
}
+ BufStr buf(fi.size());
+ fileOpened=readInputFile(name,buf,filter,isSourceCode);
+ if (fileOpened)
+ {
+ int s = buf.size();
+ if (s>1 && buf.at(s-2)!='\n')
+ {
+ buf.at(s-1)='\n';
+ buf.addChar(0);
+ }
+ return buf.data();
+ }
+#if 0
QCString filterName = getFileFilter(name,isSourceCode);
if (filterName.isEmpty() || !filter)
{
@@ -2472,6 +2485,7 @@ QCString fileToString(const char *name,bool filter,bool isSourceCode)
Debug::print(Debug::FilterOutput,0,"-------------\n%s\n-------------\n",contents.data());
return transcodeCharacterStringToUTF8(contents);
}
+#endif
}
if (!fileOpened)
{
@@ -7345,7 +7359,7 @@ static int transcodeCharacterBuffer(const char *fileName,BufStr &srcBuf,int size
}
//! read a file name \a fileName and optionally filter and transcode it
-bool readInputFile(const char *fileName,BufStr &inBuf)
+bool readInputFile(const char *fileName,BufStr &inBuf,bool filter,bool isSourceCode)
{
// try to open file
int size=0;
@@ -7354,8 +7368,8 @@ bool readInputFile(const char *fileName,BufStr &inBuf)
QFileInfo fi(fileName);
if (!fi.exists()) return FALSE;
- QCString filterName = getFileFilter(fileName,FALSE);
- if (filterName.isEmpty())
+ QCString filterName = getFileFilter(fileName,isSourceCode);
+ if (filterName.isEmpty() || !filter)
{
QFile f(fileName);
if (!f.open(IO_ReadOnly))
@@ -7432,7 +7446,7 @@ bool readInputFile(const char *fileName,BufStr &inBuf)
inBuf.shrink(newSize); // resize the array
//printf(".......resizing from %d to %d result=[%s]\n",oldPos+size,oldPos+newSize,dest.data());
}
- inBuf.at(inBuf.curPos())='\0';
+ inBuf.addChar(0);
return TRUE;
}
diff --git a/src/util.h b/src/util.h
index e19e829..1aba005 100644
--- a/src/util.h
+++ b/src/util.h
@@ -372,7 +372,8 @@ QCString convertCharEntitiesToUTF8(const QCString &s);
void stackTrace();
-bool readInputFile(const char *fileName,BufStr &inBuf);
+bool readInputFile(const char *fileName,BufStr &inBuf,
+ bool filter=TRUE,bool isSourceCode=FALSE);
QCString filterTitle(const QCString &title);
bool patternMatch(const QFileInfo &fi,const QStrList *patList);