Sfoglia il codice sorgente

Simplified smiley processing.

default 1 anno fa
parent
commit
8b176292d6
1 ha cambiato i file con 29 aggiunte e 31 eliminazioni
  1. 29 31
      format.c

+ 29 - 31
format.c

@@ -8,34 +8,30 @@
 #include "snac.h"
 
 /* emoticons, people laughing and such */
-
-struct {
-    const char *key;
-    const char *value;
-} smileys[] = {
-    { ":-)",        "🙂" },
-    { ":-D",        "😀" },
-    { "X-D",        "😆" },
-    { ";-)",        "😉" },
-    { "B-)",        "😎" },
-    { ">:-(",       "😡" },
-    { ":-(",        "😞" },
-    { ":-*",        "😘" },
-    { ":-/",        "😕" },
-    { "8-o",        "😲" },
-    { "%-)",        "🤪" },
-    { ":_(",        "😢" },
-    { ":-|",        "😐" },
-    { "<3",         "&#128147;" },
-    { ":facepalm:", "&#129318;" },
-    { ":shrug:",    "&#129335;" },
-    { ":shrug2:",   "&#175;\\_(&#12484;)_/&#175;" },
-    { ":eyeroll:",  "&#128580;" },
-    { ":beer:",     "&#127866;" },
-    { ":beers:",    "&#127867;" },
-    { ":munch:",    "&#128561;" },
-    { ":thumb:",    "&#128077;" },
-    { NULL,         NULL }
+const char *smileys[] = {
+    ":-)",        "&#128578;",
+    ":-D",        "&#128512;",
+    "X-D",        "&#128518;",
+    ";-)",        "&#128521;",
+    "B-)",        "&#128526;",
+    ">:-(",       "&#128545;",
+    ":-(",        "&#128542;",
+    ":-*",        "&#128536;",
+    ":-/",        "&#128533;",
+    "8-o",        "&#128562;",
+    "%-)",        "&#129322;",
+    ":_(",        "&#128546;",
+    ":-|",        "&#128528;",
+    "<3",         "&#128147;",
+    ":facepalm:", "&#129318;",
+    ":shrug:",    "&#129335;",
+    ":shrug2:",   "&#175;\\_(&#12484;)_/&#175;",
+    ":eyeroll:",  "&#128580;",
+    ":beer:",     "&#127866;",
+    ":beers:",    "&#127867;",
+    ":munch:",    "&#128561;",
+    ":thumb:",    "&#128077;",
+    NULL,         NULL
 };
 
 
@@ -193,10 +189,12 @@ xs_str *not_really_markdown(const char *content, xs_list **attach)
 
     {
         /* traditional emoticons */
-        int n;
+        const char **emo = smileys;
 
-        for (n = 0; smileys[n].key; n++)
-            s = xs_replace_i(s, smileys[n].key, smileys[n].value);
+        while (*emo) {
+            s = xs_replace_i(s, emo[0], emo[1]);
+            emo += 2;
+        }
     }
 
     return s;