MCPcopy Create free account
hub / github.com/coreutils/coreutils / parse_symbols

Function parse_symbols

src/dd.c:1366–1401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1364 cannot be parsed, use ERROR_MSGID to generate a diagnostic. */
1365
1366static int
1367parse_symbols (char const *str, struct symbol_value const *table,
1368 bool exclusive, char const *error_msgid)
1369{
1370 int value = 0;
1371
1372 while (true)
1373 {
1374 char const *strcomma = strchr (str, ',');
1375 struct symbol_value const *entry;
1376
1377 for (entry = table;
1378 ! (operand_matches (str, entry->symbol, ',') && entry->value);
1379 entry++)
1380 {
1381 if (! entry->symbol[0])
1382 {
1383 idx_t slen = strcomma ? strcomma - str : strlen (str);
1384 diagnose (0, "%s: %s", _(error_msgid),
1385 quotearg_n_style_mem (0, locale_quoting_style,
1386 str, slen));
1387 usage (EXIT_FAILURE);
1388 }
1389 }
1390
1391 if (exclusive)
1392 value = entry->value;
1393 else
1394 value |= entry->value;
1395 if (!strcomma)
1396 break;
1397 str = strcomma + 1;
1398 }
1399
1400 return value;
1401}
1402
1403/* Return the value of STR, interpreted as a non-negative decimal integer,
1404 optionally multiplied by various values.

Callers 1

scanargsFunction · 0.85

Calls 3

operand_matchesFunction · 0.85
diagnoseFunction · 0.85
usageFunction · 0.70

Tested by

no test coverage detected