From 9932750345d1382fe831e73e8359b8c22b313c74 Mon Sep 17 00:00:00 2001 From: stefanocasazza Date: Mon, 2 Mar 2015 20:08:48 +0100 Subject: [PATCH] Setting for FrameworkBenchmarks participations --- src/ulib/file_config.cpp | 38 +++++++++++++------ .../net/server/plugin/usp/usp_translator.cpp | 26 +++++++++---- 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/src/ulib/file_config.cpp b/src/ulib/file_config.cpp index befe5f29..5bec3965 100644 --- a/src/ulib/file_config.cpp +++ b/src/ulib/file_config.cpp @@ -74,19 +74,26 @@ bool UFileConfig::processData() # define DBG_DEF # endif -# ifdef HAVE_MCPP - command.snprintf("mcpp -P -C " DBG_DEF "-I%.*s -", U_STRING_TO_TRACE(_dir)); -# else - command.snprintf("cpp -undef -nostdinc -w -P -C " DBG_DEF "-I%.*s -", U_STRING_TO_TRACE(_dir)); -# endif - if (fd_stderr == 0) fd_stderr = UServices::getDevNull("/tmp/cpp.err"); + command.snprintf("cpp -undef -nostdinc -w -P -C " DBG_DEF "-I%.*s -", U_STRING_TO_TRACE(_dir)); + if (UFile::isOpen()) { (void) UFile::lseek(U_SEEK_BEGIN, SEEK_SET); data = UCommand::outputCommand(command, environ, UFile::getFd(), fd_stderr); + +# ifdef HAVE_MCPP + if (data.empty()) + { + command.snprintf("mcpp -P -C " DBG_DEF "-I%.*s -", U_STRING_TO_TRACE(_dir)); + + (void) UFile::lseek(U_SEEK_BEGIN, SEEK_SET); + + data = UCommand::outputCommand(command, environ, UFile::getFd(), fd_stderr); + } +# endif } else { @@ -99,11 +106,20 @@ bool UFileConfig::processData() UServer_Base::logCommandMsgError(cmd.getCommand(), true); # endif - // ------------------------------------------ - // NB: sometime we have problem with comments - // ------------------------------------------ - // if (esito == false) U_RETURN(false); - // ------------------------------------------ +# ifdef HAVE_MCPP + if (data.empty()) + { + UCommand _cmd(command); + + command.snprintf("mcpp -P -C " DBG_DEF "-I%.*s -", U_STRING_TO_TRACE(_dir)); + + (void) _cmd.execute(&data, &output, -1, fd_stderr); + +# ifndef U_LOG_DISABLE + UServer_Base::logCommandMsgError(_cmd.getCommand(), true); +# endif + } +# endif data = output; } diff --git a/src/ulib/net/server/plugin/usp/usp_translator.cpp b/src/ulib/net/server/plugin/usp/usp_translator.cpp index ba1d02b9..a4d14394 100644 --- a/src/ulib/net/server/plugin/usp/usp_translator.cpp +++ b/src/ulib/net/server/plugin/usp/usp_translator.cpp @@ -113,17 +113,19 @@ public: if (usp.empty()) U_ERROR("filename not valid"); + bool bpreprocessing_failed = false; + if (usp.find(U_CONSTANT_TO_PARAM("\n#ifdef DEBUG")) != U_NOT_FOUND) { - UString before = UStringExt::substitute(usp, U_CONSTANT_TO_PARAM("#include"), U_CONSTANT_TO_PARAM("//#include")); + UFileConfig cfg(UStringExt::substitute(usp, U_CONSTANT_TO_PARAM("#include"), U_CONSTANT_TO_PARAM("//#include")), true); - UFileConfig cfg(before, true); + if (cfg.processData()) usp = UStringExt::substitute(cfg.getData(), U_CONSTANT_TO_PARAM("//#include"), U_CONSTANT_TO_PARAM("#include")); + else + { + bpreprocessing_failed = true; - if (cfg.processData() == false) U_ERROR("preprocessing filename failed"); - - UString after = cfg.getData(); - - usp = UStringExt::substitute(after, U_CONSTANT_TO_PARAM("//#include"), U_CONSTANT_TO_PARAM("#include")); + U_WARNING("preprocessing filename failed"); + } } const char* ptr; @@ -538,10 +540,18 @@ public: if (binit) (void) u__snprintf(ptr1, 100, "\n\t\tif (client_image == (void*)-1) { usp_init_%.*s(); U_RETURN(0); }\n\t", size, ptr); if (breset) (void) u__snprintf(ptr2, 100, "\n\t\tif (client_image == (void*)-2) { usp_reset_%.*s(); U_RETURN(0); }\n\t", size, ptr); - if (bend) (void) u__snprintf(ptr3, 100, "\n\t\tif (client_image == (void*)-3) { usp_end_%.*s(); U_RETURN(0); }\n\t", size, ptr); if (bsighup) (void) u__snprintf(ptr4, 100, "\n\t\tif (client_image == (void*)-4) { usp_sighup_%.*s(); U_RETURN(0); }\n\t", size, ptr); if (bfork) (void) u__snprintf(ptr5, 100, "\n\t\tif (client_image == (void*)-5) { usp_fork_%.*s(); U_RETURN(0); }\n\t", size, ptr); + if (bend) + { +# ifndef DEBUG + if (bpreprocessing_failed) bend = false; + else +# endif + (void) u__snprintf(ptr3, 100, "\n\t\tif (client_image == (void*)-3) { usp_end_%.*s(); U_RETURN(0); }\n\t", size, ptr); + } + if (binit == false || bend == false || breset == false ||