这篇教程C++ str_eq函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中str_eq函数的典型用法代码示例。如果您正苦于以下问题:C++ str_eq函数的具体用法?C++ str_eq怎么用?C++ str_eq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了str_eq函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: init_logstatic boolinit_log(void){ extern struct conf *conf; if (debug_log_buffer || logfile || use_syslog) { return true; } assert(conf); if (conf->debug) { debug_log_buffer_capacity = DEBUG_LOG_BUFFER_MARGIN; debug_log_buffer = x_malloc(debug_log_buffer_capacity); debug_log_size = 0; } if (str_eq(conf->log_file, "")) { return conf->debug; }#ifdef HAVE_SYSLOG if (str_eq(conf->log_file, "syslog")) { use_syslog = true; openlog("ccache", LOG_PID, LOG_USER); return true; }#endif logfile = fopen(conf->log_file, "a"); if (logfile) {#ifndef _WIN32 set_cloexec_flag(fileno(logfile));#endif return true; } else { return false; }}
开发者ID:ccache,项目名称:ccache,代码行数:34,
示例2: treasure_type_by_letter_A_teststatic voidtreasure_type_by_letter_A_test(void){ struct treasure_type *treasure_type = treasure_type_by_letter('A'); assert(NULL != treasure_type); char *name = treasure_type_alloc_name(treasure_type); assert(str_eq("A", name)); free_or_die(name); char *description = treasure_type_alloc_description(treasure_type, false); char const *expected = " A | 1-6:25% | 1-6:30% | 1-6:35% | 1-10:40% | 1-4:25% | 4-40:60% | 3-30:50% | any 3: 30%/n"; assert(str_eq(expected, description)); free_or_die(description); description = treasure_type_alloc_description(treasure_type, true); expected = " | 1,000's | 1,000's | 1,000's | 1,000's | 100's | | | Maps /n" "Treasure | of | of | of | of | of | | | or /n" " Type | Copper | Silver | Electrum | Gold | Platinum | Gems | Jewelry | Magic /n" "----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------/n" " A | 1-6:25% | 1-6:30% | 1-6:35% | 1-10:40% | 1-4:25% | 4-40:60% | 3-30:50% | any 3: 30%/n"; assert(str_eq(expected, description)); free_or_die(description);}
开发者ID:donmccaughey,项目名称:FiendsAndFortune,代码行数:26,
示例3: parse_sloppinessstatic boolparse_sloppiness(const char *str, void *result, char **errmsg){ unsigned *value = (unsigned *)result; char *word, *p, *q, *saveptr = NULL; if (!str) { return *value; } p = x_strdup(str); q = p; while ((word = strtok_r(q, ", ", &saveptr))) { if (str_eq(word, "file_macro")) { *value |= SLOPPY_FILE_MACRO; } else if (str_eq(word, "include_file_mtime")) { *value |= SLOPPY_INCLUDE_FILE_MTIME; } else if (str_eq(word, "time_macros")) { *value |= SLOPPY_TIME_MACROS; } else { *errmsg = format("unknown sloppiness: /"%s/"", word); free(p); return false; } q = NULL; } free(p); return true;}
开发者ID:dgivone,项目名称:ccache,代码行数:28,
示例4: mainint main(){ object_t *o; char *s; const char *string_type = "STRING"; type_t *type; plan(9); type = type_get(string_type); type_set_callback(type, "free", free); s = calloc(20, sizeof(char)); strcpy(s, "Hello, object world"); o = object_new(string_type, s); ok(o != NULL, "object is not NULL"); ok(object_isset(o), "object is set"); ok(object_isa(o, string_type), "object isa '%s'", string_type); str_eq(object_type(o), string_type); ok(object_type(o) == string_type, "object_type() returns direct pointer to type string"); str_eq(object_value(o), s); ok(object_value(o) == s, "object_value() returns direct pointer to value"); object_set(o, "Goodbye"); str_eq(object_value(o), "Goodbye"); object_set(o, s); object_free(o); ok(object_isset(NULL) == 0, "NULL is considered as an unset object"); types_finalize(); return 0;}
开发者ID:jajm,项目名称:libobject,代码行数:35,
示例5: test_mapvoid test_map() { char** ss = str_strings("one","two","three",NULL); MAPA(int,ssl,strlen(_),ss); assert(ssl[0] == 3); assert(ssl[1] == 3); assert(ssl[2] == 5); int nn[] = {1,2,22,1,40,3}; int *na = array_new_init(int,nn); // MAPAR because we want the result to be a ref container.. MAPAR(char*,sna,str_fmt("%02d",_),na); #define cat(arr) str_concat(arr," ") assert(str_eq(cat(sna),"01 02 22 01 40 03")); // collecting the strings that match a condition // (again, we want a ref container as a result) FILTAR(char*,sna2,sna,_[1]=='2'); assert(str_eq(cat(sna2),"02 22")); FILTA(int,nam,na, _ < 10); char **sn = strbuf_new(); FORA(nam,strbuf_addf(sn,"%02d ",_)); assert(str_eq(*sn,"01 02 01 03 ")); }
开发者ID:stevedonovan,项目名称:llib,代码行数:28,
示例6: test_token_parse__no_commentvoid test_token_parse__no_comment(void) { token tk = token_parse("/"not # a comment/" /"foo/" bar"); ass(str_eq(token_str_value(tk), "not # a comment")); token tk2 = token_parse(token_rest(tk)); ass(str_eq(token_str_value(tk2), "foo"));}
开发者ID:keleshev,项目名称:kcats,代码行数:7,
示例7: test_token_parse__commentvoid test_token_parse__comment(void) { token tk = token_parse("# abc def/nfoo #ghi jkl /n bar"); ass(str_eq(token_symbol_value(tk), "foo")); token tk2 = token_parse(token_rest(tk)); ass(str_eq(token_symbol_value(tk2), "bar")); ass(str_eq(token_rest(tk2), ""));}
开发者ID:keleshev,项目名称:kcats,代码行数:8,
示例8: secd_strhashstatic cell_t *lookup_fake_variables(secd_t *secd, const char *sym) { hash_t symh = secd_strhash(sym); if ((symh == stdinhash) && str_eq(sym, SECD_FAKEVAR_STDIN)) return secd->input_port; if ((symh == stdouthash) && str_eq(sym, SECD_FAKEVAR_STDOUT)) return secd->output_port; if ((symh == stddbghash) && str_eq(sym, SECD_FAKEVAR_STDDBG)) return secd->debug_port; return SECD_NIL;}
开发者ID:EarlGray,项目名称:SECD,代码行数:10,
示例9: add_exe_ext_if_no_to_fullpathvoid add_exe_ext_if_no_to_fullpath(char *full_path_win_ext, size_t max_size, const char *ext, const char *path) { if (!ext || (!str_eq(".exe", ext) && !str_eq(".bat", ext) && !str_eq(".EXE", ext) && !str_eq(".BAT", ext))) { snprintf(full_path_win_ext, max_size, "%s.exe", path); } else { snprintf(full_path_win_ext, max_size, "%s", path); }}
开发者ID:Strongc,项目名称:ccache,代码行数:11,
示例10: test_token_parse__floatvoid test_token_parse__float(void) { token tk = token_parse("3.14 -2.72 foo bar"); ass(token_is_float(tk)); ass(token_float_value(tk) == 3.14); ass(str_eq(token_rest(tk), " -2.72 foo bar")); token tk2 = token_parse(token_rest(tk)); ass(token_is_float(tk2)); ass(token_float_value(tk2) == -2.72); ass(str_eq(token_rest(tk2), " foo bar"));}
开发者ID:keleshev,项目名称:kcats,代码行数:11,
示例11: test_token_parse__strvoid test_token_parse__str(void) { token tk = token_parse("/n /"hello world!/" /n /" foobar /" 3 4"); ass(token_is_str(tk)); ass(str_eq(token_str_value(tk), "hello world!")); ass(str_eq(token_rest(tk), " /n /" foobar /" 3 4")); token tk2 = token_parse(token_rest(tk)); ass(token_is_str(tk2)); ass(str_eq(token_str_value(tk2), " foobar ")); ass(str_eq(token_rest(tk2), " 3 4"));}
开发者ID:keleshev,项目名称:kcats,代码行数:11,
示例12: test_token_parse__indexvoid test_token_parse__index(void) { token tk = token_parse(" /n [0] [12] bar"); ass(token_is_index(tk)); ass(token_index_value(tk) == 0); ass(str_eq(token_rest(tk), " [12] bar")); token tk2 = token_parse(token_rest(tk)); ass(token_is_index(tk2)); ass(token_index_value(tk2) == 12); ass(str_eq(token_rest(tk2), " bar"));}
开发者ID:keleshev,项目名称:kcats,代码行数:11,
示例13: field_strssize_t field_str(const char *value, const char *line, const char *delim) { char *curfield; /* to hold fields from line */ int max_field_chars; /* size of curfield buffer */ int curfield_len; /* return value of get_line_field() */ int i; /* the index of the field being inspected */ int found; /* whether the value was found in line */ /* no value to look for? don't waste our time. but looking for an empty string may be valid. */ if (value == NULL) return -2; /* undefined or empty line? then it can't contain the value. */ if (line == NULL || line[0] == '/0') return -1; /* no delimiter? then treat the line like a single field. */ if (delim == NULL || delim[0] == '/0') { if (str_eq(value, line)) return 0; return -1; } /* TODO(jhinds): get rid of the malloc'd buffer for holding line fields. * This could be done better, e.g. by using get_line_pos(). */ /* this only needs to be just long enough to see if the field matches value (1 char longer), but making it a little bigger, just for fun. and allocating max+1 so there's room for the null terminator. */ max_field_chars = strlen(value) + 3; curfield = xmalloc(max_field_chars + 1); i = 0; curfield_len = 0; found = 0; while ((curfield_len = get_line_field(curfield, line, max_field_chars, i, delim)) > -1) { if (str_eq(curfield, value)) { found = 1; break; } i++; } free(curfield); if (found) return i; return -1;}
开发者ID:dbushong,项目名称:crush-tools,代码行数:53,
示例14: test_token_parse__symbolvoid test_token_parse__symbol(void) { //TODO foo#comment token tk = token_parse("/nfoo bar/nspam/teggs"); ass(token_is_symbol(tk)); ass(str_eq(token_symbol_value(tk), "foo")); ass(str_eq(token_rest(tk), " bar/nspam/teggs")); token tk2 = token_parse(token_rest(tk)); ass(token_is_symbol(tk2)); ass(str_eq(token_symbol_value(tk2), "bar")); ass(str_eq(token_rest(tk2), "/nspam/teggs"));}
开发者ID:keleshev,项目名称:kcats,代码行数:12,
示例15: test_token_parse__defvoid test_token_parse__def(void) { token tk = token_parse(" foo: bar # abc /nspam: eggs"); ass(token_is_def(tk)); ass(str_eq(token_def_value(tk), "foo")); token tk2 = token_parse(token_rest(tk)); ass(token_is_symbol(tk2)); ass(str_eq(token_symbol_value(tk2), "bar")); token tk3 = token_parse(token_rest(tk2)); ass(token_is_def(tk3)); ass(str_eq(token_def_value(tk3), "spam"));}
开发者ID:keleshev,项目名称:kcats,代码行数:13,
示例16: assertcell_t *lookup_env(secd_t *secd, const char *symbol, cell_t **symc) { cell_t *env = secd->env; assert(cell_type(env) == CELL_CONS, "lookup_env: environment is not a list"); cell_t *res = lookup_fake_variables(secd, symbol); if (not_nil(res)) return res; hash_t symh = secd_strhash(symbol); while (not_nil(env)) { // walk through frames cell_t *frame = get_car(env); if (is_nil(frame)) { /* skip omega-frame */ env = list_next(secd, env); continue; } cell_t *symlist = get_car(frame); cell_t *vallist = get_cdr(frame); while (not_nil(symlist)) { // walk through symbols if (is_symbol(symlist)) { if (symh == symhash(symlist) && str_eq(symbol, symname(symlist))) { if (symc != NULL) *symc = symlist; return vallist; } break; } cell_t *curc = get_car(symlist); assert(is_symbol(curc), "lookup_env: variable at [%ld] is not a symbol/n", cell_index(secd, curc)); if (symh == symhash(curc) && str_eq(symbol, symname(curc))) { if (symc != NULL) *symc = curc; return get_car(vallist); } symlist = list_next(secd, symlist); vallist = list_next(secd, vallist); } env = list_next(secd, env); } //errorf(";; error in lookup_env(): %s not found/n", symbol); return new_error(secd, SECD_NIL, "Lookup failed for: '%s'", symbol);}
开发者ID:EarlGray,项目名称:SECD,代码行数:50,
示例17: sort_and_clean/* sort the files we've found and delete the oldest ones until we are below the thresholds */static voidsort_and_clean(void){ unsigned i; const char *ext; char *last_base = x_strdup(""); if (num_files > 1) { /* Sort in ascending mtime order. */ qsort(files, num_files, sizeof(struct files *), (COMPAR_FN_T)files_compare); } /* delete enough files to bring us below the threshold */ for (i = 0; i < num_files; i++) { if ((cache_size_threshold == 0 || cache_size <= cache_size_threshold) && (files_in_cache_threshold == 0 || files_in_cache <= files_in_cache_threshold)) { break; } ext = get_extension(files[i]->fname); if (str_eq(ext, ".o") || str_eq(ext, ".d") || str_eq(ext, ".stderr") || str_eq(ext, "")) { char *base = remove_extension(files[i]->fname); if (!str_eq(base, last_base)) { /* Avoid redundant unlinks. */ /* * Make sure that all sibling files are deleted so that a cached result * is removed completely. Note the order of deletions -- the stderr * file must be deleted last because if the ccache process gets killed * after deleting the .stderr but before deleting the .o, the cached * result would be inconsistent. */ delete_sibling_file(base, ".o"); delete_sibling_file(base, ".d"); delete_sibling_file(base, ".stderr"); delete_sibling_file(base, ""); /* Object file from ccache 2.4. */ } free(last_base); last_base = base; } else { /* .manifest or unknown file. */ delete_file(files[i]->fname, files[i]->size); } } free(last_base);}
开发者ID:DGCDev,项目名称:digitalcoin,代码行数:51,
示例18: init_logstatic boolinit_log(void){ extern struct conf *conf; if (logfile) { return true; } assert(conf); if (str_eq(conf->log_file, "")) { return false; } logfile = fopen(conf->log_file, "a"); if (logfile) {#ifndef _WIN32 int fd = fileno(logfile); int flags = fcntl(fd, F_GETFD, 0); if (flags >= 0) { fcntl(fd, F_SETFD, flags | FD_CLOEXEC); }#endif return true; } else { return false; }}
开发者ID:chirayudesai,项目名称:ccache,代码行数:26,
示例19: cct_check_str_eqboolcct_check_str_eq(const char *file, int line, const char *expression, const char *expected, const char *actual, bool free1, bool free2){ bool result; if (expected && actual && str_eq(actual, expected)) { cct_check_passed(file, line, expression); result = true; } else { char *exp_str = expected ? format("/"%s/"", expected) : x_strdup("(null)"); char *act_str = actual ? format("/"%s/"", actual) : x_strdup("(null)"); cct_check_failed(file, line, expression, exp_str, act_str); free(exp_str); free(act_str); result = false; } if (free1) { free((char *)expected); } if (free2) { free((char *)actual); } return result;}
开发者ID:TheOneRing,项目名称:ccache,代码行数:27,
示例20: fprintfPic *pic_open_stream (char *dev, FILE *stream, char *name, char *mode){ int i; char *data; Pic *p, *q; if (pic_npic<0) pic_init(); if (!dev) { /* probably comes from pic_file_dev */ fprintf(stderr, "unknown pic device on %s/n", name); return 0; } for (i=0; i<pic_npic && !str_eq(dev, pic_list[i]->dev); i++); if (i>=pic_npic) { fprintf(stderr, "unknown pic device: %s/n", dev); return 0; } q = pic_list[i]; data = (*q->procs->open_stream)(stream, name, mode); if (!data) return 0; /* copy the Pic structure before modifying it */ ALLOC(p, Pic, 1); *p = *q; p->data = data; return p;}
开发者ID:uw-loci,项目名称:ome-server,代码行数:26,
示例21: parse_objectcolor_object parse_object(const char *name) /* {{{ */{ /* parse an object from a string */ unsigned int i; struct color_object_map { const color_object object; const char *name; }; /* object map */ static const struct color_object_map color_objects_map[] = { {OBJECT_HEADER, "header"}, {OBJECT_TASK, "task"}, {OBJECT_ERROR, "error"}, }; /* evaluate map */ for (i=0; i<sizeof(color_objects_map)/sizeof(struct color_object_map); i++) { if (str_eq(color_objects_map[i].name, name)) return color_objects_map[i].object; } return OBJECT_NONE;} /* }}} */
开发者ID:skn,项目名称:tasknc,代码行数:27,
示例22: hostname_readint hostname_read(int fd, char* hostname){ char host[HOST_NAME_MAX]; int len; if (fd < 0 || !hostname) return -1; lseek(fd, 0, SEEK_SET); len = read(fd, host, HOST_NAME_MAX); if (len <= 0) return len; host[len-1] = '/0'; if (str_eq("(none)", host)) { hostname[0] = '/0'; return 0; } str_copy(hostname, host, HOST_NAME_MAX); return len;}
开发者ID:vitalikp,项目名称:journal,代码行数:27,
示例23: select_residue_segid/*------------------------------------------------------------*/voidselect_residue_segid (const char *item){ mol3d *mol; res3d *res; int *flags;#ifndef NDEBUG int old = count_residue_selections();#endif assert (item); assert (*item); push_residue_selection(); flags = current_residue_sel->flags; for (mol = first_molecule; mol; mol = mol->next) { for (res = mol->first; res; res = res->next) { *flags++ = str_eq (res->segid, item); } }#ifdef SELECT_DEBUG fprintf (stderr, "residue select segid: %i/n", select_residue_count());#endif#ifndef NDEBUG assert (count_residue_selections() == old + 1);#endif}
开发者ID:greatlse,项目名称:MolScript,代码行数:30,
示例24: win32getshellchar *win32getshell(char *path){ char *path_env; char *sh = NULL; const char *ext = get_extension(path); if (ext && strcasecmp(ext, ".sh") == 0 && (path_env = getenv("PATH"))) { sh = find_executable_in_path("sh.exe", NULL, path_env); } if (!sh && getenv("CCACHE_DETECT_SHEBANG")) { // Detect shebang. FILE *fp = fopen(path, "r"); if (fp) { char buf[10]; fgets(buf, sizeof(buf), fp); buf[9] = 0; if (str_eq(buf, "#!/bin/sh") && (path_env = getenv("PATH"))) { sh = find_executable_in_path("sh.exe", NULL, path_env); } fclose(fp); } } return sh;}
开发者ID:orgads,项目名称:ccache,代码行数:25,
示例25: search_encodingstatic const char * search_encoding( char * norm, /* The name of encoding specified */ int alias /* The number of alias to start searching */){ const char * loc; int lo, al; for (lo = 0; lo < NUM_ENCODING; lo++) { for (al = alias ; al < NUM_ALIAS; al++) { loc = encoding_name[ lo][ al]; if (str_eq( loc, norm)) { switch (lo) { case 0 : mbchar = 0; break; case 1 : mbchar = EUC_JP; break; case 2 : mbchar = GB2312; break; case 3 : mbchar = KSC5601; break; case 4 : mbchar = SJIS; break; case 5 : mbchar = BIGFIVE; break; case 6 : mbchar = ISO2022_JP; break; case 7 : mbchar = UTF8; break; } return loc; } } } return NULL;}
开发者ID:Abyss116,项目名称:luaplus51-all,代码行数:28,
示例26: conf_set_value_in_fileboolconf_set_value_in_file(const char *path, const char *key, const char *value, char **errmsg){ FILE *infile, *outfile; char *outpath; char buf[10000]; bool found; const struct conf_item *item; item = find_conf(key); if (!item) { *errmsg = format("unknown configuration option /"%s/"", key); return false; } infile = fopen(path, "r"); if (!infile) { *errmsg = format("%s: %s", path, strerror(errno)); return false; } outpath = format("%s.tmp.%s", path, tmp_string()); outfile = fopen(outpath, "w"); if (!outfile) { *errmsg = format("%s: %s", outpath, strerror(errno)); free(outpath); fclose(infile); return false; } found = false; while (fgets(buf, sizeof(buf), infile)) { char *errmsg2, *key2, *value2; bool ok; ok = parse_line(buf, &key2, &value2, &errmsg2); if (ok && key2 && str_eq(key2, key)) { found = true; fprintf(outfile, "%s = %s/n", key, value); } else { fputs(buf, outfile); } free(key2); free(value2); } if (!found) { fprintf(outfile, "%s = %s/n", key, value); } fclose(infile); fclose(outfile); if (x_rename(outpath, path) != 0) { *errmsg = format("rename %s to %s: %s", outpath, path, strerror(errno)); return false; } free(outpath); return true;}
开发者ID:TheOneRing,项目名称:ccache,代码行数:60,
示例27: parse_boolstatic boolparse_bool(const char *str, void *result, char **errmsg){ bool *value = (bool *)result; if (str_eq(str, "true")) { *value = true; return true; } else if (str_eq(str, "false")) { *value = false; return true; } else { *errmsg = format("not a boolean value: /"%s/"", str); return false; }}
开发者ID:TheOneRing,项目名称:ccache,代码行数:16,
示例28: match_strvoid match_str (const char * str){ l_get_token (); if (!str_eq(str,token)) { merror_expect(str); }}
开发者ID:AnderainLovelace,项目名称:InvisibleBasic,代码行数:8,
示例29: find_executable_in_pathstatic char *find_executable_in_path(const char *name, const char *exclude_name, char *path){ path = x_strdup(path); // Search the path looking for the first compiler of the right name that // isn't us. char *saveptr = NULL; for (char *tok = strtok_r(path, PATH_DELIM, &saveptr); tok; tok = strtok_r(NULL, PATH_DELIM, &saveptr)) {#ifdef _WIN32 char namebuf[MAX_PATH]; int ret = SearchPath(tok, name, NULL, sizeof(namebuf), namebuf, NULL); if (!ret) { char *exename = format("%s.exe", name); ret = SearchPath(tok, exename, NULL, sizeof(namebuf), namebuf, NULL); free(exename); } (void) exclude_name; if (ret) { free(path); return x_strdup(namebuf); }#else struct stat st1, st2; char *fname = format("%s/%s", tok, name); // Look for a normal executable file. if (access(fname, X_OK) == 0 && lstat(fname, &st1) == 0 && stat(fname, &st2) == 0 && S_ISREG(st2.st_mode)) { if (S_ISLNK(st1.st_mode)) { char *buf = x_realpath(fname); if (buf) { char *p = basename(buf); if (str_eq(p, exclude_name)) { // It's a link to "ccache"! free(p); free(buf); continue; } free(buf); free(p); } } // Found it! free(path); return fname; } free(fname);#endif } free(path); return NULL;}
开发者ID:orgads,项目名称:ccache,代码行数:58,
示例30: mainintmain(int argc, char **argv){ extern char *cache_logfile; cache_logfile = "/dev/stdout"; if (argc == 4) { unsigned staleness_limit = atoi(argv[1]); if (str_eq(argv[2], "acquire")) { return lockfile_acquire(argv[3], staleness_limit) == 0; } else if (str_eq(argv[2], "release")) { lockfile_release(argv[3]); return 0; } } fprintf(stderr, "Usage: testlockfile <staleness_limit> <acquire|release> <path>/n"); return 1;}
开发者ID:jmartens,项目名称:ccache-win32,代码行数:18,
注:本文中的str_eq函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ str_equal函数代码示例 C++ str_empty函数代码示例 |