Added spec:commit task to commit changes to spec/ruby sources.
[rbx.git] / shotgun / lib / string.h
blob5483fb78d99b0c19a7275a0a9614dc12f1bf63ae
1 #ifndef RBS_STRING_H
2 #define RBS_STRING_H
4 #include <ctype.h>
6 // copied from ruby 1.8.x source, ruby.h
7 /* need to include <ctype.h> to use these macros */
8 #ifndef ISPRINT
9 #define ISASCII(c) isascii((int)(unsigned char)(c))
10 #undef ISPRINT
11 #define ISPRINT(c) (ISASCII(c) && isprint((int)(unsigned char)(c)))
12 #define ISSPACE(c) (ISASCII(c) && isspace((int)(unsigned char)(c)))
13 #define ISUPPER(c) (ISASCII(c) && isupper((int)(unsigned char)(c)))
14 #define ISLOWER(c) (ISASCII(c) && islower((int)(unsigned char)(c)))
15 #define ISALNUM(c) (ISASCII(c) && isalnum((int)(unsigned char)(c)))
16 #define ISALPHA(c) (ISASCII(c) && isalpha((int)(unsigned char)(c)))
17 #define ISDIGIT(c) (ISASCII(c) && isdigit((int)(unsigned char)(c)))
18 #define ISXDIGIT(c) (ISASCII(c) && isxdigit((int)(unsigned char)(c)))
19 #endif
21 OBJECT string_new(STATE, const char *str);
22 OBJECT string_new2(STATE, const char *str, int sz);
23 OBJECT string_dup(STATE, OBJECT self);
24 OBJECT string_append(STATE, OBJECT self, OBJECT other);
26 char* rbx_string_as_cstr(STATE, OBJECT self);
27 char *string_byte_address(STATE, OBJECT self);
29 unsigned int string_hash_int(STATE, OBJECT self);
30 unsigned int string_hash_cstr(STATE, const char *bp);
31 unsigned int string_hash_str_with_size(STATE, const char *bp, int size);
32 OBJECT string_to_sym(STATE, OBJECT self);
33 double string_to_double(STATE, OBJECT self);
34 unsigned int string_hash_str(unsigned char *bp, unsigned int sz);
35 OBJECT string_newfrombstr(STATE, bstring output);
36 int string_equal_p(STATE, OBJECT self, OBJECT other);
37 OBJECT string_tr_expand(STATE, OBJECT string, OBJECT limit);
39 #define string_unshare(state, cur) \
40 if(string_get_shared(cur) == Qtrue) { string_set_data(cur, bytearray_dup(state, string_get_data(cur))); string_set_shared(cur, Qnil); }
42 #endif