Skip to content

Commit 0313558

Browse files
committed
Move prefix_in_list to the single location where it is used
This makes the `goto_cc_cmdlinet` class easier to follow because it can be read without seeing this special case for `armcc`.
1 parent 1eaa260 commit 0313558

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

src/goto-cc/armcc_cmdline.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,20 @@ static const char *options_with_arg[]=
265265
nullptr
266266
};
267267

268+
bool prefix_in_list(const char *option, const char **list, std::string &prefix)
269+
{
270+
for(std::size_t i = 0; list[i] != nullptr; i++)
271+
{
272+
if(strncmp(option, list[i], strlen(list[i])) == 0)
273+
{
274+
prefix = std::string(list[i]);
275+
return true;
276+
}
277+
}
278+
279+
return false;
280+
}
281+
268282
bool armcc_cmdlinet::parse(int argc, const char **argv)
269283
{
270284
for(int i=1; i<argc; i++)

src/goto-cc/goto_cc_cmdline.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,6 @@ bool goto_cc_cmdlinet::in_list(const char *option, const char **list)
4747
return false;
4848
}
4949

50-
bool goto_cc_cmdlinet::prefix_in_list(
51-
const char *option,
52-
const char **list,
53-
std::string &prefix)
54-
{
55-
for(std::size_t i=0; list[i]!=nullptr; i++)
56-
{
57-
if(strncmp(option, list[i], strlen(list[i]))==0)
58-
{
59-
prefix=std::string(list[i]);
60-
return true;
61-
}
62-
}
63-
64-
return false;
65-
}
66-
6750
std::size_t goto_cc_cmdlinet::get_optnr(const std::string &opt_string)
6851
{
6952
optionalt<std::size_t> optnr;

src/goto-cc/goto_cc_cmdline.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ class goto_cc_cmdlinet:public cmdlinet
2626

2727
static bool in_list(const char *option, const char **list);
2828

29-
static bool prefix_in_list(
30-
const char *option,
31-
const char **list,
32-
std::string &prefix);
33-
3429
// never fails, will add if not found
3530
std::size_t get_optnr(const std::string &option);
3631

0 commit comments

Comments
 (0)