Commit e20d435c e20d435c8e310046c15acbdf47fa458fe7ead1ae by Sergey Poznyakoff

Minor improvements in logstream and related code.

* include/mailutils/stream.h (MU_IOCTL_LOGSTREAM_SET_LOCUS_LINE)
(MU_IOCTL_LOGSTREAM_SET_LOCUS_COL): New subcodes.
* libmailutils/stream/logstream.c (_log_ctl): Handle two new subcodes.
* comsat/action.c (eval_biffrc): Use new ioctl subcode to update the
line number.
1 parent 06fb6b02
......@@ -522,12 +522,12 @@ eval_biffrc (struct biffrc_environ *env)
ws.ws_comment = "#";
wsflags = MU_WRDSF_DEFFLAGS | MU_WRDSF_COMMENT;
while (mu_stream_getline (env->input, &stmt, &size, &n) == 0 && n > 0)
{
mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_SET_LOCUS, &env->locus);
mu_stream_ioctl (env->logstr, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_SET_LOCUS, &env->locus);
while (mu_stream_getline (env->input, &stmt, &size, &n) == 0 && n > 0)
{
if (strncmp (stmt, "#line ", 6) == 0)
{
char *p;
......@@ -540,9 +540,11 @@ eval_biffrc (struct biffrc_environ *env)
else
{
mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_SET_LOCUS, &env->locus);
MU_IOCTL_LOGSTREAM_SET_LOCUS_LINE,
&env->locus.mu_line);
mu_stream_ioctl (env->logstr, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_SET_LOCUS, &env->locus);
MU_IOCTL_LOGSTREAM_SET_LOCUS_LINE,
&env->locus.mu_line);
}
continue;
}
......@@ -553,7 +555,10 @@ eval_biffrc (struct biffrc_environ *env)
if (ws.ws_wordc == 0)
{
env->locus.mu_line++;
mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE, NULL);
mu_stream_ioctl (env->logstr, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE, NULL);
continue;
}
......@@ -591,7 +596,10 @@ eval_biffrc (struct biffrc_environ *env)
report_error (env, "%s", mu_wordsplit_strerror (&ws));
wsflags |= MU_WRDSF_REUSE;
env->locus.mu_line++;
mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE, NULL);
mu_stream_ioctl (env->logstr, MU_IOCTL_LOGSTREAM,
MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE, NULL);
}
free (stmt);
mu_wordsplit_free (&ws);
......
......@@ -108,26 +108,36 @@ enum mu_buffer_type
#define MU_IOCTL_LOGSTREAM_GET_MODE 4
#define MU_IOCTL_LOGSTREAM_SET_MODE 5
/* Set locus line.
Arg: unsigned *
*/
#define MU_IOCTL_LOGSTREAM_SET_LOCUS_LINE 6
/* Set locus column.
Arg: unsigned *
*/
#define MU_IOCTL_LOGSTREAM_SET_LOCUS_COL 7
/* Advance locus line.
Arg: NULL (increment by 1)
int *
*/
#define MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE 6
#define MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE 8
/* Advance locus column.
Arg: NULL (increment by 1)
int *
*/
#define MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_COL 7
#define MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_COL 9
/* Suppress output of messages having severity lower than the
given threshold.
Arg: int *
*/
#define MU_IOCTL_LOGSTREAM_SUPPRESS_SEVERITY 8
#define MU_IOCTL_LOGSTREAM_SUPPRESS_SEVERITY 10
/* Same as above, but:
Arg: const char *
*/
#define MU_IOCTL_LOGSTREAM_SUPPRESS_SEVERITY_NAME 9
#define MU_IOCTL_LOGSTREAM_SUPPRESS_SEVERITY_NAME 11
/* Opcodes for MU_IOCTL_XSCRIPTSTREAM */
/* Swap transcript levels.
......
......@@ -378,6 +378,18 @@ _log_ctl (struct _mu_stream *str, int code, int opcode, void *arg)
break;
}
case MU_IOCTL_LOGSTREAM_SET_LOCUS_LINE:
if (!arg)
return EINVAL;
sp->locus.mu_line = *(unsigned*)arg;
break;
case MU_IOCTL_LOGSTREAM_SET_LOCUS_COL:
if (!arg)
return EINVAL;
sp->locus.mu_col = *(unsigned*)arg;
break;
case MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE:
if (!arg)
sp->locus.mu_line++;
......