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

Incorrect usage of find_first_of in replacing {{in}} pattern #1059

Closed
tomas-davidovic opened this issue Aug 24, 2022 · 3 comments
Closed

Incorrect usage of find_first_of in replacing {{in}} pattern #1059

tomas-davidovic opened this issue Aug 24, 2022 · 3 comments

Comments

@tomas-davidovic
Copy link

I am writing a very hacked together ShaderGen and found when I have sourcecode="{0}" where in the output I want to see literally {0}, MaterialX fails.

The problem is in the SourceCodeNode::emitFunctionCall method, which uses _functionSource.find_first_of("{{") to find the first occurrence of the {{. But that's not what find_first_of actually does. It finds the first occurrence of any of the characters in the provided string, so it finds even single {. The code should be using find instead, which finds the exact match. Same goes for the postfix search a bit later.

@jstone-lucasfilm
Copy link
Member

This is a great catch, @tomas-davidovic, and I believe this issue goes back to our very first implementation of SourceCodeNode::emitFunctionCall. Would you have the bandwidth to put together a pull request addressing this, where you can validate the results with your local ShaderGen implementation?

@tomas-davidovic
Copy link
Author

I can try (my very first PR on github ever).

@jstone-lucasfilm
Copy link
Member

Thanks for this report, @tomas-davidovic, and this has been addressed in #1191.

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