Migration to new build system.

* rs12 moved and checked
This commit is contained in:
Mateusz Hromada 2009-06-09 20:50:22 +02:00
parent 4518a0b7b6
commit b5884b3fd6
4 changed files with 72 additions and 64 deletions

View File

@ -1,15 +0,0 @@
PAR = -m32
# -static
main: rs12
rs12: rs12.c
gcc $(PAR) -o rs12 rs12.c
clean:
rm rs12
copy:
ifdef UTT_BIN_DIR
cp rs12 ${UTT_BIN_DIR}
endif

View File

@ -1,48 +0,0 @@
#include <stdio.h>
#include <string.h>
#define MAXLINE 1000
main()
{
char buf[MAXLINE+1], outbuf[MAXLINE+1];
char form[MAXLINE+1];
int len;
int curpos,nextpos=0;
int a,b;
while(fgets(buf,MAXLINE,stdin))
{
int n=sscanf(buf,"%d %d",&a,&b);
if(n==2)
{
nextpos=a+b;
fputs(buf,stdout);
}
else
{
if(n==1)
{
curpos=a;
sscanf(buf,"%*d %*s %s",form);
}
else
{
curpos=nextpos;
sscanf(buf,"%*s %s",form);
}
if(*form == '*')
len=0;
else
{
char *f = form;
for(len=0; *f; ++f) if(*f != '\\') ++len;
}
char *buf1=buf; while(!isalpha(*buf1)) ++buf1;
sprintf(outbuf,"%04i %02i %s", curpos, len, buf1);
fputs(outbuf,stdout);
nextpos = curpos+len;
}
}
}

View File

@ -45,7 +45,7 @@ ALL_FFLAGS = -t \$(FFLAGS)
VPATH = ./src VPATH = ./src
PROGRAMS = tok sen fla gph kot unfla grp mar ser kon rm12 PROGRAMS = tok sen fla gph kot unfla grp mar ser kon rm12 rs12
TOK_OBJ_FILES = tok.o tok_cmdline.o TOK_OBJ_FILES = tok.o tok_cmdline.o
TOK_FLEX_FILES = tok.l TOK_FLEX_FILES = tok.l
@ -92,6 +92,10 @@ kon: \$(KON_PERL_FILES)
RM12_SED_FILES = rm12.sed RM12_SED_FILES = rm12.sed
rm12: \$(RM12_SED_FILES) rm12: \$(RM12_SED_FILES)
RS12_OBJ_FILES = rs12.o
rs12: \$(RS12_OBJ_FILES)
rs12.o: rs12.c
CONFIG_FILES = src/config.h Makefile CONFIG_FILES = src/config.h Makefile
.SUFFIXES: .SUFFIXES:
@ -126,6 +130,7 @@ clean:
\$(RM) \$(SEN_OBJ_FILES) \$(RM) \$(SEN_OBJ_FILES)
\$(RM) \$(patsubst %.l,%.c,\$(SEN_FLEX_FILES)) \$(RM) \$(patsubst %.l,%.c,\$(SEN_FLEX_FILES))
\$(RM) \$(FLA_OBJ_FILES) \$(RM) \$(FLA_OBJ_FILES)
\$(RM) \$(RS12_OBJ_FILES)
.PHONY: distclean .PHONY: distclean
distclean: clean distclean: clean

66
src/rs12.c Normal file
View File

@ -0,0 +1,66 @@
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#define MAXLINE 1000
int main()
{
char buf[MAXLINE];
char outbuf[MAXLINE];
char form[MAXLINE];
int len;
int curpos;
int nextpos=0;
int a;
int b;
while( fgets(buf, MAXLINE, stdin) )
{
int n = sscanf(buf, "%d %d", &a, &b);
if( 2 == n )
{
nextpos = a + b;
fputs(buf, stdout);
}
else
{
if( 1 == n )
{
curpos = a;
sscanf(buf, "%*d %*s %s", form);
}
else
{
curpos = nextpos;
sscanf(buf, "%*s %s", form);
}
if( '*' == *form )
{
len = 0;
}
else
{
char *f = form;
for( len = 0; *f; ++f )
{
if( '\\' != *f)
{
++len;
}
}
}
char *buf1 = buf;
while( !isalpha(*buf1) )
{
++buf1;
}
sprintf(outbuf, "%04i %02i %s", curpos, len, buf1);
fputs(outbuf, stdout);
nextpos = curpos + len;
}
}
return 0;
}