for (viewer = man_viewer_info_list; viewer; viewer = viewer->next) { if (!strcasecmp(name, viewer->name)) return viewer->info;
} return NULL;
}
staticint check_emacsclient_version(void)
{ struct strbuf buffer = STRBUF_INIT; struct child_process ec_process; constchar *argv_ec[] = { "emacsclient", "--version", NULL }; int version; int ret = -1;
/* emacsclient prints its version number on stderr */
memset(&ec_process, 0, sizeof(ec_process));
ec_process.argv = argv_ec;
ec_process.err = -1;
ec_process.stdout_to_stderr = 1; if (start_command(&ec_process)) {
fprintf(stderr, "Failed to start emacsclient.\n"); return -1;
} if (strbuf_read(&buffer, ec_process.err, 20) < 0) {
fprintf(stderr, "Failed to read emacsclient version\n"); goto out;
}
close(ec_process.err);
/* * Don't bother checking return value, because "emacsclient --version" * seems to always exits with code 1.
*/
finish_command(&ec_process);
if (!strstarts(buffer.buf, "emacsclient")) {
fprintf(stderr, "Failed to parse emacsclient version.\n"); goto out;
}
version = atoi(buffer.buf + strlen("emacsclient"));
if (version < 22) {
fprintf(stderr, "emacsclient version '%d' too old (< 22).\n",
version);
} else
ret = 0;
out:
strbuf_release(&buffer); return ret;
}
staticvoid exec_woman_emacs(constchar *path, constchar *page)
{ if (!check_emacsclient_version()) { /* This works only with emacsclient version >= 22. */ char *man_page;
if (!strcmp(var, "help.format")) { if (!value) return config_error_nonbool(var);
*help_formatp = parse_help_format(value); if (*help_formatp == HELP_FORMAT_NONE) return -1; return 0;
} if (!strcmp(var, "man.viewer")) { if (!value) return config_error_nonbool(var);
add_man_viewer(value); return 0;
} if (strstarts(var, "man.")) return add_man_viewer_info(var, value);
return 0;
}
staticstruct cmdnames main_cmds, other_cmds;
void list_common_cmds_help(void)
{ unsignedint i, longest = 0;
for (i = 0; i < ARRAY_SIZE(common_cmds); i++) { if (longest < strlen(common_cmds[i].name))
longest = strlen(common_cmds[i].name);
}
puts(" The most commonly used perf commands are:"); for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
printf(" %-*s ", longest, common_cmds[i].name);
puts(common_cmds[i].help);
}
}
/* We should always put ':' after our path. If there is no * old_path, the ':' at the end will let 'man' to try * system-wide paths after ours to find the manual page. If
* there is old_path, we need ':' as delimiter. */ if (asprintf(&new_path, "%s:%s", system_path(PERF_MAN_PATH), old_path ?: "") > 0) {
setenv("MANPATH", new_path, 1);
free(new_path);
} else {
pr_err("Unable to setup man path");
}
}
/* Check that we have a perf documentation directory. */ if (stat(mkpath(path, sizeof(path), "%s/perf.html", html_path), &st)
|| !S_ISREG(st.st_mode)) {
pr_err("'%s': not a documentation directory.", html_path); return -1;
}
/* * If open_html is not defined in a platform-specific way (see for * example compat/mingw.h), we use the script web--browse to display * HTML.
*/ #ifndef open_html staticvoid open_html(constchar *path)
{
execl_cmd("web--browse", "-c", "help.browser", path, NULL);
} #endif
staticint show_html_page(constchar *perf_cmd)
{ constchar *page = cmd_to_page(perf_cmd); char *page_path; /* it leaks but we exec below */
if (get_html_page_path(&page_path, page) < 0) return -1;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.