From 6cd86a2fead07e6bd61ac7cfa4bf720bb7b536ca Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Fri, 23 Sep 2022 13:05:50 +0300 Subject: [PATCH] Remove redundant header file sweep.h --- sweep.c | 32 +++++++++++++++++++------------- sweep.h | 47 ----------------------------------------------- 2 files changed, 19 insertions(+), 60 deletions(-) delete mode 100644 sweep.h diff --git a/sweep.c b/sweep.c index e55496e..847d981 100644 --- a/sweep.c +++ b/sweep.c @@ -30,16 +30,30 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "sweep.h" +#include "emacs-module.h" +#include +#include #include #include #include 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; @@ -93,14 +107,6 @@ ecdr(emacs_env *env, emacs_value cons) { 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"); } @@ -373,9 +379,9 @@ sweep_next_solution(emacs_env *env, ptrdiff_t nargs, emacs_value *args, void *da 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; } @@ -429,7 +435,7 @@ sweep_open_query(emacs_env *env, ptrdiff_t nargs, emacs_value *args, void *data) 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); diff --git a/sweep.h b/sweep.h deleted file mode 100644 index bc0d950..0000000 --- a/sweep.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - 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 -#include - -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*/ -- 2.39.2