source: rtems/tools/update/word-replace.in @ 11cfb6f7

4.104.114.84.95
Last change on this file since 11cfb6f7 was 11cfb6f7, checked in by Joel Sherrill <joel.sherrill@…>, on 10/14/98 at 20:19:30

Patch from Ralf Corsepius <corsepiu@…>:

  1. Rtems contains some perl scripts that use hard-coded paths to /usr/bin/perl or /usr/local/bin/perl I have already fixed these problems by adding some checks to configure.in. While doing this, I also cleaned up some more autoconf related problems for generating shell scripts. This patch might seem a bit scary to you, but I am quite confident it won't break something (I've been testing it for almost a week now, however it might introduce typos for a limited number configurations I don't have access to - But it shouldn't be a problem for you to test them :-).

I expect to get this finished tonight, hence you will very likely
have the patch when you get up tomorrow.

Changes:

  • Check for PERL and disable all PERL scripts if perl wasn't found.
  • Generate all KSHELL-scripts with autoconf instead of make-script
  • Automatic dependency handling for autoconf generated KSHELL or PERL scripts (make/rtems.cfg)

Notes:

  • this patch contains new files and deletes some other files.
  • The patch is relative to rtems-4.0.0-beta4 with my previous rtems-rc-981014-1.diff patch applied.

Testing:

I tested it with sh-rtems and posix under linux. Now all targets
which are touched by this patch and which are not used while building
for sh-rtems and posix still need to be tested. AFAIS, only the
sparc/erc32 BSP should be affected by this criterion. And if you
like to, you should also consider testing it on a Cygwin32 and a
Solaris host for one arbitrary BSP.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1#!@PERL@
2#
3#  $Id$
4#
5
6eval "exec @PERL@ -S $0 $*"
7    if $running_under_some_shell;
8
9require 'getopts.pl';
10&Getopts("p:vh");               # help, pattern file, verbose,
11
12if ($opt_h || ! $opt_p) {
13    print STDERR <<NO_MORE_HELP;
14word-replace
15
16   Replace *words* with patterns.   Pattern file specifies which patterns
17   to replace on each line.  All patterns are wrapped with perl \\b regexp
18   specifiers.
19
20Usage: $0       [-v] -p pattern-file files to replace
21
22    -v          -- possibly more verbose
23    -p file     -- pattern file
24    -h          -- help
25
26    anything else == this help message
27
28Pattern file looks like this:
29
30# Example:
31# ignores all lines with beginning with # or not exactly 2 fields
32_Dorky_Name  rtems_dorky_name           # comments, and blank lines are cool
33_Dorky_Name2 rtems_dorky_name2          # comments, and blank lines are cool
34NO_MORE_HELP
35    exit 0;
36}
37
38$verbose = $opt_v;
39$pattern_file = $opt_p;
40
41# make standard outputs unbuffered (so the '.'s come out ok)
42$oldfh = select(STDERR); $| = 1; select($oldfh);
43$oldfh = select(STDOUT); $| = 1; select($oldfh);
44
45# pull in the patterns
46open(PATTERNS, "<$pattern_file") ||
47    die "could not open $pattern_file: $!, crapped out at";
48
49foreach (<PATTERNS>)
50{
51    chop;
52    s/#.*//;
53    next if /^$/;
54    ($orig, $new, $junk, @rest) = split;
55    next if ( ! $orig || ! $new || $junk); # <2 or >2 patterns
56    die "pattern appears 2x: '$orig' in '$pattern_file'--" if defined($patterns{$orig});
57    $patterns{$orig} = $new;
58}
59close PATTERNS;
60
61# walk thru each line in each file
62foreach $file (@ARGV)
63{
64    print "$file\t";
65
66    open (INFILE, "<$file") ||
67        die "could not open input file $file: $!";
68
69    $outfile = $file . ".fixed";;
70    open (OUTFILE, ">$outfile") ||
71        die "could not open output file $outfile: $!";
72
73    while (<INFILE>)
74    {
75        study;                  # maybe make s/// faster
76        foreach $key (keys %patterns)
77        {
78            if ( s/\b$key\b/$patterns{$key}/ge )
79            {
80                print ".";
81            }
82        }
83        print OUTFILE $_;
84    }
85    print "\n";
86    close INFILE;
87    close OUTFILE;
88}
89
Note: See TracBrowser for help on using the repository browser.