Skip to content

Commit

Permalink
Merge pull request #10 from vitalibozhko/fix/utf-8-in-comments
Browse files Browse the repository at this point in the history
Fix: utf-8 in the comment gets mangled.
  • Loading branch information
cwaeland authored Mar 13, 2024
2 parents 3512342 + b6dd7d0 commit eb4d14f
Show file tree
Hide file tree
Showing 3 changed files with 753 additions and 752 deletions.
22 changes: 11 additions & 11 deletions parser/grammar.peg
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ func toIfaceSlice(v interface{}) []interface{} {

func ifaceSliceToString(v interface{}) string {
ifs := toIfaceSlice(v)
b := make([]byte, len(ifs))
for i, v := range ifs {
b[i] = v.([]uint8)[0]
b := make([]byte, 0, len(ifs))
for _, v := range ifs {
b = append(b, v.([]uint8)...)
}
return string(b)
}

func ifaceSliceToCommentString(v interface{}) string {
cps := v.([]interface{})
ccs := cps[1].([]interface{})
b := make([]byte, len(ccs))
for i, v := range ccs {
tmp := v.([]interface{})
b[i] = tmp[1].([]uint8)[0]
b := make([]byte, 0, len(ccs))
for _, v := range ccs {
tmp := v.([]interface{})
b = append(b, tmp[1].([]uint8)...)
}
s := strings.Replace(string(b), "\n", "", -1)
return strings.TrimSpace(s)
Expand All @@ -62,10 +62,10 @@ func ifaceSliceToCommentString(v interface{}) string {
func ifaceSliceToBlockCommentLineString(v interface{}) string {
cps := v.([]interface{})
ccs := cps[1].([]interface{})
b := make([]byte, len(ccs))
for i, v := range ccs {
tmp := v.([]interface{})
b[i] = tmp[1].([]uint8)[0]
b := make([]byte, 0, len(ccs))
for _, v := range ccs {
tmp := v.([]interface{})
b = append(b, tmp[1].([]uint8)...)
}
s := strings.Replace(string(b), "\n", "", -1)
for {
Expand Down
Loading

0 comments on commit eb4d14f

Please sign in to comment.