You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2009/12/12 23:55:46 UTC

svn commit: r889996 - in /lucene/lucy/trunk/charmonizer: ./ src/Charmonizer/ src/Charmonizer/Core/ src/Charmonizer/Test/

Author: marvin
Date: Sat Dec 12 22:55:43 2009
New Revision: 889996

URL: http://svn.apache.org/viewvc?rev=889996&view=rev
Log:
Change conditional bracketing style in most of Charmonizer to be consistent
with the rest of Lucy.

Modified:
    lucene/lucy/trunk/charmonizer/charmonize.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/CompilerSpec.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/HeadCheck.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.h
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/OperSys.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Stat.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Util.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Test.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/TestLargeFiles.c

Modified: lucene/lucy/trunk/charmonizer/charmonize.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/charmonize.c?rev=889996&r1=889995&r2=889996&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/charmonize.c (original)
+++ lucene/lucy/trunk/charmonizer/charmonize.c Sat Dec 12 22:55:43 2009
@@ -81,8 +81,7 @@
     size_t infile_len;
 
     /* Parse the infile. */
-    if (argc != 2)
-        die("Usage: ./charmonize INFILE");
+    if (argc != 2) { die("Usage: ./charmonize INFILE"); }
     infile_str = chaz_Probe_slurp_file(argv[1], &infile_len);
     cc_command = S_extract_delim_and_verify(infile_str, infile_len, 
         "charm_cc_command");
@@ -116,8 +115,7 @@
     char *retval = NULL;
 
     /* Sanity check, then create delimiter strings to match against. */
-    if (tag_name_len > 95)
-        die("tag name too long: '%s'");
+    if (tag_name_len > 95) { die("tag name too long: '%s'"); }
     sprintf(opening_delim, "<%s>", tag_name);
     sprintf(closing_delim, "</%s>", tag_name);
     
@@ -148,8 +146,7 @@
                            const char *tag_name)
 {
     char *retval = S_extract_delim(source, source_len, tag_name);
-    if (retval == NULL)
-        die("Couldn't extract value for '%s'", tag_name);
+    if (retval == NULL) { die("Couldn't extract value for '%s'", tag_name); }
     return retval;
 }
 

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.c?rev=889996&r1=889995&r2=889996&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.c Sat Dec 12 22:55:43 2009
@@ -31,8 +31,7 @@
     CompilerSpec *compiler_spec = CCSpec_find_spec();
     Compiler *self = (Compiler*)malloc(sizeof(Compiler));
 
-    if (Util_verbosity)
-        printf("Creating compiler object...\n");
+    if (Util_verbosity) { printf("Creating compiler object...\n"); }
 
     /* Assign. */
     self->os              = oper_sys;
@@ -206,14 +205,14 @@
     char *code = "int main() { return 0; }\n";
     chaz_bool_t success;
     
-    if (Util_verbosity) 
+    if (Util_verbosity) {
         printf("Trying to compile a small test file...\n");
+    }
 
     /* Attempt compilation. */
     success = self->compile_exe(self, "_charm_try.c", 
         "_charm_try", code, strlen(code));
-    if (!success)
-        Util_die("Failed to compile a small test file");
+    if (!success) { Util_die("Failed to compile a small test file"); }
     
     /* Clean up. */
     remove("_charm_try.c");

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/CompilerSpec.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/CompilerSpec.c?rev=889996&r1=889995&r2=889996&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/CompilerSpec.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/CompilerSpec.c Sat Dec 12 22:55:43 2009
@@ -17,8 +17,9 @@
 CompilerSpec*
 CCSpec_find_spec()
 {
-    if (Util_verbosity)
+    if (Util_verbosity) {
         printf("Trying to find a supported compiler...\n");
+    }
 
     return &spec;
 }

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/HeadCheck.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/HeadCheck.c?rev=889996&r1=889995&r2=889996&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/HeadCheck.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/HeadCheck.c Sat Dec 12 22:55:43 2009
@@ -140,12 +140,10 @@
     Header **const a = (Header**)vptr_a;
     Header **const b = (Header**)vptr_b;
 
-    if ((*a)->name == NULL) /* NULL is "greater than" any string. */
-        return 1;
-    else if ((*b)->name == NULL)
-        return -1;
-    else
-        return strcmp((*a)->name, (*b)->name);
+    /* (NULL is "greater than" any string.) */
+    if      ((*a)->name == NULL) { return 1; }
+    else if ((*b)->name == NULL) { return -1; }
+    else                         { return strcmp((*a)->name, (*b)->name); }
 }
 
 static Header* 

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.c?rev=889996&r1=889995&r2=889996&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.c Sat Dec 12 22:55:43 2009
@@ -59,12 +59,14 @@
 {
     /* Open the filehandle. */
     ModHand_charmony_fh = fopen("charmony.h", "w+");
-    if (ModHand_charmony_fh == NULL) 
+    if (ModHand_charmony_fh == NULL) {
         Util_die("Can't open 'charmony.h': %s", strerror(errno));
+    }
 
     /* Print supplied text (if any) along with warning, open include guard. */
-    if (charmony_start != NULL)
+    if (charmony_start != NULL) {
         fprintf(ModHand_charmony_fh, charmony_start);
+    }
     fprintf(ModHand_charmony_fh,
         "/* Header file auto-generated by Charmonizer. \n"
         " * DO NOT EDIT THIS FILE!!\n"
@@ -84,8 +86,9 @@
 
     /* Write the last bit of charmony.h and close. */
     fprintf(ModHand_charmony_fh, "#endif /* H_CHARMONY */\n\n");
-    if (fclose(ModHand_charmony_fh))
+    if (fclose(ModHand_charmony_fh)) {
         Util_die("Couldn't close 'charmony.h': %s", strerror(errno));
+    }
 }
 
 static char charm_h_code[] = METAQUOTE
@@ -175,8 +178,9 @@
         charm_run_code_d);
     compile_succeeded = ModHand_compiler->compile_exe(ModHand_compiler, 
         "_charm_run.c", "_charm_run", code, strlen(code));
-    if (!compile_succeeded)
+    if (!compile_succeeded) {
         Util_die("failed to compile _charm_run helper utility");
+    }
 
     remove("_charm_run.c");
     free(code);
@@ -188,8 +192,9 @@
 {
     chaz_bool_t compile_succeeded;
 
-    if ( !Util_remove_and_verify(try_app_path) ) 
+    if ( !Util_remove_and_verify(try_app_path) ) {
         Util_die("Failed to delete file '%s'", try_app_path);
+    }
 
     compile_succeeded = ModHand_compiler->compile_exe(ModHand_compiler, 
         TRY_SOURCE_PATH, TRY_APP_BASENAME, source, source_len);
@@ -207,10 +212,12 @@
     chaz_bool_t compile_succeeded;
 
     /* Clear out previous versions and test to make sure removal worked. */
-    if ( !Util_remove_and_verify(try_app_path) ) 
+    if ( !Util_remove_and_verify(try_app_path) ) {
         Util_die("Failed to delete file '%s'", try_app_path);
-    if ( !Util_remove_and_verify(TARGET_PATH) )
+    }
+    if ( !Util_remove_and_verify(TARGET_PATH) ) {
         Util_die("Failed to delete file '%s'", TARGET_PATH);
+    }
 
     /* Attempt compilation; if successful, run app and slurp output. */
     compile_succeeded = ModHand_compiler->compile_exe(ModHand_compiler, 

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.h
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.h?rev=889996&r1=889995&r2=889996&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.h (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.h Sat Dec 12 22:55:43 2009
@@ -96,8 +96,9 @@
 #define CHAZ_MODHAND_START_RUN(module_name) \
     do { \
         chaz_ModHand_append_conf("\n/* %s */\n", module_name); \
-        if (chaz_Util_verbosity > 0) \
+        if (chaz_Util_verbosity > 0) { \
             printf("Running %s module...\n", module_name); \
+        } \
     } while (0)
 
 /* Leave a little whitespace at the end of each module.

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/OperSys.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/OperSys.c?rev=889996&r1=889995&r2=889996&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/OperSys.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/OperSys.c Sat Dec 12 22:55:43 2009
@@ -27,8 +27,9 @@
 {
     OperSys *self = (OperSys*)malloc(sizeof(OperSys));
 
-    if (Util_verbosity)
+    if (Util_verbosity) {
         printf("Creating os object...\n");
+    }
 
     /* Assign. */
     self->name = strdup(name);
@@ -68,8 +69,10 @@
     };
     int i;
 
-    if (Util_verbosity)
+    if (Util_verbosity) {
         printf("Trying to find a bit-bucket a la /dev/null...\n");
+    }
+
 
     /* Iterate through names of possible devnulls trying to open them. */
     for (i = 0; devnull_options[i] != NULL; i++) {

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Stat.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Stat.c?rev=889996&r1=889995&r2=889996&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Stat.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Stat.c Sat Dec 12 22:55:43 2009
@@ -28,12 +28,10 @@
     target->valid = false;
 
     /* Lazy init. */
-    if (!initialized)
-        S_init();
+    if (!initialized) { S_init(); }
 
     /* Bail out if we didn't succeed in compiling/using _charm_stat. */
-    if (!stat_available)
-        return;
+    if (!stat_available) { return; }
 
     /* Run _charm_stat. */
     Util_remove_and_verify("_charm_statout");
@@ -60,10 +58,8 @@
     int main(int argc, char **argv) {
         FILE *out_fh = fopen("_charm_statout", "w+");
         struct stat st;
-        if (argc != 2)
-            return 1;
-        if (stat(argv[1], &st) == -1)
-            return 2;
+        if (argc != 2) { return 1; }
+        if (stat(argv[1], &st) == -1) { return 2; }
         fprintf(out_fh, "%ld %ld\n", (long)st.st_size, (long)st.st_blocks);
         return 0;
     }
@@ -74,12 +70,13 @@
 {
     /* Only try this once. */
     initialized = true;
-    if (Util_verbosity)
+    if (Util_verbosity) {
         printf("Attempting to compile _charm_stat utility...\n");
+    }
 
     /* Bail if sys/stat.h isn't available. */
-    if (!HeadCheck_check_header("sys/stat.h"))
-        return;
+    if (!HeadCheck_check_header("sys/stat.h")) { return; }
+
 
     /* If the compile succeeds, open up for business. */
     stat_available = ModHand_compiler->compile_exe(ModHand_compiler, 

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Util.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Util.c?rev=889996&r1=889995&r2=889996&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Util.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Util.c Sat Dec 12 22:55:43 2009
@@ -14,11 +14,13 @@
 {
     FILE *fh = fopen(filename, "w+");
     size_t content_len = strlen(content);
-    if (fh == NULL)
+    if (fh == NULL) {
         Util_die("Couldn't open '%s': %s", filename, strerror(errno));
+    }
     fwrite(content, sizeof(char), content_len, fh);
-    if (fclose(fh))
+    if (fclose(fh)) {
         Util_die("Error when closing '%s': %s", filename, strerror(errno));
+    }
 }
 
 char*
@@ -30,8 +32,9 @@
     long    check_val;
 
     /* Sanity check. */
-    if (file == NULL)
+    if (file == NULL) {
         Util_die("Error opening file '%s': %s", file_path, strerror(errno));
+    }
 
     /* Find length; return NULL if the file has a zero-length. */
     len = Util_flength(file);
@@ -42,22 +45,25 @@
 
     /* Allocate memory and read the file. */
     contents = (char*)malloc(len * sizeof(char) + 1);
-    if (contents == NULL)
+    if (contents == NULL) {
         Util_die("Out of memory at %d, %s", __FILE__, __LINE__);
+    }
     contents[len] = '\0';
     check_val = fread(contents, sizeof(char), len, file);
 
     /* Weak error check, because CRLF might result in fewer chars read. */
-    if (check_val <= 0)
+    if (check_val <= 0) {
         Util_die("Tried to read %d characters of '%s', got %d", (int)len,
             file_path, check_val);
+    }
 
     /* Set length pointer for benefit of caller. */
     *len_ptr = check_val;
 
     /* Clean up. */
-    if (fclose(file))
+    if (fclose(file)) {
         Util_die("Error closing file '%s': %s", file_path, strerror(errno));
+    }
 
     return contents;
 }
@@ -71,16 +77,13 @@
 
     /* Seek to end of file and check length. */
     check_val = fseek(f, 0, SEEK_END);
-    if (check_val == -1)
-        Util_die("fseek error : %s\n", strerror(errno));
+    if (check_val == -1) { Util_die("fseek error : %s\n", strerror(errno)); }
     len = ftell(f);
-    if (len == -1)
-        Util_die("ftell error : %s\n", strerror(errno));
+    if (len == -1) { Util_die("ftell error : %s\n", strerror(errno)); }
 
     /* Return to where we were. */
     check_val = fseek(f, bookmark, SEEK_SET);
-    if (check_val == -1)
-        Util_die("fseek error : %s\n", strerror(errno));
+    if (check_val == -1) { Util_die("fseek error : %s\n", strerror(errno)); }
 
     return len;
 }

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.c?rev=889996&r1=889995&r2=889996&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.c Sat Dec 12 22:55:43 2009
@@ -23,23 +23,20 @@
     HeadCheck_init();
     ModHand_open_charmony_h(charmony_start);
 
-    if (Util_verbosity)
-        printf("Initialization complete.\n");
+    if (Util_verbosity) { printf("Initialization complete.\n"); }
 }
 
 void
 Probe_clean_up()
 {
-    if (Util_verbosity)
-        printf("Cleaning up...\n");
+    if (Util_verbosity) { printf("Cleaning up...\n"); }
 
     /* Dispatch ModHandler's clean up routines, destroy objects. */
     ModHand_clean_up();
     ModHand_os->destroy(ModHand_os);
     ModHand_compiler->destroy(ModHand_compiler);
 
-    if (Util_verbosity)
-        printf("Cleanup complete.\n");
+    if (Util_verbosity) { printf("Cleanup complete.\n"); }
 }
 
 void

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Test.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Test.c?rev=889996&r1=889995&r2=889996&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Test.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Test.c Sat Dec 12 22:55:43 2009
@@ -22,8 +22,9 @@
 Test_init(void) {
     /* Unbuffer stdout. */
     int check_val = setvbuf(stdout, NULL, _IONBF, 0);
-    if (check_val != 0)
+    if (check_val != 0) {
         fprintf(stderr, "Failed when trying to unbuffer stdout\n");
+    }
 }
 
 TestBatch* 

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/TestLargeFiles.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/TestLargeFiles.c?rev=889996&r1=889995&r2=889996&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/TestLargeFiles.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/TestLargeFiles.c Sat Dec 12 22:55:43 2009
@@ -44,8 +44,9 @@
 #endif
 
     fh = fopen64("_charm_large_file_test", "w+");
-    if (fh == NULL)
+    if (fh == NULL) {
         SKIP_REMAINING(batch, "Failed to open file");
+    }
 
     check_val = fseeko64(fh, gb4_plus, SEEK_SET);
     ASSERT_INT_EQ(batch, check_val, 0, "fseeko64 above 4 GB");
@@ -77,8 +78,9 @@
 
     /* Truncate, just in case the call to remove fails. */
     fh = fopen64("_charm_large_file_test", "w+");
-    if (fh != NULL)
-        fclose(fh);
+    if (fh != NULL) { 
+        fclose(fh); 
+    }
     remove("_charm_large_file_test");
 }