subtract 'a' from indices for marks

Given:

static int marks['z' - 'a'];
marks[c];

In this case c is the character read and index is out of bounds. We
need marks[c - 'a']

While playing around with optimization settings gcc caught caught this.

Also fix one check for c, change from isalpha to islower.

-emg

From 2cc36818283e9068576c1042690c016a81b709a3 Mon Sep 17 00:00:00 2001
From: Evan Gates <evan.gates@gmail.com>
Date: Fri, 15 Jul 2016 09:52:39 -0700
Subject: [PATCH] fix marks indexing
This commit is contained in:
Evan Gates 2016-07-15 09:57:50 -07:00 committed by sin
parent 3c12b287ec
commit e3f497e1f6

6
ed.c
View File

@ -478,9 +478,9 @@ linenum(int *line)
break; break;
case '\'': case '\'':
skipblank(); skipblank();
if (!isalpha(c = input())) if (!islower(c = input()))
error("invalid mark character"); error("invalid mark character");
if (!(ln = marks[c])) if (!(ln = marks[c - 'a']))
error("invalid address"); error("invalid address");
break; break;
case '$': case '$':
@ -1191,7 +1191,7 @@ repeat:
error("invalid mark character"); error("invalid mark character");
chkprint(1); chkprint(1);
deflines(curln, curln); deflines(curln, curln);
marks[c] = line1; marks[c - 'a'] = line1;
break; break;
case 'P': case 'P':
if (nlines > 0) if (nlines > 0)