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

Function read_line

tools/kconfig2html.c:674–738  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

672 ****************************************************************************/
673
674static char *read_line(FILE *stream)
675{
676 char *ptr;
677 int len;
678
679 g_lnptr = NULL;
680
681 /* Read the next line */
682
683 g_line[LINE_SIZE] = '\0';
684 if (!fgets(g_line, LINE_SIZE, stream))
685 {
686 return NULL;
687 }
688
689 /* Loop to handle continuation lines */
690
691 for (; ; )
692 {
693 /* How long is the line so far? */
694
695 len = strlen(g_line);
696
697 /* Remove any newline character at the end of the buffer */
698
699 if (g_line[len - 1] == '\n')
700 {
701 len--;
702 g_line[len] = '\0';
703 }
704
705 /* Does this continue on the next line? Note that this check
706 * could erroneoulsy combine two lines if a comment line ends with
707 * a line continuation... Don't do that!
708 */
709
710 if (g_line[len - 1] != '\\')
711 {
712 /* No.. return now */
713
714 g_lnptr = g_line;
715 return g_line;
716 }
717
718 /* Yes.. Replace the backslash with a space delimiter */
719
720 g_line[len - 1] = ' ';
721
722 /* Read the next line into the scratch buffer */
723
724 g_scratch[SCRATCH_SIZE] = '\0';
725 if (!fgets(g_scratch, SCRATCH_SIZE, stream))
726 {
727 return NULL;
728 }
729
730 /* Skip any leading whitespace and copy the rest of the next line
731 * into the line buffer. Note that the leading white space is

Callers 2

kconfig_lineFunction · 0.70
process_helpFunction · 0.70

Calls 4

skip_spaceFunction · 0.70
fgetsFunction · 0.50
strlenFunction · 0.50
strncpyFunction · 0.50

Tested by

no test coverage detected