From c1f016be08c5a82a797e612d7297dda8dc015a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Gouget?= Date: Wed, 10 Jan 2001 22:43:21 +0000 Subject: [PATCH] Require that the user specify a work directory. This provides a safeguard against accidental invocations. --- tools/winemaker | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/tools/winemaker b/tools/winemaker index bb50dd8bc9b..8b9eb720ac9 100755 --- a/tools/winemaker +++ b/tools/winemaker @@ -3,7 +3,7 @@ # Copyright 2000 Francois Gouget for CodeWeavers # fgouget@codeweavers.com # -my $version="0.5.3"; +my $version="0.5.4"; use Cwd; use File::Basename; @@ -49,6 +49,10 @@ my $OPT_ASK_SKIP=-1; # General options +## +# This is the directory in which winemaker will operate. +my $opt_work_dir; + ## # Make a backup of the files my $opt_backup; @@ -1872,6 +1876,9 @@ sub generate_global_files } } } + if (!defined $a_source_file) { + $a_source_file="Makefile.in"; + } generate_configure("configure.in",$a_source_file); unlink("configure"); @@ -1944,6 +1951,7 @@ $opt_backup=1; $opt_lower=$OPT_LOWER_UPPERCASE; $opt_lower_include=1; +# $opt_work_dir= # $opt_single_target= $opt_target_type=$TT_GUIEXE; $opt_flags=0; @@ -2027,10 +2035,17 @@ while (@ARGV>0) { # Catch errors } else { if ($arg ne "--help" and $arg ne "-h" and $arg ne "-?") { - print STDERR "Unknown option: $arg\n"; + if (!defined $opt_work_dir) { + $opt_work_dir=$arg; + } else { + print STDERR "error: the work directory, \"$arg\", has already been specified (was \"$opt_work_dir\")\n"; + $usage=1; + last; + } + } else { + $usage=1; + last; } - $usage=1; - last; } } @@ -2039,6 +2054,15 @@ if ($opt_no_banner == 0 or defined $usage) { print "Copyright 2000 Francois Gouget for CodeWeavers\n"; } +if (!defined $opt_work_dir) { + print STDERR "error: you must specify the directory containing the sources to be converted\n"; + $usage=1; +} elsif (!chdir $opt_work_dir) { + print STDERR "error: could not chdir to the work directory\n"; + print STDERR " $!\n"; + $usage=1; +} + if (defined $usage) { print STDERR "Usage: winemaker [--nobanner] [--backup|--nobackup]\n"; print STDERR " [--lower-none|--lower-all|--lower-uppercase]\n"; @@ -2048,6 +2072,7 @@ if (defined $usage) { print STDERR " [-Dmacro[=defn]] [-Idir] [-Ldir] [-idll] [-llibrary]\n"; print STDERR " [--interactive] [--single-target name]\n"; print STDERR " [--generated-files|--nogenerated-files]\n"; + print STDERR " work_directory\n"; exit (2); }