Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add a command-line program to tool/ that will check source code files for the presence of tabs, carriage-returns, whitespace at the ends of lines, and blank lines at the ends of files. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
656a9c8b47d262e0982ad3a35db490e2 |
User & Date: | drh 2012-08-20 15:46:08.616 |
Context
2012-08-20
| ||
15:53 | Remove tab characters from source code files. Replace them with spaces. (check-in: 7edd10a960 user: drh tags: trunk) | |
15:46 | Add a command-line program to tool/ that will check source code files for the presence of tabs, carriage-returns, whitespace at the ends of lines, and blank lines at the ends of files. (check-in: 656a9c8b47 user: drh tags: trunk) | |
2012-08-17
| ||
13:44 | Clarify that the number-of-bytes parameter to sqlite3_bind_blob() must be non-negative. (check-in: b1b01c4cd9 user: drh tags: trunk) | |
Changes
Added tool/checkSpacing.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | /* ** This program checks for formatting problems in source code: ** ** * Any use of tab characters ** * White space at the end of a line ** * Blank lines at the end of a file ** ** Any violations are reported. */ #include <stdio.h> #include <stdlib.h> #include <string.h> static void checkSpacing(const char *zFile, int crok){ FILE *in = fopen(zFile, "rb"); int i; int seenSpace; int seenTab; int ln = 0; int lastNonspace = 0; char zLine[2000]; if( in==0 ){ printf("cannot open %s\n", zFile); return; } while( fgets(zLine, sizeof(zLine), in) ){ seenSpace = 0; seenTab = 0; ln++; for(i=0; zLine[i]; i++){ if( zLine[i]=='\t' && seenTab==0 ){ printf("%s:%d: tab (\\t) character\n", zFile, ln); seenTab = 1; }else if( zLine[i]=='\r' ){ if( !crok ){ printf("%s:%d: carriage-return (\\r) character\n", zFile, ln); } }else if( zLine[i]==' ' ){ seenSpace = 1; }else if( zLine[i]!='\n' ){ lastNonspace = ln; seenSpace = 0; } } if( seenSpace ){ printf("%s:%d: whitespace at end-of-line\n", zFile, ln); } } fclose(in); if( lastNonspace<ln ){ printf("%s:%d: blank lines at end of file (%d)\n", zFile, ln, ln - lastNonspace); } } int main(int argc, char **argv){ int i; int crok = 0; for(i=1; i<argc; i++){ if( strcmp(argv[i], "--crok")==0 ){ crok = 1; }else{ checkSpacing(argv[i], crok); } } return 0; } |