Skip to content

Commit

Permalink
resolve warning: implicit declaration of function 'string_plus_two' f…
Browse files Browse the repository at this point in the history
…or json_decode_u32.vv
  • Loading branch information
ttytm committed Nov 18, 2024
1 parent c707f7e commit 3b9f06a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions vlib/v/gen/c/json.v
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ ${dec_fn_dec} {
const int error_pos = (int)cJSON_GetErrorPos();
int maxcontext_chars = 30;
byte *buf = vcalloc_noscan(maxcontext_chars + 10);
if(error_pos > 0) {
if (error_pos > 0) {
int backlines = 1;
int backchars = error_pos < maxcontext_chars-7 ? (int)error_pos : maxcontext_chars-7 ;
char *prevline_ptr = (char*)error_ptr;
Expand All @@ -119,9 +119,12 @@ ${dec_fn_dec} {
int maxchars = vstrlen_char(prevline_ptr);
vmemcpy(buf, prevline_ptr, (maxchars < maxcontext_chars ? maxchars : maxcontext_chars));
}
string colon;
colon = (buf[0] == \'\\0\') ? _SLIT("") : _SLIT(": ");
return (${result_name}_${ret_styp}){.is_error = true,.err = _v_error(string_plus_two(_SLIT("failed to decode JSON string"), colon, tos2(buf))),.data = {0}};
string msg;
msg = _SLIT("failed to decode JSON string");
if (buf[0] != \'\\0\') {
msg = string__plus(msg, _SLIT(": "));
}
return (${result_name}_${ret_styp}){.is_error = true,.err = _v_error(string__plus(msg, tos2(buf))),.data = {0}};
}
}
')
Expand Down

0 comments on commit 3b9f06a

Please sign in to comment.