Fix several whitespace errors * Remove whitespace at the end of lines. * Replace space indentation by tabs. * Add whitespace before/after several operators ("+", "-", "*", ...) * Add whitespace to assignments ("foo = bar;"). * Fix whitespace in parameter lists ("foobar(foo, bar, 42)"). Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
@@ -105,7 +105,7 @@ {
if (slot->ttl < 0) return 0; else - return slot->cache_st.st_mtime + slot->ttl*60 < time(NULL); + return slot->cache_st.st_mtime + slot->ttl * 60 < time(NULL); } /* Check if the slot has been modified since we opened it.@@ -141,8 +141,8 @@ * Returns 0 on success and errno otherwise.
*/ static int lock_slot(struct cache_slot *slot) { - slot->lock_fd = open(slot->lock_name, O_RDWR|O_CREAT|O_EXCL, - S_IRUSR|S_IWUSR); + slot->lock_fd = open(slot->lock_name, O_RDWR | O_CREAT | O_EXCL, + S_IRUSR | S_IWUSR); if (slot->lock_fd == -1) return errno; if (xwrite(slot->lock_fd, slot->key, slot->keylen + 1) < 0)
@@ -741,7 +741,7 @@ int scan = 0;
for (i = 1; i < argc; i++) { if (!strncmp(argv[i], "--cache=", 8)) { - ctx.cfg.cache_root = xstrdup(argv[i]+8); + ctx.cfg.cache_root = xstrdup(argv[i] + 8); } if (!strcmp(argv[i], "--nocache")) { ctx.cfg.nocache = 1;@@ -750,24 +750,24 @@ if (!strcmp(argv[i], "--nohttp")) {
ctx.env.no_http = "1"; } if (!strncmp(argv[i], "--query=", 8)) { - ctx.qry.raw = xstrdup(argv[i]+8); + ctx.qry.raw = xstrdup(argv[i] + 8); } if (!strncmp(argv[i], "--repo=", 7)) { - ctx.qry.repo = xstrdup(argv[i]+7); + ctx.qry.repo = xstrdup(argv[i] + 7); } if (!strncmp(argv[i], "--page=", 7)) { - ctx.qry.page = xstrdup(argv[i]+7); + ctx.qry.page = xstrdup(argv[i] + 7); } if (!strncmp(argv[i], "--head=", 7)) { - ctx.qry.head = xstrdup(argv[i]+7); + ctx.qry.head = xstrdup(argv[i] + 7); ctx.qry.has_symref = 1; } if (!strncmp(argv[i], "--sha1=", 7)) { - ctx.qry.sha1 = xstrdup(argv[i]+7); + ctx.qry.sha1 = xstrdup(argv[i] + 7); ctx.qry.has_sha1 = 1; } if (!strncmp(argv[i], "--ofs=", 6)) { - ctx.qry.ofs = atoi(argv[i]+6); + ctx.qry.ofs = atoi(argv[i] + 6); } if (!strncmp(argv[i], "--scan-tree=", 12) || !strncmp(argv[i], "--scan-path=", 12)) {@@ -834,7 +834,7 @@ if (!ctx.cfg.virtual_root && ctx.cfg.script_name) {
ctx.cfg.virtual_root = trim_end(ctx.cfg.script_name, '/'); if (!ctx.cfg.virtual_root) ctx.cfg.virtual_root = ""; - } + } /* If no url parameter is specified on the querystring, lets * use PATH_INFO as url. This allows cgit to work with virtual@@ -856,7 +856,7 @@ cgit_parse_url(ctx.qry.url);
} ttl = calc_ttl(); - ctx.page.expires += ttl*60; + ctx.page.expires += ttl * 60; if (ctx.env.request_method && !strcmp(ctx.env.request_method, "HEAD")) ctx.cfg.nocache = 1; if (ctx.cfg.nocache)
@@ -13,9 +13,9 @@
int next_char(FILE *f) { int c = fgetc(f); - if (c=='\r') { + if (c == '\r') { c = fgetc(f); - if (c!='\n') { + if (c != '\n') { ungetc(c, f); c = '\r'; }@@ -27,7 +27,7 @@ void skip_line(FILE *f)
{ int c; - while((c=next_char(f)) && c!='\n' && c!=EOF) + while((c = next_char(f)) && c != '\n' && c != EOF) ; }@@ -36,31 +36,31 @@ {
int i = 0, isname = 0; *value = NULL; - while(i<bufsize-1) { + while(i < bufsize - 1) { int c = next_char(f); - if (!isname && (c=='#' || c==';')) { + if (!isname && (c == '#' || c == ';')) { skip_line(f); continue; } if (!isname && isspace(c)) continue; - if (c=='=' && !*value) { + if (c == '=' && !*value) { line[i] = 0; - *value = &line[i+1]; - } else if (c=='\n' && !isname) { + *value = &line[i + 1]; + } else if (c == '\n' && !isname) { i = 0; continue; - } else if (c=='\n' || c==EOF) { + } else if (c == '\n' || c == EOF) { line[i] = 0; break; } else { - line[i]=c; + line[i] = c; } isname = 1; i++; } - line[i+1] = 0; + line[i + 1] = 0; return i; }
@@ -54,7 +54,7 @@
va_start(args, format); len = vsnprintf(buf[bufidx], sizeof(buf[bufidx]), format, args); va_end(args); - if (len>sizeof(buf[bufidx])) { + if (len > sizeof(buf[bufidx])) { fprintf(stderr, "[html.c] string truncated: %s\n", format); exit(1); }@@ -94,19 +94,19 @@ {
const char *t = txt; while(t && *t){ int c = *t; - if (c=='<' || c=='>' || c=='&') { + if (c == '<' || c == '>' || c == '&') { html_raw(txt, t - txt); - if (c=='>') + if (c == '>') html(">"); - else if (c=='<') + else if (c == '<') html("<"); - else if (c=='&') + else if (c == '&') html("&"); - txt = t+1; + txt = t + 1; } t++; } - if (t!=txt) + if (t != txt) html(txt); }@@ -115,21 +115,21 @@ {
const char *t = txt; while(t && *t && len--){ int c = *t; - if (c=='<' || c=='>' || c=='&') { + if (c == '<' || c == '>' || c == '&') { html_raw(txt, t - txt); - if (c=='>') + if (c == '>') html(">"); - else if (c=='<') + else if (c == '<') html("<"); - else if (c=='&') + else if (c == '&') html("&"); - txt = t+1; + txt = t + 1; } t++; } - if (t!=txt) + if (t != txt) html_raw(txt, t - txt); - if (len<0) + if (len < 0) html("..."); }@@ -138,23 +138,23 @@ {
const char *t = txt; while(t && *t){ int c = *t; - if (c=='<' || c=='>' || c=='\'' || c=='\"' || c=='&') { + if (c == '<' || c == '>' || c == '\'' || c == '\"' || c == '&') { html_raw(txt, t - txt); - if (c=='>') + if (c == '>') html(">"); - else if (c=='<') + else if (c == '<') html("<"); - else if (c=='\'') + else if (c == '\'') html("'"); - else if (c=='"') + else if (c == '"') html("""); - else if (c=='&') + else if (c == '&') html("&"); - txt = t+1; + txt = t + 1; } t++; } - if (t!=txt) + if (t != txt) html(txt); }@@ -164,14 +164,14 @@ const char *t = txt;
while(t && *t){ unsigned char c = *t; const char *e = url_escape_table[c]; - if (e && c!='+' && c!='&') { + if (e && c != '+' && c != '&') { html_raw(txt, t - txt); html(e); - txt = t+1; + txt = t + 1; } t++; } - if (t!=txt) + if (t != txt) html(txt); }@@ -186,11 +186,11 @@ e = "+";
if (e) { html_raw(txt, t - txt); html(e); - txt = t+1; + txt = t + 1; } t++; } - if (t!=txt) + if (t != txt) html(txt); }@@ -286,14 +286,14 @@ if (n < 3) {
*txt = '\0'; return txt-1; } - d1 = hextoint(*(txt+1)); - d2 = hextoint(*(txt+2)); - if (d1<0 || d2<0) { - memmove(txt, txt+3, n-2); + d1 = hextoint(*(txt + 1)); + d2 = hextoint(*(txt + 2)); + if (d1 < 0 || d2 < 0) { + memmove(txt, txt + 3, n - 2); return txt-1; } else { *txt = d1 * 16 + d2; - memmove(txt+1, txt+3, n-2); + memmove(txt + 1, txt + 3, n - 2); return txt; } }@@ -311,22 +311,22 @@ printf("Out of memory\n");
exit(1); } while((c=*t) != '\0') { - if (c=='=') { + if (c == '=') { *t = '\0'; - value = t+1; - } else if (c=='+') { + value = t + 1; + } else if (c == '+') { *t = ' '; - } else if (c=='%') { + } else if (c == '%') { t = convert_query_hexchar(t); - } else if (c=='&') { + } else if (c == '&') { *t = '\0'; (*fn)(txt, value); - txt = t+1; + txt = t + 1; value = NULL; } t++; } - if (t!=txt) + if (t != txt) (*fn)(txt, value); free(o); return 0;
@@ -106,7 +106,7 @@ repo = cgit_add_repo(rel);
config_fn = fn; if (ctx.cfg.enable_git_config) git_config_from_file(gitconfig_config, fmt("%s/config", path), NULL); - + if (ctx.cfg.remove_suffix) if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git")) *p = '\0';@@ -222,7 +222,7 @@ {
char line[MAX_PATH * 2], *z; FILE *projects; int err; - + projects = fopen(projectsfile, "r"); if (!projects) { fprintf(stderr, "Error opening projectsfile %s: %s (%d)\n",
@@ -15,12 +15,12 @@ static char *match_path;
static unsigned char *matched_sha1; static int found_path; -static int walk_tree(const unsigned char *sha1, const char *base,int baselen, +static int walk_tree(const unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned mode, int stage, void *cbdata) { - if(strncmp(base,match_path,baselen) - || strcmp(match_path+baselen,pathname) ) + if(strncmp(base, match_path, baselen) + || strcmp(match_path + baselen, pathname)) return READ_TREE_RECURSIVE; - memmove(matched_sha1,sha1,20); + memmove(matched_sha1, sha1, 20); found_path = 1; return 0; }@@ -85,7 +85,7 @@ cgit_print_error(fmt("Bad hex value: %s", hex));
return; } } else { - if (get_sha1(head,sha1)) { + if (get_sha1(head, sha1)) { cgit_print_error(fmt("Bad ref: %s", head)); return; }
@@ -39,7 +39,7 @@
format_note(NULL, sha1, ¬es, PAGE_ENCODING, 0); load_ref_decorations(DECORATE_FULL_REFS); - + cgit_print_diff_ctrls(); html("<table summary='commit info' class='commit-info'>\n"); html("<tr><th>author</th><td>");@@ -75,7 +75,7 @@ html(" /");
cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tmp, prefix); } html("</td></tr>\n"); - for (p = commit->parents; p ; p = p->next) { + for (p = commit->parents; p; p = p->next) { parent = lookup_commit_reference(p->item->object.sha1); if (!parent) { html("<tr><td colspan='3'>");
@@ -200,7 +200,7 @@ qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age);
qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); } - for(i=0; i<maxcount; i++) + for(i = 0; i < maxcount; i++) print_branch(list.refs[i]); if (maxcount < list.count)@@ -224,7 +224,7 @@ maxcount = list.count;
else if (maxcount > list.count) maxcount = list.count; print_tag_header(); - for(i=0; i<maxcount; i++) + for(i = 0; i < maxcount; i++) print_tag(list.refs[i]); if (maxcount < list.count)
@@ -131,8 +131,8 @@ char *class = NULL;
html("<div class='pager'>"); for(i = 0, ofs = 0; ofs < items; i++, ofs = i * pagelen) { class = (ctx.qry.ofs == ofs) ? "current" : NULL; - cgit_index_link(fmt("[%d]", i+1), fmt("Page %d", i+1), class, - search, sort, ofs); + cgit_index_link(fmt("[%d]", i + 1), fmt("Page %d", i + 1), + class, search, sort, ofs); } html("</div>"); }@@ -264,7 +264,7 @@ else if (ctx.cfg.section_sort)
sort_repolist("section"); html("<table summary='repository list' class='list nowrap'>"); - for (i=0; i<cgit_repolist.count; i++) { + for (i = 0; i < cgit_repolist.count; i++) { ctx.repo = &cgit_repolist.repos[i]; if (!(is_match(ctx.repo) && is_in_url(ctx.repo))) continue;
@@ -23,21 +23,21 @@ static void trunc_week(struct tm *tm)
{ time_t t = timegm(tm); t -= ((tm->tm_wday + 6) % 7) * DAY_SECS; - gmtime_r(&t, tm); + gmtime_r(&t, tm); } static void dec_week(struct tm *tm) { time_t t = timegm(tm); t -= WEEK_SECS; - gmtime_r(&t, tm); + gmtime_r(&t, tm); } static void inc_week(struct tm *tm) { time_t t = timegm(tm); t += WEEK_SECS; - gmtime_r(&t, tm); + gmtime_r(&t, tm); } static char *pretty_week(struct tm *tm)@@ -153,7 +153,7 @@ for (i = 0; i < sizeof(periods) / sizeof(periods[0]); i++)
if (periods[i].code == code || !strcmp(periods[i].name, expr)) { if (period) *period = &periods[i]; - return i+1; + return i + 1; } return 0; }
@@ -27,7 +27,7 @@ if (ctx.cfg.enable_tree_linenumbers) {
html("<tr><td class='linenumbers'><pre>"); idx = 0; lineno = 0; - + if (size) { htmlf(numberfmt, ++lineno); while(idx < size - 1) { // skip absolute last newline@@ -228,7 +228,7 @@ static char buffer[PATH_MAX];
if (state == 0) { memcpy(buffer, base, baselen); - strcpy(buffer+baselen, pathname); + strcpy(buffer + baselen, pathname); if (strcmp(match_path, buffer)) return READ_TREE_RECURSIVE;