Change special_phrases format
authorPeng Huang <shawn.p.huang@gmail.com>
Wed, 14 Apr 2010 11:05:34 +0000 (19:05 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Wed, 14 Apr 2010 11:05:34 +0000 (19:05 +0800)
src/SpecialTable.cc
src/special_phrases

index 276fe14..3a5523a 100644 (file)
@@ -37,7 +37,7 @@ public:
         while (s != 2) {
             switch (s) {
             case 0:
-                pnext = m_text.find ("%(", pos);
+                pnext = m_text.find ("${", pos);
                 if (pnext == m_text.npos) {
                     result += m_text.substr (pos);
                     s = 2;
@@ -49,9 +49,9 @@ public:
                 }
                 break;
             case 1:
-                pnext = m_text.find (")", pos);
+                pnext = m_text.find ("}", pos);
                 if (pnext == m_text.npos) {
-                    result += "%(";
+                    result += "${";
                     result += m_text.substr (pos);
                     s = 2;
                 }
@@ -68,9 +68,9 @@ public:
         return result;
     }
 
-    const std::string dec (gint d) {
+    const std::string dec (gint d, const gchar *fmt = "%d") {
         char string [32];
-        std::snprintf (string, sizeof (string), "%d", d);
+        std::snprintf (string, sizeof (string), fmt, d);
         return string;
     }
 
@@ -129,7 +129,6 @@ SpecialTable::load (const gchar *file)
             getline (in, line);
             size_t pos = line.find ('\t');
             if (pos == line.npos) {
-                std::cerr << "error: " << line << std::endl;
                 continue;
             }
             std::string command = line.substr(0, pos);
@@ -145,12 +144,14 @@ SpecialTable::load (const gchar *file)
     return TRUE;
 }
 
+#if 0
 static bool
 phraseCmp (const SpecialPhrase *first,
            const SpecialPhrase *second)
 {
     return first->position () <= second->position ();
 }
+#endif
 
 void
 SpecialTable::insert (const std::string   &command,
index 818781f..27f437c 100644 (file)
@@ -22,11 +22,11 @@ kalaok      卡拉OK
 pcji   PC机
 qiruiqq        奇瑞QQ
 qqhao  QQ号
-rq     %(year)年%(month)月%(day)
-rq     %(year)-%(month)-%(day)
+rq     ${year}年${month}月${day}
+rq     ${year}-${month}-${day}
 simka  SIM卡
-sj     %(hour_24)时%(minute)分%(second)
-sj     %(hour_24):%(minute):%(second)
+sj     ${hour_24}时${minute}分${second}
+sj     ${hour_24}:${minute}:${second}
 tixu   T恤
 tixushan       T恤衫
 txingtai       T型台