From 009f8b3abd0f8aca6b027c24ce63ef7dd0d8e9be Mon Sep 17 00:00:00 2001 From: Nick White Date: Sun, 17 Jul 2011 18:22:06 +0100 Subject: Cleanup logic in if statements --- getgbook.c | 10 +++++----- 1 file 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")) == NULL) + if(!(c = strstr(buf," pages"))) 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; -- cgit v1.2.3