This is modifier for those who are bothered using `execute '!cmd'
shellescape(@%, 1)`, but cannot use `!cmd %` because they do not know what `%`
will expand to: it replaces the first variant with `!cmd %:S`.
I remember myself requesting this kind of functionality a while ago.
Note: how about making new do_newline argument be the same as do_special?
Currently if I do
echo system('echo '.shellescape("abc def\necho ghi"))
I get correct results only if my shell is tcsh, but if my shell is zsh I get
abc def\
echo ghi
which is not correct (`\`) must not be there. This should fix “newlines in
{expr} may cause the command to fail” from system() documentation as as far as
I see it is shellescape() problem and not system().
# HG changeset patch
# User ZyX <[email protected]>
# Date 1385842851 -14400
# Sun Dec 01 00:20:51 2013 +0400
# Branch S-modifier
# Node ID ce302bfd3622491bed0267bc6fedad0eb7cfc221
# Parent 486655e0c5a21469364d3cf895535137f09b3724
Add %:S filename modifier
diff -r 486655e0c5a2 -r ce302bfd3622 runtime/doc/cmdline.txt
--- a/runtime/doc/cmdline.txt Thu Nov 28 19:27:30 2013 +0100
+++ b/runtime/doc/cmdline.txt Sun Dec 01 00:20:51 2013 +0400
@@ -824,8 +824,8 @@
the start of the function.
*filename-modifiers*
- *:_%:* *::8* *::p* *::.* *::~* *::h* *::t* *::r* *::e* *::s* *::gs*
- *%:8* *%:p* *%:.* *%:~* *%:h* *%:t* *%:r* *%:e* *%:s* *%:gs*
+*:_%:* *::8* *::p* *::.* *::~* *::h* *::t* *::r* *::e* *::s* *::gs* *::S*
+ *%:8* *%:p* *%:.* *%:~* *%:h* *%:t* *%:r* *%:e* *%:s* *%:gs* *%:S*
The file name modifiers can be used after "%", "#", "#n", "<cfile>", "<sfile>",
"<afile>" or "<abuf>". They are also used with the |fnamemodify()| function.
These are not available when Vim has been compiled without the |+modify_fname|
@@ -880,6 +880,8 @@
:gs?pat?sub?
Substitute all occurrences of "pat" with "sub". Otherwise
this works like ":s".
+ :S Escape special characters (see |shellescape()|). Must be the
+ last one.
Examples, when the file name is "src/version.c", current dir
"/home/mool/vim": >
diff -r 486655e0c5a2 -r ce302bfd3622 src/eval.c
--- a/src/eval.c Thu Nov 28 19:27:30 2013 +0100
+++ b/src/eval.c Sun Dec 01 00:20:51 2013 +0400
@@ -16924,7 +16924,7 @@
typval_T *rettv;
{
rettv->vval.v_string = vim_strsave_shellescape(
- get_tv_string(&argvars[0]), non_zero_arg(&argvars[1]));
+ get_tv_string(&argvars[0]), non_zero_arg(&argvars[1]), TRUE);
rettv->v_type = VAR_STRING;
}
@@ -24328,6 +24328,17 @@
}
}
+ if (src[*usedlen] == ':' && src[*usedlen + 1] == 'S')
+ {
+ p = vim_strsave_shellescape(*fnamep, FALSE, FALSE);
+ if (p == NULL)
+ return -1;
+ vim_free(*bufp);
+ *bufp = *fnamep = p;
+ *fnamelen = (int)STRLEN(p);
+ *usedlen += 2;
+ }
+
return valid;
}
diff -r 486655e0c5a2 -r ce302bfd3622 src/misc2.c
--- a/src/misc2.c Thu Nov 28 19:27:30 2013 +0100
+++ b/src/misc2.c Sun Dec 01 00:20:51 2013 +0400
@@ -1368,13 +1368,15 @@
* (MS-DOS and MS-Windows without 'shellslash' set).
* Escape a newline, depending on the 'shell' option.
* When "do_special" is TRUE also replace "!", "%", "#" and things starting
+ * When "do_newline" is FALSE do not escape newline unless it is csh shell
* with "<" like "<cfile>".
* Returns the result in allocated memory, NULL if we have run out.
*/
char_u *
-vim_strsave_shellescape(string, do_special)
+vim_strsave_shellescape(string, do_special, do_newline)
char_u *string;
int do_special;
+ int do_newline;
{
unsigned length;
char_u *p;
@@ -1403,7 +1405,8 @@
# endif
if (*p == '\'')
length += 3; /* ' => '\'' */
- if (*p == '\n' || (*p == '!' && (csh_like || do_special)))
+ if ((*p == '\n' && (csh_like || do_newline))
+ || (*p == '!' && (csh_like || do_special)))
{
++length; /* insert backslash */
if (csh_like && do_special)
@@ -1454,7 +1457,8 @@
++p;
continue;
}
- if (*p == '\n' || (*p == '!' && (csh_like || do_special)))
+ if ((*p == '\n' && (csh_like || do_newline))
+ || (*p == '!' && (csh_like || do_special)))
{
*d++ = '\\';
if (csh_like && do_special)
diff -r 486655e0c5a2 -r ce302bfd3622 src/normal.c
--- a/src/normal.c Thu Nov 28 19:27:30 2013 +0100
+++ b/src/normal.c Sun Dec 01 00:20:51 2013 +0400
@@ -5784,7 +5784,7 @@
{
/* Escape the argument properly for a shell command */
ptr = vim_strnsave(ptr, n);
- p = vim_strsave_shellescape(ptr, TRUE);
+ p = vim_strsave_shellescape(ptr, TRUE, TRUE);
vim_free(ptr);
if (p == NULL)
{
diff -r 486655e0c5a2 -r ce302bfd3622 src/proto/misc2.pro
--- a/src/proto/misc2.pro Thu Nov 28 19:27:30 2013 +0100
+++ b/src/proto/misc2.pro Sun Dec 01 00:20:51 2013 +0400
@@ -32,7 +32,7 @@
char_u *vim_strsave_escaped __ARGS((char_u *string, char_u *esc_chars));
char_u *vim_strsave_escaped_ext __ARGS((char_u *string, char_u *esc_chars, int
cc, int bsl));
int csh_like_shell __ARGS((void));
-char_u *vim_strsave_shellescape __ARGS((char_u *string, int do_special));
+char_u *vim_strsave_shellescape __ARGS((char_u *string, int do_special, int
do_newline));
char_u *vim_strsave_up __ARGS((char_u *string));
char_u *vim_strnsave_up __ARGS((char_u *string, int len));
void vim_strup __ARGS((char_u *p));
diff -r 486655e0c5a2 -r ce302bfd3622 src/testdir/Make_amiga.mak
--- a/src/testdir/Make_amiga.mak Thu Nov 28 19:27:30 2013 +0100
+++ b/src/testdir/Make_amiga.mak Sun Dec 01 00:20:51 2013 +0400
@@ -34,7 +34,8 @@
test81.out test82.out test83.out test84.out test88.out \
test89.out test90.out test91.out test92.out test93.out \
test94.out test95.out test96.out test97.out test98.out \
- test99.out test100.out test101.out test102.out test103.out
+ test99.out test100.out test101.out test102.out test103.out \
+ test104.out
.SUFFIXES: .in .out
@@ -154,3 +155,4 @@
test101.out: test101.in
test102.out: test102.in
test103.out: test103.in
+test104.out: test104.in
diff -r 486655e0c5a2 -r ce302bfd3622 src/testdir/Make_dos.mak
--- a/src/testdir/Make_dos.mak Thu Nov 28 19:27:30 2013 +0100
+++ b/src/testdir/Make_dos.mak Sun Dec 01 00:20:51 2013 +0400
@@ -33,7 +33,7 @@
test84.out test85.out test86.out test87.out test88.out \
test89.out test90.out test91.out test92.out test93.out \
test94.out test95.out test96.out test98.out test99.out \
- test100.out test101.out test102.out test103.out
+ test100.out test101.out test102.out test103.out test104.out
SCRIPTS32 = test50.out test70.out
diff -r 486655e0c5a2 -r ce302bfd3622 src/testdir/Make_ming.mak
--- a/src/testdir/Make_ming.mak Thu Nov 28 19:27:30 2013 +0100
+++ b/src/testdir/Make_ming.mak Sun Dec 01 00:20:51 2013 +0400
@@ -53,7 +53,7 @@
test84.out test85.out test86.out test87.out test88.out \
test89.out test90.out test91.out test92.out test93.out \
test94.out test95.out test96.out test98.out test99.out \
- test100out test101.out test102.out test103.out
+ test100out test101.out test102.out test103.out test104.out
SCRIPTS32 = test50.out test70.out
diff -r 486655e0c5a2 -r ce302bfd3622 src/testdir/Make_os2.mak
--- a/src/testdir/Make_os2.mak Thu Nov 28 19:27:30 2013 +0100
+++ b/src/testdir/Make_os2.mak Sun Dec 01 00:20:51 2013 +0400
@@ -35,7 +35,7 @@
test81.out test82.out test83.out test84.out test88.out \
test89.out test90.out test91.out test92.out test93.out \
test94.out test95.out test96.out test98.out test99.out \
- test100.out test101.out test102.out test103.out
+ test100.out test101.out test102.out test103.out test104.out
.SUFFIXES: .in .out
diff -r 486655e0c5a2 -r ce302bfd3622 src/testdir/Make_vms.mms
--- a/src/testdir/Make_vms.mms Thu Nov 28 19:27:30 2013 +0100
+++ b/src/testdir/Make_vms.mms Sun Dec 01 00:20:51 2013 +0400
@@ -79,7 +79,7 @@
test82.out test83.out test84.out test88.out test89.out \
test90.out test91.out test92.out test93.out test94.out \
test95.out test96.out test97.out test98.out test99.out \
- test100.out test101.out test102.out test103.out
+ test100.out test101.out test102.out test103.out test104.out
# Known problems:
# Test 30: a problem around mac format - unknown reason
diff -r 486655e0c5a2 -r ce302bfd3622 src/testdir/Makefile
--- a/src/testdir/Makefile Thu Nov 28 19:27:30 2013 +0100
+++ b/src/testdir/Makefile Sun Dec 01 00:20:51 2013 +0400
@@ -30,7 +30,8 @@
test84.out test85.out test86.out test87.out test88.out \
test89.out test90.out test91.out test92.out test93.out \
test94.out test95.out test96.out test97.out test98.out \
- test99.out test100.out test101.out test102.out test103.out
+ test99.out test100.out test101.out test102.out test103.out \
+ test104.out
SCRIPTS_GUI = test16.out
diff -r 486655e0c5a2 -r ce302bfd3622 src/testdir/test104.in
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/test104.in Sun Dec 01 00:20:51 2013 +0400
@@ -0,0 +1,45 @@
+Test filename modifiers vim: set ft=vim :
+
+STARTTEST
+:source small.vim
+:%delete _
+:set shell=sh
+:set shellslash
+:let tab="\t"
+:command -nargs=1 Put :let expr=<q-args> | $put
=expr.tab.strtrans(string(eval(expr)))
+:let $HOME=fnamemodify('.', ':p:h:h:h')
+:Put fnamemodify('.', ':p' )[-1:]
+:Put fnamemodify('.', ':p:h' )[-1:]
+:Put fnamemodify('test.out', ':p' )[-1:]
+:Put fnamemodify('test.out', ':.' )
+:Put fnamemodify('../testdir/a', ':.' )
+:Put fnamemodify('test.out', ':~' )
+:Put fnamemodify('../testdir/a', ':~' )
+:Put fnamemodify('../testdir/a', ':t' )
+:Put fnamemodify('.', ':p:t' )
+:Put fnamemodify('test.out', ':p:t' )
+:Put fnamemodify('test.out', ':p:e' )
+:Put fnamemodify('test.out', ':p:t:e' )
+:Put fnamemodify('abc.fb2.tar.gz', ':r' )
+:Put fnamemodify('abc.fb2.tar.gz', ':r:r' )
+:Put fnamemodify('abc.fb2.tar.gz', ':r:r:r' )
+:Put fnamemodify('abc.fb2.tar.gz', ':p:r:r' )
+:Put fnamemodify('abc.fb2.tar.gz', ':e' )
+:Put fnamemodify('abc.fb2.tar.gz', ':e:e' )
+:Put fnamemodify('abc.fb2.tar.gz', ':e:e:e' )
+:Put fnamemodify('abc.fb2.tar.gz', ':e:e:e:e')
+:Put fnamemodify('abc.fb2.tar.gz', ':e:e:r' )
+:Put fnamemodify('abc def', ':S' )
+:Put fnamemodify('abc" "def', ':S' )
+:Put fnamemodify('abc"%"def', ':S' )
+:Put fnamemodify('abc'' ''def', ':S' )
+:Put fnamemodify('abc''%''def', ':S' )
+:Put fnamemodify("abc\ndef", ':S' )
+:set shell=tcsh
+:Put fnamemodify("abc\ndef", ':S' )
+:$put ='vim: ts=8'
+:1 delete _
+:w! test.out
+:qa!
+ENDTEST
+
diff -r 486655e0c5a2 -r ce302bfd3622 src/testdir/test104.ok
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/test104.ok Sun Dec 01 00:20:51 2013 +0400
@@ -0,0 +1,29 @@
+fnamemodify('.', ':p' )[-1:] '/'
+fnamemodify('.', ':p:h' )[-1:] 'r'
+fnamemodify('test.out', ':p' )[-1:] 't'
+fnamemodify('test.out', ':.' ) 'test.out'
+fnamemodify('../testdir/a', ':.' ) 'a'
+fnamemodify('test.out', ':~' ) '~/src/testdir/test.out'
+fnamemodify('../testdir/a', ':~' ) '~/src/testdir/a'
+fnamemodify('../testdir/a', ':t' ) 'a'
+fnamemodify('.', ':p:t' ) ''
+fnamemodify('test.out', ':p:t' ) 'test.out'
+fnamemodify('test.out', ':p:e' ) 'out'
+fnamemodify('test.out', ':p:t:e' ) 'out'
+fnamemodify('abc.fb2.tar.gz', ':r' ) 'abc.fb2.tar'
+fnamemodify('abc.fb2.tar.gz', ':r:r' ) 'abc.fb2'
+fnamemodify('abc.fb2.tar.gz', ':r:r:r' ) 'abc'
+fnamemodify('abc.fb2.tar.gz', ':p:r:r' )
'/home/zyx/a.a/Proj/c/vim-small-patches/src/testdir/abc.fb2'
+fnamemodify('abc.fb2.tar.gz', ':e' ) 'gz'
+fnamemodify('abc.fb2.tar.gz', ':e:e' ) 'tar.gz'
+fnamemodify('abc.fb2.tar.gz', ':e:e:e' ) 'fb2.tar.gz'
+fnamemodify('abc.fb2.tar.gz', ':e:e:e:e') 'fb2.tar.gz'
+fnamemodify('abc.fb2.tar.gz', ':e:e:r' ) 'tar'
+fnamemodify('abc def', ':S' ) '''abc def'''
+fnamemodify('abc" "def', ':S' ) '''abc" "def'''
+fnamemodify('abc"%"def', ':S' ) '''abc"%"def'''
+fnamemodify('abc'' ''def', ':S' ) '''abc''\'''' ''\''''def'''
+fnamemodify('abc''%''def', ':S' ) '''abc''\''''%''\''''def'''
+fnamemodify("abc\ndef", ':S' ) '''abc^@def'''
+fnamemodify("abc\ndef", ':S' ) '''abc\^@def'''
+vim: ts=8
diff -r 486655e0c5a2 -r ce302bfd3622 src/testdir/test104.out
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/test104.out Sun Dec 01 00:20:51 2013 +0400
@@ -0,0 +1,29 @@
+fnamemodify('.', ':p' )[-1:] '/'
+fnamemodify('.', ':p:h' )[-1:] 'r'
+fnamemodify('test.out', ':p' )[-1:] 't'
+fnamemodify('test.out', ':.' ) 'test.out'
+fnamemodify('../testdir/a', ':.' ) 'a'
+fnamemodify('test.out', ':~' ) '~/src/testdir/test.out'
+fnamemodify('../testdir/a', ':~' ) '~/src/testdir/a'
+fnamemodify('../testdir/a', ':t' ) 'a'
+fnamemodify('.', ':p:t' ) ''
+fnamemodify('test.out', ':p:t' ) 'test.out'
+fnamemodify('test.out', ':p:e' ) 'out'
+fnamemodify('test.out', ':p:t:e' ) 'out'
+fnamemodify('abc.fb2.tar.gz', ':r' ) 'abc.fb2.tar'
+fnamemodify('abc.fb2.tar.gz', ':r:r' ) 'abc.fb2'
+fnamemodify('abc.fb2.tar.gz', ':r:r:r' ) 'abc'
+fnamemodify('abc.fb2.tar.gz', ':p:r:r' )
'/home/zyx/a.a/Proj/c/vim-small-patches/src/testdir/abc.fb2'
+fnamemodify('abc.fb2.tar.gz', ':e' ) 'gz'
+fnamemodify('abc.fb2.tar.gz', ':e:e' ) 'tar.gz'
+fnamemodify('abc.fb2.tar.gz', ':e:e:e' ) 'fb2.tar.gz'
+fnamemodify('abc.fb2.tar.gz', ':e:e:e:e') 'fb2.tar.gz'
+fnamemodify('abc.fb2.tar.gz', ':e:e:r' ) 'tar'
+fnamemodify('abc def', ':S' ) '''abc def'''
+fnamemodify('abc" "def', ':S' ) '''abc" "def'''
+fnamemodify('abc"%"def', ':S' ) '''abc"%"def'''
+fnamemodify('abc'' ''def', ':S' ) '''abc''\'''' ''\''''def'''
+fnamemodify('abc''%''def', ':S' ) '''abc''\''''%''\''''def'''
+fnamemodify("abc\ndef", ':S' ) '''abc^@def'''
+fnamemodify("abc\ndef", ':S' ) '''abc\^@def'''
+vim: ts=8
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff -crN vim-small-patches.486655e0c5a2/runtime/doc/cmdline.txt vim-small-patches.ce302bfd3622/runtime/doc/cmdline.txt
*** vim-small-patches.486655e0c5a2/runtime/doc/cmdline.txt 2013-12-01 00:24:45.539752604 +0400
--- vim-small-patches.ce302bfd3622/runtime/doc/cmdline.txt 2013-12-01 00:24:45.569752603 +0400
***************
*** 824,831 ****
the start of the function.
*filename-modifiers*
! *:_%:* *::8* *::p* *::.* *::~* *::h* *::t* *::r* *::e* *::s* *::gs*
! *%:8* *%:p* *%:.* *%:~* *%:h* *%:t* *%:r* *%:e* *%:s* *%:gs*
The file name modifiers can be used after "%", "#", "#n", "<cfile>", "<sfile>",
"<afile>" or "<abuf>". They are also used with the |fnamemodify()| function.
These are not available when Vim has been compiled without the |+modify_fname|
--- 824,831 ----
the start of the function.
*filename-modifiers*
! *:_%:* *::8* *::p* *::.* *::~* *::h* *::t* *::r* *::e* *::s* *::gs* *::S*
! *%:8* *%:p* *%:.* *%:~* *%:h* *%:t* *%:r* *%:e* *%:s* *%:gs* *%:S*
The file name modifiers can be used after "%", "#", "#n", "<cfile>", "<sfile>",
"<afile>" or "<abuf>". They are also used with the |fnamemodify()| function.
These are not available when Vim has been compiled without the |+modify_fname|
***************
*** 880,885 ****
--- 880,887 ----
:gs?pat?sub?
Substitute all occurrences of "pat" with "sub". Otherwise
this works like ":s".
+ :S Escape special characters (see |shellescape()|). Must be the
+ last one.
Examples, when the file name is "src/version.c", current dir
"/home/mool/vim": >
diff -crN vim-small-patches.486655e0c5a2/src/eval.c vim-small-patches.ce302bfd3622/src/eval.c
*** vim-small-patches.486655e0c5a2/src/eval.c 2013-12-01 00:24:45.538752604 +0400
--- vim-small-patches.ce302bfd3622/src/eval.c 2013-12-01 00:24:45.568752603 +0400
***************
*** 16924,16930 ****
typval_T *rettv;
{
rettv->vval.v_string = vim_strsave_shellescape(
! get_tv_string(&argvars[0]), non_zero_arg(&argvars[1]));
rettv->v_type = VAR_STRING;
}
--- 16924,16930 ----
typval_T *rettv;
{
rettv->vval.v_string = vim_strsave_shellescape(
! get_tv_string(&argvars[0]), non_zero_arg(&argvars[1]), TRUE);
rettv->v_type = VAR_STRING;
}
***************
*** 24328,24333 ****
--- 24328,24344 ----
}
}
+ if (src[*usedlen] == ':' && src[*usedlen + 1] == 'S')
+ {
+ p = vim_strsave_shellescape(*fnamep, FALSE, FALSE);
+ if (p == NULL)
+ return -1;
+ vim_free(*bufp);
+ *bufp = *fnamep = p;
+ *fnamelen = (int)STRLEN(p);
+ *usedlen += 2;
+ }
+
return valid;
}
diff -crN vim-small-patches.486655e0c5a2/src/misc2.c vim-small-patches.ce302bfd3622/src/misc2.c
*** vim-small-patches.486655e0c5a2/src/misc2.c 2013-12-01 00:24:45.516752605 +0400
--- vim-small-patches.ce302bfd3622/src/misc2.c 2013-12-01 00:24:45.548752604 +0400
***************
*** 1368,1380 ****
* (MS-DOS and MS-Windows without 'shellslash' set).
* Escape a newline, depending on the 'shell' option.
* When "do_special" is TRUE also replace "!", "%", "#" and things starting
* with "<" like "<cfile>".
* Returns the result in allocated memory, NULL if we have run out.
*/
char_u *
! vim_strsave_shellescape(string, do_special)
char_u *string;
int do_special;
{
unsigned length;
char_u *p;
--- 1368,1382 ----
* (MS-DOS and MS-Windows without 'shellslash' set).
* Escape a newline, depending on the 'shell' option.
* When "do_special" is TRUE also replace "!", "%", "#" and things starting
+ * When "do_newline" is FALSE do not escape newline unless it is csh shell
* with "<" like "<cfile>".
* Returns the result in allocated memory, NULL if we have run out.
*/
char_u *
! vim_strsave_shellescape(string, do_special, do_newline)
char_u *string;
int do_special;
+ int do_newline;
{
unsigned length;
char_u *p;
***************
*** 1403,1409 ****
# endif
if (*p == '\'')
length += 3; /* ' => '\'' */
! if (*p == '\n' || (*p == '!' && (csh_like || do_special)))
{
++length; /* insert backslash */
if (csh_like && do_special)
--- 1405,1412 ----
# endif
if (*p == '\'')
length += 3; /* ' => '\'' */
! if ((*p == '\n' && (csh_like || do_newline))
! || (*p == '!' && (csh_like || do_special)))
{
++length; /* insert backslash */
if (csh_like && do_special)
***************
*** 1454,1460 ****
++p;
continue;
}
! if (*p == '\n' || (*p == '!' && (csh_like || do_special)))
{
*d++ = '\\';
if (csh_like && do_special)
--- 1457,1464 ----
++p;
continue;
}
! if ((*p == '\n' && (csh_like || do_newline))
! || (*p == '!' && (csh_like || do_special)))
{
*d++ = '\\';
if (csh_like && do_special)
diff -crN vim-small-patches.486655e0c5a2/src/normal.c vim-small-patches.ce302bfd3622/src/normal.c
*** vim-small-patches.486655e0c5a2/src/normal.c 2013-12-01 00:24:45.514752605 +0400
--- vim-small-patches.ce302bfd3622/src/normal.c 2013-12-01 00:24:45.546752604 +0400
***************
*** 5784,5790 ****
{
/* Escape the argument properly for a shell command */
ptr = vim_strnsave(ptr, n);
! p = vim_strsave_shellescape(ptr, TRUE);
vim_free(ptr);
if (p == NULL)
{
--- 5784,5790 ----
{
/* Escape the argument properly for a shell command */
ptr = vim_strnsave(ptr, n);
! p = vim_strsave_shellescape(ptr, TRUE, TRUE);
vim_free(ptr);
if (p == NULL)
{
diff -crN vim-small-patches.486655e0c5a2/src/proto/misc2.pro vim-small-patches.ce302bfd3622/src/proto/misc2.pro
*** vim-small-patches.486655e0c5a2/src/proto/misc2.pro 2013-12-01 00:24:45.508752605 +0400
--- vim-small-patches.ce302bfd3622/src/proto/misc2.pro 2013-12-01 00:24:45.540752604 +0400
***************
*** 32,38 ****
char_u *vim_strsave_escaped __ARGS((char_u *string, char_u *esc_chars));
char_u *vim_strsave_escaped_ext __ARGS((char_u *string, char_u *esc_chars, int cc, int bsl));
int csh_like_shell __ARGS((void));
! char_u *vim_strsave_shellescape __ARGS((char_u *string, int do_special));
char_u *vim_strsave_up __ARGS((char_u *string));
char_u *vim_strnsave_up __ARGS((char_u *string, int len));
void vim_strup __ARGS((char_u *p));
--- 32,38 ----
char_u *vim_strsave_escaped __ARGS((char_u *string, char_u *esc_chars));
char_u *vim_strsave_escaped_ext __ARGS((char_u *string, char_u *esc_chars, int cc, int bsl));
int csh_like_shell __ARGS((void));
! char_u *vim_strsave_shellescape __ARGS((char_u *string, int do_special, int do_newline));
char_u *vim_strsave_up __ARGS((char_u *string));
char_u *vim_strnsave_up __ARGS((char_u *string, int len));
void vim_strup __ARGS((char_u *p));
diff -crN vim-small-patches.486655e0c5a2/src/testdir/Make_amiga.mak vim-small-patches.ce302bfd3622/src/testdir/Make_amiga.mak
*** vim-small-patches.486655e0c5a2/src/testdir/Make_amiga.mak 2013-12-01 00:24:45.510752605 +0400
--- vim-small-patches.ce302bfd3622/src/testdir/Make_amiga.mak 2013-12-01 00:24:45.542752604 +0400
***************
*** 34,40 ****
test81.out test82.out test83.out test84.out test88.out \
test89.out test90.out test91.out test92.out test93.out \
test94.out test95.out test96.out test97.out test98.out \
! test99.out test100.out test101.out test102.out test103.out
.SUFFIXES: .in .out
--- 34,41 ----
test81.out test82.out test83.out test84.out test88.out \
test89.out test90.out test91.out test92.out test93.out \
test94.out test95.out test96.out test97.out test98.out \
! test99.out test100.out test101.out test102.out test103.out \
! test104.out
.SUFFIXES: .in .out
***************
*** 154,156 ****
--- 155,158 ----
test101.out: test101.in
test102.out: test102.in
test103.out: test103.in
+ test104.out: test104.in
diff -crN vim-small-patches.486655e0c5a2/src/testdir/Make_dos.mak vim-small-patches.ce302bfd3622/src/testdir/Make_dos.mak
*** vim-small-patches.486655e0c5a2/src/testdir/Make_dos.mak 2013-12-01 00:24:45.509752605 +0400
--- vim-small-patches.ce302bfd3622/src/testdir/Make_dos.mak 2013-12-01 00:24:45.541752604 +0400
***************
*** 33,39 ****
test84.out test85.out test86.out test87.out test88.out \
test89.out test90.out test91.out test92.out test93.out \
test94.out test95.out test96.out test98.out test99.out \
! test100.out test101.out test102.out test103.out
SCRIPTS32 = test50.out test70.out
--- 33,39 ----
test84.out test85.out test86.out test87.out test88.out \
test89.out test90.out test91.out test92.out test93.out \
test94.out test95.out test96.out test98.out test99.out \
! test100.out test101.out test102.out test103.out test104.out
SCRIPTS32 = test50.out test70.out
diff -crN vim-small-patches.486655e0c5a2/src/testdir/Makefile vim-small-patches.ce302bfd3622/src/testdir/Makefile
*** vim-small-patches.486655e0c5a2/src/testdir/Makefile 2013-12-01 00:24:45.509752605 +0400
--- vim-small-patches.ce302bfd3622/src/testdir/Makefile 2013-12-01 00:24:45.541752604 +0400
***************
*** 30,36 ****
test84.out test85.out test86.out test87.out test88.out \
test89.out test90.out test91.out test92.out test93.out \
test94.out test95.out test96.out test97.out test98.out \
! test99.out test100.out test101.out test102.out test103.out
SCRIPTS_GUI = test16.out
--- 30,37 ----
test84.out test85.out test86.out test87.out test88.out \
test89.out test90.out test91.out test92.out test93.out \
test94.out test95.out test96.out test97.out test98.out \
! test99.out test100.out test101.out test102.out test103.out \
! test104.out
SCRIPTS_GUI = test16.out
diff -crN vim-small-patches.486655e0c5a2/src/testdir/Make_ming.mak vim-small-patches.ce302bfd3622/src/testdir/Make_ming.mak
*** vim-small-patches.486655e0c5a2/src/testdir/Make_ming.mak 2013-12-01 00:24:45.517752605 +0400
--- vim-small-patches.ce302bfd3622/src/testdir/Make_ming.mak 2013-12-01 00:24:45.549752604 +0400
***************
*** 53,59 ****
test84.out test85.out test86.out test87.out test88.out \
test89.out test90.out test91.out test92.out test93.out \
test94.out test95.out test96.out test98.out test99.out \
! test100out test101.out test102.out test103.out
SCRIPTS32 = test50.out test70.out
--- 53,59 ----
test84.out test85.out test86.out test87.out test88.out \
test89.out test90.out test91.out test92.out test93.out \
test94.out test95.out test96.out test98.out test99.out \
! test100out test101.out test102.out test103.out test104.out
SCRIPTS32 = test50.out test70.out
diff -crN vim-small-patches.486655e0c5a2/src/testdir/Make_os2.mak vim-small-patches.ce302bfd3622/src/testdir/Make_os2.mak
*** vim-small-patches.486655e0c5a2/src/testdir/Make_os2.mak 2013-12-01 00:24:45.510752605 +0400
--- vim-small-patches.ce302bfd3622/src/testdir/Make_os2.mak 2013-12-01 00:24:45.542752604 +0400
***************
*** 35,41 ****
test81.out test82.out test83.out test84.out test88.out \
test89.out test90.out test91.out test92.out test93.out \
test94.out test95.out test96.out test98.out test99.out \
! test100.out test101.out test102.out test103.out
.SUFFIXES: .in .out
--- 35,41 ----
test81.out test82.out test83.out test84.out test88.out \
test89.out test90.out test91.out test92.out test93.out \
test94.out test95.out test96.out test98.out test99.out \
! test100.out test101.out test102.out test103.out test104.out
.SUFFIXES: .in .out
diff -crN vim-small-patches.486655e0c5a2/src/testdir/Make_vms.mms vim-small-patches.ce302bfd3622/src/testdir/Make_vms.mms
*** vim-small-patches.486655e0c5a2/src/testdir/Make_vms.mms 2013-12-01 00:24:45.517752605 +0400
--- vim-small-patches.ce302bfd3622/src/testdir/Make_vms.mms 2013-12-01 00:24:45.549752604 +0400
***************
*** 79,85 ****
test82.out test83.out test84.out test88.out test89.out \
test90.out test91.out test92.out test93.out test94.out \
test95.out test96.out test97.out test98.out test99.out \
! test100.out test101.out test102.out test103.out
# Known problems:
# Test 30: a problem around mac format - unknown reason
--- 79,85 ----
test82.out test83.out test84.out test88.out test89.out \
test90.out test91.out test92.out test93.out test94.out \
test95.out test96.out test97.out test98.out test99.out \
! test100.out test101.out test102.out test103.out test104.out
# Known problems:
# Test 30: a problem around mac format - unknown reason
diff -crN vim-small-patches.486655e0c5a2/src/testdir/test104.in vim-small-patches.ce302bfd3622/src/testdir/test104.in
*** vim-small-patches.486655e0c5a2/src/testdir/test104.in 1970-01-01 03:00:00.000000000 +0300
--- vim-small-patches.ce302bfd3622/src/testdir/test104.in 2013-12-01 00:24:45.540752604 +0400
***************
*** 0 ****
--- 1,45 ----
+ Test filename modifiers vim: set ft=vim :
+
+ STARTTEST
+ :source small.vim
+ :%delete _
+ :set shell=sh
+ :set shellslash
+ :let tab="\t"
+ :command -nargs=1 Put :let expr=<q-args> | $put =expr.tab.strtrans(string(eval(expr)))
+ :let $HOME=fnamemodify('.', ':p:h:h:h')
+ :Put fnamemodify('.', ':p' )[-1:]
+ :Put fnamemodify('.', ':p:h' )[-1:]
+ :Put fnamemodify('test.out', ':p' )[-1:]
+ :Put fnamemodify('test.out', ':.' )
+ :Put fnamemodify('../testdir/a', ':.' )
+ :Put fnamemodify('test.out', ':~' )
+ :Put fnamemodify('../testdir/a', ':~' )
+ :Put fnamemodify('../testdir/a', ':t' )
+ :Put fnamemodify('.', ':p:t' )
+ :Put fnamemodify('test.out', ':p:t' )
+ :Put fnamemodify('test.out', ':p:e' )
+ :Put fnamemodify('test.out', ':p:t:e' )
+ :Put fnamemodify('abc.fb2.tar.gz', ':r' )
+ :Put fnamemodify('abc.fb2.tar.gz', ':r:r' )
+ :Put fnamemodify('abc.fb2.tar.gz', ':r:r:r' )
+ :Put fnamemodify('abc.fb2.tar.gz', ':p:r:r' )
+ :Put fnamemodify('abc.fb2.tar.gz', ':e' )
+ :Put fnamemodify('abc.fb2.tar.gz', ':e:e' )
+ :Put fnamemodify('abc.fb2.tar.gz', ':e:e:e' )
+ :Put fnamemodify('abc.fb2.tar.gz', ':e:e:e:e')
+ :Put fnamemodify('abc.fb2.tar.gz', ':e:e:r' )
+ :Put fnamemodify('abc def', ':S' )
+ :Put fnamemodify('abc" "def', ':S' )
+ :Put fnamemodify('abc"%"def', ':S' )
+ :Put fnamemodify('abc'' ''def', ':S' )
+ :Put fnamemodify('abc''%''def', ':S' )
+ :Put fnamemodify("abc\ndef", ':S' )
+ :set shell=tcsh
+ :Put fnamemodify("abc\ndef", ':S' )
+ :$put ='vim: ts=8'
+ :1 delete _
+ :w! test.out
+ :qa!
+ ENDTEST
+
diff -crN vim-small-patches.486655e0c5a2/src/testdir/test104.ok vim-small-patches.ce302bfd3622/src/testdir/test104.ok
*** vim-small-patches.486655e0c5a2/src/testdir/test104.ok 1970-01-01 03:00:00.000000000 +0300
--- vim-small-patches.ce302bfd3622/src/testdir/test104.ok 2013-12-01 00:24:45.549752604 +0400
***************
*** 0 ****
--- 1,29 ----
+ fnamemodify('.', ':p' )[-1:] '/'
+ fnamemodify('.', ':p:h' )[-1:] 'r'
+ fnamemodify('test.out', ':p' )[-1:] 't'
+ fnamemodify('test.out', ':.' ) 'test.out'
+ fnamemodify('../testdir/a', ':.' ) 'a'
+ fnamemodify('test.out', ':~' ) '~/src/testdir/test.out'
+ fnamemodify('../testdir/a', ':~' ) '~/src/testdir/a'
+ fnamemodify('../testdir/a', ':t' ) 'a'
+ fnamemodify('.', ':p:t' ) ''
+ fnamemodify('test.out', ':p:t' ) 'test.out'
+ fnamemodify('test.out', ':p:e' ) 'out'
+ fnamemodify('test.out', ':p:t:e' ) 'out'
+ fnamemodify('abc.fb2.tar.gz', ':r' ) 'abc.fb2.tar'
+ fnamemodify('abc.fb2.tar.gz', ':r:r' ) 'abc.fb2'
+ fnamemodify('abc.fb2.tar.gz', ':r:r:r' ) 'abc'
+ fnamemodify('abc.fb2.tar.gz', ':p:r:r' ) '/home/zyx/a.a/Proj/c/vim-small-patches/src/testdir/abc.fb2'
+ fnamemodify('abc.fb2.tar.gz', ':e' ) 'gz'
+ fnamemodify('abc.fb2.tar.gz', ':e:e' ) 'tar.gz'
+ fnamemodify('abc.fb2.tar.gz', ':e:e:e' ) 'fb2.tar.gz'
+ fnamemodify('abc.fb2.tar.gz', ':e:e:e:e') 'fb2.tar.gz'
+ fnamemodify('abc.fb2.tar.gz', ':e:e:r' ) 'tar'
+ fnamemodify('abc def', ':S' ) '''abc def'''
+ fnamemodify('abc" "def', ':S' ) '''abc" "def'''
+ fnamemodify('abc"%"def', ':S' ) '''abc"%"def'''
+ fnamemodify('abc'' ''def', ':S' ) '''abc''\'''' ''\''''def'''
+ fnamemodify('abc''%''def', ':S' ) '''abc''\''''%''\''''def'''
+ fnamemodify("abc\ndef", ':S' ) '''abc^@def'''
+ fnamemodify("abc\ndef", ':S' ) '''abc\^@def'''
+ vim: ts=8
diff -crN vim-small-patches.486655e0c5a2/src/testdir/test104.out vim-small-patches.ce302bfd3622/src/testdir/test104.out
*** vim-small-patches.486655e0c5a2/src/testdir/test104.out 1970-01-01 03:00:00.000000000 +0300
--- vim-small-patches.ce302bfd3622/src/testdir/test104.out 2013-12-01 00:24:45.570752603 +0400
***************
*** 0 ****
--- 1,29 ----
+ fnamemodify('.', ':p' )[-1:] '/'
+ fnamemodify('.', ':p:h' )[-1:] 'r'
+ fnamemodify('test.out', ':p' )[-1:] 't'
+ fnamemodify('test.out', ':.' ) 'test.out'
+ fnamemodify('../testdir/a', ':.' ) 'a'
+ fnamemodify('test.out', ':~' ) '~/src/testdir/test.out'
+ fnamemodify('../testdir/a', ':~' ) '~/src/testdir/a'
+ fnamemodify('../testdir/a', ':t' ) 'a'
+ fnamemodify('.', ':p:t' ) ''
+ fnamemodify('test.out', ':p:t' ) 'test.out'
+ fnamemodify('test.out', ':p:e' ) 'out'
+ fnamemodify('test.out', ':p:t:e' ) 'out'
+ fnamemodify('abc.fb2.tar.gz', ':r' ) 'abc.fb2.tar'
+ fnamemodify('abc.fb2.tar.gz', ':r:r' ) 'abc.fb2'
+ fnamemodify('abc.fb2.tar.gz', ':r:r:r' ) 'abc'
+ fnamemodify('abc.fb2.tar.gz', ':p:r:r' ) '/home/zyx/a.a/Proj/c/vim-small-patches/src/testdir/abc.fb2'
+ fnamemodify('abc.fb2.tar.gz', ':e' ) 'gz'
+ fnamemodify('abc.fb2.tar.gz', ':e:e' ) 'tar.gz'
+ fnamemodify('abc.fb2.tar.gz', ':e:e:e' ) 'fb2.tar.gz'
+ fnamemodify('abc.fb2.tar.gz', ':e:e:e:e') 'fb2.tar.gz'
+ fnamemodify('abc.fb2.tar.gz', ':e:e:r' ) 'tar'
+ fnamemodify('abc def', ':S' ) '''abc def'''
+ fnamemodify('abc" "def', ':S' ) '''abc" "def'''
+ fnamemodify('abc"%"def', ':S' ) '''abc"%"def'''
+ fnamemodify('abc'' ''def', ':S' ) '''abc''\'''' ''\''''def'''
+ fnamemodify('abc''%''def', ':S' ) '''abc''\''''%''\''''def'''
+ fnamemodify("abc\ndef", ':S' ) '''abc^@def'''
+ fnamemodify("abc\ndef", ':S' ) '''abc\^@def'''
+ vim: ts=8