| 1869 | |
| 1870 | template <class SI_CHAR, class SI_STRLESS, class SI_CONVERTER> |
| 1871 | bool CSimpleIniTempl<SI_CHAR, SI_STRLESS, SI_CONVERTER>::LoadMultiLineText( |
| 1872 | SI_CHAR *&a_pData, const SI_CHAR *&a_pVal, const SI_CHAR *a_pTagName, |
| 1873 | bool a_bAllowBlankLinesInComment) const { |
| 1874 | // we modify this data to strip all newlines down to a single '\n' |
| 1875 | // character. This means that on Windows we need to strip out some |
| 1876 | // characters which will make the data shorter. |
| 1877 | // i.e. LINE1-LINE1\r\nLINE2-LINE2\0 will become |
| 1878 | // LINE1-LINE1\nLINE2-LINE2\0 |
| 1879 | // The pDataLine entry is the pointer to the location in memory that |
| 1880 | // the current line needs to start to run following the existing one. |
| 1881 | // This may be the same as pCurrLine in which case no move is needed. |
| 1882 | SI_CHAR *pDataLine = a_pData; |
| 1883 | SI_CHAR *pCurrLine; |
| 1884 | |
| 1885 | // value starts at the current line |
| 1886 | a_pVal = a_pData; |
| 1887 | |
| 1888 | // find the end tag. This tag must start in column 1 and be |
| 1889 | // followed by a newline. We ignore any whitespace after the end |
| 1890 | // tag but not whitespace before it. |
| 1891 | SI_CHAR cEndOfLineChar = *a_pData; |
| 1892 | for (;;) { |
| 1893 | // if we are loading comments then we need a comment character as |
| 1894 | // the first character on every line |
| 1895 | if (!a_pTagName && !IsComment(*a_pData)) { |
| 1896 | // if we aren't allowing blank lines then we're done |
| 1897 | if (!a_bAllowBlankLinesInComment) { |
| 1898 | break; |
| 1899 | } |
| 1900 | |
| 1901 | // if we are allowing blank lines then we only include them |
| 1902 | // in this comment if another comment follows, so read ahead |
| 1903 | // to find out. |
| 1904 | SI_CHAR *pCurr = a_pData; |
| 1905 | int nNewLines = 0; |
| 1906 | while (IsSpace(*pCurr)) { |
| 1907 | if (IsNewLineChar(*pCurr)) { |
| 1908 | ++nNewLines; |
| 1909 | SkipNewLine(pCurr); |
| 1910 | } else { |
| 1911 | ++pCurr; |
| 1912 | } |
| 1913 | } |
| 1914 | |
| 1915 | // we have a comment, add the blank lines to the output |
| 1916 | // and continue processing from here |
| 1917 | if (IsComment(*pCurr)) { |
| 1918 | for (; nNewLines > 0; --nNewLines) |
| 1919 | *pDataLine++ = '\n'; |
| 1920 | a_pData = pCurr; |
| 1921 | continue; |
| 1922 | } |
| 1923 | |
| 1924 | // the comment ends here |
| 1925 | break; |
| 1926 | } |
| 1927 | |
| 1928 | // find the end of this line |
nothing calls this directly
no outgoing calls
no test coverage detected