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