OSDN Git Service

update wikivar function.
authorvisor <visor@users.sourceforge.jp>
Sat, 22 Oct 2011 01:13:16 +0000 (10:13 +0900)
committervisor <visor@users.sourceforge.jp>
Sat, 22 Oct 2011 01:13:16 +0000 (10:13 +0900)
modules/ml-wiki.cc
wiki/wikiformat.cc
wiki/wikiformat.h

index 0ee90b4..e181686 100644 (file)
@@ -60,8 +60,13 @@ static ustring*  wikivar (const ustring& name) {
     ustring*  ans = new ustring;
 
     ans->reserve (uWiki.length () + name.length ());
-    ans->append (uWiki);
-    ans->append (name);
+    if (name.length () >= 1 && name[0] == '@') {
+       ans->append (uAWiki);
+       ans->append (name.begin () + 1, name.end ());
+    } else {
+       ans->append (uWiki);
+       ans->append (name);
+    }
 
     return ans;
 }
@@ -69,10 +74,14 @@ static ustring*  wikivar (const ustring& name) {
 static ustring*  wikivar_ary (const ustring& name) {
     ustring*  ans = new ustring;
 
-    ans->reserve (uWiki.length () + name.length () + 1);
-    ans->append (CharConst ("@"));
-    ans->append (uWiki);
-    ans->append (name);
+    ans->reserve (uAWiki.length () + name.length ());
+    if (name.length () >= 1 && name[0] == '@') {
+       ans->append (uAWiki);
+       ans->append (name.begin () + 1, name.end ());
+    } else {
+       ans->append (uAWiki);
+       ans->append (name);
+    }
 
     return ans;
 }
@@ -85,6 +94,8 @@ static ustring*  wikivar_ary (const ustring& name) {
 Return string prefixed with 'wiki_'.
 Return string prefixed with '@wiki_'.
 
+If NAME begins with '@' returns '@wiki_' followed by NAME without '@'.
+
 */
 //#AFUNC       wikivar ml_wikivar
 //#AFUNC       wikivar@        ml_wikivar_ary
index 3ab9da8..1983bd0 100644 (file)
@@ -58,6 +58,7 @@
 //#define  unbsp       "&nbsp;"
 
 ustring  uWiki (CharConst ("wiki_"));
+ustring  uAWiki (CharConst ("@wiki_"));
 
 /*DOC:
 ==テキストの整形ルール==
index 1c778fc..194153c 100644 (file)
@@ -615,5 +615,6 @@ class  WikiFormat {
 };
 
 extern ustring  uWiki;
+extern ustring  uAWiki;
 
 #endif /* WIKIFORMAT_H */