Last change
on this file since a26cf42 was
b5884b3,
checked in by Mateusz Hromada <ruanda@…>, 15 years ago
|
Migration to new build system.
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[b5884b3] | 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.