Fixed removing escape symbols for command line arguments

This commit is contained in:
AlexeyAB
2018-06-21 02:42:39 +03:00
parent 76e258520e
commit 4a2a2250f9
3 changed files with 16 additions and 1 deletions

View File

@ -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");

View File

@ -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;

View File

@ -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);