File: get_discards

package info (click to toggle)
dahdi-linux 1%3A2.3.0.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 7,640 kB
  • ctags: 14,900
  • sloc: ansic: 107,100; perl: 1,371; sh: 785; makefile: 477
file content (51 lines) | stat: -rwxr-xr-x 1,373 bytes parent folder | download | duplicates (27)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/php

<?php
/*
 * Written by Jared Smith and Kevin P. Fleming
 *
 * Copyright (C) 2006, Jared Smith and Digium, Inc.
 *
 */

# create an array of all the different prefixes you want to match on,
# as Perl-compatible regular expressions
# (yes, this is a stupid example, as the second one is just a simplified
# version of the first, but it's just an example)
$prefixes = array('\.text\.Oct');

$fp = fopen('test.map','r');

while (!feof($fp))
{
        # Loop until we find the top of section we want
        while ($line = fgets($fp))
        {
                if (preg_match('/Discarded input sections/i',$line))
                {
                        break;
                }
        }

        # Now loop until we find the next section
        while ($line = fgets($fp))
        {
                if (preg_match('/Memory Configuration/i',$line))
                {
                        # we found it!
                        break;
                }
                foreach ($prefixes as $prefix)
                {
                        if (preg_match("/$prefix/i",$line))
                        {
				preg_match("/Oct.*/", $line, $matches);
                                $line2 = fgets($fp);
				echo "#define SKIP_".$matches[0]." 1\n";
                                break;
                        }
                }
        }
}
fclose($fp);
?>