mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-12 19:29:51 +00:00
Don't repeat warnings about identical replaced characters in the lenient mode
This commit is contained in:
parent
4e1958d831
commit
2382f95b5c
@ -8,6 +8,8 @@ import millfork.{CompilationFlag, CompilationOptions}
|
||||
import millfork.error.{ConsoleLogger, Logger}
|
||||
import millfork.node.Position
|
||||
|
||||
import scala.collection.mutable
|
||||
|
||||
/**
|
||||
* @author Karol Stasiak
|
||||
*/
|
||||
@ -140,6 +142,8 @@ class TableTextCodec(override val name: String,
|
||||
val directDecompositions: Map[Char, List[Int]],
|
||||
val escapeSequences: Map[String, List[Int]]) extends TextCodec {
|
||||
|
||||
private val alreadyWarned = mutable.Set[Char]()
|
||||
|
||||
override val stringTerminator: List[Int] = List(stringTerminatorChar)
|
||||
|
||||
private def isPrintable(c: Int) = {
|
||||
@ -200,8 +204,9 @@ class TableTextCodec(override val name: String,
|
||||
Some(List(index))
|
||||
} else if (lenient) {
|
||||
val alternative = TextCodec.lossyAlternatives.getOrElse(c, Nil).:+("?").find(alts => alts.forall(alt => encodeChar(log, position, alt, options, lenient = false).isDefined)).getOrElse("")
|
||||
if (options.flag(CompilationFlag.FallbackValueUseWarning)) {
|
||||
if (options.flag(CompilationFlag.FallbackValueUseWarning) && !alreadyWarned(c)) {
|
||||
log.warn(s"Cannot encode ${format(c)} in encoding `$name`, replaced it with ${format(alternative)}", position)
|
||||
alreadyWarned += c
|
||||
}
|
||||
Some(alternative.toList.flatMap(encodeChar(log, position, _, options, lenient = false).get))
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user