[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
maint.mk: avoid to match non-cast expressions in free calls
From: |
jemarch |
Subject: |
maint.mk: avoid to match non-cast expressions in free calls |
Date: |
Thu, 20 Sep 2007 16:14:07 +0200 |
User-agent: |
Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/22.1.50 (powerpc-unknown-linux-gnu) MULE/5.0 (SAKAKI) |
Hi.
While using main.mk in the GNU PDF sources, I found that the rule
matching casts in `free' calls wrongly recognizes constructions like:
free ((*data)->foo);
as a cast.
The actual regexp used to match a cast is:
'\<free *\( *\('
I extended it to take care about parenthesized expressions with
following C operators:
'\<free *\( *\([^\)]+\) *[^ -+*=/%.]'
Strangely enough, that regexp works fine when called from the command
line and from a custom makefile:
-- makefile.foo
C_SOURCES ?= $(shell find . -name '*.[chly]')
all:
@grep -nE '\<free *\( *\([^\)]+\) *[^ -+*=/%.]' $(C_SOURCES) \
&& { echo foo 1>&2 ; exit 1; } || :
-- end of makefile.foo
But it doesnt work when used in the `sc_cast_of_argument_to_free' in
`maint.mk'.
Executing
grep -nE '\<free *\( *\([^\)]+\) *[^ -+*=/%.]' ./pdf.c ./pdf.h ./pdf_base.h
./pdf_obj.c ./pdf_obj.h ./pdf_stm.c ./pdf_stm.h ./pdf_stm_f_a85.c
./pdf_stm_f_a85.h ./pdf_stm_f_ahex.c ./pdf_stm_f_ahex.h ./pdf_stm_f_flate.c
./pdf_stm_f_flate.h ./pdf_stm_f_null.c ./pdf_stm_f_null.h ./pdf_stm_f_pred.c
./pdf_stm_f_pred.h ./pdf_stm_f_rl.c ./pdf_stm_f_rl.h ./pdf_stm_file.c
./pdf_stm_file.h ./pdf_stm_mem.c ./pdf_stm_mem.h ./pdf_xref.c ./pdf_xref.h
./pdf_date.h ./pdf_date.c ./pdf_lexer.h ./pdf_rectangle.h ./pdf_rectangle.c
./pdf_function.h ./pdf_function.c ./pdf_stm_f_fax.h ./pdf_lexer.c
./pdf_stm_f_fax.c ./pdf_stm_f_lzw.h ./pdf_stm_f_lzw.c ./config.h ./pdf_base.c
./pdf_parser.c ./pdf_parser.h && \
{ echo 'maint.mk: don'\''t cast free argument' 1>&2; \
exit 1; } || :
in the command line also works.
I am somewhat lost :)
address@hidden:~/gnu/src/gnulib/build-aux$ cvs diff -u maint.mk
cvs diff: CVS password file /home/jemarch/.cvspass does not exist - creating a
new file
Index: maint.mk
===================================================================
RCS file: /cvsroot/gnulib/gnulib/build-aux/maint.mk,v
retrieving revision 1.9
diff -u -r1.9 maint.mk
--- maint.mk 6 Aug 2007 14:06:55 -0000 1.9
+++ maint.mk 20 Sep 2007 14:01:37 -0000
@@ -39,7 +39,7 @@
# Casting arguments to free is never necessary.
sc_cast_of_argument_to_free:
- @grep -nE '\<free *\( *\(' $(C_SOURCES) && \
+ @grep -nE '\<free *\( *\([^\)]+\) *[^ -+*=/%.]' $(C_SOURCES) && \
{ echo '$(ME): don'\''t cast free argument' 1>&2; \
exit 1; } || :
- maint.mk: avoid to match non-cast expressions in free calls,
jemarch <=