Skip to content

Commit

Permalink
Fix for #1326
Browse files Browse the repository at this point in the history
- Use basename instead of filename in error messages when running the testsuite


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@6472 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Oct 20, 2010
1 parent baefd64 commit 8c04382
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Compiler/Error.mo
Expand Up @@ -615,6 +615,7 @@ protected constant list<tuple<Integer, MessageType, Severity, String>> errorTabl

protected import ErrorExt;
protected import Print;
protected import RTOpts;
protected import System;

public function updateCurrentComponent "Function: updateCurrentComponent
Expand Down Expand Up @@ -981,8 +982,8 @@ algorithm
outFilename := matchcontinue filename
case filename
equation
filename = System.stringFindString(filename, "/testsuite/");
then filename;
true = RTOpts.getRunningTestsuite();
then System.basename(filename);
case filename then filename;
end matchcontinue;
end fixFilenameForTestsuite;
Expand Down
9 changes: 9 additions & 0 deletions Compiler/System.mo
Expand Up @@ -840,5 +840,14 @@ creates the Globally Unique IDentifier and return it as String
external "C";
end getUUIDStr;

public function basename
"Returns the name of the file without any leading directory path.
See man 3 basename."
input String filename;
output String base;
// We need to strdup the input, so we can't use basename() directly
external "C" base = System_basename(filename);
end basename;

end System;

12 changes: 12 additions & 0 deletions Compiler/runtime/systemimpl.c
Expand Up @@ -44,6 +44,7 @@
/*
* Common includes
*/
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -424,6 +425,17 @@ RML_BEGIN_LABEL(System__strcmp)
}
RML_END_LABEL

RML_BEGIN_LABEL(System__basename)
{
const char *str = RML_STRINGDATA(rmlA0);
char *copy = strdup(str);
char *res = basename(copy); /* basename may modify the contents */
rmlA0 = (void*) mk_scon(res);
free(copy);
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

RML_BEGIN_LABEL(System__stringFind)
{
char *str = RML_STRINGDATA(rmlA0);
Expand Down

0 comments on commit 8c04382

Please sign in to comment.