summaryrefslogtreecommitdiff
path: root/fixpaths
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-01-20 23:13:36 +1100
committerDamien Miller <djm@mindrot.org>2000-01-20 23:13:36 +1100
commit886c63a2c533e8ce8818580920232e4903a27da7 (patch)
treefe165f9c88b10cdef0b09873c14f118d127ce64e /fixpaths
parent88b86e40d65b3cf1238ad9eee67555a2acae61a8 (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-xfixpaths14
1 files changed, 9 insertions, 5 deletions
diff --git a/fixpaths b/fixpaths
index 8a6740649..e6f47c713 100755
--- a/fixpaths
+++ b/fixpaths
@@ -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
8if (!defined(@ARGV)) { die ("$usage"); } 10if (!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
11while ($_=$ARGV[0], /^-/) { 13while ($_=$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)) {
29for $f (@ARGV) { 33for $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>