]> gitweb.hhaalo.de Git - mv_none_space.git/commitdiff
change replace revert
authorBastian Dehn <hhaalo@arcor.de>
Tue, 3 Mar 2026 19:36:24 +0000 (20:36 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 3 Mar 2026 19:36:24 +0000 (20:36 +0100)
src/rename.c

index 5b40d6bbcee56fe63af8ee85b9116de2375d694b..12060ef63d3090098b6247a87d6759b607f6a596 100644 (file)
@@ -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;
 }