02111-1307 USA. */
#include <stdlib.h>
+#include <ctype.h>
#include "cos-read.h"
+COS_object
+cos_read_int (unsigned char *str, size_t len, size_t start, size_t* endp)
+{
+ size_t i = start;
+ int c;
+ int negative_flag;
+ int dest;
+
+ if ( i < len )
+ {
+ switch ( str[i] )
+ {
+ case '+':
+ negative_flag = 0;
+ i++;
+ break;
+ case '-':
+ negative_flag = 1;
+ i++;
+ break;
+ default:
+ negative_flag = 0;
+ }
+
+ if ( (i < len) && (c = str[i++])
+ && ('0' <= c) && (c <= '9') )
+ {
+ dest = c - '0';
+
+ while ( i < len )
+ {
+ c = str[i];
+ if ( ('0' <= c) && (c <= '9') )
+ {
+ dest = dest * 10 + c - '0';
+ i++;
+ }
+ else if ( isspace (c) )
+ {
+ *endp = i;
+ return cos_make_int ( negative_flag ? - dest : dest );
+ }
+ else
+ return NULL;
+ }
+ *endp = i;
+ return cos_make_int ( negative_flag ? - dest : dest );
+ }
+ }
+ return NULL;
+}
+
+
int
cos_read_utf8 (unsigned char *str, size_t len, size_t start, size_t* endp)
{
return -1;
}
+
COS_String
cos_read_string (unsigned char *str, size_t len, size_t start, size_t* endp)
{