Skip to content

Commit e8829e9

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 b30e60e commit e8829e9

File tree

3 files changed

+15
-22
lines changed

3 files changed

+15
-22
lines changed

src/goto-cc/armcc_cmdline.cpp

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

268+
static bool
269+
prefix_in_list(const char *option, const char **list, std::string &prefix)
270+
{
271+
for(std::size_t i = 0; list[i] != nullptr; i++)
272+
{
273+
if(strncmp(option, list[i], strlen(list[i])) == 0)
274+
{
275+
prefix = std::string(list[i]);
276+
return true;
277+
}
278+
}
279+
280+
return false;
281+
}
282+
268283
bool armcc_cmdlinet::parse(int argc, const char **argv)
269284
{
270285
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
@@ -46,23 +46,6 @@ bool goto_cc_cmdlinet::in_list(const char *option, const char **list)
4646
return false;
4747
}
4848

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