Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commented out "Camel Casing" Code: What Was It? #5

Open
hostilefork opened this issue Oct 17, 2019 · 0 comments
Open

Commented out "Camel Casing" Code: What Was It? #5

hostilefork opened this issue Oct 17, 2019 · 0 comments
Labels
question Further information is requested

Comments

@hostilefork
Copy link
Member

hostilefork commented Oct 17, 2019

There is code commented out relating to de-Camel-Casing column names. This apparently originated in Christian Ensel's version:

https://github.com/gurzgri/r3-odbc/blob/c15c70d61a2f5c39cb01f7c685c4310d4ee987de/src/os/win32/host-odbc.c#L270

It's being removed. But this issue is here to track figuring out what it was for in the first place. Here is some updated code from the Ren-C version, which was never used:

int ODBC_UnCamelCase(SQLWCHAR *source, SQLWCHAR *target) {
    int length = lstrlenW(source);
    int t = 0;
    WCHAR *hyphen = L"-";
    WCHAR *underscore = L"_";
    WCHAR *space = L" ";

    int s;
    for (s = 0; s < length; s++) {
        target[t++] =
            (source[s] == *underscore or source[s] == *space)
                ? *hyphen
                : towlower(source[s]);

        if (
            (
                s < length - 2
                and iswupper(source[s])
                and iswupper(source[s + 1])
                and iswlower(source[s + 2])
            ) or (
                s < length - 1
                and iswlower(source[s])
                and iswupper(source[s + 1])
            )
        ){
            target[t++] = *hyphen;
        }
    }

    target[t++] = 0;
    return t;
}
@hostilefork hostilefork added the question Further information is requested label Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant