removing last char only when it's newline
This commit is contained in:
parent
7359c678d4
commit
85834544aa
@ -242,8 +242,9 @@ void why2_send_socket(char *text, char *username, int socket)
|
||||
char *text_copy = why2_calloc(length_buffer, sizeof(char));
|
||||
struct json_object *json = json_tokener_parse("{}");
|
||||
|
||||
//COPY text INTO text_copy WITHOUT LAST CHARACTER
|
||||
strncpy(text_copy, text, length_buffer - 1);
|
||||
//COPY text INTO text_copy (WITHOUT LAST CHARACTER WHEN NEWLINE IS AT THE END)
|
||||
if (text[length_buffer - 1] == '\n') length_buffer--;
|
||||
strncpy(text_copy, text, length_buffer);
|
||||
|
||||
//ADD OBJECTS
|
||||
json_object_object_add(json, "message", json_object_new_string(text_copy));
|
||||
|
Loading…
x
Reference in New Issue
Block a user