181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
# File 'ext/json_extractor/json_extractor.c', line 181
static VALUE (VALUE self, VALUE str, VALUE key) {
char *data, *substr;
VALUE result;
// No str?
if(str == Qnil) {
return Qnil;
}
// No key?
if(key == Qnil) {
return Qnil;
}
data = read_all(RSTRING_PTR(str));
substr = (data, RSTRING_PTR(key));
free(data);
if(substr == NULL) {
return Qnil;
}
result = rb_str_new2(substr);
// TODO: Figure out if this is right. It behaves properly, so I'm assuming
// it's OK.
free(substr);
return result;
}
|