Skip to content

Commit

Permalink
Replace strcmp by std::string_view::operator==.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed May 21, 2024
1 parent af6b285 commit 7efb698
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
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

0 comments on commit 7efb698

Please sign in to comment.