OSDN Git Service

* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Class_Wide_Type>: Fix
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-valllu.adb
index 5a1d46e..f59bf2f 100644 (file)
@@ -4,28 +4,25 @@
 --                                                                          --
 --                       S Y S T E M . V A L _ L L U                        --
 --                                                                          --
---                                 S p e c                                  --
+--                                 B o d y                                  --
 --                                                                          --
---                                                                          --
---          Copyright (C) 1992-1997 Free Software Foundation, Inc.          --
+--          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
--- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
--- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
--- for  more details.  You should have  received  a copy of the GNU General --
--- Public License  distributed with GNAT;  see file COPYING.  If not, write --
--- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
--- MA 02111-1307, USA.                                                      --
+-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
+--                                                                          --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception,   --
+-- version 3.1, as published by the Free Software Foundation.               --
 --                                                                          --
--- As a special exception,  if other files  instantiate  generics from this --
--- unit, or you link  this unit with other files  to produce an executable, --
--- this  unit  does not  by itself cause  the resulting  executable  to  be --
--- covered  by the  GNU  General  Public  License.  This exception does not --
--- however invalidate  any other reasons why  the executable file  might be --
--- covered by the  GNU Public License.                                      --
+-- You should have received a copy of the GNU General Public License and    --
+-- a copy of the GCC Runtime Library Exception along with this program;     --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
+-- <http://www.gnu.org/licenses/>.                                          --
 --                                                                          --
 -- GNAT was originally developed  by the GNAT team at  New York University. --
 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
@@ -37,15 +34,14 @@ with System.Val_Util;       use System.Val_Util;
 
 package body System.Val_LLU is
 
-   -----------------------------
-   -- Scan_Long_Long_Unsigned --
-   -----------------------------
+   ---------------------------------
+   -- Scan_Raw_Long_Long_Unsigned --
+   ---------------------------------
 
-   function Scan_Long_Long_Unsigned
-     (Str  : String;
-      Ptr  : access Integer;
-      Max  : Integer)
-      return Long_Long_Unsigned
+   function Scan_Raw_Long_Long_Unsigned
+     (Str : String;
+      Ptr : not null access Integer;
+      Max : Integer) return Long_Long_Unsigned
    is
       P : Integer;
       --  Local copy of the pointer
@@ -56,17 +52,9 @@ package body System.Val_LLU is
       Expon : Integer;
       --  Exponent value
 
-      Minus : Boolean := False;
-      --  Set to True if minus sign is present, otherwise to False. Note that
-      --  a minus sign is permissible for the singular case of -0, and in any
-      --  case the pointer is left pointing past a negative integer literal.
-
       Overflow : Boolean := False;
       --  Set True if overflow is detected at any point
 
-      Start : Positive;
-      --  Save location of first non-blank character
-
       Base_Char : Character;
       --  Base character (# or :) in based case
 
@@ -77,13 +65,6 @@ package body System.Val_LLU is
       --  Digit value
 
    begin
-      Scan_Sign (Str, Ptr, Max, Minus, Start);
-
-      if Str (Ptr.all) not in '0' .. '9' then
-         Ptr.all := Start;
-         raise Constraint_Error;
-      end if;
-
       P := Ptr.all;
       Uval := Character'Pos (Str (P)) - Character'Pos ('0');
       P := P + 1;
@@ -275,11 +256,34 @@ package body System.Val_LLU is
 
       --  Return result, dealing with sign and overflow
 
-      if Overflow or else (Minus and then Uval /= 0) then
+      if Overflow then
          raise Constraint_Error;
       else
          return Uval;
       end if;
+   end Scan_Raw_Long_Long_Unsigned;
+
+   -----------------------------
+   -- Scan_Long_Long_Unsigned --
+   -----------------------------
+
+   function Scan_Long_Long_Unsigned
+     (Str : String;
+      Ptr : not null access Integer;
+      Max : Integer) return Long_Long_Unsigned
+   is
+      Start : Positive;
+      --  Save location of first non-blank character
+
+   begin
+      Scan_Plus_Sign (Str, Ptr, Max, Start);
+
+      if Str (Ptr.all) not in '0' .. '9' then
+         Ptr.all := Start;
+         raise Constraint_Error;
+      end if;
+
+      return Scan_Raw_Long_Long_Unsigned (Str, Ptr, Max);
    end Scan_Long_Long_Unsigned;
 
    ------------------------------
@@ -287,17 +291,14 @@ package body System.Val_LLU is
    ------------------------------
 
    function Value_Long_Long_Unsigned
-     (Str : String)
-     return Long_Long_Unsigned
+     (Str : String) return Long_Long_Unsigned
    is
       V : Long_Long_Unsigned;
       P : aliased Integer := Str'First;
-
    begin
       V := Scan_Long_Long_Unsigned (Str, P'Access, Str'Last);
       Scan_Trailing_Blanks (Str, P);
       return V;
-
    end Value_Long_Long_Unsigned;
 
 end System.Val_LLU;