Official patch to newgetopt.pl 1.9 
Author Message
 Official patch to newgetopt.pl 1.9

This patch brings newgetopt.pl 1.9 to version 1.10.

New features:

 - Options matching is now case insensitive.
   (This can be disabled if not desired.)

 - A lone dash can be used as an option (one with an 'empty' name).

*** newgetopt.pl~       Mon May  4 13:10:51 1992
--- newgetopt.pl        Mon May  4 13:09:56 1992
***************
*** 1,11 ****
  # newgetopt.pl -- new options parsing


  # Author          : Johan Vromans
  # Created On      : Tue Sep 11 15:00:12 1990
  # Last Modified By: Johan Vromans
! # Last Modified On: Thu Mar 26 14:36:31 1992
! # Update Count    : 57
  # Status          : Okay

  # This package implements a new getopt function. This function adheres
--- 1,11 ----
  # newgetopt.pl -- new options parsing


  # Author          : Johan Vromans
  # Created On      : Tue Sep 11 15:00:12 1990
  # Last Modified By: Johan Vromans
! # Last Modified On: Mon May  4 13:08:53 1992
! # Update Count    : 65
  # Status          : Okay

  # This package implements a new getopt function. This function adheres
***************
*** 51,56 ****
--- 51,60 ----
  #

  # HISTORY
+ # 4-May-1992          Johan Vromans  
+ #    Add $ignorecase to match options in either case.
+ #    Allow '' option.
+
  # 19-Mar-1992         Johan Vromans  
  #    Allow require from packages.
  #    NGetOpt is now defined in the package that requires it.
***************
*** 62,69 ****
  #    Correct the dreadful semicolon/require bug.

! { package newgetopt;
!   $debug = 0;                 # for debugging
  }

  sub NGetOpt {
--- 66,74 ----
  #    Correct the dreadful semicolon/require bug.

! {   package newgetopt;
!     $debug = 0;                       # for debugging
!     $ignorecase = 1;          # ignore case when matching options
  }

  sub NGetOpt {
***************
*** 80,86 ****
      local ($opt, $optx, $arg, $type, $mand, %opctl);
      local ($pkg) = (caller)[0];

!     print STDERR "NGetOpt 1.9 -- called from $pkg\n" if $debug;

      # See if the first element of the optionlist contains option
      # starter characters.
--- 85,91 ----
      local ($opt, $optx, $arg, $type, $mand, %opctl);
      local ($pkg) = (caller)[0];

!     print STDERR "NGetOpt 1.10 -- called from $pkg\n" if $debug;

      # See if the first element of the optionlist contains option
      # starter characters.
***************
*** 95,101 ****
      # Verify correctness of optionlist.
      %opctl = ();

!       if ( $opt !~ /^(\w+)([=:][infse])?$/ ) {
            print STDERR ("Error in option spec: \"", $opt, "\"\n");
            $error++;
            next;
--- 100,107 ----
      # Verify correctness of optionlist.
      %opctl = ();

!       $opt =~ tr/A-Z/a-z/ if $ignorecase;
!       if ( $opt !~ /^(\w*)([=:][infse])?$/ ) {
            print STDERR ("Error in option spec: \"", $opt, "\"\n");
            $error++;
            next;
***************
*** 105,110 ****
--- 111,125 ----

      return 0 if $error;

+     if ( $debug ) {
+       local ($arrow, $k, $v);
+       $arrow = "=> ";
+       while ( ($k,$v) = each(%opctl) ) {
+           print STDERR ($arrow, "\$opctl{\"$k\"} = \"$v\"\n");
+           $arrow = "   ";
+       }
+     }
+
      # Process argument list

      while ( $#ARGV >= 0 ) {
***************
*** 130,135 ****
--- 145,151 ----
        }

        # Look it up.
+       $opt =~ tr/A-Z/a-z/ if $ignorecase;
        unless  ( defined ( $type = $opctl{$opt} ) ) {
            print STDERR ("Unknown option: ", $opt, "\n");
            $error++;
--

Multihouse Automatisering bv                   uucp:..!{uunet,sun4nl}!mh.nl!jv
Doesburgweg 7, 2803 PL Gouda, The Netherlands  phone/fax: +31 1820 62911/62500
------------------------ "Arms are made for hugging" -------------------------



Fri, 21 Oct 1994 19:19:02 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. abbrev.pl + newgetopt.pl = NEAT!

2. Official patch for perload script

3. perl5.001 build (with 4 official unofficial patches applied)

4. Where's perl5.001 official unofficial patches?

5. Changes to NGetOpt in newgetopt.pl

6. Source: newgetopt.pl version 1.14

7. Abbreviation support for newgetopt.pl

8. any additional docs for newgetopt.pl?

9. newgetopt.pl

10. Newgetopt.pl, version 1.13.

11. bug in newgetopt.pl

12. newgetopt.pl by Johan Vromans version 1.13

 

 
Powered by phpBB® Forum Software