tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

strpbrk.c (1543B)


      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/. */
      5 
      6 #include "plstr.h"
      7 #include <string.h>
      8 
      9 PR_IMPLEMENT(char*)
     10 PL_strpbrk(const char* s, const char* list) {
     11  if (((const char*)0 == s) || ((const char*)0 == list)) {
     12    return (char*)0;
     13  }
     14 
     15  return strpbrk(s, list);
     16 }
     17 
     18 PR_IMPLEMENT(char*)
     19 PL_strprbrk(const char* s, const char* list) {
     20  const char* p;
     21  const char* r;
     22 
     23  if (((const char*)0 == s) || ((const char*)0 == list)) {
     24    return (char*)0;
     25  }
     26 
     27  for (r = s; *r; r++);
     28 
     29  for (r--; r >= s; r--)
     30    for (p = list; *p; p++)
     31      if (*r == *p) {
     32        return (char*)r;
     33      }
     34 
     35  return (char*)0;
     36 }
     37 
     38 PR_IMPLEMENT(char*)
     39 PL_strnpbrk(const char* s, const char* list, PRUint32 max) {
     40  const char* p;
     41 
     42  if (((const char*)0 == s) || ((const char*)0 == list)) {
     43    return (char*)0;
     44  }
     45 
     46  for (; max && *s; s++, max--)
     47    for (p = list; *p; p++)
     48      if (*s == *p) {
     49        return (char*)s;
     50      }
     51 
     52  return (char*)0;
     53 }
     54 
     55 PR_IMPLEMENT(char*)
     56 PL_strnprbrk(const char* s, const char* list, PRUint32 max) {
     57  const char* p;
     58  const char* r;
     59 
     60  if (((const char*)0 == s) || ((const char*)0 == list)) {
     61    return (char*)0;
     62  }
     63 
     64  for (r = s; max && *r; r++, max--);
     65 
     66  for (r--; r >= s; r--)
     67    for (p = list; *p; p++)
     68      if (*r == *p) {
     69        return (char*)r;
     70      }
     71 
     72  return (char*)0;
     73 }