patch 9.1.0857: xxd: --- is incorrectly recognized as end-of-options
Problem: xxd: --- is incorrectly recognized as end-of-options Solution: improve xxds end-of-option parser (DungSaga) closes: #9285 Signed-off-by: DungSaga <dungsaga@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
a1b654ff36
commit
4b9fa95712
@ -356,7 +356,7 @@ endfunc
|
|||||||
|
|
||||||
" Various ways with wrong arguments that trigger the usage output.
|
" Various ways with wrong arguments that trigger the usage output.
|
||||||
func Test_xxd_usage()
|
func Test_xxd_usage()
|
||||||
for arg in ['-h', '-c', '-g', '-o', '-s', '-l', '-X', '-R', 'one two three']
|
for arg in ['-h', '-c', '-g', '-o', '-s', '-l', '-X', '-R', 'one two three', '----', '---']
|
||||||
new
|
new
|
||||||
exe 'r! ' . s:xxd_cmd . ' ' . arg
|
exe 'r! ' . s:xxd_cmd . ' ' . arg
|
||||||
call assert_match("Usage:", join(getline(1, 3)))
|
call assert_match("Usage:", join(getline(1, 3)))
|
||||||
@ -364,6 +364,13 @@ func Test_xxd_usage()
|
|||||||
endfor
|
endfor
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_xxd_end_of_options()
|
||||||
|
new
|
||||||
|
exe 'r! ' . s:xxd_cmd . ' -- random-file-' . rand()
|
||||||
|
call assert_match('random-file-.*: No such file or directory', join(getline(1, 3)))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_xxd_ignore_garbage()
|
func Test_xxd_ignore_garbage()
|
||||||
new
|
new
|
||||||
exe 'r! printf "\n\r xxxx 0: 42 42" | ' . s:xxd_cmd . ' -r'
|
exe 'r! printf "\n\r xxxx 0: 42 42" | ' . s:xxd_cmd . ' -r'
|
||||||
|
|||||||
@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
857,
|
||||||
/**/
|
/**/
|
||||||
856,
|
856,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
@ -65,6 +65,7 @@
|
|||||||
* 10.05.2024 fix another buffer-overflow when writing colored output to buffer, #14738
|
* 10.05.2024 fix another buffer-overflow when writing colored output to buffer, #14738
|
||||||
* 10.09.2024 Support -b and -i together, #15661
|
* 10.09.2024 Support -b and -i together, #15661
|
||||||
* 19.10.2024 -e did add an extra space #15899
|
* 19.10.2024 -e did add an extra space #15899
|
||||||
|
* 11.11.2024 improve end-of-options argument parser #9285
|
||||||
*
|
*
|
||||||
* (c) 1990-1998 by Juergen Weigert (jnweiger@gmail.com)
|
* (c) 1990-1998 by Juergen Weigert (jnweiger@gmail.com)
|
||||||
*
|
*
|
||||||
@ -145,7 +146,7 @@ extern void perror __P((char *));
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char version[] = "xxd 2024-10-19 by Juergen Weigert et al.";
|
char version[] = "xxd 2024-11-11 by Juergen Weigert et al.";
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
char osver[] = " (Win32)";
|
char osver[] = " (Win32)";
|
||||||
#else
|
#else
|
||||||
@ -843,7 +844,7 @@ main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
exit_with_usage();
|
exit_with_usage();
|
||||||
}
|
}
|
||||||
else if (!strcmp(pp, "--")) /* end of options */
|
else if (!strcmp(argv[1], "--")) /* end of options */
|
||||||
{
|
{
|
||||||
argv++;
|
argv++;
|
||||||
argc--;
|
argc--;
|
||||||
|
|||||||
Reference in New Issue
Block a user