Skip to content

Commit b43c88c

Browse files
authored
Fix extract_filename function (#409)
Fix extract_filename function
1 parent c216de1 commit b43c88c

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

.github/workflows/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ jobs:
143143
- name: Get number of CPU cores
144144
uses: SimenB/github-actions-cpu-cores@v2
145145

146-
- name: Install mamba
147-
uses: mamba-org/setup-micromamba@v1
146+
- name: Install micromamba
147+
uses: mamba-org/setup-micromamba@v2
148148
with:
149149
environment-file: environment-wasm-build.yml
150150
environment-name: xeus-wasm-build

include/xeus/xhelper.hpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,16 @@ namespace xeus
2424
{
2525
XEUS_API std::string get_start_message(const xconfiguration& config);
2626

27-
XEUS_API std::string extract_filename(int argc, char* argv[]);
27+
/**
28+
* @brief Extracts the filename from the command-line arguments and adjusts argc/argv.
29+
*
30+
* Searches for the "-f" flag in the arguments, extracts the following filename, and
31+
* removes both from the argument list. `argc` is updated to reflect the changes.
32+
* @param argc Reference to the argument count, modified if "-f" is found.
33+
* @param argv Argument list, potentially modified.
34+
* @return The extracted filename, or an empty string if not found.
35+
*/
36+
XEUS_API std::string extract_filename(int &argc, char* argv[]);
2837

2938
XEUS_API bool should_print_version(int argc, char* argv[]);
3039

src/xhelper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace xeus
3030
return kernel_info;
3131
}
3232

33-
std::string extract_filename(int argc, char* argv[])
33+
std::string extract_filename(int &argc, char* argv[])
3434
{
3535
std::string res = "";
3636
for (int i = 0; i < argc; ++i)

test/test_unit_kernel.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ namespace xeus
5555

5656
TEST_CASE("extract_filename")
5757
{
58+
int argc = 3;
5859
char* argv[2];
5960
argv[0] = (char*)"-f";
6061
argv[1] = (char*)"connection.json";
61-
std::string file_name = extract_filename(3, argv);
62+
std::string file_name = extract_filename(argc, argv);
6263
REQUIRE_EQ(file_name, "connection.json");
64+
REQUIRE_EQ(argc, 1);
6365
}
6466

6567
TEST_CASE("should_print_version")

0 commit comments

Comments
 (0)