commit 8b176292d60975f498a5a1564ab66393a9f4fd5b
parent 93bdf79eb69d79803a091e2d6583772b40e41f44
Author: default <nobody@localhost>
Date: Thu, 17 Aug 2023 18:20:16 +0200
Simplified smiley processing.
Diffstat:
M | format.c | | | 60 | +++++++++++++++++++++++++++++------------------------------- |
1 file changed, 29 insertions(+), 31 deletions(-)
diff --git a/format.c b/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", "💓" },
- { ":facepalm:", "🤦" },
- { ":shrug:", "🤷" },
- { ":shrug2:", "¯\\_(ツ)_/¯" },
- { ":eyeroll:", "🙄" },
- { ":beer:", "🍺" },
- { ":beers:", "🍻" },
- { ":munch:", "😱" },
- { ":thumb:", "👍" },
- { NULL, NULL }
+const char *smileys[] = {
+ ":-)", "🙂",
+ ":-D", "😀",
+ "X-D", "😆",
+ ";-)", "😉",
+ "B-)", "😎",
+ ">:-(", "😡",
+ ":-(", "😞",
+ ":-*", "😘",
+ ":-/", "😕",
+ "8-o", "😲",
+ "%-)", "🤪",
+ ":_(", "😢",
+ ":-|", "😐",
+ "<3", "💓",
+ ":facepalm:", "🤦",
+ ":shrug:", "🤷",
+ ":shrug2:", "¯\\_(ツ)_/¯",
+ ":eyeroll:", "🙄",
+ ":beer:", "🍺",
+ ":beers:", "🍻",
+ ":munch:", "😱",
+ ":thumb:", "👍",
+ 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;