[MediaWiki-commits] [Gerrit] Whitespace cleanup in filter.c - change (analytics/webstatscollector)
Hello Stefan.petrea, I'd like you to do a code review. Please visit https://gerrit.wikimedia.org/r/98508 to review the following change. Change subject: Whitespace cleanup in filter.c .. Whitespace cleanup in filter.c Change-Id: Ie636e5bf1265486e54e5fe02d73153293ebc9b77 --- M filter.c 1 file changed, 30 insertions(+), 34 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/analytics/webstatscollector refs/changes/08/98508/1 diff --git a/filter.c b/filter.c index 1bf353e..ad0eb61 100644 --- a/filter.c +++ b/filter.c @@ -2,9 +2,9 @@ #include stdio.h #include stdbool.h -/* +/* -Modified on Jun 4, 2010 by hcatlin to +Modified on Jun 4, 2010 by hcatlin to now process en.m.wikipedia.org requests into the mobile project, with the title being the language code. @@ -26,14 +26,14 @@ char *wmwhitelist[] = {commons,meta,incubator,species,strategy,outreach,usability,quality}; bool check_wikimedia(char *language) { char **p=wmwhitelist; - for(;*p;p++) { - if(!strcmp(*p,language)) + for (;*p;p++) { + if (!strcmp(*p,language)) return true; } return false; } -/* IP addresses from which duplicate requests originate +/* IP addresses from which duplicate requests originate * Correspondence with Mark Bergsma on IRC. * diederik: what is exactly the issue? * mark: squids requesting from eachother @@ -55,7 +55,7 @@ bool check_ip(char *ip) { char **prefix=dupes; for (;*prefix;prefix++) { - if(!strncmp(*prefix,ip,strlen(*prefix))) + if (!strncmp(*prefix,ip,strlen(*prefix))) return false; } return true; @@ -76,9 +76,9 @@ {wikiversity,.v,NULL}, {wikiquote,.q,NULL}, {m.wikipedia, .mw, NULL}, -{wikivoyage, .voy, NULL}, -{wikimediafoundation, .f, NULL}, -{wikidata, .wd, NULL}, + {wikivoyage, .voy, NULL}, + {wikimediafoundation, .f, NULL}, + {wikidata, .wd, NULL}, NULL }, *project; @@ -98,11 +98,11 @@ } int i; - for(i = 0; i len; i++){ - if(url[i] == ' '){ + for (i = 0; i len; i++){ + if (url[i] == ' '){ url[i] = '_'; - } -} + } + } } bool parse_url(char *url, struct info *in) { @@ -124,31 +124,30 @@ in-language=HEAD; in-project=FIELD; -if(!in-language || - !in-project ) - return false; + if (!in-language || !in-project ) + return false; if (!strncmp(in-title,Special:CentralAutoLogin/, 25)) return false; /* Special:CentralAutoLogin/.* are no real page views.*/ - if(!strcmp(in-project,m)) { - in-project = m.wikipedia; - in-title = in-language; - return true; + if (!strcmp(in-project,m)) { + in-project = m.wikipedia; + in-title = in-language; + return true; } else { - if(strcmp(TAIL,org)) - return false; - if (in-language in-project) - return true; - else - return false; + if (strcmp(TAIL,org)) + return false; + if (in-language in-project) + return true; + else + return false; } } bool check_project(struct info *in) { const struct project *pr=projects; - for(;pr-full;pr++) { - if(!strcmp(in-project,pr-full)) { + for (;pr-full;pr++) { + if (!strcmp(in-project,pr-full)) { in-suffix=pr-suffix; /* Project found, check if filter needed */ if (pr-filter) @@ -171,10 +170,10 @@ setuid(65534); char *undef,*ip,*url, *size; - while(fgets(line,LINESIZE-1,stdin)) { + while (fgets(line,LINESIZE-1,stdin)) { bzero(info,sizeof(info)); /* Tokenize the log line */ - TOKENIZE(line,\t); /* server */ + TOKENIZE(line,\t); /* server */ FIELD; /* id? */ FIELD; /* timestamp */ FIELD; /* ??? */ @@ -183,9 +182,7 @@ info.size= FIELD; /* object size */ FIELD; url=FIELD; - if(!url || - !info.ip || - !info.size ) + if (!url || !info.ip || !info.size) continue; replace_space(url); if (!check_ip(info.ip)) @@ -197,4 +194,3 @@ printf(%s%s 1 %s %s\n,info.language, info.suffix, info.size, info.title);
[MediaWiki-commits] [Gerrit] Whitespace cleanup in filter.c - change (analytics/webstatscollector)
Ottomata has submitted this change and it was merged. Change subject: Whitespace cleanup in filter.c .. Whitespace cleanup in filter.c Change-Id: Ie636e5bf1265486e54e5fe02d73153293ebc9b77 --- M filter.c 1 file changed, 30 insertions(+), 34 deletions(-) Approvals: Ottomata: Verified; Looks good to me, approved diff --git a/filter.c b/filter.c index 1bf353e..ad0eb61 100644 --- a/filter.c +++ b/filter.c @@ -2,9 +2,9 @@ #include stdio.h #include stdbool.h -/* +/* -Modified on Jun 4, 2010 by hcatlin to +Modified on Jun 4, 2010 by hcatlin to now process en.m.wikipedia.org requests into the mobile project, with the title being the language code. @@ -26,14 +26,14 @@ char *wmwhitelist[] = {commons,meta,incubator,species,strategy,outreach,usability,quality}; bool check_wikimedia(char *language) { char **p=wmwhitelist; - for(;*p;p++) { - if(!strcmp(*p,language)) + for (;*p;p++) { + if (!strcmp(*p,language)) return true; } return false; } -/* IP addresses from which duplicate requests originate +/* IP addresses from which duplicate requests originate * Correspondence with Mark Bergsma on IRC. * diederik: what is exactly the issue? * mark: squids requesting from eachother @@ -55,7 +55,7 @@ bool check_ip(char *ip) { char **prefix=dupes; for (;*prefix;prefix++) { - if(!strncmp(*prefix,ip,strlen(*prefix))) + if (!strncmp(*prefix,ip,strlen(*prefix))) return false; } return true; @@ -76,9 +76,9 @@ {wikiversity,.v,NULL}, {wikiquote,.q,NULL}, {m.wikipedia, .mw, NULL}, -{wikivoyage, .voy, NULL}, -{wikimediafoundation, .f, NULL}, -{wikidata, .wd, NULL}, + {wikivoyage, .voy, NULL}, + {wikimediafoundation, .f, NULL}, + {wikidata, .wd, NULL}, NULL }, *project; @@ -98,11 +98,11 @@ } int i; - for(i = 0; i len; i++){ - if(url[i] == ' '){ + for (i = 0; i len; i++){ + if (url[i] == ' '){ url[i] = '_'; - } -} + } + } } bool parse_url(char *url, struct info *in) { @@ -124,31 +124,30 @@ in-language=HEAD; in-project=FIELD; -if(!in-language || - !in-project ) - return false; + if (!in-language || !in-project ) + return false; if (!strncmp(in-title,Special:CentralAutoLogin/, 25)) return false; /* Special:CentralAutoLogin/.* are no real page views.*/ - if(!strcmp(in-project,m)) { - in-project = m.wikipedia; - in-title = in-language; - return true; + if (!strcmp(in-project,m)) { + in-project = m.wikipedia; + in-title = in-language; + return true; } else { - if(strcmp(TAIL,org)) - return false; - if (in-language in-project) - return true; - else - return false; + if (strcmp(TAIL,org)) + return false; + if (in-language in-project) + return true; + else + return false; } } bool check_project(struct info *in) { const struct project *pr=projects; - for(;pr-full;pr++) { - if(!strcmp(in-project,pr-full)) { + for (;pr-full;pr++) { + if (!strcmp(in-project,pr-full)) { in-suffix=pr-suffix; /* Project found, check if filter needed */ if (pr-filter) @@ -171,10 +170,10 @@ setuid(65534); char *undef,*ip,*url, *size; - while(fgets(line,LINESIZE-1,stdin)) { + while (fgets(line,LINESIZE-1,stdin)) { bzero(info,sizeof(info)); /* Tokenize the log line */ - TOKENIZE(line,\t); /* server */ + TOKENIZE(line,\t); /* server */ FIELD; /* id? */ FIELD; /* timestamp */ FIELD; /* ??? */ @@ -183,9 +182,7 @@ info.size= FIELD; /* object size */ FIELD; url=FIELD; - if(!url || - !info.ip || - !info.size ) + if (!url || !info.ip || !info.size) continue; replace_space(url); if (!check_ip(info.ip)) @@ -197,4 +194,3 @@ printf(%s%s 1 %s %s\n,info.language, info.suffix, info.size, info.title); } } - -- To view, visit https://gerrit.wikimedia.org/r/98508 To unsubscribe, visit