chiark / gitweb /
Cope with AA island name on land
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 4 Jul 2009 20:28:26 +0000 (21:28 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 4 Jul 2009 20:28:26 +0000 (21:28 +0100)
pctb/structure.c

index 28caa24..cb79f99 100644 (file)
@@ -684,24 +684,28 @@ void find_islandname(RgbImage *ri) {
     WALK_UNTIL_MUST(islandnamer.br,x, +1, cim->w,         'o');
     debug_rect("islandnamer",__LINE__, islandnamer);
 
-    require_rectangle_r(islandnamer, "O*", __LINE__);
+#define RW (RECT_W(islandnamer))
+#define RH (RECT_H(islandnamer))
 
-    int rw= RECT_W(islandnamer);
-    ADJUST_BOX(islandnamer,"O",>=,rw-4, cim->h, MUST,br,y,+1);
+    ADJUST_BOX(islandnamer,"O",>=,RW-4, cim->h, MUST,br,y,+1);
     debug_rect("islandnamer",__LINE__, islandnamer);
 
     islandnamer.br.y += 2;
-    ADJUST_BOX(islandnamer,"O",>=,1,    cim->h, MUST,br,y,+1);
+
+    ADJUST_BOX(islandnamer,"*",<,RW, cim->h, MUST,br,y,+1);
     debug_rect("islandnamer",__LINE__, islandnamer);
 
     islandnamer.tl.y= islandnamer.br.y-1;
     islandnamer.br.y= islandnamer.br.y+1;
-    int rh= RECT_H(islandnamer);
-    ADJUST_BOX(islandnamer,"*",>=,rw,   cim->h, MUST,br,y,+1);
-    ADJUST_BOX(islandnamer,"O",>=,rh,   cim->w, MUST,tl,x,+1);
     debug_rect("islandnamer",__LINE__, islandnamer);
 
-    MUST( RECT_H(islandnamer) <= 31, MR(islandnamer));
+    ADJUST_BOX(islandnamer,"*",>=,RW, cim->h, MUST,br,y,+1);
+    debug_rect("islandnamer",__LINE__, islandnamer);
+
+    ADJUST_BOX(islandnamer,"*",<, RH, cim->w, MUST,tl,x,+1);
+    debug_rect("islandnamer",__LINE__, islandnamer);
+
+    MUST( RECT_H(islandnamer) <= 30, MR(islandnamer));
 
     Point p;
     int nspaces=1, might_be_colon=0;
@@ -719,9 +723,9 @@ void find_islandname(RgbImage *ri) {
       for (p.y=islandnamer.tl.y; p.y<=islandnamer.br.y; p.y++) {
        pattern <<= 1;
        switch (get_p(p)) {
-       case 'O': runs[nruns]++;                         pattern |= 1u; break;
        case '*': if (runs[nruns]) { nruns++; runs[nruns]=0; }          break;
-       default: abort();
+       case 'O': runs[nruns]++;              pattern |= 1u;            break;
+       default:                              pattern |= 1UL<<31;       break;
        }
       }
 
@@ -735,7 +739,7 @@ void find_islandname(RgbImage *ri) {
        nspaces++;
        might_be_colon=0;
       } else {
-       if (nruns==2 && runs[1]==runs[0]) {
+       if (!(pattern & 1UL<<31) && nruns==2 && runs[1]==runs[0]) {
          if (!nspaces) {
            if (pattern==colon_pattern)
              goto ok_might_be_colon;