]> gitweb.hhaalo.de Git - mv_none_space.git/commitdiff
remove deprecated methods
authorBastian Dehn <hhaalo@arcor.de>
Thu, 2 Oct 2025 16:57:46 +0000 (18:57 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Thu, 2 Oct 2025 16:57:46 +0000 (18:57 +0200)
src/main.c
src/rename.c
src/rename.h

index ed0ee4fc6eb50aeb3e0b6f4a9fbb031cd9fd1088..004b4d782cd85653e38125ae35a65ac4587b430c 100644 (file)
@@ -42,35 +42,23 @@ void rename_file(const char* input, const char* output)
        rename(input, output);
 }
 
-void rename_files(const char* dir_path, rename_func_ptr renamefunc)
+void rename_files(const char* dir_path, rename_ptr renamefunc)
 {
-       char* input = malloc(sizeof(char) * STR_MAX_LENGTH);
-       memset(input, 0, STR_MAX_LENGTH);
-       char* output = malloc(sizeof(char) * STR_MAX_LENGTH);
-       memset(output, 0, STR_MAX_LENGTH);
-
        glob_t* files = get_files(dir_path);
 
        for (int i = 0; i < files->gl_pathc; i++) {
-               renamefunc(files->gl_pathv[i], output);
+               const char* output = renamefunc(files->gl_pathv[i]);
                rename_file(files->gl_pathv[i], output);
 
                if (is_dir(output)) {
-                       escape_str(output, input);
-                       rename_files(input, renamefunc);
+                       const char* dirname = escape(output);
+                       rename_files(dirname, renamefunc);
                }
-
-               memset(output, 0, STR_MAX_LENGTH);
-               memset(input, 0, STR_MAX_LENGTH);
        }
 
        globfree(files);
        free(files);
        files = NULL;
-       free(input);
-       input = NULL;
-       free(output);
-       output = NULL;
 }
 
 int main(int argc, char* argv[])
@@ -82,13 +70,13 @@ int main(int argc, char* argv[])
        }
 
        if (argc == 3 && strcmp(argv[2], "lower") == 0)
-               rename_files(argv[1], rename_lower_str);
+               rename_files(argv[1], rename_lower);
        else if (argc == 3 && strcmp(argv[2], "point") == 0)
-               rename_files(argv[1], rename_point_str);
+               rename_files(argv[1], rename_point);
        else if (argc == 3 && strcmp(argv[2], "revert") == 0)
-               rename_files(argv[1], rename_revert_str);
+               rename_files(argv[1], rename_revert);
        else
-               rename_files(argv[1], rename_str);
+               rename_files(argv[1], rename_string);
 
        return 0;
 }
\ No newline at end of file
index 527f07cc04d2f4ea8be7b86ef301cafc8335e47d..7fe12a0fb2872b1767e46374065f91f5ab9afca0 100644 (file)
@@ -3,29 +3,6 @@
 #include <string.h>
 #include "rename.h"
 
-void escape_str(const char* src, char* dst)
-{
-       int len = strlen(src);
-       int dstcounter = 0;
-       for (int i = 0; i < len; i++) {
-               switch(src[i]) {
-               case SPACE:
-               case ROUND_BRACKET_OPEN:
-               case ROUND_BRACKET_CLOSE:
-               case BRACKET_OPEN:
-               case BRACKET_CLOSE:
-               case BRACE_OPEN:
-               case BRACE_CLOSE:
-                       dst[dstcounter++] = '\\';
-                       dst[dstcounter++] = src[i];
-                       break;
-               default:
-                       dst[dstcounter++] = src[i];
-                       break;
-               }
-       }
-}
-
 char* escape(const char* src)
 {
        size_t length = strlen(src);
@@ -57,29 +34,6 @@ char* escape(const char* src)
        return dest;
 }
 
-void rename_point_str(const char* src, char* dst)
-{
-       char* tmp_str = NULL;
-       int len = strlen(src);
-       int point_count = 0;
-       for (int i = len - 1; i >= 0; i--) {
-               if (src[i] == POINT)
-                       point_count++;
-
-               if (src[i] != POINT)
-                       break;
-       }
-
-       tmp_str = malloc(sizeof(char) * len + 1);
-       memset(tmp_str, 0, len + 1);
-       strncpy(tmp_str, src, len - point_count);
-
-       rename_str(tmp_str, dst);
-
-       free(tmp_str);
-       tmp_str = NULL;
-}
-
 char* rename_point(const char* src)
 {
        char* dest = rename_string(src);
@@ -100,18 +54,6 @@ char* rename_point(const char* src)
 
        return dest;
 }
-
-void rename_lower_str(const char* src, char* dst)
-{
-       rename_str(src, dst);
-       int len = strlen(dst);
-       for (int i = 0; i < len; i++) {
-               if (dst[i] >= A && dst[i] <= Z) {
-                       dst[i] = dst[i] + SPACE;
-               }
-       }
-}
-
 char* rename_lower(const char* src)
 {
        char* dest = rename_string(src);
@@ -124,47 +66,6 @@ char* rename_lower(const char* src)
        return dest;
 }
 
-void rename_str(const char* src, char* dst)
-{
-       int len = strlen(src);
-       int dstcounter = 0;
-       for (int i = 0; i < len; i++) {
-               if (src[i] == SPACE) {
-                       dst[dstcounter++] = '_';
-               } else if (src[i] == WIDE_CHAR_PREFIX && src[i + 1] == WIDE_CHAR_a) {
-                       i++;
-                       dst[dstcounter++] = 'a';
-                       dst[dstcounter++] = 'e';
-               } else if (src[i] == WIDE_CHAR_PREFIX && src[i + 1] == WIDE_CHAR_A) {
-                       i++;
-                       dst[dstcounter++] = 'A';
-                       dst[dstcounter++] = 'e';
-               } else if (src[i] == WIDE_CHAR_PREFIX && src[i + 1] == WIDE_CHAR_o) {
-                       i++;
-                       dst[dstcounter++] = 'o';
-                       dst[dstcounter++] = 'e';
-               } else if (src[i] == WIDE_CHAR_PREFIX && src[i + 1] == WIDE_CHAR_O) {
-                       i++;
-                       dst[dstcounter++] = 'O';
-                       dst[dstcounter++] = 'e';
-               } else if (src[i] == WIDE_CHAR_PREFIX && src[i + 1] == WIDE_CHAR_u) {
-                       i++;
-                       dst[dstcounter++] = 'u';
-                       dst[dstcounter++] = 'e';
-               } else if (src[i] == WIDE_CHAR_PREFIX && src[i + 1] == WIDE_CHAR_U) {
-                       i++;
-                       dst[dstcounter++] = 'U';
-                       dst[dstcounter++] = 'e';
-               } else if (src[i] == WIDE_CHAR_PREFIX && src[i + 1] == WIDE_CHAR_SS) {
-                       i++;
-                       dst[dstcounter++] = 's';
-                       dst[dstcounter++] = 's';
-               } else {
-                       dst[dstcounter++] = src[i];
-               }
-       }
-}
-
 char* rename_string(const char* src)
 {
        size_t length = strlen(src);
@@ -214,47 +115,6 @@ char* rename_string(const char* src)
        return dest;
 }
 
-void rename_revert_str(const char* src, char* dst)
-{
-       int len = strlen(src);
-       int dstcounter = 0;
-       for (int i = 0; i < len; i++) {
-               if (src[i] == '_') {
-                       dst[dstcounter++] = SPACE;
-               } else if (src[i] == 'a' && src[i + 1] == 'e') {
-                       i++;
-                       dst[dstcounter++] = WIDE_CHAR_SHORT_PREFIX;
-                       dst[dstcounter++] = WIDE_CHAR_SHORT_a;
-               } else if (src[i] == 'A' && src[i + 1] == 'e') {
-                       i++;
-                       dst[dstcounter++] = WIDE_CHAR_SHORT_PREFIX;
-                       dst[dstcounter++] = WIDE_CHAR_SHORT_A;
-               } else if (src[i] == 'o' && src[i + 1] == 'e') {
-                       i++;
-                       dst[dstcounter++] = WIDE_CHAR_SHORT_PREFIX;
-                       dst[dstcounter++] = WIDE_CHAR_SHORT_o;
-               } else if (src[i] == 'O' && src[i + 1] == 'e') {
-                       i++;
-                       dst[dstcounter++] = WIDE_CHAR_SHORT_PREFIX;
-                       dst[dstcounter++] = WIDE_CHAR_SHORT_O;
-               } else if (src[i] == 'u' && src[i + 1] == 'e') {
-                       i++;
-                       dst[dstcounter++] = WIDE_CHAR_SHORT_PREFIX;
-                       dst[dstcounter++] = WIDE_CHAR_SHORT_u;
-               } else if (src[i] == 'U' && src[i + 1] == 'e') {
-                       i++;
-                       dst[dstcounter++] = WIDE_CHAR_SHORT_PREFIX;
-                       dst[dstcounter++] = WIDE_CHAR_SHORT_U;
-               } else if (src[i] == 's' && src[i + 1] == 's') {
-                       i++;
-                       dst[dstcounter++] = WIDE_CHAR_SHORT_PREFIX;
-                       dst[dstcounter++] = WIDE_CHAR_SHORT_SS;
-               } else {
-                       dst[dstcounter++] = src[i];
-               }
-       }
-}
-
 char* rename_revert(const char* src)
 {
        size_t length = strlen(src);
index ac02e591c810e63dd9f940554cc44bb2d7d67dce..490324a8c900065b35ab5e050670e4d2807b2707 100644 (file)
 #define WIDE_CHAR_SHORT_U 0x9c
 #define WIDE_CHAR_SHORT_SS 0x9f
 
-__attribute_deprecated__ typedef void (*rename_func_ptr)(const char* src, char* dst);
 typedef char* (*rename_ptr)(const char* src);
 
-__attribute_deprecated__ void escape_str(const char* src, char* dst);
 char* escape(const char* src);
-__attribute_deprecated__ void rename_point_str(const char* src, char* dst);
 char* rename_point(const char* src);
-__attribute_deprecated__ void rename_lower_str(const char* src, char* dst);
 char* rename_lower(const char* src);
-__attribute_deprecated__ void rename_str(const char* src, char* dst);
 char* rename_string(const char* src);
-__attribute_deprecated__ void rename_revert_str(const char* src, char* dst);
 char* rename_revert(const char* src);
 
 #endif
\ No newline at end of file