pkgsrc/news/knews/patches/patch-bg
fredb 6feb1cc405 Bump version to 1.0nb7 for a couple of gratuitious changes:
Implement percent ('%') filename expansion in the "pipe" widget of the
  save/pipe dialog. Especially useful for setting Knews*shellfield.buffer
  in ${XENVIRONMENT}.

  Count articles for save/pipe command as "1 of N", "2 of N", and so on.
2001-08-15 06:09:01 +00:00

68 lines
1.6 KiB
Text

$NetBSD: patch-bg,v 1.1 2001/08/15 06:09:02 fredb Exp $
--- src/save.c.orig Sun Jul 8 08:31:37 2001
+++ src/save.c
@@ -9,6 +9,7 @@
#include "child.h"
#include "codes.h"
#include "connect.h"
+#include "expand.h"
#include "file.h"
#include "save.h"
#include "sysdeps.h"
@@ -256,6 +257,9 @@
char *buffer;
SERVER *server;
+ sprintf(p, "%ld of %ld", i + 1, n);
+ set_message(message, False);
+
server = cache_get_server(arts[i]->no, False);
if (!server) {
char command[32];
@@ -276,9 +280,6 @@
server_free(server);
else if (!buffer)
return -1;
-
- sprintf(p, "%ld", i + 1);
- set_message(message, False);
}
if (fflush(fp) < 0)
@@ -436,7 +437,7 @@
XtFree(cmd);
}
-static void do_pipe(char *command, SaveScope scope, int what)
+static void do_pipe(char *raw_command, SaveScope scope, int what)
{
FILE *file = NULL;
char *file_name;
@@ -445,6 +446,7 @@
int status, fflush_status;
char message[128];
pid_t pid;
+ char *command;
char *temp;
if (global.busy)
@@ -453,11 +455,17 @@
if (global.mode != NewsModeGroup && global.mode != NewsModeThread) {
set_message("Not in a newsgroup!", True);
return;
- } else if (!command || command[0] == '\0') {
+ } else if (!raw_command || raw_command[0] == '\0') {
set_message("No command specified!", True);
return;
} else if (!(what & (SAVE_HEAD | SAVE_BODY))) {
set_message("Nothing to pipe (neither head or body selected)!", True);
+ return;
+ }
+
+ command = expand_save_text(raw_command);
+ if (!command) {
+ set_message("Shell command expansion failed!", True);
return;
}