--- nl.c 2020-12-13 14:43:42.548147088 -0800 +++ nl.posix.c 2020-12-13 14:41:54.179988143 -0800 @@ -569,17 +569,39 @@ /* Initialize the section delimiters. */ len = strlen (section_del); - header_del_len = len * 3; - header_del = xmalloc (header_del_len + 1); - stpcpy (stpcpy (stpcpy (header_del, section_del), section_del), section_del); - - body_del_len = len * 2; - body_del = xmalloc (body_del_len + 1); - stpcpy (stpcpy (body_del, section_del), section_del); - - footer_del_len = len; - footer_del = xmalloc (footer_del_len + 1); - stpcpy (footer_del, section_del); + if (len == 1) + { + header_del_len = 6; + header_del = xmalloc (header_del_len + 1); + stpcpy (stpcpy (stpcpy (stpcpy (stpcpy (stpcpy (header_del, section_del), + DEFAULT_SECTION_DELIMITERS + 1), section_del), DEFAULT_SECTION_DELIMITERS + 1), + section_del), DEFAULT_SECTION_DELIMITERS + 1); + + body_del_len = 4; + body_del = xmalloc (body_del_len + 1); + stpcpy (stpcpy (stpcpy (stpcpy (body_del, section_del), DEFAULT_SECTION_DELIMITERS + 1), + section_del), DEFAULT_SECTION_DELIMITERS + 1); + + footer_del_len = 2; + footer_del = xmalloc (footer_del_len + 1); + stpcpy (stpcpy (footer_del, section_del), DEFAULT_SECTION_DELIMITERS + 1); + + section_del = footer_del; + } + else + { + header_del_len = len * 3; + header_del = xmalloc (header_del_len + 1); + stpcpy (stpcpy (stpcpy (header_del, section_del), section_del), section_del); + + body_del_len = len * 2; + body_del = xmalloc (body_del_len + 1); + stpcpy (stpcpy (body_del, section_del), section_del); + + footer_del_len = len; + footer_del = xmalloc (footer_del_len + 1); + stpcpy (footer_del, section_del); + } /* Initialize the input buffer. */ initbuffer (&line_buf);