~ubuntu-branches/ubuntu/maverick/libvirt/maverick-proposed

« back to all changes in this revision

Viewing changes to maint.mk

  • Committer: Bazaar Package Importer
  • Author(s): Guido Günther
  • Date: 2010-04-19 18:11:57 UTC
  • mfrom: (0.2.6 upstream) (3.8.3 sid)
  • mto: This revision was merged to the branch mainline in revision 92.
  • Revision ID: james.westby@ubuntu.com-20100419181157-p8x7wvat9ovlae6m
Tags: 0.8.0-2
* [70fbcb6] New patch 0007-nwfilter-Don-t-crash-if-driverState- NULL.patch
  nwfilter: Don't crash if driverState == NULL (Closes: #577728)
* [d7d1abd] New patch 0008-Ignore-empty-type-statement-in-disk-
  element.patch Ignore empty type statement in disk element
  (Closes: #578347)

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
#           exit 1; } || :
145
145
# FIXME: don't allow `#include .strings\.h' anywhere
146
146
 
147
 
# By default, _prohibit_regexp does not ignore case.
 
147
# _sc_search_regexp
 
148
#
 
149
# This macro searches for a given construct in the selected files and
 
150
# then takes some action.
 
151
#
 
152
# Parameters (shell variables):
 
153
#
 
154
#  prohibit | require
 
155
#
 
156
#     Regular expression (ERE) denoting either a forbidden construct
 
157
#     or a required construct.  Those arguments are exclusive.
 
158
#
 
159
#  in_vc_files | in_files
 
160
#
 
161
#     grep-E-style regexp denoting the files to check.  If no files
 
162
#     are specified the default are all the files that are under
 
163
#     version control.
 
164
#
 
165
#  containing | non_containing
 
166
#
 
167
#     Select the files (non) containing strings matching this regexp.
 
168
#     If both arguments are specified then CONTAINING takes
 
169
#     precedence.
 
170
#
 
171
#  with_grep_options
 
172
#
 
173
#     Extra options for grep.
 
174
#
 
175
#  ignore_case
 
176
#
 
177
#     Ignore case.
 
178
#
 
179
#  halt
 
180
#
 
181
#     Message to display before to halting execution.
 
182
 
 
183
# By default, _sc_search_regexp does not ignore case.
148
184
export ignore_case =
149
185
_ignore_case = $$(test -n "$$ignore_case" && echo -i || :)
150
186
 
151
 
# There are many rules below that prohibit constructs in this package.
152
 
# If the offending construct can be matched with a grep-E-style regexp,
153
 
# use this macro.  The shell variables "re" and "msg" must be defined.
154
 
define _prohibit_regexp
155
 
  dummy=; : so we do not need a semicolon before each use;              \
156
 
  test "x$$re" != x || { echo '$(ME): re not defined' 1>&2; exit 1; };  \
157
 
  test "x$$msg" != x || { echo '$(ME): msg not defined' 1>&2; exit 1; };\
158
 
  grep $(_ignore_case) -nE "$$re" $$($(VC_LIST_EXCEPT)) &&              \
159
 
    { echo '$(ME): '"$$msg" 1>&2; exit 1; } || :
 
187
define _sc_say_and_exit
 
188
   dummy=; : so we do not need a semicolon before each use;             \
 
189
   { echo -e "$(ME): $$msg" 1>&2; exit 1; };
 
190
endef
 
191
 
 
192
define _sc_search_regexp
 
193
   dummy=; : so we do not need a semicolon before each use;             \
 
194
                                                                        \
 
195
   : Check arguments;                                                   \
 
196
   test -n "$$prohibit" && test -n "$$require"                          \
 
197
     && { msg='Cannot specify both prohibit and require'                \
 
198
          $(_sc_say_and_exit) } || :;                                   \
 
199
   test -z "$$prohibit" && test -z "$$require"                          \
 
200
     && { msg='Should specify either prohibit or require'               \
 
201
          $(_sc_say_and_exit) } || :;                                   \
 
202
   test -n "$$in_vc_files" && test -n "$$in_files"                      \
 
203
     && { msg='Cannot specify both in_vc_files and in_files'            \
 
204
          $(_sc_say_and_exit) } || :;                                   \
 
205
   test "x$$halt" != x                                                  \
 
206
     || { msg='halt not defined' $(_sc_say_and_exit) };                 \
 
207
                                                                        \
 
208
   : Filter by file name;                                               \
 
209
   if test -n "$$in_files"; then                                        \
 
210
     files=$$(find $(srcdir) | grep -E "$$in_files");                   \
 
211
   else                                                                 \
 
212
     files=$$($(VC_LIST_EXCEPT));                                       \
 
213
     if test -n "$$in_vc_files"; then                                   \
 
214
       files=$$(echo "$$files" | grep -E "$$in_vc_files");              \
 
215
     fi;                                                                \
 
216
   fi;                                                                  \
 
217
                                                                        \
 
218
   : Filter by content;                                                 \
 
219
   test -n "$$files" && test -n "$$containing"                          \
 
220
     && { files=$$(grep -l "$$containing" $$files); } || :;             \
 
221
   test -n "$$files" && test -n "$$non_containing"                      \
 
222
     && { files=$$(grep -vl "$$non_containing" $$files); } || :;        \
 
223
                                                                        \
 
224
   : Check for the construct;                                           \
 
225
   if test -n "$$files"; then                                           \
 
226
     if test -n "$$prohibit"; then                                      \
 
227
       grep $$with_grep_options $(_ignore_case) -nE "$$prohibit" $$files \
 
228
         && { msg="$$halt" $(_sc_say_and_exit) } || :;                  \
 
229
     else                                                               \
 
230
       grep $$with_grep_options $(_ignore_case) -LE "$$require" $$files \
 
231
           | grep .                                                     \
 
232
         && { msg="$$halt" $(_sc_say_and_exit) } || :;                  \
 
233
     fi                                                                 \
 
234
   else :;                                                              \
 
235
   fi || :;
160
236
endef
161
237
 
162
238
sc_avoid_if_before_free:
167
243
            exit 1; } || :
168
244
 
169
245
sc_cast_of_argument_to_free:
170
 
        @re='\<free *\( *\(' msg='don'\''t cast free argument'          \
171
 
          $(_prohibit_regexp)
 
246
        @prohibit='\<free *\( *\(' halt='don'\''t cast free argument'   \
 
247
          $(_sc_search_regexp)
172
248
 
173
249
sc_cast_of_x_alloc_return_value:
174
 
        @re='\*\) *x(m|c|re)alloc\>'                                    \
175
 
        msg='don'\''t cast x*alloc return value'                        \
176
 
          $(_prohibit_regexp)
 
250
        @prohibit='\*\) *x(m|c|re)alloc\>'                              \
 
251
        halt='don'\''t cast x*alloc return value'                       \
 
252
          $(_sc_search_regexp)
177
253
 
178
254
sc_cast_of_alloca_return_value:
179
 
        @re='\*\) *alloca\>' msg='don'\''t cast alloca return value'    \
180
 
          $(_prohibit_regexp)
 
255
        @prohibit='\*\) *alloca\>'                                      \
 
256
        halt='don'\''t cast alloca return value'                        \
 
257
          $(_sc_search_regexp)
181
258
 
182
259
sc_space_tab:
183
 
        @re='[ ]        ' msg='found SPACE-TAB sequence; remove the SPACE' \
184
 
          $(_prohibit_regexp)
 
260
        @prohibit='[ ]  '                                               \
 
261
        halt='found SPACE-TAB sequence; remove the SPACE'               \
 
262
          $(_sc_search_regexp)
185
263
 
186
264
# Don't use *scanf or the old ato* functions in `real' code.
187
265
# They provide no error checking mechanism.
188
266
# Instead, use strto* functions.
189
267
sc_prohibit_atoi_atof:
190
 
        @re='\<([fs]?scanf|ato([filq]|ll)) *\('                         \
191
 
        msg='do not use *scan''f, ato''f, ato''i, ato''l, ato''ll or ato''q' \
192
 
          $(_prohibit_regexp)
 
268
        @prohibit='\<([fs]?scanf|ato([filq]|ll)) *\('                           \
 
269
        halt='do not use *scan''f, ato''f, ato''i, ato''l, ato''ll or ato''q'   \
 
270
          $(_sc_search_regexp)
193
271
 
194
272
# Use STREQ rather than comparing strcmp == 0, or != 0.
195
273
sc_prohibit_strcmp:
210
288
#  | xargs --no-run-if-empty \
211
289
#      perl -pi -e 's/(^|[^.])\b(exit ?)\(0\)/$1$2(EXIT_SUCCESS)/'
212
290
sc_prohibit_magic_number_exit:
213
 
        @re='(^|[^.])\<(usage|exit) ?\([0-9]|\<error ?\([1-9][0-9]*,'   \
214
 
        msg='use EXIT_* values rather than magic number'                \
215
 
          $(_prohibit_regexp)
 
291
        @prohibit='(^|[^.])\<(usage|exit) ?\([0-9]|\<error ?\([1-9][0-9]*,'     \
 
292
        halt='use EXIT_* values rather than magic number'                       \
 
293
          $(_sc_search_regexp)
216
294
 
217
295
# Using EXIT_SUCCESS as the first argument to error is misleading,
218
296
# since when that parameter is 0, error does not exit.  Use `0' instead.
219
297
sc_error_exit_success:
220
 
        @grep -nE 'error \(EXIT_SUCCESS,'                               \
221
 
            $$($(VC_LIST_EXCEPT) | grep -E '\.[chly]$$') &&             \
222
 
          { echo '$(ME): found error (EXIT_SUCCESS' 1>&2; exit 1; } || :
 
298
        @prohibit='error *\(EXIT_SUCCESS,'                              \
 
299
        in_vc_files='\.[chly]$$'                                        \
 
300
        halt='found error (EXIT_SUCCESS'                                \
 
301
         $(_sc_search_regexp)
223
302
 
224
303
# `FATAL:' should be fully upper-cased in error messages
225
304
# `WARNING:' should be fully upper-cased, or fully lower-cased
226
305
sc_error_message_warn_fatal:
227
 
        @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT))               \
 
306
        @grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT))              \
228
307
            | grep -E '"Warning|"Fatal|"fatal' &&                       \
229
308
          { echo '$(ME): use FATAL, WARNING or warning' 1>&2;           \
230
309
            exit 1; } || :
231
310
 
232
311
# Error messages should not start with a capital letter
233
312
sc_error_message_uppercase:
234
 
        @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT))               \
 
313
        @grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT))              \
235
314
            | grep -E '"[A-Z]'                                          \
236
315
            | grep -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' &&           \
237
316
          { echo '$(ME): found capitalized error message' 1>&2;         \
239
318
 
240
319
# Error messages should not end with a period
241
320
sc_error_message_period:
242
 
        @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT))               \
 
321
        @grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT))              \
243
322
            | grep -E '[^."]\."' &&                                     \
244
323
          { echo '$(ME): found error message ending in period' 1>&2;    \
245
324
            exit 1; } || :
246
325
 
247
326
sc_file_system:
248
 
        @re=file''system ignore_case=1                                  \
249
 
        msg='found use of "file''system"; spell it "file system"'       \
250
 
          $(_prohibit_regexp)
 
327
        @prohibit=file''system                                          \
 
328
        ignore_case=1                                                   \
 
329
        halt='found use of "file''system"; spell it "file system"'      \
 
330
          $(_sc_search_regexp)
251
331
 
252
332
# Don't use cpp tests of this symbol.  All code assumes config.h is included.
253
333
sc_prohibit_have_config_h:
254
 
        @grep -n '^# *if.*HAVE''_CONFIG_H' $$($(VC_LIST_EXCEPT)) &&     \
255
 
          { echo '$(ME): found use of HAVE''_CONFIG_H; remove'          \
256
 
                1>&2; exit 1; } || :
 
334
        @prohibit='^# *if.*HAVE''_CONFIG_H'                             \
 
335
        halt='found use of HAVE''_CONFIG_H; remove'                     \
 
336
          $(_sc_search_regexp)
257
337
 
258
338
# Nearly all .c files must include <config.h>.  However, we also permit this
259
339
# via inclusion of a package-specific header, if cfg.mk specified one.
260
340
# config_h_header must be suitable for grep -E.
261
341
config_h_header ?= <config\.h>
262
342
sc_require_config_h:
263
 
        @if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then       \
264
 
          grep -EL '^# *include $(config_h_header)'                     \
265
 
                $$($(VC_LIST_EXCEPT) | grep '\.c$$')                    \
266
 
              | grep . &&                                               \
267
 
          { echo '$(ME): the above files do not include <config.h>'     \
268
 
                1>&2; exit 1; } || :;                                   \
269
 
        else :;                                                         \
270
 
        fi
 
343
        @require='^# *include $(config_h_header)'                       \
 
344
        in_vc_files='\.c$$'                                             \
 
345
        halt='the above files do not include <config.h>'                \
 
346
          $(_sc_search_regexp)
271
347
 
272
348
# You must include <config.h> before including any other header file.
273
349
# This can possibly be via a package-specific header, if given by cfg.mk.
286
362
        fi
287
363
 
288
364
sc_prohibit_HAVE_MBRTOWC:
289
 
        @re='\bHAVE_MBRTOWC\b' msg="do not use $$re; it is always defined" \
290
 
          $(_prohibit_regexp)
 
365
        @prohibit='\bHAVE_MBRTOWC\b'                                    \
 
366
        halt="do not use $$re; it is always defined"                    \
 
367
          $(_sc_search_regexp)
291
368
 
292
369
# To use this "command" macro, you must first define two shell variables:
293
370
# h: the header, enclosed in <> or ""
294
371
# re: a regular expression that matches IFF something provided by $h is used.
295
 
define _header_without_use
 
372
define _sc_header_without_use
296
373
  dummy=; : so we do not need a semicolon before each use;              \
297
374
  h_esc=`echo "$$h"|sed 's/\./\\\\./g'`;                                \
298
375
  if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then              \
307
384
 
308
385
# Prohibit the inclusion of assert.h without an actual use of assert.
309
386
sc_prohibit_assert_without_use:
310
 
        @h='<assert.h>' re='\<assert *\(' $(_header_without_use)
 
387
        @h='<assert.h>' re='\<assert *\(' $(_sc_header_without_use)
311
388
 
312
389
# Prohibit the inclusion of close-stream.h without an actual use.
313
390
sc_prohibit_close_stream_without_use:
314
 
        @h='"close-stream.h"' re='\<close_stream *\(' $(_header_without_use)
 
391
        @h='"close-stream.h"' re='\<close_stream *\(' $(_sc_header_without_use)
315
392
 
316
393
# Prohibit the inclusion of getopt.h without an actual use.
317
394
sc_prohibit_getopt_without_use:
318
 
        @h='<getopt.h>' re='\<getopt(_long)? *\(' $(_header_without_use)
 
395
        @h='<getopt.h>' re='\<getopt(_long)? *\(' $(_sc_header_without_use)
319
396
 
320
397
# Don't include quotearg.h unless you use one of its functions.
321
398
sc_prohibit_quotearg_without_use:
322
 
        @h='"quotearg.h"' re='\<quotearg(_[^ ]+)? *\(' $(_header_without_use)
 
399
        @h='"quotearg.h"' re='\<quotearg(_[^ ]+)? *\(' $(_sc_header_without_use)
323
400
 
324
401
# Don't include quote.h unless you use one of its functions.
325
402
sc_prohibit_quote_without_use:
326
 
        @h='"quote.h"' re='\<quote(_n)? *\(' $(_header_without_use)
 
403
        @h='"quote.h"' re='\<quote(_n)? *\(' $(_sc_header_without_use)
327
404
 
328
405
# Don't include this header unless you use one of its functions.
329
406
sc_prohibit_long_options_without_use:
330
407
        @h='"long-options.h"' re='\<parse_long_options *\(' \
331
 
          $(_header_without_use)
 
408
          $(_sc_header_without_use)
332
409
 
333
410
# Don't include this header unless you use one of its functions.
334
411
sc_prohibit_inttostr_without_use:
335
412
        @h='"inttostr.h"' re='\<(off|[iu]max|uint)tostr *\(' \
336
 
          $(_header_without_use)
 
413
          $(_sc_header_without_use)
337
414
 
338
415
# Don't include this header unless you use one of its functions.
339
416
sc_prohibit_ignore_value_without_use:
340
417
        @h='"ignore-value.h"' re='\<ignore_(value|ptr) *\(' \
341
 
          $(_header_without_use)
 
418
          $(_sc_header_without_use)
342
419
 
343
420
# Don't include this header unless you use one of its functions.
344
421
sc_prohibit_error_without_use:
345
422
        @h='"error.h"' \
346
423
        re='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\
347
 
          $(_header_without_use)
 
424
          $(_sc_header_without_use)
348
425
 
349
426
# Don't include xalloc.h unless you use one of its functions.
350
427
# Consider these symbols:
351
428
# perl -lne '/^# *define (\w+)\(/ and print $1' lib/xalloc.h|grep -v '^__';
352
 
# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) \(/ and print $1' lib/xalloc.h
 
429
# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/xalloc.h
353
430
# Divide into two sets on case, and filter each through this:
354
431
# | sort | perl -MRegexp::Assemble -le \
355
432
#  'print Regexp::Assemble->new(file => "/dev/stdin")->as_string'|sed 's/\?://g'
367
444
sc_prohibit_xalloc_without_use:
368
445
        @h='"xalloc.h"' \
369
446
        re='\<($(_xa1)|$(_xa2)) *\('\
370
 
          $(_header_without_use)
 
447
          $(_sc_header_without_use)
371
448
 
372
449
# Extract function names:
373
 
# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) \(/ and print $1' lib/hash.h
 
450
# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/hash.h
374
451
_hash_re = \
375
452
clear|delete|free|get_(first|next)|insert|lookup|print_statistics|reset_tuning
376
453
_hash_fn = \<($(_hash_re)) *\(
378
455
sc_prohibit_hash_without_use:
379
456
        @h='"hash.h"' \
380
457
        re='$(_hash_fn)|$(_hash_struct)'\
381
 
          $(_header_without_use)
 
458
          $(_sc_header_without_use)
382
459
 
383
460
sc_prohibit_hash_pjw_without_use:
384
461
        @h='"hash-pjw.h"' \
385
462
        re='\<hash_pjw *\(' \
386
 
          $(_header_without_use)
 
463
          $(_sc_header_without_use)
387
464
 
388
465
sc_prohibit_safe_read_without_use:
389
466
        @h='"safe-read.h"' re='(\<SAFE_READ_ERROR\>|\<safe_read *\()' \
390
 
          $(_header_without_use)
 
467
          $(_sc_header_without_use)
391
468
 
392
469
sc_prohibit_argmatch_without_use:
393
470
        @h='"argmatch.h"' \
394
471
        re='(\<(ARRAY_CARDINALITY|X?ARGMATCH(|_TO_ARGUMENT|_VERIFY))\>|\<argmatch(_exit_fn|_(in)?valid) *\()' \
395
 
          $(_header_without_use)
 
472
          $(_sc_header_without_use)
396
473
 
397
474
sc_prohibit_canonicalize_without_use:
398
475
        @h='"canonicalize.h"' \
399
476
        re='CAN_(EXISTING|ALL_BUT_LAST|MISSING)|canonicalize_(mode_t|filename_mode)' \
400
 
          $(_header_without_use)
 
477
          $(_sc_header_without_use)
401
478
 
402
479
sc_prohibit_root_dev_ino_without_use:
403
480
        @h='"root-dev-ino.h"' \
404
481
        re='(\<ROOT_DEV_INO_(CHECK|WARN)\>|\<get_root_dev_ino *\()' \
405
 
          $(_header_without_use)
 
482
          $(_sc_header_without_use)
406
483
 
407
484
sc_prohibit_openat_without_use:
408
485
        @h='"openat.h"' \
409
486
        re='\<(openat_(permissive|needs_fchdir|(save|restore)_fail)|l?(stat|ch(own|mod))at|(euid)?accessat)\>' \
410
 
          $(_header_without_use)
 
487
          $(_sc_header_without_use)
411
488
 
412
489
# Prohibit the inclusion of c-ctype.h without an actual use.
413
490
ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\
414
491
|isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper
415
492
sc_prohibit_c_ctype_without_use:
416
 
        @h='[<"]c-ctype.h[">]' re='\<c_($(ctype_re)) *\(' $(_header_without_use)
 
493
        @h='[<"]c-ctype.h[">]' re='\<c_($(ctype_re)) *\(' \
 
494
          $(_sc_header_without_use)
417
495
 
418
496
_empty =
419
497
_sp = $(_empty) $(_empty)
450
528
sc_prohibit_signal_without_use:
451
529
        @h='<signal.h>'                                                 \
452
530
        re='\<($(_sig_function_re)) *\(|\<($(_sig_syms_re))\>'          \
453
 
          $(_header_without_use)
 
531
          $(_sc_header_without_use)
 
532
 
 
533
# Get the list of symbol names with this:
 
534
# perl -lne '/^# *define (\w+)\(/ and print $1' lib/intprops.h|grep -v '^s'|fmt
 
535
_intprops_names =                                                       \
 
536
  TYPE_IS_INTEGER TYPE_TWOS_COMPLEMENT TYPE_ONES_COMPLEMENT             \
 
537
  TYPE_SIGNED_MAGNITUDE TYPE_SIGNED TYPE_MINIMUM TYPE_MAXIMUM           \
 
538
  INT_STRLEN_BOUND INT_BUFSIZE_BOUND
 
539
_intprops_syms_re = $(subst $(_sp),|,$(strip $(_intprops_names)))
 
540
# Prohibit the inclusion of intprops.h without an actual use.
 
541
sc_prohibit_intprops_without_use:
 
542
        @h='"intprops.h"'                                               \
 
543
        re='\<($(_intprops_syms_re)) *\('                               \
 
544
          $(_sc_header_without_use)
454
545
 
455
546
sc_obsolete_symbols:
456
 
        @re='\<(HAVE''_FCNTL_H|O''_NDELAY)\>'                           \
457
 
        msg='do not use HAVE''_FCNTL_H or O'_NDELAY                     \
458
 
          $(_prohibit_regexp)
 
547
        @prohibit='\<(HAVE''_FCNTL_H|O''_NDELAY)\>'                     \
 
548
        halt='do not use HAVE''_FCNTL_H or O'_NDELAY                    \
 
549
          $(_sc_search_regexp)
459
550
 
460
551
# FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
461
552
 
462
553
# Each nonempty ChangeLog line must start with a year number, or a TAB.
463
554
sc_changelog:
464
 
        @if $(VC_LIST_EXCEPT) | grep -l '^ChangeLog$$' >/dev/null; then \
465
 
          grep -n '^[^12        ]'                                      \
466
 
            $$($(VC_LIST_EXCEPT) | grep '^ChangeLog$$') &&              \
467
 
          { echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2;  \
468
 
            exit 1; } || :;                                             \
469
 
        fi
 
555
        @prohibit='^[^12        ]'                                      \
 
556
        in_vc_files='^ChangeLog$$'                                      \
 
557
        halt='found unexpected prefix in a ChangeLog'                   \
 
558
          $(_sc_search_regexp)
470
559
 
471
560
# Ensure that each .c file containing a "main" function also
472
561
# calls set_program_name.
473
562
sc_program_name:
474
 
        @if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then       \
475
 
          files=$$(grep -l '^main *(' $$($(VC_LIST_EXCEPT) | grep '\.c$$')); \
476
 
          grep -LE 'set_program_name *\(m?argv\[0\]\);' $$files         \
477
 
              | grep . &&                                               \
478
 
          { echo '$(ME): the above files do not call set_program_name'  \
479
 
                1>&2; exit 1; } || :;                                   \
480
 
        else :;                                                         \
481
 
        fi
 
563
        @require='set_program_name *\(m?argv\[0\]\);'                   \
 
564
        in_vc_files='\.c$$'                                             \
 
565
        containing='^main *('                                           \
 
566
        halt='the above files do not call set_program_name'             \
 
567
          $(_sc_search_regexp)
482
568
 
483
569
# Require that the final line of each test-lib.sh-using test be this one:
484
570
# Exit $fail
500
586
        fi
501
587
 
502
588
sc_the_the:
503
 
        @re='\<the ''the\>'                                             \
504
 
        ignore_case=1 msg='found use of "the ''the";'                   \
505
 
          $(_prohibit_regexp)
 
589
        @prohibit='\<the ''the\>'                                       \
 
590
        ignore_case=1                                                   \
 
591
        halt='found use of "the ''the";'                                \
 
592
          $(_sc_search_regexp)
506
593
 
507
594
sc_trailing_blank:
508
 
        @re='[   ]$$'                                                   \
509
 
        msg='found trailing blank(s)'                                   \
510
 
          $(_prohibit_regexp)
 
595
        @prohibit='[     ]$$'                                           \
 
596
        halt='found trailing blank(s)'                                  \
 
597
          $(_sc_search_regexp)
511
598
 
512
599
# Match lines like the following, but where there is only one space
513
600
# between the options and the description:
514
601
#   -D, --all-repeated[=delimit-method]  print all duplicate lines\n
515
602
longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)?
516
603
sc_two_space_separator_in_usage:
517
 
        @grep -nE '^   *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$'         \
518
 
            $$($(VC_LIST_EXCEPT)) &&                                    \
519
 
          { echo "$(ME): help2man requires at least two spaces between"; \
520
 
            echo "$(ME): an option and its description";                \
521
 
                1>&2; exit 1; } || :
 
604
        @prohibit='^   *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$'         \
 
605
        halt='help2man requires at least two spaces between an option and its description'\
 
606
          $(_sc_search_regexp)
522
607
 
523
608
# Look for diagnostics that aren't marked for translation.
524
609
# This won't find any for which error's format string is on a separate line.
525
610
sc_unmarked_diagnostics:
526
611
        @grep -nE                                                       \
527
 
            '\<error \([^"]*"[^"]*[a-z]{3}' $$($(VC_LIST_EXCEPT))       \
 
612
            '\<error *\([^"]*"[^"]*[a-z]{3}' $$($(VC_LIST_EXCEPT))      \
528
613
          | grep -v '_''(' &&                                           \
529
614
          { echo '$(ME): found unmarked diagnostic(s)' 1>&2;            \
530
615
            exit 1; } || :
532
617
# Avoid useless parentheses like those in this example:
533
618
# #if defined (SYMBOL) || defined (SYM2)
534
619
sc_useless_cpp_parens:
535
 
        @grep -n '^# *if .*defined *(' $$($(VC_LIST_EXCEPT)) &&         \
536
 
          { echo '$(ME): found useless parentheses in cpp directive'    \
537
 
                1>&2; exit 1; } || :
 
620
        @prohibit='^# *if .*defined *\('                                \
 
621
        halt='found useless parentheses in cpp directive'               \
 
622
          $(_sc_search_regexp)
538
623
 
539
624
# Require the latest GPL.
540
625
sc_GPL_version:
541
 
        @re='either ''version [^3]' msg='GPL vN, N!=3'                  \
542
 
          $(_prohibit_regexp)
 
626
        @prohibit='either ''version [^3]'                               \
 
627
        halt='GPL vN, N!=3'                                             \
 
628
          $(_sc_search_regexp)
543
629
 
544
630
# Require the latest GFDL.  Two regexp, since some .texi files end up
545
631
# line wrapping between 'Free Documentation License,' and 'Version'.
546
632
_GFDL_regexp = (Free ''Documentation.*Version 1\.[^3]|Version 1\.[^3] or any)
547
633
sc_GFDL_version:
548
 
        @re='$(_GFDL_regexp)' msg='GFDL vN, N!=3'                       \
549
 
          $(_prohibit_regexp)
 
634
        @prohibit='$(_GFDL_regexp)'                                     \
 
635
        halt='GFDL vN, N!=3'                                            \
 
636
          $(_sc_search_regexp)
 
637
 
 
638
# Don't use Texinfo @acronym{} as it is not a good idea.
 
639
sc_texinfo_acronym:
 
640
        @prohibit='@acronym{'                                           \
 
641
        in_vc_files='\.texi$$'                                          \
 
642
        halt='found use of Texinfo @acronym{}'                          \
 
643
          $(_sc_search_regexp)
550
644
 
551
645
cvs_keywords = \
552
646
  Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State
553
647
 
554
648
sc_prohibit_cvs_keyword:
555
 
        @re='\$$($(cvs_keywords))\$$'                                   \
556
 
            msg='do not use CVS keyword expansion'                      \
557
 
          $(_prohibit_regexp)
 
649
        @prohibit='\$$($(cvs_keywords))\$$'                             \
 
650
        halt='do not use CVS keyword expansion'                         \
 
651
          $(_sc_search_regexp)
558
652
 
559
653
# Make sure we don't use st_blocks.  Use ST_NBLOCKS instead.
560
654
# This is a bit of a kludge, since it prevents use of the string
561
655
# even in comments, but for now it does the job with no false positives.
562
656
sc_prohibit_stat_st_blocks:
563
 
        @re='[.>]st_blocks' msg='do not use st_blocks; use ST_NBLOCKS'  \
564
 
          $(_prohibit_regexp)
 
657
        @prohibit='[.>]st_blocks'                                       \
 
658
        halt='do not use st_blocks; use ST_NBLOCKS'                     \
 
659
          $(_sc_search_regexp)
565
660
 
566
661
# Make sure we don't define any S_IS* macros in src/*.c files.
567
662
# They're already defined via gnulib's sys/stat.h replacement.
568
663
sc_prohibit_S_IS_definition:
569
 
        @re='^ *# *define  *S_IS'                                       \
570
 
        msg='do not define S_IS* macros; include <sys/stat.h>'          \
571
 
          $(_prohibit_regexp)
 
664
        @prohibit='^ *# *define  *S_IS'                                 \
 
665
        halt='do not define S_IS* macros; include <sys/stat.h>'         \
 
666
          $(_sc_search_regexp)
 
667
 
 
668
_ptm1 = use "test C1 && test C2", not "test C1 -''a C2"
 
669
_ptm2 = use "test C1 || test C2", not "test C1 -''o C2"
 
670
# Using test's -a and -o operators is not portable.
 
671
# We prefer test over [, since the latter is spelled [[ in configure.ac.
 
672
sc_prohibit_test_minus_ao:
 
673
        @prohibit='(\<test| \[+) .+ -[ao] '                             \
 
674
        halt='$(_ptm1); $(_ptm2)'                                       \
 
675
          $(_sc_search_regexp)
572
676
 
573
677
# Each program that uses proper_name_utf8 must link with one of the
574
678
# ICONV libraries.  Otherwise, some ICONV library must appear in LDADD.
596
700
# Warn about "c0nst struct Foo const foo[]",
597
701
# but not about "char const *const foo" or "#define const const".
598
702
sc_redundant_const:
599
 
        @re='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b'                \
600
 
        msg='redundant "const" in declarations'                         \
601
 
          $(_prohibit_regexp)
 
703
        @prohibit='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b'          \
 
704
        halt='redundant "const" in declarations'                        \
 
705
          $(_sc_search_regexp)
602
706
 
603
707
sc_const_long_option:
604
708
        @grep '^ *static.*struct option ' $$($(VC_LIST_EXCEPT))         \
652
756
        fi
653
757
 
654
758
sc_makefile_TAB_only_indentation:
655
 
        @grep -nE '^    [ ]{8}'                                         \
656
 
            $$($(VC_LIST_EXCEPT) | grep -E 'akefile|\.mk$$')            \
657
 
          && { echo '$(ME): found TAB-8-space indentation' 1>&2;        \
658
 
               exit 1; } || :
 
759
        @prohibit='^    [ ]{8}'                                         \
 
760
        in_vc_files='akefile|\.mk$$'                                    \
 
761
        halt='found TAB-8-space indentation'                            \
 
762
          $(_sc_search_regexp)
659
763
 
660
764
sc_m4_quote_check:
661
 
        @grep -nE '(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]'              \
662
 
            $$($(VC_LIST_EXCEPT) | grep -E '(^configure\.ac|\.m4)$$')   \
663
 
          && { echo '$(ME): quote the first arg to AC_DEF*' 1>&2;       \
664
 
               exit 1; } || :
 
765
        @prohibit='(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]'              \
 
766
        in_vc_files='(^configure\.ac|\.m4)$$'                           \
 
767
        halt='quote the first arg to AC_DEF*'                           \
 
768
          $(_sc_search_regexp)
665
769
 
666
770
fix_po_file_diag = \
667
771
'you have changed the set of files with translatable diagnostics;\n\
700
804
# path separator of `:', but rather the automake-provided `$(PATH_SEPARATOR)'.
701
805
msg = '$(ME): Do not use `:'\'' above; use $$(PATH_SEPARATOR) instead'
702
806
sc_makefile_path_separator_check:
703
 
        @grep -nE 'PATH[=].*:'                                          \
704
 
            $$($(VC_LIST_EXCEPT) | grep -E 'akefile|\.mk$$')            \
705
 
          && { echo $(msg) 1>&2; exit 1; } || :
 
807
        @prohibit='PATH[=].*:'                                          \
 
808
        in_vc_files='akefile|\.mk$$'                                    \
 
809
        halt=$(msg)                                                     \
 
810
          $(_sc_search_regexp)
706
811
 
707
812
# Check that `make alpha' will not fail at the end of the process.
708
813
writable-files:
722
827
# Make sure that the copyright date in $(v_etc_file) is up to date.
723
828
# Do the same for the $(sample-test) and the main doc/.texi file.
724
829
sc_copyright_check:
725
 
        @if test -f $(v_etc_file); then                                 \
726
 
          grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \
727
 
            >/dev/null                                                  \
728
 
          || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
729
 
               exit 1; };                                               \
730
 
        fi
731
 
        @if test -f $(sample-test); then                                \
732
 
          grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test)     \
733
 
            >/dev/null                                                  \
734
 
          || { echo 'out of date copyright in $(sample-test); update it' 1>&2; \
735
 
               exit 1; };                                               \
736
 
        fi
737
 
        @if test -f $(texi); then                                       \
738
 
          grep 'Copyright @copyright{} .*'$$(date +%Y)' Free' $(texi)   \
739
 
            >/dev/null                                                  \
740
 
          || { echo 'out of date copyright in $(texi); update it' 1>&2; \
741
 
               exit 1; };                                               \
742
 
        fi
 
830
        @require='enum { COPYRIGHT_YEAR = '$$(date +%Y)' };'            \
 
831
        in_files=$(v_etc_file)                                          \
 
832
        halt='out of date copyright in $(v_etc_file); update it'        \
 
833
          $(_sc_search_regexp)
 
834
        @require='# Copyright \(C\) '$$(date +%Y)' Free'                \
 
835
        in_vc_files=$(sample-test)                                      \
 
836
        halt='out of date copyright in $(sample-test); update it'       \
 
837
          $(_sc_search_regexp)
 
838
        @require='Copyright @copyright\{\} .*'$$(date +%Y)' Free'       \
 
839
        in_vc_files=$(texi)                                             \
 
840
        halt='out of date copyright in $(texi); update it'              \
 
841
          $(_sc_search_regexp)
743
842
 
744
843
# #if HAVE_... will evaluate to false for any non numeric string.
745
844
# That would be flagged by using -Wundef, however gnulib currently
746
845
# tests many undefined macros, and so we can't enable that option.
747
846
# So at least preclude common boolean strings as macro values.
748
847
sc_Wundef_boolean:
749
 
        @grep -Ei '^#define.*(yes|no|true|false)$$' '$(CONFIG_INCLUDE)' && \
750
 
          { echo 'Use 0 or 1 for macro values' 1>&2; exit 1; } || :
 
848
        @prohibit='^#define.*(yes|no|true|false)$$'                     \
 
849
        in_files='$(CONFIG_INCLUDE)'                                    \
 
850
        halt='Use 0 or 1 for macro values'                              \
 
851
          $(_sc_search_regexp)
751
852
 
752
853
sc_vulnerable_makefile_CVE-2009-4029:
753
 
        @files=$$(find $(srcdir) -name Makefile.in);                    \
754
 
        if test -n "$$files"; then                                      \
755
 
          grep -E                                                       \
756
 
            'perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)'     \
757
 
            $$files &&                                                  \
758
 
          { echo '$(ME): the above files are vulnerable; beware of'     \
759
 
            'running "make dist*" rules, and upgrade to fixed automake' \
760
 
            'see http://bugzilla.redhat.com/542609 for details'         \
761
 
                1>&2; exit 1; } || :;                                   \
762
 
        else :;                                                         \
763
 
        fi
 
854
        @prohibit='perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \
 
855
        in_files=$$(find $(srcdir) -name Makefile.in)                   \
 
856
        halt='the above files are vulnerable; beware of running\n'\
 
857
'"make dist*" rules, and upgrade to fixed automake\n'\
 
858
'see http://bugzilla.redhat.com/542609 for details'                     \
 
859
          $(_sc_search_regexp)
764
860
 
765
861
vc-diff-check:
766
862
        (unset CDPATH; cd $(srcdir) && $(VC) diff) > vc-diffs || :