From owner-cvs-all Wed Feb 14 6:29:10 2001 Delivered-To: cvs-all@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id 5CFCE37B4EC; Wed, 14 Feb 2001 06:28:41 -0800 (PST) Received: (from des@localhost) by flood.ping.uio.no (8.9.3/8.9.3) id PAA00535; Wed, 14 Feb 2001 15:28:21 +0100 (CET) (envelope-from des@ofug.org) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: Nick Hibma Cc: Dirk Froemberg , , Subject: Re: cvs commit: src/sys/kern makeops.pl References: From: Dag-Erling Smorgrav Date: 14 Feb 2001 15:28:20 +0100 In-Reply-To: Nick Hibma's message of "Wed, 14 Feb 2001 14:17:15 +0000 (GMT)" Message-ID: Lines: 15 User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.4 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --=-=-= Nick Hibma writes: > I must have missed the patch Dag-Erling ... Could you send it again? Sure, I just didn't want to send in an untested patch. Note that the patch is for makeobjops.pl, since -CURRENT doesn't have makeops.pl. I'm not entirely satisfied with it from a stylistic point of view, but the rest of code is so butt ugly that I chose not to care. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=makeobjops.diff Content-Description: patch Index: makeobjops.pl =================================================================== RCS file: /home/ncvs/src/sys/kern/makeobjops.pl,v retrieving revision 1.2 diff -u -r1.2 makeobjops.pl --- makeobjops.pl 2001/01/04 13:41:24 1.2 +++ makeobjops.pl 2001/02/14 14:13:36 @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w # # Copyright (c) 1992, 1993 # The Regents of the University of California. All rights reserved. @@ -38,55 +38,35 @@ # # $FreeBSD: src/sys/kern/makeobjops.pl,v 1.2 2001/01/04 13:41:24 n_hibma Exp $ +use strict; +use Getopt::Std; + # # Script to produce kobj front-end sugar. # -$debug = 0; -$cfile = 0; # by default do not produce any file type -$hfile = 0; - -$keepcurrentdir = 1; - $line_width = 80; # Process the command line # +getopts('cdhl:p') + or die("blah"); while ($arg = shift @ARGV) { - if ($arg eq '-c') { - warn "Producing .c output files" - if $debug; - $cfile = 1; - } elsif ($arg eq '-h') { - warn "Producing .h output files" - if $debug; - $hfile = 1; - } elsif ($arg eq '-ch' || $arg eq '-hc') { - warn "Producing .c and .h output files" - if $debug; - $cfile = 1; - $hfile = 1; - } elsif ($arg eq '-d') { - $debug = 1; - } elsif ($arg eq '-p') { - warn "Will produce files in original not in current directory" - if $debug; - $keepcurrentdir = 0; - } elsif ($arg eq '-l') { - if ($line_width = shift @ARGV and $line_width > 0) { - warn "Line width set to $line_width" - if $debug; - } else { - die "Please specify a valid line width after -l"; - } - } elsif ($arg =~ m/\.m$/) { - warn "Filename: $arg" - if $debug; - push @filenames, $arg; - } else { - warn "$arg ignored" - if $debug; - } +warn "Will produce files in original not in current directory" + if $debug && $opt_p; +if (defined($opt_l)) { + die("invalid line width\n") + unless ($opt_l =~ m/^\d*$/ && $opt_l > 0); + $line_width = $opt_l; + warn "Line width set to $line_width" + if $opt_d; +} +foreach $arg (@ARGV) { + die("invalid input file name\n") + unless ($arg =~ m/\.m$/); + warn "Filename: $arg" + if $opt_d; + push @filenames, $arg; } @@ -99,7 +79,7 @@ -l set line width for output files [80] -d switch on debugging " - unless ($cfile or $hfile) + unless ($opt_c or $opt_h) and $#filenames != -1; # FIXME should be able to do this more easily @@ -125,21 +105,21 @@ ($name, $path, $suffix) = &fileparse($src, '.m'); $path = '.' - if $keepcurrentdir; + unless $opt_p; $cfilename="$path/$name.c"; $hfilename="$path/$name.h"; warn "Processing from $src to $cfilename / $hfilename via $ctmpname / $htmpname" - if $debug; + if $opt_d; die "Could not open $src, $!" if !open SRC, "$src"; die "Could not open $ctmpname, $!" - if $cfile and !open CFILE, ">$ctmpname"; + if $opt_c and !open CFILE, ">$ctmpname"; die "Could not open $htmpname, $!" - if $hfile and !open HFILE, ">$htmpname"; + if $opt_h and !open HFILE, ">$htmpname"; - if ($cfile) { + if ($opt_c) { # Produce the header of the C file # print CFILE "/*\n"; @@ -160,7 +140,7 @@ print CFILE "#include \n"; } - if ($hfile) { + if ($opt_h) { # Produce the header of the H file # print HFILE "/*\n"; @@ -190,9 +170,9 @@ # if ($line =~ m/^#\s*include\s+(["<])([^">]+)([">]).*/i) { warn "Included file: $1$2" . ($1 eq '<'? '>':'"') - if $debug; + if $opt_d; print CFILE "#include $1$2" . ($1 eq '<'? '>':'"') . "\n" - if $cfile; + if $opt_c; } $line =~ s/#.*//; # remove comments @@ -206,7 +186,7 @@ $semicolon = $2; unless ($intname =~ m/^[a-z_][a-z0-9_]*$/) { warn $line - if $debug; + if $opt_d; warn "$src:$lineno: Invalid interface name '$intname', use [a-z_][a-z0-9_]*"; $error = 1; last LINE; @@ -216,14 +196,14 @@ if $semicolon !~ s/;$//; warn "Interface $intname" - if $debug; + if $opt_d; print HFILE '#ifndef _'.$intname."_if_h_\n" - if $hfile; + if $opt_h; print HFILE '#define _'.$intname."_if_h_\n\n" - if $hfile; + if $opt_h; print CFILE '#include "'.$intname.'_if.h"'."\n\n" - if $cfile; + if $opt_c; } elsif ($line =~ m/^CODE\s*{$/i) { $code = ""; $line = ; @@ -236,7 +216,7 @@ $lineno++ } print CFILE "\n".$code."\n" - if $cfile; + if $opt_c; } elsif ($line =~ m/^HEADER\s*{$/i) { $header = ""; $line = ; @@ -249,7 +229,7 @@ $lineno++ } print HFILE $header - if $hfile; + if $opt_h; } elsif ($line =~ m/^(STATIC|)METHOD/i) { # Get the return type function name and delete that from # the line. What is left is the possibly first function argument @@ -267,11 +247,11 @@ $ret = join(" ", @ret); # return type warn "Method: name=$name return type=$ret" - if $debug; + if $opt_d; if (!$name or !$ret) { warn $line - if $debug; + if $opt_d; warn "$src:$lineno: Invalid method specification"; $error = 1; last LINE; @@ -279,7 +259,7 @@ unless ($name =~ m/^[a-z_][a-z_0-9]*$/) { warn $line - if $debug; + if $opt_d; warn "$src:$lineno: Invalid method name '$name', use [a-z_][a-z0-9_]*"; $error = 1; last LINE; @@ -310,7 +290,7 @@ $default = $1; } else { warn "$src:$lineno: Ignored '$1'" # warn about garbage at end of line - if $debug and $1; + if $opt_d and $1; } # Create a list of variables without the types prepended @@ -337,7 +317,7 @@ warn 'Arguments: ' . join(', ', @arguments) . "\n" . 'Varnames: ' . join(', ', @varnames) - if $debug; + if $opt_d; $mname = $intname.'_'.$name; # method name $umname = uc($mname); # uppercase method name @@ -349,7 +329,7 @@ $default = "0" if $default eq ""; push @defaultmethods, $default; - if ($hfile) { + if ($opt_h) { # the method description print HFILE "extern struct kobjop_desc $mname\_desc;\n"; # the method typedef @@ -360,14 +340,14 @@ . "\n"; } - if ($cfile) { + if ($opt_c) { # Print out the method desc print CFILE "struct kobjop_desc $mname\_desc = {\n"; print CFILE "\t0, (kobjop_t) $default\n"; print CFILE "};\n\n"; } - if ($hfile) { + if ($opt_h) { # Print out the method itself if (0) { # haven't chosen the format yet print HFILE "static __inline $ret $umname($varnames)\n"; @@ -394,7 +374,7 @@ } } else { warn $line - if $debug; + if $opt_d; warn "$src:$lineno: Invalid line encountered"; $error = 1; last LINE; @@ -404,21 +384,21 @@ # print the final '#endif' in the header file # print HFILE "#endif /* _".$intname."_if_h_ */\n" - if $hfile; + if $opt_h; close SRC; close CFILE - if $cfile; + if $opt_c; close HFILE - if $hfile; + if $opt_h; if (!$error) { - if ($cfile) { + if ($opt_c) { ($rc = system("mv $ctmpname $cfilename")) and warn "mv $ctmpname $cfilename failed, $rc"; } - if ($hfile) { + if ($opt_h) { ($rc = system("mv $htmpname $hfilename")) and warn "mv $htmpname $hfilename failed, $rc"; } --=-=-= DES -- Dag-Erling Smorgrav - des@ofug.org --=-=-=-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message