Browse Source

Simplified smiley processing.

default 1 year ago
parent
commit
8b176292d6
1 changed files with 29 additions and 31 deletions
  1. 29 31
      format.c

+ 29 - 31
format.c

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