Commit 173ef256 authored by dragontamer lance's avatar dragontamer lance

Began work on revamp. Created in a new branch because I am working on the...

Began work on revamp. Created in a new branch because I am working on the decoder first, and fixing the encoder afterwards, and I don't want to leave master in a totally broken state.
parent 2d8c4921
......@@ -23,55 +23,73 @@ int main(int argc, char **argv)
i++;
}
}
/* now we are at first inv line */
/* now we have been carried to the first line we care about.*/
/* each line starts with a letter S so we need to skip that */
char str[4]; /* ascii is limited in size */
str[3]='\0';
i=0;
if(fgetc(infile) == 'S') /* progress ahead of 'S' */
/* if(fgetc(infile) == 'S') *//* progress ahead of 'S' */
while(achar != EOF)
{
while(achar != EOF)
while(achar != ';' && achar != EOF )
{
while(achar != ';' && achar != EOF)
if(achar == '\n')
{
while(isdigit(achar=fgetc(infile)) && i < 3)
/* we know the first bit of data on each line is a string key */
/* since my current idea is to mark string beginnings with '(',
do that as long as next char isn't EOF. Then come back.*/
int tmp=fgetc(infile);
if(tmp != EOF)
{
str[i]=achar;
i++;
putchar('"');
ungetc(tmp,infile);
}
int isok=0;
i=0;
while(i<3 && str[i] != '\0' && isok == 0)
{
if(!isascii(str[i]) || str[i] == '\0')
{
isok=1;
}
i++;
}
if(isok==0 && atoi(str) != '\0')
{
printf("%c",(char)atoi(str));
}
str[0]='\0';
str[1]='\0';
str[2]='\0';
i=0;
} /* ';' reached */
if(achar == ';')
}
while(isdigit(achar=fgetc(infile)) && i < 3)
{
putchar('\0');
putchar(';');
str[i]=achar;
i++;
}
/* print out rest of line since we don't know what it is yet */
while(achar != '\n' && achar != EOF && achar != 'S' && isascii(achar))
int isok=0;
i=0;
while(i<3 && str[i] != '\0' && isok == 0)
{
achar=fgetc(infile);
if(achar != '\0')
if(!isascii(str[i]) || str[i] == '\0')
{
printf("%c",achar);
isok=1;
}
i++;
}
if(isok==0 && atoi(str) != '\0')
{
printf("%c",(char)atoi(str));
}
str[0]='\0';
str[1]='\0';
str[2]='\0';
i=0;
} /* ';' reached */
if(achar == ';')
{
/* terminate string */
/* putchar('\0');*/
/* putchar(')');*/
putchar('"');
putchar(';');
}
while(achar != '\n' && achar != EOF && achar != 'S' && isascii(achar))
{
achar=fgetc(infile);
if(achar != '\0' && achar != 'S')
{
printf("%c",achar);
}
else if(achar == 'S')
{
putchar('"'); /* open new string */
}
} /* != EOF */
}
return 0;
......
Decoder (csv2ascii):
We should, but currently don't:
Keep track of whether we're in a string or not. if we aren't, 'S' represents
the start of a string, and we go into a different function to read out the
string until we hit a semicolon. Semicolons indicate the termination of
strings.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment