MattK wrote:
+BOOL WINAPI DnsNameCompare_A(LPSTR pName1, LPSTR pName2) +{
- TRACE("(%s %s)\n",pName1, pName2);
- LPSTR name1 = pName1;
- LPSTR name2 = pName2;
- RemovePeriods(name1);
- RemovePeriods(name2);
- int equal;
- equal = lstrcmpiA(name1,name2);
- return !equal;
+}
This is still not correct. You can't modify name1, and name2 in place. You shouldn't use inline declarations (ie. the "int equal" should be after the bracket.) There's also no in assigning pName1 to name1, it doesn't make a copy of the string as you suspect, it makes a copy of the pointer to the string.
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return ERROR_CALL_NOT_IMPLEMENTED;
+}
You SetLastError or return an error code, not both.
diff -Nu dlls/dnsapi/utils.c dlls/dnsapi/utils.c
There's no need to make a seperate file for this.
+LPSTR RemovePeriods(LPSTR string) +{
- if(string == NULL)
return NULL;
- DWORD d = 0;
- while(string[d] == '.')
- {
string--;
- }
- return string;
+}
This won't work at all...
If you wrote some better test cases you would discover these problems.
How about testing:
DnsNameCompare_A(NULL, NULL) DnsNameCompare_A("", ".") DnsNameCompare_A("..........", "..........") DnsNameCompare_A(".a.b.c.d.e.", "abcde") DnsNameCompare_A("a.com.","a.com") DnsNameCompare_A("A.com", "a.com") DnsNameCompare_A(".A.com", "a.com") DnsNameCompare_A("Acom", "acom") etc.
Mike