MCPcopy Index your code
hub / github.com/eggert/tz / componentcheck

Function componentcheck

zic.c:1413–1448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1411 return errors ? EXIT_FAILURE : EXIT_SUCCESS;
1412}
1413
1414static bool
1415componentcheck(char const *name, char const *component,
1416 char const *component_end)
1417{
1418 enum { component_len_max = 14 };
1419 ptrdiff_t component_len = component_end - component;
1420 if (component_len == 0) {
1421 if (!*name)
1422 error(N_("empty file name"));
1423 else
1424 error((component == name
1425 ? N_("file name '%s' begins with '/'")
1426 : *component_end
1427 ? N_("file name '%s' contains '//'")
1428 : N_("file name '%s' ends with '/'")),
1429 name);
1430 return false;
1431 }
1432 if (0 < component_len && component_len <= 2
1433 && component[0] == '.' && component_end[-1] == '.') {
1434 int len = component_len;
1435 error(N_("file name '%s' contains '%.*s' component"),
1436 name, len, component);
1437 return false;
1438 }
1439 if (noise) {
1440 if (0 < component_len && component[0] == '-')
1441 warning(N_("file name '%s' component contains leading '-'"),
1442 name);
1443 if (component_len_max < component_len)
1444 warning(N_("file name '%s' contains overlength component"
1445 " '%.*s...'"),
1446 name, component_len_max, component);
1447 }
1448 return true;
1449}
1450
1451static bool

Callers 1

namecheckFunction · 0.85

Calls 2

errorFunction · 0.85
warningFunction · 0.85

Tested by

no test coverage detected