aboutsummaryrefslogtreecommitdiff
path: root/contrib/bc/include/history.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bc/include/history.h')
-rw-r--r--contrib/bc/include/history.h58
1 files changed, 29 insertions, 29 deletions
diff --git a/contrib/bc/include/history.h b/contrib/bc/include/history.h
index 1e9962ded1eb..13f6dc6e985c 100644
--- a/contrib/bc/include/history.h
+++ b/contrib/bc/include/history.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -79,27 +79,10 @@
#ifndef BC_HISTORY_H
#define BC_HISTORY_H
-#ifndef BC_ENABLE_HISTORY
-#define BC_ENABLE_HISTORY (1)
-#endif // BC_ENABLE_HISTORY
-
-#ifndef BC_ENABLE_EDITLINE
-#define BC_ENABLE_EDITLINE (0)
-#endif // BC_ENABLE_EDITLINE
-
-#ifndef BC_ENABLE_READLINE
-#define BC_ENABLE_READLINE (0)
-#endif // BC_ENABLE_READLINE
-
-#if BC_ENABLE_EDITLINE && BC_ENABLE_READLINE
-#error Must enable only one of editline or readline, not both.
-#endif // BC_ENABLE_EDITLINE && BC_ENABLE_READLINE
-
-#if BC_ENABLE_EDITLINE || BC_ENABLE_READLINE
-#define BC_ENABLE_LINE_LIB (1)
-#else // BC_ENABLE_EDITLINE || BC_ENABLE_READLINE
-#define BC_ENABLE_LINE_LIB (0)
-#endif // BC_ENABLE_EDITLINE || BC_ENABLE_READLINE
+// These must come before the #if BC_ENABLE_LINE_LIB below because status.h
+// defines it.
+#include <status.h>
+#include <vector.h>
#if BC_ENABLE_LINE_LIB
@@ -107,9 +90,6 @@
#include <setjmp.h>
#include <signal.h>
-#include <status.h>
-#include <vector.h>
-
extern sigjmp_buf bc_history_jmpbuf;
extern volatile sig_atomic_t bc_history_inlinelib;
@@ -140,6 +120,30 @@ typedef struct BcHistory
extern const char bc_history_editrc[];
extern const size_t bc_history_editrc_len;
+#ifdef __APPLE__
+
+/**
+ * Returns true if the line is a valid line, false otherwise.
+ * @param line The line.
+ * @param len The length of the line.
+ * @return True if the line is valid, false otherwise.
+ */
+#define BC_HISTORY_INVALID_LINE(line, len) \
+ ((line) == NULL && ((len) == -1 || errno == EINTR))
+
+#else // __APPLE__
+
+/**
+ * Returns true if the line is a valid line, false otherwise.
+ * @param line The line.
+ * @param len The length of the line.
+ * @return True if the line is valid, false otherwise.
+ */
+#define BC_HISTORY_INVALID_LINE(line, len) \
+ ((line) == NULL && (len) == -1 && errno == EINTR)
+
+#endif // __APPLE__
+
#else // BC_ENABLE_EDITLINE
#if BC_ENABLE_READLINE
@@ -193,10 +197,6 @@ typedef struct BcHistory
#include <vector.h>
#include <read.h>
-#if BC_DEBUG_CODE
-#include <file.h>
-#endif // BC_DEBUG_CODE
-
/// Default columns.
#define BC_HIST_DEF_COLS (80)