X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Fsyntax.cpp;h=c94e2e27042c63a6a7f0b2c91f3d26c5b00f1e30;hp=cb50fee18b79538c126482594a023ea8f3864001;hb=0388083;hpb=b89239e1d616f0c1d8e432b7df1eca149585cf5e diff --git a/source/glsl/syntax.cpp b/source/glsl/syntax.cpp index cb50fee1..c94e2e27 100644 --- a/source/glsl/syntax.cpp +++ b/source/glsl/syntax.cpp @@ -472,8 +472,14 @@ string get_unused_variable_name(const Block &block, const string &base, const st bool prefixed = false; unsigned number = 1; unsigned size_without_number = name.size(); - while(block.variables.count(name)) + while(1) { + bool unused = true; + for(const Block *b=█ (unused && b); b=b->parent) + unused = !b->variables.count(name); + if(unused) + return name; + if(!prefixed && !prefix_hint.empty()) { if(name.front()!='_') @@ -491,8 +497,6 @@ string get_unused_variable_name(const Block &block, const string &base, const st ++number; } } - - return name; } } // namespace SL