From 335e0503c95d1036717380fad2a408f2f95a0c9f Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Sat, 6 Oct 2018 22:42:29 +0200 Subject: [PATCH] Mayaqua/Str: add TrimQuotes() function to remove quotes from a string --- src/Mayaqua/Str.c | 27 +++++++++++++++++++++++++++ src/Mayaqua/Str.h | 1 + 2 files changed, 28 insertions(+) diff --git a/src/Mayaqua/Str.c b/src/Mayaqua/Str.c index 7a1c79c0..95cc515a 100644 --- a/src/Mayaqua/Str.c +++ b/src/Mayaqua/Str.c @@ -2412,6 +2412,33 @@ void TrimCrlf(char *str) } } +// Remove quotes at the beginning and at the end of the string +void TrimQuotes(char *str) +{ + UINT len = 0; + // Validate arguments + if (str == NULL) + { + return; + } + + len = StrLen(str); + if (len == 0) + { + return; + } + + if (str[len - 1] == '\"') + { + str[len - 1] = 0; + } + + if (str[0] == '\"') + { + Move(str, str + 1, len); + } +} + // Remove white spaces of the both side of the string void Trim(char *str) { diff --git a/src/Mayaqua/Str.h b/src/Mayaqua/Str.h index 7a554706..cb8c1e06 100644 --- a/src/Mayaqua/Str.h +++ b/src/Mayaqua/Str.h @@ -155,6 +155,7 @@ bool ToBool(char *str); int ToInti(char *str); void ToStr(char *str, UINT i); void TrimCrlf(char *str); +void TrimQuotes(char *str); void Trim(char *str); void TrimRight(char *str); void TrimLeft(char *str);