diff options
author | Damien Miller <djm@mindrot.org> | 2000-01-20 23:13:36 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2000-01-20 23:13:36 +1100 |
commit | 886c63a2c533e8ce8818580920232e4903a27da7 (patch) | |
tree | fe165f9c88b10cdef0b09873c14f118d127ce64e /fixpaths | |
parent | 88b86e40d65b3cf1238ad9eee67555a2acae61a8 (diff) |
- Big manpage and config file cleanup from Andre Lucas
<andre.lucas@dial.pipex.com>
- Re-added latest (unmodified) OpenBSD manpages
Diffstat (limited to 'fixpaths')
-rwxr-xr-x | fixpaths | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -3,22 +3,26 @@ | |||
3 | # fixpaths - substitute makefile variables into text files | 3 | # fixpaths - substitute makefile variables into text files |
4 | 4 | ||
5 | 5 | ||
6 | $usage = "Usage: $0 [-D<variable>=<value>] [[infile] ...]\n"; | 6 | $usage = "Usage: $0 [-x<file dot-suffix>] [-Dstring=replacement] [[infile] ...]\n"; |
7 | |||
8 | $ext="out"; | ||
7 | 9 | ||
8 | if (!defined(@ARGV)) { die ("$usage"); } | 10 | if (!defined(@ARGV)) { die ("$usage"); } |
9 | 11 | ||
10 | # read in the command line and get some definitions | 12 | # read in the command line and get some definitions |
11 | while ($_=$ARGV[0], /^-/) { | 13 | while ($_=$ARGV[0], /^-/) { |
12 | if (/^-D/) { | 14 | if (/^-[Dx]/) { |
13 | # definition | 15 | # definition |
14 | shift(@ARGV); | 16 | shift(@ARGV); |
15 | if ( /-D(.*)=(.*)/ ) { | 17 | if ( /-D(.*)=(.*)/ ) { |
16 | $def{"$1"}=$2; | 18 | $def{"$1"}=$2; |
19 | } elsif ( /-x\s*(\w+)/ ) { | ||
20 | $ext=$1; | ||
17 | } else { | 21 | } else { |
18 | die ("$usage$0: error in command line arguments.\n"); | 22 | die ("$usage$0: error in command line arguments.\n"); |
19 | } | 23 | } |
20 | } else { | 24 | } else { |
21 | &usage; die ("$usage$0: unknown option '-".$ARGV[0][1]."'\n"); | 25 | die ("$usage$0: unknown option '-".$ARGV[0][1]."'\n"); |
22 | } | 26 | } |
23 | } # while parsing arguments | 27 | } # while parsing arguments |
24 | 28 | ||
@@ -29,13 +33,13 @@ if (!defined(%def)) { | |||
29 | for $f (@ARGV) { | 33 | for $f (@ARGV) { |
30 | 34 | ||
31 | $f =~ /(.*\/)*(.*)$/; | 35 | $f =~ /(.*\/)*(.*)$/; |
32 | $of = $2; $of =~ s/.in$//; | 36 | $of = $2.".$ext"; |
33 | 37 | ||
34 | open(IN, "<$f") || die ("$0: input file $f missing!\n"); | 38 | open(IN, "<$f") || die ("$0: input file $f missing!\n"); |
35 | if (open(OUT, ">$of")) { | 39 | if (open(OUT, ">$of")) { |
36 | while (<IN>) { | 40 | while (<IN>) { |
37 | for $s (keys(%def)) { | 41 | for $s (keys(%def)) { |
38 | s#\@$s\@#$def{$s}#; | 42 | s#$s#$def{$s}#; |
39 | } # for $s | 43 | } # for $s |
40 | print OUT; | 44 | print OUT; |
41 | } # while <IN> | 45 | } # while <IN> |