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

Function main

src/nice.c:101–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101int
102main (int argc, char **argv)
103{
104 int current_niceness;
105 int adjustment = 10;
106 char const *adjustment_given = NULL;
107 bool ok;
108 int i;
109
110 initialize_main (&argc, &argv);
111 set_program_name (argv[0]);
112 setlocale (LC_ALL, "");
113 bindtextdomain (PACKAGE, LOCALEDIR);
114 textdomain (PACKAGE);
115
116 initialize_exit_failure (EXIT_CANCELED);
117 atexit (close_stdout);
118
119 for (i = 1; i < argc; /* empty */)
120 {
121 char const *s = argv[i];
122
123 if (s[0] == '-' && c_isdigit (s[1 + (s[1] == '-' || s[1] == '+')]))
124 {
125 adjustment_given = s + 1;
126 ++i;
127 }
128 else
129 {
130 int c;
131 int fake_argc = argc - (i - 1);
132 char **fake_argv = argv + (i - 1);
133
134 /* Ensure that any getopt diagnostics use the right name. */
135 fake_argv[0] = argv[0];
136
137 /* Initialize getopt_long's internal state. */
138 optind = 0;
139
140 c = getopt_long (fake_argc, fake_argv, "+n:", longopts, NULL);
141 i += optind - 1;
142
143 switch (c)
144 {
145 case 'n':
146 adjustment_given = optarg;
147 break;
148
149 case -1:
150 break;
151
152 case_GETOPT_HELP_CHAR;
153
154 case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
155
156 default:
157 usage (EXIT_CANCELED);
158 break;

Callers

nothing calls this directly

Calls 3

initialize_exit_failureFunction · 0.85
perm_related_errnoFunction · 0.85
usageFunction · 0.70

Tested by

no test coverage detected