The following commit has been merged in the master branch:
commit 0434e3de5d20323bed8b7b2dbff74c1d00a221ec
Merge: 3410eb32290abe51e6845483ed7a3723823a768a 
e4a4f77ac28f064d0fd5611a1b48689594289408
Author: Enrico Weigelt, metux IT service <weig...@metux.de>
Date:   Mon Feb 2 20:53:03 2009 +0100

    manually merged 235_remove_g_snprintf

diff --combined ChangeLog
index 2c39360,a54e8eb..3b5bab1
--- a/ChangeLog
+++ b/ChangeLog
@@@ -1,20 -1,7 +1,21 @@@
 +2009-02-01 Enrico Weigelt, metux ITS <weig...@metux.de>
 +
 +      * src/util.c: fixed name_trunc() on NULL or empty parameters
 +      * src/achown.c: fixed unitialized var in init_chown_advanced()
 +        (patch from andrew_b)
 +
 +2009-01-31 Enrico Weigelt, metux ITS <weig...@metux.de>, Patrick Winnertz 
<win...@debian.org>, Slava Zanko <slavaza...@gmail.com>, Sergei Trofimovich  
<sly...@inbox.ru>
 +
 +      * edit/editcmd.c, mhl/escape.h, mhl/string.h, mhl/types.h, 
src/Makefile.am,
 +      * src/boxes.c, src/command.c, src/complete.c, src/complete.h, 
src/file.c,
 +      * src/find.c, src/main.c, src/panelize.c, src/util.c, src/utilunix.c,
 +      * src/widget.c, src/widget.h, src/wtools.c, vfs/fish.c:
 +        fixed shell escaping issues in commandline completion engine
 +
  2009-01-31 Enrico Weigelt, metux ITS <weig...@metux.de>
  
        * replaced buggy concat_dir_and_file() by mhl_str_dir_plus_file() (in 
mhl/string.h)
+       * replaced g_snprintf() by snprintf()
  
  2009-01-30 Enrico Weigelt, metux ITS <weig...@metux.de>
  
@@@ -31,11 -18,6 +32,11 @@@
          This solves "strange" rename cases, when copying/moving is performed 
into
          deleted directory.
  
 +2009-01-27 Enrico Weigelt, metux ITS <weig...@metux.de>
 +
 +      * mhl/escape.h, src/complete.c, vfs/fish.c: introduced new type 
 +        SHELL_ESCAPED_STR for more type safety
 +
  2009-01-27 Enrico Weigelt, metux IT service <weig...@metux.de>
  
        * mhl/escape.h, mhl/string.h: fixed comments to use /* ... */
diff --combined edit/editcmd.c
index 07286b6,792322d..7dae88a
--- a/edit/editcmd.c
+++ b/edit/editcmd.c
@@@ -626,7 -626,7 +626,7 @@@ edit_raw_key_query (const char *heading
                    NULL, heading,
                    DLG_CENTER | DLG_TRYUP | DLG_WANT_TAB);
      add_widget (raw_dlg,
 -              input_new (3 - cancel, w - 5, INPUT_COLOR, 2, "", 0));
 +              input_new (3 - cancel, w - 5, INPUT_COLOR, 2, "", 0, 
INPUT_COMPLETE_DEFAULT));
      add_widget (raw_dlg, label_new (3 - cancel, 2, query));
      if (cancel)
        add_widget (raw_dlg,
@@@ -2337,7 -2337,7 +2337,7 @@@ edit_goto_cmd (WEdit *edit
      char *error;
      char s[32];
  
-     g_snprintf (s, sizeof (s), "%ld", line);
+     snprintf (s, sizeof (s), "%ld", line);
      f = input_dialog (_(" Goto line "), _(" Enter line: "), 
MC_HISTORY_EDIT_GOTO_LINE,
                      line ? s : "");
      if (!f)
diff --combined src/boxes.c
index 48ac3a9,23030ec..a46aeec
--- a/src/boxes.c
+++ b/src/boxes.c
@@@ -197,7 -197,7 +197,7 @@@ display_init (int radio_sel, char *init
  
      status =
        input_new (10, 9, INPUT_COLOR, DISPLAY_X - 14, _status[radio_sel],
 -                 "mini-input");
 +                 "mini-input", INPUT_COMPLETE_DEFAULT);
      add_widget (dd, status);
      input_set_point (status, 0);
  
@@@ -207,7 -207,7 +207,7 @@@
  
      user =
        input_new (7, 9, INPUT_COLOR, DISPLAY_X - 14, init_text,
 -                 "user-fmt-input");
 +                 "user-fmt-input", INPUT_COMPLETE_DEFAULT);
      add_widget (dd, user);
      input_set_point (user, 0);
  
@@@ -571,7 -571,7 +571,7 @@@ sel_charset_button (int action
        : codepages[new_display_codepage].name;
  
      /* avoid strange bug with label repainting */
-     g_snprintf (buf, sizeof (buf), "%-27s", cpname);
+     snprintf (buf, sizeof (buf), "%-27s", cpname);
      label_set_text (cplabel, buf);
      return 0;
  }
@@@ -772,12 -772,12 +772,12 @@@ configure_vfs (void
      ret_use_netrc = use_netrc;
      ret_ftpfs_use_passive_connections = ftpfs_use_passive_connections;
      ret_ftpfs_use_passive_connections_over_proxy = 
ftpfs_use_passive_connections_over_proxy;
-     g_snprintf(buffer3, sizeof (buffer3), "%i", ftpfs_directory_timeout);
+     snprintf(buffer3, sizeof (buffer3), "%i", ftpfs_directory_timeout);
      confvfs_widgets[8].text = buffer3;
      confvfs_widgets[10].text = ftpfs_anonymous_passwd;
      confvfs_widgets[5].text = ftpfs_proxy_host;
  #endif
-     g_snprintf (buffer2, sizeof (buffer2), "%i", vfs_timeout);
+     snprintf (buffer2, sizeof (buffer2), "%i", vfs_timeout);
      confvfs_widgets [3 + VFS_WIDGETBASE].text = buffer2;
  
      if (quick_dialog (&confvfs_dlg) != B_CANCEL) {
@@@ -1085,17 -1085,17 +1085,17 @@@ vfs_smb_get_authinfo (const char *host
  
      g_free (title);
  
 -    in_user  = input_new (5, istart, INPUT_COLOR, ilen, user, "auth_name");
 +    in_user  = input_new (5, istart, INPUT_COLOR, ilen, user, "auth_name", 
INPUT_COMPLETE_DEFAULT);
      add_widget (auth_dlg, in_user);
  
 -    in_domain = input_new (3, istart, INPUT_COLOR, ilen, domain, 
"auth_domain");
 +    in_domain = input_new (3, istart, INPUT_COLOR, ilen, domain, 
"auth_domain", INPUT_COMPLETE_DEFAULT);
      add_widget (auth_dlg, in_domain);
      add_widget (auth_dlg, button_new (9, b2, B_CANCEL, NORMAL_BUTTON,
                   buts[1], 0));
      add_widget (auth_dlg, button_new (9, b0, B_ENTER, DEFPUSH_BUTTON,
                   buts[0], 0));
  
 -    in_password  = input_new (7, istart, INPUT_COLOR, ilen, "", 
"auth_password");
 +    in_password  = input_new (7, istart, INPUT_COLOR, ilen, "", 
"auth_password", INPUT_COMPLETE_DEFAULT);
      in_password->completion_flags = 0;
      in_password->is_password = 1;
      add_widget (auth_dlg, in_password);
diff --combined src/charsets.c
index f2e69e0,ec1aca1..4e807c0
--- a/src/charsets.c
+++ b/src/charsets.c
@@@ -27,8 -27,6 +27,8 @@@
  
  #include <iconv.h>
  
 +#include <mhl/string.h>
 +
  #include "global.h"
  #include "charsets.h"
  
@@@ -198,7 -196,7 +198,7 @@@ init_translation_table (int cpsource, i
  
      cd = iconv_open (cpdisp, cpsour);
      if (cd == (iconv_t) - 1) {
-       g_snprintf (errbuf, sizeof (errbuf),
+       snprintf (errbuf, sizeof (errbuf),
                    _("Cannot translate from %s to %s"), cpsour, cpdisp);
        return errbuf;
      }
@@@ -212,7 -210,7 +212,7 @@@
  
      cd = iconv_open (cpsour, cpdisp);
      if (cd == (iconv_t) - 1) {
-       g_snprintf (errbuf, sizeof (errbuf),
+       snprintf (errbuf, sizeof (errbuf),
                    _("Cannot translate from %s to %s"), cpdisp, cpsour);
        return errbuf;
      }
diff --combined src/file.c
index cb61307,1ae15fd..5fb0bfd
--- a/src/file.c
+++ b/src/file.c
@@@ -50,8 -50,6 +50,8 @@@
  #include <sys/stat.h>
  #include <unistd.h>
  
 +#include <mhl/memory.h>
 +#include <mhl/escape.h>
  #include <mhl/string.h>
  
  #include "global.h"
@@@ -67,7 -65,6 +67,7 @@@
  #include "widget.h"
  #include "wtools.h"
  #include "background.h"               /* we_are_background */
 +#include "util.h"
  
  /* Needed for current_panel, other_panel and WTree */
  #include "dir.h"
@@@ -181,43 -178,37 +181,43 @@@ do_transform_source (FileOpContext *ctx
      for (next_reg = 1, j = 0, k = 0; j < strlen (ctx->dest_mask); j++) {
        switch (ctx->dest_mask[j]) {
        case '\\':
 -          j++;
 -          if (!isdigit ((unsigned char) ctx->dest_mask[j])) {
 -              /* Backslash followed by non-digit */
 -              switch (ctx->dest_mask[j]) {
 -              case 'U':
 -                  case_conv |= UP_SECT;
 -                  case_conv &= ~LOW_SECT;
 -                  break;
 -              case 'u':
 -                  case_conv |= UP_CHAR;
 -                  break;
 -              case 'L':
 -                  case_conv |= LOW_SECT;
 -                  case_conv &= ~UP_SECT;
 -                  break;
 -              case 'l':
 -                  case_conv |= LOW_CHAR;
 -                  break;
 -              case 'E':
 -                  case_conv = NO_CONV;
 -                  break;
 -              default:
 -                  /* Backslash as quote mark */
 -                  fntarget[k++] =
 -                      convert_case (ctx->dest_mask[j], &case_conv);
 -              }
 +          if (mhl_shell_is_char_escaped (&ctx->dest_mask[j])){
 +              fntarget[k++] = ctx->dest_mask[j++];
 +              fntarget[k++] = ctx->dest_mask[j];
                break;
            } else {
 -              /* Backslash followed by digit */
 -              next_reg = ctx->dest_mask[j] - '0';
 -              /* Fall through */
 +              j++;
 +              if (!isdigit ((unsigned char) ctx->dest_mask[j])) {
 +                  /* Backslash followed by non-digit */
 +                  switch (ctx->dest_mask[j]) {
 +                  case 'U':
 +                      case_conv |= UP_SECT;
 +                      case_conv &= ~LOW_SECT;
 +                      break;
 +                  case 'u':
 +                      case_conv |= UP_CHAR;
 +                      break;
 +                  case 'L':
 +                      case_conv |= LOW_SECT;
 +                      case_conv &= ~UP_SECT;
 +                      break;
 +                  case 'l':
 +                      case_conv |= LOW_CHAR;
 +                      break;
 +                  case 'E':
 +                      case_conv = NO_CONV;
 +                      break;
 +                  default:
 +                      /* Backslash as quote mark */
 +                      fntarget[k++] =
 +                          convert_case (ctx->dest_mask[j], &case_conv);
 +                  }
 +                  break;
 +              } else {
 +                  /* Backslash followed by digit */
 +                  next_reg = ctx->dest_mask[j] - '0';
 +                  /* Fall through */
 +              }
            }
  
        case '*':
@@@ -802,7 -793,7 +802,7 @@@ copy_file_file (FileOpContext *ctx, con
            }
        }
  
 -      if (!appending) {
 +      if (!appending && ctx->preserve) {
            while (mc_chmod (dst_path, (src_mode & ctx->umask_kill))) {
                temp_status = file_error (
                        _(" Cannot chmod target file \"%s\" \n %s "), dst_path);
@@@ -1701,10 -1692,10 +1701,10 @@@ panel_operate_generate_prompt (const WP
  
      if (single_source) {
        i = fmd_xlen - strlen (format_string) - 4;
-       g_snprintf (cmd_buf, sizeof (cmd_buf), format_string,
+       snprintf (cmd_buf, sizeof (cmd_buf), format_string,
                    name_trunc (single_source, i));
      } else {
-       g_snprintf (cmd_buf, sizeof (cmd_buf), format_string,
+       snprintf (cmd_buf, sizeof (cmd_buf), format_string,
                    panel->marked);
        i = strlen (cmd_buf) + 6 - fmd_xlen;
        if (i > 0) {
@@@ -1905,7 -1896,7 +1905,7 @@@ panel_operate (void *source_panel, File
                g_free (dest);
                dest = temp2;
                temp = NULL;
 -
 +              
                switch (operation) {
                case OP_COPY:
                    /*
@@@ -1997,9 -1988,6 +1997,9 @@@
                else {
                    char *temp2 = mhl_str_dir_plus_file (dest, temp);
  
 +                  source_with_path = mhl_shell_unescape_buf(source_with_path);
 +                  temp2 = mhl_shell_unescape_buf(temp2);
 +
                    switch (operation) {
                    case OP_COPY:
                        /*
@@@ -2126,7 -2114,7 +2126,7 @@@ real_do_file_error (enum OperationMode 
  int
  file_error (const char *format, const char *file)
  {
-     g_snprintf (cmd_buf, sizeof (cmd_buf), format,
+     snprintf (cmd_buf, sizeof (cmd_buf), format,
                path_trunc (file, 30), unix_error_string (errno));
  
      return do_file_error (cmd_buf);
@@@ -2142,7 -2130,7 +2142,7 @@@ files_error (const char *format, const 
      strcpy (nfile1, path_trunc (file1, 15));
      strcpy (nfile2, path_trunc (file2, 15));
  
-     g_snprintf (cmd_buf, sizeof (cmd_buf), format, nfile1, nfile2,
+     snprintf (cmd_buf, sizeof (cmd_buf), format, nfile1, nfile2,
                unix_error_string (errno));
  
      return do_file_error (cmd_buf);
diff --combined src/find.c
index ca06df9,bb0a1e2..8d90bc8
--- a/src/find.c
+++ b/src/find.c
@@@ -276,16 -276,16 +276,16 @@@ find_parameters (char **start_dir, cha
      add_widget (find_dlg, case_sense);
  
      in_with =
 -      input_new (8, istart, INPUT_COLOR, ilen, in_contents, "content");
 +      input_new (8, istart, INPUT_COLOR, ilen, in_contents, "content", 
INPUT_COMPLETE_DEFAULT);
      add_widget (find_dlg, in_with);
  
      add_widget (find_dlg, recursively_cbox);
      in_name =
 -      input_new (5, istart, INPUT_COLOR, ilen, in_start_name, "name");
 +      input_new (5, istart, INPUT_COLOR, ilen, in_start_name, "name", 
INPUT_COMPLETE_DEFAULT);
      add_widget (find_dlg, in_name);
  
      in_start =
 -      input_new (3, istart, INPUT_COLOR, ilen, in_start_dir, "start");
 +      input_new (3, istart, INPUT_COLOR, ilen, in_start_dir, "start", 
INPUT_COMPLETE_DEFAULT);
      add_widget (find_dlg, in_start);
  
      add_widget (find_dlg, label_new (8, 3, labs[2]));
@@@ -530,7 -530,7 +530,7 @@@ search_content (Dlg_head *h, const cha
      if (file_fd == -1)
        return 0;
  
-     g_snprintf (buffer, sizeof (buffer), _("Grepping in %s"), name_trunc 
(filename, FIND2_X_USE));
+     snprintf (buffer, sizeof (buffer), _("Grepping in %s"), name_trunc 
(filename, FIND2_X_USE));
  
      status_update (buffer);
      mc_refresh ();
@@@ -666,7 -666,7 +666,7 @@@ do_search (struct Dlg_head *h
            if (verbose){
                char buffer [BUF_SMALL];
  
-               g_snprintf (buffer, sizeof (buffer), _("Searching %s"), 
+               snprintf (buffer, sizeof (buffer), _("Searching %s"), 
                            name_trunc (directory, FIND2_X_USE));
                status_update (buffer);
            }
diff --combined src/main.c
index 89fd0fd,359d549..a24c337
--- a/src/main.c
+++ b/src/main.c
@@@ -67,6 -67,7 +67,6 @@@
  #include "widget.h"
  #include "command.h"
  #include "wtools.h"
 -#include "complete.h"         /* For the free_completion */
  
  #include "chmod.h"
  #include "chown.h"
@@@ -1649,7 -1650,7 +1649,7 @@@ load_hint (int force
      } else {
        char text[BUF_SMALL];
  
-       g_snprintf (text, sizeof (text), _("GNU Midnight Commander %s\n"),
+       snprintf (text, sizeof (text), _("GNU Midnight Commander %s\n"),
                    VERSION);
        set_hintbar (text);
      }
diff --combined src/util.c
index aebf59a,6f5d443..deeff58
--- a/src/util.c
+++ b/src/util.c
@@@ -35,7 -35,6 +35,7 @@@
  #include <sys/stat.h>
  #include <unistd.h>
  
 +#include <mhl/escape.h>
  #include <mhl/string.h>
  
  #include "global.h"
@@@ -230,27 -229,22 +230,27 @@@ fake_name_quote (const char *s, int quo
   * Return static buffer, no need to free() it.
   */
  const char *
 -name_trunc (const char *txt, int trunc_len)
 +name_trunc (const char *txt, size_t trunc_len)
  {
      static char x[MC_MAXPATHLEN + MC_MAXPATHLEN];
 -    int txt_len;
 +    size_t txt_len;
      char *p;
  
 -    if ((size_t) trunc_len > sizeof (x) - 1) {
 +    if (!txt)
 +      return NULL;
 +    if (!*txt)
 +      return txt;
 +
 +    if (trunc_len > sizeof (x) - 1) {
        trunc_len = sizeof (x) - 1;
      }
      txt_len = strlen (txt);
      if (txt_len <= trunc_len) {
        strcpy (x, txt);
      } else {
 -      int y = (trunc_len / 2) + (trunc_len % 2);
 -      strncpy (x, txt, y);
 -      strncpy (x + y, txt + txt_len - (trunc_len / 2), trunc_len / 2);
 +      size_t y = (trunc_len / 2) + (trunc_len % 2);
 +      strncpy (x, txt, (size_t) y);
 +      strncpy (x + y, txt + (txt_len - (trunc_len / 2)), trunc_len / 2);
        x[y] = '~';
      }
      x[trunc_len] = 0;
@@@ -266,7 -260,7 +266,7 @@@
   * reasons.
   */
  const char *
 -path_trunc (const char *path, int trunc_len) {
 +path_trunc (const char *path, size_t trunc_len) {
      const char *ret;
      char *secure_path = strip_password (g_strdup (path), 1);
      
@@@ -291,7 -285,7 +291,7 @@@ size_trunc (double size
            xtra = "M";
        }
      }
-     g_snprintf (x, sizeof (x), "%.0f%s", (size/divisor), xtra);
+     snprintf (x, sizeof (x), "%.0f%s", (size/divisor), xtra);
      return x;
  }
  
@@@ -350,18 -344,18 +350,18 @@@ size_trunc_len (char *buffer, int len, 
        if (size == 0) {
            if (j == units) {
                /* Empty files will print "0" even with minimal width.  */
-               g_snprintf (buffer, len + 1, "0");
+               snprintf (buffer, len + 1, "0");
                break;
            }
  
            /* Use "~K" or just "K" if len is 1.  Use "B" for bytes.  */
-           g_snprintf (buffer, len + 1, (len > 1) ? "~%s" : "%s",
+           snprintf (buffer, len + 1, (len > 1) ? "~%s" : "%s",
                        (j > 1) ? suffix[j - 1] : "B");
            break;
        }
  
        if (size < power10 [len - (j > 0)]) {
-           g_snprintf (buffer, len + 1, "%lu%s", (unsigned long) size, 
suffix[j]);
+           snprintf (buffer, len + 1, "%lu%s", (unsigned long) size, 
suffix[j]);
            break;
        }
  
@@@ -635,7 -629,7 +635,7 @@@ set_int (const char *file, const char *
  {
      char buffer [BUF_TINY];
  
-     g_snprintf (buffer, sizeof (buffer), "%d", value);
+     snprintf (buffer, sizeof (buffer), "%d", value);
      return WritePrivateProfileString (app_text, key, buffer, file);
  }
  
@@@ -851,11 -845,11 +851,11 @@@ unix_error_string (int error_num
      gchar *strerror_currentlocale;
        
      strerror_currentlocale = g_locale_from_utf8(g_strerror (error_num), -1, 
NULL, NULL, NULL);
-     g_snprintf (buffer, sizeof (buffer), "%s (%d)",
+     snprintf (buffer, sizeof (buffer), "%s (%d)",
                strerror_currentlocale, error_num);
      g_free(strerror_currentlocale);
  #else
-     g_snprintf (buffer, sizeof (buffer), "%s (%d)",
+     snprintf (buffer, sizeof (buffer), "%s (%d)",
                g_strerror (error_num), error_num);
  #endif
      return buffer;
@@@ -1522,3 -1516,4 +1522,3 @@@ Q_ (const char *s
      sep = strchr(result, '|');
      return (sep != NULL) ? sep + 1 : result;
  }
 -
diff --combined src/utilunix.c
index 4b088e5,7cefb5a..77b07b9
--- a/src/utilunix.c
+++ b/src/utilunix.c
@@@ -41,8 -41,6 +41,8 @@@
  #endif
  #include <unistd.h>
  
 +#include <mhl/string.h>
 +
  #include "global.h"
  #include "execute.h"
  #include "wtools.h"           /* message() */
@@@ -95,7 -93,7 +95,7 @@@ char *get_owner (int uid
        return pwd->pw_name;
      }
      else {
-       g_snprintf (ibuf, sizeof (ibuf), "%d", uid);
+       snprintf (ibuf, sizeof (ibuf), "%d", uid);
        return ibuf;
      }
  }
@@@ -115,7 -113,7 +115,7 @@@ char *get_group (int gid
        i_cache_add (gid, gid_cache, GID_CACHE_SIZE, grp->gr_name, &gid_last);
        return grp->gr_name;
      } else {
-       g_snprintf (gbuf, sizeof (gbuf), "%d", gid);
+       snprintf (gbuf, sizeof (gbuf), "%d", gid);
        return gbuf;
      }
  }
@@@ -256,10 -254,10 +256,10 @@@ mc_tmpdir (void
      pwd = getpwuid (getuid ());
  
      if (pwd)
-       g_snprintf (buffer, sizeof (buffer), "%s/mc-%s", sys_tmp,
+       snprintf (buffer, sizeof (buffer), "%s/mc-%s", sys_tmp,
                pwd->pw_name);
      else
-       g_snprintf (buffer, sizeof (buffer), "%s/mc-%lu", sys_tmp,
+       snprintf (buffer, sizeof (buffer), "%s/mc-%lu", sys_tmp,
                (unsigned long) getuid ());
  
      canonicalize_pathname (buffer);
@@@ -308,11 -306,11 +308,11 @@@
        if (fallback_ok) {
            fprintf (stderr, _("Temporary files will be created in %s\n"),
                     sys_tmp);
-           g_snprintf (buffer, sizeof (buffer), "%s", sys_tmp);
+           snprintf (buffer, sizeof (buffer), "%s", sys_tmp);
            error = NULL;
        } else {
            fprintf (stderr, _("Temporary files will not be created\n"));
-           g_snprintf (buffer, sizeof (buffer), "%s", "/dev/null/");
+           snprintf (buffer, sizeof (buffer), "%s", "/dev/null/");
        }
  
        fprintf (stderr, "%s\n", _("Press any key to continue..."));
@@@ -428,7 -426,7 +428,7 @@@ canonicalize_pathname (char *path
        if (p[0] == PATH_SEP && p[1] == PATH_SEP) {
            s = p + 1;
            while (*(++s) == PATH_SEP);
 -          strcpy (p + 1, s);
 +          mhl_strmove (p + 1, s);
        }
        p++;
      }
@@@ -437,7 -435,7 +437,7 @@@
      p = lpath;
      while (*p) {
        if (p[0] == PATH_SEP && p[1] == '.' && p[2] == PATH_SEP)
 -          strcpy (p, p + 2);
 +          mhl_strmove (p, p + 2);
        else
            p++;
      }
@@@ -453,7 -451,7 +453,7 @@@
            lpath[1] = 0;
            return;
        } else {
 -          strcpy (lpath, lpath + 2);
 +          mhl_strmove (lpath, lpath + 2);
        }
      }
  
@@@ -499,10 -497,10 +499,10 @@@
        if (p[3] != 0) {
            if (s == lpath && *s == PATH_SEP) {
                /* "/../foo" -> "/foo" */
 -              strcpy (s + 1, p + 4);
 +              mhl_strmove (s + 1, p + 4);
            } else {
                /* "token/../foo" -> "foo" */
 -              strcpy (s, p + 4);
 +              mhl_strmove (s, p + 4);
            }
            p = (s > lpath) ? s - 1 : s;
            continue;
diff --combined src/widget.c
index f85cc2a,4312677..597438f
--- a/src/widget.c
+++ b/src/widget.c
@@@ -43,6 -43,7 +43,6 @@@
  #include "dialog.h"
  #include "widget.h"
  #include "win.h"
 -#include "complete.h"
  #include "key.h"      /* XCTRL and ALT macros  */
  #include "profile.h"  /* for history loading and saving */
  #include "wtools.h"   /* For common_dialog_repaint() */
@@@ -157,15 -158,15 +157,15 @@@ button_callback (Widget *w, widget_msg_
  
        switch (b->flags) {
        case DEFPUSH_BUTTON:
-           g_snprintf (buf, sizeof (buf), "[< %s >]", b->text);
+           snprintf (buf, sizeof (buf), "[< %s >]", b->text);
            off = 3;
            break;
        case NORMAL_BUTTON:
-           g_snprintf (buf, sizeof (buf), "[ %s ]", b->text);
+           snprintf (buf, sizeof (buf), "[ %s ]", b->text);
            off = 2;
            break;
        case NARROW_BUTTON:
-           g_snprintf (buf, sizeof (buf), "[%s]", b->text);
+           snprintf (buf, sizeof (buf), "[%s]", b->text);
            off = 1;
            break;
        case HIDDEN_BUTTON:
@@@ -870,7 -871,7 +870,7 @@@ history_get (const char *input_name
      for (i = 0;; i++) {
        char key_name[BUF_TINY];
        char this_entry[BUF_LARGE];
-       g_snprintf (key_name, sizeof (key_name), "%d", i);
+       snprintf (key_name, sizeof (key_name), "%d", i);
        GetPrivateProfileString (input_name, key_name, "", this_entry,
                                 sizeof (this_entry), profile);
        if (!*this_entry)
@@@ -934,7 -935,7 +934,7 @@@ history_put (const char *input_name, GL
        /* We shouldn't have null entries, but let's be sure */
        if (text && *text) {
            char key_name[BUF_TINY];
-           g_snprintf (key_name, sizeof (key_name), "%d", i++);
+           snprintf (key_name, sizeof (key_name), "%d", i++);
            WritePrivateProfileString (input_name, key_name, text,
                                       profile);
        }
@@@ -1659,7 -1660,7 +1659,7 @@@ input_event (Gpm_Event * event, void *d
  
  WInput *
  input_new (int y, int x, int color, int len, const char *def_text,
 -         const char *histname)
 +         const char *histname, INPUT_COMPLETE_FLAGS completion_flags)
  {
      WInput *in = g_new (WInput, 1);
      int initial_buffer_len;
@@@ -1688,7 -1689,9 +1688,7 @@@
      initial_buffer_len = 1 + max ((size_t) len, strlen (def_text));
      in->widget.options |= W_IS_INPUT;
      in->completions = NULL;
 -    in->completion_flags =
 -      INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_HOSTNAMES |
 -      INPUT_COMPLETE_VARIABLES | INPUT_COMPLETE_USERNAMES;
 +    in->completion_flags = completion_flags;
      in->current_max_len = initial_buffer_len;
      in->buffer = g_malloc (initial_buffer_len);
      in->color = color;
diff --combined vfs/fish.c
index 6d45387,1723d04..d01e6cd
--- a/vfs/fish.c
+++ b/vfs/fish.c
@@@ -144,7 -144,7 +144,7 @@@ fish_command (struct vfs_class *me, str
      enable_interrupt_key ();
  
      status = write (SUP.sockw, str, strlen (str));
 -    g_free (str);
 +    mhl_mem_free (str);
  
      disable_interrupt_key ();
      if (status < 0)
@@@ -168,10 -168,10 +168,10 @@@ fish_free_archive (struct vfs_class *me
        close (SUP.sockr);
        SUP.sockw = SUP.sockr = -1;
      }
 -    g_free (SUP.host);
 -    g_free (SUP.user);
 -    g_free (SUP.cwdir);
 -    g_free (SUP.password);
 +    mhl_mem_free (SUP.host);
 +    mhl_mem_free (SUP.user);
 +    mhl_mem_free (SUP.cwdir);
 +    mhl_mem_free (SUP.password);
  }
  
  static void
@@@ -228,7 -228,7 +228,7 @@@ fish_open_archive_int (struct vfs_clas
        if (SUP.flags > FISH_FLAG_RSH)
        {
            argv[i++] = "-p";
-           g_snprintf (gbuf, sizeof (gbuf), "%d", SUP.flags);
+           snprintf (gbuf, sizeof (gbuf), "%d", SUP.flags);
            argv[i++] = gbuf;
        }
  
@@@ -260,7 -260,7 +260,7 @@@
                p = g_strconcat (_(" fish: Password required for "),
                                 SUP.user, " ", (char *) NULL);
                op = vfs_get_password (p);
 -              g_free (p);
 +              mhl_mem_free (p);
                if (op == NULL)
                    ERRNOR (EPERM, -1);
                SUP.password = op;
@@@ -323,7 -323,7 +323,7 @@@ fish_open_archive (struct vfs_class *me
      p = vfs_split_url (strchr (op, ':') + 1, &host, &user, &flags,
                       &password, 0, URL_NOSLASH);
  
 -    g_free (p);
 +    mhl_mem_free (p);
  
      SUP.host = host;
      SUP.user = user;
@@@ -350,12 -350,12 +350,12 @@@ fish_archive_same (struct vfs_class *me
      op = vfs_split_url (strchr (op, ':') + 1, &host, &user, &flags, 0, 0,
                        URL_NOSLASH);
  
 -    g_free (op);
 +    mhl_mem_free (op);
  
      flags = ((strcmp (host, SUP.host) == 0)
             && (strcmp (user, SUP.user) == 0) && (flags == SUP.flags));
 -    g_free (host);
 -    g_free (user);
 +    mhl_mem_free (host);
 +    mhl_mem_free (user);
  
      return flags;
  }
@@@ -367,7 -367,7 +367,7 @@@ fish_dir_load(struct vfs_class *me, str
      char buffer[8192];
      struct vfs_s_entry *ent = NULL;
      FILE *logfile;
 -    char *quoted_path;
 +    SHELL_ESCAPED_STR quoted_path;
      int reply_code;
  
  #if 0
@@@ -462,8 -462,8 +462,8 @@@
        "else\n"
                  "echo '### 500'\n"
        "fi\n",
 -          quoted_path, quoted_path, quoted_path, quoted_path, quoted_path, 
quoted_path);
 -    mhl_mem_free (quoted_path);
 +          quoted_path.s, quoted_path.s, quoted_path.s, quoted_path.s, 
quoted_path.s, quoted_path.s);
 +    mhl_mem_free (quoted_path.s);
      ent = vfs_s_generate_entry(me, NULL, dir, 0);
      while (1) {
        int res = vfs_s_get_line_interruptible (me, buffer, sizeof (buffer), 
SUP.sockr); 
@@@ -594,7 -594,7 +594,7 @@@
      vfs_s_free_entry (me, ent);
      reply_code = fish_decode_reply(buffer + 4, 0);
      if (reply_code == COMPLETE) {
 -      g_free (SUP.cwdir);
 +      mhl_mem_free (SUP.cwdir);
        SUP.cwdir = g_strdup (remote_path);
        print_vfs_message (_("%s: done."), me->name);
        return 0;
@@@ -618,7 -618,7 +618,7 @@@ fish_file_store(struct vfs_class *me, s
      struct stat s;
      int was_error = 0;
      int h;
 -    char *quoted_name;
 +    SHELL_ESCAPED_STR quoted_name;
  
      h = open (localname, O_RDONLY);
  
@@@ -659,7 -659,7 +659,7 @@@
       */
  
      quoted_name = mhl_shell_escape_dup(name);
 -    print_vfs_message(_("fish: store %s: sending command..."), quoted_name );
 +    print_vfs_message(_("fish: store %s: sending command..."), quoted_name.s 
);
  
      /* FIXME: File size is limited to ULONG_MAX */
      if (!fh->u.fish.append)
@@@ -683,8 -683,8 +683,8 @@@
                        "    rest=`expr $rest - $n`\n"
                        "done\n"
                 "}; echo '### 200'\n",
 -               (unsigned long) s.st_size, quoted_name,
 -               quoted_name, (unsigned long) s.st_size,
 +               (unsigned long) s.st_size, quoted_name.s,
 +               quoted_name.s, (unsigned long) s.st_size,
                 (unsigned long) s.st_size);
      else
        n = fish_command (me, super, WAIT_REPLY,
@@@ -700,8 -700,8 +700,8 @@@
                        "    rest=`expr $rest - $n`\n"
                        "done\n"
                 "}; echo '### 200'\n",
 -               (unsigned long) s.st_size, quoted_name,
 -               quoted_name, (unsigned long) s.st_size);
 +               (unsigned long) s.st_size, quoted_name.s,
 +               quoted_name.s, (unsigned long) s.st_size);
  
      if (n != PRELIM) {
        close (h);
@@@ -735,14 -735,14 +735,14 @@@
                          (unsigned long) s.st_size);
      }
      close(h);
 -    mhl_mem_free(quoted_name);
 +    mhl_mem_free(quoted_name.s);
      if ((fish_get_reply (me, SUP.sockr, NULL, 0) != COMPLETE) || was_error)
          ERRNOR (E_REMOTE, -1);
      return 0;
  error_return:
      close(h);
      fish_get_reply(me, SUP.sockr, NULL, 0);
 -    mhl_mem_free(quoted_name);
 +    mhl_mem_free(quoted_name.s);
      return -1;
  }
  
@@@ -750,7 -750,7 +750,7 @@@ static in
  fish_linear_start (struct vfs_class *me, struct vfs_s_fh *fh, off_t offset)
  {
      char *name;
 -    char *quoted_name;
 +    SHELL_ESCAPED_STR quoted_name;
      if (offset)
          ERRNOR (E_NOTSUPP, 0);
      name = vfs_s_fullpath (me, fh->ino);
@@@ -779,8 -779,8 +779,8 @@@
                "else\n"
                "echo '### 500'\n"
                "fi\n",
 -              quoted_name, quoted_name, quoted_name, quoted_name );
 -    g_free (quoted_name);
 +              quoted_name.s, quoted_name.s, quoted_name.s, quoted_name.s );
 +    mhl_mem_free (quoted_name.s);
      if (offset != PRELIM) ERRNOR (E_REMOTE, 0);
      fh->linear = LS_LINEAR_OPEN;
      fh->u.fish.got = 0;
@@@ -889,29 -889,28 +889,29 @@@ fish_send_command(struct vfs_class *me
  #define PREFIX \
      char buf[BUF_LARGE]; \
      const char *crpath; \
 -    char *rpath, *mpath = g_strdup (path); \
 +    char *mpath = mhl_str_dup (path); \
 +    SHELL_ESCAPED_STR rpath; \
      struct vfs_s_super *super; \
      if (!(crpath = vfs_s_get_path_mangle (me, mpath, &super, 0))) { \
 -      g_free (mpath); \
 +      mhl_mem_free (mpath); \
        return -1; \
      } \
      rpath = mhl_shell_escape_dup(crpath); \
 -    g_free (mpath);
 +    mhl_mem_free (mpath);
  
  #define POSTFIX(flags) \
 -    g_free (rpath); \
 +    mhl_mem_free (rpath.s); \
      return fish_send_command(me, super, buf, flags);
  
  static int
  fish_chmod (struct vfs_class *me, const char *path, int mode)
  {
      PREFIX
-     g_snprintf(buf, sizeof(buf), "#CHMOD %4.4o /%s\n"
+     snprintf(buf, sizeof(buf), "#CHMOD %4.4o /%s\n"
                                 "chmod %4.4o /%s 2>/dev/null\n"
                                 "echo '### 000'\n", 
 -          mode & 07777, rpath,
 -          mode & 07777, rpath);
 +          mode & 07777, rpath.s,
 +          mode & 07777, rpath.s);
      POSTFIX(OPT_FLUSH);
  }
  
@@@ -920,24 -919,24 +920,24 @@@ static int fish_##name (struct vfs_clas
  { \
      char buf[BUF_LARGE]; \
      const char *crpath1, *crpath2; \
 -    char *rpath1, *rpath2, *mpath1, *mpath2; \
 +    char *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); \
 +      mhl_mem_free (mpath1); \
        return -1; \
      } \
      if (!(crpath2 = vfs_s_get_path_mangle (me, mpath2 = g_strdup(path2), 
&super2, 0))) { \
 -      g_free (mpath1); \
 -      g_free (mpath2); \
 +      mhl_mem_free (mpath1); \
 +      mhl_mem_free (mpath2); \
        return -1; \
      } \
 -    rpath1 = mhl_shell_escape_dup (crpath1); \
 -    g_free (mpath1); \
 -    rpath2 = mhl_shell_escape_dup (crpath2); \
 -    g_free (mpath2); \
 -    snprintf(buf, sizeof(buf), string "\n", rpath1, rpath2, rpath1, rpath2); \
 -    mhl_mem_free (rpath1); \
 -    mhl_mem_free (rpath2); \
 +    SHELL_ESCAPED_STR rpath1 = mhl_shell_escape_dup (crpath1); \
 +    mhl_mem_free (mpath1); \
 +    SHELL_ESCAPED_STR rpath2 = mhl_shell_escape_dup (crpath2); \
 +    mhl_mem_free (mpath2); \
 +    g_snprintf(buf, sizeof(buf), string "\n", rpath1.s, rpath2.s, rpath1.s, 
rpath2.s); \
 +    mhl_mem_free (rpath1.s); \
 +    mhl_mem_free (rpath2.s); \
      return fish_send_command(me, super2, buf, OPT_FLUSH); \
  }
  
@@@ -950,15 -949,15 +950,15 @@@ FISH_OP(link,   "#LINK /%s /%s\n
  
  static int fish_symlink (struct vfs_class *me, const char *setto, const char 
*path)
  {
 -    char *qsetto;
 +    SHELL_ESCAPED_STR qsetto;
      PREFIX
      qsetto = mhl_shell_escape_dup (setto);
-     g_snprintf(buf, sizeof(buf),
+     snprintf(buf, sizeof(buf),
              "#SYMLINK %s /%s\n"
            "ln -s %s /%s 2>/dev/null\n"
            "echo '### 000'\n",
 -          qsetto, rpath, qsetto, rpath);
 -    mhl_mem_free (qsetto);
 +          qsetto.s, rpath.s, qsetto.s, rpath.s);
 +    mhl_mem_free (qsetto.s);
      POSTFIX(OPT_FLUSH);
  }
  
@@@ -979,20 -978,20 +979,20 @@@ fish_chown (struct vfs_class *me, cons
      sgroup = gr->gr_name;
      {
        PREFIX
-       g_snprintf (buf, sizeof(buf),
+       snprintf (buf, sizeof(buf),
            "#CHOWN %s /%s\n"
            "chown %s /%s 2>/dev/null\n"
            "echo '### 000'\n", 
 -          sowner, rpath,
 -          sowner, rpath);
 +          sowner, rpath.s,
 +          sowner, rpath.s);
        fish_send_command (me, super, buf, OPT_FLUSH); 
        /* FIXME: what should we report if chgrp succeeds but chown fails? */
-       g_snprintf (buf, sizeof(buf),
+       snprintf (buf, sizeof(buf),
              "#CHGRP /%s \"/%s\"\n"
            "chgrp %s \"/%s\" 2>/dev/null\n"
            "echo '### 000'\n", 
 -          sgroup, rpath,
 -          sgroup, rpath);
 +          sgroup, rpath.s,
 +          sgroup, rpath.s);
        /* fish_send_command(me, super, buf, OPT_FLUSH); */
        POSTFIX (OPT_FLUSH)
      }
@@@ -1001,11 -1000,11 +1001,11 @@@
  static int fish_unlink (struct vfs_class *me, const char *path)
  {
      PREFIX
-     g_snprintf(buf, sizeof(buf),
+     snprintf(buf, sizeof(buf),
              "#DELE /%s\n"
            "rm -f /%s 2>/dev/null\n"
            "echo '### 000'\n",
 -          rpath, rpath);
 +          rpath.s, rpath.s);
      POSTFIX(OPT_FLUSH);
  }
  
@@@ -1015,22 -1014,22 +1015,22 @@@ static int fish_mkdir (struct vfs_clas
  
      (void) mode;
  
-     g_snprintf(buf, sizeof(buf),
+     snprintf(buf, sizeof(buf),
              "#MKD /%s\n"
            "mkdir /%s 2>/dev/null\n"
            "echo '### 000'\n",
 -          rpath, rpath);
 +          rpath.s, rpath.s);
      POSTFIX(OPT_FLUSH);
  }
  
  static int fish_rmdir (struct vfs_class *me, const char *path)
  {
      PREFIX
-     g_snprintf(buf, sizeof(buf),
+     snprintf(buf, sizeof(buf),
              "#RMD /%s\n"
            "rmdir /%s 2>/dev/null\n"
            "echo '### 000'\n",
 -          rpath, rpath);
 +          rpath.s, rpath.s);
      POSTFIX(OPT_FLUSH);
  }
  
@@@ -1085,7 -1084,7 +1085,7 @@@ fish_fill_names (struct vfs_class *me, 
                if (SUP.flags > FISH_FLAG_RSH)
                {
                    break;
-                   g_snprintf (gbuf, sizeof (gbuf), ":%d", SUP.flags);
+                   snprintf (gbuf, sizeof (gbuf), ":%d", SUP.flags);
                    flags = gbuf;
                }
                break;
@@@ -1094,7 -1093,7 +1094,7 @@@
        name = g_strconcat ("/#sh:", SUP.user, "@", SUP.host, flags,
                            "/", SUP.cwdir, (char *) NULL);
        (*func)(name);
 -      g_free (name);
 +      mhl_mem_free (name);
        super = super->next;
      }
  }

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

Reply via email to