Hi Gerd
Attached is a patch that takes Steve's changes for Hebrew and a merges
his other changes with my patch from 8th Apr that removes a lot of
pointless swapping between byte/char and int and also fixes the sign
-extension problem.
Regards
Ticker
On Mon, 2019-04-08 at 21:22 +0100, Steve Ratcliffe wrote:
> Hi
>
> There is a problem that is specific to cp1255 in that there is a
> primary
> character with more than 15 secondary variations.
>
> I've split the first line up in cp1255.txt for lack of any better
> idea
> of what to do.
>
> The attached patch fixes both 1255 and unicode.
>
> Steve
> _______________________________________________
> mkgmap-dev mailing list
> mkgmap-dev@lists.mkgmap.org.uk
> http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
Index: resources/sort/cp1255.txt
===================================================================
--- resources/sort/cp1255.txt (revision 4285)
+++ resources/sort/cp1255.txt (working copy)
@@ -5,7 +5,8 @@
characters
-=0008=000e=000f=0010=0011=0012=0013=0014=0015=0016=0017=0018=0019=001a=001b=001c=001d=001e=001f=007f=00ad=05bd=200e=200f,0001,0002,0003,0004,0005,0006,0007 ; 05b0 ; 05b1 ; 05b2 ; 05b3 ; 05b4 ; 05b5 ; 05b6 ; 05b7 ; 05b8 ; 05b9 ; 05bb ; 05c2 ; 05c1 ; 05bc ; 05bf
+=0008=000e=000f=0010=0011=0012=0013=0014=0015=0016=0017=0018=0019=001a=001b=001c=001d=001e=001f=007f=00ad=05bd=200e=200f,0001,0002,0003,0004,0005,0006,0007
+ < 05b0 ; 05b1 ; 05b2 ; 05b3 ; 05b4 ; 05b5 ; 05b6 ; 05b7 ; 05b8 ; 05b9 ; 05bb ; 05c2 ; 05c1 ; 05bc ; 05bf
< 0009
< 000a
< 000b
Index: src/uk/me/parabola/imgfmt/app/srt/CodePosition.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/srt/CodePosition.java (revision 4285)
+++ src/uk/me/parabola/imgfmt/app/srt/CodePosition.java (working copy)
@@ -20,19 +20,19 @@
* @author Steve Ratcliffe
*/
public class CodePosition {
- private char primary;
- private byte secondary;
- private byte tertiary;
+ private int primary;
+ private int secondary;
+ private int tertiary;
- public char getPrimary() {
+ public int getPrimary() {
return primary;
}
- public byte getSecondary() {
+ public int getSecondary() {
return secondary;
}
- public byte getTertiary() {
+ public int getTertiary() {
return tertiary;
}
@@ -47,23 +47,23 @@
case Collator.PRIMARY:
return primary;
case Collator.SECONDARY:
- return secondary & 0xff;
+ return secondary;
case Collator.TERTIARY:
- return tertiary & 0xff;
+ return tertiary;
default:
return 0;
}
}
- public void setPrimary(char primary) {
+ public void setPrimary(int primary) {
this.primary = primary;
}
- public void setSecondary(byte secondary) {
+ public void setSecondary(int secondary) {
this.secondary = secondary;
}
- public void setTertiary(byte tertiary) {
+ public void setTertiary(int tertiary) {
this.tertiary = tertiary;
}
}
Index: src/uk/me/parabola/imgfmt/app/srt/SRTFile.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/srt/SRTFile.java (revision 4285)
+++ src/uk/me/parabola/imgfmt/app/srt/SRTFile.java (working copy)
@@ -106,16 +106,16 @@
int secondary = sort.getSecondary(i);
int tertiary = sort.getTertiary(i);
if (isMulti) {
- assert primary <= 0xffff;
- assert secondary <= 0xff;
- assert tertiary <= 0xff;
+ assert primary <= 0xffff : primary;
+ assert secondary <= 0xff : secondary;
+ assert tertiary <= 0xff : tertiary;
writer.put2u(primary);
writer.put1u(secondary);
writer.put1u(tertiary);
} else {
- assert primary <= 0xff;
- assert secondary <= 0xf;
- assert tertiary <= 0xf;
+ assert primary <= 0xff : primary;
+ assert secondary <= 0xf : secondary;
+ assert tertiary <= 0xf : tertiary;
writer.put1u(primary);
writer.put1u((tertiary << 4) | (secondary & 0xf));
}
Index: src/uk/me/parabola/imgfmt/app/srt/Sort.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/srt/Sort.java (revision 4285)
+++ src/uk/me/parabola/imgfmt/app/srt/Sort.java (working copy)
@@ -135,7 +135,7 @@
for (int i = 0; i < 256; i++) {
if (((p.flags[i] >>> 4) & 0xf) == 0) {
if (p.getPrimary(i) != 0) {
- byte second = p.getSecondary(i);
+ int second = p.getSecondary(i);
maxSecondary = Math.max(maxSecondary, second);
if (second != 0) {
maxTertiary = Math.max(maxTertiary, p.getTertiary(i));
@@ -361,7 +361,7 @@
// We need +1 for the null bytes, we also +2 for a couple of expanded characters. For a complete
// german map this was always enough in tests.
byte[] key = new byte[(chars.length + 1 + 2) * 4];
- int needed = 0;
+ int needed;
try {
needed = fillCompleteKey(chars, key);
} catch (ArrayIndexOutOfBoundsException e) {
@@ -597,7 +597,7 @@
/**
* Allocate space for up to n pages.
- * @param n
+ * @param n Number of pages
*/
public void setMaxPage(int n) {
pages = Arrays.copyOf(pages, n + 1);
@@ -626,7 +626,7 @@
private final byte[] tertiary = new byte[256];
private final byte[] flags = new byte[256];
- char getPrimary(int ch) {
+ int getPrimary(int ch) {
return primary[ch & 0xff];
}
@@ -634,8 +634,8 @@
primary[ch & 0xff] = (char) val;
}
- byte getSecondary(int ch) {
- return secondary[ch & 0xff];
+ int getSecondary(int ch) {
+ return secondary[ch & 0xff] & 0xff;
}
void setSecondary(int ch, int val) {
@@ -642,8 +642,8 @@
secondary[ch & 0xff] = (byte) val;
}
- byte getTertiary(int ch) {
- return tertiary[ch & 0xff];
+ int getTertiary(int ch) {
+ return tertiary[ch & 0xff] & 0xff;
}
void setTertiary(int ch, int val) {
@@ -659,11 +659,11 @@
public int getPos(int type, int ch) {
switch (type) {
case Collator.PRIMARY:
- return getPrimary(ch) & 0xffff;
+ return getPrimary(ch);
case Collator.SECONDARY:
- return getSecondary(ch) & 0xff;
+ return getSecondary(ch);
case Collator.TERTIARY:
- return getTertiary(ch) & 0xff;
+ return getTertiary(ch);
default:
assert false : "bad collation type passed";
return 0;
@@ -850,7 +850,7 @@
}
// Get the first non-ignorable at this level
- int c = chars[(pos++ & 0xff)];
+ int c = chars[pos++ & 0xff];
if (!hasPage(c >>> 8)) {
next = 0;
continue;
Index: src/uk/me/parabola/imgfmt/app/srt/SrtFileReader.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/srt/SrtFileReader.java (revision 4285)
+++ src/uk/me/parabola/imgfmt/app/srt/SrtFileReader.java (working copy)
@@ -173,20 +173,21 @@
int rec;
if (posLength == 2) {
rec = reader.get2u();
- cp.setPrimary((char) (rec & 0xff));
- cp.setSecondary((byte) ((rec >> 8) & 0xf));
- cp.setTertiary((byte) ((rec >> 12) & 0xf));
+ cp.setPrimary(rec & 0xff);
+ cp.setSecondary((rec >> 8) & 0xf);
+ cp.setTertiary((rec >> 12) & 0xf);
} else if (posLength == 3) {
+ // what is the extra byte for ???
rec = reader.get3u();
- cp.setPrimary((char) (rec & 0xff));
- cp.setSecondary((byte) ((rec >> 8) & 0xf));
- cp.setTertiary((byte) ((rec >> 12) & 0xf));
+ cp.setPrimary(rec & 0xff);
+ cp.setSecondary((rec >> 8) & 0xf);
+ cp.setTertiary((rec >> 12) & 0xf);
} else if (posLength == 4) {
rec = reader.get4();
- cp.setPrimary((char) (rec & 0xffff));
- cp.setSecondary((byte) ((rec >> 16) & 0xff));
- cp.setTertiary((byte) ((rec >> 24) & 0xff));
+ cp.setPrimary(rec & 0xffff);
+ cp.setSecondary((rec >> 16) & 0xff);
+ cp.setTertiary((rec >> 24) & 0xff);
} else {
throw new RuntimeException("unexpected value posLength " + posLength);
}
Index: src/uk/me/parabola/mkgmap/srt/SrtTextReader.java
===================================================================
--- src/uk/me/parabola/mkgmap/srt/SrtTextReader.java (revision 4285)
+++ src/uk/me/parabola/mkgmap/srt/SrtTextReader.java (working copy)
@@ -329,7 +329,7 @@
CodePosition cp = new CodePosition();
int b = r.getBval();
int primary = sort.getPrimary(b);
- cp.setPrimary((char) primary);
+ cp.setPrimary(primary);
// We do not want the character to sort fully equal to the expanded characters (or any other
// character so adjust the ordering at other strengths. May need further tweaks.
@@ -346,15 +346,15 @@
} else {
secondary = 1;
}
- cp.setSecondary((byte) (secondary));
- cp.setTertiary((byte) (tertiary));
+ cp.setSecondary(secondary);
+ cp.setTertiary(tertiary);
} else {
num++;
- secondary = sort.getSecondary(b) & 0xff;
- cp.setSecondary((byte) (secondary + 7));
+ secondary = sort.getSecondary(b);
+ cp.setSecondary(secondary + 7);
- tertiary = sort.getTertiary(b) & 0xff;
- cp.setTertiary((byte) (tertiary + 2));
+ tertiary = sort.getTertiary(b);
+ cp.setTertiary(tertiary + 2);
}
expansions.add(cp);
}
_______________________________________________
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev