From 255f723fefb9963a690c2ea32eab8afdb4362fe6 Mon Sep 17 00:00:00 2001 From: Stefan Fritsch Date: Wed, 22 Jun 2011 20:24:27 +0000 Subject: [PATCH] We already have ap_str_tolower(), so also add ap_str_toupper() function and use it where possible. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1138617 13f79535-47bb-0310-9956-ffa450edef68 --- include/ap_mmn.h | 3 ++- include/httpd.h | 6 ++++++ modules/mappers/mod_rewrite.c | 11 ++--------- os/bs2000/os.c | 9 --------- os/unix/unixd.c | 9 --------- server/util.c | 8 ++++++++ server/util_expr_eval.c | 7 +------ 7 files changed, 19 insertions(+), 34 deletions(-) diff --git a/include/ap_mmn.h b/include/ap_mmn.h index f5c9346459..8e7865a785 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -336,6 +336,7 @@ * 20110619.0 (2.3.13-dev) add async connection infos to process_score in scoreboard, * add ap_start_lingering_close(), * add conn_state_e:CONN_STATE_LINGER_NORMAL and CONN_STATE_LINGER_SHORT + * 20110619.1 (2.3.13-dev) add ap_str_toupper() */ #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */ @@ -343,7 +344,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20110619 #endif -#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 1 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/httpd.h b/include/httpd.h index b09a9d040f..38a469bb53 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -1798,6 +1798,12 @@ AP_DECLARE(void) ap_content_type_tolower(char *s); */ AP_DECLARE(void) ap_str_tolower(char *s); +/** + * convert a string to all uppercase + * @param s The string to convert to uppercase + */ +AP_DECLARE(void) ap_str_toupper(char *s); + /** * Search a string from left to right for the first occurrence of a * specific character diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index 08bd02e531..f7f02b582d 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -1051,11 +1051,7 @@ static int init_cache(apr_pool_t *p) static char *rewrite_mapfunc_toupper(request_rec *r, char *key) { - char *p; - - for (p = key; *p; ++p) { - *p = apr_toupper(*p); - } + ap_str_toupper(key); return key; } @@ -1849,13 +1845,10 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx) /* well, do it the hard way */ else { - char *p; apr_time_exp_t tm; /* can't do this above, because of the getenv call */ - for (p = var; *p; ++p) { - *p = apr_toupper(*p); - } + ap_str_toupper(var); switch (varlen) { case 4: diff --git a/os/bs2000/os.c b/os/bs2000/os.c index d0f2164594..0869ff4cbf 100644 --- a/os/bs2000/os.c +++ b/os/bs2000/os.c @@ -42,15 +42,6 @@ typedef enum static bs2_ForkType forktype = bs2_unknown; - -static void ap_str_toupper(char *str) -{ - while (*str) { - *str = apr_toupper(*str); - ++str; - } -} - /* Determine the method for forking off a child in such a way as to * set both the POSIX and BS2000 user id's to the unprivileged user. */ diff --git a/os/unix/unixd.c b/os/unix/unixd.c index db5d328e47..e29fb16d1d 100644 --- a/os/unix/unixd.c +++ b/os/unix/unixd.c @@ -453,15 +453,6 @@ typedef enum static bs2_ForkType forktype = bs2_unknown; - -static void ap_str_toupper(char *str) -{ - while (*str) { - *str = apr_toupper(*str); - ++str; - } -} - /* Determine the method for forking off a child in such a way as to * set both the POSIX and BS2000 user id's to the unprivileged user. */ diff --git a/server/util.c b/server/util.c index 86b7843c45..51e8becb93 100644 --- a/server/util.c +++ b/server/util.c @@ -1889,6 +1889,14 @@ AP_DECLARE(void) ap_str_tolower(char *str) } } +AP_DECLARE(void) ap_str_toupper(char *str) +{ + while (*str) { + *str = apr_toupper(*str); + ++str; + } +} + /* * We must return a FQDN */ diff --git a/server/util_expr_eval.c b/server/util_expr_eval.c index 99fb21dac0..3771caeb5e 100644 --- a/server/util_expr_eval.c +++ b/server/util_expr_eval.c @@ -831,13 +831,8 @@ static const char *tolower_func(ap_expr_eval_ctx_t *ctx, const void *data, static const char *toupper_func(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg) { - char *p; char *result = apr_pstrdup(ctx->p, arg); - - for (p = result; *p; ++p) { - *p = apr_toupper(*p); - } - + ap_str_toupper(result); return result; } -- 2.40.0