lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r904951 - in /lucene/lucy/trunk/charmonizer/src/Charmonizer: Core/Compiler.c Core/Defines.h Core/Dir.c Core/HeaderChecker.c Core/OperatingSystem.c Core/Stat.c Probe.c Probe/FuncMacro.c Probe/Integers.c Probe/LargeFiles.c Probe/VariadicMacros.c
Date Sun, 31 Jan 2010 01:54:53 GMT
Author: marvin
Date: Sun Jan 31 01:54:51 2010
New Revision: 904951

URL: http://svn.apache.org/viewvc?rev=904951&view=rev
Log:
Replace METAQUOTE with QUOTE macro within Charmonizer source files.
(quote.diff from LUCY-71).

Modified:
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Defines.h
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Dir.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/HeaderChecker.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Stat.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/VariadicMacros.c

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=904951&r1=904950&r2=904951&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.c Sun Jan 31 01:54:51 2010
@@ -21,17 +21,14 @@
 /* Detect a supported compiler, or assume a generic GCC-compatible compiler
  * and hope for the best.  */
 #ifdef __GNUC__
-static char *compiler_nickname = "gcc";
 static char *include_flag      = "-I ";
 static char *object_flag       = "-o ";
 static char *exe_flag          = "-o ";
 #elif defined(_MSC_VER)
-static char *compiler_nickname = "MSVC";
 static char *include_flag      = "/I";
 static char *object_flag       = "/Fo";
 static char *exe_flag          = "/Fe";
 #else
-static char *compiler_nickname = "cc";
 static char *include_flag      = "-I ";
 static char *object_flag       = "-o ";
 static char *exe_flag          = "-o ";

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Defines.h
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Defines.h?rev=904951&r1=904950&r2=904951&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Defines.h (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Defines.h Sun Jan 31 01:54:51 2010
@@ -14,6 +14,12 @@
   #define false 0
 #endif
 
+#define CHAZ_QUOTE(x) #x "\n" 
+
+#if (defined(CHAZ_USE_SHORT_NAMES) || defined(CHY_USE_SHORT_NAMES))
+  #define QUOTE CHAZ_QUOTE
+#endif
+
 #ifdef __cplusplus
 }
 #endif

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Dir.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Dir.c?rev=904951&r1=904950&r2=904951&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Dir.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Dir.c Sun Jan 31 01:54:51 2010
@@ -19,34 +19,31 @@
 char *Dir_mkdir_command = mkdir_command;
 
 /* Source code for standard POSIX mkdir */
-static char posix_mkdir_code[] = METAQUOTE
-    #include <%s>
-    int main(int argc, char **argv) {
-        if (argc != 2) { return 1; }
-        if (mkdir(argv[1], 0777) != 0) { return 2; }
-        return 0;
-    }
-METAQUOTE;
+static char posix_mkdir_code[] =
+    QUOTE(  #include <%s>                                          )
+    QUOTE(  int main(int argc, char **argv) {                      )
+    QUOTE(      if (argc != 2) { return 1; }                       )
+    QUOTE(      if (mkdir(argv[1], 0777) != 0) { return 2; }       )
+    QUOTE(      return 0;                                          )
+    QUOTE(  }                                                      );
 
 /* Source code for Windows _mkdir. */
-static char win_mkdir_code[] = METAQUOTE
-    #include <direct.h>
-    int main(int argc, char **argv) {
-        if (argc != 2) { return 1; }
-        if (_mkdir(argv[1]) != 0) { return 2; }
-        return 0;
-    }
-METAQUOTE;
+static char win_mkdir_code[] =
+    QUOTE(  #include <direct.h>                                    )
+    QUOTE(  int main(int argc, char **argv) {                      )
+    QUOTE(      if (argc != 2) { return 1; }                       )
+    QUOTE(      if (_mkdir(argv[1]) != 0) { return 2; }            )
+    QUOTE(      return 0;                                          )
+    QUOTE(  }                                                      );
 
 /* Source code for rmdir. */
-static char rmdir_code[] = METAQUOTE
-    #include <%s>
-    int main(int argc, char **argv) {
-        if (argc != 2) { return 1; }
-        if (rmdir(argv[1]) != 0) { return 2; }
-        return 0;
-    }
-METAQUOTE;
+static char rmdir_code[] =
+    QUOTE(  #include <%s>                                          )
+    QUOTE(  int main(int argc, char **argv) {                      )
+    QUOTE(      if (argc != 2) { return 1; }                       )
+    QUOTE(      if (rmdir(argv[1]) != 0) { return 2; }             )
+    QUOTE(      return 0;                                          )
+    QUOTE(  }                                                      );
 
 static chaz_bool_t
 S_try_init_posix_mkdir(char *header)

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/HeaderChecker.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/HeaderChecker.c?rev=904951&r1=904950&r2=904951&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/HeaderChecker.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/HeaderChecker.c Sun Jan 31 01:54:51
2010
@@ -116,11 +116,10 @@
     return success;
 }
 
-static char contains_code[] = METAQUOTE
-  #include <stddef.h>
-  %s
-  int main() { return offsetof(%s, %s); }
-METAQUOTE;
+static char contains_code[] = 
+    QUOTE(  #include <stddef.h>                           )
+    QUOTE(  %s                                            )
+    QUOTE(  int main() { return offsetof(%s, %s); }       );
 
 chaz_bool_t
 HeadCheck_contains_member(const char *struct_name, const char *member,

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c?rev=904951&r1=904950&r2=904951&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c Sun Jan 31 01:54:51
2010
@@ -99,74 +99,50 @@
     return dev_null;
 }
 
-static char charm_run_code_a[] = METAQUOTE
-    #include <stdio.h>
-    #include <stdlib.h>
-    #include <string.h>
-    #include <stddef.h>
-    int main(int argc, char **argv)
-    {
-        char *command;
-        size_t command_len = 1; /* Terminating null. */
-        int i;
-        int retval;
-        
-        /* Rebuild the command line args, minus the name of this utility. */
-        for (i = 1; i < argc; i++) {
-            command_len += strlen(argv[i]) + 1;
-        }
-        command = (char*)calloc(command_len, sizeof(char));
-METAQUOTE;
-
-static char charm_run_code_b[] = METAQUOTE
-        if (command == NULL) {
-            fprintf(stderr, "calloc failed\n");
-            exit(1);
-        }
-        for (i = 1; i < argc; i++) {
-            strcat( strcat(command, " "), argv[i] );
-        }
-
-        /* Redirect stdout and stderr to /dev/null or equivalent. */
-        freopen( 
-METAQUOTE;
-
-static char charm_run_code_c[] = METAQUOTE
-             , "w", stdout);
-        freopen( 
-METAQUOTE;
-
-static char charm_run_code_d[] = METAQUOTE
-             , "w", stderr);
-
-        /* Run the commmand and return its value to the parent process. */
-        retval = system(command);
-        free(command);
-        return retval;
-    }
-METAQUOTE;
+static char charm_run_code[] = 
+    QUOTE(  #include <stdio.h>                                           )
+    QUOTE(  #include <stdlib.h>                                          )
+    QUOTE(  #include <string.h>                                          )
+    QUOTE(  #include <stddef.h>                                          )
+    QUOTE(  int main(int argc, char **argv)                              )
+    QUOTE(  {                                                            )
+    QUOTE(      char *command;                                           )
+    QUOTE(      size_t command_len = 1; /* Terminating null. */          )
+    QUOTE(      int i;                                                   )
+    QUOTE(      int retval;                                              )
+                /* Rebuild command line args. */ 
+    QUOTE(      for (i = 1; i < argc; i++) {                             )
+    QUOTE(          command_len += strlen(argv[i]) + 1;                  )
+    QUOTE(      }                                                        )
+    QUOTE(      command = (char*)calloc(command_len, sizeof(char));      )
+    QUOTE(      if (command == NULL) {                                   )
+    QUOTE(          fprintf(stderr, "calloc failed\n");                  )
+    QUOTE(          exit(1);                                             )
+    QUOTE(      }                                                        )
+    QUOTE(      for (i = 1; i < argc; i++) {                             )
+    QUOTE(          strcat( strcat(command, " "), argv[i] );             )
+    QUOTE(      }                                                        )
+                /* Redirect all output to /dev/null or equivalent. */
+    QUOTE(      freopen("%s", "w", stdout);                              )
+    QUOTE(      freopen("%s", "w", stderr);                              )
+                /* Run commmand and return its value to parent. */
+    QUOTE(      retval = system(command);                                )
+    QUOTE(      free(command);                                           )
+    QUOTE(      return retval;                                           )
+    QUOTE(  }                                                            );
 
 static void
 S_build_charm_run()
 {
     chaz_bool_t compile_succeeded = false;
     const char *dev_null = OS_dev_null();
-    size_t needed = sizeof(charm_run_code_a)
-                  + sizeof(charm_run_code_b)
+    size_t needed = sizeof(charm_run_code)
                   + strlen(dev_null)
-                  + sizeof(charm_run_code_c)
                   + strlen(dev_null)
-                  + sizeof(charm_run_code_d)
                   + 20;
     char *code = (char*)malloc(needed);
 
-    sprintf(code, "%s%s \"%s\" %s \"%s\" %s", 
-        charm_run_code_a, 
-        charm_run_code_b,
-        dev_null,
-        charm_run_code_c,
-        dev_null,
-        charm_run_code_d);
+    sprintf(code, charm_run_code, dev_null, dev_null);
     compile_succeeded = CC_compile_exe("_charm_run.c", "_charm_run", 
         code, strlen(code));
     if (!compile_succeeded) {

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=904951&r1=904950&r2=904951&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Stat.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Stat.c Sun Jan 31 01:54:51 2010
@@ -52,18 +52,18 @@
 }
 
 /* Source code for the _charm_stat utility. */
-static char charm_stat_code[] = METAQUOTE
-    #include <stdio.h>
-    #include <sys/stat.h>
-    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; }
-        fprintf(out_fh, "%ld %ld\n", (long)st.st_size, (long)st.st_blocks);
-        return 0;
-    }
-METAQUOTE;
+static char charm_stat_code[] = 
+    QUOTE(  #include <stdio.h>                                     )
+    QUOTE(  #include <sys/stat.h>                                  )
+    QUOTE(  int main(int argc, char **argv) {                      )
+    QUOTE(      FILE *out_fh = fopen("_charm_statout", "w+");      )
+    QUOTE(      struct stat st;                                    )
+    QUOTE(      if (argc != 2) { return 1; }                       )
+    QUOTE(      if (stat(argv[1], &st) == -1) { return 2; }        )
+    QUOTE(      fprintf(out_fh, "%ld ", (long)st.st_size);         )
+    QUOTE(      fprintf(out_fh, "%ld\n", (long)st.st_blocks);      )
+    QUOTE(      return 0;                                          )
+    QUOTE(  }                                                      );
 
 static void
 S_init()

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.c?rev=904951&r1=904950&r2=904951&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.c Sun Jan 31 01:54:51 2010
@@ -57,17 +57,12 @@
     return ConfWriter_get_charmony_fh();
 }
 
-static char charm_h_code[] = METAQUOTE
-    #ifndef CHARM_H
-    #define CHARM_H 1
-
-    #include <stdio.h>
-
-    #define Charm_Setup \
-        freopen("_charmonizer_target", "w", stdout)
-    
-    #endif
-METAQUOTE;
+static char charm_h_code[] =
+    QUOTE(  #ifndef CHARM_H                                                  )
+    QUOTE(  #define CHARM_H 1                                                )
+    QUOTE(  #include <stdio.h>                                               )
+    QUOTE(  #define Charm_Setup freopen("_charmonizer_target", "w", stdout)  )
+    QUOTE(  #endif                                                           );
 
 static void
 S_write_charm_h()

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.c?rev=904951&r1=904950&r2=904951&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.c Sun Jan 31 01:54:51 2010
@@ -9,35 +9,32 @@
 #include <stdlib.h>
 
 /* code for verifying ISO func macro */
-static char iso_func_code[] = METAQUOTE
-    #include "_charm.h" 
-    int main() {
-        Charm_Setup;
-        printf("%s", __func__);
-        return 0;
-    }
-METAQUOTE;
+static char iso_func_code[] =
+    QUOTE(  #include "_charm.h"               )
+    QUOTE(  int main() {                      )
+    QUOTE(      Charm_Setup;                  )
+    QUOTE(      printf("%s", __func__);       )
+    QUOTE(      return 0;                     )
+    QUOTE(  }                                 );
 
 /* code for verifying GNU func macro */
-static char gnuc_func_code[] = METAQUOTE
-    #include "_charm.h" 
-    int main() {
-        Charm_Setup;
-        printf("%s", __FUNCTION__);
-        return 0;
-    }
-METAQUOTE;
+static char gnuc_func_code[] = 
+    QUOTE(  #include "_charm.h"               )
+    QUOTE(  int main() {                      )
+    QUOTE(      Charm_Setup;                  )
+    QUOTE(      printf("%s", __FUNCTION__);   )
+    QUOTE(      return 0;                     )
+    QUOTE(  }                                 );
 
 /* code for verifying inline keyword */
-static char inline_code[] = METAQUOTE
-    #include "_charm.h" 
-    static %s int foo() { return 1; }
-    int main() {
-        Charm_Setup;
-        printf("%%d", foo());
-        return 0;
-    }
-METAQUOTE;
+static char inline_code[] =
+    QUOTE(  #include "_charm.h"               )
+    QUOTE(  static %s int foo() { return 1; } )
+    QUOTE(  int main() {                      )
+    QUOTE(      Charm_Setup;                  )
+    QUOTE(      printf("%%d", foo());         )
+    QUOTE(      return 0;                     )
+    QUOTE(  }                                 );
 
 static char*
 S_try_inline(const char *keyword, size_t *output_len) {

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.c?rev=904951&r1=904950&r2=904951&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.c Sun Jan 31 01:54:51 2010
@@ -14,41 +14,37 @@
 static chaz_bool_t
 S_machine_is_big_endian();
 
-static char sizes_code[] = METAQUOTE
-    #include "_charm.h"
-    int main () {
-        Charm_Setup;
-        printf("%d %d %d %d %d",
-            (int)sizeof(char),
-            (int)sizeof(short),
-            (int)sizeof(int),
-            (int)sizeof(long),
-            (int)sizeof(void *)
-        );
-        return 0;
-    }
-METAQUOTE;
-
-static char type64_code[] = METAQUOTE
-    #include "_charm.h"
-    int main() 
-    {
-        Charm_Setup;
-        printf("%%d", (int)sizeof(%s));
-        return 0;
-    }
-METAQUOTE;
-
-static char literal64_code[] = METAQUOTE
-    #include "_charm.h"
-    #define big 9000000000000000000%s
-    int main()
-    {
-        Charm_Setup;
-        printf("1\n");
-        return 0;
-    }
-METAQUOTE;
+static char sizes_code[] = 
+    QUOTE(  #include "_charm.h"                       )
+    QUOTE(  int main () {                             )
+    QUOTE(      Charm_Setup;                          )
+    QUOTE(      printf("%d ", (int)sizeof(char));     )
+    QUOTE(      printf("%d ", (int)sizeof(short));    )
+    QUOTE(      printf("%d ", (int)sizeof(int));      )
+    QUOTE(      printf("%d ", (int)sizeof(long));     )
+    QUOTE(      printf("%d ", (int)sizeof(void*));    )
+    QUOTE(      return 0;                             )
+    QUOTE(  }                                         );
+
+static char type64_code[] =
+    QUOTE(  #include "_charm.h"                       )
+    QUOTE(  int main()                                )
+    QUOTE(  {                                         )
+    QUOTE(      Charm_Setup;                          )
+    QUOTE(      printf("%%d", (int)sizeof(%s));       )
+    QUOTE(      return 0;                             )
+    QUOTE(  }                                         );
+
+static char literal64_code[] = 
+    QUOTE(  #include "_charm.h"                       )
+    QUOTE(  #define big 9000000000000000000%s         )
+    QUOTE(  int main()                                )
+    QUOTE(  {                                         )
+    QUOTE(      Charm_Setup;                          )
+    QUOTE(      int truncated = (int)big;             )
+    QUOTE(      printf("%%d\n", truncated);           )
+    QUOTE(      return 0;                             )
+    QUOTE(  }                                         );
 
 void
 Integers_run(void) 
@@ -76,7 +72,7 @@
     char i64_t_type[10];
     char i64_t_postfix[10];
     char u64_t_postfix[10];
-    char code_buf[sizeof(type64_code) + 200];
+    char code_buf[1000];
 
     ConfWriter_start_module("Integers");
 
@@ -306,25 +302,18 @@
         };
 
         /* buffer to hold the code, and its start and end */
-        char format_64_code[1000];
-        static char format_64_code_a[] = METAQUOTE
-            #include "_charm.h"
-            int main() {
-                Charm_Setup;
-                printf(
-        METAQUOTE;
-        static char format_64_code_b[] = METAQUOTE
-                );
-                return 0;
-            }
-        METAQUOTE;
+        static char format_64_code[] = 
+            QUOTE(  #include "_charm.h"                           )
+            QUOTE(  int main() {                                  )
+            QUOTE(      Charm_Setup;                              )
+            QUOTE(      printf("%%%su", 18446744073709551615%s);  )
+            QUOTE(      return 0;                                 )
+            QUOTE( }                                              );
 
         for (i = 0; options[i] != NULL; i++) {
             /* try to print 2**64-1, and see if we get it back intact */
-            sprintf(format_64_code, 
-                "%s\"%%%su\", 18446744073709551615%s%s", format_64_code_a, 
-                    options[i], u64_t_postfix, format_64_code_b);
-            output = CC_capture_output(format_64_code, strlen(format_64_code),
+            sprintf(code_buf, format_64_code, options[i], u64_t_postfix);
+            output = CC_capture_output(code_buf, strlen(code_buf),
                 &output_len);
 
             if (   output_len != 0 

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.c?rev=904951&r1=904950&r2=904951&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.c Sun Jan 31 01:54:51 2010
@@ -173,21 +173,20 @@
 }
 
 /* code for checking ftello64 and friends */
-static char off64_code[] = METAQUOTE
-    %s
-    #include "_charm.h"
-    int main() {
-        %s pos;
-        FILE *f;
-        Charm_Setup;
-        f = %s("_charm_off64", "w");
-        if (f == NULL) return -1;
-        printf("%%d", (int)sizeof(%s));
-        pos = %s(stdout);
-        %s(stdout, 0, SEEK_SET);
-        return 0;
-    }
-METAQUOTE;
+static char off64_code[] = 
+    QUOTE(  %s                                         )
+    QUOTE(  #include "_charm.h"                        )
+    QUOTE(  int main() {                               )
+    QUOTE(      %s pos;                                )
+    QUOTE(      FILE *f;                               )
+    QUOTE(      Charm_Setup;                           )
+    QUOTE(      f = %s("_charm_off64", "w");           )
+    QUOTE(      if (f == NULL) return -1;              )
+    QUOTE(      printf("%%d", (int)sizeof(%s));        )
+    QUOTE(      pos = %s(stdout);                      )
+    QUOTE(      %s(stdout, 0, SEEK_SET);               )
+    QUOTE(      return 0;                              )
+    QUOTE(  }                                          );
 
 
 static chaz_bool_t
@@ -226,20 +225,19 @@
 }
 
 /* Code for checking 64-bit lseek. */
-static char lseek_code[] = METAQUOTE
-    %s
-    #include "_charm.h"
-    int main() {
-        int fd;
-        Charm_Setup;
-        fd = open("_charm_lseek", O_WRONLY | O_CREAT, 0666);
-        if (fd == -1) { return -1; }
-        %s(fd, 0, SEEK_SET);
-        printf("%%d", 1);
-        if (close(fd)) { return -1; }
-        return 0;
-    }
-METAQUOTE;
+static char lseek_code[] = 
+    QUOTE(  %s                                                        )
+    QUOTE(  #include "_charm.h"                                       )
+    QUOTE(  int main() {                                              )
+    QUOTE(      int fd;                                               )
+    QUOTE(      Charm_Setup;                                          )
+    QUOTE(      fd = open("_charm_lseek", O_WRONLY | O_CREAT, 0666);  )
+    QUOTE(      if (fd == -1) { return -1; }                          )
+    QUOTE(      %s(fd, 0, SEEK_SET);                                  )
+    QUOTE(      printf("%%d", 1);                                     )
+    QUOTE(      if (close(fd)) { return -1; }                         )
+    QUOTE(      return 0;                                             )
+    QUOTE(  }                                                         );
 
 static chaz_bool_t
 S_probe_lseek(unbuff_combo *combo)
@@ -269,18 +267,17 @@
 
 /* Code for checking 64-bit pread.  The pread call will fail, but that's fine
  * as long as it compiles. */
-static char pread64_code[] = METAQUOTE
-    %s
-    #include "_charm.h"
-    int main() {
-        int fd = 20;
-        char buf[1];
-        Charm_Setup;
-        printf("1");
-        %s(fd, buf, 1, 1);
-        return 0;
-    }
-METAQUOTE;
+static char pread64_code[] = 
+    QUOTE(  %s                                     )
+    QUOTE(  #include "_charm.h"                    )
+    QUOTE(  int main() {                           )
+    QUOTE(      int fd = 20;                       )
+    QUOTE(      char buf[1];                       )
+    QUOTE(      Charm_Setup;                       )
+    QUOTE(      printf("1");                       )
+    QUOTE(      %s(fd, buf, 1, 1);                 )
+    QUOTE(      return 0;                          )
+    QUOTE(  }                                      );
 
 static chaz_bool_t
 S_probe_pread64(unbuff_combo *combo)
@@ -355,30 +352,25 @@
 }
 
 /* open a file, seek to a loc, print a char, and communicate success */
-static char create_bigfile_code_a[] = METAQUOTE
-    #include "_charm.h"
-    int main() {
-        FILE *fh = fopen("_charm_large_file_test", "w+");
-        int check_seek;
-        Charm_Setup;
-        /* bail unless seek succeeds */
-        check_seek = 
-METAQUOTE;
-
-static char create_bigfile_code_b[] = METAQUOTE
-            (fh, 5000000000, SEEK_SET);
-        if (check_seek == -1)
-            exit(1);
-        /* bail unless we write successfully */
-        if (fprintf(fh, "X") != 1)
-            exit(1);
-        if (fclose(fh))
-            exit(1);
-        /* communicate success to Charmonizer */
-        printf("1");
-        return 0;
-    }
-METAQUOTE;
+static char create_bigfile_code[] = 
+    QUOTE(  #include "_charm.h"                                      )
+    QUOTE(  int main() {                                             )
+    QUOTE(      FILE *fh = fopen("_charm_large_file_test", "w+");    )
+    QUOTE(      int check_seek;                                      )
+    QUOTE(      Charm_Setup;                                         )
+                /* bail unless seek succeeds */
+    QUOTE(      check_seek = %s(fh, 5000000000, SEEK_SET);           )
+    QUOTE(      if (check_seek == -1)                                )
+    QUOTE(          exit(1);                                         )
+                /* bail unless we write successfully */
+    QUOTE(      if (fprintf(fh, "X") != 1)                           )
+    QUOTE(          exit(1);                                         )
+    QUOTE(      if (fclose(fh))                                      )
+    QUOTE(          exit(1);                                         )
+                /* communicate success to Charmonizer */
+    QUOTE(      printf("1");                                         )
+    QUOTE(      return 0;                                            )
+    QUOTE(  }                                                        );
 
 static chaz_bool_t
 S_can_create_big_files()
@@ -386,15 +378,13 @@
     char *output;
     size_t output_len;
     FILE *truncating_fh;
-    size_t needed = strlen(create_bigfile_code_a)
+    size_t needed = strlen(create_bigfile_code)
                   + strlen(fseek_command)
-                  + strlen(create_bigfile_code_b)
                   + 10;
     char *code_buf = (char*)malloc(needed);
 
     /* concat the source strings, compile the file, capture output */
-    sprintf(code_buf, "%s%s%s", create_bigfile_code_a, fseek_command, 
-        create_bigfile_code_b);
+    sprintf(code_buf, create_bigfile_code, fseek_command);
     output = CC_capture_output(code_buf, strlen(code_buf), &output_len);
 
     /* truncate, just in case the call to remove fails */

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/VariadicMacros.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/VariadicMacros.c?rev=904951&r1=904950&r2=904951&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/VariadicMacros.c (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/VariadicMacros.c Sun Jan 31 01:54:51
2010
@@ -9,28 +9,25 @@
 
 
 /* code for verifying ISO-style variadic macros */
-static char iso_code[] = METAQUOTE
-    #include "_charm.h"
-    #define ISO_TEST(fmt, ...) \
-        printf(fmt, __VA_ARGS__)
-    int main() {
-        Charm_Setup;
-        ISO_TEST("%d %d", 1, 1);
-        return 0;
-    }
-METAQUOTE;
+static char iso_code[] = 
+    QUOTE(  #include "_charm.h"                                   )
+    QUOTE(  #define ISO_TEST(fmt, ...) \\                         )
+    "           printf(fmt, __VA_ARGS__)                        \n"
+    QUOTE(  int main() {                                          )
+    QUOTE(      Charm_Setup;                                      )
+    QUOTE(      ISO_TEST("%d %d", 1, 1);                          )
+    QUOTE(      return 0;                                         )
+    QUOTE(  }                                                     );
 
 /* code for verifying GNU-style variadic macros */
-static char gnuc_code[] = METAQUOTE
-    #include "_charm.h"
-    #define GNU_TEST(fmt, args...) \
-        printf(fmt, ##args)
-    int main() {
-        Charm_Setup;
-        GNU_TEST("%d %d", 1, 1);
-        return 0;
-    }
-METAQUOTE;
+static char gnuc_code[] = 
+    QUOTE(  #include "_charm.h"                                   )
+    QUOTE(  #define GNU_TEST(fmt, args...) printf(fmt, ##args)    )
+    QUOTE(  int main() {                                          )
+    QUOTE(      Charm_Setup;                                      )
+    QUOTE(      GNU_TEST("%d %d", 1, 1);                          )
+    QUOTE(      return 0;                                         )
+    QUOTE(  }                                                     );
 
 void
 VariadicMacros_run(void) 



Mime
View raw message