main
|
Last change
on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago |
|
Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Rev | Line | |
|---|
| [6027313] | 1 | /* fileOpen: an example for covering CIVL code. The example may not be
|
|---|
| 2 | understandable for human beings. The main purpose is testing
|
|---|
| 3 | different forms of char array or pointer to char as an argument of
|
|---|
| 4 | a function expecting the "char *" type. */
|
|---|
| [ed451d9] | 5 |
|
|---|
| [6027313] | 6 | #include<civlc.cvh>
|
|---|
| 7 | #include<stdio.h>
|
|---|
| 8 | #include<civl-stdio.cvh>
|
|---|
| 9 |
|
|---|
| 10 | $input int x;
|
|---|
| 11 | $input int y;
|
|---|
| 12 | $input char ncaFilename[y];
|
|---|
| 13 | $input char icaFilename[];
|
|---|
| 14 | $assume(x < 10);
|
|---|
| 15 | $assume(y > 10);
|
|---|
| 16 | void main(){
|
|---|
| 17 | char filename[10] = "dummyfile";
|
|---|
| 18 | char c = 'c';
|
|---|
| 19 | FILE *file0 = fopen(&filename[4], "r");
|
|---|
| 20 | int a[5];
|
|---|
| 21 | int count = fscanf(file0, "%d", a);
|
|---|
| [abd3108] | 22 | int fooLength = $text_file_length("foo");
|
|---|
| [6027313] | 23 |
|
|---|
| 24 | #ifdef NCINDEX //non-concrete index
|
|---|
| 25 | FILE *file1 = fopen(&filename[x], "r");
|
|---|
| 26 | #elif defined NCARRAY //array with non-concrete extent
|
|---|
| 27 | FILE *file1 = fopen(&ncaFilename[2], "r");
|
|---|
| 28 | #elif defined NEGINDEX //negative index
|
|---|
| 29 | FILE *file1 = fopen((&filename[-1]), "r");
|
|---|
| 30 | #elif defined SCHAR //single char
|
|---|
| 31 | FILE *file1 = fopen(&c, "r");
|
|---|
| 32 | #else //incomplete array
|
|---|
| 33 | FILE *file1 = fopen(&icaFilename[2], "r");
|
|---|
| 34 | #endif
|
|---|
| 35 | $free(file0);
|
|---|
| 36 | $free(file1);
|
|---|
| 37 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.