White space around control verbs.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
lf/filter
Jason A. Donenfeld 11 years ago
parent 53bc747d31
commit bdae1d8a8d

@ -214,7 +214,7 @@ unsigned long hash_str(const char *str)
if (!s) if (!s)
return h; return h;
while(*s) { while (*s) {
h *= FNV_PRIME; h *= FNV_PRIME;
h ^= *s++; h ^= *s++;
} }
@ -342,7 +342,7 @@ int cache_process(int size, const char *path, const char *key, int ttl,
strcpy(filename, path); strcpy(filename, path);
if (filename[len - 1] != '/') if (filename[len - 1] != '/')
filename[len++] = '/'; filename[len++] = '/';
for(i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
sprintf(filename + len++, "%x", sprintf(filename + len++, "%x",
(unsigned char)(hash & 0xf)); (unsigned char)(hash & 0xf));
hash >>= 4; hash >>= 4;
@ -407,7 +407,7 @@ int cache_ls(const char *path)
*name = '\0'; *name = '\0';
} }
slot.cache_name = fullname; slot.cache_name = fullname;
while((ent = readdir(dir)) != NULL) { while ((ent = readdir(dir)) != NULL) {
if (strlen(ent->d_name) != 8) if (strlen(ent->d_name) != 8)
continue; continue;
strcpy(name, ent->d_name); strcpy(name, ent->d_name);

@ -315,7 +315,7 @@ static void querystring_cb(const char *name, const char *value)
ctx.qry.name = xstrdup(value); ctx.qry.name = xstrdup(value);
} else if (!strcmp(name, "mimetype")) { } else if (!strcmp(name, "mimetype")) {
ctx.qry.mimetype = xstrdup(value); ctx.qry.mimetype = xstrdup(value);
} else if (!strcmp(name, "s")){ } else if (!strcmp(name, "s")) {
ctx.qry.sort = xstrdup(value); ctx.qry.sort = xstrdup(value);
} else if (!strcmp(name, "showmsg")) { } else if (!strcmp(name, "showmsg")) {
ctx.qry.showmsg = atoi(value); ctx.qry.showmsg = atoi(value);
@ -653,7 +653,7 @@ void print_repolist(FILE *f, struct cgit_repolist *list, int start)
{ {
int i; int i;
for(i = start; i < list->count; i++) for (i = start; i < list->count; i++)
print_repo(f, &list->repos[i]); print_repo(f, &list->repos[i]);
} }

@ -166,7 +166,7 @@ struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx)
ctx->qry.page = "repolist"; ctx->qry.page = "repolist";
} }
for(i = 0; i < sizeof(cmds)/sizeof(*cmds); i++) for (i = 0; i < sizeof(cmds)/sizeof(*cmds); i++)
if (!strcmp(ctx->qry.page, cmds[i].name)) if (!strcmp(ctx->qry.page, cmds[i].name))
return &cmds[i]; return &cmds[i];
return NULL; return NULL;

@ -27,7 +27,7 @@ void skip_line(FILE *f)
{ {
int c; int c;
while((c = next_char(f)) && c != '\n' && c != EOF) while ((c = next_char(f)) && c != '\n' && c != EOF)
; ;
} }
@ -36,7 +36,7 @@ int read_config_line(FILE *f, char *line, const char **value, int bufsize)
int i = 0, isname = 0; int i = 0, isname = 0;
*value = NULL; *value = NULL;
while(i < bufsize - 1) { while (i < bufsize - 1) {
int c = next_char(f); int c = next_char(f);
if (!isname && (c == '#' || c == ';')) { if (!isname && (c == '#' || c == ';')) {
skip_line(f); skip_line(f);
@ -78,7 +78,7 @@ int parse_configfile(const char *filename, configfile_value_fn fn)
if (!(f = fopen(filename, "r"))) if (!(f = fopen(filename, "r")))
return -1; return -1;
nesting++; nesting++;
while((len = read_config_line(f, line, &value, sizeof(line))) > 0) while ((len = read_config_line(f, line, &value, sizeof(line))) > 0)
fn(line, value); fn(line, value);
nesting--; nesting--;
fclose(f); fclose(f);

@ -92,7 +92,7 @@ void html_status(int code, const char *msg, int more_headers)
void html_txt(const char *txt) void html_txt(const char *txt)
{ {
const char *t = txt; const char *t = txt;
while(t && *t){ while (t && *t) {
int c = *t; int c = *t;
if (c == '<' || c == '>' || c == '&') { if (c == '<' || c == '>' || c == '&') {
html_raw(txt, t - txt); html_raw(txt, t - txt);
@ -113,7 +113,7 @@ void html_txt(const char *txt)
void html_ntxt(int len, const char *txt) void html_ntxt(int len, const char *txt)
{ {
const char *t = txt; const char *t = txt;
while(t && *t && len--){ while (t && *t && len--) {
int c = *t; int c = *t;
if (c == '<' || c == '>' || c == '&') { if (c == '<' || c == '>' || c == '&') {
html_raw(txt, t - txt); html_raw(txt, t - txt);
@ -136,7 +136,7 @@ void html_ntxt(int len, const char *txt)
void html_attr(const char *txt) void html_attr(const char *txt)
{ {
const char *t = txt; const char *t = txt;
while(t && *t){ while (t && *t) {
int c = *t; int c = *t;
if (c == '<' || c == '>' || c == '\'' || c == '\"' || c == '&') { if (c == '<' || c == '>' || c == '\'' || c == '\"' || c == '&') {
html_raw(txt, t - txt); html_raw(txt, t - txt);
@ -161,7 +161,7 @@ void html_attr(const char *txt)
void html_url_path(const char *txt) void html_url_path(const char *txt)
{ {
const char *t = txt; const char *t = txt;
while(t && *t){ while (t && *t) {
unsigned char c = *t; unsigned char c = *t;
const char *e = url_escape_table[c]; const char *e = url_escape_table[c];
if (e && c != '+' && c != '&') { if (e && c != '+' && c != '&') {
@ -178,7 +178,7 @@ void html_url_path(const char *txt)
void html_url_arg(const char *txt) void html_url_arg(const char *txt)
{ {
const char *t = txt; const char *t = txt;
while(t && *t){ while (t && *t) {
unsigned char c = *t; unsigned char c = *t;
const char *e = url_escape_table[c]; const char *e = url_escape_table[c];
if (c == ' ') if (c == ' ')
@ -260,7 +260,7 @@ int html_include(const char *filename)
filename, strerror(errno), errno); filename, strerror(errno), errno);
return -1; return -1;
} }
while((len = fread(buf, 1, 4096, f)) > 0) while ((len = fread(buf, 1, 4096, f)) > 0)
html_raw(buf, len); html_raw(buf, len);
fclose(f); fclose(f);
return 0; return 0;
@ -310,7 +310,7 @@ int http_parse_querystring(const char *txt_, void (*fn)(const char *name, const
printf("Out of memory\n"); printf("Out of memory\n");
exit(1); exit(1);
} }
while((c=*t) != '\0') { while ((c=*t) != '\0') {
if (c == '=') { if (c == '=') {
*t = '\0'; *t = '\0';
value = t + 1; value = t + 1;

@ -112,7 +112,7 @@ const char *reencode(char **txt, const char *src_enc, const char *dst_enc)
return *txt; return *txt;
/* no encoding needed if src_enc equals dst_enc */ /* no encoding needed if src_enc equals dst_enc */
if(!strcasecmp(src_enc, dst_enc)) if (!strcasecmp(src_enc, dst_enc))
return *txt; return *txt;
tmp = reencode_string(*txt, dst_enc, src_enc); tmp = reencode_string(*txt, dst_enc, src_enc);
@ -170,7 +170,7 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
} }
/* if no special encoding is found, assume UTF-8 */ /* if no special encoding is found, assume UTF-8 */
if(!ret->msg_encoding) if (!ret->msg_encoding)
ret->msg_encoding = xstrdup("UTF-8"); ret->msg_encoding = xstrdup("UTF-8");
// skip unknown header fields // skip unknown header fields

@ -185,7 +185,7 @@ static void scan_path(const char *base, const char *path, repo_config_fn fn)
add_repo(base, fmt("%s/.git", path), fn); add_repo(base, fmt("%s/.git", path), fn);
goto end; goto end;
} }
while((ent = readdir(dir)) != NULL) { while ((ent = readdir(dir)) != NULL) {
if (ent->d_name[0] == '.') { if (ent->d_name[0] == '.') {
if (ent->d_name[1] == '\0') if (ent->d_name[1] == '\0')
continue; continue;

@ -108,7 +108,7 @@ char *trim_end(const char *str, char c)
if (str == NULL) if (str == NULL)
return NULL; return NULL;
len = strlen(str); len = strlen(str);
while(len > 0 && str[len - 1] == c) while (len > 0 && str[len - 1] == c)
len--; len--;
if (len == 0) if (len == 0)
return NULL; return NULL;
@ -351,16 +351,16 @@ int cgit_parse_snapshots_mask(const char *str)
int tl, sl, rv = 0; int tl, sl, rv = 0;
/* favor legacy setting */ /* favor legacy setting */
if(atoi(str)) if (atoi(str))
return 1; return 1;
for(;;) { for (;;) {
str += strspn(str, delim); str += strspn(str, delim);
tl = strcspn(str, delim); tl = strcspn(str, delim);
if (!tl) if (!tl)
break; break;
for (f = cgit_snapshot_formats; f->suffix; f++) { for (f = cgit_snapshot_formats; f->suffix; f++) {
sl = strlen(f->suffix); sl = strlen(f->suffix);
if((tl == sl && !strncmp(f->suffix, str, tl)) || if ((tl == sl && !strncmp(f->suffix, str, tl)) ||
(tl == sl - 1 && !strncmp(f->suffix + 1, str, tl - 1))) { (tl == sl - 1 && !strncmp(f->suffix + 1, str, tl - 1))) {
rv |= f->bit; rv |= f->bit;
break; break;

@ -17,7 +17,7 @@ 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) { const char *pathname, unsigned mode, int stage, void *cbdata) {
if(strncmp(base, match_path, baselen) if (strncmp(base, match_path, baselen)
|| strcmp(match_path + baselen, pathname)) || strcmp(match_path + baselen, pathname))
return READ_TREE_RECURSIVE; return READ_TREE_RECURSIVE;
memmove(matched_sha1, sha1, 20); memmove(matched_sha1, sha1, 20);
@ -43,7 +43,7 @@ int cgit_print_file(char *path, const char *head)
if (get_sha1(head, sha1)) if (get_sha1(head, sha1))
return -1; return -1;
type = sha1_object_info(sha1, &size); type = sha1_object_info(sha1, &size);
if(type == OBJ_COMMIT && path) { if (type == OBJ_COMMIT && path) {
commit = lookup_commit_reference(sha1); commit = lookup_commit_reference(sha1);
match_path = path; match_path = path;
matched_sha1 = sha1; matched_sha1 = sha1;
@ -80,7 +80,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head)
}; };
if (hex) { if (hex) {
if (get_sha1_hex(hex, sha1)){ if (get_sha1_hex(hex, sha1)) {
cgit_print_error(fmt("Bad hex value: %s", hex)); cgit_print_error(fmt("Bad hex value: %s", hex));
return; return;
} }
@ -93,7 +93,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head)
type = sha1_object_info(sha1, &size); type = sha1_object_info(sha1, &size);
if((!hex) && type == OBJ_COMMIT && path) { if ((!hex) && type == OBJ_COMMIT && path) {
commit = lookup_commit_reference(sha1); commit = lookup_commit_reference(sha1);
match_path = path; match_path = path;
matched_sha1 = sha1; matched_sha1 = sha1;

@ -184,7 +184,7 @@ void cgit_print_diffstat(const unsigned char *old_sha1,
max_changes = 0; max_changes = 0;
cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix, cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix,
ctx.qry.ignorews); ctx.qry.ignorews);
for(i = 0; i<files; i++) for (i = 0; i<files; i++)
print_fileinfo(&items[i]); print_fileinfo(&items[i]);
html("</table>"); html("</table>");
html("<div class='diffstat-summary'>"); html("<div class='diffstat-summary'>");

@ -200,7 +200,7 @@ void cgit_print_branches(int maxcount)
qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); 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]); print_branch(list.refs[i]);
if (maxcount < list.count) if (maxcount < list.count)
@ -224,7 +224,7 @@ void cgit_print_tags(int maxcount)
else if (maxcount > list.count) else if (maxcount > list.count)
maxcount = list.count; maxcount = list.count;
print_tag_header(); print_tag_header();
for(i = 0; i < maxcount; i++) for (i = 0; i < maxcount; i++)
print_tag(list.refs[i]); print_tag(list.refs[i]);
if (maxcount < list.count) if (maxcount < list.count)

@ -129,7 +129,7 @@ void print_pager(int items, int pagelen, char *search, char *sort)
int i, ofs; int i, ofs;
char *class = NULL; char *class = NULL;
html("<div class='pager'>"); html("<div class='pager'>");
for(i = 0, ofs = 0; ofs < items; i++, ofs = i * pagelen) { for (i = 0, ofs = 0; ofs < items; i++, ofs = i * pagelen) {
class = (ctx.qry.ofs == ofs) ? "current" : NULL; class = (ctx.qry.ofs == ofs) ? "current" : NULL;
cgit_index_link(fmt("[%d]", i + 1), fmt("Page %d", i + 1), cgit_index_link(fmt("[%d]", i + 1), fmt("Page %d", i + 1),
class, search, sort, ofs); class, search, sort, ofs);
@ -258,7 +258,7 @@ void cgit_print_repolist()
if (ctx.cfg.index_header) if (ctx.cfg.index_header)
html_include(ctx.cfg.index_header); html_include(ctx.cfg.index_header);
if(ctx.qry.sort) if (ctx.qry.sort)
sorted = sort_repolist(ctx.qry.sort); sorted = sort_repolist(ctx.qry.sort);
else if (ctx.cfg.section_sort) else if (ctx.cfg.section_sort)
sort_repolist("section"); sort_repolist("section");

@ -103,20 +103,20 @@ const char *cgit_repobasename(const char *reponame)
int p; int p;
const char *rv; const char *rv;
strncpy(rvbuf, reponame, sizeof(rvbuf)); strncpy(rvbuf, reponame, sizeof(rvbuf));
if(rvbuf[sizeof(rvbuf)-1]) if (rvbuf[sizeof(rvbuf)-1])
die("cgit_repobasename: truncated repository name '%s'", reponame); die("cgit_repobasename: truncated repository name '%s'", reponame);
p = strlen(rvbuf)-1; p = strlen(rvbuf)-1;
/* strip trailing slashes */ /* strip trailing slashes */
while(p && rvbuf[p] == '/') rvbuf[p--] = 0; while (p && rvbuf[p] == '/') rvbuf[p--] = 0;
/* strip trailing .git */ /* strip trailing .git */
if(p >= 3 && !strncmp(&rvbuf[p-3], ".git", 4)) { if (p >= 3 && !strncmp(&rvbuf[p-3], ".git", 4)) {
p -= 3; rvbuf[p--] = 0; p -= 3; rvbuf[p--] = 0;
} }
/* strip more trailing slashes if any */ /* strip more trailing slashes if any */
while( p && rvbuf[p] == '/') rvbuf[p--] = 0; while ( p && rvbuf[p] == '/') rvbuf[p--] = 0;
/* find last slash in the remaining string */ /* find last slash in the remaining string */
rv = strrchr(rvbuf,'/'); rv = strrchr(rvbuf,'/');
if(rv) if (rv)
return ++rv; return ++rv;
return rvbuf; return rvbuf;
} }
@ -576,7 +576,7 @@ void cgit_print_date(time_t secs, const char *format, int local_time)
if (!secs) if (!secs)
return; return;
if(local_time) if (local_time)
time = localtime(&secs); time = localtime(&secs);
else else
time = gmtime(&secs); time = gmtime(&secs);

@ -72,7 +72,7 @@ const struct cgit_snapshot_format cgit_snapshot_formats[] = {
{ ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive, 0x04 }, { ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive, 0x04 },
{ ".tar", "application/x-tar", write_tar_archive, 0x08 }, { ".tar", "application/x-tar", write_tar_archive, 0x08 },
{ ".tar.xz", "application/x-xz", write_tar_xz_archive, 0x10 }, { ".tar.xz", "application/x-xz", write_tar_xz_archive, 0x10 },
{} { NULL }
}; };
static const struct cgit_snapshot_format *get_format(const char *filename) static const struct cgit_snapshot_format *get_format(const char *filename)
@ -81,7 +81,7 @@ static const struct cgit_snapshot_format *get_format(const char *filename)
int fl, sl; int fl, sl;
fl = strlen(filename); fl = strlen(filename);
for(fmt = cgit_snapshot_formats; fmt->suffix; fmt++) { for (fmt = cgit_snapshot_formats; fmt->suffix; fmt++) {
sl = strlen(fmt->suffix); sl = strlen(fmt->suffix);
if (sl >= fl) if (sl >= fl)
continue; continue;

@ -83,7 +83,7 @@ static char *pretty_month(struct tm *tm)
static void trunc_quarter(struct tm *tm) static void trunc_quarter(struct tm *tm)
{ {
trunc_month(tm); trunc_month(tm);
while(tm->tm_mon % 3 != 0) while (tm->tm_mon % 3 != 0)
dec_month(tm); dec_month(tm);
} }

@ -30,7 +30,7 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size)
if (size) { if (size) {
htmlf(numberfmt, ++lineno); htmlf(numberfmt, ++lineno);
while(idx < size - 1) { // skip absolute last newline while (idx < size - 1) { // skip absolute last newline
if (buf[idx] == '\n') if (buf[idx] == '\n')
htmlf(numberfmt, ++lineno); htmlf(numberfmt, ++lineno);
idx++; idx++;

Loading…
Cancel
Save