| 2476 | #else // ASTYLE_LIB |
| 2477 | |
| 2478 | utf16_t* ASLibrary::formatUtf16(const utf16_t* pSourceIn, // the source to be formatted |
| 2479 | const utf16_t* pOptions, // AStyle options |
| 2480 | fpError fpErrorHandler, // error handler function |
| 2481 | fpAlloc fpMemoryAlloc) const // memory allocation function) |
| 2482 | { |
| 2483 | const char* utf8In = convertUtf16ToUtf8(pSourceIn); |
| 2484 | if (utf8In == NULL) |
| 2485 | { |
| 2486 | fpErrorHandler(121, "Cannot convert input utf-16 to utf-8."); |
| 2487 | return NULL; |
| 2488 | } |
| 2489 | const char* utf8Options = convertUtf16ToUtf8(pOptions); |
| 2490 | if (utf8Options == NULL) |
| 2491 | { |
| 2492 | delete [] utf8In; |
| 2493 | fpErrorHandler(122, "Cannot convert options utf-16 to utf-8."); |
| 2494 | return NULL; |
| 2495 | } |
| 2496 | // call the Artistic Style formatting function |
| 2497 | // cannot use the callers memory allocation here |
| 2498 | char* utf8Out = ::AStyleMain(utf8In, |
| 2499 | utf8Options, |
| 2500 | fpErrorHandler, |
| 2501 | ASLibrary::tempMemoryAllocation); |
| 2502 | // finished with these |
| 2503 | delete [] utf8In; |
| 2504 | delete [] utf8Options; |
| 2505 | utf8In = NULL; |
| 2506 | utf8Options = NULL; |
| 2507 | // AStyle error has already been sent |
| 2508 | if (utf8Out == NULL) |
| 2509 | return NULL; |
| 2510 | // convert text to wide char and return it |
| 2511 | utf16_t* utf16Out = convertUtf8ToUtf16(utf8Out, fpMemoryAlloc); |
| 2512 | delete [] utf8Out; |
| 2513 | utf8Out = NULL; |
| 2514 | if (utf16Out == NULL) |
| 2515 | { |
| 2516 | fpErrorHandler(123, "Cannot convert output utf-8 to utf-16."); |
| 2517 | return NULL; |
| 2518 | } |
| 2519 | return utf16Out; |
| 2520 | } |
| 2521 | |
| 2522 | bool ASLibrary::getBigEndian() const |
| 2523 | { |
no test coverage detected