Skip to content

Commit

Permalink
Merge pull request CEED#1542 from CEED/jeremy/clean-paths
Browse files Browse the repository at this point in the history
Fix JiT path cleaning logic
  • Loading branch information
jeremylt authored Mar 28, 2024
2 parents 7cbc98e + 101cc02 commit 4782334
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/sphinx/source/releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ On this page we provide a summary of the main API changes, new features and exam
- Add `CeedOperatorCreateAtPoints` which evaluates the `CeedQFunction` at arbitrary locations in each element, for use in Particle in Cell, Material Point Method, and similar methods.
- Add `CeedElemRestrictionGetLLayout` to provide L-vector layout for strided `CeedElemRestriction` created with `CEED_BACKEND_STRIDES`.
- Add `CeedVectorReturnCeed` and similar when parent `Ceed` context for a libCEED object is only needed once in a calling scope.
- Enable `#pragma once` for all JiT source; remove duplicate includes in JiT source string before compilation.

### Examples

Expand Down
7 changes: 5 additions & 2 deletions interface/ceed-jit-tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ static int CeedTrimPath(Ceed ceed, const char *source_file_path, char **trimmed_
char *first_dot = strchr(*trimmed_source_file_path, '.');

while (first_dot) {
char keyword[5] = "";
char *search_from = first_dot + 1;
char keyword[5] = "";

// -- Check for /./ and covert to /
if (first_dot != *trimmed_source_file_path && strlen(first_dot) > 2) memcpy(keyword, &first_dot[-1], 3);
bool is_here = !strcmp(keyword, "/./");

if (is_here) {
for (CeedInt i = 0; first_dot[i - 1]; i++) first_dot[i] = first_dot[i + 2];
search_from = first_dot;
} else {
// -- Check for /foo/../ and convert to /
if (first_dot != *trimmed_source_file_path && strlen(first_dot) > 3) memcpy(keyword, &first_dot[-1], 4);
Expand All @@ -96,9 +98,10 @@ static int CeedTrimPath(Ceed ceed, const char *source_file_path, char **trimmed_
while (last_slash[0] != '/' && last_slash != *trimmed_source_file_path) last_slash--;
CeedCheck(last_slash != *trimmed_source_file_path, ceed, CEED_ERROR_MAJOR, "Malformed source path %s", source_file_path);
for (CeedInt i = 0; first_dot[i - 1]; i++) last_slash[i] = first_dot[i + 2];
search_from = last_slash;
}
}
first_dot = strchr(&first_dot[1], '.');
first_dot = strchr(search_from, '.');
}
return CEED_ERROR_SUCCESS;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/t406-qfunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// Test duplicate includes of guarded files
// Also test include path with "/../"
#include "../tests/t406-qfunction-helper.h"
// Also test include path with "/../../"
#include "../../libCEED/tests/t406-qfunction-helper.h"
# include "t406-qfunction-scales.h"
// clang-format on

Expand Down

0 comments on commit 4782334

Please sign in to comment.