From f8300b56ba4cb1df7fe3484008ea7620f535f8db Mon Sep 17 00:00:00 2001 From: Paul Querna Date: Sun, 5 Sep 2004 02:11:16 +0000 Subject: [PATCH] Remove the use of sprintf. Cleanup the history parts at the top of mod_info.c git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@104981 13f79535-47bb-0310-9956-ffa450edef68 --- modules/generators/mod_info.c | 50 ++++++++++++++++------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/modules/generators/mod_info.c b/modules/generators/mod_info.c index 1a90fbc1ed..6d84f7f0e4 100644 --- a/modules/generators/mod_info.c +++ b/modules/generators/mod_info.c @@ -27,25 +27,15 @@ * GET /server-info?list - Returns quick list of included modules * GET /server-info?config - Returns full configuration * - * Rasmus Lerdorf , May 1996 + * Original Author: + * Rasmus Lerdorf , May 1996 * - * 05.01.96 Initial Version + * Modified By: + * Lou Langholtz , July 1997 * - * Lou Langholtz , July 1997 - * - * 07.11.97 Addition of the AddModuleInfo directive - * - * Ryan Morgan + * Apache 2.0 Port: + * Ryan Morgan , August 2000 * - * 8.11.00 Port to Apache 2.0. Read configuation from the configuration - * tree rather than reparse the entire configuation file. - * - * Rici Lake - * - * 2004-08-28 Rewrote config tree walk using recursion the way God intended. - * Added ?config option. Added printout of config filename and line numbers. - * Fixed indentation. - * */ #define CORE_PRIVATE @@ -98,13 +88,22 @@ static void *merge_info_config(apr_pool_t * p, void *basev, void *overridesv) return new; } -static void mod_info_indent(request_rec *r, int nest, const char *thisfn, - int linenum) +static void put_int_flush_right(request_rec *r, int i, int field) +{ + if (field > 1 || i > 9) + put_int_flush_right(r, i / 10, field - 1); + if (i) + ap_rputc('0' + i % 10, r); + else + ap_rputs(" ", r); +} + +static void mod_info_indent(request_rec *r, int nest, + const char *thisfn, int linenum) { int i; const char *prevfn = ap_get_module_config(r->request_config, &info_module); - char buf[32]; if (thisfn == NULL) thisfn = "*UNKNOWN*"; if (prevfn == NULL || 0 != strcmp(prevfn, thisfn)) { @@ -113,17 +112,14 @@ static void mod_info_indent(request_rec *r, int nest, const char *thisfn, thisfn); ap_set_module_config(r->request_config, &info_module, thisfn); } + ap_rputs("
", r); - if (linenum > 0) - sprintf(buf, "%d", linenum); - else - buf[0] = '\0'; - for (i = strlen(buf); i < 4; ++i) - ap_rputs(" ", r); - ap_rputs(buf, r); + put_int_flush_right(r, linenum > 0 ? linenum : 0, 4); ap_rputs(": ", r); - for (i = 1; i <= nest; ++i) + + for (i = 1; i <= nest; ++i) { ap_rputs("  ", r); + } } static void mod_info_show_cmd(request_rec *r, const ap_directive_t * dir, -- 2.50.1