Skip to content

Commit 6e274fb

Browse files
authored
[portsyncd] allow port syncd to parse port_config.ini in random column order (sonic-net#445)
- Parse the column header to decide column ordering. - Extra column(s) will be ignored. Signed-off-by: Ying Xie <[email protected]>
1 parent 6dd0870 commit 6e274fb

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

portsyncd/portsyncd.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,15 @@ void handlePortConfigFile(ProducerStateTable &p, string file)
205205
{
206206
if (line.at(0) == '#')
207207
{
208-
/* Find out what info is specified in the configuration file */
209-
for (auto it = header.begin(); it != header.end();)
210-
{
211-
if (line.find(*it) == string::npos)
212-
{
213-
it = header.erase(it);
214-
}
215-
else
216-
{
217-
++it;
218-
}
208+
// Take this line as column header line
209+
istringstream iss_hdr(line.substr(1));
210+
string hdr;
211+
212+
header.clear();
213+
while (! iss_hdr.eof()) {
214+
iss_hdr >> hdr;
215+
cout << "Adding column header '" << hdr << "'" << endl;
216+
header.push_back(hdr);
219217
}
220218

221219
continue;

0 commit comments

Comments
 (0)