diff --git a/ChangeLog b/ChangeLog index 4fc82d682..88b3a520e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-01-28 Stefan Jahn + + * configure.in (guile_cv_have_uint32_t): Look also in + `stdint.h' for uint32_t. + 2002-01-13 Neil Jerram * Makefile.am (SUBDIRS): Added lang. diff --git a/configure.in b/configure.in index 9618a9734..4607b4d76 100644 --- a/configure.in +++ b/configure.in @@ -348,7 +348,12 @@ fi AC_MSG_CHECKING(whether uint32_t is defined) AC_CACHE_VAL(guile_cv_have_uint32_t, [AC_TRY_COMPILE([#include - #include ], + #if HAVE_STDINT_H + #include + #endif + #ifndef __MINGW32__ + #include + #endif], [uint32_t a;], guile_cv_have_uint32_t=yes, guile_cv_have_uint32_t=no)]) AC_MSG_RESULT($guile_cv_have_uint32_t) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index f28ecbbb0..767002040 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,19 @@ +2002-01-28 Stefan Jahn + + * symbols.c (scm_c_symbol2str): New function, replacement for + `gh_scm2newsymbol()'. + + * strings.c (scm_c_substring2str): New function. Proper + replacement for `gh_get_substr()'. + + * socket.c: Include `stdint.h' if available for the `uint32_t' + declaration. + + * scmsigs.c (s_scm_sigaction): Initialize `chandler' (inhibits + compiler warning). + + * backtrace.c: Include `lang.h' for GUILE_DEBUG conditional. + 2002-01-22 Neil Jerram Other changes unrelated to Elisp... diff --git a/libguile/Makefile.am b/libguile/Makefile.am index 14aae5521..e3bb3b3ea 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -203,7 +203,7 @@ SUFFIXES = .x .doc .c.doc: -(test -n "${AWK+set}" || AWK="@AWK@"; ${AWK} -f ./guile-func-name-check $<) (./guile-snarf-docs $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $< | \ - ./guile_filter_doc_snarfage --filter-snarfage) > $@ || { rm $@; false; } + ./guile_filter_doc_snarfage$(EXEEXT) --filter-snarfage) > $@ || { rm $@; false; } $(DOT_X_FILES) $(EXTRA_DOT_DOC_FILES): snarf.h guile-snarf.in diff --git a/libguile/backtrace.c b/libguile/backtrace.c index 290627fbb..baa0e6e1a 100644 --- a/libguile/backtrace.c +++ b/libguile/backtrace.c @@ -67,6 +67,7 @@ #include "libguile/strings.h" #include "libguile/validate.h" +#include "libguile/lang.h" #include "libguile/backtrace.h" #include "libguile/filesys.h" diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c index 97375e8af..da1f93bfe 100644 --- a/libguile/scmsigs.c +++ b/libguile/scmsigs.c @@ -187,7 +187,7 @@ SCM_DEFINE (scm_sigaction, "sigaction", 1, 2, 0, struct sigaction action; struct sigaction old_action; #else - SIGRETTYPE (* chandler) (int); + SIGRETTYPE (* chandler) (int) = SIG_DFL; SIGRETTYPE (* old_chandler) (int); #endif int query_only = 0; diff --git a/libguile/socket.c b/libguile/socket.c index 7dc729ca1..10c064242 100644 --- a/libguile/socket.c +++ b/libguile/socket.c @@ -58,6 +58,9 @@ #include "win32-socket.h" #endif +#ifdef HAVE_STDINT_H +#include +#endif #ifdef HAVE_STRING_H #include #endif diff --git a/libguile/strings.c b/libguile/strings.c index 3aa24958d..6744a58c6 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -350,12 +350,13 @@ SCM_DEFINE (scm_string_append, "string-append", 0, 0, 1, determine the length of the returned value. However, the function always copies the complete contents of OBJ, and sets *LENP to the length of the scheme string (if LENP is non-null). */ +#define FUNC_NAME "scm_c_string2str" char * scm_c_string2str (SCM obj, char *str, size_t *lenp) { size_t len; - SCM_ASSERT (SCM_STRINGP (obj), obj, SCM_ARG1, "scm_c_string2str"); + SCM_ASSERT (SCM_STRINGP (obj), obj, SCM_ARG1, FUNC_NAME); len = SCM_STRING_LENGTH (obj); if (str == NULL) @@ -376,6 +377,30 @@ scm_c_string2str (SCM obj, char *str, size_t *lenp) return str; } +#undef FUNC_NAME + + +/* Copy LEN characters at START from the Scheme string OBJ to memory + at STR. START is an index into OBJ; zero means the beginning of + the string. STR has already been allocated by the caller. + + If START + LEN is off the end of OBJ, silently truncate the source + region to fit the string. If truncation occurs, the corresponding + area of STR is left unchanged. */ +#define FUNC_NAME "scm_c_substring2str" +char * +scm_c_substring2str (SCM obj, char *str, size_t start, size_t len) +{ + size_t src_length, effective_length; + + SCM_ASSERT (SCM_STRINGP (obj), obj, SCM_ARG2, FUNC_NAME); + src_length = SCM_STRING_LENGTH (obj); + effective_length = (len + start <= src_length) ? len : src_length - start; + memcpy (str, SCM_STRING_CHARS (obj) + start, effective_length); + scm_remember_upto_here_1 (obj); + return str; +} +#undef FUNC_NAME void diff --git a/libguile/strings.h b/libguile/strings.h index ea1bf7132..aea044dd9 100644 --- a/libguile/strings.h +++ b/libguile/strings.h @@ -79,6 +79,7 @@ SCM_API SCM scm_substring (SCM str, SCM start, SCM end); SCM_API SCM scm_string_append (SCM args); SCM_API void scm_init_strings (void); SCM_API char *scm_c_string2str (SCM obj, char *str, size_t *lenp); +SCM_API char *scm_c_substring2str (SCM obj, char *str, size_t start, size_t len); diff --git a/libguile/symbols.c b/libguile/symbols.c index 0a408234b..c3e22c865 100644 --- a/libguile/symbols.c +++ b/libguile/symbols.c @@ -318,6 +318,50 @@ SCM_DEFINE (scm_symbol_pset_x, "symbol-pset!", 2, 0, 0, } #undef FUNC_NAME + +/* Converts the given Scheme symbol OBJ into a C string, containing a copy + of OBJ's content with a trailing null byte. If LENP is non-NULL, set + *LENP to the string's length. + + When STR is non-NULL it receives the copy and is returned by the function, + otherwise new memory is allocated and the caller is responsible for + freeing it via free(). If out of memory, NULL is returned. + + Note that Scheme symbols may contain arbitrary data, including null + characters. This means that null termination is not a reliable way to + determine the length of the returned value. However, the function always + copies the complete contents of OBJ, and sets *LENP to the length of the + scheme symbol (if LENP is non-null). */ +#define FUNC_NAME "scm_c_symbol2str" +char * +scm_c_symbol2str (SCM obj, char *str, size_t *lenp) +{ + size_t len; + + SCM_ASSERT (SCM_SYMBOLP (obj), obj, SCM_ARG1, FUNC_NAME); + len = SCM_SYMBOL_LENGTH (obj); + + if (str == NULL) + { + /* FIXME: Should we use exported wrappers for malloc (and free), which + * allow windows DLLs to call the correct freeing function? */ + str = (char *) malloc ((len + 1) * sizeof (char)); + if (str == NULL) + return NULL; + } + + memcpy (str, SCM_SYMBOL_CHARS (obj), len); + scm_remember_upto_here_1 (obj); + str[len] = '\0'; + + if (lenp != NULL) + *lenp = len; + + return str; +} +#undef FUNC_NAME + + void scm_symbols_prehistory () { diff --git a/libguile/symbols.h b/libguile/symbols.h index 9de355540..e4c624801 100644 --- a/libguile/symbols.h +++ b/libguile/symbols.h @@ -89,6 +89,7 @@ SCM_API SCM scm_symbol_pset_x (SCM s, SCM val); SCM_API SCM scm_symbol_hash (SCM s); SCM_API SCM scm_gensym (SCM prefix); +SCM_API char *scm_c_symbol2str (SCM obj, char *str, size_t *lenp); SCM_API void scm_symbols_prehistory (void); SCM_API void scm_init_symbols (void);