Author: fuankg Date: Mon Apr 16 07:49:52 2007 New Revision: 529274 URL: http://svn.apache.org/viewvc?view=rev&rev=529274 Log: removed sprintf() / vsprintf() hacks; removed old vsnprintf() implementation.
Modified: tomcat/connectors/trunk/jk/native/common/jk_status.c tomcat/connectors/trunk/jk/native/common/jk_util.c Modified: tomcat/connectors/trunk/jk/native/common/jk_status.c URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_status.c?view=diff&rev=529274&r1=529273&r2=529274 ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_status.c (original) +++ tomcat/connectors/trunk/jk/native/common/jk_status.c Mon Apr 16 07:49:52 2007 @@ -323,28 +323,6 @@ HEADERS_NO_CACHE }; -#if !defined(HAVE_VSNPRINTF) && !defined(HAVE_APR) -static FILE *f = NULL; -static int vsnprintf(char *str, size_t n, const char *fmt, va_list ap) -{ - int res; - - if (f == NULL) - f = fopen("/dev/null", "w"); - if (f == NULL) - return -1; - - setvbuf(f, str, _IOFBF, n); - - res = vfprintf(f, fmt, ap); - - if (res > 0 && res < n) { - res = vsprintf(str, fmt, ap); - } - return res; -} -#endif - static void jk_puts(jk_ws_service_t *s, const char *str) { if (str) @@ -390,11 +368,7 @@ if (NULL == buf) return -1; #endif -#ifdef USE_VSPRINTF /* until we get a vsnprintf function */ - rc = vsprintf(buf, fmt, args); -#else rc = vsnprintf(buf, HUGE_BUFFER_SIZE, fmt, args); -#endif va_end(args); if (rc > 0) s->write(s, buf, rc); Modified: tomcat/connectors/trunk/jk/native/common/jk_util.c URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_util.c?view=diff&rev=529274&r1=529273&r2=529274 ============================================================================== --- tomcat/connectors/trunk/jk/native/common/jk_util.c (original) +++ tomcat/connectors/trunk/jk/native/common/jk_util.c Mon Apr 16 07:49:52 2007 @@ -352,46 +352,6 @@ return (int)strftime(str, len, JK_TIME_FORMAT, tms); } -/* Write at most n characters to the buffer in str, return the - * number of chars written or -1 if the buffer would have been - * overflowed. - * - * This is portable to any POSIX-compliant system that has /dev/null - */ -#if !defined(HAVE_VSNPRINTF) && !defined(HAVE_APR) -static FILE *f = NULL; -static int vsnprintf(char *str, size_t n, const char *fmt, va_list ap) -{ - int res; - - if (f == NULL) - f = fopen("/dev/null", "w"); - if (f == NULL) - return -1; - - setvbuf(f, str, _IOFBF, n); - - res = vfprintf(f, fmt, ap); - - if (res > 0 && res < n) { - res = vsprintf(str, fmt, ap); - } - return res; -} -#endif -#if !defined(HAVE_SNPRINTF) && !defined(HAVE_APR) -static int snprintf(char *str, size_t n, const char *fmt, ...) -{ - va_list ap; - int res; - - va_start(ap, fmt); - res = vsnprintf(str, n, fmt, ap); - va_end(ap); - return res; -} -#endif - static int JK_METHOD log_to_file(jk_logger_t *l, int level, const char *what) { if (l && @@ -530,13 +490,8 @@ /* This information helps to correlate lines from different logs. */ /* Performance is no issue, because with production log levels */ /* we only call it often, if we have a lot of errors */ -#ifdef USE_SPRINTF /* until we get a snprintf function */ - rc = sprintf(&buf[used], "[%04d:%04d] ", getpid(), - jk_gettid()); -#else rc = snprintf(&buf[used], usable_size - used, "[%04d:%04d] ", getpid(), jk_gettid()); -#endif used += rc; if (rc < 0 || usable_size - used < 8) { return 0; @@ -553,12 +508,8 @@ } } -#ifdef USE_SPRINTF /* until we get a snprintf function */ - rc = sprintf(&buf[used], "%s (%d): ", f, line); -#else rc = snprintf(&buf[used], usable_size - used, "%s (%d): ", f, line); -#endif used += rc; if (rc < 0 || usable_size - used < 0) { return 0; /* [V] not sure what to return... */ @@ -566,11 +517,7 @@ } va_start(args, fmt); -#ifdef USE_VSPRINTF /* until we get a vsnprintf function */ - rc = vsprintf(buf + used, fmt, args); -#else rc = vsnprintf(buf + used, usable_size - used, fmt, args); -#endif va_end(args); if ( rc <= usable_size - used ) { used += rc; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]