Hi!

I found that getlongopts from the getopts unit does not work properly on Mac OS 
X / PowerPC. The Longind : Longint returned is not valid.

The problem is a cast to a pinteger of a pointer that is in fact a plongint, 
which seems to break on powerpc, and possibly on other platforms or 
architectures as well. The attached patch fixes this :)

Note that the getopts unit does not have mode OBJFPC set, nor ANSISTRINGS (well 
at least not in the unit's source). This limits the use of getopts to options 
of 255 bytes. getopts also resides in rtl/inc/, so this is no big surprise. Is 
it possible to move the unit to OBJFPC, such that it supports ansistrings?

Regards,

Bram
Index: getopts.pp
===================================================================
--- getopts.pp  (revision 3421)
+++ getopts.pp  (working copy)
@@ -214,8 +214,6 @@
 
 Function Internal_getopt (Var Optstring : string;LongOpts : POption;
                           LongInd : pointer;Long_only : boolean ) : char;
-type
-  pinteger=^integer;
 var
   temp,endopt,
   option_index : byte;
@@ -392,7 +390,7 @@
            end; { argument in next parameter end;}
           nextchar:=0;
           if longind<>nil then
-           pinteger(longind)^:=indfound+1;
+           plongint(longind)^:=indfound+1;
           if pfound^.flag<>nil then
            begin
              pfound^.flag^:=pfound^.value;
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to