2001-05-14 16:38:08 +00:00
|
|
|
|
/* Copyright (C) 2001 Free Software Foundation, Inc.
|
2001-05-02 00:45:45 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2001-05-02 00:45:45 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
* Lesser General Public License for more details.
|
2001-05-02 00:45:45 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
*/
|
2001-05-02 00:45:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-03-25 23:54:07 +00:00
|
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
|
|
# include <config.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2001-05-02 00:45:45 +00:00
|
|
|
|
#include <stdio.h>
|
2001-06-20 17:33:43 +00:00
|
|
|
|
#include <string.h>
|
2002-02-11 17:17:48 +00:00
|
|
|
|
#include <stdarg.h>
|
2001-05-02 00:45:45 +00:00
|
|
|
|
|
|
|
|
|
|
#include "libguile/_scm.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "libguile/deprecation.h"
|
|
|
|
|
|
#include "libguile/strings.h"
|
|
|
|
|
|
#include "libguile/ports.h"
|
|
|
|
|
|
|
2002-02-27 15:41:01 +00:00
|
|
|
|
/* Windows defines. */
|
|
|
|
|
|
#ifdef __MINGW32__
|
|
|
|
|
|
#define vsnprintf _vsnprintf
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2001-05-02 00:45:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
2001-08-31 14:42:31 +00:00
|
|
|
|
#if (SCM_ENABLE_DEPRECATED == 1)
|
2001-05-02 00:45:45 +00:00
|
|
|
|
|
2002-02-11 17:17:48 +00:00
|
|
|
|
struct issued_warning {
|
|
|
|
|
|
struct issued_warning *prev;
|
|
|
|
|
|
const char *message;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static struct issued_warning *issued_warnings;
|
|
|
|
|
|
static enum { detailed, summary, summary_print } mode;
|
2001-05-02 00:45:45 +00:00
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_c_issue_deprecation_warning (const char *msg)
|
|
|
|
|
|
{
|
2002-02-11 17:17:48 +00:00
|
|
|
|
if (mode != detailed)
|
|
|
|
|
|
mode = summary_print;
|
2001-05-02 00:45:45 +00:00
|
|
|
|
else
|
2002-02-11 17:17:48 +00:00
|
|
|
|
{
|
|
|
|
|
|
struct issued_warning *iw;
|
|
|
|
|
|
for (iw = issued_warnings; iw; iw = iw->prev)
|
|
|
|
|
|
if (!strcmp (iw->message, msg))
|
|
|
|
|
|
return;
|
|
|
|
|
|
if (scm_gc_running_p)
|
|
|
|
|
|
fprintf (stderr, "%s\n", msg);
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_puts (msg, scm_current_error_port ());
|
|
|
|
|
|
scm_newline (scm_current_error_port ());
|
|
|
|
|
|
}
|
|
|
|
|
|
msg = strdup (msg);
|
2002-08-16 22:01:10 +00:00
|
|
|
|
iw = scm_malloc (sizeof (struct issued_warning));
|
2002-02-11 17:17:48 +00:00
|
|
|
|
if (msg == NULL || iw == NULL)
|
|
|
|
|
|
return;
|
|
|
|
|
|
iw->message = msg;
|
|
|
|
|
|
iw->prev = issued_warnings;
|
|
|
|
|
|
issued_warnings = iw;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_c_issue_deprecation_warning_fmt (const char *msg, ...)
|
|
|
|
|
|
{
|
|
|
|
|
|
va_list ap;
|
|
|
|
|
|
char buf[512];
|
|
|
|
|
|
|
|
|
|
|
|
va_start (ap, msg);
|
|
|
|
|
|
vsnprintf (buf, 511, msg, ap);
|
2003-07-09 22:07:11 +00:00
|
|
|
|
va_end (ap);
|
2002-02-11 17:17:48 +00:00
|
|
|
|
buf[511] = '\0';
|
|
|
|
|
|
scm_c_issue_deprecation_warning (buf);
|
2001-05-02 00:45:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE(scm_issue_deprecation_warning,
|
|
|
|
|
|
"issue-deprecation-warning", 0, 0, 1,
|
|
|
|
|
|
(SCM msgs),
|
|
|
|
|
|
"Output @var{msgs} to @code{(current-error-port)} when this "
|
|
|
|
|
|
"is the first call to @code{issue-deprecation-warning} with "
|
2002-02-11 17:17:48 +00:00
|
|
|
|
"this specific @var{msgs}. Do nothing otherwise. "
|
2001-05-02 00:45:45 +00:00
|
|
|
|
"The argument @var{msgs} should be a list of strings; "
|
|
|
|
|
|
"they are printed in turn, each one followed by a newline.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_issue_deprecation_warning
|
|
|
|
|
|
{
|
2002-02-11 17:17:48 +00:00
|
|
|
|
if (mode != detailed)
|
|
|
|
|
|
mode = summary_print;
|
2001-05-02 00:45:45 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
|
|
|
|
SCM nl = scm_from_locale_string ("\n");
|
2002-02-11 17:17:48 +00:00
|
|
|
|
SCM msgs_nl = SCM_EOL;
|
* stime.c, socket.c, simpos.c, procs.c, posix.c, ports.c,
net_db.c, fports.c, filesys.c, eval.c, deprecation.c, dynl.c:
Replaced uses of SCM_STRING_CHARS with proper uses of
scm_to_locale_string. Replaced SCM_STRINGP with scm_is_string.
Replaced scm_mem2string with scm_from_locale_string.
* simpos.c, posix.c (allocate_string_pointers, environ_list_to_c):
Removed, replaced all uses with scm_i_allocate_string_pointers.
2004-08-10 14:08:02 +00:00
|
|
|
|
char *c_msgs;
|
2002-02-11 17:17:48 +00:00
|
|
|
|
while (SCM_CONSP (msgs))
|
2001-05-02 00:45:45 +00:00
|
|
|
|
{
|
2002-02-11 17:17:48 +00:00
|
|
|
|
if (msgs_nl != SCM_EOL)
|
|
|
|
|
|
msgs_nl = scm_cons (nl, msgs_nl);
|
|
|
|
|
|
msgs_nl = scm_cons (SCM_CAR (msgs), msgs_nl);
|
|
|
|
|
|
msgs = SCM_CDR (msgs);
|
2001-05-02 00:45:45 +00:00
|
|
|
|
}
|
2002-02-11 17:17:48 +00:00
|
|
|
|
msgs_nl = scm_string_append (scm_reverse_x (msgs_nl, SCM_EOL));
|
* stime.c, socket.c, simpos.c, procs.c, posix.c, ports.c,
net_db.c, fports.c, filesys.c, eval.c, deprecation.c, dynl.c:
Replaced uses of SCM_STRING_CHARS with proper uses of
scm_to_locale_string. Replaced SCM_STRINGP with scm_is_string.
Replaced scm_mem2string with scm_from_locale_string.
* simpos.c, posix.c (allocate_string_pointers, environ_list_to_c):
Removed, replaced all uses with scm_i_allocate_string_pointers.
2004-08-10 14:08:02 +00:00
|
|
|
|
c_msgs = scm_to_locale_string (msgs_nl);
|
|
|
|
|
|
scm_c_issue_deprecation_warning (c_msgs);
|
|
|
|
|
|
free (c_msgs);
|
2001-05-02 00:45:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
print_deprecation_summary (void)
|
|
|
|
|
|
{
|
2002-02-11 17:17:48 +00:00
|
|
|
|
if (mode == summary_print)
|
2001-05-02 00:45:45 +00:00
|
|
|
|
{
|
|
|
|
|
|
fputs ("\n"
|
|
|
|
|
|
"Some deprecated features have been used. Set the environment\n"
|
|
|
|
|
|
"variable GUILE_WARN_DEPRECATED to \"detailed\" and rerun the\n"
|
|
|
|
|
|
"program to get more information. Set it to \"no\" to suppress\n"
|
|
|
|
|
|
"this message.\n", stderr);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE(scm_include_deprecated_features,
|
|
|
|
|
|
"include-deprecated-features", 0, 0, 0,
|
|
|
|
|
|
(),
|
2001-05-22 22:46:39 +00:00
|
|
|
|
"Return @code{#t} iff deprecated features should be included "
|
|
|
|
|
|
"in public interfaces.")
|
2001-05-02 00:45:45 +00:00
|
|
|
|
#define FUNC_NAME s_scm_include_deprecated_features
|
|
|
|
|
|
{
|
2004-07-06 10:59:25 +00:00
|
|
|
|
return scm_from_bool (SCM_ENABLE_DEPRECATED == 1);
|
2001-05-02 00:45:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_init_deprecation ()
|
|
|
|
|
|
{
|
2001-08-31 14:42:31 +00:00
|
|
|
|
#if (SCM_ENABLE_DEPRECATED == 1)
|
2001-05-02 00:45:45 +00:00
|
|
|
|
const char *level = getenv ("GUILE_WARN_DEPRECATED");
|
|
|
|
|
|
if (level == NULL)
|
2001-05-16 07:20:53 +00:00
|
|
|
|
level = SCM_WARN_DEPRECATED_DEFAULT;
|
2001-05-02 00:45:45 +00:00
|
|
|
|
if (!strcmp (level, "detailed"))
|
2002-02-11 17:17:48 +00:00
|
|
|
|
mode = detailed;
|
2001-05-02 00:45:45 +00:00
|
|
|
|
else if (!strcmp (level, "no"))
|
2002-02-11 17:17:48 +00:00
|
|
|
|
mode = summary;
|
2001-05-02 00:45:45 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2002-02-11 17:17:48 +00:00
|
|
|
|
mode = summary;
|
2001-05-02 00:45:45 +00:00
|
|
|
|
atexit (print_deprecation_summary);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
#include "libguile/deprecation.x"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End: */
|