| 33 | // --------------------------------------------------------------------------- |
| 34 | |
| 35 | void pj_wkt_error(pj_wkt_parse_context *context, const char *msg) { |
| 36 | context->errorMsg = "Parsing error : "; |
| 37 | context->errorMsg += msg; |
| 38 | context->errorMsg += ". Error occurred around:\n"; |
| 39 | |
| 40 | std::string ctxtMsg; |
| 41 | const int n = static_cast<int>(context->pszLastSuccess - context->pszInput); |
| 42 | int start_i = std::max(0, n - 40); |
| 43 | for (int i = start_i; i < n + 40 && context->pszInput[i]; i++) { |
| 44 | if (context->pszInput[i] == '\r' || context->pszInput[i] == '\n') { |
| 45 | if (i > n) { |
| 46 | break; |
| 47 | } else { |
| 48 | ctxtMsg.clear(); |
| 49 | start_i = i + 1; |
| 50 | } |
| 51 | } else { |
| 52 | ctxtMsg += context->pszInput[i]; |
| 53 | } |
| 54 | } |
| 55 | context->errorMsg += ctxtMsg; |
| 56 | context->errorMsg += '\n'; |
| 57 | for (int i = start_i; i < n; i++) |
| 58 | context->errorMsg += ' '; |
| 59 | context->errorMsg += '^'; |
| 60 | } |
no test coverage detected