diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2000-07-31 18:09:08 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2000-07-31 18:09:08 (GMT) |
commit | 5ad8b41eb93b9ca6a4c2ce90837103f8a4e750d8 (patch) | |
tree | 8b6d1855a77a3cfa84674b2918bdb7c6478b94ae /src/util.cpp | |
parent | 7ce8e31b7d4f831949f7061ef2808c867da4edd1 (diff) | |
download | Doxygen-5ad8b41eb93b9ca6a4c2ce90837103f8a4e750d8.zip Doxygen-5ad8b41eb93b9ca6a4c2ce90837103f8a4e750d8.tar.gz Doxygen-5ad8b41eb93b9ca6a4c2ce90837103f8a4e750d8.tar.bz2 |
Release-1.2.0-20000731
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 42 |
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) |