本文整理汇总了C++中rb_str_cat2函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_str_cat2函数的具体用法?C++ rb_str_cat2怎么用?C++ rb_str_cat2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_str_cat2函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: fortitude_escaped_strcpy
void fortitude_escaped_strcpy(VALUE rb_output, const char * src, int for_attribute_value) {
char buf[BUF_SIZE + 1];
char* buf_pos = buf;
char* max_buf_pos = buf + (BUF_SIZE - MAX_SUBSTITUTION_LENGTH);
char ch;
while (1) {
if (buf_pos >= max_buf_pos) {
*buf_pos = '\0';
rb_str_cat2(rb_output, buf);
buf_pos = buf;
}
ch = *src;
if (ch == '&') {
*buf_pos++ = '&';
*buf_pos++ = 'a';
*buf_pos++ = 'm';
*buf_pos++ = 'p';
*buf_pos++ = ';';
} else if (ch == '"') {
*buf_pos++ = '&';
*buf_pos++ = 'q';
*buf_pos++ = 'u';
*buf_pos++ = 'o';
*buf_pos++ = 't';
*buf_pos++ = ';';
} else if (ch == '<' && (! for_attribute_value)) {
*buf_pos++ = '&';
*buf_pos++ = 'l';
*buf_pos++ = 't';
*buf_pos++ = ';';
} else if (ch == '>' && (! for_attribute_value)) {
*buf_pos++ = '&';
*buf_pos++ = 'g';
*buf_pos++ = 't';
*buf_pos++ = ';';
} else if (ch == '\'' && (! for_attribute_value)) {
*buf_pos++ = '&';
*buf_pos++ = '#';
*buf_pos++ = '3';
*buf_pos++ = '9';
*buf_pos++ = ';';
} else {
if (ch == '\0') {
break;
}
*buf_pos++ = ch;
}
src++;
}
if (buf_pos > buf) {
*buf_pos = '\0';
rb_str_cat2(rb_output, buf);
}
}
开发者ID:ageweke,项目名称:fortitude,代码行数:60,代码来源:fortitude_native_ext.c
示例2: err_append
static void
err_append(const char *s)
{
if (rb_vm_parse_in_eval()) {
VALUE err = rb_errinfo();
if (err == Qnil) {
err = rb_exc_new2(rb_eSyntaxError, s);
rb_set_errinfo(err);
}
else {
VALUE str = rb_obj_as_string(err);
rb_str_cat2(str, "\n");
rb_str_cat2(str, s);
rb_set_errinfo(rb_exc_new3(rb_eSyntaxError, str));
}
}
else {
VALUE err = rb_vm_current_exception();
if (err == Qnil) {
err = rb_exc_new2(rb_eSyntaxError, "compile error");
rb_vm_set_current_exception(err);
}
rb_write_error(s);
rb_write_error("\n");
}
}
开发者ID:ferrous26,项目名称:MacRuby,代码行数:28,代码来源:error.c
示例3: err_append
static void
err_append(const char *s)
{
rb_thread_t *th = GET_THREAD();
VALUE err = th->errinfo;
if (th->mild_compile_error) {
if (!RTEST(err)) {
err = rb_exc_new2(rb_eSyntaxError, s);
th->errinfo = err;
}
else {
VALUE str = rb_obj_as_string(err);
rb_str_cat2(str, "\n");
rb_str_cat2(str, s);
th->errinfo = rb_exc_new3(rb_eSyntaxError, str);
}
}
else {
if (!RTEST(err)) {
err = rb_exc_new2(rb_eSyntaxError, "compile error");
th->errinfo = err;
}
rb_write_error(s);
rb_write_error("\n");
}
}
开发者ID:AdamDotCom,项目名称:my-rvm,代码行数:28,代码来源:error.c
示例4: shoes_http_headers
SHOES_DOWNLOAD_HEADERS
shoes_http_headers(VALUE hsh)
{
long i;
LPWSTR hdrs = NULL;
VALUE keys = rb_funcall(hsh, s_keys, 0);
if (RARRAY_LEN(keys) > 0)
{
VALUE headers = rb_str_new2("");
//for (i = 0; i < RARRAY(keys)->as.heap.len; i++ )
for (i = 0; i < RARRAY_LEN(keys); i++ )
{
VALUE key = rb_ary_entry(keys, i);
rb_str_append(headers, key);
rb_str_cat2(headers, ": ");
rb_str_append(headers, rb_hash_aref(hsh, key));
rb_str_cat2(headers, "\n");
}
hdrs = SHOE_ALLOC_N(WCHAR, RSTRING_LEN(headers) + 1);
SHOE_MEMZERO(hdrs, WCHAR, RSTRING_LEN(headers) + 1);
MultiByteToWideChar(CP_UTF8, 0, RSTRING_PTR(headers), -1, hdrs, RSTRING_LEN(headers) + 1);
}
return hdrs;
}
开发者ID:kannans,项目名称:shoes,代码行数:25,代码来源:windownload.c
示例5: fc_path
static VALUE
fc_path(struct fc_result *fc, ID name)
{
VALUE path, tmp;
path = rb_str_dup(rb_id2str(name));
while (fc) {
st_data_t n;
if (fc->track == rb_cObject) break;
if (RCLASS_IV_TBL(fc->track) &&
st_lookup(RCLASS_IV_TBL(fc->track), (st_data_t)classpath, &n)) {
tmp = rb_str_dup((VALUE)n);
rb_str_cat2(tmp, "::");
rb_str_append(tmp, path);
path = tmp;
break;
}
tmp = rb_str_dup(rb_id2str(fc->name));
rb_str_cat2(tmp, "::");
rb_str_append(tmp, path);
path = tmp;
fc = fc->prev;
}
OBJ_FREEZE(path);
return path;
}
开发者ID:amtep,项目名称:ruby,代码行数:26,代码来源:variable.c
示例6: compile_err_append
static void
compile_err_append(VALUE mesg)
{
rb_thread_t *th = GET_THREAD();
VALUE err = th->errinfo;
rb_block_t *prev_base_block = th->base_block;
th->base_block = 0;
/* base_block should be zero while normal Ruby execution */
/* after this line, any Ruby code *can* run */
if (th->mild_compile_error) {
if (RTEST(err)) {
VALUE str = rb_obj_as_string(err);
rb_str_cat2(str, "\n");
rb_str_append(str, mesg);
mesg = str;
}
err = rb_exc_new3(rb_eSyntaxError, mesg);
th->errinfo = err;
}
else {
if (!RTEST(err)) {
err = rb_exc_new2(rb_eSyntaxError, "compile error");
th->errinfo = err;
}
rb_str_cat2(mesg, "\n");
rb_write_error_str(mesg);
}
/* returned to the parser world */
th->base_block = prev_base_block;
}
开发者ID:alansparrow,项目名称:learningruby,代码行数:33,代码来源:error.c
示例7: end_element_ns_callback
static void end_element_ns_callback(void *ctx,
const xmlChar *xlocalname, const xmlChar *xprefix, const xmlChar *xURI)
{
VALUE handler = (VALUE) ctx;
if (handler == Qnil)
return;
/* Call end element for old-times sake */
if (rb_respond_to(handler, cbidOnEndElement))
{
VALUE name;
if (xprefix)
{
name = rb_str_new2(xprefix);
rb_str_cat2(name, ":");
rb_str_cat2(name, xlocalname);
}
else
{
name = rb_str_new2(xlocalname);
}
rb_funcall(handler, cbidOnEndElement, 1, name);
}
rb_funcall(handler, cbidOnEndElementNs, 3,
rb_str_new2(xlocalname),
xprefix ? rb_str_new2(xprefix) : Qnil,
xURI ? rb_str_new2(xURI) : Qnil);
}
开发者ID:ChrisMissal,项目名称:shouldly,代码行数:30,代码来源:ruby_xml_sax2_handler.c
示例8: rb_smbdir_read
static VALUE rb_smbdir_read(VALUE self)
{
RB_SMBFILE_DATA_FROM_OBJ(self, data);
RB_SMBFILE_DATA_CLOSED(data);
smbc_readdir_fn fn;
struct smbc_dirent *smbcdent;
fn = smbc_getFunctionReaddir(data->smbcctx);
errno = 0;
smbcdent = (*fn)(data->smbcctx, data->smbcfile);
if (smbcdent == NULL) {
if (errno) {
rb_sys_fail(data->url);
}
return Qnil;
}
VALUE args[4];
args[0] = rb_external_str_new_with_enc(smbcdent->name,
strlen(smbcdent->name), data->enc);
args[1] = INT2NUM(smbcdent->smbc_type);
args[2] = rb_str_new2(data->url);
rb_str_cat2(args[2], "/"); /* FIXME: Unless if the last char is not "/" */
rb_str_cat2(args[2], smbcdent->name); /* FIXME: Must be URL encoding */
args[3] = rb_str_new(smbcdent->comment, smbcdent->commentlen);
VALUE entry_obj = rb_class_new_instance(4, args, rb_cSMBDirEntry);
return entry_obj;
}
开发者ID:fumiyas,项目名称:ruby-net-smb,代码行数:32,代码来源:smbdir.c
示例9: Map_inspect
/*
* call-seq:
* Map.inspect => string
*
* Returns a string representing this map's elements. It will be formatted as
* "{key => value, key => value, ...}", with each key and value string
* representation computed by its own #inspect method.
*/
VALUE Map_inspect(VALUE _self) {
Map* self = ruby_to_Map(_self);
VALUE str = rb_str_new2("{");
bool first = true;
VALUE inspect_sym = rb_intern("inspect");
upb_strtable_iter it;
for (upb_strtable_begin(&it, &self->table);
!upb_strtable_done(&it);
upb_strtable_next(&it)) {
VALUE key = table_key_to_ruby(
self, upb_strtable_iter_key(&it), upb_strtable_iter_keylength(&it));
upb_value v = upb_strtable_iter_value(&it);
void* mem = value_memory(&v);
VALUE value = native_slot_get(self->value_type,
self->value_type_class,
mem);
if (!first) {
str = rb_str_cat2(str, ", ");
} else {
first = false;
}
str = rb_str_append(str, rb_funcall(key, inspect_sym, 0));
str = rb_str_cat2(str, "=>");
str = rb_str_append(str, rb_funcall(value, inspect_sym, 0));
}
str = rb_str_cat2(str, "}");
return str;
}
开发者ID:2007750219,项目名称:protobuf,代码行数:42,代码来源:map.c
示例10: figure_singleton_name
/* ================ Helper Functions =================*/
static VALUE
figure_singleton_name(VALUE klass)
{
VALUE result = Qnil;
/* We have come across a singleton object. First
figure out what it is attached to.*/
VALUE attached = rb_iv_get(klass, "__attached__");
/* Is this a singleton class acting as a metaclass? */
if (BUILTIN_TYPE(attached) == T_CLASS)
{
result = rb_str_new2("<Class::");
rb_str_append(result, rb_inspect(attached));
rb_str_cat2(result, ">");
}
/* Is this for singleton methods on a module? */
else if (BUILTIN_TYPE(attached) == T_MODULE)
{
result = rb_str_new2("<Module::");
rb_str_append(result, rb_inspect(attached));
rb_str_cat2(result, ">");
}
/* Is this for singleton methods on an object? */
else if (BUILTIN_TYPE(attached) == T_OBJECT)
{
/* Make sure to get the super class so that we don't
mistakenly grab a T_ICLASS which would lead to
unknown method errors. */
#ifdef HAVE_RB_CLASS_SUPERCLASS
// 1.9.3
VALUE super = rb_class_superclass(klass);
#else
# ifdef RCLASS_SUPER
VALUE super = rb_class_real(RCLASS_SUPER(klass));
# else
VALUE super = rb_class_real(RCLASS(klass)->super);
# endif
#endif
result = rb_str_new2("<Object::");
rb_str_append(result, rb_inspect(super));
rb_str_cat2(result, ">");
}
/* Ok, this could be other things like an array made put onto
a singleton object (yeah, it happens, see the singleton
objects test case). */
else
{
result = rb_inspect(klass);
}
return result;
}
开发者ID:jokester01au,项目名称:GetUpQuiz,代码行数:57,代码来源:ruby_prof.c
示例11: rldap_inspect
static VALUE rldap_inspect(VALUE obj)
{
VALUE ruri, ret;
ruri = rb_funcall(rldap_uri(obj), rb_intern("dump"), 0);
ret = rb_str_new2("#<LDAP @uri=");
rb_str_cat2(ret, StringValuePtr(ruri));
rb_str_cat2(ret, ">");
return ret;
}
开发者ID:henrikhodne,项目名称:rldap,代码行数:11,代码来源:ldap.c
示例12: Message_inspect
/*
* call-seq:
* Message.inspect => string
*
* Returns a human-readable string representing this message. It will be
* formatted as "<MessageType: field1: value1, field2: value2, ...>". Each
* field's value is represented according to its own #inspect method.
*/
VALUE Message_inspect(VALUE _self) {
MessageHeader* self;
TypedData_Get_Struct(_self, MessageHeader, &Message_type, self);
VALUE str = rb_str_new2("<");
str = rb_str_append(str, rb_str_new2(rb_class2name(CLASS_OF(_self))));
str = rb_str_cat2(str, ": ");
str = rb_str_append(str, layout_inspect(
self->descriptor->layout, Message_data(self)));
str = rb_str_cat2(str, ">");
return str;
}
开发者ID:goodleon,项目名称:protobuf,代码行数:20,代码来源:message.c
示例13: pg_define_coder
void
pg_define_coder( const char *name, void *func, VALUE klass, VALUE nsp )
{
VALUE type_obj = Data_Wrap_Struct( klass, NULL, NULL, func );
VALUE objname = rb_str_dup(rb_mod_name(nsp));
rb_str_cat2( objname, "::");
rb_str_cat2( objname, name);
rb_iv_set( type_obj, "@name", rb_obj_freeze(objname) );
rb_define_const( nsp, name, rb_obj_freeze(type_obj) );
RB_GC_GUARD(type_obj);
}
开发者ID:willbryant,项目名称:ruby-pg,代码行数:13,代码来源:pg_coder.c
示例14: compile_snprintf
static VALUE
compile_snprintf(rb_encoding *enc, const char *pre, const char *file, int line, const char *fmt, va_list args)
{
VALUE str = rb_enc_str_new(0, 0, enc);
if (file) {
rb_str_cat2(str, file);
if (line) rb_str_catf(str, ":%d", line);
rb_str_cat2(str, ": ");
}
if (pre) rb_str_cat2(str, pre);
rb_str_vcatf(str, fmt, args);
return str;
}
开发者ID:knugie,项目名称:ruby,代码行数:14,代码来源:error.c
示例15: name_err_mesg_to_str
/* :nodoc: */
static VALUE
name_err_mesg_to_str(VALUE obj, SEL sel)
{
VALUE *ptr, mesg;
Data_Get_Struct(obj, VALUE, ptr);
mesg = ptr[0];
if (NIL_P(mesg)) {
return Qnil;
}
else {
const char *desc = 0;
VALUE d = 0, args[3];
obj = ptr[1];
switch (TYPE(obj)) {
case T_NIL:
desc = "nil";
break;
case T_TRUE:
desc = "true";
break;
case T_FALSE:
desc = "false";
break;
default:
d = rb_protect(safe_inspect, obj, NULL);
if (NIL_P(d) || RSTRING_LEN(d) > 65) {
d = rb_any_to_s(obj);
}
desc = RSTRING_PTR(d);
break;
}
if (desc && desc[0] != '#') {
d = d ? rb_str_dup(d) : rb_str_new2(desc);
rb_str_cat2(d, ":");
rb_str_cat2(d, rb_obj_classname(obj));
}
args[0] = mesg;
args[1] = ptr[2];
args[2] = d;
mesg = rb_f_sprintf(3, args);
}
if (OBJ_TAINTED(obj)) {
OBJ_TAINT(mesg);
}
return mesg;
}
开发者ID:1nueve,项目名称:MacRuby,代码行数:49,代码来源:error.c
示例16: fortitude_append_to
void fortitude_append_to(VALUE object, VALUE rb_output, int for_attribute_value) {
ID to_s;
char buf[25];
long value;
int i;
VALUE new_string, array_element;
#ifdef CONST_ID
CONST_ID(to_s, "to_s");
#else
to_s = rb_intern("to_s");
#endif
switch (TYPE(object)) {
case T_STRING:
fortitude_escaped_strcpy(rb_output, RSTRING_PTR(object), for_attribute_value);
break;
case T_SYMBOL:
fortitude_escaped_strcpy(rb_output, rb_id2name(SYM2ID(object)), for_attribute_value);
break;
case T_ARRAY:
value = RARRAY_LEN(object);
for (i = 0; i < value; ++i) {
array_element = rb_ary_entry(object, i);
if (i > 0) {
rb_str_cat2(rb_output, " ");
}
fortitude_append_to(array_element, rb_output, for_attribute_value);
}
case T_NONE:
case T_NIL:
break;
case T_FIXNUM:
value = NUM2LONG(object);
sprintf(buf, "%ld", value);
rb_str_cat2(rb_output, buf);
break;
default:
new_string = rb_funcall(object, to_s, 0);
fortitude_escaped_strcpy(rb_output, RSTRING_PTR(new_string), for_attribute_value);
break;
}
}
开发者ID:ageweke,项目名称:fortitude,代码行数:48,代码来源:fortitude_native_ext.c
示例17: oletypelib_path
static VALUE
oletypelib_path(VALUE guid, VALUE version)
{
int k;
LONG err;
HKEY hkey;
HKEY hlang;
VALUE lang;
VALUE path = Qnil;
VALUE key = rb_str_new2("TypeLib\\");
rb_str_concat(key, guid);
rb_str_cat2(key, "\\");
rb_str_concat(key, version);
err = reg_open_vkey(HKEY_CLASSES_ROOT, key, &hkey);
if (err != ERROR_SUCCESS) {
return Qnil;
}
for(k = 0; path == Qnil; k++) {
lang = reg_enum_key(hkey, k);
if (lang == Qnil)
break;
err = reg_open_vkey(hkey, lang, &hlang);
if (err == ERROR_SUCCESS) {
path = reg_get_typelib_file_path(hlang);
RegCloseKey(hlang);
}
}
RegCloseKey(hkey);
return path;
}
开发者ID:DashYang,项目名称:sim,代码行数:32,代码来源:win32ole_typelib.c
示例18: ossl_sslctx_set_ciphers
/*
* call-seq:
* ctx.ciphers = "cipher1:cipher2:..."
* ctx.ciphers = [name, ...]
* ctx.ciphers = [[name, version, bits, alg_bits], ...]
*/
static VALUE
ossl_sslctx_set_ciphers(VALUE self, VALUE v)
{
SSL_CTX *ctx;
VALUE str, elem;
int i;
rb_check_frozen(self);
if (NIL_P(v))
return v;
else if (TYPE(v) == T_ARRAY) {
str = rb_str_new(0, 0);
for (i = 0; i < RARRAY_LEN(v); i++) {
elem = rb_ary_entry(v, i);
if (TYPE(elem) == T_ARRAY) elem = rb_ary_entry(elem, 0);
elem = rb_String(elem);
rb_str_append(str, elem);
if (i < RARRAY_LEN(v)-1) rb_str_cat2(str, ":");
}
} else {
str = v;
StringValue(str);
}
Data_Get_Struct(self, SSL_CTX, ctx);
if(!ctx){
ossl_raise(eSSLError, "SSL_CTX is not initialized.");
return Qnil;
}
if (!SSL_CTX_set_cipher_list(ctx, RSTRING_PTR(str))) {
ossl_raise(eSSLError, "SSL_CTX_set_cipher_list:");
}
return v;
}
开发者ID:2220142,项目名称:ruby,代码行数:41,代码来源:ossl_ssl.c
示例19: superclass_name
static VALUE superclass_name(VALUE module)
{
if(TYPE(module) == T_MODULE)
{
return Qnil;
}
else
{
VALUE super = RCLASS_SUPER(module);
while(TYPE(super) == T_ICLASS)
{
super = RCLASS_SUPER(super);
}
if(!super)
{
return Qnil;
}
if(FL_TEST(super, FL_SINGLETON))
{
VALUE v = rb_iv_get(super, "__attached__");
VALUE name = rb_mod_name(v);
rb_str_cat2(name, "::<Singleton>");
return name;
}
else
{
return rb_mod_name(super);
}
}
}
开发者ID:shmulim,项目名称:ruby-internal,代码行数:33,代码来源:module.c
示例20: rb_set_class_path2
void
rb_set_class_path2(VALUE klass, VALUE under, const char *name, VALUE outer)
{
VALUE str;
if (under == rb_cObject) {
str = rb_str_new2(name);
}
else {
str = rb_str_dup(rb_class_path(under));
rb_str_cat2(str, "::");
rb_str_cat2(str, name);
}
OBJ_FREEZE(str);
rb_ivar_set(klass, id_classpath, str);
}
开发者ID:kyab,项目名称:MacRuby,代码行数:16,代码来源:variable.c
注:本文中的rb_str_cat2函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论