ucl_emitter_utils.c (302408) | ucl_emitter_utils.c (314278) |
---|---|
1/* Copyright (c) 2014, Vsevolod Stakhov 2 * All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above copyright --- 88 unchanged lines hidden (view full) --- 97{ 98 const char *p = str, *c = str; 99 size_t len = 0; 100 const struct ucl_emitter_functions *func = ctx->func; 101 102 func->ucl_emitter_append_character ('"', 1, func->ud); 103 104 while (size) { | 1/* Copyright (c) 2014, Vsevolod Stakhov 2 * All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above copyright --- 88 unchanged lines hidden (view full) --- 97{ 98 const char *p = str, *c = str; 99 size_t len = 0; 100 const struct ucl_emitter_functions *func = ctx->func; 101 102 func->ucl_emitter_append_character ('"', 1, func->ud); 103 104 while (size) { |
105 if (ucl_test_character (*p, UCL_CHARACTER_JSON_UNSAFE)) { | 105 if (ucl_test_character (*p, UCL_CHARACTER_JSON_UNSAFE|UCL_CHARACTER_DENIED)) { |
106 if (len > 0) { 107 func->ucl_emitter_append_len (c, len, func->ud); 108 } 109 switch (*p) { 110 case '\n': 111 func->ucl_emitter_append_len ("\\n", 2, func->ud); 112 break; 113 case '\r': --- 9 unchanged lines hidden (view full) --- 123 func->ucl_emitter_append_len ("\\f", 2, func->ud); 124 break; 125 case '\\': 126 func->ucl_emitter_append_len ("\\\\", 2, func->ud); 127 break; 128 case '"': 129 func->ucl_emitter_append_len ("\\\"", 2, func->ud); 130 break; | 106 if (len > 0) { 107 func->ucl_emitter_append_len (c, len, func->ud); 108 } 109 switch (*p) { 110 case '\n': 111 func->ucl_emitter_append_len ("\\n", 2, func->ud); 112 break; 113 case '\r': --- 9 unchanged lines hidden (view full) --- 123 func->ucl_emitter_append_len ("\\f", 2, func->ud); 124 break; 125 case '\\': 126 func->ucl_emitter_append_len ("\\\\", 2, func->ud); 127 break; 128 case '"': 129 func->ucl_emitter_append_len ("\\\"", 2, func->ud); 130 break; |
131 default: 132 /* Emit unicode unknown character */ 133 func->ucl_emitter_append_len ("\\uFFFD", 5, func->ud); 134 break; |
|
131 } 132 len = 0; 133 c = ++p; 134 } 135 else { 136 p ++; 137 len ++; 138 } 139 size --; 140 } | 135 } 136 len = 0; 137 c = ++p; 138 } 139 else { 140 p ++; 141 len ++; 142 } 143 size --; 144 } |
145 |
|
141 if (len > 0) { 142 func->ucl_emitter_append_len (c, len, func->ud); 143 } | 146 if (len > 0) { 147 func->ucl_emitter_append_len (c, len, func->ud); 148 } |
149 |
|
144 func->ucl_emitter_append_character ('"', 1, func->ud); 145} 146 147void 148ucl_elt_string_write_multiline (const char *str, size_t size, 149 struct ucl_emitter_context *ctx) 150{ 151 const struct ucl_emitter_functions *func = ctx->func; --- 342 unchanged lines hidden --- | 150 func->ucl_emitter_append_character ('"', 1, func->ud); 151} 152 153void 154ucl_elt_string_write_multiline (const char *str, size_t size, 155 struct ucl_emitter_context *ctx) 156{ 157 const struct ucl_emitter_functions *func = ctx->func; --- 342 unchanged lines hidden --- |