Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace strcmp by std::string_view::operator==. #679

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/stratagus/stratagus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ extern void beos_init(int argc, char **argv);

#include <SDL.h>
#include <guichan.hpp>
#include <string_view>

#ifdef USE_STACKTRACE
#include <stdexcept>
Expand Down Expand Up @@ -590,11 +591,8 @@ void ParseCommandLine(int argc, char **argv, Parameters &parameters)
RefreshRate = to_number(optarg);
continue;
case 'u':
if (!strcmp(optarg, "userhome")) {
Parameters::Instance.SetUserDirectory("");
} else {
Parameters::Instance.SetUserDirectory(optarg);
}
Parameters::Instance.SetUserDirectory(
optarg == std::string_view("userhome") ? "" : optarg);
continue;
case 'v': {
sep = strchr(optarg, 'x');
Expand Down
3 changes: 2 additions & 1 deletion src/stratagus/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ int to_number(std::string_view s, int base)
*/

#include <cstring>
#include <string_view>

int opterr = 1;
int optind = 1;
Expand Down Expand Up @@ -371,7 +372,7 @@ int getopt(int argc, char *const *argv, const char *opts) noexcept
if (sp == 1) {
if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0') {
return EOF;
} else if (!strcmp(argv[optind], "--")) {
} else if (argv[optind] == std::string_view("--")) {
optind++;
return EOF;
}
Expand Down
Loading