On Thu, 13 Jan 2005, Paul Vriens wrote:
[...]
how do you cater for the following in your one-liner:

include/accctrl.h:#define ACTRL_RESERVED              0x00000000
include/accctrl.h:#define ACTRL_DS_OPEN               ACTRL_RESERVED

good luck :-)

The previous script doesn't. Handling this is a bit more tricky, mostly because of sed's restrictions on regular expressions.


Fortunately perl is there to save the day!
There you go:

new=`perl -n -e 'chomp;if (s/^ *# *define *([a-zA-Z_][a-zA-Z0-9_]*) *0(x0+L?)? *\$/\$1/) 
{print;print " ";}' include/*.h`
while [ -n "$new" ]
do
    new=`echo "$new" | sed -e 's/ $//' -e 's/ NULL / /' -e 's/ /|/g'`
    if [ -z "$regexp" ]
    then
        regexp="$new"
    else
        regexp="$regexp|$new"
    fi
    new=`perl -n -e "chomp;if (s/^ *# *define *([a-zA-Z_][a-zA-Z0-9_]*) *($new) 
*\\$/\\$1/) {print;print ' ';}" include/*.h`
    echo "Synonyms: $new"
done
find . -name "*.[chly]" -print0 | xargs -0 perl -n -e "if (eof) {close ARGV;};if (/& 
*($regexp)(?![a-zA-Z0-9_]| ==)/ or /($regexp) *&[^&]/) {print \"\$ARGV:\$.: \$_\";}"

Hopefully it won't be too line wrapped.
And here's the result, with no false positives this time, thanks to perl's negative lookhead.


./dlls/comctl32/listview.c:6297:         if (nColumn == 0 || lpColumn->fmt & 
LVCFMT_LEFT)
./dlls/comctl32/pager.c:844:     if (!(dwStyle & PGS_HORZ) && !(dwStyle & 
PGS_VERT))
./dlls/commdlg/filedlgbrowser.c:320:    (wFlags & SBSP_ABSOLUTE) ? "SBSP_ABSOLUTE" : 
"SBPS_????");
./dlls/dplayx/dplay.c:1164:   if( ( dwFlags & DPSET_REMOTE ) &&
./dlls/dplayx/dplay.c:1180:     if( dwFlags & DPSET_REMOTE )
./dlls/dplayx/dplay.c:1363:   if( ( dwFlags & DPSET_REMOTE ) &&
./dlls/dplayx/dplay.c:1379:     if( dwFlags & DPSET_REMOTE )
./dlls/dplayx/dplay.c:2430:   if( dwFlags & DPSET_REMOTE )
./dlls/dplayx/dplay.c:2635:   if( dwFlags & DPSET_REMOTE )
./dlls/dplayx/dplay.c:3061:   if( dwFlags & DPSET_REMOTE )
./dlls/dplayx/dplay.c:3074:   if( dwFlags & DPSET_REMOTE )
./dlls/dplayx/dplay.c:3159:   if( dwFlags & DPSET_REMOTE )
./dlls/dplayx/dplay.c:3169:   if( dwFlags & DPSET_REMOTE )
./dlls/winmm/mciseq/mcimidi.c:1359:     if (lpParms->dwAudio & 
MCI_SET_AUDIO_ALL)
./dlls/winmm/mciwave/mciwave.c:1233:    if (lpParms->dwAudio & 
MCI_SET_AUDIO_ALL)


But seriously what would be the best way to fix up dplayx.c?

Not sure, maybe:

   if (dwFlags == DPSET_REMOTE)

or

   if (!dwFlags)

but I find the latter a bit less clear.

--
Francois Gouget         [EMAIL PROTECTED]        http://fgouget.free.fr/
    I haven't lost my mind, it's backed up on tape around here somewhere...



Reply via email to