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

[rcore] Parser - invalid raylib_api.json #4323

Closed
4 tasks done
Leopotam opened this issue Sep 15, 2024 · 11 comments
Closed
4 tasks done

[rcore] Parser - invalid raylib_api.json #4323

Leopotam opened this issue Sep 15, 2024 · 11 comments

Comments

@Leopotam
Copy link

Leopotam commented Sep 15, 2024

  • I tested it on latest raylib version from master branch
  • I checked there is no similar issue already reported
  • I checked the documentation on the wiki
  • My code has no errors or misuse of raylib

Issue description

Paser generates invalid json api file after commit #16e9317220bcede380873d2000c1ccd5062e3f07 by @foxblock - "-quotes should be backslashed:

"Load directory filepaths with extension filtering and recursive directory scan. Use "/DIR" in the filter string to include directories in the result",

"/DIR" should be \"/DIR\"

@raysan5
Copy link
Owner

raysan5 commented Sep 16, 2024

@Leopotam Good catch, actually that keyword should be reviewed...

@Leopotam
Copy link
Author

@raysan5 can be fast fixed in this way:

static char *EscapeBackslashes(char *text)
{
    static char buffer[256] = {0};

    int count = 0;

    for (int i = 0; (text[i] != '\0') && (i < 255); i++, count++)
    {
        // start of fix.
        if (text[i] == '"')
        {
            buffer[count] = '\\';
            count++;
        }
        // end of fix.
        buffer[count] = text[i];

        if (text[i] == '\\')
        {
            buffer[count + 1] = '\\';
            count++;
        }
    }

    buffer[count] = '\0';

    return buffer;
}

@Leopotam
Copy link
Author

Maybe, buffer size should be increased too (up to 512), for new poetry in api comments.

raysan5 added a commit that referenced this issue Sep 17, 2024
raysan5 added a commit that referenced this issue Sep 17, 2024
@raysan5
Copy link
Owner

raysan5 commented Sep 17, 2024

@Leopotam Reviewed required tag and buffer size.

@raysan5 raysan5 closed this as completed Sep 17, 2024
@Leopotam
Copy link
Author

Leopotam commented Sep 17, 2024

@raysan5 issue not solved - problem in api parser, that doesnt generate proper json file for description field that contains quotes (").
you can generate json api file and check it in any online json linter.

@raysan5
Copy link
Owner

raysan5 commented Sep 17, 2024

@Leopotam Thanks for leting me know! Could you send a PR reviewing the issue? Probably replacing the double quoates by simple quotes ' would be enough.

@raysan5
Copy link
Owner

raysan5 commented Sep 17, 2024

Never mind, fixed it. Let me know if now it works, please!

@Leopotam
Copy link
Author

Probably replacing the double quoates by simple quotes ' would be enough.

it works now, but only before next commit with comment that contains ". what about suggestion above with patching EscapeBackslashes() function?

@raysan5
Copy link
Owner

raysan5 commented Sep 17, 2024

@Leopotam I prefer to avoid more code to maintain.

@Leopotam
Copy link
Author

Leopotam commented Sep 17, 2024

@raysan5 i see, then better to drop builtin parser and write proper one by myself. thanks for fast fix of raylib.h, issue solved.

@raysan5
Copy link
Owner

raysan5 commented Sep 17, 2024

@raysan5 i see, then better to drop builtin parser and write proper one by myself.

Sure! That's the spirit of open source! 👍😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants