Header And Logo

PostgreSQL
| The world's most advanced open source database.

Functions

wstrncmp.c File Reference

#include "postgres_fe.h"
#include "mb/pg_wchar.h"
Include dependency graph for wstrncmp.c:

Go to the source code of this file.

Functions

int pg_wchar_strncmp (const pg_wchar *s1, const pg_wchar *s2, size_t n)
int pg_char_and_wchar_strncmp (const char *s1, const pg_wchar *s2, size_t n)
size_t pg_wchar_strlen (const pg_wchar *str)

Function Documentation

int pg_char_and_wchar_strncmp ( const char *  s1,
const pg_wchar s2,
size_t  n 
)

Definition at line 55 of file wstrncmp.c.

Referenced by cclass(), and element().

{
    if (n == 0)
        return 0;
    do
    {
        if ((pg_wchar) ((unsigned char) *s1) != *s2++)
            return ((pg_wchar) ((unsigned char) *s1) - *(s2 - 1));
        if (*s1++ == 0)
            break;
    } while (--n != 0);
    return 0;
}

size_t pg_wchar_strlen ( const pg_wchar str  ) 

Definition at line 70 of file wstrncmp.c.

Referenced by pg_wchar2mb().

{
    const pg_wchar *s;

    for (s = str; *s; ++s)
        ;
    return (s - str);
}

int pg_wchar_strncmp ( const pg_wchar s1,
const pg_wchar s2,
size_t  n 
)

Definition at line 40 of file wstrncmp.c.

{
    if (n == 0)
        return 0;
    do
    {
        if (*s1 != *s2++)
            return (*s1 - *(s2 - 1));
        if (*s1++ == 0)
            break;
    } while (--n != 0);
    return 0;
}