Repository: Konstantin8105/c4go
Pull request #493 (2021-04-21 13:59:15)

noarch: string

codecov[bot]: # [Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/493?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Konstantin) Report
> Merging [#493](https://codecov.io/gh/Konstantin8105/c4go/pull/493?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Konstantin) (168165d) into [master](https://codecov.io/gh/Konstantin8105/c4go/commit/94cefd20c442b330878781ea6f5e12ecf5b5d63c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Konstantin) (94cefd2) will **decrease** coverage by `0.00%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/Konstantin8105/c4go/pull/493/graphs/tree.svg?width=650&height=150&src=pr&token=esH2rHXlZ2&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Konstantin)](https://codecov.io/gh/Konstantin8105/c4go/pull/493?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Konstantin)

```diff
@@            Coverage Diff             @@
##           master     #493      +/-   ##
==========================================
- Coverage   82.75%   82.75%   -0.01%     
==========================================
  Files         193      193              
  Lines       10864    10861       -3     
==========================================
- Hits         8991     8988       -3     
  Misses       1362     1362              
  Partials      511      511              
```


| [Impacted Files](https://codecov.io/gh/Konstantin8105/c4go/pull/493?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Konstantin) | Coverage Δ | |
|---|---|---|
| [noarch/string.go](https://codecov.io/gh/Konstantin8105/c4go/pull/493/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Konstantin#diff-bm9hcmNoL3N0cmluZy5nbw==) | `77.94% <ø> (-0.64%)` | :arrow_down: |
| [transpiler/transpiler.go](https://codecov.io/gh/Konstantin8105/c4go/pull/493/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Konstantin#diff-dHJhbnNwaWxlci90cmFuc3BpbGVyLmdv) | `83.62% <100.00%> (-0.05%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/493?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Konstantin).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Konstantin)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/493?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Konstantin). Last update [94cefd2...168165d](https://codecov.io/gh/Konstantin8105/c4go/pull/493?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Konstantin). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Konstantin).


Patch:
diff --git a/noarch/string.go b/noarch/string.go
index aafbc2a..d66a281 100644
--- a/noarch/string.go
+++ b/noarch/string.go
@@ -96,15 +96,13 @@ func Strcmp(str1, str2 []byte) int32 {
 // See: http://www.cplusplus.com/reference/cstring/strchr/
 func Strchr(str []byte, ch32 int32) []byte {
 	ch := int(ch32)
-	i := 0
-	for {
+	for i := 0; i < len(str); i++ {
 		if str[i] == '\x00' {
 			break
 		}
 		if int(str[i]) == ch {
 			return str[i:]
 		}
-		i++
 	}
 	return nil
 }
diff --git a/scripts/vorbis.sh b/scripts/vorbis.sh
index 5aa1412..be33b3c 100755
--- a/scripts/vorbis.sh
+++ b/scripts/vorbis.sh
@@ -30,6 +30,7 @@ mkdir -p ./testdata/
 	echo "Transpile to $GO_FILE"
 	$C4GO transpile                         \
 		-s                                  \
+		-clang-flag="-lm"                   \
 		-o="$GO_FILE"                       \
 		$TEMP_FOLDER/*.c
 
diff --git a/transpiler/transpiler.go b/transpiler/transpiler.go
index 33d106f..90276e4 100644
--- a/transpiler/transpiler.go
+++ b/transpiler/transpiler.go
@@ -522,8 +522,7 @@ func transpileToNode(node ast.Node, p *program.Program) (
 	}
 
 	if !AddOutsideStruct &&
-		!p.PreprocessorFile.IsUserSource(node.Position().File) &&
-		!strings.HasSuffix(node.Position().File, "stdint.h") {
+		!p.PreprocessorFile.IsUserSource(node.Position().File) {
 		if fd, ok := node.(*ast.FunctionDecl); ok {
 			if getFunctionBody(fd) != nil {
 				return


Test patch:
diff --git a/other_test.go b/other_test.go
index 21683ff..9eaafa8 100644
--- a/other_test.go
+++ b/other_test.go
@@ -645,6 +645,8 @@ func TestKiloEditor(t *testing.T) {
 	args.state = StateTranspile
 	args.verbose = false
 
+	t.Logf("Go: %s", goFile)
+
 	if err := Start(args); err != nil {
 		t.Fatalf("Cannot transpile `%v`: %v", args, err)
 	}
@@ -656,7 +658,7 @@ func TestKiloEditor(t *testing.T) {
 	}
 
 	if bytes.Contains(dat, []byte(program.WarningMessage)) {
-		t.Fatalf("find warning message")
+		t.Errorf("find warning message: %s", program.WarningMessage)
 	}
 
 	// calculate amount unsafe operations