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

Function main

src/cut.c:1276–1456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1274}
1275
1276int
1277main (int argc, char **argv)
1278{
1279 int optc;
1280 bool ok;
1281 bool delim_specified = false;
1282 bool whitespace_delimited_specified = false;
1283 char *spec_list_string = NULL;
1284
1285 initialize_main (&argc, &argv);
1286 set_program_name (argv[0]);
1287 setlocale (LC_ALL, "");
1288 bindtextdomain (PACKAGE, LOCALEDIR);
1289 textdomain (PACKAGE);
1290
1291 atexit (close_stdout);
1292
1293 while ((optc = getopt_long (argc, argv, "b:c:d:f:F:nO:szw", longopts, NULL))
1294 != -1)
1295 {
1296 switch (optc)
1297 {
1298 case 'b':
1299 cut_mode = CUT_MODE_BYTES;
1300 FALLTHROUGH;
1301 case 'c':
1302 if (optc == 'c')
1303 cut_mode = CUT_MODE_CHARACTERS;
1304 FALLTHROUGH;
1305 case 'f':
1306 case 'F':
1307 if (optc == 'f' || optc == 'F')
1308 cut_mode = CUT_MODE_FIELDS;
1309 if (optc == 'F')
1310 {
1311 whitespace_delimited = true;
1312 space_output_delimiter_default = true;
1313 }
1314 if (spec_list_string)
1315 FATAL_ERROR (_("only one list may be specified"));
1316 spec_list_string = optarg;
1317 break;
1318
1319 case 'd':
1320 {
1321 /* New delimiter. */
1322 /* Interpret -d '' to mean 'use the NUL byte as the delimiter.' */
1323 mcel_t g = delim_mcel = mcel_scanz (optarg);
1324 if (optarg[0] && optarg[g.len])
1325 FATAL_ERROR (_("the delimiter must be a single character"));
1326 copy_bytes (delim_bytes, optarg, g.len);
1327 delim_specified = true;
1328 break;
1329 }
1330
1331 case 'w':
1332 whitespace_delimited = true;
1333 whitespace_delimited_specified = true;

Callers

nothing calls this directly

Calls 5

copy_bytesFunction · 0.85
set_fieldsFunction · 0.85
cut_fileFunction · 0.85
usageFunction · 0.70

Tested by

no test coverage detected