Repository: Konstantin8105/c4go
Pull request #422 (2019-04-23 13:10:33)

stdio.c: vfprintf: add test

codecov[bot]: # [Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/422?src=pr&el=h1) Report
> Merging [#422](https://codecov.io/gh/Konstantin8105/c4go/pull/422?src=pr&el=desc) into [master](https://codecov.io/gh/Konstantin8105/c4go/commit/d8d6cc707218a097829eea294057c4da0cc37ca9?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/Konstantin8105/c4go/pull/422/graphs/tree.svg?width=650&token=esH2rHXlZ2&height=150&src=pr)](https://codecov.io/gh/Konstantin8105/c4go/pull/422?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #422      +/-   ##
==========================================
+ Coverage   85.02%   85.03%   +<.01%     
==========================================
  Files         191      191              
  Lines       11583    11589       +6     
==========================================
+ Hits         9849     9855       +6     
  Misses       1254     1254              
  Partials      480      480
```


| [Impacted Files](https://codecov.io/gh/Konstantin8105/c4go/pull/422?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [program/definition\_function.go](https://codecov.io/gh/Konstantin8105/c4go/pull/422/diff?src=pr&el=tree#diff-cHJvZ3JhbS9kZWZpbml0aW9uX2Z1bmN0aW9uLmdv) | `89.21% <ø> (ø)` | :arrow_up: |
| [noarch/stdio.go](https://codecov.io/gh/Konstantin8105/c4go/pull/422/diff?src=pr&el=tree#diff-bm9hcmNoL3N0ZGlvLmdv) | `80.13% <100%> (+0.4%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/422?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/422?src=pr&el=footer). Last update [d8d6cc7...0a7fcb8](https://codecov.io/gh/Konstantin8105/c4go/pull/422?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/noarch/stdio.go b/noarch/stdio.go
index 3e6bade..b2473c9 100644
--- a/noarch/stdio.go
+++ b/noarch/stdio.go
@@ -763,6 +763,14 @@ func Vprintf(format []byte, varList ...interface{}) int32 {
 	return n
 }
 
+func Vfprintf(f *File, format []byte, varList ...interface{}) int32 {
+	buffer := make([]byte, 1000)
+	n := Vsprintf(buffer, format, varList...)
+	buf := CStringToString(buffer)
+	fmt.Fprintf(f.OsFile, "%s", buf)
+	return n
+}
+
 // Snprintf handles snprintf().
 //
 // Writes the C string pointed by format to the standard output (stdout). If
diff --git a/program/definition_function.go b/program/definition_function.go
index b7cad9a..193467b 100644
--- a/program/definition_function.go
+++ b/program/definition_function.go
@@ -246,6 +246,7 @@ var builtInFunctionDefinitions = map[string][]string{
 		"int snprintf(char*, int, const char *, ...) -> noarch.Snprintf",
 		"int vsprintf(char*, const char *, ...) -> noarch.Vsprintf",
 		"int vprintf(const char *, ...) -> noarch.Vprintf",
+		"int vfprintf(FILE *, const char *, ...) -> noarch.Vfprintf",
 		"int vsnprintf(char*, int, const char *, ...) -> noarch.Vsnprintf",
 		"void perror( const char *) -> noarch.Perror",
 		"ssize_t getline(char **, size_t *, FILE *) -> noarch.Getline",
diff --git a/scripts/scripts.txt b/scripts/scripts.txt
index 097bb96..45db9fa 100644
--- a/scripts/scripts.txt
+++ b/scripts/scripts.txt
@@ -6,8 +6,8 @@ Calculate warnings : ./testdata/9wm
 
 Calculate warnings : ./testdata/ed
 		After transpiling : 0 warnings.
-		Go build : 8 warnings
-		Unsafe   : 170
+		Go build : 7 warnings
+		Unsafe   : 168
 
 Calculate warnings in file: ./testdata/kilo/kilo.go
 		After transpiling : 0 warnings.
@@ -36,8 +36,8 @@ Calculate warnings in file: ./testdata/neatmail/neatmail.go
 
 Calculate warnings in file: ./testdata/neatpost/neatpost.go
 		After transpiling : 0 warnings.
-		Go build : 32 warnings
-		Unsafe   : 47
+		Go build : 15 warnings
+		Unsafe   : 45
 
 Calculate warnings in file: ./testdata/neatrefer/neatrefer.go
 		After transpiling : 0 warnings.
@@ -46,8 +46,8 @@ Calculate warnings in file: ./testdata/neatrefer/neatrefer.go
 
 Calculate warnings in file: ./testdata/neatroff/neatroff.go
 		After transpiling : 3 warnings.
-		Go build : 17 warnings
-		Unsafe   : 252
+		Go build : 8 warnings
+		Unsafe   : 251
 
 Calculate warnings in file: ./testdata/neatvi/neatvi.go
 		After transpiling : 0 warnings.


Test patch:
diff --git a/tests/stdio.c b/tests/stdio.c
index d5983ad..d90ac38 100644
--- a/tests/stdio.c
+++ b/tests/stdio.c
@@ -614,12 +614,30 @@ void WriteFormatted ( const char * format, ... )
   va_end (args);
 }
 
-void test_vfprintf()
+void test_vprintf()
 {
    WriteFormatted ("Call with %d variable argument.\n",1);
    WriteFormatted ("Call with %d variable %s.\n",2,"arguments");
 }
 
+
+void FWriteFormatted (FILE * stream, const char * format, ...)
+{
+  va_list args;
+  va_start (args, format);
+  vfprintf (stream, format, args);
+  va_end (args);
+}
+
+void test_vfprintf()
+{
+   FILE * pFile;
+   pFile = fopen ("./testdata/vfprintf.txt","w");
+   FWriteFormatted (pFile,"Call with %d variable argument.\n",1);
+   FWriteFormatted (pFile,"Call with %d variable %s.\n",2,"arguments");
+   fclose (pFile);
+}
+
 int main()
 {
     plan(71);
@@ -659,6 +677,7 @@ int main()
     START_TEST(getline)
     START_TEST(sscanf)
     START_TEST(FILE)
+    START_TEST(vprintf)
     START_TEST(vfprintf)
 
     // that test must be last test