dgaudet     98/03/13 16:50:41

  Modified:    src/main util.c util_script.c
               src/modules/proxy proxy_util.c
  Log:
  ind() isn't as optimized as strchr() is in some C libraries, switch some
  code to use strchr().  I didn't bother touching mod_autoindex or
  mod_speling which both use ind (and rind).
  
  Revision  Changes    Path
  1.99      +18 -19    apache-1.3/src/main/util.c
  
  Index: util.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/util.c,v
  retrieving revision 1.98
  retrieving revision 1.99
  diff -u -r1.98 -r1.99
  --- util.c    1998/03/09 22:42:59     1.98
  +++ util.c    1998/03/14 00:50:38     1.99
  @@ -496,22 +496,22 @@
   
   API_EXPORT(char *) getword(pool *atrans, const char **line, char stop)
   {
  -    int pos = ind(*line, stop);
  +    char *pos = strchr(*line, stop);
       char *res;
   
  -    if (pos == -1) {
  +    if (!pos) {
        res = pstrdup(atrans, *line);
        *line += strlen(*line);
        return res;
       }
   
  -    res = palloc(atrans, pos + 1);
  -    ap_cpystrn(res, *line, pos + 1);
  +    res = pstrndup(atrans, *line, pos - *line);
   
  -    while ((*line)[pos] == stop)
  +    while (*pos == stop) {
        ++pos;
  +    }
   
  -    *line += pos;
  +    *line = pos;
   
       return res;
   }
  @@ -557,21 +557,20 @@
   
   API_EXPORT(char *) getword_nulls(pool *atrans, const char **line, char stop)
   {
  -    int pos = ind(*line, stop);
  +    char *pos = strchr(*line, stop);
       char *res;
   
  -    if (pos == -1) {
  +    if (!pos) {
        res = pstrdup(atrans, *line);
        *line += strlen(*line);
        return res;
       }
   
  -    res = palloc(atrans, pos + 1);
  -    ap_cpystrn(res, *line, pos + 1);
  +    res = pstrndup(atrans, *line, pos - *line);
   
       ++pos;
   
  -    *line += pos;
  +    *line = pos;
   
       return res;
   }
  @@ -1036,7 +1035,7 @@
        }
   #endif
   
  -     if (ind("&;`'\"|*?~<>^()[]{}$\\\n", cmd[x]) != -1) {
  +     if (strchr("&;`'\"|*?~<>^()[]{}$\\\n", cmd[x])) {
            for (y = l + 1; y > x; y--)
                cmd[y] = cmd[y - 1];
            l++;                /* length has been increased */
  @@ -1170,7 +1169,7 @@
   #else /* CHARSET_EBCDIC*/
        if (!isalnum(c)
   #endif /*CHARSET_EBCDIC*/
  -         && ind("$-_.+!*'(),:@&=~", c) == -1) {
  +         && !strchr("$-_.+!*'(),:@&=~", c)) {
            c2x(c, &copy[y]);
            y += 2;
        }
  @@ -1187,10 +1186,10 @@
       char *s = copy;
   
       if (!partial) {
  -     int colon = ind(path, ':');
  -     int slash = ind(path, '/');
  +     char *colon = strchr(path, ':');
  +     char *slash = strchr(path, '/');
   
  -     if (colon >= 0 && (colon < slash || slash < 0)) {
  +     if (colon && (!slash || colon < slash)) {
            *s++ = '.';
            *s++ = '/';
        }
  @@ -1202,7 +1201,7 @@
   #else /* CHARSET_EBCDIC*/
        if (!isalnum(c)
   #endif /*CHARSET_EBCDIC*/
  -         && ind("$-_.+!*'(),:@&=/~", c) == -1) {
  +         && !strchr("$-_.+!*'(),:@&=/~", c)) {
            c2x(c, s);
            s += 3;
        }
  @@ -1574,9 +1573,9 @@
   {
       int x;
   
  -    if (ind(p->h_name, '.') == -1) {
  +    if (!strchr(p->h_name, '.')) {
        for (x = 0; p->h_aliases[x]; ++x) {
  -         if ((ind(p->h_aliases[x], '.') != -1) &&
  +         if (strchr(p->h_aliases[x], '.') &&
                (!strncasecmp(p->h_aliases[x], p->h_name, strlen(p->h_name))))
                return pstrdup(a, p->h_aliases[x]);
        }
  
  
  
  1.103     +7 -7      apache-1.3/src/main/util_script.c
  
  Index: util_script.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/util_script.c,v
  retrieving revision 1.102
  retrieving revision 1.103
  diff -u -r1.102 -r1.103
  --- util_script.c     1998/03/14 00:03:39     1.102
  +++ util_script.c     1998/03/14 00:50:39     1.103
  @@ -660,7 +660,7 @@
            is_script = 0;
        }
   
  -     if ((!r->args) || (!r->args[0]) || (ind(r->args, '=') >= 0)) {
  +     if ((!r->args) || (!r->args[0]) || strchr(r->args, '=')) {
            int emxloop;
            char *emxtemp;
   
  @@ -772,7 +772,7 @@
            }
        }
   
  -     if ((!r->args) || (!r->args[0]) || (ind(r->args, '=') >= 0)) {
  +     if ((!r->args) || (!r->args[0]) || strchr(r->args, '=')) {
            if (is_exe || is_binary) {
                pid = spawnle(_P_NOWAIT, r->filename, r->filename, NULL, env);
            }
  @@ -817,10 +817,10 @@
        if (!strncmp("/~", r->uri, 2)) {
            gid_t user_gid;
            char *username = pstrdup(r->pool, r->uri + 2);
  -         int pos = ind(username, '/');
  +         char *pos = strchr(username, '/');
   
  -         if (pos >= 0)
  -             username[pos] = '\0';
  +         if (pos)
  +             *pos = '\0';
   
            if ((pw = getpwnam(username)) == NULL) {
                aplog_error(APLOG_MARK, APLOG_ERR, r->server,
  @@ -860,7 +860,7 @@
        if (shellcmd)
            execle(SUEXEC_BIN, SUEXEC_BIN, execuser, grpname, argv0, NULL, env);
   
  -     else if ((!r->args) || (!r->args[0]) || (ind(r->args, '=') >= 0))
  +     else if ((!r->args) || (!r->args[0]) || strchr(r->args, '='))
            execle(SUEXEC_BIN, SUEXEC_BIN, execuser, grpname, argv0, NULL, env);
   
        else {
  @@ -874,7 +874,7 @@
        if (shellcmd)
            execle(SHELL_PATH, SHELL_PATH, "-c", argv0, NULL, env);
   
  -     else if ((!r->args) || (!r->args[0]) || (ind(r->args, '=') >= 0))
  +     else if ((!r->args) || (!r->args[0]) || strchr(r->args, '='))
            execle(r->filename, argv0, NULL, env);
   
        else
  
  
  
  1.50      +3 -3      apache-1.3/src/modules/proxy/proxy_util.c
  
  Index: proxy_util.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/modules/proxy/proxy_util.c,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- proxy_util.c      1998/03/09 22:43:01     1.49
  +++ proxy_util.c      1998/03/14 00:50:40     1.50
  @@ -155,7 +155,7 @@
       for (i = 0, j = 0; i < len; i++, j++) {
   /* always handle '/' first */
        ch = x[i];
  -     if (ind(reserved, ch) != -1) {
  +     if (strchr(reserved, ch)) {
            y[j] = ch;
            continue;
        }
  @@ -165,14 +165,14 @@
                return NULL;
            ch = proxy_hex2c(&x[i + 1]);
            i += 2;
  -         if (ch != 0 && ind(reserved, ch) != -1) {   /* keep it encoded */
  +         if (ch != 0 && strchr(reserved, ch)) {      /* keep it encoded */
                proxy_c2hex(ch, &y[j]);
                j += 2;
                continue;
            }
        }
   /* recode it, if necessary */
  -     if (!isalnum(ch) && ind(allowed, ch) == -1) {
  +     if (!isalnum(ch) && !strchr(allowed, ch)) {
            proxy_c2hex(ch, &y[j]);
            j += 2;
        }
  
  
  

Reply via email to