#397 closed enhancement (fixed)
Please add --outfile argument to parseErrorCodes.pl
| Reported by: | Owned by: | ||
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | sys | Version: | 0.5.0 |
| Severity: | minor | Keywords: | |
| Cc: |
Description
When generating input files to be registered with psError, it is useful not to have
parseErrorCodes.pl modify the file in place (e.g. it doesn't confuse cvs; the machine
generated code should not be checked in).
Here's a patch that achieves this.
Index: src/parseErrorCodes.pl
===============================================================
====
RCS file: /usr/local/cvs/repositories/pan-starrs/datasys/IPP/psLib/src/parseErrorCodes.pl,v
retrieving revision 1.3
diff -a -c -w -r1.3 parseErrorCodes.pl
* src/parseErrorCodes.pl 3 Feb 2005 00:54:10 -0000 1.3
--- src/parseErrorCodes.pl 6 May 2005 17:56:45 -0000
*
* 11,26
# Assign variables based on the presence of command line options to the script
GetOptions(
"data=s" => \$data,
"verbose" => \$verbose,
"help" => \$help
! );
if ($help) {
! print "Usage: parseErrorCodes ", "[--data=$data] ", "[--help] ",
! "[--verbose] filename [filename ...]\n\n";
exit(0);
}
print "Using data file '$data'\n" if $verbose;
unless ( open( DATAFILE, "<", $data ) ) {
die "Can not open data file $data.";
--- 11,33 ----
# Assign variables based on the presence of command line options to the script
GetOptions(
"data=s" => \$data,
+ "outfile=s" => \$outputfile,
"verbose" => \$verbose,
"help" => \$help
! ) or exit(1);
if ($help) {
! print "Usage: parseErrorCodes ", "[--data=$data] ", "[--outfile=$file] ", "[--help] ",
! "[--verbose] [filename [filename ...]]\n\n";
exit(0);
}
+ if(defined($outputfile)) {
+ if (@ARGV > 1) {
+ die "You may only specify one input filename if you use --outfile\n";
+ }
+ }
+
print "Using data file '$data'\n" if $verbose;
unless ( open( DATAFILE, "<", $data ) ) {
die "Can not open data file $data.";
*
* 84,91
close(INFILE);
die "Failed to overwrite input file"
! if !open( OUTFILE, ">", $filename );
foreach (@result) {
print OUTFILE "$_\n";
--- 91,103 ----
close(INFILE);
+ if (defined($outputfile)) {
+ $ofile = $outputfile;
+ } else {
+ $ofile = $filename;
+ }
die "Failed to overwrite input file"
! if !open( OUTFILE, ">", $ofile );
foreach (@result) {
print OUTFILE "$_\n";
Change History (4)
comment:1 by , 21 years ago
| Status: | new → assigned |
|---|
comment:2 by , 21 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
I modified the script to mimick autoconf/automake style behavior, in that it looks for the input
template with an '.in' suffix on it. This effective does what you want, in that the file is not modified in-
place.
-rdd

yeah, that should be fixed to be CVS friendly. I need to modify some makefiles
as well, I assume.