Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/tool/checkSpacing.c # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / tool / checkSpacing.c` 84 lines ยท 2214 bytes Raw Blame History 1 /* 2 ** This program checks for formatting problems in source code: 3 ** 4 ** * Any use of tab characters 5 ** * White space at the end of a line 6 ** * Blank lines at the end of a file 7 ** 8 ** Any violations are reported. 9 */ 10 #include 11 #include 12 #include 13 14 #define CR_OK 0x001 15 #define WSEOL_OK 0x002 16 17 static void checkSpacing(const char *zFile, unsigned flags){ 18 FILE *in = fopen(zFile, "rb"); 19 int i; 20 int seenSpace; 21 int seenTab; 22 int ln = 0; 23 int lastNonspace = 0; 24 char zLine[2000]; 25 if( in==0 ){ 26 printf("cannot open %s\n", zFile); 27 return; 28 } 29 while( fgets(zLine, sizeof(zLine), in) ){ 30 seenSpace = 0; 31 seenTab = 0; 32 ln++; 33 for(i=0; zLine[i]; i++){ 34 if( zLine[i]=='\t' && seenTab==0 ){ 35 printf("%s:%d: tab (\\t) character\n", zFile, ln); 36 seenTab = 1; 37 }else if( zLine[i]=='\r' ){ 38 if( (flags & CR_OK)==0 ){ 39 printf("%s:%d: carriage-return (\\r) character\n", zFile, ln); 40 } 41 }else if( zLine[i]==' ' ){ 42 seenSpace = 1; 43 }else if( zLine[i]!='\n' ){ 44 lastNonspace = ln; 45 seenSpace = 0; 46 } 47 } 48 if( seenSpace && (flags & WSEOL_OK)==0 ){ 49 printf("%s:%d: whitespace at end-of-line\n", zFile, ln); 50 } 51 } 52 fclose(in); 53 if( lastNonspace