Skip to content

Commit 0a88d79

Browse files
committed
Use std::ostringstream instead of std::stringstream.
1 parent 4a7e94e commit 0a88d79

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

sdk/src/org.graalvm.launcher.native/src/launcher.cc

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static std::string canonicalize(std::string path) {
285285
* system JRE and fail if none is installed
286286
*/
287287
static void *load_jli_lib(std::string exeDir) {
288-
std::stringstream libjliPath;
288+
std::ostringstream libjliPath;
289289
libjliPath << exeDir << DIR_SEP_STR << LIBJLI_RELPATH_STR;
290290
return dlopen(libjliPath.str().c_str(), RTLD_NOW);
291291
}
@@ -330,7 +330,7 @@ void* get_function(void* library, const char* function_name) {
330330
}
331331

332332
static std::string vm_path(std::string exeDir, bool jvmMode) {
333-
std::stringstream liblangPath;
333+
std::ostringstream liblangPath;
334334
if (jvmMode) {
335335
liblangPath << exeDir << DIR_SEP_STR << LIBJVM_RELPATH_STR;
336336
} else {
@@ -348,9 +348,9 @@ static size_t parse_size(std::string_view str);
348348

349349
static void parse_vm_option(
350350
std::vector<std::string> *vmArgs,
351-
std::stringstream *cp,
352-
std::stringstream *modulePath,
353-
std::stringstream *libraryPath,
351+
std::ostringstream *cp,
352+
std::ostringstream *modulePath,
353+
std::ostringstream *libraryPath,
354354
size_t* stack_size,
355355
std::string_view option) {
356356
if (IS_VM_CP_ARG(option)) {
@@ -367,7 +367,7 @@ static void parse_vm_option(
367367
if (IS_VM_STACK_SIZE_ARG(option)) {
368368
*stack_size = parse_size(option.substr(VM_STACK_SIZE_ARG_OFFSET));
369369
}
370-
std::stringstream opt;
370+
std::ostringstream opt;
371371
opt << '-' << option.substr(VM_ARG_OFFSET);
372372
vmArgs->push_back(opt.str());
373373
} else if (option == "--jvm") {
@@ -412,7 +412,7 @@ static void parse_vm_options(struct MainThreadArgs& parsedArgs) {
412412
}
413413
vmArgs.push_back("-Dorg.graalvm.version=" GRAALVM_VERSION_STR);
414414

415-
std::stringstream executablename;
415+
std::ostringstream executablename;
416416
executablename << "-Dorg.graalvm.launcher.executablename=";
417417
char *executablenameEnv = getenv("GRAALVM_LAUNCHER_EXECUTABLE_NAME");
418418
if (executablenameEnv) {
@@ -427,18 +427,18 @@ static void parse_vm_options(struct MainThreadArgs& parsedArgs) {
427427
}
428428

429429
/* construct classpath - only needed for jvm mode */
430-
std::stringstream cp;
430+
std::ostringstream cp;
431431

432432
/* construct module path - only needed for jvm mode */
433-
std::stringstream modulePath;
433+
std::ostringstream modulePath;
434434
modulePath << "--module-path=";
435435
#ifdef LAUNCHER_MODULE_PATH
436436
if (jvmMode) {
437437
/* add the launcher module path */
438438
const char *launcherModulePathEntries[] = LAUNCHER_MODULE_PATH;
439439
int launcherModulePathCnt = sizeof(launcherModulePathEntries) / sizeof(*launcherModulePathEntries);
440440
for (int i = 0; i < launcherModulePathCnt; i++) {
441-
std::stringstream entry;
441+
std::ostringstream entry;
442442
entry << exeDir << DIR_SEP_STR << launcherModulePathEntries[i];
443443
modulePath << canonicalize(entry.str());
444444
if (i < launcherModulePathCnt-1) {
@@ -455,7 +455,7 @@ static void parse_vm_options(struct MainThreadArgs& parsedArgs) {
455455
const char* dirs[] = { LANGUAGES_DIR_STR, TOOLS_DIR_STR };
456456
for (int i = 0; i < 2; i++) {
457457
const char* relativeDir = dirs[i];
458-
std::stringstream absoluteDirStream;
458+
std::ostringstream absoluteDirStream;
459459
absoluteDirStream << exeDir << DIR_SEP_STR << relativeDir;
460460
std::string absoluteDir = absoluteDirStream.str();
461461

@@ -476,7 +476,7 @@ static void parse_vm_options(struct MainThreadArgs& parsedArgs) {
476476
// From https://learn.microsoft.com/en-us/windows/win32/fileio/listing-the-files-in-a-directory
477477
// and https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findfirstfilea
478478
WIN32_FIND_DATAA entry;
479-
std::stringstream searchDir;
479+
std::ostringstream searchDir;
480480
searchDir << absoluteDir << "\\*";
481481
HANDLE dir = FindFirstFileA(searchDir.str().c_str(), &entry);
482482
if (dir != INVALID_HANDLE_VALUE) {
@@ -495,7 +495,7 @@ static void parse_vm_options(struct MainThreadArgs& parsedArgs) {
495495
#endif
496496

497497
/* construct java.library.path - only needed for jvm mode */
498-
std::stringstream libraryPath;
498+
std::ostringstream libraryPath;
499499
#ifdef LAUNCHER_LIBRARY_PATH
500500
if (jvmMode) {
501501
/* add the library path */
@@ -512,8 +512,8 @@ static void parse_vm_options(struct MainThreadArgs& parsedArgs) {
512512
const char *launcherLangHomePaths[] = LAUNCHER_LANG_HOME_PATHS;
513513
int launcherLangHomeNamesCnt = sizeof(launcherLangHomeNames) / sizeof(*launcherLangHomeNames);
514514
for (int i = 0; i < launcherLangHomeNamesCnt; i++) {
515-
std::stringstream ss;
516-
std::stringstream relativeHome;
515+
std::ostringstream ss;
516+
std::ostringstream relativeHome;
517517
relativeHome << exeDir << DIR_SEP_STR << launcherLangHomePaths[i];
518518
ss << "-Dorg.graalvm.language." << launcherLangHomeNames[i] << ".home=" << canonicalize(relativeHome.str());
519519
vmArgs.push_back(ss.str());
@@ -526,8 +526,8 @@ static void parse_vm_options(struct MainThreadArgs& parsedArgs) {
526526
const char *extractedLibPaths[] = LAUNCHER_EXTRACTED_LIB_PATHS;
527527
int extractedLibCnt = sizeof(extractedLibNames) / sizeof(*extractedLibNames);
528528
for (int i = 0; i < extractedLibCnt; i++) {
529-
std::stringstream ss;
530-
std::stringstream relativePath;
529+
std::ostringstream ss;
530+
std::ostringstream relativePath;
531531
relativePath << exeDir << DIR_SEP_STR << extractedLibPaths[i];
532532
ss << "-D" << extractedLibNames[i] << "=" << canonicalize(relativePath.str());
533533
vmArgs.push_back(ss.str());
@@ -588,7 +588,7 @@ static void parse_vm_options(struct MainThreadArgs& parsedArgs) {
588588
std::cout << "Relaunch environment variable detected" << std::endl;
589589
}
590590
for (int i = 0; i < vmArgCount; i++) {
591-
std::stringstream ss;
591+
std::ostringstream ss;
592592
ss << "GRAALVM_LANGUAGE_LAUNCHER_VMARGS_" << i;
593593
std::string envKey = ss.str();
594594
char *cur = getenv(envKey.c_str());
@@ -996,7 +996,7 @@ static int jvm_main_thread(struct MainThreadArgs& parsedArgs) {
996996
if (debug) {
997997
std::cout << "Relaunch VM arguments read: " << vmArgCount << std::endl;
998998
}
999-
std::stringstream ss;
999+
std::ostringstream ss;
10001000
ss << vmArgCount;
10011001
if (setenv("GRAALVM_LANGUAGE_LAUNCHER_VMARGS", ss.str()) == -1) {
10021002
return -1;
@@ -1015,7 +1015,7 @@ static int jvm_main_thread(struct MainThreadArgs& parsedArgs) {
10151015
return -1;
10161016
}
10171017
/* set environment variables for relaunch vm arguments */
1018-
std::stringstream key;
1018+
std::ostringstream key;
10191019
key << "GRAALVM_LANGUAGE_LAUNCHER_VMARGS_" << i;
10201020
std::string arg(vmArg);
10211021
if (setenv(key.str(), arg) == -1) {

0 commit comments

Comments
 (0)