nsprpub/lib/libc/src/strpbrk.c

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include "plstr.h"
     7 #include <string.h>
     9 PR_IMPLEMENT(char *)
    10 PL_strpbrk(const char *s, const char *list)
    11 {
    12     if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
    14     return strpbrk(s, list);
    15 }
    17 PR_IMPLEMENT(char *)
    18 PL_strprbrk(const char *s, const char *list)
    19 {
    20     const char *p;
    21     const char *r;
    23     if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
    25     for( r = s; *r; r++ )
    26         ;
    28     for( r--; r >= s; r-- )
    29         for( p = list; *p; p++ )
    30             if( *r == *p )
    31                 return (char *)r;
    33     return (char *)0;
    34 }
    36 PR_IMPLEMENT(char *)
    37 PL_strnpbrk(const char *s, const char *list, PRUint32 max)
    38 {
    39     const char *p;
    41     if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
    43     for( ; max && *s; s++, max-- )
    44         for( p = list; *p; p++ )
    45             if( *s == *p )
    46                 return (char *)s;
    48     return (char *)0;
    49 }
    51 PR_IMPLEMENT(char *)
    52 PL_strnprbrk(const char *s, const char *list, PRUint32 max)
    53 {
    54     const char *p;
    55     const char *r;
    57     if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
    59     for( r = s; max && *r; r++, max-- )
    60         ;
    62     for( r--; r >= s; r-- )
    63         for( p = list; *p; p++ )
    64             if( *r == *p )
    65                 return (char *)r;
    67     return (char *)0;
    68 }

mercurial