Erase \1 after a, i, u, e, o.
authorPhilipp Reh <sefi@s-e-f-i.de>
Sat, 1 Aug 2009 18:21:43 +0000 (20:21 +0200)
committerPhilipp Reh <sefi@s-e-f-i.de>
Sat, 1 Aug 2009 18:21:43 +0000 (20:21 +0200)
kana2romaji.cpp

index 7024f3fe20f8f5091df04d64d20a1c2d05c1109e..ac239f8c30a6b8084e477bdd7a4b0211089c8601 100644 (file)
@@ -408,6 +408,7 @@ void kana2romaji(const string& kana, string& rom) {
                       ? 3
                       : 2);
                   pos -= 2;
+                 continue;
                }
                else if(
                   pred == "fu" ||
@@ -417,6 +418,7 @@ void kana2romaji(const string& kana, string& rom) {
                {
                   remove_quote_1(pos, rom);
                   pos -= 2;
+                 continue;
                }
                else if(
                  pred == "su" ||
@@ -430,6 +432,8 @@ void kana2romaji(const string& kana, string& rom) {
                {
                  rom[pos - 1] = 'w'; 
                  rom.erase(pos);
+                 --pos;
+                 continue;
                }
                else if(
                  pred == "to" ||
@@ -438,11 +442,27 @@ void kana2romaji(const string& kana, string& rom) {
                {
                  rom[pos - 1] = 'h';
                  rom.erase(pos);
+                 --pos;
+                 continue;
                }
-               else
-               {
-                 cout << "Encountered a special character in " << kana << " but don't know what to do with it.\n";
-               }
+            }
+
+            if (pos > 0) {
+              char const pred = rom[pos - 1];
+
+              switch(pred)
+              {
+              case 'a':
+              case 'i':
+              case 'u':
+              case 'e':
+              case 'o':
+                rom.erase(pos);
+                --pos;
+                continue;
+              default:
+                cout << "Encountered a special character in " << kana << " but don't know what to do with it.\n";
+              }
             }
             else
             {