help
Line | |
---|
1 | |
---|
2 | #include <ctype.h> |
---|
3 | #include <stdio.h> |
---|
4 | #include <string.h> |
---|
5 | #include <locale.h> |
---|
6 | |
---|
7 | |
---|
8 | #include <stdlib.h> |
---|
9 | //#include "../lib/iotools.h" |
---|
10 | |
---|
11 | #include "cmdline.h" |
---|
12 | |
---|
13 | |
---|
14 | char buf[257]; |
---|
15 | int filepos=0; |
---|
16 | char* tokstart; |
---|
17 | char* tokend; |
---|
18 | char tmp; |
---|
19 | char tag; |
---|
20 | |
---|
21 | |
---|
22 | gengetopt_args_info args; |
---|
23 | |
---|
24 | |
---|
25 | inline |
---|
26 | void printtoken(char tag) |
---|
27 | { |
---|
28 | tmp=*tokend; |
---|
29 | *tokend='\0'; |
---|
30 | printf("%04d %02d %c %s\n", filepos, tokend-tokstart, tag, tokstart); |
---|
31 | *tokend=tmp; |
---|
32 | filepos+=tokend-tokstart; |
---|
33 | tokstart=tokend; |
---|
34 | if(args.interactive_flag) fflush(stdout); |
---|
35 | } |
---|
36 | |
---|
37 | main(int argc, char** argv) |
---|
38 | { |
---|
39 | |
---|
40 | if (cmdline_parser(argc, argv, &args) != 0) |
---|
41 | exit(1); |
---|
42 | |
---|
43 | printf("inter:%d\n",args.interactive_flag); |
---|
44 | |
---|
45 | // process_common_options(&args, argv[0]); |
---|
46 | // process_tok_options(args); |
---|
47 | |
---|
48 | setlocale(LC_CTYPE,""); |
---|
49 | setlocale(LC_COLLATE,""); |
---|
50 | |
---|
51 | while(fgets(buf,256,stdin)) |
---|
52 | { |
---|
53 | |
---|
54 | tokstart=tokend=buf; |
---|
55 | while(*tokend) |
---|
56 | { |
---|
57 | char *prev=tokend; |
---|
58 | ++tokend; |
---|
59 | if(isalpha(*prev) && !isalpha(*tokend)) |
---|
60 | printtoken('W'); |
---|
61 | else if(isdigit(*prev) && !isdigit(*tokend)) |
---|
62 | printtoken('N'); |
---|
63 | else if(isspace(*prev)) |
---|
64 | { |
---|
65 | switch(*prev) |
---|
66 | { |
---|
67 | case ' ': *prev='_'; break; |
---|
68 | case '\t':*prev='t'; break; |
---|
69 | case '\r':*prev='r'; break; |
---|
70 | case '\f':*prev='f'; break; |
---|
71 | case '\n':*prev='n'; |
---|
72 | } |
---|
73 | if(!isspace(*tokend)) |
---|
74 | printtoken('S'); |
---|
75 | } |
---|
76 | else if(ispunct(*prev)) |
---|
77 | printtoken('P'); |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | cmdline_parser_free(&args); |
---|
82 | } |
---|
83 | |
---|
Note: See
TracBrowser
for help on using the repository browser.