Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions modules/charset/ambiguous.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// This file is generated by modules/charset/ambiguous/generate.go DO NOT EDIT
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

Expand All @@ -14,11 +13,12 @@ import (

// AmbiguousTablesForLocale provides the table of ambiguous characters for this locale.
func AmbiguousTablesForLocale(locale translation.Locale) []*AmbiguousTable {
ambiguousTableMap := globalVars().ambiguousTableMap
key := locale.Language()
var table *AmbiguousTable
var ok bool
for len(key) > 0 {
if table, ok = AmbiguousCharacters[key]; ok {
if table, ok = ambiguousTableMap[key]; ok {
break
}
idx := strings.LastIndexAny(key, "-_")
Expand All @@ -29,18 +29,18 @@ func AmbiguousTablesForLocale(locale translation.Locale) []*AmbiguousTable {
}
}
if table == nil && (locale.Language() == "zh-CN" || locale.Language() == "zh_CN") {
table = AmbiguousCharacters["zh-hans"]
table = ambiguousTableMap["zh-hans"]
}
if table == nil && strings.HasPrefix(locale.Language(), "zh") {
table = AmbiguousCharacters["zh-hant"]
table = ambiguousTableMap["zh-hant"]
}
if table == nil {
table = AmbiguousCharacters["_default"]
table = ambiguousTableMap["_default"]
}

return []*AmbiguousTable{
table,
AmbiguousCharacters["_common"],
ambiguousTableMap["_common"],
}
}

Expand All @@ -52,7 +52,7 @@ func isAmbiguous(r rune, confusableTo *rune, tables ...*AmbiguousTable) bool {
i := sort.Search(len(table.Confusable), func(i int) bool {
return table.Confusable[i] >= r
})
(*confusableTo) = table.With[i]
*confusableTo = table.With[i]
return true
}
return false
Expand Down
188 changes: 0 additions & 188 deletions modules/charset/ambiguous/generate.go

This file was deleted.

1,590 changes: 803 additions & 787 deletions modules/charset/ambiguous_gen.go

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion modules/charset/ambiguous_gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import (
"testing"
"unicode"

"code.gitea.io/gitea/modules/translation"

"github.com/stretchr/testify/assert"
)

func TestAmbiguousCharacters(t *testing.T) {
for locale, ambiguous := range AmbiguousCharacters {
for locale, ambiguous := range globalVars().ambiguousTableMap {
assert.Equal(t, locale, ambiguous.Locale)
assert.Len(t, ambiguous.With, len(ambiguous.Confusable))
assert.True(t, sort.SliceIsSorted(ambiguous.Confusable, func(i, j int) bool {
Expand All @@ -28,4 +30,8 @@ func TestAmbiguousCharacters(t *testing.T) {
assert.True(t, found, "%c is not in %d", confusable, i)
}
}

var confusableTo rune
ret := isAmbiguous('𝐾', &confusableTo, AmbiguousTablesForLocale(&translation.MockLocale{})...)
assert.True(t, ret)
}
43 changes: 0 additions & 43 deletions modules/charset/breakwriter.go

This file was deleted.

68 changes: 0 additions & 68 deletions modules/charset/breakwriter_test.go

This file was deleted.

Loading