* ReadTxtToList */
| 163 | * ReadTxtToList |
| 164 | */ |
| 165 | char **GDALMDReaderKompsat::ReadTxtToList() |
| 166 | { |
| 167 | char **papszLines = CSLLoad(m_osIMDSourceFilename); |
| 168 | if (nullptr == papszLines) |
| 169 | return nullptr; |
| 170 | |
| 171 | char **papszIMD = nullptr; |
| 172 | char szName[512]; |
| 173 | int i; |
| 174 | size_t j; |
| 175 | CPLString soGroupName; |
| 176 | |
| 177 | for (i = 0; papszLines[i] != nullptr; i++) |
| 178 | { |
| 179 | const char *pszLine = papszLines[i]; |
| 180 | const size_t nLineLenLimited = CPLStrnlen(pszLine, 512); |
| 181 | |
| 182 | // check if this is begin block |
| 183 | if (STARTS_WITH_CI(pszLine, "BEGIN_")) |
| 184 | { |
| 185 | for (j = 6; j + 1 < nLineLenLimited; j++) |
| 186 | { |
| 187 | if (STARTS_WITH_CI(pszLine + j, "_BLOCK")) |
| 188 | { |
| 189 | szName[j - 6] = 0; |
| 190 | break; |
| 191 | } |
| 192 | szName[j - 6] = pszLine[j]; |
| 193 | } |
| 194 | szName[j - 6] = '\0'; |
| 195 | |
| 196 | soGroupName = szName; |
| 197 | |
| 198 | continue; |
| 199 | } |
| 200 | |
| 201 | // check if this is end block |
| 202 | if (STARTS_WITH_CI(pszLine, "END_")) |
| 203 | { |
| 204 | soGroupName.clear(); // we don't expect subblocks |
| 205 | continue; |
| 206 | } |
| 207 | |
| 208 | // get name and value |
| 209 | for (j = 0; j + 1 < nLineLenLimited; j++) |
| 210 | { |
| 211 | if (pszLine[j] == '\t') |
| 212 | { |
| 213 | if (soGroupName.empty() || j > 0) |
| 214 | { |
| 215 | szName[j] = 0; |
| 216 | j++; |
| 217 | break; |
| 218 | } |
| 219 | else |
| 220 | { |
| 221 | continue; |
| 222 | } |
nothing calls this directly
no test coverage detected