Sha256: ad3aee2fa4f35cc7d9d2f27511c48a4b70748278ed52d923d095c51469058505
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
#include <string.h> #include "jansson_private.h" void jsonp_error_init(json_error_t *error, const char *source) { if(error) { error->text[0] = '\0'; error->line = -1; error->column = -1; error->position = 0; if(source) jsonp_error_set_source(error, source); else error->source[0] = '\0'; } } void jsonp_error_set_source(json_error_t *error, const char *source) { size_t length; if(!error || !source) return; length = strlen(source); if(length < JSON_ERROR_SOURCE_LENGTH) strncpy(error->source, source, length + 1); else { size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4; strncpy(error->source, "...", 3); strncpy(error->source + 3, source + extra, length - extra + 1); } } void jsonp_error_set(json_error_t *error, int line, int column, size_t position, const char *msg, ...) { va_list ap; va_start(ap, msg); jsonp_error_vset(error, line, column, position, msg, ap); va_end(ap); } void jsonp_error_vset(json_error_t *error, int line, int column, size_t position, const char *msg, va_list ap) { if(!error) return; if(error->text[0] != '\0') { /* error already set */ return; } error->line = line; error->column = column; error->position = (int)position; vsnprintf(error->text, JSON_ERROR_TEXT_LENGTH, msg, ap); error->text[JSON_ERROR_TEXT_LENGTH - 1] = '\0'; }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ctags.rb-1.1.4 | ext/vendor/jansson-2.9/src/error.c |
ctags.rb-1.1.3 | ext/vendor/jansson-2.9/src/error.c |