]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - Ada95/samples/ncurses2-getopt.adb
ncurses 5.7 - patch 20091226
[ncurses.git] / Ada95 / samples / ncurses2-getopt.adb
index 93f1713959cdef9f2fe875236e04cdf2bbf69bf3..238c43919eac908502fd2dfedba4389233e85d44 100644 (file)
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
+-- Copyright (c) 2000-2004,2008 Free Software Foundation, Inc.              --
 --                                                                          --
 -- Permission is hereby granted, free of charge, to any person obtaining a  --
 -- copy of this software and associated documentation files (the            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
 --  Version Control
---  $Revision: 1.2 $
+--  $Revision: 1.7 $
+--  $Date: 2008/07/26 18:46:44 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 --  A simplified version of the  GNU getopt function
@@ -47,10 +48,6 @@ with Ada.Text_IO; use Ada.Text_IO;
 
 package body ncurses2.getopt is
 
-   opterr : Character := Character'Val (1);
-   optopt : Character := '?';
-   initialized : Boolean := False;
-
    nextchar : Natural := 0;
 
    --  Ncurses doesn't use the non option elements so we are spared
@@ -106,13 +103,12 @@ package body ncurses2.getopt is
       --  Look at and handle the next short option-character.
       declare
          c : Character := argv (optind) (nextchar);
-         temp : Natural :=
+         temp : constant Natural :=
            Ada.Strings.Fixed.Index (optstring, String'(1 => c));
       begin
          if temp = 0 or c = ':' then
             Put_Line (Standard_Error,
                       argv (optind) & ": invalid option -- " & c);
-            optopt := c;
             c := '?';
             return;
          end if;
@@ -136,8 +132,7 @@ package body ncurses2.getopt is
                   Put_Line (Standard_Error,
                             argv (optind) &
                             ": option requires an argument -- " & c);
-                  optopt := c;
-                  if optstring (1) = ':'  then
+                  if optstring (optstring'First) = ':'  then
                      c := ':';
                   else
                      c := '?';