Compare commits
2 commits
d1f41b37c0
...
44c60d8bb7
Author | SHA1 | Date | |
---|---|---|---|
|
44c60d8bb7 | ||
|
c9d485472e |
1 changed files with 4 additions and 1 deletions
|
@ -12,6 +12,9 @@ static char *separation_character_line(const char *separation_character, const u
|
||||||
const size_t character_length = strlen(separation_character);
|
const size_t character_length = strlen(separation_character);
|
||||||
|
|
||||||
char *line = malloc(line_length * sizeof(char));
|
char *line = malloc(line_length * sizeof(char));
|
||||||
|
// Avoiding undefined behaviour with strlen if no null byte is
|
||||||
|
// present at the end of line
|
||||||
|
*line = 0;
|
||||||
|
|
||||||
while (strlen(line) + character_length <= line_length) {
|
while (strlen(line) + character_length <= line_length) {
|
||||||
strncat(line, separation_character, character_length);
|
strncat(line, separation_character, character_length);
|
||||||
|
@ -37,7 +40,7 @@ int main(int argc, char *argv[]) {
|
||||||
name = "";
|
name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc >= 3) {
|
if (argc >= 3 && *argv[2] != 0) {
|
||||||
separation_character = argv[2];
|
separation_character = argv[2];
|
||||||
} else {
|
} else {
|
||||||
separation_character = "=";
|
separation_character = "=";
|
||||||
|
|
Loading…
Reference in a new issue