Commit 3c4583a6 authored by Geoff Simmons's avatar Geoff Simmons

style fascism:

* consistent brace style (K&R for if, while, for, do etc.)
* I'm prejudiced against cuddled elses %^)
parent 59734e30
...@@ -99,16 +99,13 @@ saveConfig(const char * fname) ...@@ -99,16 +99,13 @@ saveConfig(const char * fname)
char * content; char * content;
fp = fopen( fname, "w" ); fp = fopen( fname, "w" );
if ( fp == NULL ) if ( fp == NULL ) {
{
perror(fname); perror(fname);
return 4; return 4;
} }
content = getConfigContent(); content = getConfigContent();
for (int i = 0; *(content + i) != 0; i++) for (int i = 0; *(content + i) != 0; i++) {
{ if (EOF == putc(*(content + i), fp)) {
if (EOF == putc(*(content + i), fp))
{
fclose( fp); fclose( fp);
return 8; return 8;
} }
......
...@@ -59,25 +59,21 @@ TEST_compareFiles(const char * fname1, const char * fname2) ...@@ -59,25 +59,21 @@ TEST_compareFiles(const char * fname1, const char * fname2)
verbose("comparing files %s : %s", fname1, fname2); verbose("comparing files %s : %s", fname1, fname2);
fp1 = fopen( fname1, "r" ); fp1 = fopen( fname1, "r" );
if ( fp1 == NULL ) if ( fp1 == NULL ) {
{
perror(fname1); perror(fname1);
return -2; return -2;
} }
fp2 = fopen( fname2, "r" ) ; fp2 = fopen( fname2, "r" ) ;
if (fp2 == NULL) if (fp2 == NULL) {
{
perror(fname2); perror(fname2);
return -3; return -3;
} }
do do {
{
col++; col++;
ch1 = getc( fp1 ); ch1 = getc( fp1 );
ch2 = getc( fp2 ); ch2 = getc( fp2 );
if ( ch1 == '\n' && ch2 == '\n') if ( ch1 == '\n' && ch2 == '\n') {
{
line++; line++;
col = 0; col = 0;
} }
...@@ -88,7 +84,8 @@ TEST_compareFiles(const char * fname1, const char * fname2) ...@@ -88,7 +84,8 @@ TEST_compareFiles(const char * fname1, const char * fname2)
printf(" comparing files %s : %s, ", fname1, fname2); printf(" comparing files %s : %s, ", fname1, fname2);
printf("files differ at line: %i col: %i \n", line, col); printf("files differ at line: %i col: %i \n", line, col);
return line; return line;
} else { }
else {
return 0; return 0;
} }
} }
...@@ -104,19 +101,16 @@ TEST_compareFileWithString(const char * fname, const char * text) ...@@ -104,19 +101,16 @@ TEST_compareFileWithString(const char * fname, const char * text)
verbose("comparing file %s with text", fname); verbose("comparing file %s with text", fname);
fp1 = fopen( fname, "r" ); fp1 = fopen( fname, "r" );
if ( fp1 == NULL ) if ( fp1 == NULL ) {
{
perror(fname); perror(fname);
return -2; return -2;
} }
do do {
{
col++; col++;
ch1 = getc( fp1 ); ch1 = getc( fp1 );
ch2 = *(text + i++); ch2 = *(text + i++);
if ( ch1 == '\n' && ch2 == '\n') if ( ch1 == '\n' && ch2 == '\n') {
{
line++; line++;
col = 0; col = 0;
} }
...@@ -126,7 +120,8 @@ TEST_compareFileWithString(const char * fname, const char * text) ...@@ -126,7 +120,8 @@ TEST_compareFileWithString(const char * fname, const char * text)
printf(" comparing file %s with text, ", fname); printf(" comparing file %s with text, ", fname);
printf("file differs at line: %i col: %i \n", line, col); printf("file differs at line: %i col: %i \n", line, col);
return line; return line;
} else { }
else {
return 0; return 0;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment