~ubuntu-branches/ubuntu/gutsy/ntp/gutsy

« back to all changes in this revision

Viewing changes to libopts/compat/strchr.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-05-18 22:41:56 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070518224156-563ruqxsxvqvoy8h
Tags: 1:4.2.4p0+dfsg-1ubuntu1
* Merge from Debian unstable.
* Remaining Ubuntu changes:
  - Update version in conflicts/replaces to that which was shipped in edgy,
    which was later than that in Debian (due to the ubuntuX).
  - Change default server to ntp.ubuntu.com.
  - Remove stop links from rc0 and rc6
  - Call dh_installinit with --error-handler
  - Set Ubuntu maintainer address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   SYNOPSIS
 
3
       #include <string.h>
 
4
 
 
5
       char *strchr(char const *s, int c);
 
6
 
 
7
       char *strrchr(char const *s, int c);
 
8
 
 
9
   DESCRIPTION
 
10
       The  strchr() function returns a pointer to the first occurrence of the
 
11
       character c in the string s.
 
12
 
 
13
       The strrchr() function returns a pointer to the last occurrence of  the
 
14
       character c in the string s.
 
15
 
 
16
       Here  "character"  means "byte" - these functions do not work with wide
 
17
       or multi-byte characters.
 
18
 
 
19
   RETURN VALUE
 
20
       The strchr() and strrchr() functions return a pointer  to  the  matched
 
21
       character or NULL if the character is not found.
 
22
 
 
23
   CONFORMING TO
 
24
       SVID 3, POSIX, BSD 4.3, ISO 9899
 
25
*/
 
26
 
 
27
char*
 
28
strchr( char const *s, int c)
 
29
{
 
30
    do {
 
31
        if ((unsigned)*s == (unsigned)c)
 
32
            return s;
 
33
 
 
34
    } while (*(++s) != NUL);
 
35
 
 
36
    return NULL;
 
37
}
 
38
 
 
39
char*
 
40
strrchr( char const *s, int c)
 
41
{
 
42
    char const *e = s + strlen(s);
 
43
 
 
44
    for (;;) {
 
45
        if (--e < s)
 
46
            break;
 
47
 
 
48
        if ((unsigned)*e == (unsigned)c)
 
49
            return e;
 
50
    }
 
51
    return NULL;
 
52
}
 
53
 
 
54
/*
 
55
 * Local Variables:
 
56
 * mode: C
 
57
 * c-file-style: "stroustrup"
 
58
 * indent-tabs-mode: nil
 
59
 * End:
 
60
 * end of compat/strsignal.c */