The following commit has been merged in the master branch:
commit 0450daf56672a75df543c8222353c8042de8c7a1
Author: Patrick Winnertz <win...@debian.org>
Date:   Fri Feb 6 00:09:35 2009 +0100

    Removed type SHELL_ESCAPED_STR in favour of plain char*
    Signed-off-by: Patrick Winnertz <win...@debian.org>

diff --git a/ChangeLog b/ChangeLog
index a4b977f..3fd7ee3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -40,7 +40,7 @@
 
 2009-01-30 Enrico Weigelt, metux ITS <weig...@metux.de>
 
-       * replaced calls to g_free() by g_free()
+       * replaced calls to g_free() by mhl_mem_free()
 
 2009-01-29 Mikhail S. Pobolovets <styx...@gmail.com>
 
diff --git a/mhl/escape.h b/mhl/escape.h
index 485579c..3f07d62 100644
--- a/mhl/escape.h
+++ b/mhl/escape.h
@@ -17,9 +17,6 @@
 #define mhl_shell_escape_nottoesc(x)   \
     (((x)!=0) && (!mhl_shell_escape_toesc((x))))
 
-/* type for escaped string - just for a bit more type safety ;-p */
-typedef struct { char* s; } SHELL_ESCAPED_STR;
-
 /** To be compatible with the general posix command lines we have to escape
  strings for the command line
 
@@ -28,10 +25,10 @@ typedef struct { char* s; } SHELL_ESCAPED_STR;
  /returns
  return escaped string (later need to free)
  */
-static inline SHELL_ESCAPED_STR mhl_shell_escape_dup(const char* src)
+static inline char* mhl_shell_escape_dup(const char* src)
 {
     if ((src==NULL)||(!(*src)))
-       return (SHELL_ESCAPED_STR){ .s = strdup("") };
+       return strdup("");
 
     char* buffer = calloc(1, strlen(src)*2+2);
     char* ptr = buffer;
@@ -50,7 +47,7 @@ static inline SHELL_ESCAPED_STR mhl_shell_escape_dup(const 
char* src)
 
        /* at this point we either have an \0 or an char to escape */
        if (!c)
-           return (SHELL_ESCAPED_STR){ .s = buffer };
+           return buffer;
 
        *ptr = '\\';
        ptr++;
diff --git a/src/complete.c b/src/complete.c
index ed4dfcd..6a7b19d 100644
--- a/src/complete.c
+++ b/src/complete.c
@@ -206,9 +206,7 @@ filename_completion_function (char *text, int state, 
INPUT_COMPLETE_FLAGS flags)
 
        if (temp && (flags & INPUT_COMPLETE_SHELL_ESC))
        {
-           SHELL_ESCAPED_STR e_temp = mhl_shell_escape_dup(temp);
-           g_free (temp);
-           temp = e_temp.s;
+           temp = mhl_shell_escape_dup(temp);
        }
        return temp;
     }
@@ -486,9 +484,8 @@ command_completion_function (char *text, int state, 
INPUT_COMPLETE_FLAGS flags)
        p = filename_completion_function (text, state, flags);
        if (!p)
            return 0;
-       SHELL_ESCAPED_STR e_p = mhl_shell_escape_dup(p);
-       g_free(p);
-       return e_p.s;
+       p = mhl_shell_escape_dup(p);
+       return p;
     }
 
     found = NULL;
@@ -543,9 +540,9 @@ command_completion_function (char *text, int state, 
INPUT_COMPLETE_FLAGS flags)
     }
     if ((p = strrchr (found, PATH_SEP)) != NULL) {
        p++;
-       SHELL_ESCAPED_STR e_p = mhl_shell_escape_dup(p);
+       p = mhl_shell_escape_dup(p);
        g_free(found);
-       return e_p.s;
+       return p;
     }
     return found;
 
diff --git a/vfs/fish.c b/vfs/fish.c
index 06cf483..397d310 100644
--- a/vfs/fish.c
+++ b/vfs/fish.c
@@ -367,7 +367,7 @@ fish_dir_load(struct vfs_class *me, struct vfs_s_inode 
*dir, char *remote_path)
     char buffer[8192];
     struct vfs_s_entry *ent = NULL;
     FILE *logfile;
-    SHELL_ESCAPED_STR quoted_path;
+    char *quoted_path;
     int reply_code;
 
 #if 0
@@ -462,7 +462,7 @@ fish_dir_load(struct vfs_class *me, struct vfs_s_inode 
*dir, char *remote_path)
        "else\n"
                  "echo '### 500'\n"
        "fi\n",
-           quoted_path.s, quoted_path.s, quoted_path.s, quoted_path.s, 
quoted_path.s, quoted_path.s);
+           quoted_path, quoted_path, quoted_path, quoted_path, quoted_path, 
quoted_path);
     g_free (quoted_path.s);
     ent = vfs_s_generate_entry(me, NULL, dir, 0);
     while (1) {
@@ -618,7 +618,7 @@ fish_file_store(struct vfs_class *me, struct vfs_s_fh *fh, 
char *name, char *loc
     struct stat s;
     int was_error = 0;
     int h;
-    SHELL_ESCAPED_STR quoted_name;
+    char *quoted_name;
 
     h = open (localname, O_RDONLY);
 
@@ -659,7 +659,7 @@ fish_file_store(struct vfs_class *me, struct vfs_s_fh *fh, 
char *name, char *loc
      */
 
     quoted_name = mhl_shell_escape_dup(name);
-    print_vfs_message(_("fish: store %s: sending command..."), quoted_name.s );
+    print_vfs_message(_("fish: store %s: sending command..."), quoted_name );
 
     /* FIXME: File size is limited to ULONG_MAX */
     if (!fh->u.fish.append)
@@ -683,8 +683,8 @@ fish_file_store(struct vfs_class *me, struct vfs_s_fh *fh, 
char *name, char *loc
                        "    rest=`expr $rest - $n`\n"
                        "done\n"
                 "}; echo '### 200'\n",
-                (unsigned long) s.st_size, quoted_name.s,
-                quoted_name.s, (unsigned long) s.st_size,
+                (unsigned long) s.st_size, quoted_name,
+                quoted_name, (unsigned long) s.st_size,
                 (unsigned long) s.st_size);
     else
        n = fish_command (me, super, WAIT_REPLY,
@@ -700,8 +700,8 @@ fish_file_store(struct vfs_class *me, struct vfs_s_fh *fh, 
char *name, char *loc
                        "    rest=`expr $rest - $n`\n"
                        "done\n"
                 "}; echo '### 200'\n",
-                (unsigned long) s.st_size, quoted_name.s,
-                quoted_name.s, (unsigned long) s.st_size);
+                (unsigned long) s.st_size, quoted_name,
+                quoted_name, (unsigned long) s.st_size);
 
     if (n != PRELIM) {
        close (h);
@@ -750,7 +750,7 @@ static int
 fish_linear_start (struct vfs_class *me, struct vfs_s_fh *fh, off_t offset)
 {
     char *name;
-    SHELL_ESCAPED_STR quoted_name;
+    char *quoted_name;
     if (offset)
         ERRNOR (E_NOTSUPP, 0);
     name = vfs_s_fullpath (me, fh->ino);
@@ -779,7 +779,7 @@ fish_linear_start (struct vfs_class *me, struct vfs_s_fh 
*fh, off_t offset)
                "else\n"
                "echo '### 500'\n"
                "fi\n",
-               quoted_name.s, quoted_name.s, quoted_name.s, quoted_name.s );
+               quoted_name, quoted_name, quoted_name, quoted_name );
     g_free (quoted_name.s);
     if (offset != PRELIM) ERRNOR (E_REMOTE, 0);
     fh->linear = LS_LINEAR_OPEN;
@@ -889,8 +889,7 @@ fish_send_command(struct vfs_class *me, struct vfs_s_super 
*super, const char *c
 #define PREFIX \
     char buf[BUF_LARGE]; \
     const char *crpath; \
-    char *mpath = mhl_str_dup (path); \
-    SHELL_ESCAPED_STR rpath; \
+    char *rpath, *mpath = g_strdup (path); \
     struct vfs_s_super *super; \
     if (!(crpath = vfs_s_get_path_mangle (me, mpath, &super, 0))) { \
        g_free (mpath); \
@@ -900,7 +899,7 @@ fish_send_command(struct vfs_class *me, struct vfs_s_super 
*super, const char *c
     g_free (mpath);
 
 #define POSTFIX(flags) \
-    g_free (rpath.s); \
+    g_free (rpath); \
     return fish_send_command(me, super, buf, flags);
 
 static int
@@ -910,8 +909,8 @@ fish_chmod (struct vfs_class *me, const char *path, int 
mode)
     g_snprintf(buf, sizeof(buf), "#CHMOD %4.4o /%s\n"
                                 "chmod %4.4o /%s 2>/dev/null\n"
                                 "echo '### 000'\n", 
-           mode & 07777, rpath.s,
-           mode & 07777, rpath.s);
+           mode & 07777, rpath,
+           mode & 07777, rpath);
     POSTFIX(OPT_FLUSH);
 }
 
@@ -920,7 +919,7 @@ static int fish_##name (struct vfs_class *me, const char 
*path1, const char *pat
 { \
     char buf[BUF_LARGE]; \
     const char *crpath1, *crpath2; \
-    char *mpath1, *mpath2; \
+    char *rpath1, *rpath2, *mpath1, *mpath2; \
     struct vfs_s_super *super1, *super2; \
     if (!(crpath1 = vfs_s_get_path_mangle (me, mpath1 = g_strdup(path1), 
&super1, 0))) { \
        g_free (mpath1); \
@@ -930,11 +929,11 @@ static int fish_##name (struct vfs_class *me, const char 
*path1, const char *pat
        g_free (mpath1); \
        g_free (mpath2); \
     } \
-    SHELL_ESCAPED_STR rpath1 = mhl_shell_escape_dup (crpath1); \
+    rpath1 = mhl_shell_escape_dup (crpath1); \
     g_free (mpath1); \
-    SHELL_ESCAPED_STR rpath2 = mhl_shell_escape_dup (crpath2); \
+    rpath2 = mhl_shell_escape_dup (crpath2); \
     g_free (mpath2); \
-    g_snprintf(buf, sizeof(buf), string "\n", rpath1.s, rpath2.s, rpath1.s, 
rpath2.s); \
+    g_snprintf(buf, sizeof(buf), string "\n", rpath1, rpath2, rpath1, rpath2); 
\
     g_free (rpath1.s); \
     g_free (rpath2.s); \
     return fish_send_command(me, super2, buf, OPT_FLUSH); \
@@ -949,15 +948,15 @@ FISH_OP(link,   "#LINK /%s /%s\n"
 
 static int fish_symlink (struct vfs_class *me, const char *setto, const char 
*path)
 {
-    SHELL_ESCAPED_STR qsetto;
+    char *qsetto;
     PREFIX
     qsetto = mhl_shell_escape_dup (setto);
     g_snprintf(buf, sizeof(buf),
             "#SYMLINK %s /%s\n"
            "ln -s %s /%s 2>/dev/null\n"
            "echo '### 000'\n",
-           qsetto.s, rpath.s, qsetto.s, rpath.s);
-    g_free (qsetto.s);
+           qsetto, rpath, qsetto, rpath);
+    g_free (qsetto);
     POSTFIX(OPT_FLUSH);
 }
 
@@ -982,16 +981,16 @@ fish_chown (struct vfs_class *me, const char *path, int 
owner, int group)
            "#CHOWN %s /%s\n"
            "chown %s /%s 2>/dev/null\n"
            "echo '### 000'\n", 
-           sowner, rpath.s,
-           sowner, rpath.s);
+           sowner, rpath,
+           sowner, rpath);
        fish_send_command (me, super, buf, OPT_FLUSH); 
        /* FIXME: what should we report if chgrp succeeds but chown fails? */
        g_snprintf (buf, sizeof(buf),
             "#CHGRP /%s \"/%s\"\n"
            "chgrp %s \"/%s\" 2>/dev/null\n"
            "echo '### 000'\n", 
-           sgroup, rpath.s,
-           sgroup, rpath.s);
+           sgroup, rpath,
+           sgroup, rpath);
        /* fish_send_command(me, super, buf, OPT_FLUSH); */
        POSTFIX (OPT_FLUSH)
     }
@@ -1004,7 +1003,7 @@ static int fish_unlink (struct vfs_class *me, const char 
*path)
             "#DELE /%s\n"
            "rm -f /%s 2>/dev/null\n"
            "echo '### 000'\n",
-           rpath.s, rpath.s);
+           rpath, rpath);
     POSTFIX(OPT_FLUSH);
 }
 
@@ -1018,7 +1017,7 @@ static int fish_mkdir (struct vfs_class *me, const char 
*path, mode_t mode)
             "#MKD /%s\n"
            "mkdir /%s 2>/dev/null\n"
            "echo '### 000'\n",
-           rpath.s, rpath.s);
+           rpath, rpath);
     POSTFIX(OPT_FLUSH);
 }
 
@@ -1029,7 +1028,7 @@ static int fish_rmdir (struct vfs_class *me, const char 
*path)
             "#RMD /%s\n"
            "rmdir /%s 2>/dev/null\n"
            "echo '### 000'\n",
-           rpath.s, rpath.s);
+           rpath, rpath);
     POSTFIX(OPT_FLUSH);
 }
 

-- 
Midnight Commander Development
_______________________________________________
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel

Reply via email to