POSSIBILITY OF SUCH DAMAGE.
*/
-#include "sweep.h"
+#include "emacs-module.h"
+#include <SWI-Prolog.h>
+#include <SWI-Stream.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int plugin_is_GPL_compatible;
-term_t o = 0;
+term_t output_term = 0;
emacs_env * current_env = NULL;
+static int value_to_term(emacs_env*, emacs_value, term_t);
+static emacs_value term_to_value(emacs_env*, term_t);
+
+void
+ethrow(emacs_env *env, const char * message) {
+ ptrdiff_t len = strlen(message);
+
+ emacs_value str = env->make_string(env, message, len);
+ emacs_value arg = env->funcall (env, env->intern (env, "list"), 1, &str);
+ env->non_local_exit_signal(env, env->intern(env, "error"), arg);
+}
+
char*
estring_to_cstring(emacs_env *eenv, emacs_value estring, ptrdiff_t *len_p) {
char * buf = NULL;
return env->funcall (env, env->intern (env, "cdr"), 1, &cons);
}
-void
-ethrow(emacs_env *env, const char * message) {
- ptrdiff_t len = strlen(message);
-
- emacs_value str = env->make_string(env, message, len);
- emacs_value arg = env->funcall (env, env->intern (env, "list"), 1, &str);
- env->non_local_exit_signal(env, env->intern(env, "error"), arg);
-}
emacs_value
enil(emacs_env *env) { return env->intern(env, "nil"); }
case PL_S_FALSE:
return enil(env);
case PL_S_TRUE:
- return econs(env, et(env), term_to_value(env, o));
+ return econs(env, et(env), term_to_value(env, output_term));
case PL_S_LAST:
- return econs(env, env->intern(env, "!"), term_to_value(env, o));
+ return econs(env, env->intern(env, "!"), term_to_value(env, output_term));
default:
return NULL;
}
PL_open_query(n, PL_Q_NODEBUG | PL_Q_EXT_STATUS | PL_Q_CATCH_EXCEPTION, p, a);
- o = a+(env->is_not_nil(env, s) ? 0 : 1);
+ output_term = a+(env->is_not_nil(env, s) ? 0 : 1);
r = et(env);
+++ /dev/null
-/*
- Author: Eshel Yaron
- E-mail: eshel@swi-prolog.org
- Copyright (c) 2022, SWI-Prolog Solutions b.v.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef _SWEEP_H
-#define _SWEEP_H
-
-#include "emacs-module.h"
-#include <SWI-Prolog.h>
-#include <SWI-Stream.h>
-
-static int value_to_term(emacs_env*, emacs_value, term_t);
-static emacs_value term_to_value(emacs_env*, term_t);
-static char * estring_to_cstring(emacs_env*, emacs_value, ptrdiff_t*);
-static void ethrow(emacs_env*, const char*);
-/* static int estring_to_atom(emacs_env*, emacs_value, term_t); */
-/* static IOSTREAM * estring_to_stream(emacs_env*, emacs_value); */
-
-#endif /*_SWEEP_H*/