From 95c5b66fdc2a4c11c6b05ab35dbc6b75e1e0bcf4 Mon Sep 17 00:00:00 2001 From: "R. Eric Wheeler" Date: Mon, 25 Jan 2021 06:58:35 -0800 Subject: [PATCH] Added strrev function to getch.c --- src/Console/Resources/getch.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Console/Resources/getch.c b/src/Console/Resources/getch.c index 126072c..7a25d88 100644 --- a/src/Console/Resources/getch.c +++ b/src/Console/Resources/getch.c @@ -4,6 +4,22 @@ #include static struct termios oldattr; +static char *strrev(char *str) +{ + char *p1, *p2; + + if (! str || ! *str) + return str; + for (p1 = str, p2 = str + wcslen(str) - 1; p2 > p1; ++p1, --p2) + { + *p1 ^= *p2; + *p2 ^= *p1; + *p1 ^= *p2; + } + return str; +} + + static void setRawMode(void) { struct termios newattr;