Skip to content

Commit

Permalink
HPCC-29742 Fix problem with eclcc when filename is not an valid ident…
Browse files Browse the repository at this point in the history
…ifier

* Treat the ecl file in the same way as submitting from stdin, or
  any other file that is not part of a repository

Signed-off-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday committed Jun 22, 2023
1 parent 8a70491 commit e62fa52
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions ecl/eclcc/eclcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1037,8 +1037,11 @@ static bool convertPathToModule(StringBuffer & out, const char * filename)
{
char next = filename[i];
if (isPathSepChar(next))
next = '.';
out.append(next);
out.append('.');
else if (isalnum(next) || (next == '_'))
out.append(next);
else
return false; // filename is not a valid identifier.
}
return true;
}
Expand Down Expand Up @@ -1078,13 +1081,18 @@ static bool findFilenameInSearchPath(StringBuffer & attributePath, const char *
tail++;
if (convertPathToModule(attributePath, tail))
return true;
else
break;
}
}

if (!sep)
return false;
break;
cur = sep+1;
}

attributePath.clear();
return false;
}

bool EclCC::isWithinPath(const char * sourcePathname, const char * searchPath)
Expand Down Expand Up @@ -1842,13 +1850,16 @@ void EclCC::processFile(EclCompileInstance & instance)
StringBuffer thisDirectory;
StringBuffer thisTail;
splitFilename(expandedSourceName, &thisDirectory, &thisDirectory, &thisTail, NULL);
attributePath.append(moduleName).append(".").append(thisTail);
if (isValidIdentifier(thisTail))
{
attributePath.append(moduleName).append(".").append(thisTail);

inputFileCollection.setown(createSingleDefinitionEclCollection(attributePath, queryText));
localRepositoryManager.addRepository(inputFileCollection, nullptr, true);
inputFileCollection.setown(createSingleDefinitionEclCollection(attributePath, queryText));
localRepositoryManager.addRepository(inputFileCollection, nullptr, true);

Owned<IEclSourceCollection> directory = createFileSystemEclCollection(&instance.queryErrorProcessor(), thisDirectory, ESFnone, 0);
localRepositoryManager.addNestedRepository(moduleNameId, directory, true);
Owned<IEclSourceCollection> directory = createFileSystemEclCollection(&instance.queryErrorProcessor(), thisDirectory, ESFnone, 0);
localRepositoryManager.addNestedRepository(moduleNameId, directory, true);
}
}
}

Expand Down

0 comments on commit e62fa52

Please sign in to comment.