]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Make compilable on Windows again. I'm not sure the x = { [1] = 1 }
authorKen Coar <coar@apache.org>
Mon, 14 Aug 2000 21:33:27 +0000 (21:33 +0000)
committerKen Coar <coar@apache.org>
Mon, 14 Aug 2000 21:33:27 +0000 (21:33 +0000)
syntax is even ANSI C, but it originally compiled for me.  Oh, well.
I'd rather have this statically built at compile time, but I don't
want to add the dependencies on the method order and its being
a contiguous sequence.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86073 13f79535-47bb-0310-9956-ffa450edef68

modules/http/http_protocol.c

index 87ad70eaf0b4e602404da2d5688ec78b84c68870..caea143c51a2a653fd9740bf1960fb2c651a3478 100644 (file)
@@ -811,26 +811,44 @@ API_EXPORT(int) ap_method_number_of(const char *method)
     return M_INVALID;
 }
 
+/*
+ * Turn a known method number into a name.  Doesn't work for
+ * extension methods, obviously.
+ */
 API_EXPORT(const char *) ap_method_name_of(int methnum) {
-    static const char *AP_HTTP_METHODS[] = {
-       [M_GET]       = "GET",
-       [M_PUT]       = "PUT",
-       [M_POST]      = "POST",
-       [M_DELETE]    = "DELETE",
-       [M_CONNECT]   = "CONNECT",
-       [M_OPTIONS]   = "OPTIONS",
-       [M_TRACE]     = "TRACE",
-       [M_PATCH]     = "PATCH",
-       [M_PROPFIND]  = "PROPFIND",
-       [M_PROPPATCH] = "PROPPATCH",
-       [M_MKCOL]     = "MKCOL",
-       [M_COPY]      = "COPY",
-       [M_MOVE]      = "MOVE",
-       [M_LOCK]      = "LOCK",
-       [M_UNLOCK]    = "UNLOCK",
-       [M_INVALID]   = NULL
-    };
-    
+    static const char *AP_HTTP_METHODS[METHODS] = { NULL };
+
+    /*
+     * This is ugly, but the previous incantation made Windows C
+     * varf.  I'm not even sure it was ANSI C.  However, ugly as it
+     * is, this works, and we only have to do it once.
+     */
+    if (AP_HTTP_METHODS[0] == NULL) {
+       AP_HTTP_METHODS[M_GET]       = "GET";
+       AP_HTTP_METHODS[M_PUT]       = "PUT";
+       AP_HTTP_METHODS[M_POST]      = "POST";
+       AP_HTTP_METHODS[M_DELETE]    = "DELETE";
+       AP_HTTP_METHODS[M_CONNECT]   = "CONNECT";
+       AP_HTTP_METHODS[M_OPTIONS]   = "OPTIONS";
+       AP_HTTP_METHODS[M_TRACE]     = "TRACE";
+       AP_HTTP_METHODS[M_PATCH]     = "PATCH";
+       AP_HTTP_METHODS[M_PROPFIND]  = "PROPFIND";
+       AP_HTTP_METHODS[M_PROPPATCH] = "PROPPATCH";
+       AP_HTTP_METHODS[M_MKCOL]     = "MKCOL";
+       AP_HTTP_METHODS[M_COPY]      = "COPY";
+       AP_HTTP_METHODS[M_MOVE]      = "MOVE";
+       AP_HTTP_METHODS[M_LOCK]      = "LOCK";
+       AP_HTTP_METHODS[M_UNLOCK]    = "UNLOCK";
+       AP_HTTP_METHODS[M_INVALID]   = NULL;
+       /*
+        * Since we're using symbolic names, make sure we only do
+        * this once by forcing a value into the first slot IFF it's
+        * still NULL.
+        */
+       if (AP_HTTP_METHODS[0] == NULL) {
+           AP_HTTP_METHODS[0] = "INVALID";
+       }
+    }
 
     if ((methnum == M_INVALID) || (methnum >= METHODS)) {
        return NULL;