MCPcopy Create free account
hub / github.com/KhronosGroup/glslang / isValidIdentifier

Function isValidIdentifier

StandAlone/StandAlone.cpp:476–499  ·  view source on GitHub ↗

whether string isa valid identifier to be used in glsl

Source from the content-addressed store, hash-verified

474
475// whether string isa valid identifier to be used in glsl
476bool isValidIdentifier(const char* str) {
477 std::string idn(str);
478
479 if (idn.length() == 0) {
480 return false;
481 }
482
483 if (idn.length() >= 3 && idn.substr(0, 3) == "gl_") {
484 // identifiers startin with "gl_" are reserved
485 return false;
486 }
487
488 if (!isNonDigit(idn[0])) {
489 return false;
490 }
491
492 for (unsigned int i = 1; i < idn.length(); ++i) {
493 if (!(isdigit(idn[i]) || isNonDigit(idn[i]))) {
494 return false;
495 }
496 }
497
498 return true;
499}
500
501// Process settings for either the global buffer block or global unfirom block
502// of the form:

Callers 1

Calls 1

isNonDigitFunction · 0.85

Tested by

no test coverage detected