void editall(void) { char file[PATHLEN + 1]; /* file name */ char linenum[NUMLEN + 1]; /* line number */ int c; /* verify that there is a references found file */ if (refsfound == NULL) { return; } /* get the first line */ seekline(1); /* get each file name and line number */ while (fscanf(refsfound, "%" PATHLEN_STR "s%*s%" NUMLEN_STR "s%*[^\n]", file, linenum) == 2) { edit(decode_path(file), linenum); /* edit it */ if (editallprompt == YES) { addstr("Type ^D to stop editing all lines, or any other character to continue: "); if ((c = mygetch()) == EOF || c == ctrl('D') || c == ctrl('Z')) { break; } } } seekline(topline); }
/* * 2.2.6. readlinkres * * union readlinkres switch (stat status) { * case NFS_OK: * path data; * default: * void; * }; */ static int nfs2_xdr_dec_readlinkres(struct rpc_rqst *req, struct xdr_stream *xdr, void *__unused) { enum nfs_stat status; int error; error = decode_stat(xdr, &status); if (unlikely(error)) goto out; if (status != NFS_OK) goto out_default; error = decode_path(xdr); out: return error; out_default: return nfs_stat_to_errno(status); }
void editref(int i) { char file[PATHLEN + 1]; /* file name */ char linenum[NUMLEN + 1]; /* line number */ /* verify that there is a references found file */ if (refsfound == NULL) { return; } /* get the selected line */ seekline(i + topline); /* get the file name and line number */ if (fscanf(refsfound, "%" PATHLEN_STR "s%*s%" NUMLEN_STR "s", file, linenum) == 2) { edit(decode_path(file), linenum); /* edit it */ } seekline(topline); /* restore the line pointer */ }
/** * Generate list body. * * @NAME{ctags_x} with the @CODE{--encode-path=\" \\t\"} */ const char * gen_list_body(const char *srcdir, const char *ctags_x, const char *fid) /* virtually const */ { STATIC_STRBUF(sb); char path[MAXPATHLEN]; const char *p; SPLIT ptable; strbuf_clear(sb); if (split((char *)ctags_x, 4, &ptable) < 4) { recover(&ptable); die("too small number of parts in list_body().\n'%s'", ctags_x); } strlimcpy(path, decode_path(ptable.part[PART_PATH].start + 2), sizeof(path)); if (fid == NULL) fid = path2fid(path); if (table_list) { strbuf_puts(sb, current_row_begin); if (enable_xhtml) { strbuf_puts(sb, "<td class='tag'>"); strbuf_puts(sb, gen_href_begin(srcdir, fid, HTML, ptable.part[PART_LNO].start)); strbuf_puts(sb, ptable.part[PART_TAG].start); strbuf_puts(sb, gen_href_end()); strbuf_sprintf(sb, "</td><td class='line'>%s</td><td class='file'>%s</td><td class='code'>", ptable.part[PART_LNO].start, path); } else { strbuf_puts(sb, "<td nowrap='nowrap'>"); strbuf_puts(sb, gen_href_begin(srcdir, fid, HTML, ptable.part[PART_LNO].start)); strbuf_puts(sb, ptable.part[PART_TAG].start); strbuf_puts(sb, gen_href_end()); strbuf_sprintf(sb, "</td><td nowrap='nowrap' align='right'>%s</td>" "<td nowrap='nowrap' align='left'>%s</td><td nowrap='nowrap'>", ptable.part[PART_LNO].start, path); } for (p = ptable.part[PART_LINE].start; *p; p++) { unsigned char c = *p; if (c == '&') strbuf_puts(sb, quote_amp); else if (c == '<') strbuf_puts(sb, quote_little); else if (c == '>') strbuf_puts(sb, quote_great); else if (c == ' ') strbuf_puts(sb, quote_space); else if (c == '\t') { strbuf_puts(sb, quote_space); strbuf_puts(sb, quote_space); } else strbuf_putc(sb, c); } strbuf_puts(sb, "</td>"); strbuf_puts(sb, current_row_end); recover(&ptable); } else { /* print tag name with anchor */ strbuf_puts(sb, current_line_begin); strbuf_puts(sb, gen_href_begin(srcdir, fid, HTML, ptable.part[PART_LNO].start)); strbuf_puts(sb, ptable.part[PART_TAG].start); strbuf_puts(sb, gen_href_end()); recover(&ptable); /* print line number */ for (p = ptable.part[PART_TAG].end; p < ptable.part[PART_PATH].start; p++) strbuf_putc(sb, *p); /* print file name */ strbuf_puts(sb, path); /* print the rest */ for (p = ptable.part[PART_PATH].end; *p; p++) { unsigned char c = *p; if (c == '&') strbuf_puts(sb, quote_amp); else if (c == '<') strbuf_puts(sb, quote_little); else if (c == '>') strbuf_puts(sb, quote_great); else strbuf_putc(sb, c); } strbuf_puts(sb, current_line_end); } return strbuf_value(sb); }
/* * convert_put: convert path into relative or absolute and print. * * i) cv CONVERT structure * i) ctags_x tag record (ctags-x format) * * Note: This function is only called by gtags with the --path option. */ void convert_put(CONVERT *cv, const char *ctags_x) { char *tagnextp = NULL; int tagnextc = 0; char *tag = NULL, *lineno = NULL, *path, *rest = NULL; const char *fid = NULL; if (cv->format == FORMAT_PATH) die("convert_put: internal error."); /* Use convert_put_path() */ /* * parse tag line. * Don't use split() function not to destroy line image. */ { char *p = (char *)ctags_x; /* * tag name */ tag = p; for (; *p && !isspace(*p); p++) ; if (*p == '\0') die("illegal ctags-x format (line number not found)."); tagnextp = p; tagnextc = *p; *p++ = '\0'; /* skip blanks */ for (; *p && isspace(*p); p++) ; if (*p == '\0') die("illegal ctags-x format (line number not found)."); /* * line number */ lineno = p; for (; *p && !isspace(*p); p++) ; if (*p == '\0') die("illegal ctags-x format (path name not found)."); *p++ = '\0'; /* skip blanks */ for (; *p && isspace(*p); p++) ; if (*p == '\0') die("illegal ctags-x format (path name not found)."); /* * path name */ path = p; for (; *p && !isspace(*p); p++) ; if (*p == '\0') die("illegal ctags-x format (line image not found)."); *p++ = '\0'; rest = p; } /* * The path name has already been encoded. */ path = decode_path((unsigned char *)path); switch (cv->format) { case FORMAT_CTAGS: fputs(tag, cv->op); fputc('\t', cv->op); fputs(convert_pathname(cv, path), cv->op); fputc('\t', cv->op); fputs(lineno, cv->op); break; case FORMAT_CTAGS_XID: fid = gpath_path2fid(path, NULL); if (fid == NULL) die("convert_put: unknown file. '%s'", path); fputs(fid, cv->op); fputc(' ', cv->op); /* PASS THROUGH */ case FORMAT_CTAGS_X: /* * print until path name. */ *tagnextp = tagnextc; fputs(ctags_x, cv->op); fputc(' ', cv->op); /* * print path name and the rest. */ fputs(convert_pathname(cv, path), cv->op); fputc(' ', cv->op); fputs(rest, cv->op); break; case FORMAT_GREP: fputs(convert_pathname(cv, path), cv->op); fputc(':', cv->op); fputs(lineno, cv->op); fputc(':', cv->op); fputs(rest, cv->op); break; case FORMAT_CSCOPE: fputs(convert_pathname(cv, path), cv->op); fputc(' ', cv->op); fputs(tag, cv->op); fputc(' ', cv->op); fputs(lineno, cv->op); fputc(' ', cv->op); for (; *rest && isspace(*rest); rest++) ; fputs(rest, cv->op); break; default: die("unknown format type."); } (void)fputc(newline, cv->op); }
/*----------------------------------------------------------------------*/ void makeincludeindex(void) { FILE *PIPE; STRBUF *input = strbuf_open(0); char *ctags_x; struct data *inc; char *target = (Fflag) ? "mains" : "_top"; char command[MAXFILLEN]; /* * Pick up include pattern. * * C: #include "xxx.h" * PHP: include("xxx.inc.php"); */ /* * Unlike Perl regular expression, POSIX regular expression doesn't support C-style escape sequence. * Therefore, we can not use "\\t" here. */ snprintf(command, sizeof(command), PQUOTE "%s -gnx --encode-path=\" \t\" \"^[ \t]*(#[ \t]*(import|include)|include[ \t]*\\()\"" PQUOTE, quote_shell(global_path)); if ((PIPE = popen(command, "r")) == NULL) die("cannot execute '%s'.", command); strbuf_reset(input); while ((ctags_x = strbuf_fgets(input, PIPE, STRBUF_NOCRLF)) != NULL) { SPLIT ptable; char buf[MAXBUFLEN]; int is_php = 0; const char *last, *lang, *suffix; if (split(ctags_x, 4, &ptable) < 4) { recover(&ptable); die("too small number of parts in makefileindex()."); } if ((suffix = locatestring(ptable.part[PART_PATH].start, ".", MATCH_LAST)) != NULL && (lang = decide_lang(suffix)) != NULL && strcmp(lang, "php") == 0) is_php = 1; last = extract_lastname(ptable.part[PART_LINE].start, is_php); if (last == NULL || (inc = get_inc(last)) == NULL) continue; recover(&ptable); /* * s/^[^ \t]+/$last/; */ { const char *p; char *q = buf; for (p = last; *p; p++) *q++ = *p; for (p = ctags_x; *p && *p != ' ' && *p != '\t'; p++) ; for (; *p; p++) *q++ = *p; *q = '\0'; } put_included(inc, buf); } if (pclose(PIPE) != 0) die("terminated abnormally '%s' (errno = %d).", command, errno); for (inc = first_inc(); inc; inc = next_inc()) { const char *last = inc->name; int no = inc->id; FILEOP *fileop_INCLUDE; FILE *INCLUDE; if (inc->count > 1) { char path[MAXPATHLEN]; snprintf(path, sizeof(path), "%s/%s/%d.%s", distpath, INCS, no, HTML); fileop_INCLUDE = open_output_file(path, 0); INCLUDE = get_descripter(fileop_INCLUDE); fputs_nl(gen_page_begin(last, SUBDIR), INCLUDE); fputs_nl(body_begin, INCLUDE); fputs_nl(verbatim_begin, INCLUDE); { const char *filename = strbuf_value(inc->contents); int count = inc->count; for (; count; filename += strlen(filename) + 1, count--) { fputs(gen_href_begin_with_title_target(upperdir(SRCS), path2fid(filename), HTML, NULL, NULL, target), INCLUDE); fputs(removedotslash(filename), INCLUDE); fputs_nl(gen_href_end(), INCLUDE); } } fputs_nl(verbatim_end, INCLUDE); fputs_nl(body_end, INCLUDE); fputs_nl(gen_page_end(), INCLUDE); close_file(fileop_INCLUDE); html_count++; /* * inc->contents == NULL means that information already * written to file. */ strbuf_close(inc->contents); inc->contents = NULL; } if (!inc->ref_count) continue; if (inc->ref_count == 1) { SPLIT ptable; char buf[1024]; if (split(strbuf_value(inc->ref_contents), 4, &ptable) < 4) { recover(&ptable); die("too small number of parts in makefileindex()."); } snprintf(buf, sizeof(buf), "%s %s", ptable.part[PART_LNO].start, decode_path(ptable.part[PART_PATH].start)); recover(&ptable); strbuf_reset(inc->ref_contents); strbuf_puts(inc->ref_contents, buf); } else { char path[MAXPATHLEN]; snprintf(path, sizeof(path), "%s/%s/%d.%s", distpath, INCREFS, no, HTML); fileop_INCLUDE = open_output_file(path, 0); INCLUDE = get_descripter(fileop_INCLUDE); fputs_nl(gen_page_begin(last, SUBDIR), INCLUDE); fputs_nl(body_begin, INCLUDE); fputs_nl(gen_list_begin(), INCLUDE); { const char *line = strbuf_value(inc->ref_contents); int count = inc->ref_count; for (; count; line += strlen(line) + 1, count--) fputs_nl(gen_list_body(upperdir(SRCS), line, NULL), INCLUDE); } fputs_nl(gen_list_end(), INCLUDE); fputs_nl(body_end, INCLUDE); fputs_nl(gen_page_end(), INCLUDE); close_file(fileop_INCLUDE); html_count++; /* * inc->ref_contents == NULL means that information already * written to file. */ strbuf_close(inc->ref_contents); inc->ref_contents = NULL; } } strbuf_close(input); }