这篇教程C++ strbuf_close函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中strbuf_close函数的典型用法代码示例。如果您正苦于以下问题:C++ strbuf_close函数的具体用法?C++ strbuf_close怎么用?C++ strbuf_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了strbuf_close函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: setenv_from_configvoidsetenv_from_config(void){ int i, lim = sizeof(envname) / sizeof(char *); STRBUF *sb = strbuf_open(0); for (i = 0; i < lim; i++) { if (getenv(envname[i]) == NULL) { strbuf_reset(sb); if (getconfs(envname[i], sb)) set_env(envname[i], strbuf_value(sb)); else if (getconfb(envname[i])) set_env(envname[i], ""); } } /* * For upper compatibility. * htags_options is deprecated. */ if (getenv("HTAGS_OPTIONS") == NULL) { strbuf_reset(sb); if (getconfs("htags_options", sb)) set_env("HTAGS_OPTIONS", strbuf_value(sb)); } strbuf_close(sb);}
开发者ID:badwtg1111,项目名称:emacs-c-ide-demo,代码行数:26,
示例2: load_alias/* * load_alias: load alias value. * * [$HOME/.gozillarc] * +----------------------- * |a:http://www.gnu.org * |f = file:/usr/share/xxx.html * |www http://www.xxx.yyy/ */static voidload_alias(void){ FILE *ip; STRBUF *sb = strbuf_open(0); char *p; int flag = STRBUF_NOCRLF; struct sh_entry *ent; sh = strhash_open(10); if (!(p = get_home_directory())) goto end; if (!test("r", makepath(p, gozillarc, NULL)))#ifdef __DJGPP__ if (!test("r", makepath(p, dos_gozillarc, NULL)))#endif goto end; if (!(ip = fopen(makepath(p, gozillarc, NULL), "r")))#ifdef __DJGPP__ if (!(ip = fopen(makepath(p, dos_gozillarc, NULL), "r")))#endif goto end; while ((p = strbuf_fgets(sb, ip, flag)) != NULL) { char *name, *value; flag &= ~STRBUF_APPEND; if (*p == '#') continue; if (strbuf_unputc(sb, '//')) { flag |= STRBUF_APPEND; continue; } while (*p && isblank(*p)) /* skip spaces */ p++; name = p; while (*p && isalnum(*p)) /* get name */ p++; *p++ = 0; while (*p && isblank(*p)) /* skip spaces */ p++; if (*p == '=' || *p == ':') { p++; while (*p && isblank(*p))/* skip spaces */ p++; } value = p; while (*p && !isblank(*p)) /* get value */ p++; *p = 0; ent = strhash_assign(sh, name, 1); if (ent->value) (void)free(ent->value); ent->value = check_strdup(value); } fclose(ip);end: strbuf_close(sb);}
开发者ID:cage433,项目名称:global_with_scala,代码行数:67,
示例3: replace_variablesstatic voidreplace_variables(STRBUF *sb){ STRBUF *result = strbuf_open(0); STRBUF *word = strbuf_open(0); const char *p = strbuf_value(sb); /* * Simple of detecting infinite loop. */ if (++recursive_call > 32) die("Seems to be a never-ending referring."); for (;;) { for (; *p; p++) { if (*p == '$') break; if (*p == '//' && *(p + 1) != 0) p++; strbuf_putc(result, *p); } if (*p == 0) break; /* * $<word> or ${<word>} */ if (*p == '$') { strbuf_reset(word); if (*++p == '{') { for (p++; *p && *p != '}'; p++) strbuf_putc(word, *p);; if (*p++ != '}') die("invalid variable."); } else { for (; *p && (isalnum(*p) || *p == '_'); p++) strbuf_putc(word, *p); } getconfs(strbuf_value(word), result); } } strbuf_reset(sb); strbuf_puts(sb, strbuf_value(result)); strbuf_close(result); strbuf_close(word); recursive_call--;}
开发者ID:lucafavatella,项目名称:mirror-gnu-global,代码行数:45,
示例4: prepare_source/* * prepare_source: preparing regular expression. * * i) flags flags for regcomp. * go) suff regular expression for source files. */static voidprepare_source(void){ STRBUF *sb = strbuf_open(0); char *sufflist = NULL; int flags = REG_EXTENDED; /* * load icase_path option. */ if (getconfb("icase_path")) flags |= REG_ICASE;#if defined(_WIN32) || defined(__DJGPP__) flags |= REG_ICASE;#endif strbuf_reset(sb); if (!getconfs("suffixes", sb)) die("cannot get suffixes data."); sufflist = check_strdup(strbuf_value(sb)); trim(sufflist); { const char *suffp; int retval; strbuf_reset(sb); strbuf_puts(sb, "//.("); /* ) */ for (suffp = sufflist; suffp; ) { const char *p; for (p = suffp; *p && *p != ','; p++) { if (!isalnum((unsigned char)*p)) strbuf_putc(sb, '//'); strbuf_putc(sb, *p); } if (!*p) break; assert(*p == ','); strbuf_putc(sb, '|'); suffp = ++p; } strbuf_puts(sb, ")$"); /* * compile regular expression. */ retval = regcomp(suff, strbuf_value(sb), flags);#ifdef DEBUG if (debug) fprintf(stderr, "find regex: %s/n", strbuf_value(sb));#endif if (retval != 0) die("cannot compile regular expression."); } strbuf_close(sb); if (sufflist) free(sufflist);}
开发者ID:kosaki,项目名称:gtags,代码行数:62,
示例5: dbop_close/** * dbop_close: close db * * @param[in] dbop dbop descripter */voiddbop_close(DBOP *dbop){ DB *db = dbop->db; /* * Load sorted tag records and write them to the tag file. */ if (dbop->sortout != NULL) { STRBUF *sb = strbuf_open(256); char *p; /* * End of the former stage of sorted writing. * fclose() and sortout = NULL is important. * * fclose(): enables reading from sortin descriptor. * sortout = NULL: makes the following dbop_put write to the tag file directly. */ fclose(dbop->sortout); dbop->sortout = NULL; /* * The last stage of sorted writing. */ while (strbuf_fgets(sb, dbop->sortin, STRBUF_NOCRLF)) { for (p = strbuf_value(sb); *p && *p != SORT_SEP; p++) ; if (!*p) die("unexpected end of record."); *p++ = '/0'; dbop_put(dbop, strbuf_value(sb), p); } fclose(dbop->sortin); strbuf_close(sb); terminate_sort_process(dbop); }#ifdef USE_SQLITE3 if (dbop->openflags & DBOP_SQLITE3) { dbop3_close(dbop); return; }#endif#ifdef USE_DB185_COMPAT (void)db->close(db);#else /* * If dbname = NULL, omit writing to the disk in __bt_close(). */ (void)db->close(db, dbop->dbname[0] == '/0' ? 1 : 0);#endif if (dbop->dbname[0] != '/0') { if (dbop->perm && chmod(dbop->dbname, dbop->perm) < 0) die("chmod(2) failed."); } (void)free(dbop);}
开发者ID:luchachen,项目名称:global,代码行数:61,
示例6: usable/** * usable: check if command is executable or not. * * @param[in] command * @return ==NULL: not found. <br> * !=NULL: absolute path of @a command. */char *usable(const char *command){ STRBUF *sb; char *p; const char *dir; static char path[MAXPATHLEN];#if defined(_WIN32) || defined(__DJGPP__) int i, lim = sizeof(suffix)/sizeof(char *);#endif if (isabspath(command) || locatestring(command, "./", MATCH_AT_FIRST) || locatestring(command, "../", MATCH_AT_FIRST)) { if (test("fx", command)) { strlimcpy(path, command, sizeof(path)); return path; } return NULL; } /* * If found in BINDIR then use it. */ if (test("fx", makepath(BINDIR, command, NULL))) { strlimcpy(path, makepath(BINDIR, command, NULL), sizeof(path)); return path; } /* * Locate the command for each path in PATH. */ *path = 0; /* Don't use fixed length buffer for environment variable * because it brings buffer overflow. */ sb = strbuf_open(0); strbuf_puts(sb, getenv("PATH")); p = strbuf_value(sb); while (p) { dir = p; if ((p = locatestring(p, PATHSEP, MATCH_FIRST)) != NULL) *p++ = 0; if (test("fx", makepath(dir, command, NULL))) { strlimcpy(path, makepath(dir, command, NULL), sizeof(path)); goto finish; }#if defined(_WIN32) || defined(__DJGPP__) for (i = 0; i < lim; i++) if (test("f", makepath(dir, command, suffix[i]))) { strlimcpy(path, makepath(dir, command, suffix[i]), sizeof(path)); goto finish; }#endif }finish: strbuf_close(sb); return *path ? path : NULL;}
开发者ID:aYosukeAkatsuka,项目名称:global-6.4,代码行数:63,
示例7: loadfile/** * Load file. */voidloadfile(const char *file, STRBUF *result){ STRBUF *sb = strbuf_open(0); FILE *ip = fopen(file, "r"); if (!ip) die("file '%s' not found.", file); while (strbuf_fgets(sb, ip, STRBUF_NOCRLF) != NULL) strbuf_puts_nl(result, strbuf_value(sb)); fclose(ip); strbuf_close(sb);}
开发者ID:lucafavatella,项目名称:mirror-gnu-global,代码行数:15,
示例8: makedirectories/* * makedirectories: make directories on the path like mkdir(1) with the -p option. * * i) base base directory * i) rest path from the base * i) verbose 1: verbose mode, 0: not verbose mode * r) 0: success * -1: base directory not found * -2: permission error * -3: cannot make directory */intmakedirectories(const char *base, const char *rest, int verbose){ STRBUF *sb; const char *p, *q; if (!test("d", base)) return -1; if (!test("drw", base)) return -2; sb = strbuf_open(0); strbuf_puts(sb, base); if (*rest == SEP) rest++; for (q = rest; *q;) { p = q; while (*q && *q != SEP) q++; strbuf_putc(sb, SEP); strbuf_nputs(sb, p, q - p); p = strbuf_value(sb); if (!test("d", p)) { if (verbose) fprintf(stderr, " Making directory '%s'./n", p);#if defined(_WIN32) && !defined(__CYGWIN__) if (mkdir(p) < 0) {#else if (mkdir(p, 0775) < 0) {#endif /* WIN32 */ strbuf_close(sb); return -3; } } if (*q == SEP) q++; } strbuf_close(sb); return 0;}
开发者ID:WilsonChiang,项目名称:global,代码行数:50,
示例9: tagsearch/* * tagsearch: execute tag search * * i) pattern search pattern * i) cwd current directory * i) root root of source tree * i) dbpath database directory * i) db GTAGS,GRTAGS,GSYMS */voidtagsearch(const char *pattern, const char *cwd, const char *root, const char *dbpath, int db){ int count, total = 0; char libdbpath[MAXPATHLEN]; /* * search in current source tree. */ count = search(pattern, root, cwd, dbpath, db); total += count; /* * search in library path. */ if (db == GTAGS && getenv("GTAGSLIBPATH") && (count == 0 || Tflag) && !lflag) { STRBUF *sb = strbuf_open(0); char *libdir, *nextp = NULL; strbuf_puts(sb, getenv("GTAGSLIBPATH")); /* * search for each tree in the library path. */ for (libdir = strbuf_value(sb); libdir; libdir = nextp) { if ((nextp = locatestring(libdir, PATHSEP, MATCH_FIRST)) != NULL) *nextp++ = 0; if (!gtagsexist(libdir, libdbpath, sizeof(libdbpath), 0)) continue; if (!strcmp(dbpath, libdbpath)) continue; if (!test("f", makepath(libdbpath, dbname(db), NULL))) continue; /* * search again */ count = search(pattern, libdir, cwd, libdbpath, db); total += count; if (count > 0 && !Tflag) { /* for verbose message */ dbpath = libdbpath; break; } } strbuf_close(sb); } if (vflag) { print_count(total); if (!Tflag) fprintf(stderr, " (using '%s')", makepath(dbpath, dbname(db), NULL)); fputs("./n", stderr); }}
开发者ID:WilsonChiang,项目名称:global,代码行数:60,
示例10: xargs_close/** * xargs_close(xp) * * @param[in] xp xargs structure */intxargs_close(XARGS *xp){ int count; assert(xp != NULL); count = xp->seqno; assert(xp->pipe == NULL); free(xp->command); strbuf_close(xp->result); switch (xp->type) { case XARGS_FILE: strbuf_close(xp->path); break; case XARGS_ARGV: case XARGS_STRBUF: /* Nothing to do */ break; } free(xp); return count;}
开发者ID:aYosukeAkatsuka,项目名称:global-6.4,代码行数:28,
示例11: dbop3_closevoiddbop3_close(DBOP *dbop) { int rc; char *errmsg = 0; rc = sqlite3_exec(dbop->db3, "end transaction", NULL, NULL, &errmsg); if (rc != SQLITE_OK) die("end transaction error: %s", errmsg); /* * create index */ if (dbop->mode == 1 && dbop->openflags & DBOP_DUP) { STATIC_STRBUF(sql); strbuf_clear(sql); strbuf_puts(sql, "create index key_i on "); strbuf_puts(sql, dbop->tblname); strbuf_puts(sql, "(key)"); rc = sqlite3_exec(dbop->db3, strbuf_value(sql), NULL, NULL, &errmsg); if (rc != SQLITE_OK) die("create index error: %s", errmsg); strbuf_clear(sql); strbuf_puts(sql, "create index fid_i on "); strbuf_puts(sql, dbop->tblname); strbuf_puts(sql, "(extra)"); rc = sqlite3_exec(dbop->db3, strbuf_value(sql), NULL, NULL, &errmsg); if (rc != SQLITE_OK) die("create index error: %s", errmsg); } if (dbop->stmt) { rc = sqlite3_finalize(dbop->stmt); if (rc != SQLITE_OK) die("sqlite3_finalize failed. (rc = %d)", rc); dbop->stmt = NULL; } if (dbop->stmt_put3) { rc = sqlite3_finalize(dbop->stmt_put3); if (rc != SQLITE_OK) die("dbop3_finalize failed. (rc = %d)", rc); dbop->stmt_put3 = NULL; } rc = sqlite3_close(dbop->db3); if (rc != SQLITE_OK) die("sqlite3_close failed. (rc = %d)", rc); dbop->db3 = NULL; if (dbop->tblname) free((void *)dbop->tblname); strbuf_close(dbop->sb); free(dbop);}
开发者ID:luchachen,项目名称:global,代码行数:50,
示例12: configuration/** * load configuration variables. */static voidconfiguration(){ STRBUF *sb = strbuf_open(0); if (getconfb("extractmethod")) extractmethod = 1; strbuf_reset(sb); if (getconfs("langmap", sb)) langmap = check_strdup(strbuf_value(sb)); strbuf_reset(sb); if (getconfs("gtags_parser", sb)) gtags_parser = check_strdup(strbuf_value(sb)); strbuf_close(sb);}
开发者ID:lianhongHou,项目名称:Emacs,代码行数:18,
示例13: completion_idutils/** * completion_idutils: print completion list of specified @a prefix * * @param[in] dbpath dbpath directory * @param[in] root root directory * @param[in] prefix prefix of primary key */voidcompletion_idutils(const char *dbpath, const char *root, const char *prefix){ FILE *ip; STRBUF *sb = strbuf_open(0); const char *lid = usable("lid"); char *line, *p; if (prefix && *prefix == 0) /* In the case global -c '' */ prefix = NULL; /* * make lid command line. * Invoke lid with the --result=grep option to generate grep format. */ if (!lid) die("lid(idutils) not found."); strbuf_puts(sb, lid); strbuf_sprintf(sb, " --file=%s/ID", quote_shell(dbpath)); strbuf_puts(sb, " --key=token"); if (iflag) strbuf_puts(sb, " --ignore-case"); if (prefix) { strbuf_putc(sb, ' '); strbuf_putc(sb, '"'); strbuf_putc(sb, '^'); strbuf_puts(sb, prefix); strbuf_putc(sb, '"'); } if (debug) fprintf(stderr, "completion_idutils: %s/n", strbuf_value(sb)); if (chdir(root) < 0) die("cannot move to '%s' directory.", root); if (!(ip = popen(strbuf_value(sb), "r"))) die("cannot execute '%s'.", strbuf_value(sb)); while ((line = strbuf_fgets(sb, ip, STRBUF_NOCRLF)) != NULL) { for (p = line; *p && *p != ' '; p++) ; if (*p == '/0') { warning("Invalid line: %s", line); continue; } *p = '/0'; puts(line); } if (pclose(ip) != 0) die("terminated abnormally (errno = %d).", errno); strbuf_close(sb);}
开发者ID:rchmielarz,项目名称:global-ttcn3,代码行数:55,
示例14: getURL/* * getURL: get URL of the specified file. * * i) file file name * i) htmldir HTML directory * o) URL URL begin with 'file:' */voidgetURL(const char *file, const char *htmldir, STRBUF *URL){ char *p; char buf[MAXPATHLEN]; STRBUF *sb = strbuf_open(0); if (!test("f", file) && !test("d", file)) die("file '%s' not found.", file); p = normalize(file, get_root_with_slash(), cwd, buf, sizeof(buf)); if (p != NULL && convertpath(dbpath, htmldir, p, sb) == 0) makefileurl(strbuf_value(sb), linenumber, URL); else makefileurl(realpath(file, buf), 0, URL); strbuf_close(sb);}
开发者ID:fedragoneric,项目名称:global,代码行数:23,
示例15: printconf/* * printconf: print configuration data. * * i) name label of config data * r) exit code */intprintconf(const char *name){ int num; int exist = 1; if (getconfn(name, &num)) fprintf(stdout, "%d/n", num); else if (getconfb(name)) fprintf(stdout, "1/n"); else { STRBUF *sb = strbuf_open(0); if (getconfs(name, sb)) fprintf(stdout, "%s/n", strbuf_value(sb)); else exist = 0; strbuf_close(sb); } return exist;}
开发者ID:baohaojun,项目名称:ajoke-global,代码行数:26,
示例16: completion/** * completion: print completion list of specified @a prefix * * @param[in] dbpath dbpath directory * @param[in] root root directory * @param[in] prefix prefix of primary key * @param[in] db #GTAGS,#GRTAGS,#GSYMS */voidcompletion(const char *dbpath, const char *root, const char *prefix, int db){ int count, total = 0; char libdbpath[MAXPATHLEN]; if (prefix && *prefix == 0) /* In the case global -c '' */ prefix = NULL; count = completion_tags(dbpath, root, prefix, db); /* * search in library path. */ if (db == GTAGS && getenv("GTAGSLIBPATH") && (count == 0 || Tflag) && !Sflag) { STRBUF *sb = strbuf_open(0); char *libdir, *nextp = NULL; strbuf_puts(sb, getenv("GTAGSLIBPATH")); /* * search for each tree in the library path. */ for (libdir = strbuf_value(sb); libdir; libdir = nextp) { if ((nextp = locatestring(libdir, PATHSEP, MATCH_FIRST)) != NULL) *nextp++ = 0; if (!gtagsexist(libdir, libdbpath, sizeof(libdbpath), 0)) continue; if (!strcmp(dbpath, libdbpath)) continue; if (!test("f", makepath(libdbpath, dbname(db), NULL))) continue; /* * search again */ count = completion_tags(libdbpath, libdir, prefix, db); total += count; if (count > 0 && !Tflag) break; } strbuf_close(sb); } /* return total; */}
开发者ID:rchmielarz,项目名称:global-ttcn3,代码行数:49,
示例17: gtags_close/** * gtags_close: close tag file * * @param[in] gtop #GTOP structure */voidgtags_close(GTOP *gtop){ if (gtop->format & GTAGS_COMPRESS) abbrev_close(); if (gtop->segment_pool) pool_close(gtop->segment_pool); if (gtop->path_array) free(gtop->path_array); if (gtop->sb) strbuf_close(gtop->sb); if (gtop->vb) varray_close(gtop->vb); if (gtop->path_hash) strhash_close(gtop->path_hash); gpath_close(); dbop_close(gtop->dbop); if (gtop->gtags) dbop_close(gtop->gtags); free(gtop);}
开发者ID:aYosukeAkatsuka,项目名称:global-6.4,代码行数:26,
示例18: includelabel/** * includelabel: procedure for tc= (or include=) * * @param[in] fp file pointer * @param[out] sb string buffer * @param[in] label record label * @param[in] level nest level for check * * This function may call itself (recursive) */static voidincludelabel(FILE *fp, STRBUF *sb, const char *label, int level){ const char *savep, *p, *q; char *file; if (++level > allowed_nest_level) die("nested include= (or tc=) over flow."); /* * Label can include a '@' and a following path name. * Label: <label>[@<path>] */ if ((file = locatestring(label, "@", MATCH_FIRST)) != NULL) { *file++ = '/0'; if ((p = makepath_with_tilde(file)) == NULL) die("config file must be absolute path. (%s)", file); fp = fopen(p, "r"); if (fp == NULL) die("cannot open config file. (%s)", p); } if (!(savep = p = readrecord(fp, label))) die("label '%s' not found.", label); while ((q = locatestring(p, ":include=", MATCH_FIRST)) || (q = locatestring(p, ":tc=", MATCH_FIRST))) { STRBUF *inc = strbuf_open(0); strbuf_nputs(sb, p, q - p); q = locatestring(q, "=", MATCH_FIRST) + 1; for (; *q && *q != ':'; q++) strbuf_putc(inc, *q); includelabel(fp, sb, strbuf_value(inc), level); p = q; strbuf_close(inc); } strbuf_puts(sb, p); free((void *)savep); if (file) fclose(fp);}
开发者ID:lucafavatella,项目名称:mirror-gnu-global,代码行数:48,
示例19: includelabel/** * includelabel: procedure for @CODE{tc=} (or @CODE{include=}) * * @param[out] sb string buffer * @param[in] label record label * @param[in] level nest level for check */static voidincludelabel(STRBUF *sb, const char *label, int level){ const char *savep, *p, *q; if (++level > allowed_nest_level) die("nested include= (or tc=) over flow."); if (!(savep = p = readrecord(label))) die("label '%s' not found.", label); while ((q = locatestring(p, ":include=", MATCH_FIRST)) || (q = locatestring(p, ":tc=", MATCH_FIRST))) { STRBUF *inc = strbuf_open(0); strbuf_nputs(sb, p, q - p); q = locatestring(q, "=", MATCH_FIRST) + 1; for (; *q && *q != ':'; q++) strbuf_putc(inc, *q); includelabel(sb, strbuf_value(inc), level); p = q; strbuf_close(inc); } strbuf_puts(sb, p); free((void *)savep);}
开发者ID:badwtg1111,项目名称:emacs-c-ide-demo,代码行数:30,
示例20: getdefinitionURL/** * getdefinitionURL: get URL includes specified definition. * * @param[in] arg definition name * @param[in] htmldir HTML directory * @param[out] URL URL begin with 'file:' */voidgetdefinitionURL(const char *arg, const char *htmldir, STRBUF *URL){ FILE *fp; char *p; SPLIT ptable; int status = -1; STRBUF *sb = strbuf_open(0); const char *path = makepath(htmldir, "D", NULL); if (!test("d", path)) die("'%s' not found. Please invoke htags(1) without the -D option.", path); path = makepath(htmldir, "MAP", NULL); if (!test("f", path)) die("'%s' not found. Please invoke htags(1) with the --map-file option.", path); fp = fopen(path, "r"); if (!fp) die("cannot open '%s'.", path); while ((p = strbuf_fgets(sb, fp, STRBUF_NOCRLF)) != NULL) { if (split(p, 2, &ptable) != 2) die("invalid format."); if (!strcmp(arg, ptable.part[0].start)) { status = 0; break; } } fclose(fp); if (status == -1) die("definition %s not found.", arg); strbuf_reset(URL); /* * convert path into URL. */ makefileurl(makepath(htmldir, ptable.part[1].start, NULL), 0, URL); recover(&ptable); strbuf_close(sb);}
开发者ID:GimXu,项目名称:global,代码行数:44,
示例21: makedupindex//.........这里部分代码省略......... close_file(fileop); html_count++; } writing = 0; /* * cache record: " <fid>/0<entry number>/0" */ strbuf_reset(tmp); strbuf_putc(tmp, ' '); strbuf_putn(tmp, count - 1); strbuf_putc(tmp, '/0'); strbuf_putn(tmp, entry_count); cache_put(db, prev, strbuf_value(tmp), strbuf_getlen(tmp) + 1); } /* single entry */ if (first_line[0]) { char fid[MAXFIDLEN]; const char *ctags_x = parse_xid(first_line, fid, NULL); const char *lno = nextelement(ctags_x); strbuf_reset(tmp); strbuf_puts_withterm(tmp, lno, ' '); strbuf_putc(tmp, '/0'); strbuf_puts(tmp, fid); cache_put(db, prev, strbuf_value(tmp), strbuf_getlen(tmp) + 1); } /* * Chop the tail of the line. It is not important. * strlimcpy(first_line, ctags_x, sizeof(first_line)); */ strncpy(first_line, ctags_xid, sizeof(first_line)); first_line[sizeof(first_line) - 1] = '/0'; strlimcpy(prev, tag, sizeof(prev)); entry_count = 0; } else { /* duplicate entry */ if (first_line[0]) { char fid[MAXFIDLEN]; const char *ctags_x = parse_xid(first_line, fid, NULL); if (!dynamic) { char path[MAXPATHLEN]; snprintf(path, sizeof(path), "%s/%s/%d.%s", distpath, dirs[db], count, HTML); fileop = open_output_file(path, cflag); op = get_descripter(fileop); fputs_nl(gen_page_begin(tag, SUBDIR), op); fputs_nl(body_begin, op); fputs_nl(gen_list_begin(), op); fputs_nl(gen_list_body(srcdir, ctags_x, fid), op); } writing = 1; entry_count++; first_line[0] = 0; } if (!dynamic) { fputs_nl(gen_list_body(srcdir, ctags_x, fid), op); } entry_count++; } } if (db == GTAGS) definition_count = count; if (pclose(ip) != 0) die("'%s' failed.", strbuf_value(command)); if (writing) { if (!dynamic) { fputs_nl(gen_list_end(), op); fputs_nl(body_end, op); fputs_nl(gen_page_end(), op); close_file(fileop); html_count++; } /* * cache record: " <fid>/0<entry number>/0" */ strbuf_reset(tmp); strbuf_putc(tmp, ' '); strbuf_putn(tmp, count); strbuf_putc(tmp, '/0'); strbuf_putn(tmp, entry_count); cache_put(db, prev, strbuf_value(tmp), strbuf_getlen(tmp) + 1); } if (first_line[0]) { char fid[MAXFIDLEN]; const char *ctags_x = parse_xid(first_line, fid, NULL); const char *lno = nextelement(ctags_x); strbuf_reset(tmp); strbuf_puts_withterm(tmp, lno, ' '); strbuf_putc(tmp, '/0'); strbuf_puts(tmp, fid); cache_put(db, prev, strbuf_value(tmp), strbuf_getlen(tmp) + 1); } } strbuf_close(sb); strbuf_close(tmp); strbuf_close(command); return definition_count;}
开发者ID:harveyt,项目名称:global,代码行数:101,
示例22: makecflowindex//.........这里部分代码省略......... } else if (isalpha(*p) || *p == '_') break; } m1 = "function name not found"; if (!*p || !isalpha(*p)) ERROR; name = p; /* name */ for (; *p && *p != ':'; p++) ; if (*p != ':') ERROR; name_end = p++; if (*p++ != ' ') ERROR; if (isdigit(*p)) { /* (1) name: 999 */ lineno = p; /* lineno */ for (; *p && isdigit(*p); p++) ; lineno_end = p; } else if (*p == '<' && *(p + 1) == '>') { /* (2) name: <> */ ; } else { /* (3) name: ... <path lineno> */ m1 = "<path lineno> not found"; for (; *p && *p != '<'; p++) ; if (!*p++) ERROR; path = p; m1 = "path not found"; for (; *p && !isspace(*p); p++) if (*p == '>') ERROR; if (!*p || *p != ' ') ERROR; path_end = p++; m1 = "lineno not found"; if (!isdigit(*p)) ERROR; lineno = p; for (; *p && isdigit(*p); p++) ; if (*p != '>') ERROR; lineno_end = p; } /* * print anchor */ fprintf(op, gen_name_number(atoi(anchor))); /* * print until name */ fwrite(cflow_posix, name - cflow_posix, 1, op); /* * print name */ if (path) { const char *fid = NULL; int path_save = *path_end; int lineno_save = *lineno_end; *path_end = *lineno_end = 0; if (test("f", path) && (fid = path2fid_readonly(path)) != NULL) fprintf(op, gen_href_begin(SRCS, fid, HTML, lineno)); else path = lineno = NULL; /* not to print </a> */ *path_end = path_save; *lineno_end = lineno_save; } else if (lineno) { int lineno_save = *lineno_end; *lineno_end = 0; fprintf(op, gen_href_begin(NULL, NULL, NULL, lineno)); *lineno_end = lineno_save; } fwrite(name, name_end - name, 1, op); if (path || lineno) fputs(gen_href_end(), op); /* * print the rest */ for (p = name_end; *p; p++) { if (*p == '<') fputs(quote_little, op); else if (*p == '>') fputs(quote_great, op); else fputc(*p, op); } fputc('/n', op); }finish: fputs_nl(verbatim_end, op); fputs_nl(body_end, op); fputs_nl(gen_page_end(), op); strbuf_close(input); fclose(ip); fclose(op); return status;}
开发者ID:fedragoneric,项目名称:global,代码行数:101,
示例23: closetoken/** * closetoken: */voidclosetoken(void){ strbuf_close(ib); fclose(ip);}
开发者ID:lshain,项目名称:enviroment,代码行数:9,
示例24: getconfs//.........这里部分代码省略......... * @param[out] result string buffer (if not NULL) * @return 1: found, 0: not found */intgetconfs(const char *name, STRBUF *result){ STRBUF *sb = NULL; const char *p; char buf[MAXPROPLEN]; int all = 0; int exist = 0; int bufsize; if (!opened) die("configuration file not opened."); /* 'path' is reserved name for the current path of configuration file */ if (!strcmp(name, "path")) { if (config_path && result) strbuf_puts(result, config_path); return 1; } sb = strbuf_open(0); if (!strcmp(name, "skip") || !strcmp(name, "gtags_parser") || !strcmp(name, "langmap")) all = 1; snprintf(buf, sizeof(buf), ":%s=", name); bufsize = strlen(buf); p = confline; while ((p = locatestring(p, buf, MATCH_FIRST)) != NULL) { if (exist && sb) strbuf_putc(sb, ','); exist = 1; for (p += bufsize; *p; p++) { if (*p == ':') break; if (*p == '//' && *(p + 1) == ':') /* quoted character */ p++; if (sb) strbuf_putc(sb, *p); } if (!all) break; } /* * If 'bindir' and 'datadir' are not defined then * return system configuration value. */ if (!exist) { if (!strcmp(name, "bindir")) { if (sb) strbuf_puts(sb, BINDIR); exist = 1; } else if (!strcmp(name, "datadir")) {#if defined(_WIN32) && !defined(__CYGWIN__) /* * Test if this directory exists, and if not, take the * directory relative to the binary. */ if (test("d", DATADIR)) { if (sb) strbuf_puts(sb, DATADIR); } else { char path[MAX_PATH], *name, *p; GetModuleFileName(NULL, path, MAX_PATH); for (p = name = path; *p; ++p) { if (*p == '//') { *p = '/'; name = p+1; } } strcpy(name, "../share"); if (sb) strbuf_puts(sb, path); }#else if (sb) strbuf_puts(sb, DATADIR);#endif exist = 1; } else if (!strcmp(name, "libdir")) { if (sb) strbuf_puts(sb, LIBDIR); exist = 1; } else if (!strcmp(name, "localstatedir")) { if (sb) strbuf_puts(sb, LOCALSTATEDIR); exist = 1; } else if (!strcmp(name, "sysconfdir")) { if (sb) strbuf_puts(sb, SYSCONFDIR); exist = 1; } } replace_variables(sb); if (result) strbuf_puts(result, !strcmp(name, "langmap") ? trim_langmap(strbuf_value(sb)) : strbuf_value(sb)); strbuf_close(sb); return exist;}
开发者ID:lucafavatella,项目名称:mirror-gnu-global,代码行数:101,
示例25: openconf/** * openconf: load configuration file. * * @param[in] rootdir Project root directory * * Globals used (output): * confline: specified entry */voidopenconf(const char *rootdir){ STRBUF *sb; if (opened) return; opened = 1; /* * if config file not found then return default value. */ if (!(config_path = configpath(rootdir))) confline = check_strdup(""); /* * if it is not an absolute path then assumed config value itself. */ else if (!isabspath(config_path)) { confline = check_strdup(config_path); if (!locatestring(confline, ":", MATCH_FIRST)) die("GTAGSCONF must be absolute path name."); } /* * else load value from config file. */ else { if (test("d", config_path)) die("config file '%s' is a directory.", config_path); if (!test("f", config_path)) die("config file '%s' not found.", config_path); if (!test("r", config_path)) die("config file '%s' is not readable.", config_path); if ((config_label = getenv("GTAGSLABEL")) == NULL) config_label = "default"; if (!(fp = fopen(config_path, "r"))) die("cannot open '%s'.", config_path); ib = strbuf_open(MAXBUFLEN); sb = strbuf_open(0); includelabel(fp, sb, config_label, 0); confline = check_strdup(strbuf_value(sb)); strbuf_close(ib); strbuf_close(sb); fclose(fp); } /* * make up required variables. */ sb = strbuf_open(0); strbuf_puts(sb, confline); strbuf_unputc(sb, ':'); if (!getconfs("langmap", NULL)) { strbuf_puts(sb, ":langmap="); strbuf_puts(sb, quote_chars(DEFAULTLANGMAP, ':')); } if (!getconfs("skip", NULL)) { strbuf_puts(sb, ":skip="); strbuf_puts(sb, DEFAULTSKIP); } strbuf_unputc(sb, ':'); strbuf_putc(sb, ':'); confline = check_strdup(strbuf_value(sb)); strbuf_close(sb); trim(confline); return;}
开发者ID:lucafavatella,项目名称:mirror-gnu-global,代码行数:74,
示例26: makecommonpart//.........这里部分代码省略......... break; case 't': if (call_file || callee_file) { strbuf_puts(sb, header_begin); if (call_file) { strbuf_puts(sb, gen_href_begin(NULL, "call", normal_suffix, NULL)); strbuf_puts(sb, title_call_tree); strbuf_puts(sb, gen_href_end()); } if (call_file && callee_file) strbuf_puts(sb, " / "); if (callee_file) { strbuf_puts(sb, gen_href_begin(NULL, "callee", normal_suffix, NULL)); strbuf_puts(sb, title_callee_tree); strbuf_puts(sb, gen_href_end()); } strbuf_puts_nl(sb, header_end); strbuf_puts_nl(sb, hr); } break; case 'm': strbuf_sprintf(sb, "%sMAINS%s/n", header_begin, header_end); snprintf(buf, sizeof(buf), PQUOTE "%s --result=ctags-xid --encode-path=/" /t/" --nofilter=path %s" PQUOTE, quote_shell(global_path), main_func); ip = popen(buf, "r"); if (!ip) die("cannot execute '%s'.", buf); strbuf_puts_nl(sb, gen_list_begin()); while ((_ = strbuf_fgets(ib, ip, STRBUF_NOCRLF)) != NULL) { char fid[MAXFIDLEN]; const char *ctags_x = parse_xid(_, fid, NULL); strbuf_puts_nl(sb, gen_list_body(SRCS, ctags_x, fid)); } strbuf_puts_nl(sb, gen_list_end()); if (pclose(ip) != 0) die("terminated abnormally '%s' (errno = %d).", buf, errno); strbuf_puts_nl(sb, hr); break; case 'd': if (aflag && !Fflag) { strbuf_puts(sb, header_begin); strbuf_puts(sb, title_define_index); strbuf_puts_nl(sb, header_end); strbuf_puts(sb, defines); } else { strbuf_puts(sb, header_begin); strbuf_puts(sb, gen_href_begin(NULL, "defines", normal_suffix, NULL)); strbuf_puts(sb, title_define_index); strbuf_puts(sb, gen_href_end()); strbuf_puts_nl(sb, header_end); } strbuf_puts_nl(sb, hr); break; case 'f': if (Fflag) { strbuf_puts(sb, header_begin); strbuf_puts(sb, gen_href_begin(NULL, "files", normal_suffix, NULL)); strbuf_puts(sb, title_file_index); strbuf_puts(sb, gen_href_end()); strbuf_puts_nl(sb, header_end); } else { strbuf_puts(sb, header_begin); strbuf_puts(sb, title_file_index); strbuf_puts_nl(sb, header_end); if (tree_view) { strbuf_puts_nl(sb, tree_control); strbuf_puts_nl(sb, tree_loading); if (tree_view_type) { strbuf_sprintf(sb, tree_begin_using, tree_view_type); strbuf_putc(sb, '/n'); } else { strbuf_puts_nl(sb, tree_begin); } } else if (table_flist) strbuf_puts_nl(sb, flist_begin); else if (!no_order_list) strbuf_puts_nl(sb, list_begin); strbuf_puts(sb, files); if (tree_view) strbuf_puts_nl(sb, tree_end); else if (table_flist) strbuf_puts_nl(sb, flist_end); else if (!no_order_list) strbuf_puts_nl(sb, list_end); else strbuf_puts_nl(sb, br); } strbuf_puts_nl(sb, hr); break; default: warning("unknown item '%c'. (Ignored)", *item); break; } } strbuf_close(ib); return strbuf_value(sb); /* doesn't close string buffer */}
开发者ID:lucafavatella,项目名称:mirror-gnu-global,代码行数:101,
示例27: main//.........这里部分代码省略......... if (!av) av = (argc > 0) ? *argv : NULL; if (debug) setdebug(); settabs(tabs); /* setup tab skip */ if (qflag) { setquiet(); vflag = 0; } if (show_version) version(av, vflag); if (show_help) help(); /* * Invokes gtags beforehand. */ if (gflag) { STRBUF *sb = strbuf_open(0); strbuf_puts(sb, gtags_path); if (vflag) strbuf_puts(sb, " -v"); if (wflag) strbuf_puts(sb, " -w"); if (suggest2 && enable_idutils && usable("mkid")) strbuf_puts(sb, " -I"); if (arg_dbpath[0]) { strbuf_putc(sb, ' '); strbuf_puts(sb, arg_dbpath); } if (system(strbuf_value(sb))) die("cannot execute gtags(1) command."); strbuf_close(sb); } /* * get dbpath. */ if (arg_dbpath[0]) { strlimcpy(dbpath, arg_dbpath, sizeof(dbpath)); } else { int status = setupdbpath(0); if (status < 0) die_with_code(-status, "%s", gtags_dbpath_error); strlimcpy(dbpath, get_dbpath(), sizeof(dbpath)); } if (!title) { char *p = strrchr(cwdpath, sep); title = p ? p + 1 : cwdpath; } if (cvsweb_url && test("d", "CVS")) use_cvs_module = 1; /* * decide directory in which we make hypertext. */ if (av) { char realpath[MAXPATHLEN]; if (!test("dw", av)) die("'%s' is not writable directory.", av); if (chdir(av) < 0) die("directory '%s' not found.", av); if (!vgetcwd(realpath, sizeof(realpath))) die("cannot get current directory"); if (chdir(cwdpath) < 0) die("cannot return to original directory.");
开发者ID:lucafavatella,项目名称:mirror-gnu-global,代码行数:67,
示例28: C_family//.........这里部分代码省略......... case SHARP_IFDEF: case SHARP_IFNDEF: case SHARP_IF: case SHARP_ELIF: case SHARP_ELSE: case SHARP_ENDIF: condition_macro(param, c); continue; default: break; } if (c == ';' && level == typedef_savelevel) { if (savetok[0]) PUT(PARSER_DEF, savetok, savelineno, sp); break; } else if (c == '{') level++; else if (c == '}') { if (--level == typedef_savelevel) break; } else if (c == SYMBOL) { PUT(PARSER_REF_SYM, token, lineno, sp); /* save lastest token */ strlimcpy(savetok, token, sizeof(savetok)); savelineno = lineno; } } if (c == ';') break; } if ((param->flags & PARSER_WARNING) && c == EOF) { warning("unexpected eof. [+%d %s]", lineno, curfile); break; } } else if (c == SYMBOL) { PUT(PARSER_REF_SYM, token, lineno, sp); } savetok[0] = 0; while ((c = nexttoken("(),;", c_reserved_word)) != EOF) { switch (c) { case SHARP_IFDEF: case SHARP_IFNDEF: case SHARP_IF: case SHARP_ELIF: case SHARP_ELSE: case SHARP_ENDIF: condition_macro(param, c); continue; default: break; } if (c == '(') level++; else if (c == ')') level--; else if (c == SYMBOL) { if (level > typedef_savelevel) { PUT(PARSER_REF_SYM, token, lineno, sp); } else { /* put latest token if any */ if (savetok[0]) { PUT(PARSER_REF_SYM, savetok, savelineno, sp); } /* save lastest token */ strlimcpy(savetok, token, sizeof(savetok)); savelineno = lineno; } } else if (c == ',' || c == ';') { if (savetok[0]) { PUT(PARSER_DEF, savetok, lineno, sp); savetok[0] = 0; } } if (level == typedef_savelevel && c == ';') break; } if (param->flags & PARSER_WARNING) { if (c == EOF) warning("unexpected eof. [+%d %s]", lineno, curfile); else if (level != typedef_savelevel) warning("unmatched () block. (last at level %d.)[+%d %s]", level, lineno, curfile); } } break; case C___ATTRIBUTE__: process_attribute(param); break; default: break; } } strbuf_close(sb); if (param->flags & PARSER_WARNING) { if (level != 0) warning("unmatched {} block. (last at level %d.)[+%d %s]", level, lineno, curfile); if (piflevel != 0) warning("unmatched #if block. (last at level %d.)[+%d %s]", piflevel, lineno, curfile); } closetoken();}
开发者ID:aYosukeAkatsuka,项目名称:global-6.4,代码行数:101,
示例29: makedefineindex//.........这里部分代码省略......... * generating url for function definition. */ line = cache_get(GTAGS, tag); strbuf_reset(url); if (line == NULL) die("internal error in makedefineindex()."); /* * About the format of 'line', please see the head comment of cache.c. */ if (*line == ' ') { const char *fid = line + 1; const char *enumber = nextstring(fid); snprintf(url_for_map, sizeof(url_for_map), "%s/%s.%s", DEFS, fid, HTML); if (dynamic) { if (*action != '/' && aflag) strbuf_puts(url, "../"); strbuf_puts(url, action); strbuf_sprintf(url, "?pattern=%s%stype=definitions", tag, quote_amp); } else { if (aflag) strbuf_puts(url, "../"); strbuf_sprintf(url, "%s/%s.%s", DEFS, fid, HTML); } snprintf(guide, sizeof(guide), "Multiple defined in %s places.", enumber); } else { const char *lno = line; const char *fid = nextstring(line); const char *path = gpath_fid2path(fid, NULL); path += 2; /* remove './' */ snprintf(url_for_map, sizeof(url_for_map), "%s/%s.%s#L%s", SRCS, fid, HTML, lno); if (aflag) strbuf_puts(url, "../"); strbuf_sprintf(url, "%s/%s.%s#L%s", SRCS, fid, HTML, lno); snprintf(guide, sizeof(guide), "Defined at %s in %s.", lno, path); } if (!no_order_list) fputs(item_begin, STDOUT); fputs(gen_href_begin_with_title_target(NULL, strbuf_value(url), NULL, NULL, guide, target), STDOUT); fputs(tag, STDOUT); fputs(gen_href_end(), STDOUT); if (!no_order_list) fputs(item_end, STDOUT); else fputs(br, STDOUT); fputc('/n', STDOUT); if (map_file) fprintf(MAP, "%s/t%s/n", tag, url_for_map); } if (pclose(TAGS) != 0) die("terminated abnormally '%s' (errno = %d).", command, errno); if (aflag && alpha[0]) { char tmp[128]; const char *msg = (alpha_count == 1) ? "definition" : "definitions"; snprintf(tmp, sizeof(tmp), "%d %s", alpha_count, msg); strbuf_puts(defines, gen_href_begin_with_title("defines", alpha_f, HTML, NULL, tmp)); strbuf_sprintf(defines, "[%s]", alpha); strbuf_puts_nl(defines, gen_href_end()); if (!no_order_list) fputs_nl(list_end, ALPHA); else fputs_nl(br, ALPHA); fputs(gen_href_begin_with_title(NULL, indexlink, normal_suffix, NULL, index_string), ALPHA); if (Iflag) fputs(gen_image(PARENT, back_icon, ".."), ALPHA); else fputs("[..]", ALPHA); fputs_nl(gen_href_end(), ALPHA); fputs_nl(body_end, ALPHA); fputs_nl(gen_page_end(), ALPHA); close_file(fileop_ALPHA); html_count++; fputs(strbuf_value(defines), DEFINES); } if (!no_order_list && !aflag) fputs_nl(list_end, DEFINES); if (!aflag && !Fflag) { fputs(gen_href_begin_with_title(NULL, "mains", normal_suffix, NULL, index_string), DEFINES); if (Iflag) fputs(gen_image(CURRENT, back_icon, ".."), DEFINES); else fputs("[..]", DEFINES); fputs_nl(gen_href_end(), DEFINES); } fputs_nl(body_end, DEFINES); fputs_nl(gen_page_end(), DEFINES); close_file(fileop_DEFINES); html_count++; if (map_file) close_file(fileop_MAP); strbuf_close(sb); strbuf_close(url); return count;}
开发者ID:GimXu,项目名称:global,代码行数:101,
示例30: save_environment/** * save_environment: save configuration data and arguments. */static voidsave_environment(int argc, char *const *argv){ char command[MAXFILLEN]; STRBUF *sb = strbuf_open(0); STRBUF *save_c = strbuf_open(0); STRBUF *save_a = strbuf_open(0); int i; const char *p; FILE *ip; /* * save config values. */ snprintf(command, sizeof(command), PQUOTE "%s --config" PQUOTE, quote_shell(gtags_path)); if ((ip = popen(command, "r")) == NULL) die("cannot execute '%s'.", command); while (strbuf_fgets(sb, ip, STRBUF_NOCRLF) != NULL) { for (p = strbuf_value(sb); *p; p++) { if (*p == '/'') { strbuf_putc(save_c, '/''); strbuf_putc(save_c, '"'); strbuf_putc(save_c, '/''); strbuf_putc(save_c, '"'); strbuf_putc(save_c, '/''); } else strbuf_putc(save_c, *p); } } if (pclose(ip) != 0) die("terminated abnormally '%s' (errno = %d).", command, errno); strbuf_close(sb); save_config = strbuf_value(save_c); /* doesn't close string buffer for save config. */ /* strbuf_close(save_c); */ /* * save arguments. */ { char *opt_gtagsconf = "--gtagsconf"; for (i = 1; i < argc; i++) { char *blank; /* * skip --gtagsconf because it is already read * as config value. */ if ((p = locatestring(argv[i], opt_gtagsconf, MATCH_AT_FIRST))) { if (*p == '/0') i++; continue; } blank = locatestring(argv[i], " ", MATCH_FIRST); strbuf_putc(save_a, ' '); if (blank) strbuf_putc(save_a, '/''); strbuf_puts(save_a, argv[i]); if (blank) strbuf_putc(save_a, '/''); } } save_argv = strbuf_value(save_a); /* doesn't close string buffer for save arguments. */ /* strbuf_close(save_a); */}
开发者ID:lucafavatella,项目名称:mirror-gnu-global,代码行数:70,
注:本文中的strbuf_close函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ strbuf_detach函数代码示例 C++ strbuf_clear函数代码示例 |