Initial import of linux-libre deblob scripts from https://www.fsfla.org/svn/fsfla...
[librecmc/linux-deblob.git] / 2.6.24-libre / deblob-check
1 #! /bin/sh
2
3 # deblob-check version 2008-03-29 $Rev: 3476 $
4 # Inspired in gNewSense's find-firmware script.
5 # Written by Alexandre Oliva <lxoliva@fsfla.org>
6
7 # Check http://www.fsfla.org/svn/fsfla/software/linux-libre for newer
8 # versions.
9
10 # Copyright (C) 2008 Alexandre Oliva
11 #
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
16 #
17 # This program is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 # General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
25 # USA
26
27
28 # usage: deblob-check [-S] [-vv] [-s S] [-lDdBbCcXxPpFftVh?H] \
29 #        [*.tar* patch-* *.patch]
30
31 # Look for too-long undocumented sequences of numbers (generally blobs
32 # in disguise) in source files.
33
34 # The order of command line flags is significant.  Flags given out of
35 # the order above won't be handled correctly, sorry.
36
37 # -s --sensitivity: must be followed by a blank and a number.
38 #               Specifies the number of consecutive integral or
39 #               character constants that trigger the blob detector.
40
41 # The default sensitivity is 32 constants.
42
43 # The sensitivity, if present, must be the first option.  The action
44 # selection, if present, must be the first argument, except for the
45 # sensitivity and verbosity.
46
47 # The default can be overridden with one of:
48
49 # -l --list-blobs: list files that contain sequences that match the
50 #               blob detector test and that are not known to be false
51 #               positives.  This is the default option.
52
53 # -d --deblob --mark-blobs: print the processed input, replacing
54 #               sequences that match the blob detector test and that
55 #               are NOT known to be false positives with
56 #               /*(DEBLOBBED)*/.
57
58 # -D --cat: print the processed input, as it would have been fed to
59 #               the blob detector script.  Use -S to save the sed
60 #               script used to process it, and search for `sedcat:' in
61 #               comments to locate the relevant adaptation points.
62
63 # -b --print-marked-blobs: like -d, but print only the matching
64 #               sequences.
65
66 # -B --print-blobs: like -b, but do not deblob the sequences.
67
68 # -c --print-marked-blobs-with-context: like -b, but try to maximize
69 #               the context around the blobs.  This maximization will
70 #               sometimes disregard known false positives, if they
71 #               happen to be contained within the extended match.
72 #               This is probably an indication that the false positive
73 #               matching rule could be improved.
74
75 # -C --print-blobs-with-context: like -B, but try to maximize the
76 #               context around the blobs.
77
78 # -X --print-all-matches: print all blobs, be they known false
79 #               positives or blobs.
80
81 # -x --list-all-matches: list files that contain sequences that appear
82 #               to be blobs, be they known false positives or not.
83
84 # -p --mark-false-positives: print the processed input, replacing
85 #               sequences that match the blob detector test, but that
86 #               are known to be false positives, with /*(DEBLOBBED)*/.
87
88 # -P --list-false-positives: list files that contain false positives.
89
90 # -f --print-marked-false-positives: like -p, but print only the
91 #               matching sequences.
92
93 # -F --print-false-positives: like -f, but do not deblob the sequences.
94
95 # -t --test: run (very minimal) self-test.
96
97 # -V --version: print a version number
98
99 # -h -? -H --help: print short or long help message
100
101
102 # debugging options:
103
104 # -S --save-scripts: save scripts and temporary files.
105
106 # -v --verbose: increase verbosity level, for internal debugging.  May
107 #               be given at most twice.
108
109 # The exit status is only significant for the --list options: it will
110 # be true if nothing was found, and false otherwise.
111
112 : # Mark the end of the help message.
113
114 # TODO:
115
116 # - Improve handling of command-line arguments, so as to not make the
117 # order relevant.
118
119 # - Add an option for the user to feed their own false positive
120 # patterns.
121
122 # - Add support to recognize known blobs (or other non-Free
123 # signatures, really), to speed up the scanning of files containing
124 # blobs, and to avoid attempts to disguise blobs.
125
126 # - Factor out the code in the various print_* and list_* parts of the
127 # sed script, at least in the shell sources.  Make sure they're all
128 # included and expanded in a saved --cat script though.
129
130 # - Add support for file name tagging in patterns, such that blobs or
131 # false positives are recognized only when handling the specific
132 # filename, be it stand-alone, as part of a patch or a tarball.  This
133 # should help avoid recognition of actual blobs as false positives
134 # just because there's a symbol with a different name elsewhere.
135
136 #   It is convenient that the patterns provided by the user to
137 # recognize file names can be empty (for backward compatibility), but
138 # this should ideally be phased out in favor of more precise matches.
139 # It's important that files can be recognized with leading tarball or
140 # patch names, that the filename used within the tarball contain
141 # leading garbage, and even that a partial pathname be recognizable
142 # (say recognize drivers/net/whatever.c when the input file is named
143 # ../net/whatever.c).
144
145 #   Rather than using regular expressions to recognize multiple files
146 # it's convenient (but not quite essential) that filename patterns be
147 # specifiable as regular expressions, rather than simple filenames,
148 # but there are other ways around this.
149
150 #   Maintaining begin/end markers in a stack-like fashion as part of
151 # the processed stream, and using the names in them as (optional) part
152 # of the recognition patterns, would enable us to do it.
153
154 #   Introducing annotations next to the false positives (and recognized
155 # blobs) as an early part of the process may speed things up and
156 # enable fast processing, but how to introduce the annotations quickly
157 # in the first place?  Given patterns such as
158
159 #   \(\(file1\)\(.*\)\(pat1\)\|\(file2\)\(.*\)\(pat2\)\|...\)
160
161 # how do we get sed to introduce a marker that contains file2 right
162 # before or right after pat2, without turning a big efficient regexp
163 # into a slowish sequence of s/// commands?
164
165 # - Re-check and narrow false-positive patterns to make sure they
166 # apply only to the relevant content.
167
168 # - Scripting abilities, so as to be able to automate the removal of
169 # source files or of blobs from source files in a tarball without
170 # having to extract the entire tarball (as in tar --update/--delete)
171 # would be nice.  Carrying over removed files automatically into
172 # patches would also be great, and this sort of script would be
173 # perfect to document what has been done to a tarball plus a set of
174 # patches.  Something like deblob.script:
175 #
176 #   tarball linux-2.6.24.tar.bz2
177 #   delete net/wireloss/freedom.c drivers/me/crazy.c
178 #   deblob include/linux/slab-blob-kfree.h
179 #   deconfig drivers/char/drm DRM_IS_BAD
180 #
181 #   patch patch-2.6.25-rc7.bz2
182 #   delete arch/power/over/you.c
183
184 # such that the deletes from an earlier file would carry over into the
185 # subsequent ones, and new tarballs and patch files would be generated
186 # with the libre- prefix in their basename, and the xdeltas between
187 # the original files and the modified files would be minimal, and
188 # redundant with this script and the input script while at that.
189
190 # - Improve documentation of the code.
191
192 # - Write a decent testsuite.
193
194 # - Insert your idea here. :-)
195
196 # Yeah, lots of stuff to do.  Want to help?
197
198 # This makes it much faster, and mostly immune to non-ASCII stuff, as
199 # long as a 8-bit-safe sed is used.  Probably a safe assumption these
200 # days.
201 case ${LANG+set} in set) LANG=C; export LANG;; esac
202
203 rm="rm -f"
204 case $1 in
205 --save-scripts | -S)
206   shift
207   rm="echo preserving"
208   ;;
209 esac
210
211 # Choose verbosity level for sed script debugging and performance
212 # analysis.
213 case $1 in
214 --verbose | -v)
215   shift
216   case $1 in
217   --verbose | -v)
218     shift
219     v="i\\
220 :
221 p;
222 i\\
223 "
224     ;;
225   *)
226     v="P;i\\
227 "
228     ;;
229   esac
230   ;;
231 *) 
232   v="# "
233   ;;
234 esac
235
236 sens=31 # 32 - 1
237 case $1 in
238 --sensitivity | -s)
239   sens=$2;
240   shift 2 || exit 1
241
242   if test "$sens" -gt 0 2>/dev/null; then
243     :
244   else
245     echo invalid sensitivity: $sens >&2
246     exit 1
247   fi
248
249   sens=`expr $sens - 1`
250   ;;
251 esac
252
253 test_mode=false
254
255 name=deblob-check
256
257 case $1 in
258 --version | -V)
259   sed '/^# '$name' version /,/^# Written by/ { s/^# //; p; }; d' < $0
260   exit 0
261   ;;
262
263 -\? | -h)
264   sed -n '/^# usage:/,/# -h/ { /^# -/,/^$/{s/^# \(-.*\):.*/\1/p; d; }; s/^\(# \?\)\?//p; }' < $0 &&
265   echo
266   echo "run \`$name --help | more' for full usage"
267   exit 0
268   ;;
269
270 --help | -H)
271   sed -n '/^# '$name' version /,/^[^#]/ s/^\(# \?\)\?//p' < $0
272   exit 0
273   ;;
274
275 --test | -t)
276   test_mode=:
277   ;;
278
279 --mark-false-positives | -p)
280   shift;
281   set_sed_cmd () {
282     set_sedmain "b list_both;" "p;" "b list_matches;"
283   }
284   ;;
285
286 --print-marked-false-positives | -f)
287   shift;
288   set_sed_cmd () {
289     set_sedmain "b print_marked_matches;" "" "b print_marked_matches;"
290   }
291   ;;
292
293 --print-false-positives | -F)
294   shift;
295   set_sed_cmd () {
296     set_sedmain "b print_matches;" "" "b print_matches;"
297   }
298   ;;
299
300 --deblob | --mark-blobs | -d)
301   shift;
302   set_sed_cmd () {
303     set_sedmain "b list_blobs;" "p;" "p;"
304   }
305   ;;
306
307 --cat | -D)
308   shift;
309   set_sed_cmd () {
310     set_sedmain \
311       "# sedcat: Actual blob detected, but there may be false positives." \
312       "# sedcat: No blob whatsoever found." \
313       "# sedcat: False positives found." \
314       "p; d; # sedcat: Just print stuff, remove this line to run the actual script."
315   }
316   ;;
317
318 --print-marked-blobs | -b)
319   shift;
320   set_sed_cmd () {
321     set_sedmain "b print_marked_blobs;"
322   }
323   ;;
324
325 --print-blobs | -B)
326   shift;
327   set_sed_cmd () {
328     set_sedmain "b print_blobs;"
329   }
330   ;;
331
332 --print-marked-blobs-with-context | -c)
333   shift;
334   set_sed_cmd () {
335     set_sedmain "b print_marked_cblobs;"
336   }
337   ;;
338
339 --print-blobs-with-context | -C)
340   shift;
341   set_sed_cmd () {
342     set_sedmain "b print_cblobs;"
343   }
344   ;;
345
346 --list-false-positives | -P)
347   shift;
348   set_sed_cmd () {
349     set_sedmain "" "" "
350 i\\
351 $file
352 q 1;"
353   }
354   ;;
355
356 --list-all-matches | -x)
357   shift;
358   set_sed_cmd () {
359     set_sedmain "
360 i\\
361 $file
362 q 1;" "" "
363 i\\
364 $file
365 q 1;"
366   }
367   ;;
368
369 --print-all-matches | -X)
370   shift;
371   set_sed_cmd () {
372     set_sedmain "b print_both;" "" "b print_matches;"
373   }
374   ;;
375
376 *)
377   case $1 in
378   -- | -l | --list-blobs) shift;;
379   esac
380   case $1 in
381   -*)
382     if test ! -f "$1"; then
383       echo "$name: \`$1' given too late or out of the proper sequence." >&2
384       echo "$name: The order of arguments is significant, see the usage." >&2
385       exit 1
386     fi
387     ;;
388   esac
389       
390   set_sed_cmd () {
391     set_sedmain "
392 i\\
393 $file
394 q 1;"
395   }
396   ;;
397
398 esac
399
400 case $1 in
401 --) shift;;
402 esac
403
404 if $test_mode; then
405   pass=:
406
407   # Exercise some nasty inputs to see that we recognize them as blobs
408   # with full context.
409   for string in \
410     "1,2,3,4" \
411     "= {
412 1, 0x2, 03, L'\x4'
413 }" \
414     "=
415 {
416   '\\x1', '\\002'
417   ,
418   {
419     { \"\\x3\", },
420     \"\\004\"
421   },
422 };" \
423     ".long 1,2
424      .long \$3,\$4" \
425     "#define X { 1, 2, \\
426                  3, 4, /* comment */ \\
427                }" \
428   "= {
429 /*
430  * multi-line
431  * comment
432  */
433  {
434    0x4c00c000, 0x00000000, 0x00060000, 0x00000000,
435  },
436 }" \
437   ; do
438     case `echo "$string" | $0 -s 4 -c` in
439     "::: - :::
440 $string") ;;
441     *) echo "failed positive test for:
442 $string" >&2
443        pass=false;;
444     esac
445   done
446
447   # Make sure we do not recognize these as blobs.
448   for string in \
449     "#define X { 1, 2 }
450 #define Y { 3, 4 }" \
451     " 0x00, 0x00, 0x00 " \
452   ; do
453     case `echo "$string" | $0 -s 4` in
454     "") ;;
455     *) echo "failed negative test for:
456 $string" >&2
457        pass=false;;
458     esac
459   done
460
461   # How did we do?
462   if $pass; then
463     echo success
464   fi
465
466   $pass
467   exit
468 fi
469
470 # Call addx as needed to set up more patterns to be recognized as
471 # false positives.  Takes the input filename in $1.
472
473 set_except () {
474   # Look for a multi-line definition starting with a line that matches
475   # $1 (implicitly anchored to the beginning of the line), and ending
476   # at the first ';'.
477   initnc () {
478     addx "$1[^;]*;"
479   }
480
481   # Look for a multi-line definition starting with a line that matches
482   # $1 (implicitly anchored to the beginning of the line), and ending
483   # at the first ';' that's not within comments.
484   initc () {
485     addx "$1\\([^;]*\\|$comment\\)*;"
486   }
487
488   # Accept as a non-blob an expression $1 that would have otherwise
489   # triggered blob detection.  The expression must end in a way that
490   # would trigger the blob detection machinery.
491   accept () {
492     addx "$1"
493   }
494
495   # Match up to the end a comment started in $1.
496   ocomment () {
497     addx "$1\\([^*]\\|[*][*]*[^*/]\\|[*]*[\\n]\\)*[*]*[*][/]"
498   }
499
500   # Match $1 followed by backslash-terminated lines and a last
501   # non-backslash-terminated line.
502   oprepline () {
503     addx "$1\\([^\\n]*\\\\[\\n]\\)*[^\\n\\\\]*$eol"
504   }
505
506   case /$1 in
507   /drivers/net/tg3.c)
508     # This file contains firmwares that we deblob with high
509     # sensitivity, so make sure the sequences of numbers that are not
510     # blobs are not deblobbed.  FIXME: we should have patterns to
511     # recognize the blobs instead.
512     initnc '    static const u32 test_pat\[4\]\[6\] ='
513     initnc '    }, mem_tbl_5705\[\] ='
514     ;;
515   */*linux*.tar* | */*kernel*.tar* | */*linux-*.*.*/*)
516     # false alarms, contain source
517     # drivers/net/wan/wanxlfw.inc_shipped -> wanxlfw.S
518     accept 'static u8 firmware\[\]={[\n]0x60,\(0x00,\)*0x16,\(0x00,\)*\([\n]\(0x[0-9A-F][0-9A-F],\)*\)*[\n]0x23,0xFC,0x00,0x00,0x00,0x01,0xFF,0xF9,0x00,0xD4,0x61,0x00,0x06,0x74,0x33,0xFC,\([\n]\(0x[0-9A-F][0-9A-F],\)*\)*0x00[\n]};'
519     # drivers/usb/serial/xircom_pgs_fw.h -> xircom_pgs.S
520     initnc 'static const struct ezusb_hex_record xircom_pgs_firmware\[\] ='
521     # drivers/usb/serial/keyspan_pda_fw_h -> keyspan_pda.S
522     initnc 'static const struct ezusb_hex_record keyspan_pda_firmware\[\] ='
523     # arch/m68k/ifpsp060/*.sa -> src/*.s
524     accept '    \.long  0x60ff0000,0x02360000,0x60ff0000,0x16260000[\n]'"$sepx$blobpat*"
525     accept '    \.long  0x60ff0000,0x17400000,0x60ff0000,0x15f40000[\n]'"$sepx$blobpat*"
526     # arch/powerpc/platforms/cell/spufs/spu_save_dump.h_shipped -> spu_save.c
527     initnc 'static unsigned int spu_save_code\[\]  __attribute__((__aligned__(128))) ='
528     # arch/powerpc/platforms/cell/spufs/spu_restore_dump.h_shipped -> spu_restore.c
529     initnc 'static unsigned int spu_restore_code\[\]  __attribute__((__aligned__(128))) ='
530     # drivers/net/ixp2000/ixp2400_tx.ucode -> ixp2400_tx.uc
531     initnc '    \.initial_reg_values    = (struct ixp2000_reg_value \[\]) {'
532     # drivers/net/ixp2000/ixp2400_rx.ucode -> ixp2400_rx.uc
533     initnc '    \.initial_reg_values    = (struct ixp2000_reg_value \[\]) {'
534     # crypto/tcrypt.h
535     initnc '[   ]*\.\(digest\|entries\|input\|key\|output\|plaintext\|result\)[         ]*= {'
536
537     # checked:
538
539     accept '    \$3 = {{pge = {{ste = {\(\([0-9][0-9a-fx{},\n   ]*\|\(pge\|ste\) =\|<repeats [0-9]\+ times>\)[{},\n     ]*\)*<repeats 11 times>}'"$eol"
540     # arch/sparc/lib/divdi3.S
541     accept '__clz_tab:[\n]      \.byte  0\(,[0-5]\)\+'"$sepx$blobpat*"
542     accept 'PITBL:[\n]  \.long  0xC0040000,0xC90FDAA2,'"$blobpat*"
543     # arch/m68k/mac/mac_penguin.S
544     accept '\(0x[0F][0F],\)\+\\[\n]\(\(0x[0F][0F],\)\+\\[\n]\)*\(0x[0F][0F],\)\+0x00'
545     # arch/s390/kernel/head.S
546     accept '\.lowcase:[\n]      \.byte 0x00\(,0x0[1-7]\)\+'"$sepx$blobpat*$eol"
547     # arch/s390/kernel/bitmap.S
548     accept '_zb_findmap:[\n]         \.byte  0\(,[123],0\)\+,4'"$sepx$blobpat*$eol"
549     accept '_sb_findmap:[\n]         \.byte  8\(,0,[123]\)\+,0'"$sepx$blobpat*$eol"
550     # arch/powerpc/lib/copyuser_64.S
551     accept '    \.section __ex_table,"a"'"$sepx$blobpat*"
552     # arch/powerpc/platforms/iseries/mf.c
553     accept '    memcpy(src, "\\x01\\x00\\x00\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00".*PROGxxxx'
554     # arch/ppc/platforms/ev64260.c
555     initnc 'static const unsigned int cpu_745x\[2\]\[16\] ='
556     # arch/alpha/lib/fls.c
557     initnc 'const unsigned char __flsm1_tab\[256\] ='
558     # drivers/input/misc/map_to_7segment.h
559     accept '#define _MAP_0_32_ASCII_SEG7_NON_PRINTABLE  \\[\n]  \(0,\)\+'"$eol"
560     # sound/oss/ad1848.c
561     initc '     static int      init_values_b\[\] ='
562     # drivers/input/keyboard/atkbd.c
563     initnc 'static unsigned char atkbd_set2_keycode\[512\] ='
564     # drivers/usb/serial/keyspan_pda.S and
565     # drivers/usb/serial/xircom_pgs.S
566     accept 'desc_config1:[\n]   \.byte 0x09, 0x02'"$sepx$blobpat*"
567     accept 'string_mfg:[\n]\?\(;\?      \.byte[^\n]*[\n]\)\+string_mfg_end:'
568     accept 'string_product:[\n]\?\(;\?  \.byte[^\n]*[\n]\)\+string_product_end:'
569     # drivers/media/video/pwc/pwc-nala.h
570     accept '   [/][*] \(SQCIF\|QSIF\|QCIF\|SIF\|CIF\|VGA\) [*][/][\n]   {[\n]      {'"$blobpat*"
571     # drivers/video/logo/*.ppm
572     accept 'P[13]\([\n]#[^\n]*\)*[\n]*\([\n][0-9 ]*\)\+'
573     # Documentation/specialix.txt
574     accept 'for i in [  0-9\\\n]*[\n]do'
575     # Documentation/cpu-freq/cpufreq-stats.txt
576     accept '         :   3600000   3400000   3200000   3000000   2800000 '
577     # Documentation/scsi/sym53c8xx_2.txt and
578     # Documentation/scsi/ncr53c8xx_2.txt
579     accept '00 00[\n]64 01[\n]8e 0b[\n][\n][0-9a-f \n]*fe fe'
580     accept '0f 00 08 08 64 00 0a 00 - id 0[\n]'"$blobpat*"
581     accept 'default nvram data:'"$sepx$blobpat*"
582     # Documentation/video4linux/sn9c102.txt
583     accept '0x0458     0x7025[\n]'"$blobpat*"
584     # Documentation/video4linux/et61x251.txt
585     accept '0x102c     0x6151[\n]'"$blobpat*"
586     # Documentation/video4linux/zc0301.txt
587     accept '0x041e     0x4017[\n]'"$blobpat*"
588     # Documentation/uml/UserModeLinux-HOWTO.txt
589     accept '  (gdb) x\/100x \$25[\n]  0x507d2434:     0x507d2434      0x00000000      0x08048000      0x080a4f8c'"$sepx$blobpat*"
590     # Documentation/isdn/README.inc
591     accept '      1  0  0  0  0x308'"$sepx$blobpat*"
592     # Documentation/sched-stats.txt
593     accept 'domain<N> <cpumask> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36'"$eol"
594     # net/ipv4/ipvs/ip_vs_sync.c and
595     # net/sctp/sm_make_chunk.c and
596     # include/linux/sctp.h
597     accept '[ * ]*0                   1                   2                   3[\n][ *  ]*0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1'
598     # arch/x86/lguest/boot.c
599     accept ' \*  1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'
600     # drivers/net/fealnx.c
601     ocomment '  [/][*] Configure the PCI bus bursts and FIFO thresholds.'
602     # drivers/hwmon/via686a.c
603     ocomment '[/][*] the original LUT values from Alex van Kaam <darkside@chello\.nl>'
604     # drivers/media/video/saa7114.c
605     initc 'static const unsigned char init\[\] = {[^;]*MODE=0 ;.*SAA_7114_NTSC_HSYNC_START'
606
607     # in 2.6.23 only
608     accept " Psize    Ipps       Tput     Rxint     Txint    Done     Ndone[\\n] ---------------------------------------------------------------\\([\\n][ 0-9]\\+\\)\\+$eol"
609     initnc 'static u_short ataplain_map\[NR_KEYS\] __initdata ='
610     initnc 'static RegInitializer initData\[\] __initdata ='
611     initnc '    static const unsigned char invert5\[\] ='
612     initnc 'static unsigned char alpa2target\[\] ='
613     initnc 'static unsigned char target2alpa\[\] ='
614     oprepline '#define INIT_THREAD [{0},]\+[    ]*\\[   ]*[{0},]\+'
615     initnc 'static uint tas300\(1c\|4\)_\(master\|mixer\|treble\|bass\)_tab\[\]='
616     initnc 'static short dmasound_[au]law2dma16\[\] ='
617     initnc 'static const unsigned short DACVolTable\[101\] ='
618
619     # new in 2.6.25
620     accept "%canned_values = ([\\n]     \\([0-9]\\+ => \\[[     \\n]\\+\\(\\([0-9]\\+\\|'0x[0-9a-f]\\+'\\),[    \\n]*\\)*\\]\\(, \\|[\\n]\\)\\)*);"
621
622     # from 2.6.25-rc* patches
623     initnc '    int bcomm_irq\[3\*16\] ='
624     initnc '    static const int8 countLeadingZerosHigh\[\] ='
625     initnc 'static struct nic_qp_map nic_qp_mapping_[01]\[\] ='
626     initnc 'static struct regval ov_initvals\[\] ='
627     initnc 'static struct regval stk1125_initvals\[\] ='
628     initnc 'static u8 bnx2x_stats_len_arr\[BNX2X_NUM_STATS\] ='
629     initnc 'static const struct arb_line read_arb_data\[NUM_RD_Q\]\[MAX_RD_ORD + 1\] ='
630     initnc 'static const struct arb_line write_arb_data\[NUM_WR_Q\]\[MAX_WR_ORD + 1\] ='
631     oprepline '#define AR5K_RATES_11A '
632     oprepline '#define AR5K_RATES_11B '
633     oprepline '#define AR5K_RATES_11G '
634     oprepline '#define AR5K_RATES_TURBO '
635     oprepline '#define AR5K_RATES_XR '
636     initnc '            } blinkrates\[\] ='
637     initnc 'static const struct ath5k_ini ar5212_ini\[\] ='
638     initnc 'static const struct ath5k_ini_mode rf5413_ini_mode_end\[\] ='
639     initnc 'static const struct ath5k_ini_rf rfregs_5111\[\] ='
640     initnc 'static const struct ath5k_ini_rf rfregs_5112\[\] ='
641     initnc 'static const struct ath5k_ini_rf rfregs_5112a\[\] ='
642     initnc 'static const struct ath5k_ini_rf rfregs_5413\[\] ='
643     initnc 'const u\(8\|16\|32\) b43_ntab_\(\(adjustpower\|estimatepowerlt\|gainctl\|iqlt\|loftlt\|noisevar1\|tdi[24]0a\)[01]\|channelest\|frame\(lookup\|struct\)\|mcs\|pilot\|tdtrn\|tmap\)\[\] ='
644
645     # quite suspicious
646     # arch/parisc/kernel/perf_images.h
647     initc 'static uint32_t onyx_images\[\]\[PCXU_IMAGE_SIZE\/sizeof(uint32_t)\] __read_mostly ='
648     initc 'static uint32_t cuda_images\[\]\[PCXW_IMAGE_SIZE\/sizeof(uint32_t)\] __read_mostly ='
649
650     # These are regarded as ok
651     initnc 'static const u8 SN9C102_\(Y\|UV\)_QTABLE[01]\[64\] = {'
652     initnc '    static const u8 jpeg_header\[589\] = {'
653     accept '[   ]\{1,2\}err = sn9c102_write_const_regs(cam\(,[  \n]\+{0x[0-9a-fA-F][0-9a-fA-F], 0x[0-9a-fA-F][0-9a-fA-F]}\)*);'
654
655     # too lax?
656     initnc 'static yyconst flex_int\(16\|32\)_t yy_[^[]*\[[][0-9]*\] ='
657     initnc 'static const \(yytype_u\?int\(8\|16\)\|unsigned \(short\( int\)\?\|char\)\) yy[^[]*\[\] ='
658     initnc '\(\|        \)static \(const \|\)\(unsigned \(short\|char\)\|struct SiS_[^ ]*\) SiS[^[]*\(\[[] [*0-9]*\]\)\+ *='
659
660     initnc 'static const a3d_Hrtf_t A3dHrirZeros = {'
661     initnc 'static const a3d_Hrtf_t A3dHrirImpulse = {'
662     initnc 'static const a3d_Hrtf_t A3dHrirOnes = {'
663     initnc 'static const a3d_Hrtf_t A3dHrirSatTest = {'
664     initnc 'static const a3d_Hrtf_t A3dHrirDImpulse = {'
665     initnc 'static const a3d_ItdDline_t A3dItdDlineZeros = {'
666     initnc 'static auxxEqCoeffSet_t asEqCoefsNormal = {'
667     initnc 'static xtalk_dline_t const alXtalkDlineTest = {'
668     initnc 'static struct nand_ecclayout rtc_from4_nand_oobinfo = {'
669     initnc 'static const s16 tempLUT\[\] ='
670     initnc 'static const u8 viaLUT\[\] ='
671     initnc 'static struct { int xres, yres, left, right, upper, lower, hslen, vslen, vfreq; } timmings\[\] __initdata = {'
672     initnc 'static struct platinum_regvals platinum_reg_init_[0-9]* = {'
673     initnc '} sisfb_ddc[sf]modes\[\] __devinitdata ='
674     initnc 'static struct dvb_pll_desc [^\n]* = {'
675     initnc 'static u32 LABELPATCHES\[\] __attribute((unused)) ='
676
677     initnc 'static dbdev_tab_t dbdev_tab\[\] ='
678     accept '\(EXP\|LOG\|ATAN\)TBL:'"$sepx$blobpat*"
679     initnc 'static char fm_volume_table\[128\] ='
680     initnc 'unsigned int snd_gf1_scale_table\[SNDRV_GF1_SCALE_TABLE_SIZE\] ='
681     # remaining after original deblob_2_6_24, not fully checked
682
683     oprepline '#define OV51[18]_\(Y\|UV\)QUANTABLE {'
684     initnc '            static unsigned char const data_bit\[64\] ='
685     initnc '            static const u8 data_sbit\[32\] ='
686     initnc '    \.RightCoefs ='
687     initnc '    #define WakeupSeq    {'
688     initnc '    SetRate44100\[\] ='
689     initnc '    const short period\[32\] ='
690     initnc '    const static int desc_idx_table\[\] ='
691     initnc '    int prop_bcomm_irq\[3\*16\] ='
692     initnc '    static char logSlopeTable\[128\] ='
693     initnc '    static const int uc_\(dup\|word\)_table\[\]\[2\] ='
694     initnc '    static const struct mc7_timing_params mc7_timings\[\] ='
695     initnc '    static const u8 biphase_tbl\[\] ='
696     initnc '    static const u8 cs170\[7 \* 8\] ='
697     initnc '    static const u8 cs3[13]a\[8 \* 4\] ='
698     initnc '    static const u8 dramsr13\[12 \* 5\] ='
699     initnc '    static const u8 log10\[\] ='
700     initnc '    static const u8 mpeg_hdr_data\[\] ='
701     initnc '    static const u8 sdramtype\[13\]\[5\] ='
702     initnc '    static const u8 t\[\] ='
703     initnc '    static const unsigned int avg_pkts\[NCCTRL_WIN\] ='
704     initnc '    static const unsigned short ac97_defaults\[\] ='
705     initnc '    static int exp_lut\[256\] ='
706     initnc '    static u16 jpeg_tables\[\]\[70\] ='
707     initnc '    static u16 tables\[\] ='
708     initnc '    static u32 logMagTable\[128\] ='
709     initnc '    static u8 init_bufs\[13\]\[5\] ='
710     initnc '    static u8 sine \[\] ='
711     initnc '    static u_short geometry_table\[\]\[[45]\] ='
712     initnc '    static unsigned char CRCTable1\[\] ='
713     initnc '    static unsigned char CRCTable2\[\] ='
714     initnc '    static unsigned char default_colors\[\] ='
715     initnc '    static unsigned char iso_regs\[8\]\[4\] ='
716     initnc '    static unsigned char log_scale\[101\] ='
717     initnc '    static unsigned char msg\[\] ='
718     initnc '    static unsigned char static_pad\[\] ='
719     initnc '    static unsigned char table_alaw2ulaw\[\] ='
720     initnc '    static unsigned char table_ulaw2alaw\[\] ='
721     initnc '    u32 reg_boundaries\[\] ='
722     initnc '    u8 b\[\] ='
723     initnc '    uint8_t tx\[\] ='
724     initnc '    unsigned char saa7111_regs\[\] ='
725     initnc '    unsigned char sas_pcd_m_pg\[\] ='
726     initnc '    } modedb\[5\] ='
727     initnc '    } reg_tbl\[\] ='
728     initnc '    } vals\[\] ='
729     initnc '    } vm_devices\[\] ='
730     initnc '    static const code distfix\[32\] ='
731     initnc '    static const code lenfix\[512\] ='
732     initnc '  int poly\[\]='
733     initnc '  static const unsigned char asso_values\[\] ='
734     initnc '  static unsigned char asso_values\[\] ='
735     initnc '  } cards_ds\[\] ='
736     initnc '    static const int8 countLeadingZerosHigh\[\] ='
737     initnc '    static const unsigned short d\(base\|ext\)\[32\] ='
738     initnc '#define OV511_QUANTABLESIZE 64'
739     initnc 'BYTE BtCard::SRAMTable_\(NTSC\|PAL\)\[\] ='
740     initnc 'BYTE SRAMTable\[\]\[ 60 \] ='
741     accept 'irq_prio_[hdlc]*:'"$sepx$blobpat*"
742     initc '__u8 _ascebc\[256\] ='
743     initc '__u8 _ebc_tolower\[256\] ='
744     initc '__u8 _ebc_toupper\[256\] ='
745     initnc 'adapter_tag_info_t aic7[9x]xx_tag_info\[\] ='
746     initnc 'char dmasound_alaw2dma8\[\] ='
747     initnc 'char dmasound_ulaw2dma8\[\] ='
748     initnc 'const struct aper_size_info_16 agp3_generic_sizes\[AGP_GENERIC_SIZES_ENTRIES\] ='
749     initnc 'const u16 crc_itu_t_table\[256\] ='
750     initnc 'const u8 byte_rev_table\[256\] ='
751     initnc 'const u8 crc7_syndrome_table\[256\] ='
752     initnc 'const unsigned char INIT_2\[127\] ='
753     initnc 'int snd_sf_vol_table\[128\] ='
754     initnc 'static      u_char  irq_to_siubit\[\] ='
755     initnc 'static      u_char  irq_to_siureg\[\] ='
756     initnc 'static Byte_t RData\[RDATASIZE\] ='
757     initnc 'static __const__ __u16 gx_coeff\[256\] ='
758     initnc 'static __u8 init7121ntsc\[\] ='
759     initnc 'static __u8 init7121pal\[\] ='
760     initnc 'static __u8 mode8420\(pro\|con\)\[\] ='
761     initnc 'static byte capidtmf_leading_zeroes_table\[0x100\] ='
762     initnc 'static char channel_map_madi_ss\[HDSPM_MAX_CHANNELS\] ='
763     initnc 'static char coefficients\[NM_TOTAL_COEFF_COUNT \* 4\] ='
764     initnc 'static char ecc_syndrome_table\[\] ='
765     initnc 'static char isdn_audio_alaw_to_ulaw\[\] ='
766     initnc 'static char isdn_audio_ulaw_to_alaw\[\] ='
767     initnc 'static char mix_cvt\[101\] ='
768     initnc 'static char opl3_volume_table\[128\] ='
769     initnc 'static const RegInitializer initData\[\] __initdata ='
770     initnc 'static const __u16 crc10_table\[256\] ='
771     initnc 'static const __u32 crc_c\[256\] ='
772     initnc 'static const char zr360[56]0_dht\[0x1a4\] ='
773     initnc 'static const char zr360[56]0_dqt\[0x86\] ='
774     initnc 'static const fixp_t cos_table\[46\] ='
775     initnc 'static const int init_seq\[\] ='
776     initnc 'static const int mobile_vid_table\[32\] ='
777     initnc 'static const s16 snd_opl4_pitch_map\[0x600\] ='
778     initnc 'static const s8 \(b43\(\|legacy\)\|bcm43xx\)_tssi2dbm_[bg]_table\[\] ='
779     initnc 'static const s8 budtab\[256\] ='
780     initnc 'static const struct aper_size_info_32 u3_sizes\[8\] ='
781     initnc 'static const struct aper_size_info_8 via_generic_sizes\[9\] ='
782     initnc 'static const struct color clut_vga16\[16\] ='
783     initnc 'static const struct gain_entry gain_table\[2\]\[108\] ='
784     initnc 'static const struct mV_pos __initdata mobilevrm_mV\[32\] ='
785     initnc 'static const struct mV_pos __initdata vrm85_mV\[32\] ='
786     initnc 'static const struct menelaus_vtg_value vcore_values\[\] ='
787     initnc 'static const struct opl4_region regions_[0-9a-frums]*\[\] ='
788     initnc 'static const struct regval regval_table\[\] ='
789     initnc 'static const struct rf_channel rf_vals_5222\[\] ='
790     initnc 'static const struct rf_channel rf_vals_5225_2527\[\] ='
791     initnc 'static const struct rf_channel rf_vals_5226\[\] ='
792     initnc 'static const struct rf_channel rf_vals_bg\[\] ='
793     initnc 'static const struct rf_channel rf_vals_bg_2522\[\] ='
794     initnc 'static const struct rf_channel rf_vals_bg_2523\[\] ='
795     initnc 'static const struct rf_channel rf_vals_bg_2524\[\] ='
796     initnc 'static const struct rf_channel rf_vals_bg_2525\[\] ='
797     initnc 'static const struct rf_channel rf_vals_bg_2525e\[\] ='
798     initnc 'static const struct rf_channel rf_vals_bg_2528\[\] ='
799     initnc 'static const struct rf_channel rf_vals_noseq\[\] ='
800     initnc 'static const struct rf_channel rf_vals_seq\[\] ='
801     initnc 'static const u16 Sbox\[256\] ='
802     initnc 'static const u16 count_lut\[\] ='
803     # drivers/net/e1000e/phy.c
804     initnc 'static const u16 e1000_igp_2_cable_length_table\[\] ='
805     initnc 'static const u16 rtl8225bcd_rxgain\[\] ='
806     initnc 'static const u16 rtl8225z2_rxgain\[\] ='
807     initnc 'static const u16 stufftab\[5 \* 256\] ='
808     initnc 'static const u16 tkip_sbox\[256\] ='
809     initnc 'static const u16 wm8753_reg\[\] ='
810     initnc 'static const u32 SS[0-3]\[256\] ='
811     initnc 'static const u32 S[1-8]\[64\] ='
812     initnc 'static const u32 T[0-5]\[256\] ='
813     initnc 'static const u32 Tm\[24\]\[8\] ='
814     initnc 'static const u32 bass_table\[41\]\[5\] ='
815     initnc 'static const u32 bf_sbox\[256 \* 4\] ='
816     initnc 'static const u32 camellia_sp0222\[256\] ='
817     initnc 'static const u32 camellia_sp1110\[256\] ='
818     initnc 'static const u32 camellia_sp3033\[256\] ='
819     initnc 'static const u32 camellia_sp4404\[256\] ='
820     initnc 'static const u32 crc32c_table\[256\] ='
821     initnc 'static const u32 db_table\[101\] ='
822     initnc 'static const u32 m8xx_size_to_gray\[M8XX_SIZES_NO\] ='
823     initnc 'static const u32 mds\[4\]\[256\] ='
824     initnc 'static const u32 pc2\[1024\] ='
825     initnc 'static const u32 s[1-7]\[256\] ='
826     initnc 'static const u32 sb8\[256\] ='
827     initnc 'static const u32 tfrc_calc_x_lookup\[TFRC_CALC_X_ARRSIZE\]\[2\] ='
828     initnc 'static const u32 treble_table\[41\]\[5\] ='
829     initnc 'static const u64 [CT][0-7]\[256\] ='
830     initnc 'static const u64 sbox[1-4]\[256\] ='
831     initnc 'static const u64 sha512_K\[80\] ='
832     initnc 'static const u8 Tr\[4\]\[8\] ='
833     initnc 'static const u8 aes_sbox\[256\] ='
834     initnc 'static const u8 calc_sb_tbl\[512\] ='
835     initnc 'static const u8 exp_to_poly\[492\] ='
836     initnc 'static const u8 legal_ansi_char_array\[0x40\] ='
837     initnc 'static const u8 parity\[\] ='
838     initnc 'static const u8 pc1\[256\] ='
839     initnc 'static const u8 poly_to_exp\[255\] ='
840     initnc 'static const u8 q[01]\[256\] ='
841     initnc 'static const u8 ratio_lut\[\] ='
842     initnc 'static const u8 rs\[256\] ='
843     initnc 'static const u8 rtl8225_agc\[\] ='
844     initnc 'static const u8 rtl8225_tx_power_cck\[\] ='
845     initnc 'static const u8 rtl8225_tx_power_cck_ch14\[\] ='
846     initnc 'static const u8 rtl8225z2_tx_gain_cck_ofdm\[\] ='
847     initnc 'static const u8 setup\[\] ='
848     initnc 'static const u8 speedtab \[3\]\[12\] ='
849     initnc 'static const u_char irq_to_siubit\[\] ='
850     initnc 'static const u_char irq_to_siureg\[\] ='
851     initnc 'static const u_char nand_ecc_precalc_table\[\] ='
852     initnc 'static const uint8_t parity\[256\] ='
853     initnc 'static const unsigned char \(UV\|Y\)_QUANTABLE\[64\] ='
854     initnc 'static const unsigned char __initdata mV_mobilevrm\[32\] ='
855     initnc 'static const unsigned char __initdata mV_vrm85\[32\] ='
856     initnc 'static const unsigned char barco_p1\[2\]\[9\]\[7\]\[3\] ='
857     initnc 'static const unsigned char bitcounts\[256\] ='
858     initnc 'static const unsigned char blue\[256\] ='
859     initnc 'static const unsigned char chktab[hl]\[256\] ='
860     initnc 'static const unsigned char comet_miireg2offset\[32\] ='
861     initnc 'static \(const \)\?unsigned char euc2sjisibm_g3upper_map\[\]\[2\] ='
862     initnc 'static const unsigned char green\[256\] ='
863     initnc 'static const unsigned char hash_table_ops\[64\*4\] ='
864     initnc 'static const unsigned char hid_keyboard\[256\] ='
865     initnc 'static const unsigned char mts_direction\[256\/8\] ='
866     initnc 'static const unsigned char red\[256\] ='
867     initnc 'static \(const \)\?unsigned char sjisibm2euc_map\[\]\[2\] ='
868     initnc 'static const unsigned char vol_cvt_datt\[128\] ='
869     initnc 'static const unsigned char wm_vol\[256\] ='
870     initnc 'static const unsigned int MulIdx\[16\]\[16\] ='
871     initnc 'static const unsigned int crctab32\[\] ='
872     initnc 'static const unsigned short crc_flex_table\[\] ='
873     initnc 'static const unsigned short logtable\[256\] ='
874     initnc 'static const unsigned short wd7000_iobase\[\] ='
875     initnc 'static const unsigned short x86_keycodes\[256\] ='
876     initnc 'static const unsigned table\[\] ='
877     initnc 'static int MV300_reg_8bit\[256\] ='
878     initnc 'static int fifo_map\[\]\[MAX_TX_FIFOS\] ='
879     initnc 'static int initial_lfsr\[\] ='
880     initnc 'static int log_tbl\[129\] ='
881     initnc 'static int logitech_expanded_keymap\[LOGITECH_EXPANDED_KEYMAP_SIZE\] ='
882     initnc 'static int miro_fmtuner\[\]  ='
883     initnc 'static int miro_tunermap\[\] ='
884     initnc 'static int register_size\[\] ='
885     initnc 'static int reserve_list\[MAX_RES_ARGS\] ='
886     initnc 'static int reverse6\[64\] ='
887     initnc 'static short attack_time_tbl\[128\] ='
888     initnc 'static short beep_wform\[256\] ='
889     initnc 'static short decay_time_tbl\[128\] ='
890     initnc 'static short isdn_audio_[ua]law_to_s16\[\] ='
891     initnc 'static struct cipher_testvec anubis_cbc_dec_tv_template\[\] ='
892     initnc 'static struct cipher_testvec anubis_cbc_enc_tv_template\[\] ='
893     initnc 'static struct cipher_testvec anubis_dec_tv_template\[\] ='
894     initnc 'static struct cipher_testvec anubis_enc_tv_template\[\] ='
895     initnc 'static struct cipher_testvec camellia_cbc_dec_tv_template\[\] ='
896     initnc 'static struct cipher_testvec camellia_cbc_enc_tv_template\[\] ='
897     initnc 'static struct cipher_testvec camellia_dec_tv_template\[\] ='
898     initnc 'static struct cipher_testvec camellia_enc_tv_template\[\] ='
899     initnc 'static struct cipher_testvec cast6_dec_tv_template\[\] ='
900     initnc 'static struct cipher_testvec cast6_enc_tv_template\[\] ='
901     initnc 'static struct cipher_testvec serpent_dec_tv_template\[\] ='
902     initnc 'static struct cipher_testvec serpent_enc_tv_template\[\] ='
903     initnc 'static struct cipher_testvec tea_dec_tv_template\[\] ='
904     initnc 'static struct cipher_testvec tea_enc_tv_template\[\] ='
905     initnc 'static struct cipher_testvec tf_dec_tv_template\[\] ='
906     initnc 'static struct cipher_testvec tf_enc_tv_template\[\] ='
907     initnc 'static struct cipher_testvec tnepres_dec_tv_template\[\] ='
908     initnc 'static struct cipher_testvec xeta_dec_tv_template\[\] ='
909     initnc 'static struct cipher_testvec xeta_enc_tv_template\[\] ='
910     initnc 'static struct cipher_testvec xtea_dec_tv_template\[\] ='
911     initnc 'static struct cipher_testvec xtea_enc_tv_template\[\] ='
912     initnc 'static struct comp_testvec deflate_decomp_tv_template\[\] ='
913     initnc 'static struct hash_testvec aes_xcbc128_tv_template\[\] ='
914     initnc 'static struct hash_testvec crc32c_tv_template\[\] ='
915     initnc 'static struct hash_testvec hmac_sha256_tv_template\[\] ='
916     initnc 'static struct hash_testvec sha256_tv_template\[\] ='
917     initnc 'static struct hash_testvec sha384_tv_template\[\] ='
918     initnc 'static struct hash_testvec sha512_tv_template\[\] ='
919     initnc 'static struct hash_testvec wp256_tv_template\[\] ='
920     initnc 'static struct hash_testvec wp384_tv_template\[\] ='
921     initnc 'static struct hash_testvec wp512_tv_template\[\] ='
922     initnc 'static struct iwl\(3945\)\?_tx_power power_gain_table\[2\]\[IWL_MAX_GAIN_ENTRIES\] ='
923     initnc 'static struct ovcamchip_regvals regvals_init_\(76be\|7[16]20\|7x10\)\[\] ='
924     initnc 'static struct regval_list ov7670_default_regs\[\] ='
925     initnc 'static struct s_c2 SetRate48000\[\] ='
926     initnc 'static struct tea6420_multiplex TEA6420_line\[MXB_AUDIOS+1\]\[2\] ='
927     initnc 'static struct wm_info i810_wm_16_100\[\] ='
928     initnc 'static struct wm_info i810_wm_16_133\[\] ='
929     initnc 'static struct wm_info i810_wm_24_100\[\] ='
930     initnc 'static struct wm_info i810_wm_24_133\[\] ='
931     initnc 'static struct wm_info i810_wm_8_100\[\] ='
932     initnc 'static struct wm_info i810_wm_8_133\[\] ='
933     initnc 'static struct { struct fb_bitfield red, green, blue, transp; int bits_per_pixel; } colors\[\] ='
934     initnc 'static u16 asEqCoefsPipes\[64\] ='
935     initnc 'static u16 asEqCoefsZeros\[50\] ='
936     initnc 'static u16 asEqOutStateZeros\[48\] ='
937     initnc 'static u16 default_key_map \[256\] ='
938     initnc 'static u16 eq_levels\[64\] ='
939     initnc 'static u32  crc32tab\[\] __attribute__ ((aligned(8))) ='
940     initnc 'static u32 ac3_frames\[3\]\[32\] ='
941     initnc 'static u32 adwDecim8\[33\] ='
942     initnc 'static u32 h_prescale\[64\] ='
943     initnc 'static u32 v_gain\[64\] ='
944     initnc 'static u8 cvs_time_value\[\]\[XFER_UDMA_6 - XFER_UDMA_0 + 1\] ='
945     initnc 'static u8 SRAM_Table\[\]\[60\] ='
946     initnc 'static u8 act_time_value\[\]\[8\] ='
947     initnc 'static u8 alps_tdee4_stv0297_inittab\[\] ='
948     initnc 'static u8 bnx2_5706_stats_len_arr\[BNX2_NUM_STATS\] ='
949     initnc 'static u8 bnx2_5708_stats_len_arr\[BNX2_NUM_STATS\] ='
950     initnc 'static u8 flit_desc_map\[\] ='
951     initnc 'static u8 ini_time_value\[\]\[8\] ='
952     initnc 'static u8 init_tab \[\] ='
953     initnc 'static u8 mac_reader\[\] ='
954     initnc 'static u8 mt2131_config1\[\] ='
955     initnc 'static u8 mt2266_init2\[\] ='
956     initnc 'static u8 opera1_inittab\[\] ='
957     initnc 'static u8 rco_time_value\[\]\[8\] ='
958     initnc 'static u8 saa7113_init_regs\[\] ='
959     initnc 'static u8 samsung_tbmu24112_inittab\[\] ='
960     initnc 'static u8 tas3004_treble_table\[\] ='
961     initnc 'static u8 w1_crc8_table\[\] ='
962     initnc 'static u_char const data_sizes_32\[32\] ='
963     initnc 'static u_long ident_map\[32\] ='
964     initnc 'static u_short alt_map\[NR_KEYS\] ='
965     initnc 'static u_short altgr_map\[NR_KEYS\] ='
966     initnc 'static u_short ctrl_alt_map\[NR_KEYS\] ='
967     initnc 'static u_short ctrl_map\[NR_KEYS\] *='
968     initnc 'static u_short shift_ctrl_map\[NR_KEYS\] ='
969     initnc 'static u_short shift_map\[NR_KEYS\] *='
970     initnc 'static uchar perm1\[56\] ='
971     initnc 'static uchar perm2\[48\] ='
972     initnc 'static uchar perm3\[64\] ='
973     initnc 'static uchar perm4\[48\] ='
974     initnc 'static uchar perm5\[32\] ='
975     initnc 'static uchar perm6\[64\] ='
976     initnc 'static uchar sbox\[8\]\[4\]\[16\] ='
977     initnc 'static uint16_t crc_table\[256\] ='
978     initnc 'static uint8_t lpfcAlpaArray\[\] ='
979     initnc 'static uint8_t seqprog\[\] ='
980     initnc 'static unsigned char V110_OffMatrix_9600\[\] ='
981     initnc 'static unsigned char V110_OnMatrix_9600\[\] ='
982     initnc 'static unsigned char a2232_65EC02code\[\] ='
983     initnc 'static unsigned char alaw_main\[\] ='
984     initnc 'static unsigned char atkbd_set3_keycode\[512\] ='
985     initnc 'static unsigned char atkbd_unxlate_table\[128\] ='
986     initnc 'static unsigned char banner_table\[\] ='
987     initnc 'static unsigned char bootlogo_bits\[\] ='
988     initnc 'static unsigned char bus2core_8260\[\] ='
989     initnc 'static unsigned char bus2core_8280\[\] ='
990     initnc 'static unsigned char caseorder\[256\] ='
991     initnc 'static unsigned char crystal_key\[\] ='
992     initnc 'static unsigned char dsp_ulaw\[\] ='
993     initnc 'static unsigned char expressiontab\[128\] ='
994     initnc 'static unsigned char header2\[\] ='
995     initnc 'static unsigned char hidp_keycode\[256\] ='
996     initnc 'static unsigned char ima_adpcm_capture\[\] ='
997     initnc 'static unsigned char ima_adpcm_init\[\] ='
998     initnc 'static unsigned char ima_adpcm_playback\[\] ='
999     initnc 'static unsigned char irq_xlate\[32\] ='
1000     initnc 'static unsigned char mulaw_main\[\] ='
1001     initnc 'static unsigned char nkbd_keycode\[128\] ='
1002     initnc 'static unsigned char pan_volumes\[256\] ='
1003     initnc 'static unsigned char parm_block\[32\] ='
1004     initnc 'static unsigned char raw3270_ebcgraf\[64\] ='
1005     initnc 'static unsigned char rfcomm_crc_table\[256\] ='
1006     initnc 'static unsigned char rwa_unlock\[\] __initdata ='
1007     initnc 'static unsigned char seqprog\[\] ='
1008     initnc 'static unsigned char snd_opl4_volume_table\[128\] ='
1009     initnc 'static unsigned char splash_bits\[\] ='
1010     initnc 'static unsigned char sunkbd_keycode\[128\] ='
1011     initnc 'static unsigned char ufs_fragtable_8fpb\[\] ='
1012     initnc 'static unsigned char ufs_fragtable_other\[\] ='
1013     initnc 'static unsigned char ulaw_dsp\[\] ='
1014     initnc 'static unsigned char usb_kbd_keycode\[256\] ='
1015     initnc 'static unsigned char vga_font\[cmapsz\] \(BTDATA \|\)='
1016     initnc 'static unsigned char voltab[12]\[128\] ='
1017     initnc 'static unsigned char vpd89_data\[\] ='
1018     initnc 'static unsigned char xtkbd_keycode\[256\] ='
1019     initnc 'static unsigned int ac3_bitrates\[32\] ='
1020     initnc 'static unsigned int bass_volume_table\[\] ='
1021     initnc 'static unsigned int bitrates\[3\]\[16\] ='
1022     initnc 'static unsigned int isa_dma_port\[8\]\[7\] ='
1023     initnc 'static unsigned int master_volume_table\[\] ='
1024     initnc 'static unsigned int mixer_volume_table\[\] ='
1025     initnc 'static unsigned int pan_table\[63\] ='
1026     initnc 'static unsigned int snapper_bass_volume_table\[\] ='
1027     initnc 'static unsigned int snapper_treble_volume_table\[\] ='
1028     initnc 'static unsigned int treble_volume_table\[\] ='
1029     initnc 'static unsigned int valid_mem\[\] ='
1030     initnc 'static unsigned long arthur_to_linux_signals\[32\] ='
1031     initnc 'static unsigned long shmedia_opcode_table\[64\] ='
1032     initnc 'static unsigned nv\([34]\|10\)TableP\(FIFO\|GRAPH\|RAMIN\)\[\]\[2\] ='
1033     initnc 'static unsigned short fcstab\[256\] ='
1034     initnc 'static unsigned short init[1234]\[128\] \/\*__devinitdata\*\/ ='
1035     initnc 'static unsigned short log_table\[LOG_TABLE_SIZE\*2\] ='
1036     initnc 'static unsigned short rc_ioport\[\] ='
1037     initnc 'static unsigned short translations\[\]\[256\] ='
1038     initnc 'static unsigned short treble_parm\[12\]\[9\] ='
1039     initnc 'struct RGBColors TextCLUT\[256\] ='
1040     initnc 'struct VgaRegs GenVgaTextRegs\[NREGS+1\] ='
1041     initnc 'struct battery_thresh  spitz_battery_levels_noac\[\] ='
1042     initnc 'struct battery_thresh spitz_battery_levels_acin\[\] ='
1043     initnc 'struct fb_bitfield rgb_bitfields\[\]\[4\] ='
1044     initnc 'struct mode_registers std_modes\[\] ='
1045     initnc 'struct vmode_attr vmode_attrs\[VMODE_MAX\] ='
1046     initnc 'u16 const crc16_table\[256\] ='
1047     initnc 'u16 const crc_ccitt_table\[256\] ='
1048     initnc 'u16 hfsplus_compose_table\[\] ='
1049     initnc 'u16 hfsplus_decompose_table\[\] ='
1050     initnc 'u_char const data_sizes_16\[32\] ='
1051     initnc 'u_short alt_map\[NR_KEYS\] ='
1052     initnc 'u_short altgr_map\[NR_KEYS\] ='
1053     initnc 'u_short ctrl_alt_map\[NR_KEYS\] ='
1054     initnc 'u_short ctrl_map\[NR_KEYS\] *='
1055     initnc 'u_short plain_map\[NR_KEYS\] *='
1056     initnc 'u_short shift_ctrl_map\[NR_KEYS\] ='
1057     initnc 'u_short shift_map\[NR_KEYS\] *='
1058     initnc 'uint patch_2[0f]00\[\] ='
1059     initnc 'uint16_t e1000_igp_cable_length_table\[IGP01E1000_AGC_LENGTH_TABLE_SIZE\] ='
1060     initnc 'uint16_t e1000_igp_2_cable_length_table\[IGP02E1000_AGC_LENGTH_TABLE_SIZE\] ='
1061     initnc '} euc2sjisibm_jisx0212_map\[\] ='
1062     initnc '} freq\[\] ='
1063     initnc '} hps_h_coeff_tab \[\] ='
1064     initnc '} hps_v_coeff_tab \[\] ='
1065     initnc '} init_tab\[\] ='
1066     initnc '} maven_gamma\[\] ='
1067     initnc '} mem_table\[\] ='
1068     initnc '} mxb_saa7740_init\[\] ='
1069     initnc '} pll_table\[\] ='
1070     initnc '} qam256_snr_tab\[\] ='
1071     initnc '} qam64_snr_tab\[\] ='
1072     initnc '} sil_port\[\] ='
1073     initnc '} vsb_snr_tab\[\] ='
1074     initnc '} yss225_registers\[\] __devinitdata ='
1075     ;;
1076   */patch*2.6.25-rc*)
1077     initnc ';[/][*]@@ -[0-9]*,[0-9]* +[0-9]*,[0-9]* @@ static uchar sbox\[8\]\[4\]\[16\] = {[*][/];'
1078     accept '    \$3 = {{pge = {{ste = {\(\([0-9][0-9a-fx{},\n   ]*\|\(pge\|ste\) =\|<repeats [0-9]\+ times>\)[{},\n     ]*\)*<repeats 11 times>}'"$eol"
1079     initnc 'static yyconst flex_int\(16\|32\)_t yy_[^[]*\[[0-9]*\] ='
1080     initnc 'static const yytype_u\?int\(8\|16\) yy[^[]*\[\] ='
1081     initnc '    int bcomm_irq\[3\*16\] ='
1082     initnc '    static const int8 countLeadingZerosHigh\[\] ='
1083     initnc 'static unsigned long shmedia_opcode_table\[64\] ='
1084     initnc 'u_char const data_sizes_16\[32\] ='
1085     initnc 'static u_char const data_sizes_32\[32\] ='
1086     initnc '            \.\(digest\|entries\|input\|key\|output\|plaintext\|result\)[   ]*= {'
1087     initnc 'static struct [^\n]*_testvec [^\n]*_tv_template\[\] ='
1088     initnc 'static struct nic_qp_map nic_qp_mapping_[01]\[\] ='
1089     initnc 'static u8 mt2266_init2\[\] ='
1090     initnc 'static struct regval ov_initvals\[\] ='
1091     initnc 'static struct regval stk1125_initvals\[\] ='
1092     initnc 'static u8 bnx2x_stats_len_arr\[BNX2X_NUM_STATS\] ='
1093     initnc 'static const struct arb_line read_arb_data\[NUM_RD_Q\]\[MAX_RD_ORD + 1\] ='
1094     initnc 'static const struct arb_line write_arb_data\[NUM_WR_Q\]\[MAX_WR_ORD + 1\] ='
1095     initnc 'uint16_t e1000_igp_cable_length_table\[IGP01E1000_AGC_LENGTH_TABLE_SIZE\] ='
1096     initnc 'uint16_t e1000_igp_2_cable_length_table\[IGP02E1000_AGC_LENGTH_TABLE_SIZE\] ='
1097     oprepline '#define AR5K_RATES_11A '
1098     oprepline '#define AR5K_RATES_11B '
1099     oprepline '#define AR5K_RATES_11G '
1100     oprepline '#define AR5K_RATES_TURBO '
1101     oprepline '#define AR5K_RATES_XR '
1102     initnc '            } blinkrates\[\] ='
1103     initnc 'static const struct ath5k_ini ar5212_ini\[\] ='
1104     initnc 'static const struct ath5k_ini_mode rf5413_ini_mode_end\[\] ='
1105     initnc 'static const struct ath5k_ini_rf rfregs_5111\[\] ='
1106     initnc 'static const struct ath5k_ini_rf rfregs_5112\[\] ='
1107     initnc 'static const struct ath5k_ini_rf rfregs_5112a\[\] ='
1108     initnc 'static const struct ath5k_ini_rf rfregs_5413\[\] ='
1109     initnc 'static const u16 rtl8225bcd_rxgain\[\] ='
1110     initnc 'static const u8 rtl8225_agc\[\] ='
1111     initnc 'static const u8 rtl8225_tx_power_cck\[\] ='
1112     initnc 'static const u8 rtl8225_tx_power_cck_ch14\[\] ='
1113     initnc 'static const u16 rtl8225z2_rxgain\[\] ='
1114     accept '     \( 49,\)*[\n]\([ 0-9,]*[\n]\)*     \( 49,\)*'"$eol"
1115     initnc 'static const unsigned char wm_vol\[256\] ='
1116     accept 'domain<N> <cpumask> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36'"$eol"
1117     # drivers/net/e1000e/phy.c
1118     initnc 'static const u16 e1000_igp_2_cable_length_table\[\] ='
1119     accept '    24 => \[[\n]\([^\n]*[\n]\)*     \]\(, [0-9]\+ => \[\)\?'"$eol"
1120     accept '            '"'"'0x[^\n]*[\n]\([^\n]*[\n]\)*        \]\(, [0-9]\+ => \[\)\?'"$eol"
1121     initnc 'const u\(8\|16\|32\) b43_ntab_\(\(adjustpower\|estimatepowerlt\|gainctl\|iqlt\|loftlt\|noisevar1\|tdi[24]0a\)[01]\|channelest\|frame\(lookup\|struct\)\|mcs\|pilot\|tdtrn\|tmap\)\[\] ='
1122     ;;
1123   */nouveau-drm*.patch)
1124     initnc '\(static uint32_t\|}\) nv04_graph_ctx_regs \[\] ='
1125     initnc 'static int nv10_graph_ctx_regs \[\] ='
1126
1127     # Although the developers of the drivers are not trying to stop
1128     # anyone from modifying it or understanding it, they acknowledge
1129     # these are bits of code, obtained through mmio interactions.
1130     # This means these blobs are not source code, AND original authors
1131     # of the blobs have power to stop others from modifying them.
1132     # Non-Free software, for sure.
1133
1134     # initnc 'static uint32_t nv\(4[013467ace]\|49_4b\|8[46]\)_ctx_\(voodoo\|prog\)\[\] ='
1135     ;;
1136   */linux-2.6-lirc.patch)
1137     initnc 'const unsigned char map_table\[\] ='
1138     ;;
1139   */linux-2.6-modsign-mpilib.patch)
1140     initnc 'const unsigned char __clz_tab\[\] ='
1141     ;;
1142   */linux-2.6-wireless*.patch)
1143     initnc 'const u\(8\|16\|32\) b43_ntab_\(\(adjustpower\|estimatepowerlt\|gainctl\|iqlt\|loftlt\|noisevar1\|tdi[24]0a\)[01]\|channelest\|frame\(lookup\|struct\)\|mcs\|pilot\|tdtrn\|tmap\)\[\] ='
1144     initnc 'static const s8 \(b43\(legacy\)\?\|bcm43xx\)_tssi2dbm_[bg]_table\[\] ='
1145     initnc 'static struct iwl\(3945\)\?_tx_power power_gain_table\[2\]\[IWL_MAX_GAIN_ENTRIES\] ='
1146     initnc 'static const struct gain_entry gain_table\[2\]\[108\] ='
1147     initnc 'static const struct rf_channel rf_vals_5222\[\] ='
1148     initnc 'static const struct rf_channel rf_vals_5225_2527\[\] ='
1149     initnc 'static const struct rf_channel rf_vals_5226\[\] ='
1150     initnc 'static const struct rf_channel rf_vals_bg\[\] ='
1151     initnc 'static const struct rf_channel rf_vals_bg_2522\[\] ='
1152     initnc 'static const struct rf_channel rf_vals_bg_2523\[\] ='
1153     initnc 'static const struct rf_channel rf_vals_bg_2524\[\] ='
1154     initnc 'static const struct rf_channel rf_vals_bg_2525\[\] ='
1155     initnc 'static const struct rf_channel rf_vals_bg_2525e\[\] ='
1156     initnc 'static const struct rf_channel rf_vals_bg_2528\[\] ='
1157     initnc 'static const struct rf_channel rf_vals_noseq\[\] ='
1158     initnc 'static const struct rf_channel rf_vals_seq\[\] ='
1159     initnc '    static const u8 t\[\] ='
1160     initnc 'static const u16 rtl8225bcd_rxgain\[\] ='
1161     initnc 'static const u8 rtl8225_agc\[\] ='
1162     initnc 'static const u8 rtl8225_tx_power_cck\[\] ='
1163     initnc 'static const u8 rtl8225_tx_power_cck_ch14\[\] ='
1164     initnc 'static const u16 rtl8225z2_rxgain\[\] ='
1165     initnc 'static const struct ath5k_ini_rf rfregs_5111\[\] ='
1166     initnc 'static const struct ath5k_ini_rf rfregs_5112\[\] ='
1167     initnc 'static const struct ath5k_ini_rf rfregs_5112a\[\] ='
1168     initnc 'static const struct ath5k_ini_rf rfregs_5413\[\] ='
1169     oprepline '#define AR5K_RATES_11A '
1170     oprepline '#define AR5K_RATES_11B '
1171     oprepline '#define AR5K_RATES_11G '
1172     oprepline '#define AR5K_RATES_TURBO '
1173     oprepline '#define AR5K_RATES_XR '
1174     initnc 'static const struct ath5k_ini ar5212_ini\[\] ='
1175     initnc 'static const struct ath5k_ini_mode rf\(5413\|24\(13\|25\)\)_ini_mode_end\[\] ='
1176     initnc '            } blinkrates\[\] ='
1177
1178     # git logs
1179     accept '   sudo modprobe ath5k debug=0x00000400[\n][        ]*[\n]\([       ]*Band[^\n]*[\n]\([     ]*\(\(channels\|rates\):\|[-    0-9a-f]*\|\[\.\.\. etc \]\)[\n]\)\+\)\+       540 000c 0000 0000'
1180     oprepline ' { 1, MODULATION_XR, 3000, 1, 150, 3 },'
1181     ;;
1182   */linux-2.6-drm-i915-modeset.patch)
1183     initnc 'static const u32 filter_table\[\] ='
1184     ;;
1185   */linux-2.6-netdev-e1000e*.patch)
1186     # drivers/net/e1000e/phy.c
1187     initnc 'static const u16 e1000_igp_2_cable_length_table\[\] ='
1188     ;;
1189   esac
1190 }  
1191
1192 # Regular expression that matches a literal constant.
1193 constx="[0-9][0-9a-fA-FxX]*"
1194 # Regular expression that matches a separator between consecutive
1195 # literal constants.
1196 sepx="\\([,:{}  \\nLlUu\"\'\\\\]\\+[xX\$]\\?\\|[        \\n]*[.][a-zA-Z][a-zA-Z0-9]*[   ]\\+[\$]\\?\\)"
1197
1198 # Regular expression that matches a continuation of a blob, after an
1199 # initial constant.  *, \+ and \? can be safely appended to it without
1200 # \(\)s.
1201 blobcont="\\($sepx$constx\\)"
1202
1203 # Regular expression that matches the initial constant of a blob plus
1204 # its continuation.  *, \+ and \? can be safely appended to it without
1205 # \(\)s.
1206 blobpat="$constx$blobcont"
1207
1208 # Regular expression that matches a blob with the exact number of
1209 # constants specified as sensitivity.
1210 blobseq="$blobpat\\{$sens\\}"
1211
1212 # Regular expression that matches a blob with the exact specified
1213 # length, or longer.
1214 blobfseq="$blobseq$blobcont*"
1215
1216 # Regular expression that matches the beginning of the pattern or a
1217 # line break.  It must be \(\)ed, such that it can be named in
1218 # replacement patterns without being named.
1219 bol="\\(^\\|[\\n]\\)"
1220
1221 # Regular expression that matches the end of the pattern or a line
1222 # break.  It must be \(\)ed, such that it can be named in replacement
1223 # patterns without being named.
1224 eol="\\([\\n]\\|\$\\)"
1225
1226 # Regular expression that matches a C-style comment.
1227 comment="\\([/][*]\\([^*]*\\|[*]\\+[^/*]\\)*[*]\\+[/]\\|[/][/][^\\n]*[\\n]\\)"
1228
1229 # Regular expression that matches comments typically used in assembly.
1230 asmcomment="\\($comment\\|[;#][^\\n]*[\\n]\\)"
1231
1232 # Regular expression that matches a braced initializer containing at
1233 # least one blob.
1234 initblob="[^\\n]*=\\([  \\n\\\\]*\\|$comment\\)*{\\([^;]*\\|$comment\\)*$blobseq\\([^;]*\\|$comment\\)*}\\?\\([         \\n\\\\]*\\|$comment\\);\\?"
1235
1236 # Regular expression that matches a C (possibly multi-line) #define
1237 # that contains a blob.
1238 defineblob='[   ]*#[    ]*define[       ]\+\([^\n]*\\[\n]\)*[^\n]*'"$blobseq"'\([^\n]*\\[\n]\)*'
1239
1240 # Regular expression that matches an assembly label followed by a blob
1241 # without any intervening label.
1242 asmblob="[a-zA-Z_.][^\\n:;#/    ]*[ ]*:\\([^:]*\\|$asmcomment\\)*$blobseq\\([^:]*\\|$asmcomment\\)*"
1243
1244 # Regular expression that matches one or more blobs without
1245 # intervening line breaks.
1246 sblobctx="\\([^\\n]*$blobfseq\\)\\+"
1247
1248 # Regular expression that matches the context for a long blob match.
1249 lblobctx="\\($initblob\\|$defineblob\\|$asmblob\\|$sblobctx\\)"
1250
1251 # Set up the sed script that will go through the (processed) input,
1252 # looking for sequences of blobs and printing whatever was requested.
1253 # It accepts 3 arguments.
1254
1255 # $1 is the action in case blobs were found in the input.
1256
1257 # $2 is the action in case no blobs were found, not even false positives.
1258
1259 # $3 is the action in case false positives were located.
1260
1261 # $4 is the action for every complete input pattern.
1262
1263 set_sedmain () {
1264   falsepos=`sed 's,^\\\|,,;s,^,\\\\(,;s,$,\\\\),' < "$falsepos_name"`
1265
1266   if test -s "$falsepos_name"; then
1267     check_false_positives="$v:???falsepos
1268 /$bol$falsepos/!b blob;
1269 $v:+++falsepos
1270 h;
1271 s/$bol$falsepos/\\1;\/**\/;/g;
1272 # See if, after removing all matches, we end up without any blobs.
1273 $v:???blobseq
1274 /$blobseq/!{
1275   g;
1276   b falsepos;
1277 }
1278 g;
1279 "
1280   else
1281     falsepos="$^"
1282     check_false_positives=
1283   fi
1284
1285   sedmain="
1286 /^;[/][*]\\(end .*\\)\\?[*][/];$/{
1287   $4;
1288   d;
1289 }
1290 /^;[/][*]begin /!{
1291   : internal_error
1292   i\\
1293 Internal error at
1294   p;
1295   q 2;
1296 }
1297 $v:reading file in
1298 h;
1299 n;
1300 : read_more
1301 /^;[/][*]end [^\\n]*[*][/];$/! {
1302   H;
1303   n;
1304   b read_more;
1305 }
1306 H;
1307 g;
1308 $4
1309 s/^\(;[/][*]begin [^\n]*[\n]\)*//;
1310 s/\\($bol;[/][*]\\(end [^\n]*\\)\\?[*][/];\\)*$//;
1311 $v:???!blobseq
1312 /$blobseq/!b clean;
1313 $check_false_positives
1314 # Fall through.
1315 : blob
1316 $v:blob
1317 $1
1318 d;
1319 : clean
1320 $2
1321 d;
1322 : falsepos
1323 $v:falsepos
1324 $3
1325 d;
1326
1327 : print_matches
1328 $v:print_matches
1329 /^$falsepos/! {
1330   $v:delete unmatching lines
1331   h;
1332   s/[\\n]$falsepos.*//;
1333   : print_matches_nomatch_loop
1334   /[\\n]/ {
1335     s/^[^\\n]*[\\n]//;
1336     x;
1337     s/^[^\\n]*[\\n]//;
1338     x;
1339     b print_matches_nomatch_loop;
1340   }
1341   x;
1342   b print_matches_delete_to_eol;
1343 }
1344 h;
1345 s/^\\($falsepos[^\\n]*\\)\\([\\n].*\\)\\?$/\\1/;
1346 $v:narrowed to match
1347 /$blobfseq/ {
1348   i\\
1349 ::: $file :::
1350   p;
1351 }
1352 g;
1353 s/^\\($falsepos[^\\n]*\\)//;
1354 : print_matches_delete_to_eol
1355 $v:delete to eol
1356 s/^[^\\n]*//;
1357 /^$/d;
1358 s/^[\\n]//;
1359 b print_matches;
1360
1361 : print_marked_matches
1362 $v:print_marked_matches
1363 /^$falsepos/! {
1364   h;
1365   s/[\\n]$falsepos.*//;
1366   : print_marked_matches_nomatch_loop
1367   /[\\n]/ {
1368     s/^[^\\n]*[\\n]//;
1369     x;
1370     s/^[^\\n]*[\\n]//;
1371     x;
1372     b print_marked_matches_nomatch_loop;
1373   }
1374   x;
1375   b print_marked_matches_delete_to_eol;
1376 }
1377 h;
1378 s/^\\($falsepos[^\\n]*\\)\\([\\n].*\\)\\?$/\\1/;
1379 $v:narrowed to match
1380 /$blobfseq/{
1381   i\\
1382 ::: $file :::
1383   s/{\\($sepx\\)\\?$blobfseq\\($sepx\\)\\?}[    ]*;/{\/*(DEBLOBBED)*\/};/g;
1384   s/$blobfseq/\/*(DEBLOBBED)*\//g;
1385   p;
1386 }
1387 g;
1388 s/^\\($falsepos[^\\n]*\\)//;
1389 : print_marked_matches_delete_to_eol
1390 $v:delete to eol
1391 s/^[^\\n]*//;
1392 /^$/d;
1393 s/^[\\n]//;
1394 b print_marked_matches;
1395
1396 : print_blobs
1397 $v:print_blobs
1398 /^$falsepos/ {
1399   $v:delete false positive
1400   # This is tricky.  We don't want to print the false positive.
1401   /^$falsepos[^\\n]*$blobseq/ {
1402     $v:delete false positive immediately followed by blob
1403     h;
1404     s/^\\($falsepos\\)[^\\n]*$blobseq.*/\\1/;
1405     : print_blobs_match_loop
1406     /[\\n]/ {
1407       s/^[^\\n]*[\\n]//;
1408       x;
1409       s/^[^\\n]*[\\n]//;
1410       x;
1411       b print_blobs_match_loop;
1412     }
1413     G;
1414     b print_blobs_delete_to_eol;
1415   }
1416   s/^$falsepos//;
1417   b print_blobs_delete_to_eol;
1418 }
1419 /^[^\\n]*$blobseq/! {
1420   $v:delete non-blob header
1421   h;
1422   s/[\\n]\\($falsepos\\|[^\\n]*$blobseq\\).*//;
1423   : print_blobs_nomatch_loop
1424   /[\\n]/ {
1425     s/^[^\\n]*[\\n]//;
1426     x;
1427     s/^[^\\n]*[\\n]//;
1428     x;
1429     b print_blobs_nomatch_loop;
1430   }
1431   x;
1432   b print_blobs_delete_to_eol;
1433 }
1434 h;
1435 i\\
1436 ::: $file :::
1437 s/^\\([^\\n]*\\($blobfseq[^\\n]*\\)\\+\\)\\([\\n].*\\)\\?$/\\1/;
1438 $v:narrowed to blob
1439 p;
1440 g;
1441 s/^\\([^\\n]*\\($blobfseq[^\\n]*\\)\\+\\)//;
1442 : print_blobs_delete_to_eol
1443 $v:delete to eol
1444 s/^[^\\n]*//;
1445 /^$/d;
1446 s/^[\\n]//;
1447 b print_blobs;
1448
1449 : print_marked_blobs
1450 $v:print_marked_blobs
1451 /^$falsepos/ {
1452   $v:delete false positive
1453   # This is tricky.  We don't want to print the false positive.
1454   /^$falsepos[^\\n]*$blobseq/ {
1455     $v:delete false positive immediately followed by blob
1456     h;
1457     s/^\\($falsepos\\)[^\\n]*$blobseq.*/\\1/;
1458     : print_marked_blobs_match_loop
1459     /[\\n]/ {
1460       s/^[^\\n]*[\\n]//;
1461       x;
1462       s/^[^\\n]*[\\n]//;
1463       x;
1464       b print_marked_blobs_match_loop;
1465     }
1466     G;
1467     b print_marked_blobs_delete_to_eol;
1468   }
1469   s/^falsepos//;
1470   b print_marked_blobs_delete_to_eol;
1471 }
1472 /^[^\\n]*$blobseq/! {
1473   $v:delete non-blob header
1474   h;
1475   s/[\\n]\\($falsepos\\|[^\\n]*$blobseq\\).*//;
1476   : print_marked_blobs_nomatch_loop
1477   /[\\n]/ {
1478     s/^[^\\n]*[\\n]//;
1479     x;
1480     s/^[^\\n]*[\\n]//;
1481     x;
1482     b print_marked_blobs_nomatch_loop;
1483   }
1484   x;
1485   b print_marked_blobs_delete_to_eol;
1486 }
1487 h;
1488 i\\
1489 ::: $file :::
1490 s/^\\([^\\n]*\\($blobfseq[^\\n]*\\)\\+\\)\\([\\n].*\\)\\?$/\\1/;
1491 $v:narrowed to blob
1492 s/{\\($sepx\\)\\?$blobfseq\\($sepx\\)\\?}[      ]*;/{\/*(DEBLOBBED)*\/};/g;
1493 s/$blobfseq/\/*(DEBLOBBED)*\//g;
1494 p;
1495 g;
1496 s/^\\([^\\n]*\\($blobfseq[^\\n]*\\)\\+\\)//;
1497 : print_marked_blobs_delete_to_eol
1498 $v:delete to eol
1499 s/^[^\\n]*//;
1500 /^$/d;
1501 s/^[\\n]//;
1502 b print_marked_blobs;
1503
1504 : print_cblobs
1505 $v:print_cblobs
1506 /^$falsepos/ {
1507   $v:delete false positive
1508   # This is tricky.  We don't want to print the false positive.
1509   /^$falsepos[^\\n]*$blobseq/ {
1510     $v:delete false positive immediately followed by blob
1511     h;
1512     s/^\\($falsepos\\)[^\\n]*$blobseq.*/\\1/;
1513     : print_cblobs_match_loop
1514     /[\\n]/ {
1515       s/^[^\\n]*[\\n]//;
1516       x;
1517       s/^[^\\n]*[\\n]//;
1518       x;
1519       b print_cblobs_match_loop;
1520     }
1521     G;
1522     b print_cblobs_delete_to_eol;
1523   }
1524   s/^$falsepos//;
1525   b print_cblobs_delete_to_eol;
1526 }
1527 /^$lblobctx/! {
1528   $v:delete non-blob header
1529   h;
1530   s/[\\n]\\($falsepos\\|$lblobctx\\).*//;
1531   : print_cblobs_nomatch_loop
1532   /[\\n]/ {
1533     s/^[^\\n]*[\\n]//;
1534     x;
1535     s/^[^\\n]*[\\n]//;
1536     x;
1537     b print_cblobs_nomatch_loop;
1538   }
1539   x;
1540   b print_cblobs_delete_to_eol;
1541 }
1542 h;
1543 i\\
1544 ::: $file :::
1545 s/^\\($lblobctx[^\\n]*\\($blobfseq[^\\n]*\\)*\\)\\([\\n].*\\)\\?$/\\1/;
1546 $v:narrowed to blob
1547 p;
1548 g;
1549 s/^\\($lblobctx[^\\n]*\\($blobfseq[^\\n]*\\)*\\)//;
1550 : print_cblobs_delete_to_eol
1551 $v:delete to eol
1552 s/^[^\\n]*//;
1553 /^$/d;
1554 s/^[\\n]//;
1555 b print_cblobs;
1556
1557 : print_marked_cblobs
1558 $v:print_marked_cblobs
1559 /^$falsepos/ {
1560   $v:delete false positive
1561   # This is tricky.  We don't want to print the false positive.
1562   /^$falsepos[^\\n]*$blobseq/ {
1563     $v:delete false positive immediately followed by blob
1564     h;
1565     s/^\\($falsepos\\)[^\\n]*$blobseq.*/\\1/;
1566     : print_marked_cblobs_match_loop
1567     /[\\n]/ {
1568       s/^[^\\n]*[\\n]//;
1569       x;
1570       s/^[^\\n]*[\\n]//;
1571       x;
1572       b print_marked_cblobs_match_loop;
1573     }
1574     G;
1575     b print_marked_cblobs_delete_to_eol;
1576   }
1577   s/^$falsepos//;
1578   b print_marked_cblobs_delete_to_eol;
1579 }
1580 /^$lblobctx/! {
1581   $v:delete non-blob header
1582   h;
1583   s/[\\n]\\($falsepos\\|$lblobctx\\).*//;
1584   : print_marked_cblobs_nomatch_loop
1585   /[\\n]/ {
1586     s/^[^\\n]*[\\n]//;
1587     x;
1588     s/^[^\\n]*[\\n]//;
1589     x;
1590     b print_marked_cblobs_nomatch_loop;
1591   }
1592   x;
1593   b print_marked_cblobs_delete_to_eol;
1594 }
1595 h;
1596 i\\
1597 ::: $file :::
1598 s/^\\($lblobctx[^\\n]*\\($blobfseq[^\\n]*\\)*\\)\\([\\n].*\\)\\?$/\\1/;
1599 $v:narrowed to blob
1600 s/{\\($sepx\\)\\?$blobfseq\\($sepx\\)\\?}[      ]*;/{\/*(DEBLOBBED)*\/};/g;
1601 s/$blobfseq/\/*(DEBLOBBED)*\//g;
1602 p;
1603 g;
1604 s/^\\($lblobctx[^\\n]*\\($blobfseq[^\\n]*\\)*\\)//;
1605 : print_marked_cblobs_delete_to_eol
1606 $v:delete to eol
1607 s/^[^\\n]*//;
1608 /^$/d;
1609 s/^[\\n]//;
1610 b print_marked_cblobs;
1611
1612 : print_both
1613 $v:print_both
1614 /^\\($falsepos\\|[^\\n]*$blobseq\\)/! {
1615   $v:delete non-blob header
1616   h;
1617   s/[\\n]\\($falsepos\\|[^\\n]*$blobseq\\).*//;
1618   : print_both_nomatch_loop
1619   /[\\n]/ {
1620     s/^[^\\n]*[\\n]//;
1621     x;
1622     s/^[^\\n]*[\\n]//;
1623     x;
1624     b print_both_nomatch_loop;
1625   }
1626   x;
1627   b print_both_delete_to_eol;
1628 }
1629 h;
1630 i\\
1631 ::: $file :::
1632 s/^\\(\\($falsepos[^\\n]*\\|[^\\n]*$blobfseq[^\\n]*\\)\\($blobfseq[^\\n]*\\)*\\)\\([\\n].*\\)\\?$/\\1/;
1633 $v:narrowed to blob
1634 p;
1635 g;
1636 s/^\\(\\($falsepos[^\\n]*\\|[^\\n]*$blobfseq[^\\n]*\\)\\($blobfseq[^\\n]*\\)*\\)//;
1637 : print_both_delete_to_eol
1638 $v:delete to eol
1639 s/^[^\\n]*//;
1640 /^$/d;
1641 s/^[\\n]//;
1642 b print_both;
1643
1644 : list_matches
1645 $v:list_matches
1646 /^$falsepos/! {
1647   $v:print unmatching lines
1648   h;
1649   s/[\\n]$falsepos.*//;
1650   p;
1651   : list_matches_nomatch_loop
1652   /[\\n]/ {
1653     s/^[^\\n]*[\\n]//;
1654     x;
1655     s/^[^\\n]*[\\n]//;
1656     x;
1657     b list_matches_nomatch_loop;
1658   }
1659   x;
1660   b list_matches_delete_to_eol;
1661 }
1662 h;
1663 s/^\\($falsepos[^\\n]*\\)\\([\\n].*\\)\\?$/\\1/;
1664 $v:narrowed to match
1665 /$blobfseq/{
1666   s/{\\($sepx\\)\\?$blobfseq\\($sepx\\)\\?}[    ]*;/{\/*(DEBLOBBED)*\/};/g;
1667   s/$blobfseq/\/*(DEBLOBBED)*\//g;
1668 }
1669 p;
1670 g;
1671 s/^\\($falsepos[^\\n]*\\)//;
1672 : list_matches_delete_to_eol
1673 $v:delete to eol
1674 s/^[^\\n]*//;
1675 /^$/d;
1676 s/^[\\n]//;
1677 b list_matches;
1678
1679 : list_blobs
1680 $v:list_blobs
1681 /^$falsepos/ {
1682   $v:print false positive
1683   # This is tricky.  We don't want to deblob the false positive.
1684   /^$falsepos[^\\n]*$blobseq/ {
1685     $v:print false positive immediately followed by blob
1686     h;
1687     s/^\\($falsepos\\)[^\\n]*$blobseq.*/\\1/;
1688     : list_blobs_match_loop
1689     /[\\n]/ {
1690       P;
1691       s/^[^\\n]*[\\n]//;
1692       x;
1693       s/^[^\\n]*[\\n]//;
1694       x;
1695       b list_blobs_match_loop;
1696     }
1697     G;
1698     b list_blobs_delete_to_eol;
1699   }
1700   h;
1701   s/^\\($falsepos[^\\n]*\\)[\\n].*/\\1/;
1702   p;
1703   g;
1704   s/^\\($falsepos[^\\n]*\\)//;
1705   b list_blobs_delete_to_eol;
1706 }
1707 /^[^\\n]*$blobseq/! {
1708   $v:print non-blob header
1709   h;
1710   s/[\\n]\\($falsepos\\|[^\\n]*$blobseq\\).*//;
1711   p;
1712   : list_blobs_nomatch_loop
1713   /[\\n]/ {
1714     s/^[^\\n]*[\\n]//;
1715     x;
1716     s/^[^\\n]*[\\n]//;
1717     x;
1718     b list_blobs_nomatch_loop;
1719   }
1720   x;
1721   b list_blobs_delete_to_eol;
1722 }
1723 h;
1724 s/^\\([^\\n]*\\($blobfseq[^\\n]*\\)\\+\\)\\([\\n].*\\)\\?$/\\1/;
1725 $v:narrowed to blob
1726 s/{\\($sepx\\)\\?$blobfseq\\($sepx\\)\\?}[      ]*;/{\/*(DEBLOBBED)*\/};/g;
1727 s/$blobfseq/\/*(DEBLOBBED)*\//g;
1728 p;
1729 g;
1730 s/^\\([^\\n]*\\($blobfseq[^\\n]*\\)\\+\\)//;
1731 : list_blobs_delete_to_eol
1732 $v:delete to eol
1733 s/^[^\\n]*//;
1734 /^$/d;
1735 s/^[\\n]//;
1736 b list_blobs;
1737
1738 : list_both
1739 $v:list_both
1740 /^\\($falsepos\\|[^\\n]*$blobseq\\)/! {
1741   $v:print non-blob header
1742   h;
1743   s/[\\n]\\($falsepos\\|[^\\n]*$blobseq\\).*//;
1744   p;
1745   : list_both_nomatch_loop
1746   /[\\n]/ {
1747     s/^[^\\n]*[\\n]//;
1748     x;
1749     s/^[^\\n]*[\\n]//;
1750     x;
1751     b list_both_nomatch_loop;
1752   }
1753   x;
1754   b list_both_delete_to_eol;
1755 }
1756 h;
1757 s/^\\(\\($falsepos[^\\n]*\\|[^\\n]*$blobfseq[^\\n]*\\)\\($blobfseq[^\\n]*\\)*\\)\\([\\n].*\\)\\?$/\\1/;
1758 $v:narrowed to blob
1759 s/{\\($sepx\\)\\?$blobfseq\\($sepx\\)\\?}[      ]*;/{\/*(DEBLOBBED)*\/};/g;
1760 s/$blobfseq/\/*(DEBLOBBED)*\//g;
1761 p;
1762 g;
1763 s/^\\(\\($falsepos[^\\n]*\\|[^\\n]*$blobfseq[^\\n]*\\)\\($blobfseq[^\\n]*\\)*\\)//;
1764 : list_both_delete_to_eol
1765 $v:delete to eol
1766 s/^[^\\n]*//;
1767 /^$/d;
1768 s/^[\\n]//;
1769 b list_both;
1770
1771 "
1772 }
1773
1774 # Process an input file named in $1 and run it through the blob
1775 # recognizer.  Functions set_except and set_sed_cmd provide additional
1776 # arguments on a per-file and per-action basis.
1777
1778 check () {
1779   case "$#" in 1) ;; *) echo ICE >&2; exit 1;; esac
1780
1781   input=$1
1782
1783   falsepos_name=`mktemp -t deblob-check-falsepos-XXXXXX`
1784   tempfiles="$falsepos_name"
1785
1786   # Add $1 to falsepos.  Its usage makes it implicitly anchored to
1787   # the beginning of the line.
1788   addx () {
1789     if test -n "$1"; then
1790       echo -n "\\|$1" >> $falsepos_name
1791     fi
1792   }
1793
1794   set_except "$input"
1795
1796   set_sed_cmd "$input"
1797
1798   rm -f "$falsepos_name"
1799   tempfiles=
1800
1801   # Choose the input source...
1802   case $input in
1803   -) in= ;;
1804   *) in='< "$input"' ;;
1805   esac
1806
1807   set fnord # shifted out below
1808
1809   # Decompress as needed...
1810   case $input in
1811   *.bz2) cmd='bunzip2' ;;
1812   *.gz) cmd='gunzip' ;;
1813   *) cmd= ;;
1814   esac
1815   if test -n "$cmd"; then
1816     set "$@" "$cmd"
1817   fi
1818
1819   # Extract or otherwise munge...
1820   case $input in
1821   *.tar*)
1822     cmd="tar -xf - --to-command='echo \";/*begin \$TAR_FILENAME*/;\"; cat; echo \";/**/;\"; echo \";/*end \$TAR_FILENAME*/;\"'"
1823     ;;
1824   *patch* | *diff*)
1825     sedpatch='
1826       /^[-]/d;
1827       /^\(@@\|+++\) / {
1828         i\
1829 ;/**/;\
1830 ;/*end patchlet */;\
1831 ;/*begin patchlet */;
1832         s/^/;\/*/;
1833         s/$/*\/;/;
1834       };
1835       s/^[ +]//;'
1836     cmd='sed "$sedpatch"'
1837     ;;
1838   *)
1839     cmd='cat'
1840     ;;
1841   esac
1842   cmd="{ echo \";/*begin $input*/;\"; $cmd; echo \";/*end $input*/;\"; }"
1843   set "$@" "$cmd"
1844
1845   case $input in
1846   *.tar*)
1847     cmd="{ cat; cat > /dev/null; }"
1848     set "$@" "$cmd"
1849     ;;
1850   esac
1851
1852   # Then run through the selected action.
1853   if test "$rm" != "rm -f" || test ! `echo "$sedmain" | wc -c` -lt 1024; then
1854     scriptname=`mktemp -t deblob-check-sedmain-XXXXXX`
1855     tempfiles="$tempfiles $scriptname"
1856     echo "$sedmain" > $scriptname
1857     cmd="sed -n -f \"$scriptname\""
1858   else
1859     cmd='sed -n "$sedmain"'
1860   fi
1861   set "$@" "$cmd"
1862
1863   test $# != 1 || set "$@" "cat"
1864
1865   shift # fnord goes out here
1866
1867   pipe=
1868   for cmd
1869   do
1870     if test -z "$pipe"; then
1871       pipe="$cmd $in"
1872     else
1873       pipe="$pipe | $cmd"
1874     fi
1875   done
1876
1877   eval "$pipe"
1878   status=$?
1879
1880   $rm $tempfiles
1881   tempfiles=
1882
1883   (exit $status)
1884 }
1885
1886 # If no input given, use stdin.
1887 case $# in
1888 0)
1889   test -t 0 && echo reading from standard input >&2
1890   set fnord -
1891   shift
1892   ;;
1893 esac
1894
1895 # The lines below commented out out #list: can be used to get a list
1896 # of matching inputs.  ATM this is useless, so we just use a shell
1897 # boolean.
1898
1899 #list: n=$#
1900 pass=:
1901
1902 tempfiles=
1903 trap "status=$?; test -z \"$tempfiles\" || rm -f $tempfiles; (exit $status); exit" 0 1 2 15
1904
1905 # Go through each of the input files in the command line.
1906 for file
1907 do
1908   # If we print anything whatsoever (even a blank line) while
1909   # processing it, we've failed.
1910   if check "$file"; then
1911     :
1912   else
1913     pass=false
1914     #list: set fnord "$@" "$file"
1915     #list: shift
1916   fi
1917 done
1918
1919 #list: shift $n
1920
1921 #list: exec test $# = 0
1922 $pass
1923 exit