You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Faust doesn't correctly modify --class-name and --super-class-name to valid c++ identifiers and generates uncompilable c++ code. Its bigger issue with faust2.. scripts using filename as classname, for instance faust2lv2, so filenames that are valid (for instance starting with a digit or containing hyphen) result in error during the compilation of the generated c++ code.
The text was updated successfully, but these errors were encountered:
Pri-yan-shu
changed the title
Faust doesn't check --class-name and --super-class-name values for validity
Faust passes invalid --class-name and --super-class-name identifiers to generated code
Feb 13, 2025
I have already developed a prototype of this solution. Could you please review this approach, @sletz ?
Approach
The solution is to sanitize the provided identifier strings to ensure they conform to C++ identifier rules. The key steps are:
Validation and Sanitization Function
Create a helper function (e.g., sanitizeIdentifier) that:
Checks the first character: If it is a digit, prepend an underscore.
Filters through the rest of the string: Convert any illegal character (anything other than alphanumerics or underscore) into an underscore.
Optionally: Warn the user if the provided identifier is changed, so they are aware of the transformation.
Integrate the Sanitization Function
Modify the part of the Faust code where --class-name and --super-class-name are processed. Instead of using the raw input, pass the input through the sanitization function before using it in code generation.
Faust doesn't correctly modify --class-name and --super-class-name to valid c++ identifiers and generates uncompilable c++ code. Its bigger issue with faust2.. scripts using filename as classname, for instance faust2lv2, so filenames that are valid (for instance starting with a digit or containing hyphen) result in error during the compilation of the generated c++ code.
The text was updated successfully, but these errors were encountered: