improved parsing

This commit is contained in:
ALEXks
2023-12-20 17:18:02 +03:00
parent 41fdfcf3f8
commit 6ae8dac71f
2 changed files with 25 additions and 16 deletions

View File

@@ -114,6 +114,7 @@ string OnlyName(const char *filename)
string OnlyExt(const char *filename) string OnlyExt(const char *filename)
{ {
char *extname = new char[1024]; char *extname = new char[1024];
extname[0] = '\0';
int i; int i;
int len = (int)strlen(filename); int len = (int)strlen(filename);
@@ -1385,25 +1386,33 @@ pair<vector<string>, vector<string>> splitCommandLineForParse(char** argv, int a
//fdv|f|ftn|for|f90|f95|f03 //fdv|f|ftn|for|f90|f95|f03
for (int z = 0; z < argc; ++z) for (int z = 0; z < argc; ++z)
{ {
string isFile = argv[z]; string arg = argv[z];
if (isFile.find(".for") != string::npos ||
isFile.find(".f90") != string::npos || string ext = OnlyExt(arg.c_str());
isFile.find(".fdv") != string::npos || convertToLower(ext);
isFile.find(".ftn") != string::npos || if (ext.find("for") != string::npos ||
isFile.find(".f95") != string::npos || ext.find("f90") != string::npos ||
isFile.find(".f03") != string::npos || ext.find("fdv") != string::npos ||
isFile.find(".f") != string::npos) ext.find("ftn") != string::npos ||
ext.find("f95") != string::npos ||
ext.find("f03") != string::npos ||
ext.find("f") != string::npos)
{ {
if (isFile.find("*") == string::npos) if (arg.find("*") == string::npos)
files.insert(isFile); files.insert(arg);
else else
{ {
#if __cplusplus >= 201703L #if __cplusplus >= 201703L
fs::path ext = fs::path(isFile).filename().extension(); fs::path ext = fs::path(arg).filename().extension();
auto str_ext = ext.string();
convertToLower(str_ext);
for (auto& file : filesInDir) for (auto& file : filesInDir)
{ {
auto cmp = file.extension().compare(ext); auto cmp_ext = file.extension().string();
if (cmp == 0) convertToLower(cmp_ext);
if (cmp_ext == str_ext)
files.insert(file.filename().string()); files.insert(file.filename().string());
} }
#endif #endif
@@ -1411,10 +1420,10 @@ pair<vector<string>, vector<string>> splitCommandLineForParse(char** argv, int a
} }
else else
{ {
if (isFile == "-inl") if (arg == "-inl")
isInline = true; isInline = true;
else else
options.push_back(isFile); options.push_back(arg);
} }
} }

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2257" #define VERSION_SPF "2258"