- prev = g_auth;
-#endif
- /* This could stand some work */
- while ((p0 = fgets(buf, sizeof(buf), f)) != NULL) {
- c = NULL;
- for (p = p0; *p0 != '\0' && *p0 != '#'; p0++) {
- if (!isspace(*p0)) {
- *p++ = *p0;
- if (*p0 == ':' && c == NULL)
- c = p;
+ /* in "/file:user:pass" lines, we prepend path in subdirs */
+ if (flag != SUBDIR_PARSE)
+ path = "";
+#endif
+ /* The lines can be:
+ *
+ * I:default_index_file
+ * H:http_home
+ * [AD]:IP[/mask] # allow/deny, * for wildcard
+ * Ennn:error.html # error page for status nnn
+ * P:/url:[http://]hostname[:port]/new/path # reverse proxy
+ * .ext:mime/type # mime type
+ * *.php:/path/php # run xxx.php through an interpreter
+ * /file:user:pass # username and password
+ */
+ while (fgets(buf, sizeof(buf), f) != NULL) {
+ unsigned strlen_buf;
+ unsigned char ch;
+ char *after_colon;
+
+ { /* remove all whitespace, and # comments */
+ char *p, *p0;
+
+ p0 = buf;
+ /* skip non-whitespace beginning. Often the whole line
+ * is non-whitespace. We want this case to work fast,
+ * without needless copying, therefore we don't merge
+ * this operation into next while loop. */
+ while ((ch = *p0) != '\0' && ch != '\n' && ch != '#'
+ && ch != ' ' && ch != '\t'
+ ) {
+ p0++;
+ }
+ p = p0;
+ /* if we enter this loop, we have some whitespace.
+ * discard it */
+ while (ch != '\0' && ch != '\n' && ch != '#') {
+ if (ch != ' ' && ch != '\t') {
+ *p++ = ch;
+ }
+ ch = *++p0;