[Ctool-develop] separating preprocessing and parsing
Brought to you by:
flisakow
|
From: Stefan S. <se...@sy...> - 2003-08-22 09:40:37
|
hi there,
I'm looking at the project.cc file, specifically the Project::parse
function. I'd like to reimplement this method using two new methods -
preprocess and parse - such that the old parse method becomes obsolete
and is only provided for backward compatibility.
I'm now in the process to implement the 'preprocess' method, and
I'm looking at the old code for inspiration. I'm hesitant to just
cut&paste the code I see because I don't understand it. Or better,
it looks quite suspicious, and I'm wondering whether anybody is
actually using it.
Examples:
* the default 'cd_cmd' parameter is "cd % ;", but that string, taken
as a format string for 'sprintf' doesn't do anything, i.e. I guess
it's a typo and it actually should read "cd %s ;".
* the ctdemo passes 'NULL' for the cd_cmd if it isn't explicitely
specified per '-cdcmmd' argument. What happens, if 'sprintf'
receives a NULL format string ??
* I see code such as
if (use_cpp)
{
if (cpp_outputfile)
strcpy(cpp_file, cpp_outputfile);
if (cpp_dir)
sprintf(cpp_cmmd, cd_cmd, cpp_dir);
if (cpp_cmd)
sprintf(cpp_cmmd, cpp_cmd, path, cpp_file);
else
...
which means the 'cpp_cmmd' variable is overridden each time
'sprintf' is called.
I'm obviously something missing here, though I don't see what.
Or is it simply that there is lots of redundant code, i.e.
this code gets never used, and so the 'bugs' never surface ?
I'm tempted to just reimplement the 'preprocess' method
and then use that instead.
Any comments ?
Best regards,
Stefan
|