~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to src/tools/find_badmacros

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

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