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));
|
char *text_copy = why2_calloc(length_buffer, sizeof(char));
|
||||||
struct json_object *json = json_tokener_parse("{}");
|
struct json_object *json = json_tokener_parse("{}");
|
||||||
|
|
||||||
//COPY text INTO text_copy WITHOUT LAST CHARACTER
|
//COPY text INTO text_copy (WITHOUT LAST CHARACTER WHEN NEWLINE IS AT THE END)
|
||||||
strncpy(text_copy, text, length_buffer - 1);
|
if (text[length_buffer - 1] == '\n') length_buffer--;
|
||||||
|
strncpy(text_copy, text, length_buffer);
|
||||||
|
|
||||||
//ADD OBJECTS
|
//ADD OBJECTS
|
||||||
json_object_object_add(json, "message", json_object_new_string(text_copy));
|
json_object_object_add(json, "message", json_object_new_string(text_copy));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user