Thu 01 Apr 2010 12:26:27 AM UTC, original submission:
The command
:hardcopy -h
(hardcopy [-h] [file]; saves currently displayed image to file or hardcopy.n, also scrollback buffer with -h)
instead of saving both display and scrollback to hardcopy.n saves only the currently displayed image, to a file named '-h'.
The difference is simply the condition
argc > 1
to only use -h if there's a second argument
vs
argc >= 1
to make sure there's at least one argument to check if it's '-h'
or
*args
to do the same (which seems to be the more commonly used condition elsewhere in the file)
Since the attached patches are so short they're reproduced below.
The first makes -h save scrollback with or without a file name given.
The second preserves the unlikely case in which someone actually does want to save display to '-h'; with
:hardcopy -- -h
or, to save both history and display to '-h'
:hardcopy -h -h
works as it always has
:hardcopy --
:hardcopy -h --
will, as they always have, save display or history and display to '--'.
diff --git a/src/process.c b/src/process.c
index cc2b56f..3a39c60 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1272,7 +1272,7 @@ int key;
{
int mode = DUMP_HARDCOPY;
- if (argc > 1 && !strcmp(*args, "-h"))
+ if (args && !strcmp(args, "-h"))
{
mode = DUMP_SCROLLBACK;
args++;
diff --git a/src/process.c b/src/process.c
index 3a39c60..3b9ba54 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1272,7 +1272,12 @@ int key;
{
int mode = DUMP_HARDCOPY;
- if (args && !strcmp(args, "-h"))
+ if (argc > 1 && !strcmp(*args, "--"))
+ {
+ args++;
+ argc--;
+ }
+ else if (args && !strcmp(args, "-h"))
{
mode = DUMP_SCROLLBACK;
args++;
|