summaryrefslogtreecommitdiffstats
path: root/src/util.cpp
diff options
context:
space:
mode:
authordimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2000-07-31 18:09:08 (GMT)
committerdimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2000-07-31 18:09:08 (GMT)
commite139c0246413d3803028572dcafe9f065f4c9eab (patch)
tree8b6d1855a77a3cfa84674b2918bdb7c6478b94ae /src/util.cpp
parent3876f92c80e9cc62af30916f0ccdeb83cdc2ff05 (diff)
downloadDoxygen-e139c0246413d3803028572dcafe9f065f4c9eab.zip
Doxygen-e139c0246413d3803028572dcafe9f065f4c9eab.tar.gz
Doxygen-e139c0246413d3803028572dcafe9f065f4c9eab.tar.bz2
Release-1.2.0-20000731
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 1870400..5158031 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -838,6 +838,23 @@ QCString fileToString(const char *name)
if (name[0]=='-' && name[1]==0) // read from stdin
{
fileOpened=f.open(IO_ReadOnly,stdin);
+ if (fileOpened)
+ {
+ const int bSize=4096;
+ QCString contents(bSize);
+ int totalSize=0;
+ int size;
+ while ((size=f.readBlock(contents.data()+totalSize,bSize))==bSize)
+ {
+ totalSize+=bSize;
+ contents.resize(totalSize+bSize);
+ }
+ totalSize+=size+2;
+ contents.resize(totalSize);
+ contents.at(totalSize-2)='\n'; // to help the scanner
+ contents.at(totalSize-1)='\0';
+ return contents;
+ }
}
else // read from file
{
@@ -849,22 +866,25 @@ QCString fileToString(const char *name)
}
f.setName(name);
fileOpened=f.open(IO_ReadOnly);
+ if (fileOpened)
+ {
+ int fsize=f.size();
+ QCString contents(fsize+2);
+ f.readBlock(contents.data(),fsize);
+ if (fsize==0 || contents[fsize-1]=='\n')
+ contents[fsize]='\0';
+ else
+ contents[fsize]='\n'; // to help the scanner
+ contents[fsize+1]='\0';
+ f.close();
+ return contents;
+ }
}
if (!fileOpened)
{
err("Error: cannot open file `%s' for reading\n",name);
- return "";
}
- int fsize=f.size();
- QCString contents(fsize+2);
- f.readBlock(contents.data(),fsize);
- if (fsize==0 || contents[fsize-1]=='\n')
- contents[fsize]='\0';
- else
- contents[fsize]='\n';
- contents[fsize+1]='\0';
- f.close();
- return contents;
+ return "";
}
QCString dateToString(bool includeTime)