Skip to content

Commit c575fc9

Browse files
committed
remove special case handling for directories, whatever the usecase was for this. Emit control codes for spaces right after the line number, which would otherwise be removed by the parser when tokenizing again. Spaces at the end of the line still needs to be fixed - this will require more involved rewrite :/
git-svn-id: https://svn.code.sf.net/p/vice-emu/code/trunk@45962 379a1393-f5fb-40a0-bcee-ef074d9b53f7
1 parent ca009c7 commit c575fc9

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

vice/src/tools/petcat/petcat.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,8 +1882,9 @@ static int p_expand(int version, int addr, int ctrls)
18821882
{
18831883
static char line[4];
18841884
int c = 0;
1885-
int quote, spnum, directory = 0;
1885+
int quote, spnum;
18861886
int sysflg = 0;
1887+
int initialspace = 0;
18871888

18881889
void *checksummer_data = NULL;
18891890
if (checksummer) {
@@ -1906,24 +1907,11 @@ static int p_expand(int version, int addr, int ctrls)
19061907
checksummer->init(checksummer_data, spnum);
19071908
}
19081909

1909-
if (directory) {
1910-
if (spnum >= 100) {
1911-
spnum = 0;
1912-
} else if (spnum >= 10) {
1913-
spnum = 1;
1914-
} else {
1915-
spnum = 2;
1916-
}
1917-
}
1918-
19191910
/* prevent list protection from terminating listing */
1920-
19211911
while ((c = getc(source)) != EOF && !c) {
19221912
}
19231913

1924-
if (c == 0x12 && !line[2] && !line[3]) { /* 00 00 12 22 */
1925-
directory++;
1926-
}
1914+
initialspace = (c == 0x20);
19271915

19281916
do {
19291917
if (checksummer) {
@@ -1932,6 +1920,8 @@ static int p_expand(int version, int addr, int ctrls)
19321920

19331921
if (c == 0x22) {
19341922
quote ^= c;
1923+
} else if (c != 0x20) {
1924+
initialspace = 0;
19351925
}
19361926

19371927
/* Simons' basic. Tokens are prefixed by $64 */
@@ -2051,11 +2041,6 @@ static int p_expand(int version, int addr, int ctrls)
20512041
continue;
20522042
} /* quote */
20532043

2054-
if (directory && spnum && c == 0x20) {
2055-
spnum--; /* eat spaces to adjust directory lines */
2056-
continue;
2057-
}
2058-
20592044
/* some codes must always be converted to control codes, else they can't
20602045
be tokenized into the exact same thing again */
20612046
if ((c == 0x0d) || /* return */
@@ -2069,6 +2054,12 @@ static int p_expand(int version, int addr, int ctrls)
20692054
(c == 0x5e) /* literal "^" (else converts into a token) */
20702055
){
20712056
out_ctrl((int)c); /* output as control code */
2057+
} else if (c == 0x20) {
2058+
if (initialspace) {
2059+
out_ctrl((int)c); /* output as control code */
2060+
} else {
2061+
_p_toascii((int)c, version, ctrls, quote); /* convert character */
2062+
}
20722063
} else {
20732064
_p_toascii((int)c, version, ctrls, quote); /* convert character */
20742065
}

0 commit comments

Comments
 (0)