Minor improvements in comsat and frm
* comsat/action.c (action_exec): Remove `line' argument. Do not explicitly add locus to the messages. (run_user_action): Add locus to diagnostics mu_debug_t, so it is prepended to all diagnostic messages automatically. * comsat/comsat.c: Improve help output * frm/frm.c (attr_help): Remove unnecessary variable.
Showing
3 changed files
with
31 additions
and
22 deletions
... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
18 | MA 02110-1301 USA */ | 18 | MA 02110-1301 USA */ |
19 | 19 | ||
20 | #include "comsat.h" | 20 | #include "comsat.h" |
21 | #include <mailutils/io.h> | ||
21 | #define obstack_chunk_alloc malloc | 22 | #define obstack_chunk_alloc malloc |
22 | #define obstack_chunk_free free | 23 | #define obstack_chunk_free free |
23 | #include <obstack.h> | 24 | #include <obstack.h> |
... | @@ -287,35 +288,32 @@ action_echo (FILE *tty, const char *cr, int omit_newline, | ... | @@ -287,35 +288,32 @@ action_echo (FILE *tty, const char *cr, int omit_newline, |
287 | } | 288 | } |
288 | 289 | ||
289 | static void | 290 | static void |
290 | action_exec (FILE *tty, int line, int argc, char **argv) | 291 | action_exec (FILE *tty, int argc, char **argv) |
291 | { | 292 | { |
292 | pid_t pid; | 293 | pid_t pid; |
293 | struct stat stb; | 294 | struct stat stb; |
294 | 295 | ||
295 | if (argc == 0) | 296 | if (argc == 0) |
296 | { | 297 | { |
297 | mu_diag_output (MU_DIAG_ERROR, _("%s:.biffrc:%d: no arguments for exec"), username, line); | 298 | mu_diag_output (MU_DIAG_ERROR, _("no arguments for exec")); |
298 | return; | 299 | return; |
299 | } | 300 | } |
300 | 301 | ||
301 | if (argv[0][0] != '/') | 302 | if (argv[0][0] != '/') |
302 | { | 303 | { |
303 | mu_diag_output (MU_DIAG_ERROR, _("%s:.biffrc:%d: not an absolute pathname"), | 304 | mu_diag_output (MU_DIAG_ERROR, _("not an absolute pathname: %s"), argv[0]); |
304 | username, line); | ||
305 | return; | 305 | return; |
306 | } | 306 | } |
307 | 307 | ||
308 | if (stat (argv[0], &stb)) | 308 | if (stat (argv[0], &stb)) |
309 | { | 309 | { |
310 | mu_diag_output (MU_DIAG_ERROR, _("%s:.biffrc:%d: cannot stat %s: %s"), | 310 | mu_diag_funcall (MU_DIAG_ERROR, "stat", argv[0], errno); |
311 | username, line, argv[0], strerror (errno)); | ||
312 | return; | 311 | return; |
313 | } | 312 | } |
314 | 313 | ||
315 | if (stb.st_mode & (S_ISUID|S_ISGID)) | 314 | if (stb.st_mode & (S_ISUID|S_ISGID)) |
316 | { | 315 | { |
317 | mu_diag_output (MU_DIAG_ERROR, _("%s:.biffrc:%d: will not execute set[ug]id programs"), | 316 | mu_diag_output (MU_DIAG_ERROR, _("will not execute set[ug]id programs")); |
318 | username, line); | ||
319 | return; | 317 | return; |
320 | } | 318 | } |
321 | 319 | ||
... | @@ -374,7 +372,15 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg) | ... | @@ -374,7 +372,15 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg) |
374 | if (fp) | 372 | if (fp) |
375 | { | 373 | { |
376 | unsigned line = 1, n; | 374 | unsigned line = 1, n; |
377 | 375 | mu_debug_t debug; | |
376 | char *cwd = mu_getcwd (); | ||
377 | char *rcname; | ||
378 | |||
379 | mu_asprintf (&rcname, "%s/%s", cwd, BIFF_RC); | ||
380 | free (cwd); | ||
381 | |||
382 | mu_diag_get_debug (&debug); | ||
383 | |||
378 | while ((n = act_getline (fp, &stmt, &size))) | 384 | while ((n = act_getline (fp, &stmt, &size))) |
379 | { | 385 | { |
380 | int argc; | 386 | int argc; |
... | @@ -384,6 +390,7 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg) | ... | @@ -384,6 +390,7 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg) |
384 | && argc | 390 | && argc |
385 | && argv[0][0] != '#') | 391 | && argv[0][0] != '#') |
386 | { | 392 | { |
393 | mu_debug_set_locus (debug, rcname, line); | ||
387 | if (strcmp (argv[0], "beep") == 0) | 394 | if (strcmp (argv[0], "beep") == 0) |
388 | { | 395 | { |
389 | /* FIXME: excess arguments are ignored */ | 396 | /* FIXME: excess arguments are ignored */ |
... | @@ -412,15 +419,15 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg) | ... | @@ -412,15 +419,15 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg) |
412 | } | 419 | } |
413 | else if (strcmp (argv[0], "exec") == 0) | 420 | else if (strcmp (argv[0], "exec") == 0) |
414 | { | 421 | { |
415 | action_exec (tty, line, argc - 1, argv + 1); | 422 | action_exec (tty, argc - 1, argv + 1); |
416 | nact++; | 423 | nact++; |
417 | } | 424 | } |
418 | else | 425 | else |
419 | { | 426 | { |
420 | fprintf (tty, _(".biffrc:%d: unknown keyword"), line); | 427 | fprintf (tty, _(".biffrc:%d: unknown keyword"), line); |
421 | fprintf (tty, "\r\n"); | 428 | fprintf (tty, "\r\n"); |
422 | mu_diag_output (MU_DIAG_ERROR, _("%s:.biffrc:%d: unknown keyword %s"), | 429 | mu_diag_output (MU_DIAG_ERROR, _("unknown keyword %s"), |
423 | username, line, argv[0]); | 430 | argv[0]); |
424 | break; | 431 | break; |
425 | } | 432 | } |
426 | } | 433 | } |
... | @@ -429,6 +436,8 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg) | ... | @@ -429,6 +436,8 @@ run_user_action (FILE *tty, const char *cr, mu_message_t msg) |
429 | line += n; | 436 | line += n; |
430 | } | 437 | } |
431 | fclose (fp); | 438 | fclose (fp); |
439 | mu_debug_set_locus (debug, NULL, 0); | ||
440 | free (rcname); | ||
432 | } | 441 | } |
433 | 442 | ||
434 | if (nact == 0) | 443 | if (nact == 0) | ... | ... |
... | @@ -55,6 +55,7 @@ typedef struct utmp UTMP; | ... | @@ -55,6 +55,7 @@ typedef struct utmp UTMP; |
55 | 55 | ||
56 | const char *program_version = "comsatd (" PACKAGE_STRING ")"; | 56 | const char *program_version = "comsatd (" PACKAGE_STRING ")"; |
57 | static char doc[] = "GNU comsatd"; | 57 | static char doc[] = "GNU comsatd"; |
58 | static char args_doc[] = N_("\n--test MBOX-URL MSG-QID"); | ||
58 | 59 | ||
59 | #define OPT_FOREGROUND 256 | 60 | #define OPT_FOREGROUND 256 |
60 | 61 | ||
... | @@ -77,7 +78,7 @@ static error_t comsatd_parse_opt (int key, char *arg, | ... | @@ -77,7 +78,7 @@ static error_t comsatd_parse_opt (int key, char *arg, |
77 | static struct argp argp = { | 78 | static struct argp argp = { |
78 | options, | 79 | options, |
79 | comsatd_parse_opt, | 80 | comsatd_parse_opt, |
80 | NULL, | 81 | args_doc, |
81 | doc, | 82 | doc, |
82 | NULL, | 83 | NULL, |
83 | NULL, NULL | 84 | NULL, NULL | ... | ... |
... | @@ -46,13 +46,6 @@ static struct attr_tab { | ... | @@ -46,13 +46,6 @@ static struct attr_tab { |
46 | { NULL } | 46 | { NULL } |
47 | }; | 47 | }; |
48 | 48 | ||
49 | static char attr_help[] = | ||
50 | /* TRANSLATORS: Please do *not* translate the words "new", "unread", | ||
51 | "old" and "read". They are keywords. */ | ||
52 | N_("select messages with the specific attribute: \ | ||
53 | new, unread, old (same as unread) or read (or any unambiguous \ | ||
54 | abbreviation of these)"); | ||
55 | |||
56 | 49 | ||
57 | /* Attribute table handling */ | 50 | /* Attribute table handling */ |
58 | 51 | ||
... | @@ -127,10 +120,16 @@ static struct argp_option options[] = { | ... | @@ -127,10 +120,16 @@ static struct argp_option options[] = { |
127 | {"field", 'f', N_("NAME"), 0, N_("header field to display"), 0}, | 120 | {"field", 'f', N_("NAME"), 0, N_("header field to display"), 0}, |
128 | {"to", 'l', NULL, 0, N_("include the To: information"), 0}, | 121 | {"to", 'l', NULL, 0, N_("include the To: information"), 0}, |
129 | {"number", 'n', NULL, 0, N_("display message numbers"), 0}, | 122 | {"number", 'n', NULL, 0, N_("display message numbers"), 0}, |
130 | {"Quiet", 'Q', NULL, 0, N_("very quiet"), 0}, | 123 | {"Quiet", 'Q', NULL, 0, N_("do not display headers"), 0}, |
131 | {"query", 'q', NULL, 0, N_("print a message if the mailbox contains some unread mail"), 0}, | 124 | {"query", 'q', NULL, 0, N_("print a message if the mailbox contains some unread mail"), 0}, |
132 | {"summary",'S', NULL, 0, N_("print a summary of messages"), 0}, | 125 | {"summary",'S', NULL, 0, N_("print a summary of messages"), 0}, |
133 | {"status", 's', N_("STATUS"), 0, attr_help, 0}, | 126 | {"status", 's', N_("STATUS"), 0, |
127 | /* TRANSLATORS: Please do *not* translate the words "new", "unread", | ||
128 | "old" and "read". They are keywords. */ | ||
129 | N_("select messages with the specific attribute:" | ||
130 | " new, unread, old (same as unread) or read (or any unambiguous" | ||
131 | " abbreviation of these)"), | ||
132 | 0}, | ||
134 | {"align", 't', NULL, 0, N_("tidy mode: align subject lines"), 0}, | 133 | {"align", 't', NULL, 0, N_("tidy mode: align subject lines"), 0}, |
135 | {0, 0, 0, 0} | 134 | {0, 0, 0, 0} |
136 | }; | 135 | }; | ... | ... |
-
Please register or sign in to post a comment