chiark
/
gitweb
/
~mdw
/
bascat
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
992dc05
)
Fix decoding of line numbers.
author
mdw
<mdw>
Thu, 25 Nov 1999 01:08:57 +0000
(
01:08
+0000)
committer
mdw
<mdw>
Thu, 25 Nov 1999 01:08:57 +0000
(
01:08
+0000)
bascat.c
patch
|
blob
|
blame
|
history
diff --git
a/bascat.c
b/bascat.c
index b685a5cd0ff393665b2ffbf67b816c4e6cb9c05b..48e032eaa8aa3b9da7689bac626c99d8df6f996e 100644
(file)
--- a/
bascat.c
+++ b/
bascat.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: bascat.c,v 1.
4 1999/10/28 10:42:23
mdw Exp $
+ * $Id: bascat.c,v 1.
5 1999/11/25 01:08:57
mdw Exp $
*
* Display BBC BASIC programs more or less anywhere
*
*
* Display BBC BASIC programs more or less anywhere
*
@@
-29,6
+29,9
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: bascat.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: bascat.c,v $
+ * Revision 1.5 1999/11/25 01:08:57 mdw
+ * Fix decoding of line numbers.
+ *
* Revision 1.4 1999/10/28 10:42:23 mdw
* More minor twiddling.
*
* Revision 1.4 1999/10/28 10:42:23 mdw
* More minor twiddling.
*
@@
-226,7
+229,7
@@
static void keyword(const char *s, FILE *fp)
* Use: Decodes multibyte tokens.
*/
* Use: Decodes multibyte tokens.
*/
-static int mbtok(int byte, const char *t[], int n, FILE *
fp)
+static int mbtok(int byte, const char *t[], int n, FILE *fp)
{
byte -= 0x8E;
if (byte >= n)
{
byte -= 0x8E;
if (byte >= n)
@@
-246,7
+249,7
@@
static int mbtok(int byte, const char *t[], int n, FILE * fp)
* Use: Decodes a byte, changing states as necessary.
*/
* Use: Decodes a byte, changing states as necessary.
*/
-static int decode(int byte, FILE *
fp)
+static int decode(int byte, FILE *fp)
{
switch (state) {
{
switch (state) {
@@
-324,17
+327,20
@@
static int decode(int byte, FILE * fp)
/* --- Encoded line number states --- */
case s_linex:
/* --- Encoded line number states --- */
case s_linex:
- lineno = ((((byte << 2) | (byte << 12)) & 0xc0c0u) ^ 0x4040u);
+ byte ^= 0x54;
+ lineno = (((byte & 0x30) << 2) |
+ ((byte & 0x0c) << 12) |
+ ((byte & 0x03) << 16));
state++;
break;
case s_liney:
state++;
break;
case s_liney:
- lineno |= byte & 0x3f
u
;
+ lineno |= byte & 0x3f;
state++;
break;
case s_linez:
state++;
break;
case s_linez:
- lineno |= (byte
<< 8) & 0x3fu
;
+ lineno |= (byte
& 0x3f) << 8
;
fprintf(fp, "%u", lineno);
state = s_normal;
break;
fprintf(fp, "%u", lineno);
state = s_normal;
break;
@@
-386,7
+392,7
@@
static int line(FILE *in, FILE *out)
goto eof;
len -= 4;
goto eof;
len -= 4;
- state = s_
normal
;
+ state = s_
keyword
;
while (len) {
byte = getc(in);
D( fprintf(stderr, "state == %i, byte == %i\n",
while (len) {
byte = getc(in);
D( fprintf(stderr, "state == %i, byte == %i\n",