source: app/src/rs12/rs12.c @ 25ae32e

help
Last change on this file since 25ae32e was 25ae32e, checked in by obrebski <obrebski@…>, 16 years ago

git-svn-id: svn://atos.wmid.amu.edu.pl/utt@4 e293616e-ec6a-49c2-aa92-f4a8b91c5d16

  • Property mode set to 100644
File size: 845 bytes
Line 
1#include <stdio.h>
2#include <string.h>
3
4#define MAXLINE 1000
5
6main()
7{
8  char buf[MAXLINE+1], outbuf[MAXLINE+1];
9  char form[MAXLINE+1];
10  int len;
11  int curpos,nextpos=0;
12  int a,b;
13  while(fgets(buf,MAXLINE,stdin))
14  {
15    int n=sscanf(buf,"%d %d",&a,&b);
16    if(n==2)
17    {
18      nextpos=a+b;
19      fputs(buf,stdout);
20    }
21    else
22    {
23      if(n==1)
24      {
25        curpos=a;
26        sscanf(buf,"%*d %*s %s",form);
27      }
28      else
29      {
30        curpos=nextpos;
31        sscanf(buf,"%*s %s",form);
32      }
33 
34      if(*form == '*')
35        len=0;
36      else
37      {
38        char *f = form;
39        for(len=0; *f; ++f) if(*f != '\\') ++len;
40      }
41     
42      char *buf1=buf; while(!isalpha(*buf1)) ++buf1;
43      sprintf(outbuf,"%04i %02i %s", curpos, len, buf1);
44      fputs(outbuf,stdout);
45      nextpos = curpos+len;
46    }   
47  }
48}
Note: See TracBrowser for help on using the repository browser.