You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2015/12/29 23:40:23 UTC

svn commit: r1722243 - in /httpd/httpd/trunk: include/ap_mmn.h include/httpd.h server/util.c

Author: jim
Date: Tue Dec 29 22:40:21 2015
New Revision: 1722243

URL: http://svn.apache.org/viewvc?rev=1722243&view=rev
Log:
Ok... allow for getting "words" by also allowing the
use of curlies... That is:

   "Hello World" Foo Bar

and

   {Hello World} Foo Bar

will both return the same if using ap_getword_conf2()

Modified:
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/httpd.h
    httpd/httpd/trunk/server/util.c

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1722243&r1=1722242&r2=1722243&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Tue Dec 29 22:40:21 2015
@@ -496,6 +496,7 @@
  *                         conn_rec.
  * 20150222.6 (2.5.0-dev)  Add async_filter to conn_rec.
  * 20150222.7 (2.5.0-dev)  Add ap_casecmpstr[n]();
+ * 20150222.8 (2.5.0-dev)  Add ap_getword_conf2[_nc]();
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */

Modified: httpd/httpd/trunk/include/httpd.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/httpd.h?rev=1722243&r1=1722242&r2=1722243&view=diff
==============================================================================
--- httpd/httpd/trunk/include/httpd.h (original)
+++ httpd/httpd/trunk/include/httpd.h Tue Dec 29 22:40:21 2015
@@ -1533,6 +1533,25 @@ AP_DECLARE(char *) ap_getword_conf(apr_p
 AP_DECLARE(char *) ap_getword_conf_nc(apr_pool_t *p, char **line);
 
 /**
+ * Get the second word in the string paying attention to quoting.
+ * The format {...} can be used instead of quotes with this implementation
+ * @param p The pool to allocate from
+ * @param line The line to traverse
+ * @return A copy of the string
+ */
+AP_DECLARE(char *) ap_getword_conf2(apr_pool_t *p, const char **line);
+
+/**
+ * Get the second word in the string paying attention to quoting
+ * The format {...} can be used instead of quotes with this implementation
+ * @param p The pool to allocate from
+ * @param line The line to traverse
+ * @return A copy of the string
+ * @note The same as ap_getword_conf2(), except it doesn't use const char **.
+ */
+AP_DECLARE(char *) ap_getword_conf2_nc(apr_pool_t *p, char **line);
+
+/**
  * Check a string for any config define or environment variable construct
  * and replace each of them by the value of that variable, if it exists.
  * The default syntax of the constructs is ${ENV} but can be changed by

Modified: httpd/httpd/trunk/server/util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?rev=1722243&r1=1722242&r2=1722243&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util.c (original)
+++ httpd/httpd/trunk/server/util.c Tue Dec 29 22:40:21 2015
@@ -772,16 +772,12 @@ static char *substring_conf(apr_pool_t *
 #endif
 }
 
-AP_DECLARE(char *) ap_getword_conf_nc(apr_pool_t *p, char **line)
-{
-    return ap_getword_conf(p, (const char **) line);
-}
-
-AP_DECLARE(char *) ap_getword_conf(apr_pool_t *p, const char **line)
+static char *getword_conf_ex(apr_pool_t *p, const char **line, int curlyok)
 {
     const char *str = *line, *strend;
     char *res;
     char quote;
+    char curly = '{';
 
     while (apr_isspace(*str))
         ++str;
@@ -791,7 +787,11 @@ AP_DECLARE(char *) ap_getword_conf(apr_p
         return "";
     }
 
-    if ((quote = *str) == '"' || quote == '\'') {
+    if ((quote = *str) == '"' || quote == '\'' || quote == (curlyok ? curly : '\'')) {
+        if (quote == curly) {
+            /* only true if curlyok and we matched */
+            quote = '}';
+        }
         strend = str + 1;
         while (*strend && *strend != quote) {
             if (*strend == '\\' && strend[1] &&
@@ -821,6 +821,26 @@ AP_DECLARE(char *) ap_getword_conf(apr_p
     return res;
 }
 
+AP_DECLARE(char *) ap_getword_conf_nc(apr_pool_t *p, char **line)
+{
+    return getword_conf_ex(p, (const char **) line, 0);
+}
+
+AP_DECLARE(char *) ap_getword_conf(apr_pool_t *p, const char **line)
+{
+    return getword_conf_ex(p, line, 0);
+}
+
+AP_DECLARE(char *) ap_getword_conf2_nc(apr_pool_t *p, char **line)
+{
+    return getword_conf_ex(p, (const char **) line, 1);
+}
+
+AP_DECLARE(char *) ap_getword_conf2(apr_pool_t *p, const char **line)
+{
+    return getword_conf_ex(p, line, 1);
+}
+
 AP_DECLARE(int) ap_cfg_closefile(ap_configfile_t *cfp)
 {
 #ifdef DEBUG