From: Bastian Dehn Date: Tue, 3 Mar 2026 19:36:24 +0000 (+0100) Subject: change replace revert X-Git-Tag: 1.1.6^2~1^2~4 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=013215ce16e7bbcb67af16420e9c47c766780e81;p=mv_none_space.git change replace revert --- diff --git a/src/rename.c b/src/rename.c index 5b40d6b..12060ef 100644 --- a/src/rename.c +++ b/src/rename.c @@ -114,42 +114,24 @@ void rename_string(const char* src, char* dst) void rename_revert(const char* src, char* dst) { - uint16_t dst_count = 0; - size_t length = strlen(src); - for (size_t i = 0; i < length; i++) { - if (src[i] == '_') { - dst[dst_count++] = SPACE; - } else if (src[i] == 'a' && src[i + 1] == 'e') { - i++; - dst[dst_count++] = WIDE_CHAR_SHORT_PREFIX; - dst[dst_count++] = WIDE_CHAR_SHORT_a; - } else if (src[i] == 'A' && src[i + 1] == 'e') { - i++; - dst[dst_count++] = WIDE_CHAR_SHORT_PREFIX; - dst[dst_count++] = WIDE_CHAR_SHORT_A; - } else if (src[i] == 'o' && src[i + 1] == 'e') { - i++; - dst[dst_count++] = WIDE_CHAR_SHORT_PREFIX; - dst[dst_count++] = WIDE_CHAR_SHORT_o; - } else if (src[i] == 'O' && src[i + 1] == 'e') { - i++; - dst[dst_count++] = WIDE_CHAR_SHORT_PREFIX; - dst[dst_count++] = WIDE_CHAR_SHORT_O; - } else if (src[i] == 'u' && src[i + 1] == 'e') { - i++; - dst[dst_count++] = WIDE_CHAR_SHORT_PREFIX; - dst[dst_count++] = WIDE_CHAR_SHORT_u; - } else if (src[i] == 'U' && src[i + 1] == 'e') { - i++; - dst[dst_count++] = WIDE_CHAR_SHORT_PREFIX; - dst[dst_count++] = WIDE_CHAR_SHORT_U; - } else if (src[i] == 's' && src[i + 1] == 's') { - i++; - dst[dst_count++] = WIDE_CHAR_SHORT_PREFIX; - dst[dst_count++] = WIDE_CHAR_SHORT_SS; - } else { - dst[dst_count++] = src[i]; - } - } + size_t len = strlen(src) + 1; + char* out = malloc(len); + if (out == NULL) + return; + + memcpy(out, src, len); + + out = replace(&out, "_", " "); + out = replace(&out, "ae", "ä"); + out = replace(&out, "Ae", "Ä"); + out = replace(&out, "oe", "ö"); + out = replace(&out, "Oe", "Ö"); + out = replace(&out, "ue", "ü"); + out = replace(&out, "Ue", "Ü"); + out = replace(&out, "ss", "ß"); + + memcpy(dst, out, strlen(out) + 1); + free(out); + out = NULL; }