[Libreoffice] Need a little help with the easyhack "Strip include guards in idl files"
Nuno J. Silva
nunojsilva at ist.utl.pt
Sun Mar 27 04:21:07 PDT 2011
Julien Nabet <serval2412 at yahoo.fr> writes:
> Concerning the easyhack "Strip include guards in idl files", I pushed
> 2 patches for the directory "ure/udkapi".
[...]
> Then to check it was ok, i used this command to search ifndef line
> followed by include line in idl files :
> find . -name "*.idl"|xargs pcregrep -M 'ifndef.*\n.*include'
[...]
> There were few to process manually so I did it and pushed a second patch.
>
>
> Then I took a look at the directory "ure/offapi". There are about 3700
> files and the strip-guards script lets a lot (more than 3000!) of
> "#ifndef" with "#include".( I don't know why, a pb of Unix/Dos
> end-of-line perhaps ?)
> This time it's too much to do it manually.
> Some idea to improve the strip-guards script ?
I looked at your commit with the manually fixed guards[1] and at least
some of these are explainable. Maybe that's why there are so many guards
left in offapi:
[1] http://cgit.freedesktop.org/libreoffice/ure/commit/?id=cab76775a72e2e9e6cd242bbf87dd23475999164
- Some guards end with _idl_idl__ instead of _idl__. If I understood the
script correctly, this should not be an issue, because it visits the
included files and retrieves the right guard from there. But some are
wrong, like
#ifndef __com_sun_star_lang_XServiceInfo_idl_idl__
#include <com/sun/star/lang/XServiceInfo.idl>
Because the file actually defines
#define __com_sun_star_lang_XServiceInfo_idl__
So these will not get caught by the script.
Unless there's a good reason to have _idl_idl__ in a guard name (like
if there are actually .idl.idl files), maybe these should be changed
to _idl__ to fix the ifndefs themselves and to allow the script to
find them.
- Some guards are written with lower case, while they're defined in
upper case in the included file, like
#ifndef __com_sun_star_bridge_XBridge_idl__
#include <com/sun/star/bridge/XBridge.idl>
while the file does
#define _COM_SUN_STAR_BRIDGE_XBRIDGE_IDL_
The script allows it the other way around, that is, upper case guards
in ifndefs around includes. (Although I wonder if guards are really
case-insensitive.)
> I know very little of Perl,
Same here.
> does anybody got an idea to avoid to
> process 3700 files by hand ?
I'd say "regular expressions"! :-)
--
Nuno J. Silva
gopher://sdf-eu.org/1/users/njsg
More information about the LibreOffice
mailing list