gamgi_io_token.c (gamgi-all-0.17.4x) | : | gamgi_io_token.c (gamgi-all-0.17.5x) | ||
---|---|---|---|---|
skipping to change at line 24 | skipping to change at line 24 | |||
#include <errno.h> | #include <errno.h> | |||
#include <ctype.h> | #include <ctype.h> | |||
/************* external function *********** | /************* external function *********** | |||
* * | * * | |||
* GAMGI_IO_TOKEN_CUT * | * GAMGI_IO_TOKEN_CUT * | |||
* * | * * | |||
*******************************************/ | *******************************************/ | |||
void gamgi_io_token_cut (const char *string, | void gamgi_io_token_cut (const char *string, char *token, int length) | |||
char *token, int length) | ||||
{ | { | |||
/******************************************************** | ||||
* length is the true output array length, so the * | ||||
* maximum number of characters that can be effectively * | ||||
* copied is length - 1, to save the last position to * | ||||
* the end character: output[length - 1] = '\0'; * | ||||
* * | ||||
* standard strncpy function truncates strings with the * | ||||
* maximum size (length - 1) without ending the string, * | ||||
* so adding the terminating '\0' character is required * | ||||
********************************************************/ | ||||
strncpy (token, string, length - 1); | strncpy (token, string, length - 1); | |||
token[length - 1] = '\0'; | token[length - 1] = '\0'; | |||
} | } | |||
/************* external function *********** | /************* external function *********** | |||
* * | * * | |||
* GAMGI_IO_TOKEN_CLEAN * | * GAMGI_IO_TOKEN_CLEAN * | |||
* * | * * | |||
* Remove all delimiter char around string * | * Remove all delimiter char around string * | |||
*******************************************/ | *******************************************/ | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 12 lines changed or added |