Commit 79aadeff 79aadeff3be8c1fd7cc10a05ad53f0b5f38e8862 by Sergey Poznyakoff

removed mail_[set_]is_terminal(), interactive is used instead.

1 parent 2a4860b9
......@@ -17,8 +17,6 @@
#include "mail.h"
static int is_terminal;
#define COND_STK_SIZE 64
#define COND_STK_INCR 16
static int *_cond_stack; /* Stack of conditions */
......@@ -54,7 +52,7 @@ _cond_push(int val)
if (!_cond_stack)
{
fprintf(ofile, "not enough memeory");
util_error("not enough memory");
exit (EXIT_FAILURE);
}
_cond_stack[_cond_level++] = val;
......@@ -65,7 +63,7 @@ _cond_pop()
{
if (_cond_level == 0)
{
fprintf(ofile, "internal error: condition stack underflow\n");
util_error("internal error: condition stack underflow");
abort();
}
return _cond_stack[--_cond_level];
......@@ -87,13 +85,13 @@ mail_if (int argc, char **argv)
if (argc != 2)
{
fprintf(ofile, "if requires an argument: s | r | t\n");
util_error("if requires an argument: s | r | t");
return 1;
}
if (argv[1][1] != 0)
{
fprintf(ofile, "valid if arguments are: s | r | t\n");
util_error("valid if arguments are: s | r | t");
return 1;
}
......@@ -117,10 +115,10 @@ mail_if (int argc, char **argv)
cond = strcmp(mode->value, "send") != 0;
break;
case 't': /* Reading from a terminal */
cond = is_terminal;
cond = interactive;
break;
default:
fprintf(ofile, "valid if arguments are: s | r | t\n");
util_error("valid if arguments are: s | r | t");
return 1;
}
}
......@@ -135,7 +133,7 @@ mail_else (int argc, char **argv)
int cond;
if (_cond_level == 0)
{
fprintf(ofile, "else without matching if\n");
util_error("else without matching if");
return 1;
}
cond = _cond_pop();
......@@ -150,21 +148,11 @@ mail_endif (int argc, char **argv)
{
if (_cond_level == 0)
{
fprintf(ofile, "endif without matching if\n");
util_error("endif without matching if");
return 1;
}
_cond_pop();
return 1;
}
void
mail_set_is_terminal(int val)
{
is_terminal = val;
}
int
mail_is_terminal(void)
{
return is_terminal;
}
......
......@@ -48,21 +48,21 @@ mail_source (int argc, char **argv)
if (argc != 2)
{
fprintf(ofile, "source requires an argument\n");
util_error("source requires an argument");
return 1;
}
fp = fopen (argv[1], "r");
if (!fp)
{
fprintf(ofile, "can't open `%s': %s\n", argv[1], strerror(errno));
util_error("can't open `%s': %s", argv[1], strerror(errno));
return 1;
}
save_term = mail_is_terminal();
mail_set_is_terminal(0);
save_term = interactive;
interactive = 0;
mail_mainloop(source_readline, fp, 0);
mail_set_is_terminal(save_term);
interactive = save_term;
fclose (fp);
return 0;
}
......