MCPcopy Create free account
hub / github.com/Kitware/CMake / Compare

Function Compare

Source/CursesDialog/form/fty_enum.c:111–148  ·  view source on GitHub ↗

--------------------------------------------------------------------------- | Facility : libnform | Function : static int Compare(const unsigned char * s, | const unsigned char * buf, | bool ccase ) | | Description : Check whether or not the text in 'buf' matches the | text i

Source from the content-addressed store, hash-verified

109| EXACT - buffer matches exactly
110+--------------------------------------------------------------------------*/
111static int Compare(const unsigned char *s, const unsigned char *buf,
112 bool ccase)
113{
114 SKIP_SPACE(buf); /* Skip leading spaces in both texts */
115 SKIP_SPACE(s);
116
117 if (*buf=='\0')
118 {
119 return (((*s)=='\0') ? EXACT : NOMATCH);
120 }
121 else
122 {
123 if (ccase)
124 {
125 while(*s++ == *buf)
126 {
127 if (*buf++=='\0') return EXACT;
128 }
129 }
130 else
131 {
132 while(toupper(*s++)==toupper(*buf))
133 {
134 if (*buf++=='\0') return EXACT;
135 }
136 }
137 }
138 /* At this location buf points to the first character where it no longer
139 matches with s. So if only blanks are following, we have a partial
140 match otherwise there is no match */
141 SKIP_SPACE(buf);
142 if (*buf)
143 return NOMATCH;
144
145 /* If it happens that the reference buffer is at its end, the partial
146 match is actually an exact match. */
147 return ((s[-1]=='\0') ? EXACT : PARTIAL);
148}
149
150/*---------------------------------------------------------------------------
151| Facility : libnform

Callers 3

Check_Enum_FieldFunction · 0.85
Next_EnumFunction · 0.85
Previous_EnumFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…