summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <hg@njw.me.uk>2011-07-17 18:22:06 +0100
committerNick White <hg@njw.me.uk>2011-07-17 18:22:06 +0100
commit009f8b3abd0f8aca6b027c24ce63ef7dd0d8e9be (patch)
tree0bfe75f1569ea6a9a868b49d95387680febe8b50
parent136e4a162059871f9c89f73fb64013050cad7300 (diff)
Cleanup logic in if statements
-rw-r--r--getgbook.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/getgbook.c b/getgbook.c
index 622243a..d11761d 100644
--- a/getgbook.c
+++ b/getgbook.c
@@ -32,7 +32,7 @@ int gettotalpages(char *bookid)
if(!get("books.google.com", url, &buf))
return 0;
- if((c = strstr(buf," pages</dc:format>")) == NULL)
+ if(!(c = strstr(buf," pages</dc:format>")))
return 0;
while(*c && *c != '>') c--;
sscanf(c+1, "%d ", &total);
@@ -52,7 +52,7 @@ Page *getpagedetail(char *bookid, char *pg)
return NULL;
snprintf(m, 80, "\"pid\":\"%s\"", pg);
- if((c = strstr(buf,m)) == NULL)
+ if(!(c = strstr(buf,m)))
return NULL;
page = malloc(sizeof(Page));
@@ -60,7 +60,7 @@ Page *getpagedetail(char *bookid, char *pg)
page->url[0] = '\0';
page->num = 0;
- if(strncmp(c+strlen(m)+1, "\"src\"", 5) != 0) {
+ if(strncmp(c+strlen(m)+1, "\"src\"", 5)) {
free(buf); return page;
}
@@ -109,7 +109,7 @@ int main(int argc, char *argv[])
for(i=1; i<=totalpages; i++) {
snprintf(pg, 16, "%s%d", "PT", i);
- if((page = getpagedetail(bookid, pg)) == NULL || page->url[0] == '\0') {
+ if(!(page = getpagedetail(bookid, pg)) || !page->url[0]) {
fprintf(stderr, "%s failed\n", pg);
free(page);
continue;
@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
while(fgets(buf, 1024, stdin)) {
sscanf(buf, "%d", &i);
snprintf(pg, 16, "%s%d", "PA", i);
- if((page = getpagedetail(bookid, pg)) == NULL || page->url[0] == '\0') {
+ if(!(page = getpagedetail(bookid, pg)) || !page->url[0]) {
fprintf(stderr, "%d failed\n", i);
free(page);
continue;