Skip to content

Commit

Permalink
Fixed removing escape symbols for command line arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyAB committed Jun 20, 2018
1 parent 76e2585 commit 4a2a225
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/darknet.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ int main(int argc, char **argv)
int i;
for (i = 0; i < argc; ++i) {
if (!argv[i]) continue;
strip(argv[i]);
strip_args(argv[i]);
}

//test_resize("data/bad.jpg");
Expand Down
14 changes: 14 additions & 0 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,20 @@ void strip(char *s)
s[len-offset] = '\0';
}


void strip_args(char *s)
{
size_t i;
size_t len = strlen(s);
size_t offset = 0;
for (i = 0; i < len; ++i) {
char c = s[i];
if (c == '\t' || c == '\n' || c == '\r' || c == 0x0d || c == 0x0a) ++offset;
else s[i - offset] = c;
}
s[len - offset] = '\0';
}

void strip_char(char *s, char bad)
{
size_t i;
Expand Down
1 change: 1 addition & 0 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void error(const char *s);
void malloc_error();
void file_error(char *s);
void strip(char *s);
void strip_args(char *s);
void strip_char(char *s, char bad);
void top_k(float *a, int n, int k, int *index);
list *split_str(char *s, char delim);
Expand Down

0 comments on commit 4a2a225

Please sign in to comment.