Author | Jamozed <[email protected]> |
Date | 2021-11-26 02:45:27 |
Commit | 19538ba5d979a5bd3fb6c78d7312225bf3ed287d |
Parent | 4eee86debb5d4b41362589324711a460eaf7ff3c |
Add alert function to util/error
Diffstat
M | src/bltn.c | | | 2 | +- |
M | src/bltns/set.c | | | 2 | +- |
R | src/cll/error.c -> src/util/error.c | | | 11 | +++++++++-- |
R | src/cll/error.h -> src/util/error.h | | | 12 | ++++++++---- |
M | src/conf.c | | | 4 | +--- |
M | src/eval.c | | | 3 | ++- |
M | src/exec.c | | | 3 | +-- |
M | src/lex.c | | | 3 | +-- |
M | src/lineread.c | | | 3 | +-- |
M | src/main.c | | | 2 | +- |
M | src/parse.c | | | 8 | +------- |
11 files changed, 27 insertions, 26 deletions
diff --git a/src/bltn.c b/src/bltn.c index c854294..7e06b2c 100644 --- a/src/bltn.c +++ b/src/bltn.c @@ -33,8 +33,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #include "alias.h" #include "bltn.h" #include "esh.h" +#include "util/error.h" -#include "cll/error.h" #include "cll/optget.h" #include <stdio.h> diff --git a/src/bltns/set.c b/src/bltns/set.c index 36ec030..fd50ebc 100644 --- a/src/bltns/set.c +++ b/src/bltns/set.c @@ -31,9 +31,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. */ #include "../conf.h" +#include "../util/error.h" #include "../cll/optget.h" -#include "../cll/error.h" #include "../cll/strconv.h" #include <stddef.h> diff --git a/src/conf.c b/src/conf.c index 5ad2f73..1528203 100644 --- a/src/conf.c +++ b/src/conf.c @@ -32,9 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #include "conf.h" #include "esh.h" - -#include "cll/error.h" - +#include "util/error.h" #include "util/util.h" #include <unistd.h> diff --git a/src/eval.c b/src/eval.c index 61496ee..98778d9 100644 --- a/src/eval.c +++ b/src/eval.c @@ -31,9 +31,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. */ #include "esh.h" +#include "util/error.h" #include "util/util.h" -#include "cll/error.h" +#include <unistd.h> #include <errno.h> #include <stdio.h> diff --git a/src/exec.c b/src/exec.c index 6fd4546..daa35b6 100644 --- a/src/exec.c +++ b/src/exec.c @@ -32,8 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #include "bltn.h" #include "esh.h" - -#include "cll/error.h" +#include "util/error.h" #include <fcntl.h> #include <sys/stat.h> diff --git a/src/lex.c b/src/lex.c index e84545d..d70cfe4 100644 --- a/src/lex.c +++ b/src/lex.c @@ -31,11 +31,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. */ #include "lex.h" +#include "util/error.h" #include "util/stack.h" #include "util/util.h" -#include "cll/error.h" - #include <ctype.h> #include <stdio.h> #include <stdlib.h> diff --git a/src/lineread.c b/src/lineread.c index 1f6187b..81fe185 100644 --- a/src/lineread.c +++ b/src/lineread.c @@ -32,10 +32,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #include "conf.h" #include "lineread.h" +#include "util/error.h" #include "util/util.h" -#include "cll/error.h" - #include <sys/ioctl.h> #include <termios.h> #include <unistd.h> diff --git a/src/main.c b/src/main.c index cdcca1a..d91060c 100644 --- a/src/main.c +++ b/src/main.c @@ -40,9 +40,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. #include "conf.h" #include "esh.h" #include "lineread.h" +#include "util/error.h" #include "util/util.h" -#include "cll/error.h" #include "cll/optget.h" #include <sys/stat.h> diff --git a/src/parse.c b/src/parse.c index 3ab46da..882ee26 100644 --- a/src/parse.c +++ b/src/parse.c @@ -30,18 +30,12 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. */ -/* - FIXME redirecting the output of a command before a pipe results in the - post-pipe command hanging indefinitely and leaking memory. -*/ - #include "esh.h" #include "lex.h" +#include "util/error.h" #include "util/stack.h" #include "util/util.h" -#include "cll/error.h" - #include <stdio.h> #include <stdlib.h> diff --git a/src/cll/error.c b/src/util/error.c similarity index 87% rename from src/cll/error.c rename to src/util/error.c index e0c80d3..e51a00d 100644 --- a/src/cll/error.c +++ b/src/util/error.c @@ -1,5 +1,5 @@ -// error.c, version 1.0.2 -// Error source file for OMKOV lib +// util/error.c +// Error utility source file for ESH // Copyright (C) 2020, Jakob Wakeling // All rights reserved. @@ -57,5 +57,12 @@ void warn(const char *format, ...) { fputc('\n', stderr); warned = true; return; } +/* Print a warning message but do not set the warned flag */ +void alert(const char *format, ...) { + fflush(stdout); if (A0) { fputs(A0, stderr); fputs(": ", stderr); } + va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); + fputc('\n', stderr); return; +} + /* Shorthand for strerror(errno) */ char *serr(void) { return strerror(errno); } diff --git a/src/cll/error.h b/src/util/error.h similarity index 89% rename from src/cll/error.h rename to src/util/error.h index 16db9cf..2a242ec 100644 --- a/src/cll/error.h +++ b/src/util/error.h @@ -1,5 +1,5 @@ -// error.h, version 1.0.2 -// Error header file for OMKOV lib +// util/error.h +// Error utility header file for ESH // Copyright (C) 2020, Jakob Wakeling // All rights reserved. @@ -30,17 +30,21 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. */ -#ifndef OMKOV_LIB_ERROR_H_38W06M3W -#define OMKOV_LIB_ERROR_H_38W06M3W +#ifndef ESH_UTIL_ERROR_H_38W06M3W +#define ESH_UTIL_ERROR_H_38W06M3W +#include <errno.h> #include <stdbool.h> #include <stdnoreturn.h> +#define SERR (strerror(errno)) + extern char *A0; extern bool warned; extern noreturn void error(int status, const char *format, ...); extern void warn(const char *format, ...); +extern void alert(const char *format, ...); extern char *serr(void);