Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: nspr/lib/libc/src/strstr.c

Issue 2078763002: Delete bundled copy of NSS and replace with README. (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/nss@master
Patch Set: Delete bundled copy of NSS and replace with README. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « nspr/lib/libc/src/strpbrk.c ('k') | nspr/lib/libc/src/strtok.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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_strstr(const char *big, const char *little)
11 {
12 if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char * )0;
13 if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
14
15 return strstr(big, little);
16 }
17
18 PR_IMPLEMENT(char *)
19 PL_strrstr(const char *big, const char *little)
20 {
21 const char *p;
22 size_t ll;
23 size_t bl;
24
25 if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char * )0;
26 if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
27
28 ll = strlen(little);
29 bl = strlen(big);
30 if( bl < ll ) return (char *)0;
31 p = &big[ bl - ll ];
32
33 for( ; p >= big; p-- )
34 if( *little == *p )
35 if( 0 == strncmp(p, little, ll) )
36 return (char *)p;
37
38 return (char *)0;
39 }
40
41 PR_IMPLEMENT(char *)
42 PL_strnstr(const char *big, const char *little, PRUint32 max)
43 {
44 size_t ll;
45
46 if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char * )0;
47 if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
48
49 ll = strlen(little);
50 if( ll > (size_t)max ) return (char *)0;
51 max -= (PRUint32)ll;
52 max++;
53
54 for( ; max && *big; big++, max-- )
55 if( *little == *big )
56 if( 0 == strncmp(big, little, ll) )
57 return (char *)big;
58
59 return (char *)0;
60 }
61
62 PR_IMPLEMENT(char *)
63 PL_strnrstr(const char *big, const char *little, PRUint32 max)
64 {
65 const char *p;
66 size_t ll;
67
68 if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char * )0;
69 if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
70
71 ll = strlen(little);
72
73 for( p = big; max && *p; p++, max-- )
74 ;
75
76 p -= ll;
77 if( p < big ) return (char *)0;
78
79 for( ; p >= big; p-- )
80 if( *little == *p )
81 if( 0 == strncmp(p, little, ll) )
82 return (char *)p;
83
84 return (char *)0;
85 }
OLDNEW
« no previous file with comments | « nspr/lib/libc/src/strpbrk.c ('k') | nspr/lib/libc/src/strtok.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698