Last change
on this file was
5f4d9c3,
checked in by Maciej Prill <mprill@…>, 13 years ago
|
Rewritten the build system, added lem UTF-8 version.
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[5f4d9c3] | 1 | #include <ctype.h> |
---|
| 2 | #include <stdio.h> |
---|
| 3 | #include <string.h> |
---|
| 4 | |
---|
| 5 | #define MAXLINE 1000 |
---|
| 6 | |
---|
| 7 | int main() |
---|
| 8 | { |
---|
| 9 | char buf[MAXLINE]; |
---|
| 10 | char outbuf[MAXLINE]; |
---|
| 11 | char form[MAXLINE]; |
---|
| 12 | int len; |
---|
| 13 | int curpos; |
---|
| 14 | int nextpos=0; |
---|
| 15 | int a; |
---|
| 16 | int b; |
---|
| 17 | |
---|
| 18 | while( fgets(buf, MAXLINE, stdin) ) |
---|
| 19 | { |
---|
| 20 | int n = sscanf(buf, "%d %d", &a, &b); |
---|
| 21 | if( 2 == n ) |
---|
| 22 | { |
---|
| 23 | nextpos = a + b; |
---|
| 24 | fputs(buf, stdout); |
---|
| 25 | } |
---|
| 26 | else |
---|
| 27 | { |
---|
| 28 | if( 1 == n ) |
---|
| 29 | { |
---|
| 30 | curpos = a; |
---|
| 31 | sscanf(buf, "%*d %*s %s", form); |
---|
| 32 | } |
---|
| 33 | else |
---|
| 34 | { |
---|
| 35 | curpos = nextpos; |
---|
| 36 | sscanf(buf, "%*s %s", form); |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | if( '*' == *form ) |
---|
| 40 | { |
---|
| 41 | len = 0; |
---|
| 42 | } |
---|
| 43 | else |
---|
| 44 | { |
---|
| 45 | char *f = form; |
---|
| 46 | for( len = 0; *f; ++f ) |
---|
| 47 | { |
---|
| 48 | if( '\\' != *f) |
---|
| 49 | { |
---|
| 50 | ++len; |
---|
| 51 | } |
---|
| 52 | } |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | char *buf1 = buf; |
---|
| 56 | while( !isalpha(*buf1) ) |
---|
| 57 | { |
---|
| 58 | ++buf1; |
---|
| 59 | } |
---|
| 60 | sprintf(outbuf, "%04i %02i %s", curpos, len, buf1); |
---|
| 61 | fputs(outbuf, stdout); |
---|
| 62 | nextpos = curpos + len; |
---|
| 63 | } |
---|
| 64 | } |
---|
| 65 | return 0; |
---|
| 66 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.