* Replace function scm_makstr with new function scm_allocate_string.
[bpt/guile.git] / libguile / strings.h
index 279dd57..76919d7 100644 (file)
@@ -2,7 +2,7 @@
 
 #ifndef STRINGSH
 #define STRINGSH
-/*     Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
+/*     Copyright (C) 1995,1996,1997,1998, 2000 Free Software Foundation, Inc.
  * 
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 
 #include "libguile/__scm.h"
 
-#ifdef HAVE_STRING_H
-#include <string.h>
+\f
+
+#define SCM_STRINGP(x) (SCM_NIMP (x) && (SCM_TYP7S (x) == scm_tc7_string))
+#if (SCM_DEBUG_DEPRECATED == 1)
+#define SCM_STRING_UCHARS(x) ((unsigned char *) (SCM_CELL_WORD_1 (x)))
+#define SCM_STRING_CHARS(x) ((char *) (SCM_CELL_WORD_1 (x)))
 #endif
+#define SCM_SET_STRING_CHARS(s, c) (SCM_SET_CELL_WORD_1 ((s), (c)))
+#define SCM_STRING_MAX_LENGTH ((1L << 24) - 1)
+#define SCM_STRING_LENGTH(x) (((unsigned long) SCM_CELL_WORD_0 (x)) >> 8)
+#define SCM_SET_STRING_LENGTH(s, l) (SCM_SET_CELL_WORD_0 ((s), ((l) << 8) + scm_tc7_string))
 
-\f
+#define SCM_STRING_COERCE_0TERMINATION_X(x) \
+  { if (SCM_NIMP (x) && (SCM_TYP7 (x) == scm_tc7_substring)) \
+      x = scm_makfromstr (SCM_STRING_CHARS (x), SCM_STRING_LENGTH (x), 0); }
 
-#define SCM_STRINGP(x) (SCM_NIMP(x) && (SCM_TYP7S(x)==scm_tc7_string))
-#define SCM_NSTRINGP(x) (!SCM_STRINGP(x))
+\f
 
-/* Is X a writable string (i.e., not a substring)?  */
-#define SCM_RWSTRINGP(x) (SCM_NIMP(x) && (SCM_TYP7(x) == scm_tc7_string))
-#define SCM_NRWSTRINGP(x) (! SCM_RWSTRINGP (x))
+extern SCM scm_string_p (SCM x);
+extern SCM scm_read_only_string_p (SCM x);
+extern SCM scm_string (SCM chrs);
+extern SCM scm_makfromstrs (int argc, char **argv);
+extern SCM scm_take_str (char *s, int len);
+extern SCM scm_take0str (char *s);
+extern SCM scm_makfromstr (const char *src, scm_sizet len, int);
+extern SCM scm_makfrom0str (const char *src);
+extern SCM scm_makfrom0str_opt (const char *src);
+extern SCM scm_allocate_string (scm_sizet len);
+extern SCM scm_make_string (SCM k, SCM chr);
+extern SCM scm_string_length (SCM str);
+extern SCM scm_string_ref (SCM str, SCM k);
+extern SCM scm_string_set_x (SCM str, SCM k, SCM chr);
+extern SCM scm_substring (SCM str, SCM start, SCM end);
+extern SCM scm_string_append (SCM args);
+extern void scm_init_strings (void);
 
 \f
 
+#if (SCM_DEBUG_DEPRECATED == 0)
 
-extern SCM scm_string_p SCM_P ((SCM x));
-extern SCM scm_read_only_string_p SCM_P ((SCM x));
-extern SCM scm_string SCM_P ((SCM chrs));
-extern SCM scm_makstr SCM_P ((long len, int slots));
-extern SCM scm_makfromstrs SCM_P ((int argc, char **argv));
-extern SCM scm_take_str SCM_P ((char *s, int len));
-extern SCM scm_take0str SCM_P ((char *s));
-extern SCM scm_makfromstr SCM_P ((const char *src, scm_sizet len, int slots));
-extern SCM scm_makfrom0str SCM_P ((const char *src));
-extern SCM scm_makfrom0str_opt SCM_P ((const char *src));
-extern SCM scm_make_string SCM_P ((SCM k, SCM chr));
-extern SCM scm_string_length SCM_P ((SCM str));
-extern SCM scm_string_ref SCM_P ((SCM str, SCM k));
-extern SCM scm_string_set_x SCM_P ((SCM str, SCM k, SCM chr));
-extern SCM scm_substring SCM_P ((SCM str, SCM start, SCM end));
-extern SCM scm_string_append SCM_P ((SCM args));
-extern SCM scm_make_shared_substring SCM_P ((SCM str, SCM frm, SCM to));
-extern void scm_init_strings SCM_P ((void));
+#define SCM_SLOPPY_STRINGP(x) (SCM_STRINGP(x))
+#define SCM_NSTRINGP(x) (!SCM_STRINGP(x))
+#define SCM_RWSTRINGP(x) (SCM_NIMP (x) && (SCM_TYP7 (x) == scm_tc7_string))
+#define SCM_NRWSTRINGP(x) (! SCM_RWSTRINGP (x))
+#define SCM_STRING_UCHARS(x) \
+  ((SCM_TYP7 (x) == scm_tc7_substring) \
+     ? (unsigned char *) SCM_CELL_WORD_1 (SCM_CDDR (x)) + SCM_INUM (SCM_CADR (x)) \
+     : (unsigned char *) SCM_CELL_WORD_1 (x))
+#define SCM_STRING_CHARS(x) \
+  ((SCM_TYP7 (x) == scm_tc7_substring) \
+     ? (char *) SCM_CELL_WORD_1 (SCM_CDDR (x)) + SCM_INUM (SCM_CADR (x)) \
+     : (char *) SCM_CELL_WORD_1 (x))
+extern SCM scm_make_shared_substring (SCM str, SCM frm, SCM to);
+extern SCM scm_makstr (long len, int);
+
+#endif  /* SCM_DEBUG_DEPRECATED == 0 */
 
 #endif  /* STRINGSH */
+
+/*
+  Local Variables:
+  c-file-style: "gnu"
+  End:
+*/