@@ -8,8 +8,11 @@ extern int optind;
8
8
#define __CPROVER_STRING_H_INCLUDED
9
9
#endif
10
10
11
- inline int getopt (int argc , char * const argv [],
12
- const char * optstring )
11
+ __CPROVER_bool __VERIFIER_nondet___CPROVER_bool ();
12
+ size_t __VERIFIER_nondet_size_t ();
13
+
14
+ inline int getopt (
15
+ int argc , char * const argv [], const char * optstring )
13
16
{
14
17
__CPROVER_HIDE :;
15
18
int result = -1 ;
@@ -20,25 +23,26 @@ inline int getopt(int argc, char * const argv[],
20
23
if (optind >=argc || argv [optind ][0 ]!= '-' )
21
24
return -1 ;
22
25
23
- size_t result_index ;
26
+ size_t result_index = __VERIFIER_nondet_size_t () ;
24
27
__CPROVER_assume (
25
28
result_index < strlen (optstring ) && optstring [result_index ]!= ':' );
26
29
#ifdef __CPROVER_STRING_ABSTRACTION
27
30
__CPROVER_assert (__CPROVER_is_zero_string (optstring ),
28
31
"getopt zero-termination of 3rd argument" );
29
32
#endif
30
33
31
- _Bool found ;
34
+ __CPROVER_bool found = __VERIFIER_nondet___CPROVER_bool () ;
32
35
if (found )
33
36
{
34
37
result = optstring [result_index ];
38
+ __CPROVER_bool skipped = __VERIFIER_nondet___CPROVER_bool ();
35
39
if (skipped )
36
40
++ optind ;
37
41
}
38
42
39
43
if (result != -1 && optind < argc && optstring [result_index + 1 ]== ':' )
40
44
{
41
- _Bool has_no_arg ;
45
+ __CPROVER_bool has_no_arg = __VERIFIER_nondet___CPROVER_bool () ;
42
46
if (has_no_arg )
43
47
{
44
48
optarg = argv [optind ];
@@ -53,10 +57,17 @@ inline int getopt(int argc, char * const argv[],
53
57
54
58
/* FUNCTION: getopt_long */
55
59
56
- int getopt (int argc , char * const argv [], const char * optstring );
60
+ #ifndef __CPROVER_GETOPT_H_INCLUDED
61
+ #include <getopt.h>
62
+ #define __CPROVER_GETOPT_H_INCLUDED
63
+ #endif
57
64
58
- inline int getopt_long (int argc , char * const argv [], const char * optstring ,
59
- const struct option * longopts , int * longindex )
65
+ inline int getopt_long (
66
+ int argc ,
67
+ char * const argv [],
68
+ const char * optstring ,
69
+ const struct option * longopts ,
70
+ int * longindex )
60
71
{
61
72
// trigger valid-pointer checks (if enabled), even though we don't
62
73
// use the parameter in this model
0 commit comments