summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8fbf675)
raw | patch | inline | side by side (parent: 8fbf675)
author | Jonas Fonseca <fonseca@diku.dk> | |
Thu, 9 Oct 2008 12:05:55 +0000 (14:05 +0200) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Thu, 9 Oct 2008 12:05:55 +0000 (14:05 +0200) |
tig.c | patch | blob | history |
index 6a1d5c9b26281f5545f0ff0fc53426ab213c389c..f9562edf3795122e87bc989df47d51d9c0d91354 100644 (file)
--- a/tig.c
+++ b/tig.c
unsigned int next:1; /* For ref lists: are there more refs? */
};
-static struct ref **get_refs(char *id);
+static struct ref **get_refs(const char *id);
struct int_map {
const char *name;
struct request_info {
enum request request;
- char *name;
+ const char *name;
int namelen;
- char *help;
+ const char *help;
};
static struct request_info req_info[] = {
static char opt_editor[SIZEOF_STR] = "";
static enum request
-parse_options(int argc, char *argv[])
+parse_options(int argc, const char *argv[])
{
enum request request = REQ_VIEW_MAIN;
size_t buf_size;
- char *subcommand;
+ const char *subcommand;
bool seen_dashdash = FALSE;
int i;
buf_size = strlen(opt_cmd);
for (i = 1 + !!subcommand; i < argc; i++) {
- char *opt = argv[i];
+ const char *opt = argv[i];
if (seen_dashdash || !strcmp(opt, "--")) {
seen_dashdash = TRUE;
struct key {
- char *name;
+ const char *name;
int value;
};
return ERR;
}
-static char *
+static const char *
get_key_name(int key_value)
{
static char key_char[] = "'X'";
- char *seq = NULL;
+ const char *seq = NULL;
int key;
for (key = 0; key < ARRAY_SIZE(key_table); key++)
return seq ? seq : "(no key)";
}
-static char *
+static const char *
get_key(enum request request)
{
static char buf[BUFSIZ];
static int config_lineno;
static bool config_errors;
-static char *config_msg;
+static const char *config_msg;
/* Wants: object fgcolor bgcolor [attr] */
static int
}
static int
-set_option(char *opt, char *value)
+set_option(const char *opt, char *value)
{
const char *argv[SIZEOF_ARG];
int valuelen;
static int
load_options(void)
{
- char *home = getenv("HOME");
- char *tigrc_user = getenv("TIGRC_USER");
- char *tigrc_system = getenv("TIGRC_SYSTEM");
+ const char *home = getenv("HOME");
+ const char *tigrc_user = getenv("TIGRC_USER");
+ const char *tigrc_system = getenv("TIGRC_SYSTEM");
char buf[SIZEOF_STR];
add_builtin_run_requests();
@@ -1639,7 +1639,7 @@ draw_graphic(struct view *view, enum line_type type, chtype graphic[], size_t si
}
static bool
-draw_field(struct view *view, enum line_type type, char *text, int len, bool trim)
+draw_field(struct view *view, enum line_type type, const char *text, int len, bool trim)
{
int max = MIN(view->width - view->col, len);
int col;
}
static struct line *
-add_line_text(struct view *view, char *data, enum line_type type)
+add_line_text(struct view *view, const char *text, enum line_type type)
{
- if (data)
- data = strdup(data);
+ char *data = text ? strdup(text) : NULL;
return data ? add_line_data(view, data, type) : NULL;
}
{
char cmd[SIZEOF_STR];
char file_sq[SIZEOF_STR];
- char *editor;
+ const char *editor;
char *prefix = from_root ? opt_cdup : "";
editor = getenv("GIT_EDITOR");
}
static bool
-add_describe_ref(char *buf, size_t *bufpos, char *commit_id, const char *sep)
+add_describe_ref(char *buf, size_t *bufpos, const char *commit_id, const char *sep)
{
char refbuf[SIZEOF_STR];
char *ref = NULL;
do {
struct ref *ref = refs[refpos];
- char *fmt = ref->tag ? "%s[%s]" :
- ref->remote ? "%s<%s>" : "%s%s";
+ const char *fmt = ref->tag ? "%s[%s]" :
+ ref->remote ? "%s<%s>" : "%s%s";
if (!string_format_from(buf, &bufpos, fmt, sep, ref->name))
return;
add_line_text(view, "Quick reference for tig keybindings:", LINE_DEFAULT);
for (i = 0; i < ARRAY_SIZE(req_info); i++) {
- char *key;
+ const char *key;
if (req_info[i].request == REQ_NONE)
continue;
for (i = 0; i < run_requests; i++) {
struct run_request *req = get_run_request(REQ_NONE + i + 1);
- char *key;
+ const char *key;
if (!req)
continue;
}
static void
-push_tree_stack_entry(char *name, unsigned long lineno)
+push_tree_stack_entry(const char *name, unsigned long lineno)
{
struct tree_stack_entry *entry = calloc(1, sizeof(*entry));
size_t pathlen = strlen(opt_path);
#define TREE_UP_FORMAT "040000 tree %s\t.."
static int
-tree_compare_entry(enum line_type type1, char *name1,
- enum line_type type2, char *name2)
+tree_compare_entry(enum line_type type1, const char *name1,
+ enum line_type type2, const char *name2)
{
if (type1 != type2) {
if (type1 == LINE_TREE_DIR)
return strcmp(name1, name2);
}
-static char *
+static const char *
tree_path(struct line *line)
{
- char *path = line->data;
+ const char *path = line->data;
return path + SIZEOF_TREE_ATTR;
}
/* Skip "Directory ..." and ".." line. */
for (pos = 1 + !!*opt_path; pos < view->lines; pos++) {
struct line *line = &view->line[pos];
- char *path1 = tree_path(line);
+ const char *path1 = tree_path(line);
char *path2 = text + SIZEOF_TREE_ATTR;
int cmp = tree_compare_entry(line->type, path1, type, path2);
enum open_flags flags;
if (request == REQ_VIEW_BLAME) {
- char *filename = tree_path(line);
+ const char *filename = tree_path(line);
if (line->type == LINE_TREE_DIR) {
report("Cannot show blame for directory %s", opt_path);
pop_tree_stack_entry();
} else {
- char *basename = tree_path(line);
+ const char *basename = tree_path(line);
push_tree_stack_entry(basename, view->lineno);
}
}
static bool
-parse_number(char **posref, size_t *number, size_t min, size_t max)
+parse_number(const char **posref, size_t *number, size_t min, size_t max)
{
- char *pos = *posref;
+ const char *pos = *posref;
*posref = NULL;
pos = strchr(pos + 1, ' ');
}
static struct blame_commit *
-parse_blame_commit(struct view *view, char *text, int *blamed)
+parse_blame_commit(struct view *view, const char *text, int *blamed)
{
struct blame_commit *commit;
struct blame *blame;
- char *pos = text + SIZEOF_REV - 1;
+ const char *pos = text + SIZEOF_REV - 1;
size_t lineno;
size_t group;
}
static bool
-blame_read_file(struct view *view, char *line)
+blame_read_file(struct view *view, const char *line)
{
if (!line) {
FILE *pipe = NULL;
{
struct blame *blame = line->data;
struct tm *time = NULL;
- char *id = NULL, *author = NULL;
+ const char *id = NULL, *author = NULL;
if (blame->commit && *blame->commit->filename) {
id = blame->commit->id;
* :100644 100644 06a5d6ae9eca55be2e0e585a152e6b1336f2b20e 0000000000000000000000000000000000000000 M
*/
static inline bool
-status_get_diff(struct status *file, char *buf, size_t bufsize)
+status_get_diff(struct status *file, const char *buf, size_t bufsize)
{
- char *old_mode = buf + 1;
- char *new_mode = buf + 8;
- char *old_rev = buf + 15;
- char *new_rev = buf + 56;
- char *status = buf + 97;
+ const char *old_mode = buf + 1;
+ const char *new_mode = buf + 8;
+ const char *old_rev = buf + 15;
+ const char *new_rev = buf + 56;
+ const char *status = buf + 97;
if (bufsize < 99 ||
old_mode[-1] != ':' ||
{
struct status *status = line->data;
enum line_type type;
- char *text;
+ const char *text;
if (!status) {
switch (line->type) {
struct status *status = line->data;
char oldpath[SIZEOF_STR] = "";
char newpath[SIZEOF_STR] = "";
- char *info;
+ const char *info;
size_t cmdsize = 0;
enum open_flags split;
{
struct status *status = line->data;
char file[SIZEOF_STR] = "all files";
- char *text;
- char *key;
+ const char *text;
+ const char *key;
if (status && !string_format(file, "'%s'", status->new.name))
return;
return FALSE;
for (state = S_STATUS; state < S_END; state++) {
- char *text;
+ const char *text;
switch (state) {
case S_NAME: text = status->new.name; break;
static bool
stage_diff_line(FILE *pipe, struct line *line)
{
- char *buf = line->data;
+ const char *buf = line->data;
size_t bufsize = strlen(buf);
size_t written = 0;
}
static void
-push_rev_graph(struct rev_graph *graph, char *parent)
+push_rev_graph(struct rev_graph *graph, const char *parent)
{
int i;
}
static struct ref **
-get_refs(char *id)
+get_refs(const char *id)
{
struct ref ***tmp_id_refs;
struct ref **ref_list = NULL;
}
int
-main(int argc, char *argv[])
+main(int argc, const char *argv[])
{
struct view *view;
enum request request;
case REQ_SEARCH:
case REQ_SEARCH_BACK:
{
- const char *prompt = request == REQ_SEARCH
- ? "/" : "?";
+ const char *prompt = request == REQ_SEARCH ? "/" : "?";
char *search = read_prompt(prompt);
if (search)