* xmlSaveErr: * @code: the error number * @node: the location of the error. * @extra: extra information * * Handle an out of memory condition */
| 77 | * Handle an out of memory condition |
| 78 | */ |
| 79 | static void |
| 80 | xmlSaveErr(xmlOutputBufferPtr out, int code, xmlNodePtr node, |
| 81 | const char *extra) |
| 82 | { |
| 83 | const char *msg = NULL; |
| 84 | int res; |
| 85 | |
| 86 | /* Don't overwrite memory errors */ |
| 87 | if ((out != NULL) && (out->error == XML_ERR_NO_MEMORY)) |
| 88 | return; |
| 89 | |
| 90 | if (code == XML_ERR_NO_MEMORY) { |
| 91 | xmlSaveErrMemory(out); |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | if (out != NULL) |
| 96 | out->error = code; |
| 97 | |
| 98 | switch(code) { |
| 99 | case XML_SAVE_NOT_UTF8: |
| 100 | msg = "string is not in UTF-8\n"; |
| 101 | break; |
| 102 | case XML_SAVE_CHAR_INVALID: |
| 103 | msg = "invalid character value\n"; |
| 104 | break; |
| 105 | case XML_SAVE_UNKNOWN_ENCODING: |
| 106 | msg = "unknown encoding %s\n"; |
| 107 | break; |
| 108 | case XML_SAVE_NO_DOCTYPE: |
| 109 | msg = "document has no DOCTYPE\n"; |
| 110 | break; |
| 111 | default: |
| 112 | msg = "unexpected error number\n"; |
| 113 | } |
| 114 | |
| 115 | res = __xmlRaiseError(NULL, NULL, NULL, NULL, node, |
| 116 | XML_FROM_OUTPUT, code, XML_ERR_ERROR, NULL, 0, |
| 117 | extra, NULL, NULL, 0, 0, |
| 118 | msg, extra); |
| 119 | if (res < 0) |
| 120 | xmlSaveErrMemory(out); |
| 121 | } |
| 122 | |
| 123 | /************************************************************************ |
| 124 | * * |
no test coverage detected