Fixed print command with additional arguments.

Previous version ignored second argument if more than 2 were given and
quoted the additional arguments leading to lp thinking they represented
a filename.

Before:
:print HPF300 14-15 -o side=onesided
-> lp -d HPF300 -P 1-38 ' -o side=onesided' 'filename'

Now:
:print HPF300 14-15 -o side=onesided
-> lp -d HPF300 -P 14-15  -o side=onesided 'filename'

Signed-off-by: mlq <mlq@pwmt.org>
This commit is contained in:
Moritz Lipp 2011-03-09 01:35:08 +00:00
parent 64fe1f132d
commit d7e82969a5

View file

@ -3529,7 +3529,7 @@ cmd_print(int argc, char** argv)
}
char* printer = argv[0];
char* sites = (argc == 2) ? g_strdup(argv[1]) : g_strdup_printf("1-%i", Zathura.PDF.number_of_pages);
char* sites = (argc >= 2) ? g_strdup(argv[1]) : g_strdup_printf("1-%i", Zathura.PDF.number_of_pages);
GString *addit = g_string_new("");
int i;
@ -3542,13 +3542,11 @@ cmd_print(int argc, char** argv)
}
char* escaped_filename = g_shell_quote(Zathura.PDF.file);
char* escaped_addit = addit->len ? g_shell_quote(addit->str) : g_strdup("");
char* command = g_strdup_printf(print_command, printer, sites, escaped_addit, escaped_filename);
char* command = g_strdup_printf(print_command, printer, sites, addit->str, escaped_filename);
system(command);
g_free(sites);
g_free(escaped_filename);
g_free(escaped_addit);
g_free(command);
g_string_free(addit, TRUE);