Adding command line processing test.

This commit is contained in:
Martin Dvorak 2014-01-17 04:17:31 +01:00
parent 356379f63d
commit aa4872b314
3 changed files with 37 additions and 0 deletions

BIN
tests/test_args Executable file

Binary file not shown.

36
tests/test_args.c Normal file
View file

@ -0,0 +1,36 @@
/*
============================================================================
Name : test_args.c
Author : martin.dvorak@midforger.com
Copyright : Apache 2.0
Description : A test
============================================================================
*/
#include <string.h>
#include <stdio.h>
#define LINELNG 500
int main(int argc, char *argv[])
{
if(argc>0) {
int i;
char line[LINELNG];
line[0]=0;
for(i=0; i<argc; i++) {
if((strlen(line)+strlen(argv[i])*2)>LINELNG) break;
printf("%d %s\n", i, argv[i]);
if(strstr(argv[i], " ")) {
strcat(line, "\"");
}
strcat(line, argv[i]);
if(strstr(argv[i], " ")) {
strcat(line, "\"");
}
strcat(line, " ");
}
printf("#%s#", line);
}
}

1
tests/test_args.sh Executable file
View file

@ -0,0 +1 @@
gcc test_args.c -o test_args