OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [string/] [wcsncmp.c] - Blame information for rev 831

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
2
FUNCTION
3
        <<wcsncmp>>---compare part of two wide-character strings
4
 
5
ANSI_SYNOPSIS
6
        #include <wchar.h>
7
        int wcsncmp(const wchar_t *<[s1]>, const wchar_t *<[s2]>, size_t <[n]>);
8
 
9
TRAD_SYNOPSIS
10
        int wcsncmp(<[s1]>, <[s2]>, <[n]>
11
        const wchar_t *<[s1]>;
12
        const wchar_t *<[s2]>;
13
        size_t <[n]>;
14
 
15
DESCRIPTION
16
        The <<wcsncmp>> function compares not more than <[n]> wide-character
17
        codes (wide-character codes that follow a null wide-character code are
18
        not compared) from the array pointed to by <[s1]> to the array pointed
19
        to by <[s2]>.
20
 
21
        The sign of a non-zero return value is determined by the sign of the
22
        difference between the values of the first pair of wide-character codes
23
        that differ in the objects being compared.
24
 
25
RETURNS
26
        Upon successful completion, <<wcsncmp>> returns an integer greater than,
27
        equal to or less than 0, if the possibly null-terminated array pointed
28
        to by <[s1]> is greater than, equal to or less than the possibly
29
        null-terminated array pointed to by <[s2]> respectively.
30
 
31
PORTABILITY
32
<<wcsncmp>> is ISO/IEC 9899/AMD1:1995 (ISO C).
33
 
34
No supporting OS subroutines are required.
35
*/
36
 
37
/*      $NetBSD$        */
38
 
39
/*
40
 * Copyright (c) 1989, 1993
41
 *      The Regents of the University of California.  All rights reserved.
42
 *
43
 * Redistribution and use in source and binary forms, with or without
44
 * modification, are permitted provided that the following conditions
45
 * are met:
46
 * 1. Redistributions of source code must retain the above copyright
47
 *    notice, this list of conditions and the following disclaimer.
48
 * 2. Redistributions in binary form must reproduce the above copyright
49
 *    notice, this list of conditions and the following disclaimer in the
50
 *    documentation and/or other materials provided with the distribution.
51
 * 3. Neither the name of the University nor the names of its contributors
52
 *    may be used to endorse or promote products derived from this software
53
 *    without specific prior written permission.
54
 *
55
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
56
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
58
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
59
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
60
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
61
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
62
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
63
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
64
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
65
 * SUCH DAMAGE.
66
 */
67
 
68
#include <_ansi.h>
69
#include <wchar.h>
70
 
71
int
72
_DEFUN (wcsncmp, (s1, s2, n),
73
        _CONST wchar_t * s1 _AND
74
        _CONST wchar_t * s2 _AND
75
        size_t n)
76
{
77
 
78
  if (n == 0)
79
    return (0);
80
  do
81
    {
82
      if (*s1 != *s2++)
83
        {
84
          return (*s1 - *--s2);
85
        }
86
      if (*s1++ == 0)
87
        break;
88
    }
89
  while (--n != 0);
90
  return (0);
91
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.