~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/tools/find_badmacros

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# This script attempts to find bad ifdef's, i.e. ifdef's that use braces
 
3
# but not the do { ... } while (0) syntax
 
4
#
 
5
# This is useful for running before pgindent
 
6
 
 
7
for FILE
 
8
do
 
9
        awk '   BEGIN           {was_define = "N"}
 
10
                                { if (was_define == "Y" &&
 
11
                                      $0 ~ /^{/)
 
12
                                        printf "%s  %d\n", FILENAME, NR
 
13
                                  if ($0 ~ /^#define/)
 
14
                                        was_define = "Y"
 
15
                                  else
 
16
                                        was_define = "N"
 
17
                                }' "$FILE"
 
18
        grep -on '^#define.*{' "$FILE" | grep -v 'do[   ]*{'
 
19
done
 
20