summaryrefslogtreecommitdiffstats
path: root/src/config.l
diff options
context:
space:
mode:
authordimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2001-08-01 18:08:50 (GMT)
committerdimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2001-08-01 18:08:50 (GMT)
commit071e39254b00ad7ffed5de8cdeb44072278d4d57 (patch)
treedd7f0f7dd0875046b1426a541b00547a8af08af1 /src/config.l
parentea8a1bc7ccbd7b64a31c293caa31240bde7397cf (diff)
downloadDoxygen-071e39254b00ad7ffed5de8cdeb44072278d4d57.zip
Doxygen-071e39254b00ad7ffed5de8cdeb44072278d4d57.tar.gz
Doxygen-071e39254b00ad7ffed5de8cdeb44072278d4d57.tar.bz2
Release-1.2.9
Diffstat (limited to 'src/config.l')
-rw-r--r--src/config.l68
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;