mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-11 12:29:46 +00:00
Don't used str2word
as scrstr2word
when the string terminator matches, but digits don't
This commit is contained in:
parent
be21c34dc4
commit
742fc50ccc
@ -6,7 +6,6 @@ alias scrstrzcmp = strzcmp
|
||||
alias scrstrzcopy = strzcopy
|
||||
alias scrstrzpaste = strzpaste
|
||||
alias scrstrzappendchar = strzappendchar
|
||||
alias scrstrz2word = strz2word
|
||||
alias scrstrzappend = strzappend
|
||||
|
||||
|
||||
@ -27,6 +26,14 @@ void scrstrzappendchar(pointer buffer, byte char) {
|
||||
buffer[1] = nullchar_scr
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if DECIMALS_SAME
|
||||
|
||||
alias scrstrz2word = strz2word
|
||||
|
||||
#else
|
||||
|
||||
word scrstrz2word(pointer str) {
|
||||
byte i
|
||||
byte char
|
||||
|
@ -295,6 +295,9 @@ object Platform {
|
||||
|
||||
val builtInFeatures = builtInCpuFeatures(cpu) ++ Map(
|
||||
"ENCODING_SAME" -> toLong(codec.name == srcCodec.name),
|
||||
"DECIMALS_SAME" -> toLong(codec.stringTerminator == srcCodec.stringTerminator && ('0' to '9').forall{c =>
|
||||
codec.encodeOneChar(c) == srcCodec.encodeOneChar(c)
|
||||
}),
|
||||
"ENCCONV_SUPPORTED" -> toLong((codec.name, srcCodec.name) match {
|
||||
case (TextCodec.Petscii.name, TextCodec.CbmScreencodes.name) |
|
||||
(TextCodec.PetsciiJp.name, TextCodec.CbmScreencodesJp.name) |
|
||||
|
@ -21,6 +21,10 @@ sealed trait TextCodec {
|
||||
|
||||
def decode(by: Int): Char
|
||||
|
||||
// encodes one char from BMP, without any lookup tables, conversions, and stuff
|
||||
// useful only for things like ASCII digits
|
||||
def encodeOneChar(c: Char): List[Int]
|
||||
|
||||
def dump(): Unit = {
|
||||
(0 until 256).map(decode).zipWithIndex.grouped(32).map(row => row.head._2.toHexString + "\t" + row.map(_._1).mkString("")).foreach(println(_))
|
||||
}
|
||||
@ -105,6 +109,10 @@ class UnicodeTextCodec(override val name: String, val charset: Charset, override
|
||||
}
|
||||
}
|
||||
|
||||
def encodeOneChar(c: Char): List[Int] = {
|
||||
c.toString.getBytes(charset).map(_.&(0xff)).toList
|
||||
}
|
||||
|
||||
override def decode(by: Int): Char = {
|
||||
if (by >= 0x20 && by <= 0x7E) by.toChar
|
||||
else if (by == 0) '.'
|
||||
@ -246,6 +254,8 @@ class TableTextCodec(override val name: String,
|
||||
val index = by & 0xff
|
||||
if (index < map.length) map(index) else TextCodec.NotAChar
|
||||
}
|
||||
|
||||
override def encodeOneChar(c: Char): List[Int] = List(map.indexOf(c.toInt))
|
||||
}
|
||||
|
||||
object TextCodec {
|
||||
|
Loading…
x
Reference in New Issue
Block a user