/* -*-C-*-
-$Id: extern.h,v 9.57 2000/12/05 21:23:44 cph Exp $
+$Id: extern.h,v 9.58 2001/03/08 17:01:55 cph Exp $
-Copyright (c) 1987-2000 Massachusetts Institute of Technology
+Copyright (c) 1987-2001 Massachusetts Institute of Technology
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
extern SCHEME_OBJECT EXFUN (allocate_non_marked_vector, (int, long, Boolean));
extern SCHEME_OBJECT EXFUN (allocate_marked_vector, (int, long, Boolean));
extern SCHEME_OBJECT EXFUN (make_vector, (long, SCHEME_OBJECT, Boolean));
-extern SCHEME_OBJECT EXFUN (allocate_string, (long));
-extern SCHEME_OBJECT EXFUN (memory_to_string, (long, unsigned char *));
+extern SCHEME_OBJECT EXFUN (allocate_string, (unsigned long));
+extern SCHEME_OBJECT EXFUN (allocate_string_no_gc, (unsigned long));
+extern SCHEME_OBJECT EXFUN
+ (memory_to_string, (unsigned long, unsigned char *));
+extern SCHEME_OBJECT EXFUN
+ (memory_to_string_no_gc, (unsigned long, unsigned char *));
extern SCHEME_OBJECT EXFUN (char_pointer_to_string, (unsigned char *));
+extern SCHEME_OBJECT EXFUN (char_pointer_to_string_no_gc, (unsigned char *));
/* Random and OS utilities */
extern Boolean EXFUN (Restore_History, (SCHEME_OBJECT));
/* -*-C-*-
-$Id: string.c,v 9.41 2001/01/05 20:43:06 cph Exp $
+$Id: string.c,v 9.42 2001/03/08 17:02:02 cph Exp $
Copyright (c) 1987-2001 Massachusetts Institute of Technology
#endif
\f
SCHEME_OBJECT
-DEFUN (allocate_string, (nbytes), fast long nbytes)
+DEFUN (allocate_string, (nbytes), unsigned long nbytes)
{
- fast long count = (STRING_LENGTH_TO_GC_LENGTH (nbytes));
- fast SCHEME_OBJECT result =
- (allocate_non_marked_vector (TC_CHARACTER_STRING, count, true));
+ SCHEME_OBJECT result
+ = (allocate_non_marked_vector
+ (TC_CHARACTER_STRING,
+ (STRING_LENGTH_TO_GC_LENGTH (nbytes)),
+ 1));
+ SET_STRING_LENGTH (result, nbytes);
+ return (result);
+}
+
+SCHEME_OBJECT
+DEFUN (allocate_string_no_gc, (nbytes), unsigned long nbytes)
+{
+ SCHEME_OBJECT result
+ = (allocate_non_marked_vector
+ (TC_CHARACTER_STRING,
+ (STRING_LENGTH_TO_GC_LENGTH (nbytes)),
+ 0));
SET_STRING_LENGTH (result, nbytes);
return (result);
}
SCHEME_OBJECT
DEFUN (memory_to_string, (nbytes, data),
- long nbytes
- AND fast unsigned char * data)
+ unsigned long nbytes AND
+ unsigned char * data)
{
SCHEME_OBJECT result = (allocate_string (nbytes));
- fast unsigned char * scan_result = (STRING_LOC (result, 0));
- fast unsigned char * end_result = (scan_result + nbytes);
+ unsigned char * scan_result = (STRING_LOC (result, 0));
+ unsigned char * end_result = (scan_result + nbytes);
+ while (scan_result < end_result)
+ (*scan_result++) = (*data++);
+ return (result);
+}
+
+SCHEME_OBJECT
+DEFUN (memory_to_string_no_gc, (nbytes, data),
+ unsigned long nbytes AND
+ unsigned char * data)
+{
+ SCHEME_OBJECT result = (allocate_string_no_gc (nbytes));
+ unsigned char * scan_result = (STRING_LOC (result, 0));
+ unsigned char * end_result = (scan_result + nbytes);
while (scan_result < end_result)
(*scan_result++) = (*data++);
return (result);
DEFUN (char_pointer_to_string, (char_pointer), unsigned char * char_pointer)
{
unsigned char * scan = char_pointer;
- if (scan == ((unsigned char *) NULL))
+ if (scan == 0)
scan += 1;
else
while ((*scan++) != '\0')
return (memory_to_string (((scan - 1) - char_pointer), char_pointer));
}
+SCHEME_OBJECT
+DEFUN (char_pointer_to_string_no_gc, (char_pointer),
+ unsigned char * char_pointer)
+{
+ unsigned char * scan = char_pointer;
+ if (scan == 0)
+ scan += 1;
+ else
+ while ((*scan++) != '\0')
+ ;
+ return (memory_to_string_no_gc (((scan - 1) - char_pointer), char_pointer));
+}
+\f
/* Currently the strings used in symbols have type codes in the length
field. They should be changed to have just longwords there. */
PRIMITIVE_HEADER (1);
PRIMITIVE_RETURN (BOOLEAN_TO_OBJECT (STRING_P (ARG_REF (1))));
}
-\f
+
DEFINE_PRIMITIVE ("STRING-LENGTH", Prim_string_length, 1, 1, 0)
{
PRIMITIVE_HEADER (1);
PRIMITIVE_HEADER (2);
CHECK_ARG (1, STRING_P);
{
- fast SCHEME_OBJECT string = (ARG_REF (1));
+ SCHEME_OBJECT string = (ARG_REF (1));
SET_STRING_LENGTH
(string,
(arg_index_integer (2, ((MAXIMUM_STRING_LENGTH (string)) + 1))));
PRIMITIVE_HEADER (2);
CHECK_ARG (1, STRING_P);
{
- fast SCHEME_OBJECT string = (ARG_REF (1));
- fast long length =
+ SCHEME_OBJECT string = (ARG_REF (1));
+ long length =
(arg_index_integer (2, ((MAXIMUM_STRING_LENGTH (string)) + 1)));
MEMORY_SET
(string,
PRIMITIVE_HEADER (2); \
CHECK_ARG (1, STRING_P); \
{ \
- fast SCHEME_OBJECT string = (ARG_REF (1)); \
+ SCHEME_OBJECT string = (ARG_REF (1)); \
PRIMITIVE_RETURN \
(process_result \
(STRING_REF \
PRIMITIVE_HEADER (3); \
CHECK_ARG (1, STRING_P); \
{ \
- fast SCHEME_OBJECT string = (ARG_REF (1)); \
+ SCHEME_OBJECT string = (ARG_REF (1)); \
STRING_SET \
(string, \
(arg_index_integer (2, (STRING_LENGTH (string)))), \
{ \
SCHEME_OBJECT string; \
long start, end; \
- fast long length; \
- fast unsigned char *scan, temp; \
+ long length; \
+ unsigned char *scan, temp; \
PRIMITIVE_HEADER (3); \
CHECK_ARG (1, STRING_P); \
string = (ARG_REF (1)); \
\f
#define VECTOR_8B_SUBSTRING_PREFIX() \
long start, end, ascii; \
- fast unsigned char *string_start, *scan, *limit; \
+ unsigned char *string_start, *scan, *limit; \
PRIMITIVE_HEADER (4); \
CHECK_ARG (1, STRING_P); \
string_start = (STRING_LOC ((ARG_REF (1)), 0)); \
{
VECTOR_8B_SUBSTRING_PREFIX_FORWARD ();
{
- fast unsigned char char1 = ((unsigned char) (char_upcase (ascii)));
+ unsigned char char1 = ((unsigned char) (char_upcase (ascii)));
while (scan < limit)
if ((char_upcase (*scan++)) == char1)
PRIMITIVE_RETURN (LONG_TO_UNSIGNED_FIXNUM ((scan - 1) - string_start));
{
VECTOR_8B_SUBSTRING_PREFIX_BACKWARD ();
{
- fast unsigned char char1 = ((unsigned char) (char_upcase (ascii)));
+ unsigned char char1 = ((unsigned char) (char_upcase (ascii)));
while (scan > limit)
if ((char_upcase (*--scan)) == char1)
PRIMITIVE_RETURN (LONG_TO_UNSIGNED_FIXNUM (scan - string_start));
error_bad_range_arg (5)
#define SUBSTRING_EQUAL_PREFIX() \
- fast unsigned char *scan1, *scan2, *limit; \
+ unsigned char *scan1, *scan2, *limit; \
SUBSTRING_COMPARE_PREFIX (); \
if ((end1 - start1) != (end2 - start2)) \
PRIMITIVE_RETURN (SHARP_F); \
{
SUBSTRING_COMPARE_PREFIX ();
{
- fast unsigned char * scan1 = (string1_start + start1);
- fast unsigned char * scan2 = (string2_start + start2);
+ unsigned char * scan1 = (string1_start + start1);
+ unsigned char * scan2 = (string2_start + start2);
long length1 = (end1 - start1);
long length2 = (end2 - start2);
- fast unsigned char * limit =
+ unsigned char * limit =
(scan1 + ((length1 < length2) ? length1 : length2));
while (scan1 < limit)
if ((*scan1++) != (*scan2++))
AND long start2
AND long end2)
{
- fast long length1 = (end1 - start1);
- fast long length2 = (end2 - start2);
+ long length1 = (end1 - start1);
+ long length2 = (end2 - start2);
return ((length1 < length2) ? length1 : length2);
}
#define SUBSTRING_MATCH_PREFIX() \
- fast unsigned char *scan1, *scan2, *limit; \
+ unsigned char *scan1, *scan2, *limit; \
long length; \
unsigned char *scan1_start; \
SUBSTRING_COMPARE_PREFIX (); \