PostgreSQL Source Code git master
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

◆ pg_char_and_wchar_strncmp()

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

Definition at line 55 of file wstrncmp.c.

56{
57 if (n == 0)
58 return 0;
59 do
60 {
61 if ((pg_wchar) ((unsigned char) *s1) != *s2++)
62 return ((pg_wchar) ((unsigned char) *s1) - *(s2 - 1));
63 if (*s1++ == 0)
64 break;
65 } while (--n != 0);
66 return 0;
67}
unsigned int pg_wchar
Definition: mbprint.c:31
char * s1
char * s2

References s1, and s2.

Referenced by element(), and lookupcclass().

◆ pg_wchar_strlen()

size_t pg_wchar_strlen ( const pg_wchar str)

Definition at line 70 of file wstrncmp.c.

71{
72 const pg_wchar *s;
73
74 for (s = str; *s; ++s)
75 ;
76 return (s - str);
77}
const char * str

References str.

Referenced by pg_wchar2mb().

◆ pg_wchar_strncmp()

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

Definition at line 40 of file wstrncmp.c.

41{
42 if (n == 0)
43 return 0;
44 do
45 {
46 if (*s1 != *s2++)
47 return (*s1 - *(s2 - 1));
48 if (*s1++ == 0)
49 break;
50 } while (--n != 0);
51 return 0;
52}

References s1, and s2.