-- B O D Y --
-- --
------------------------------------------------------------------------------
--- Copyright (c) 2000,2004 Free Software Foundation, Inc. --
+-- Copyright (c) 2000-2008,2011 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 --
------------------------------------------------------------------------------
-- Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
-- Version Control
--- $Revision: 1.3 $
+-- $Revision: 1.8 $
+-- $Date: 2011/03/19 12:09:51 $
-- Binding Version 01.00
------------------------------------------------------------------------------
-- A simplified version of the GNU getopt function
package body ncurses2.getopt is
- optopt : Character := '?';
-
nextchar : Natural := 0;
-- Ncurses doesn't use the non option elements so we are spared
-- also the user is not allowed to modify argv or argc
-- Doing so is Erroneous execution.
- -- longoptions are not handled.
+ -- long options are not handled.
procedure Qgetopt (retval : out Integer;
argc : Integer;
-- ignored for ncurses, must be initialized to 1 by
-- the caller
Optarg : out stringa
- -- a garbage colector would be useful here.
+ -- a garbage collector would be useful here.
) is
package BS is new Ada.Strings.Bounded.Generic_Bounded_Length (200);
-- 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;
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 := '?';