MCPcopy Create free account
hub / github.com/apache/nuttx / generate_definitions

Function generate_definitions

tools/cfgdefine.c:294–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292 ****************************************************************************/
293
294void generate_definitions(FILE *stream)
295{
296 char *varname;
297 char *varval;
298 char *ptr;
299
300 /* Loop until the entire file has been parsed. */
301
302 do
303 {
304 /* Read the next line from the file */
305
306 ptr = read_line(stream);
307 if (ptr)
308 {
309 /* Parse the line into a variable and a value field */
310
311 parse_line(ptr, &varname, &varval);
312
313 /* Was a variable name found? */
314
315 if (varname)
316 {
317 /* Yes.. dequote the value if necessary */
318
319 varval = dequote_value(varname, varval);
320
321 /* If no value was provided or if the special value 'n' was
322 * provided, then undefine the configuration variable.
323 */
324
325 if (!varval || strcmp(varval, "n") == 0)
326 {
327 printf("#undef %s\n", varname);
328 }
329
330 /* Simply define the configuration variable to '1' if it has
331 * the special value "y"
332 */
333
334 else if (strcmp(varval, "y") == 0)
335 {
336 printf("#define %s 1\n", varname);
337 }
338
339 /* Or to '2' if it has the special value 'm' */
340
341 else if (strcmp(varval, "m") == 0)
342 {
343 printf("#define %s 2\n", varname);
344 }
345
346 /* Otherwise, use the value as provided */
347
348 else
349 {
350 printf("#define %s %s\n", varname, varval);
351 }

Callers 2

mainFunction · 0.85
mainFunction · 0.85

Calls 5

dequote_valueFunction · 0.85
printfFunction · 0.85
read_lineFunction · 0.70
parse_lineFunction · 0.70
strcmpFunction · 0.50

Tested by

no test coverage detected