diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2001-08-01 18:08:50 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2001-08-01 18:08:50 (GMT) |
commit | ecb8f53e30524a6eca3c28db4d1a1d708a5a0976 (patch) | |
tree | dd7f0f7dd0875046b1426a541b00547a8af08af1 /src/config.l | |
parent | 7703ff62ed5e27d32af03d4a613f16e8a3320eb1 (diff) | |
download | Doxygen-ecb8f53e30524a6eca3c28db4d1a1d708a5a0976.zip Doxygen-ecb8f53e30524a6eca3c28db4d1a1d708a5a0976.tar.gz Doxygen-ecb8f53e30524a6eca3c28db4d1a1d708a5a0976.tar.bz2 |
Release-1.2.9
Diffstat (limited to 'src/config.l')
-rw-r--r-- | src/config.l | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/src/config.l b/src/config.l index 583195c..3a887a6 100644 --- a/src/config.l +++ b/src/config.l @@ -2165,28 +2165,68 @@ void Config::create() // The IMAGE_PATTERNS tag is now officially obsolete. } - -bool Config::parse(const char *fn) +static QCString configFileToString(const char *name) { - QFileInfo fi( fn ); - if (!fi.exists()) + if (name==0 || name[0]==0) return 0; + QFile f; + + bool fileOpened=FALSE; + if (name[0]=='-' && name[1]==0) // read from stdin { - return FALSE; + 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; + } } - QFile f( fn ); - if (!f.open(IO_ReadOnly)) + else // read from file { - return FALSE; + QFileInfo fi(name); + if (!fi.exists() || !fi.isFile()) + { + config_err("Error: file `%s' not found\n",name); + return ""; + } + 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; + } } - // read file into a string buffer - int fsize = fi.size(); - QCString contents(fsize+1); // add room for \0 terminator - if (f.readBlock(contents.data(),fsize)!=fsize) + if (!fileOpened) { - return FALSE; + config_err("Error: cannot open file `%s' for reading\n",name); } - contents[fsize]='\0'; + return ""; +} + +bool Config::parse(const char *fn) +{ + QCString contents = configFileToString(fn); config = Config::instance(); inputString = contents.data(); inputPosition = 0; |