[Pkg-mc-commits] r81 - trunk/debian/patches
winnie at alioth.debian.org
winnie at alioth.debian.org
Wed Feb 27 11:54:06 UTC 2008
Author: winnie
Date: 2008-02-27 11:54:06 +0000 (Wed, 27 Feb 2008)
New Revision: 81
Added:
trunk/debian/patches/61_escaping.patch
Log:
Merging back escaping fix
Copied: trunk/debian/patches/61_escaping.patch (from rev 79, branch/new-utf8/debian/patches/33_escaping.patch)
===================================================================
--- trunk/debian/patches/61_escaping.patch (rev 0)
+++ trunk/debian/patches/61_escaping.patch 2008-02-27 11:54:06 UTC (rev 81)
@@ -0,0 +1,114 @@
+diff -Nurwd mc-4.6.2~pre1.orig/src/command.c mc-4.6.2~pre1/src/command.c
+--- mc-4.6.2~pre1.orig/src/command.c 2008-02-27 01:21:56.000000000 +0100
++++ mc-4.6.2~pre1/src/command.c 2008-02-27 01:22:17.000000000 +0100
+@@ -44,6 +44,33 @@
+ /* This holds the command line */
+ WInput *cmdline;
+
++/* We'll get escaped strings now.. so we have to unescape them */
++char *
++unescape_string ( char * in ) {
++ char * local = NULL;
++ int i = 0;
++ int j = 20;
++ int k = 0;
++
++ local = g_malloc(j);
++
++ for (i=0;i<=strlen(in);i++) {
++ if (i-k >= j ) {
++ j = j + 20;
++ local = g_realloc(local,j);
++ }
++ if ( (strchr(" \t*|;<>",in[i])) && ( strchr("\\",in[i-1])) ) {
++ k++;
++ local[i-k] = in[i];
++ } else {
++ local[i-k] = in[i];
++ }
++ }
++ local[i-k] = '\0';
++
++ return local;
++}
++
+ /*
+ * Expand the argument to "cd" and change directory. First try tilde
+ * expansion, then variable substitution. If the CDPATH variable is set
+@@ -63,6 +90,7 @@
+ const char *t;
+
+ /* Tilde expansion */
++ path = unescape_string(path);
+ path_tilde = tilde_expand (path);
+
+ /* Leave space for further expansion */
+diff -Nurwd mc-4.6.2~pre1.orig/src/complete.c mc-4.6.2~pre1/src/complete.c
+--- mc-4.6.2~pre1.orig/src/complete.c 2008-02-27 01:26:38.000000000 +0100
++++ mc-4.6.2~pre1/src/complete.c 2008-02-27 01:26:01.000000000 +0100
+@@ -962,6 +962,34 @@
+ }
+ }
+
++char *
++escape_string ( char * in ) {
++ char * local = NULL;
++ int i = 0;
++ int j = 20;
++ int k = 0;
++
++ local = g_malloc(j);
++
++ for (i=0;i<strlen(in);i++) {
++ if (i+k >= j ) { //If 20 chars is too low for the path
++ j = j + 20;
++ local = g_realloc(local,j);
++ }
++ if ( (strchr(" \t*|;<>",in[i])) && (! strchr("\\",in[i-1])) ) {
++ local[i+k] = 92; // Ascii for "\"
++ k = k+1;
++ local[i+k] = in[i];
++ } else {
++ local[i+k] = in[i];
++ }
++ }
++ local[i+k] = '\0';
++
++ return local;
++}
++
++
+ #define DO_INSERTION 1
+ #define DO_QUERY 2
+ /* Returns 1 if the user would like to see us again */
+@@ -969,6 +997,7 @@
+ complete_engine (WInput *in, int what_to_do)
+ {
+ int s;
++ char *complete = NULL;
+
+ if (in->completions && (str_offset_to_pos (in->buffer, in->point)) != end)
+ free_completions (in);
+@@ -985,7 +1014,8 @@
+ }
+ if (in->completions){
+ if (what_to_do & DO_INSERTION || ((what_to_do & DO_QUERY) && !in->completions[1])) {
+- if (insert_text (in, in->completions [0], strlen (in->completions [0]))){
++ complete = escape_string(in->completions [0]);
++ if (insert_text (in, complete, strlen (complete))){
+ if (in->completions [1])
+ beep ();
+ else
+@@ -1001,9 +1031,11 @@
+ Dlg_head *query_dlg;
+ WListbox *query_list;
+
+- for (p=in->completions + 1; *p; count++, p++)
++ for (p=in->completions + 1; *p; count++, p++) {
++ *p = escape_string(*p);
+ if ((i = str_term_width1 (*p)) > maxlen)
+ maxlen = i;
++ }
+ start_x = in->widget.x;
+ start_y = in->widget.y;
+ if (start_y - 2 >= count) {
More information about the Pkg-mc-commits
mailing list