(i *syntax.Inst)
| 70 | } |
| 71 | |
| 72 | func oneByteRange(i *syntax.Inst) (lo, hi byte, fold, ok bool) { |
| 73 | if i.Op == syntax.InstRune1 { |
| 74 | r := i.Rune[0] |
| 75 | if r < utf8.RuneSelf { |
| 76 | return byte(r), byte(r), false, true |
| 77 | } |
| 78 | } |
| 79 | if i.Op != syntax.InstRune { |
| 80 | return |
| 81 | } |
| 82 | fold = syntax.Flags(i.Arg)&syntax.FoldCase != 0 |
| 83 | if len(i.Rune) == 1 || len(i.Rune) == 2 && i.Rune[0] == i.Rune[1] { |
| 84 | r := i.Rune[0] |
| 85 | if r >= utf8.RuneSelf { |
| 86 | return |
| 87 | } |
| 88 | if fold && !asciiFold(r) { |
| 89 | return |
| 90 | } |
| 91 | return byte(r), byte(r), fold, true |
| 92 | } |
| 93 | if len(i.Rune) == 2 && i.Rune[1] < utf8.RuneSelf { |
| 94 | if fold { |
| 95 | for r := i.Rune[0]; r <= i.Rune[1]; r++ { |
| 96 | if asciiFold(r) { |
| 97 | return |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | return byte(i.Rune[0]), byte(i.Rune[1]), fold, true |
| 102 | } |
| 103 | if len(i.Rune) == 4 && i.Rune[0] == i.Rune[1] && i.Rune[2] == i.Rune[3] && unicode.SimpleFold(i.Rune[0]) == i.Rune[2] && unicode.SimpleFold(i.Rune[2]) == i.Rune[0] { |
| 104 | return byte(i.Rune[0]), byte(i.Rune[0]), true, true |
| 105 | } |
| 106 | |
| 107 | return |
| 108 | } |
| 109 | |
| 110 | func asciiFold(r rune) bool { |
| 111 | if r >= utf8.RuneSelf { |
no test coverage detected
searching dependent graphs…