diff options
author | Daniel Stenberg <daniel@haxx.se> | 2016-02-11 09:42:38 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2016-02-11 09:44:45 +0100 |
commit | 3a6563d668406df1703edb4202afc038fcf9d30e (patch) | |
tree | 0fbb9438d99c13049f72b10c966583e582e4e238 /docs/examples/htmltidy.c | |
parent | 936d8f07dfbf2ac22ffd216f5363152bcecc2651 (diff) | |
download | curl-3a6563d668406df1703edb4202afc038fcf9d30e.tar.gz |
examples: adhere to curl code style
All plain C examples now (mostly) adhere to the curl code style. While
they are only examples, they had diverted so much and contained all
sorts of different mixed code styles by now. Having them use a unified
style helps users and readability. Also, as they get copy-and-pasted
widely by users, making sure they're clean and nice is a good idea.
573 checksrc warnings were addressed.
Diffstat (limited to 'docs/examples/htmltidy.c')
-rw-r--r-- | docs/examples/htmltidy.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/docs/examples/htmltidy.c b/docs/examples/htmltidy.c index 8df5d8fea..01b1e68f1 100644 --- a/docs/examples/htmltidy.c +++ b/docs/examples/htmltidy.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -38,23 +38,21 @@ uint write_cb(char *in, uint size, uint nmemb, TidyBuffer *out) uint r; r = size * nmemb; tidyBufAppend( out, in, r ); - return(r); + return r; } /* Traverse the document tree */ void dumpNode(TidyDoc doc, TidyNode tnod, int indent ) { TidyNode child; - for ( child = tidyGetChild(tnod); child; child = tidyGetNext(child) ) - { + for(child = tidyGetChild(tnod); child; child = tidyGetNext(child) ) { ctmbstr name = tidyNodeGetName( child ); - if ( name ) - { + if(name) { /* if it has a name, then it's an HTML tag ... */ TidyAttr attr; printf( "%*.*s%s ", indent, indent, "<", name); /* walk the attribute list */ - for ( attr=tidyAttrFirst(child); attr; attr=tidyAttrNext(attr) ) { + for(attr=tidyAttrFirst(child); attr; attr=tidyAttrNext(attr) ) { printf(tidyAttrName(attr)); tidyAttrValue(attr)?printf("=\"%s\" ", tidyAttrValue(attr)):printf(" "); @@ -82,7 +80,7 @@ int main(int argc, char **argv ) TidyBuffer docbuf = {0}; TidyBuffer tidy_errbuf = {0}; int err; - if ( argc == 2) { + if(argc == 2) { curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, argv[1]); curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_errbuf); @@ -98,13 +96,13 @@ int main(int argc, char **argv ) curl_easy_setopt(curl, CURLOPT_WRITEDATA, &docbuf); err=curl_easy_perform(curl); - if ( !err ) { + if(!err) { err = tidyParseBuffer(tdoc, &docbuf); /* parse the input */ - if ( err >= 0 ) { + if(err >= 0) { err = tidyCleanAndRepair(tdoc); /* fix any problems */ - if ( err >= 0 ) { + if(err >= 0) { err = tidyRunDiagnostics(tdoc); /* load tidy error buffer */ - if ( err >= 0 ) { + if(err >= 0) { dumpNode( tdoc, tidyGetRoot(tdoc), 0 ); /* walk the tree */ fprintf(stderr, "%s\n", tidy_errbuf.bp); /* show errors */ } @@ -119,11 +117,11 @@ int main(int argc, char **argv ) tidyBufFree(&docbuf); tidyBufFree(&tidy_errbuf); tidyRelease(tdoc); - return(err); + return err; } else printf( "usage: %s <url>\n", argv[0] ); - return(0); + return 0; } |