mirror of
https://github.com/dvorka/hstr.git
synced 2025-02-22 22:04:46 +08:00
Adding command line processing test.
This commit is contained in:
parent
356379f63d
commit
aa4872b314
3 changed files with 37 additions and 0 deletions
BIN
tests/test_args
Executable file
BIN
tests/test_args
Executable file
Binary file not shown.
36
tests/test_args.c
Normal file
36
tests/test_args.c
Normal 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
1
tests/test_args.sh
Executable file
|
@ -0,0 +1 @@
|
|||
gcc test_args.c -o test_args
|
Loading…
Reference in a new issue