Created
October 10, 2016 18:30
-
-
Save anonymous/e26fdadd4a88fbd3c27db74d09db5158 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Program GetLongOpts_Error; | |
{ program demonstrating misbehaving of GetLongOpts } | |
{$h+} | |
Uses getopts; | |
Var c : char; | |
OptionIndex : Longint; | |
TheOpts : array[1..2] Of TOption; | |
flag : char; | |
Begin | |
flag := #0; | |
With TheOpts[1] Do | |
Begin | |
name := 'option'; | |
has_arg := 0; | |
flag := @flag; | |
value := 'o'; | |
End; | |
With TheOpts[2] Do | |
Begin | |
name := ''; | |
has_arg := 0; | |
flag := Nil; | |
value := #0; | |
End; | |
c := #0; | |
WriteLn('Getting there'); | |
Repeat | |
c := GetLongOpts('o',@TheOpts[1],OptionIndex); | |
Case c Of | |
'o' : | |
Begin | |
flag := 'x'; | |
WriteLn( | |
'This will never be printed should we use long option. If you are here, it means short option was used, wasn''t it?' | |
); | |
break; | |
End; | |
End; | |
Until c=EndOfOptions; | |
If (flag <> #0) Then WriteLn('flag=',flag) | |
Else | |
WriteLn('flag=0'); | |
End. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment