version 1.3, 2000/02/27 16:10:19 |
version 1.4, 2000/04/13 06:12:14 |
|
|
/* |
/* |
* Extended (M-X) commands, rebinding, and |
* Extended (M-X) commands, rebinding, and |
* startup file processing. |
* startup file processing. |
*/ |
*/ |
#include "def.h" |
#include "def.h" |
|
|
#include "key.h" |
#include "key.h" |
#ifndef NO_STARTUP |
#ifndef NO_STARTUP |
#ifndef BINDKEY |
#ifndef BINDKEY |
#define BINDKEY /* bindkey is used by FKEYS startup code */ |
#define BINDKEY /* bindkey is used by FKEYS startup code */ |
#endif |
#endif |
#endif |
#endif |
#endif |
#endif |
|
|
extern int rescan(); |
static KEYMAP *realocmap __P((KEYMAP *)); |
|
static VOID fixmap __P((KEYMAP *, KEYMAP*, KEYMAP*)); |
|
static char *skipwhite __P((char *)); |
|
static char *parsetoken __P((char *)); |
|
int load __P((char *)); |
|
int excline __P((char *)); |
|
|
/* insert a string, mainly for use from macros (created by selfinsert) */ |
/* insert a string, mainly for use from macros (created by selfinsert) */ |
/*ARGSUSED*/ |
/* ARGSUSED */ |
|
int |
insert(f, n) |
insert(f, n) |
int f, n; |
int f, n; |
{ |
{ |
register char *cp; |
char *cp; |
char buf[128]; |
char buf[128]; |
#ifndef NO_MACRO |
#ifndef NO_MACRO |
register int count; |
int count; |
int c; |
int c; |
|
|
if(inmacro) { |
if (inmacro) { |
while(--n >= 0) { |
while (--n >= 0) { |
for(count = 0; count < maclcur->l_used; count++) { |
for (count = 0; count < maclcur->l_used; count++) { |
if((((c=maclcur->l_text[count]) == '\n') ? lnewline() |
if ((((c = maclcur->l_text[count]) == '\n') |
: linsert(1, c)) != TRUE) return FALSE; |
? lnewline() : linsert(1, c)) != TRUE) |
} |
return FALSE; |
|
} |
|
} |
|
maclcur = maclcur->l_fp; |
|
return TRUE; |
} |
} |
maclcur = maclcur->l_fp; |
if (n == 1) |
return TRUE; |
thisflag |= CFINS; /* CFINS means selfinsert can tack on |
} |
* end */ |
if(n==1) thisflag |= CFINS; /* CFINS means selfinsert can tack on end */ |
|
#endif |
#endif |
if(eread("Insert: ", buf, sizeof(buf), EFNEW) == FALSE) return FALSE; |
if (eread("Insert: ", buf, sizeof(buf), EFNEW) == FALSE) |
while(--n >= 0) { |
|
cp = buf; |
|
while(*cp) { |
|
if(((*cp == '\n') ? lnewline() : linsert(1, *cp)) != TRUE) |
|
return FALSE; |
return FALSE; |
cp++; |
while (--n >= 0) { |
|
cp = buf; |
|
while (*cp) { |
|
if (((*cp == '\n') ? lnewline() : linsert(1, *cp)) |
|
!= TRUE) |
|
return FALSE; |
|
cp++; |
|
} |
} |
} |
} |
return TRUE; |
return TRUE; |
|
} |
} |
|
|
/* |
/* |
|
|
* don't have them. Care is taken so running out of memory will leave |
* don't have them. Care is taken so running out of memory will leave |
* the keymap in a usable state. |
* the keymap in a usable state. |
*/ |
*/ |
static int remap(curmap, c, funct, pref_map) |
static int |
register KEYMAP *curmap;/* pointer to the map being changed */ |
remap(curmap, c, funct, pref_map) |
int c; /* character being changed */ |
KEYMAP *curmap; /* pointer to the map being changed */ |
PF funct; /* function being changed to */ |
int c; /* character being changed */ |
KEYMAP *pref_map; /* if funct==prefix, map to bind to or NULL for new */ |
PF funct; /* function being changed to */ |
|
KEYMAP *pref_map; /* if funct==prefix, map to bind to or |
|
NULL for new */ |
/* extern MAP_ELEMENT *ele; must be set before calling */ |
/* extern MAP_ELEMENT *ele; must be set before calling */ |
{ |
{ |
register int i; |
int i; |
int n1, n2, nold; |
int n1, n2, nold; |
KEYMAP *mp; |
KEYMAP *mp; |
PF *pfp; |
PF *pfp; |
MAP_ELEMENT *mep; |
MAP_ELEMENT *mep; |
static KEYMAP *realocmap(); |
|
|
|
if(ele >= &curmap->map_element[curmap->map_num] || c < ele->k_base) { |
if (ele >= &curmap->map_element[curmap->map_num] || c < ele->k_base) { |
if(ele > &curmap->map_element[0] && (funct!=prefix || |
if (ele > &curmap->map_element[0] && (funct != prefix || |
(ele-1)->k_prefmap==NULL)) { |
(ele - 1)->k_prefmap == NULL)) { |
n1 = c - (ele-1)->k_num; |
n1 = c - (ele - 1)->k_num; |
} else n1 = HUGE; |
} else |
if(ele < &curmap->map_element[curmap->map_num] && (funct!=prefix || |
n1 = HUGE; |
ele->k_prefmap==NULL)) { |
if (ele < &curmap->map_element[curmap->map_num] && |
n2 = ele->k_base - c; |
(funct != prefix || ele->k_prefmap == NULL)) { |
} else n2 = HUGE; |
n2 = ele->k_base - c; |
if(n1 <= MAPELEDEF && n1 <= n2) { |
} else |
ele--; |
n2 = HUGE; |
if((pfp = (PF *)malloc((unsigned)(c - ele->k_base+1) |
if (n1 <= MAPELEDEF && n1 <= n2) { |
* sizeof(PF))) == NULL) { |
ele--; |
ewprintf("Out of memory"); |
if ((pfp = (PF *) malloc((c - ele->k_base + 1) * |
return FALSE; |
sizeof(PF))) == NULL) { |
} |
ewprintf("Out of memory"); |
nold = ele->k_num - ele->k_base + 1; |
return FALSE; |
for(i=0; i < nold; i++) |
} |
pfp[i] = ele->k_funcp[i]; |
nold = ele->k_num - ele->k_base + 1; |
while(--n1) pfp[i++] = curmap->map_default; |
for (i = 0; i < nold; i++) |
pfp[i] = funct; |
pfp[i] = ele->k_funcp[i]; |
ele->k_num = c; |
while (--n1) |
ele->k_funcp = pfp; |
pfp[i++] = curmap->map_default; |
} else if(n2 <= MAPELEDEF) { |
pfp[i] = funct; |
if((pfp = (PF *)malloc((unsigned)(ele->k_num - c + 1) |
ele->k_num = c; |
* sizeof(PF))) == NULL) { |
ele->k_funcp = pfp; |
ewprintf("Out of memory"); |
} else if (n2 <= MAPELEDEF) { |
return FALSE; |
if ((pfp = (PF *) malloc((ele->k_num - c + 1) |
} |
* sizeof(PF))) == NULL) { |
nold = ele->k_num - ele->k_base + 1; |
ewprintf("Out of memory"); |
for(i=0; i < nold; i++) |
return FALSE; |
pfp[i+n2] = ele->k_funcp[i]; |
} |
while(--n2) pfp[n2] = curmap->map_default; |
nold = ele->k_num - ele->k_base + 1; |
pfp[0] = funct; |
for (i = 0; i < nold; i++) |
ele->k_base = c; |
pfp[i + n2] = ele->k_funcp[i]; |
ele->k_funcp = pfp; |
while (--n2) |
} else { |
pfp[n2] = curmap->map_default; |
if(curmap->map_num >= curmap->map_max && |
pfp[0] = funct; |
(curmap = realocmap(curmap)) == NULL) return FALSE; |
ele->k_base = c; |
if((pfp = (PF *)malloc(sizeof(PF))) == NULL) { |
ele->k_funcp = pfp; |
ewprintf("Out of memory"); |
|
return FALSE; |
|
} |
|
pfp[0] = funct; |
|
for(mep = &curmap->map_element[curmap->map_num]; mep > ele; mep--) { |
|
mep->k_base = (mep-1)->k_base; |
|
mep->k_num = (mep-1)->k_num; |
|
mep->k_funcp = (mep-1)->k_funcp; |
|
mep->k_prefmap = (mep-1)->k_prefmap; |
|
} |
|
ele->k_base = c; |
|
ele->k_num = c; |
|
ele->k_funcp = pfp; |
|
ele->k_prefmap = NULL; |
|
curmap->map_num++; |
|
} |
|
if(funct == prefix) { |
|
if(pref_map != NULL) { |
|
ele->k_prefmap = pref_map; |
|
} else { |
} else { |
if((mp = (KEYMAP *)malloc(sizeof(KEYMAP) + |
if (curmap->map_num >= curmap->map_max && |
(MAPINIT-1)*sizeof(MAP_ELEMENT))) == NULL) { |
(curmap = realocmap(curmap)) == NULL) |
ewprintf("Out of memory"); |
return FALSE; |
ele->k_funcp[c - ele->k_base] = curmap->map_default; |
if ((pfp = (PF *) malloc(sizeof(PF))) == NULL) { |
return FALSE; |
ewprintf("Out of memory"); |
} |
return FALSE; |
mp->map_num = 0; |
} |
mp->map_max = MAPINIT; |
pfp[0] = funct; |
mp->map_default = rescan; |
for (mep = &curmap->map_element[curmap->map_num]; |
ele->k_prefmap = mp; |
mep > ele; mep--) { |
|
mep->k_base = (mep - 1)->k_base; |
|
mep->k_num = (mep - 1)->k_num; |
|
mep->k_funcp = (mep - 1)->k_funcp; |
|
mep->k_prefmap = (mep - 1)->k_prefmap; |
|
} |
|
ele->k_base = c; |
|
ele->k_num = c; |
|
ele->k_funcp = pfp; |
|
ele->k_prefmap = NULL; |
|
curmap->map_num++; |
} |
} |
} |
if (funct == prefix) { |
|
if (pref_map != NULL) { |
|
ele->k_prefmap = pref_map; |
|
} else { |
|
if (!(mp = (KEYMAP *) malloc(sizeof(KEYMAP) + |
|
(MAPINIT - 1) * sizeof(MAP_ELEMENT)))) { |
|
ewprintf("Out of memory"); |
|
ele->k_funcp[c - ele->k_base] = |
|
curmap->map_default; |
|
return FALSE; |
|
} |
|
mp->map_num = 0; |
|
mp->map_max = MAPINIT; |
|
mp->map_default = rescan; |
|
ele->k_prefmap = mp; |
|
} |
|
} |
} else { |
} else { |
n1 = c - ele->k_base; |
n1 = c - ele->k_base; |
if(ele->k_funcp[n1] == funct && (funct!=prefix || pref_map==NULL || |
if (ele->k_funcp[n1] == funct && (funct != prefix || |
pref_map==ele->k_prefmap)) |
pref_map == NULL || pref_map == ele->k_prefmap)) |
return TRUE; /* no change */ |
return TRUE; /* no change */ |
if(funct!=prefix || ele->k_prefmap==NULL) { |
if (funct != prefix || ele->k_prefmap == NULL) { |
if(ele->k_funcp[n1] == prefix) |
if (ele->k_funcp[n1] == prefix) |
ele->k_prefmap = (KEYMAP *)NULL; |
ele->k_prefmap = (KEYMAP *) NULL; |
ele->k_funcp[n1] = funct; /* easy case */ |
ele->k_funcp[n1] = funct; /* easy case */ |
if(funct==prefix) { |
if (funct == prefix) { |
if(pref_map!=NULL) |
if (pref_map != NULL) |
ele->k_prefmap = pref_map; |
ele->k_prefmap = pref_map; |
else { |
else { |
if((mp = (KEYMAP *)malloc(sizeof(KEYMAP) + |
if (!(mp = malloc(sizeof(KEYMAP) + |
(MAPINIT-1)*sizeof(MAP_ELEMENT))) == NULL) { |
(MAPINIT - 1) * sizeof(MAP_ELEMENT)))) { |
ewprintf("Out of memory"); |
ewprintf("Out of memory"); |
ele->k_funcp[c - ele->k_base] = curmap->map_default; |
ele->k_funcp[c - ele->k_base] = |
return FALSE; |
curmap->map_default; |
|
return FALSE; |
|
} |
|
mp->map_num = 0; |
|
mp->map_max = MAPINIT; |
|
mp->map_default = rescan; |
|
ele->k_prefmap = mp; |
|
} |
} |
} |
mp->map_num = 0; |
} else { |
mp->map_max = MAPINIT; |
/* |
mp->map_default = rescan; |
* This case is the splits |
ele->k_prefmap = mp; |
* determine which side of the break c goes on |
} |
* 0 = after break; 1 = before break |
|
*/ |
|
n2 = 1; |
|
for (i = 0; n2 && i < n1; i++) |
|
n2 &= ele->k_funcp[i] != prefix; |
|
if (curmap->map_num >= curmap->map_max && |
|
(curmap = realocmap(curmap)) == NULL) |
|
return FALSE; |
|
if (!(pfp = malloc((ele->k_num - c + !n2) * sizeof(PF)))) { |
|
ewprintf("Out of memory"); |
|
return FALSE; |
|
} |
|
ele->k_funcp[n1] = prefix; |
|
for (i = n1 + n2; i <= ele->k_num - ele->k_base; i++) |
|
pfp[i - n1 - n2] = ele->k_funcp[i]; |
|
for (mep = &curmap->map_element[curmap->map_num]; |
|
mep > ele; mep--) { |
|
mep->k_base = (mep - 1)->k_base; |
|
mep->k_num = (mep - 1)->k_num; |
|
mep->k_funcp = (mep - 1)->k_funcp; |
|
mep->k_prefmap = (mep - 1)->k_prefmap; |
|
} |
|
ele->k_num = c - !n2; |
|
(ele + 1)->k_base = c + n2; |
|
(ele + 1)->k_funcp = pfp; |
|
ele += !n2; |
|
ele->k_prefmap = NULL; |
|
curmap->map_num++; |
|
if (pref_map == NULL) { |
|
if ((mp = malloc(sizeof(KEYMAP) + (MAPINIT - 1) |
|
* sizeof(MAP_ELEMENT))) == NULL) { |
|
ewprintf("Out of memory"); |
|
ele->k_funcp[c - ele->k_base] = |
|
curmap->map_default; |
|
return FALSE; |
|
} |
|
mp->map_num = 0; |
|
mp->map_max = MAPINIT; |
|
mp->map_default = rescan; |
|
ele->k_prefmap = mp; |
|
} else |
|
ele->k_prefmap = pref_map; |
} |
} |
} else { |
|
/* this case is the splits */ |
|
/* determine which side of the break c goes on */ |
|
/* 0 = after break; 1 = before break */ |
|
n2 = 1; |
|
for(i=0; n2 && i < n1; i++) |
|
n2 &= ele->k_funcp[i] != prefix; |
|
if(curmap->map_num >= curmap->map_max && |
|
(curmap = realocmap(curmap)) == NULL) return FALSE; |
|
if((pfp = (PF *)malloc((unsigned)(ele->k_num - c + !n2) |
|
* sizeof(PF))) == NULL) { |
|
ewprintf("Out of memory"); |
|
return FALSE; |
|
} |
|
ele->k_funcp[n1] = prefix; |
|
for(i=n1+n2; i <= ele->k_num - ele->k_base; i++) |
|
pfp[i-n1-n2] = ele->k_funcp[i]; |
|
for(mep = &curmap->map_element[curmap->map_num]; mep > ele; mep--) { |
|
mep->k_base = (mep-1)->k_base; |
|
mep->k_num = (mep-1)->k_num; |
|
mep->k_funcp = (mep-1)->k_funcp; |
|
mep->k_prefmap = (mep-1)->k_prefmap; |
|
} |
|
ele->k_num = c - !n2; |
|
(ele+1)->k_base = c + n2; |
|
(ele+1)->k_funcp = pfp; |
|
ele += !n2; |
|
ele->k_prefmap = NULL; |
|
curmap->map_num++; |
|
if(pref_map == NULL) { |
|
if((mp = (KEYMAP *)malloc(sizeof(KEYMAP) + |
|
(MAPINIT-1)*sizeof(MAP_ELEMENT))) == NULL) { |
|
ewprintf("Out of memory"); |
|
ele->k_funcp[c - ele->k_base] = curmap->map_default; |
|
return FALSE; |
|
} |
|
mp->map_num = 0; |
|
mp->map_max = MAPINIT; |
|
mp->map_default = rescan; |
|
ele->k_prefmap = mp; |
|
} else ele->k_prefmap = pref_map; |
|
} |
|
} |
} |
return TRUE; |
return TRUE; |
} |
} |
|
|
/* reallocate a keymap, used above */ |
/* |
static KEYMAP *realocmap(curmap) |
* Reallocate a keymap, used above. |
register KEYMAP *curmap; |
*/ |
|
static KEYMAP * |
|
realocmap(curmap) |
|
KEYMAP *curmap; |
{ |
{ |
register KEYMAP *mp; |
KEYMAP *mp; |
register int i; |
int i; |
static VOID fixmap(); |
extern int nmaps; |
extern int nmaps; |
|
|
|
if((mp = (KEYMAP *)malloc((unsigned)(sizeof(KEYMAP)+ |
if ((mp = (KEYMAP *) malloc((unsigned) (sizeof(KEYMAP) + |
(curmap->map_max+(MAPGROW-1))*sizeof(MAP_ELEMENT)))) == NULL) { |
(curmap->map_max + (MAPGROW - 1)) * sizeof(MAP_ELEMENT)))) == NULL) { |
ewprintf("Out of memory"); |
ewprintf("Out of memory"); |
return NULL; |
return NULL; |
} |
} |
mp->map_num = curmap->map_num; |
mp->map_num = curmap->map_num; |
mp->map_max = curmap->map_max + MAPGROW; |
mp->map_max = curmap->map_max + MAPGROW; |
mp->map_default = curmap->map_default; |
mp->map_default = curmap->map_default; |
for(i=curmap->map_num; i--; ) { |
for (i = curmap->map_num; i--;) { |
mp->map_element[i].k_base = curmap->map_element[i].k_base; |
mp->map_element[i].k_base = curmap->map_element[i].k_base; |
mp->map_element[i].k_num = curmap->map_element[i].k_num; |
mp->map_element[i].k_num = curmap->map_element[i].k_num; |
mp->map_element[i].k_funcp = curmap->map_element[i].k_funcp; |
mp->map_element[i].k_funcp = curmap->map_element[i].k_funcp; |
mp->map_element[i].k_prefmap = curmap->map_element[i].k_prefmap; |
mp->map_element[i].k_prefmap = curmap->map_element[i].k_prefmap; |
} |
} |
for(i=nmaps; i--; ) { |
for (i = nmaps; i--;) { |
if(map_table[i].p_map == curmap) map_table[i].p_map = mp; |
if (map_table[i].p_map == curmap) |
else fixmap(curmap, mp, map_table[i].p_map); |
map_table[i].p_map = mp; |
} |
else |
ele = &mp->map_element[ele - &curmap->map_element[0]]; |
fixmap(curmap, mp, map_table[i].p_map); |
return mp; |
} |
|
ele = &mp->map_element[ele - &curmap->map_element[0]]; |
|
return mp; |
} |
} |
|
|
/* fix references to a reallocated keymap (recursive) */ |
/* |
static VOID fixmap(curmap, mp, mt) |
* Fix references to a reallocated keymap (recursive). |
register KEYMAP *mt; |
*/ |
register KEYMAP *curmap; |
static VOID |
KEYMAP *mp; |
fixmap(curmap, mp, mt) |
|
KEYMAP *mt; |
|
KEYMAP *curmap; |
|
KEYMAP *mp; |
{ |
{ |
register int i; |
int i; |
|
|
for(i = mt->map_num; i--; ) { |
for (i = mt->map_num; i--;) { |
if(mt->map_element[i].k_prefmap != NULL) { |
if (mt->map_element[i].k_prefmap != NULL) { |
if(mt->map_element[i].k_prefmap == curmap) |
if (mt->map_element[i].k_prefmap == curmap) |
mt->map_element[i].k_prefmap = mp; |
mt->map_element[i].k_prefmap = mp; |
else fixmap(curmap, mp, mt->map_element[i].k_prefmap); |
else |
|
fixmap(curmap, mp, mt->map_element[i].k_prefmap); |
|
} |
} |
} |
} |
|
} |
} |
|
|
/* |
/* |
* do the input for local-set-key, global-set-key and define-key |
* do the input for local-set-key, global-set-key and define-key |
* then call remap to do the work. |
* then call remap to do the work. |
*/ |
*/ |
|
static int |
static int dobind(curmap, p, unbind) |
dobind(curmap, p, unbind) |
register KEYMAP *curmap; |
KEYMAP *curmap; |
char *p; |
char *p; |
int unbind; |
int unbind; |
{ |
{ |
PF funct; |
PF funct; |
char prompt[80]; |
char prompt[80]; |
char *pep; |
char *pep; |
int c; |
int c; |
int s; |
int s; |
KEYMAP *pref_map = NULL; |
KEYMAP *pref_map = NULL; |
|
|
#ifndef NO_MACRO |
#ifndef NO_MACRO |
if(macrodef) { |
if (macrodef) { |
/* keystrokes arn't collected. Not hard, but pretty useless */ |
/* |
/* would not work for function keys in any case */ |
* Keystrokes aren't collected. Not hard, but pretty useless. |
ewprintf("Can't rebind key in macro"); |
* Would not work for function keys in any case. |
return FALSE; |
*/ |
|
ewprintf("Can't rebind key in macro"); |
|
return FALSE; |
} |
} |
#ifndef NO_STARTUP |
#ifndef NO_STARTUP |
if(inmacro) { |
if (inmacro) { |
for(s=0; s < maclcur->l_used - 1; s++) { |
for (s = 0; s < maclcur->l_used - 1; s++) { |
if(doscan(curmap, c=CHARMASK(maclcur->l_text[s])) != prefix) { |
if (doscan(curmap, c = CHARMASK(maclcur->l_text[s])) |
if(remap(curmap, c, prefix, (KEYMAP *)NULL) != TRUE) { |
!= prefix) { |
return FALSE; |
if (remap(curmap, c, prefix, (KEYMAP *) NULL) |
} |
!= TRUE) |
|
return FALSE; |
|
} |
|
curmap = ele->k_prefmap; |
} |
} |
curmap = ele->k_prefmap; |
(VOID) doscan(curmap, c = maclcur->l_text[s]); |
} |
maclcur = maclcur->l_fp; |
(VOID) doscan(curmap, c=maclcur->l_text[s]); |
|
maclcur = maclcur->l_fp; |
|
} else { |
} else { |
#endif |
#endif |
#endif |
#endif |
(VOID) strcpy(prompt, p); |
(VOID) strcpy(prompt, p); |
pep = prompt + strlen(prompt); |
pep = prompt + strlen(prompt); |
for(;;) { |
for (;;) { |
ewprintf("%s", prompt); |
ewprintf("%s", prompt); |
pep[-1] = ' '; |
pep[-1] = ' '; |
pep = keyname(pep, c = getkey(FALSE)); |
pep = keyname(pep, c = getkey(FALSE)); |
if(doscan(curmap,c) != prefix) break; |
if (doscan(curmap, c) != prefix) |
*pep++ = '-'; |
break; |
*pep = '\0'; |
*pep++ = '-'; |
curmap = ele->k_prefmap; |
*pep = '\0'; |
} |
curmap = ele->k_prefmap; |
|
} |
#ifndef NO_STARTUP |
#ifndef NO_STARTUP |
} |
} |
#endif |
#endif |
if(unbind) funct = rescan; |
if (unbind) |
|
funct = rescan; |
else { |
else { |
if ((s=eread("%s to command: ", prompt, 80, EFFUNC|EFNEW, prompt)) |
if ((s = eread("%s to command: ", prompt, 80, EFFUNC | EFNEW, |
!= TRUE) return s; |
prompt)) != TRUE) |
if (((funct = name_function(prompt)) == prefix) ? |
return s; |
(pref_map = name_map(prompt)) == NULL : funct==NULL) { |
if (((funct = name_function(prompt)) == prefix) ? |
ewprintf("[No match]"); |
(pref_map = name_map(prompt)) == NULL : funct == NULL) { |
return FALSE; |
ewprintf("[No match]"); |
} |
return FALSE; |
|
} |
} |
} |
return remap(curmap, c, funct, pref_map); |
return remap(curmap, c, funct, pref_map); |
} |
} |
|
|
* KEYMAP *curmap rather than KEYMAP **mapp. |
* KEYMAP *curmap rather than KEYMAP **mapp. |
*/ |
*/ |
#ifdef BINDKEY |
#ifdef BINDKEY |
|
int |
bindkey(mapp, fname, keys, kcount) |
bindkey(mapp, fname, keys, kcount) |
KEYMAP **mapp; |
KEYMAP **mapp; |
char *fname; |
char *fname; |
KCHAR *keys; |
KCHAR *keys; |
int kcount; |
int kcount; |
{ |
{ |
KEYMAP *curmap = *mapp; |
KEYMAP *curmap = *mapp; |
PF funct; |
PF funct; |
int c; |
int c; |
KEYMAP *pref_map = NULL; |
KEYMAP *pref_map = NULL; |
|
|
if(fname == NULL) funct = rescan; |
if (fname == NULL) |
|
funct = rescan; |
else if (((funct = name_function(fname)) == prefix) ? |
else if (((funct = name_function(fname)) == prefix) ? |
(pref_map = name_map(fname)) == NULL : funct==NULL) { |
(pref_map = name_map(fname)) == NULL : funct == NULL) { |
ewprintf("[No match: %s]", fname); |
ewprintf("[No match: %s]", fname); |
return FALSE; |
return FALSE; |
} |
} |
while(--kcount) { |
while (--kcount) { |
if(doscan(curmap, c = *keys++) != prefix) { |
if (doscan(curmap, c = *keys++) != prefix) { |
if(remap(curmap, c, prefix, (KEYMAP *)NULL) != TRUE) |
if (remap(curmap, c, prefix, (KEYMAP *) NULL) != TRUE) |
return FALSE; |
return FALSE; |
} |
} |
curmap = ele->k_prefmap; |
curmap = ele->k_prefmap; |
} |
} |
(VOID) doscan(curmap, c = *keys); |
(VOID) doscan(curmap, c = *keys); |
return remap(curmap, c, funct, pref_map); |
return remap(curmap, c, funct, pref_map); |
|
|
int |
int |
dobindkey(map, func, str) |
dobindkey(map, func, str) |
KEYMAP *map; |
KEYMAP *map; |
char *func; |
char *func; |
char *str; |
char *str; |
{ |
{ |
int i; |
int i; |
|
|
for (i = 0; *str && i < MAXKEY; i++) { |
for (i = 0; *str && i < MAXKEY; i++) { |
/* XXX - convert numbers w/ strol()? */ |
/* XXX - convert numbers w/ strol()? */ |
if (*str != '\\') |
if (*str != '\\') |
key.k_chars[i] = *str; |
key.k_chars[i] = *str; |
else { |
else { |
switch(*++str) { |
switch (*++str) { |
case 't': case 'T': |
case 't': |
|
case 'T': |
key.k_chars[i] = '\t'; |
key.k_chars[i] = '\t'; |
break; |
break; |
case 'n': case 'N': |
case 'n': |
|
case 'N': |
key.k_chars[i] = '\n'; |
key.k_chars[i] = '\n'; |
break; |
break; |
case 'r': case 'R': |
case 'r': |
|
case 'R': |
key.k_chars[i] = '\r'; |
key.k_chars[i] = '\r'; |
break; |
break; |
case 'e': case 'E': |
case 'e': |
|
case 'E': |
key.k_chars[i] = CCHR('['); |
key.k_chars[i] = CCHR('['); |
break; |
break; |
} |
} |
|
|
str++; |
str++; |
} |
} |
key.k_count = i; |
key.k_count = i; |
return(bindkey(&map, func, key.k_chars, key.k_count)); |
return (bindkey(&map, func, key.k_chars, key.k_count)); |
} |
} |
#endif |
#endif |
#endif |
#endif |
|
|
/* |
/* |
* This function modifies the fundamental keyboard map. |
* This function modifies the fundamental keyboard map. |
*/ |
*/ |
/*ARGSUSED*/ |
/* ARGSUSED */ |
|
int |
bindtokey(f, n) |
bindtokey(f, n) |
|
int f, n; |
{ |
{ |
return dobind(map_table[0].p_map, "Global set key: ", FALSE); |
return dobind(map_table[0].p_map, "Global set key: ", FALSE); |
} |
} |
|
|
/* |
/* |
* This function modifies the current mode's keyboard map. |
* This function modifies the current mode's keyboard map. |
*/ |
*/ |
/*ARGSUSED*/ |
/* ARGSUSED */ |
|
int |
localbind(f, n) |
localbind(f, n) |
|
int f, n; |
{ |
{ |
return dobind(curbp->b_modes[curbp->b_nmodes]->p_map, "Local set key: ", |
|
FALSE); |
return dobind(curbp->b_modes[curbp->b_nmodes]->p_map, "Local set key: ", |
|
FALSE); |
} |
} |
|
|
/* |
/* |
* This function redefines a key in any keymap. |
* This function redefines a key in any keymap. |
*/ |
*/ |
/*ARGSUSED*/ |
/* ARGSUSED */ |
|
int |
define_key(f, n) |
define_key(f, n) |
|
int f, n; |
{ |
{ |
static char buf[48] = "Define key map: "; |
static char buf[48] = "Define key map: "; |
MAPS *mp; |
MAPS *mp; |
char *strncat(); |
char *strncat(); |
|
|
buf[16] = '\0'; |
buf[16] = '\0'; |
if(eread(buf, &buf[16], 48 - 16, EFNEW) != TRUE) return FALSE; |
if (eread(buf, &buf[16], 48 - 16, EFNEW) != TRUE) |
if((mp = name_mode(&buf[16])) == NULL) { |
return FALSE; |
ewprintf("Unknown map %s", &buf[16]); |
if ((mp = name_mode(&buf[16])) == NULL) { |
return FALSE; |
ewprintf("Unknown map %s", &buf[16]); |
} |
return FALSE; |
(VOID) strncat(&buf[16], " key: ", 48-16-1); |
} |
return dobind(mp->p_map, buf, FALSE); |
(VOID) strncat(&buf[16], " key: ", 48 - 16 - 1); |
|
return dobind(mp->p_map, buf, FALSE); |
} |
} |
|
|
|
int |
unbindtokey(f, n) |
unbindtokey(f, n) |
int f, n; |
int f, n; |
{ |
{ |
return dobind(map_table[0].p_map, "Global unset key: ", TRUE); |
|
|
return dobind(map_table[0].p_map, "Global unset key: ", TRUE); |
} |
} |
|
|
|
int |
localunbind(f, n) |
localunbind(f, n) |
int f, n; |
int f, n; |
{ |
{ |
return dobind(curbp->b_modes[curbp->b_nmodes]->p_map, "Local unset key: ", |
|
TRUE); |
return dobind(curbp->b_modes[curbp->b_nmodes]->p_map, |
|
"Local unset key: ", TRUE); |
} |
} |
|
|
/* |
/* |
|
|
* and run the command if it is found. |
* and run the command if it is found. |
* Print an error if there is anything wrong. |
* Print an error if there is anything wrong. |
*/ |
*/ |
|
int |
extend(f, n) |
extend(f, n) |
|
int f, n; |
{ |
{ |
PF funct; |
PF funct; |
int s; |
int s; |
char xname[NXNAME]; |
char xname[NXNAME]; |
|
|
if(!(f & FFARG)) s = eread("M-x ", xname, NXNAME, EFNEW|EFFUNC); |
if (!(f & FFARG)) |
else s = eread("%d M-x ", xname, NXNAME, EFNEW|EFFUNC, n); |
s = eread("M-x ", xname, NXNAME, EFNEW | EFFUNC); |
if(s != TRUE) return s; |
else |
if((funct = name_function(xname)) != NULL) { |
s = eread("%d M-x ", xname, NXNAME, EFNEW | EFFUNC, n); |
|
if (s != TRUE) |
|
return s; |
|
if ((funct = name_function(xname)) != NULL) { |
#ifndef NO_MACRO |
#ifndef NO_MACRO |
if(macrodef) { |
if (macrodef) { |
LINE *lp = maclcur; |
LINE *lp = maclcur; |
macro[macrocount-1].m_funct = funct; |
macro[macrocount - 1].m_funct = funct; |
maclcur = lp->l_bp; |
maclcur = lp->l_bp; |
maclcur->l_fp = lp->l_fp; |
maclcur->l_fp = lp->l_fp; |
free((char *)lp); |
free((char *) lp); |
} |
} |
#endif |
#endif |
return (*funct)(f, n); |
return (*funct) (f, n); |
} |
} |
ewprintf("[No match]"); |
ewprintf("[No match]"); |
return FALSE; |
return FALSE; |
|
|
/* |
/* |
* evalexpr - get one line from the user, and run it. |
* evalexpr - get one line from the user, and run it. |
*/ |
*/ |
/*ARGSUSED*/ |
/* ARGSUSED */ |
|
int |
evalexpr(f, n) |
evalexpr(f, n) |
|
int f, n; |
{ |
{ |
int s; |
int s; |
char exbuf[128]; |
char exbuf[128]; |
|
|
if ((s = ereply("Eval: ", exbuf, 128)) != TRUE) |
if ((s = ereply("Eval: ", exbuf, 128)) != TRUE) |
return s; |
return s; |
return excline(exbuf); |
return excline(exbuf); |
} |
} |
|
|
/* |
/* |
* evalbuffer - evaluate the current buffer as line commands. Useful |
* evalbuffer - evaluate the current buffer as line commands. Useful |
* for testing startup files. |
* for testing startup files. |
*/ |
*/ |
/*ARGSUSED*/ |
/* ARGSUSED */ |
|
int |
evalbuffer(f, n) |
evalbuffer(f, n) |
|
int f, n; |
{ |
{ |
register LINE *lp; |
LINE *lp; |
register BUFFER *bp = curbp; |
BUFFER *bp = curbp; |
register int s; |
int s; |
static char excbuf[128]; |
static char excbuf[128]; |
|
|
for (lp = lforw(bp->b_linep); lp != bp->b_linep; lp = lforw(lp)) { |
for (lp = lforw(bp->b_linep); lp != bp->b_linep; lp = lforw(lp)) { |
if (llength(lp) >= 128) return FALSE; |
if (llength(lp) >= 128) |
|
return FALSE; |
(VOID) strncpy(excbuf, ltext(lp), llength(lp)); |
(VOID) strncpy(excbuf, ltext(lp), llength(lp)); |
excbuf[llength(lp)] = '\0'; /* make sure it's terminated */ |
excbuf[llength(lp)] = '\0'; /* make sure it's terminated */ |
if ((s = excline(excbuf)) != TRUE) return s; |
if ((s = excline(excbuf)) != TRUE) |
|
return s; |
} |
} |
return TRUE; |
return TRUE; |
} |
} |
|
|
/* |
/* |
* evalfile - go get a file and evaluate it as line commands. You can |
* evalfile - go get a file and evaluate it as line commands. You can |
* go get your own startup file if need be. |
* go get your own startup file if need be. |
*/ |
*/ |
/*ARGSUSED*/ |
/* ARGSUSED */ |
|
int |
evalfile(f, n) |
evalfile(f, n) |
|
int f, n; |
{ |
{ |
register int s; |
int s; |
char fname[NFILEN]; |
char fname[NFILEN]; |
|
|
if ((s = ereply("Load file: ", fname, NFILEN)) != TRUE) |
if ((s = ereply("Load file: ", fname, NFILEN)) != TRUE) |
return s; |
return s; |
|
|
/* |
/* |
* load - go load the file name we got passed. |
* load - go load the file name we got passed. |
*/ |
*/ |
load(fname) char *fname; { |
int |
int s = TRUE; |
load(fname) |
int nbytes; |
char *fname; |
char excbuf[128]; |
{ |
|
int s = TRUE; |
|
int nbytes; |
|
char excbuf[128]; |
|
|
if ((fname = adjustname(fname)) == NULL) |
if ((fname = adjustname(fname)) == NULL) |
return FALSE; /* just to be careful */ |
return FALSE; /* just to be careful */ |
|
|
if (ffropen(fname, (BUFFER *) NULL) != FIOSUC) return FALSE; |
if (ffropen(fname, (BUFFER *) NULL) != FIOSUC) |
while ((s = ffgetline(excbuf, sizeof(excbuf)-1, &nbytes)) == FIOSUC) { |
return FALSE; |
|
while ((s = ffgetline(excbuf, sizeof(excbuf) - 1, &nbytes)) == FIOSUC) { |
excbuf[nbytes] = '\0'; |
excbuf[nbytes] = '\0'; |
if (excline(excbuf) != TRUE) { |
if (excline(excbuf) != TRUE) { |
s = FIOERR; |
s = FIOERR; |
|
|
} |
} |
(VOID) ffclose((BUFFER *) NULL); |
(VOID) ffclose((BUFFER *) NULL); |
excbuf[nbytes] = '\0'; |
excbuf[nbytes] = '\0'; |
if(s!=FIOEOF || (nbytes && excline(excbuf)!=TRUE)) |
if (s != FIOEOF || (nbytes && excline(excbuf) != TRUE)) |
return FALSE; |
return FALSE; |
return TRUE; |
return TRUE; |
} |
} |
|
|
* if FKEYS is defined, duplicate functionallity of dobind so function |
* if FKEYS is defined, duplicate functionallity of dobind so function |
* key values don't have to fit in type char. |
* key values don't have to fit in type char. |
*/ |
*/ |
|
int |
excline(line) |
excline(line) |
register char *line; |
char *line; |
{ |
{ |
register char *funcp, *argp = NULL; |
char *funcp, *argp = NULL; |
register int c; |
int c; |
int status; |
int status; |
int f, n; |
int f, n; |
LINE *lp, *np; |
LINE *lp, *np; |
PF fp; |
PF fp; |
#ifdef FKEYS |
#ifdef FKEYS |
int bind; |
int bind; |
KEYMAP *curmap; |
KEYMAP *curmap; |
MAPS *mp; |
MAPS *mp; |
#define BINDARG 0 /* this arg is key to bind (local/global set key) */ |
#define BINDARG 0 /* this arg is key to bind (local/global set |
|
* key) */ |
#define BINDNO 1 /* not binding or non-quoted BINDARG */ |
#define BINDNO 1 /* not binding or non-quoted BINDARG */ |
#define BINDNEXT 2 /* next arg " (define-key) */ |
#define BINDNEXT 2 /* next arg " (define-key) */ |
#define BINDDO 3 /* already found key to bind */ |
#define BINDDO 3 /* already found key to bind */ |
|
|
#else |
#else |
#define BINDEXT 0 |
#define BINDEXT 0 |
#endif |
#endif |
PF name_function(); |
|
LINE *lalloc(); |
|
static char *skipwhite(), *parsetoken(); |
|
|
|
if(macrodef || inmacro) { |
if (macrodef || inmacro) { |
ewprintf("Not now!"); |
ewprintf("Not now!"); |
return FALSE; |
return FALSE; |
} |
} |
|
|
f = 0; |
f = 0; |
n = 1; |
n = 1; |
funcp = skipwhite(line); |
funcp = skipwhite(line); |
if (*funcp == '\0') return TRUE; /* No error on blank lines */ |
if (*funcp == '\0') |
|
return TRUE; /* No error on blank lines */ |
line = parsetoken(funcp); |
line = parsetoken(funcp); |
if (*line != '\0') { |
if (*line != '\0') { |
*line++ = '\0'; |
*line++ = '\0'; |
|
|
line = parsetoken(line); |
line = parsetoken(line); |
} |
} |
} |
} |
|
|
if (argp != NULL) { |
if (argp != NULL) { |
f = FFARG; |
f = FFARG; |
n = atoi(argp); |
n = atoi(argp); |
} |
} |
if((fp = name_function(funcp)) == NULL) { |
if ((fp = name_function(funcp)) == NULL) { |
ewprintf("Unknown function: %s", funcp); |
ewprintf("Unknown function: %s", funcp); |
return FALSE; |
return FALSE; |
} |
} |
#ifdef FKEYS |
#ifdef FKEYS |
if(fp == bindtokey || fp == unbindtokey) { |
if (fp == bindtokey || fp == unbindtokey) { |
bind = BINDARG; |
bind = BINDARG; |
curmap = map_table[0].p_map; |
curmap = map_table[0].p_map; |
} else if(fp == localbind || fp == localunbind) { |
} else if (fp == localbind || fp == localunbind) { |
bind = BINDARG; |
bind = BINDARG; |
curmap = curbp->b_modes[curbp->b_nmodes]->p_map; |
curmap = curbp->b_modes[curbp->b_nmodes]->p_map; |
} else if(fp == define_key) bind = BINDNEXT; |
} else if (fp == define_key) |
else bind = BINDNO; |
bind = BINDNEXT; |
|
else |
|
bind = BINDNO; |
#endif |
#endif |
/* Pack away all the args now... */ |
/* Pack away all the args now... */ |
if((np = lalloc(0))==FALSE) return FALSE; |
if ((np = lalloc(0)) == FALSE) |
|
return FALSE; |
np->l_fp = np->l_bp = maclcur = np; |
np->l_fp = np->l_bp = maclcur = np; |
while (*line != '\0') { |
while (*line != '\0') { |
argp = skipwhite(line); |
argp = skipwhite(line); |
if (*argp == '\0') break; |
if (*argp == '\0') |
|
break; |
line = parsetoken(argp); |
line = parsetoken(argp); |
if (*argp != '"') { |
if (*argp != '"') { |
if (*argp == '\'') ++argp; |
if (*argp == '\'') |
if((lp = lalloc((int)(line-argp)+BINDEXT))==NULL) { |
++argp; |
status = FALSE; |
if (!(lp = lalloc((int) (line - argp) + BINDEXT))) { |
goto cleanup; |
status = FALSE; |
} |
goto cleanup; |
bcopy(argp, ltext(lp), (int)(line-argp)); |
} |
|
bcopy(argp, ltext(lp), (int) (line - argp)); |
#ifdef FKEYS |
#ifdef FKEYS |
lp->l_used--; /* don't count BINDEXT! */ |
lp->l_used--; /* don't count BINDEXT! */ |
if(bind == BINDARG) bind = BINDNO; |
if (bind == BINDARG) |
|
bind = BINDNO; |
#endif |
#endif |
} else { /* Quoted strings special */ |
} else { /* Quoted strings special */ |
++argp; |
++argp; |
#ifdef FKEYS |
#ifdef FKEYS |
if(bind != BINDARG) { |
if (bind != BINDARG) { |
#endif |
#endif |
if((lp = lalloc((int)(line-argp)+BINDEXT))==NULL) { |
lp = lalloc((int) (line - argp) + BINDEXT); |
status = FALSE; |
if (lp == NULL) { |
goto cleanup; |
status = FALSE; |
|
goto cleanup; |
|
} |
|
lp->l_used = 0; |
|
#ifdef FKEYS |
|
} else { |
|
key.k_count = 0; |
} |
} |
lp->l_used = 0; |
#endif |
|
while (*argp != '"' && *argp != '\0') { |
|
if (*argp != '\\') |
|
c = *argp++; |
|
else { |
|
switch (*++argp) { |
|
case 't': |
|
case 'T': |
|
c = CCHR('I'); |
|
break; |
|
case 'n': |
|
case 'N': |
|
c = CCHR('J'); |
|
break; |
|
case 'r': |
|
case 'R': |
|
c = CCHR('M'); |
|
break; |
|
case 'e': |
|
case 'E': |
|
c = CCHR('['); |
|
break; |
|
case '^': |
|
/* |
|
* split into two statements |
|
* due to bug in OSK cpp |
|
*/ |
|
c = CHARMASK(*++argp); |
|
c = ISLOWER(c) ? |
|
CCHR(TOUPPER(c)) : CCHR(c); |
|
break; |
|
case '0': |
|
case '1': |
|
case '2': |
|
case '3': |
|
case '4': |
|
case '5': |
|
case '6': |
|
case '7': |
|
c = *argp - '0'; |
|
if (argp[1] <= '7' && argp[1] >= '0') { |
|
c <<= 3; |
|
c += *++argp - '0'; |
|
if (argp[1] <= '7' && |
|
argp[1] >= '0') { |
|
c <<= 3; |
|
c += *++argp |
|
- '0'; |
|
} |
|
} |
|
break; |
#ifdef FKEYS |
#ifdef FKEYS |
} else { |
case 'f': |
key.k_count = 0; |
case 'F': |
} |
c = *++argp - '0'; |
|
if (ISDIGIT(argp[1])) { |
|
c *= 10; |
|
c += *++argp - '0'; |
|
} |
|
c += KFIRST; |
|
break; |
#endif |
#endif |
while (*argp != '"' && *argp != '\0') { |
default: |
if (*argp != '\\') c = *argp++; |
c = CHARMASK(*argp); |
else { |
break; |
switch(*++argp) { |
|
case 't': case 'T': |
|
c = CCHR('I'); |
|
break; |
|
case 'n': case 'N': |
|
c = CCHR('J'); |
|
break; |
|
case 'r': case 'R': |
|
c = CCHR('M'); |
|
break; |
|
case 'e': case 'E': |
|
c = CCHR('['); |
|
break; |
|
case '^': |
|
/* split into two statements due to bug in OSK cpp */ |
|
c = CHARMASK(*++argp); |
|
c = ISLOWER(c) ? |
|
CCHR(TOUPPER(c)) : CCHR(c); |
|
break; |
|
case '0': case '1': case '2': case '3': |
|
case '4': case '5': case '6': case '7': |
|
c = *argp - '0'; |
|
if(argp[1] <= '7' && argp[1] >= '0') { |
|
c <<= 3; |
|
c += *++argp - '0'; |
|
if(argp[1] <= '7' && argp[1] >= '0') { |
|
c <<= 3; |
|
c += *++argp - '0'; |
|
} |
} |
} |
argp++; |
break; |
} |
#ifdef FKEYS |
#ifdef FKEYS |
case 'f': case 'F': |
if (bind == BINDARG) |
c = *++argp - '0'; |
key.k_chars[key.k_count++] = c; |
if(ISDIGIT(argp[1])) { |
else |
c *= 10; |
|
c += *++argp - '0'; |
|
} |
|
c += KFIRST; |
|
break; |
|
#endif |
#endif |
default: |
lp->l_text[lp->l_used++] = c; |
c = CHARMASK(*argp); |
|
break; |
|
} |
|
argp++; |
|
} |
} |
#ifdef FKEYS |
if (*line) |
if(bind == BINDARG) |
line++; |
key.k_chars[key.k_count++] = c; |
|
else |
|
#endif |
|
lp->l_text[lp->l_used++] = c; |
|
} |
|
if(*line) line++; |
|
} |
} |
#ifdef FKEYS |
#ifdef FKEYS |
switch(bind) { |
switch (bind) { |
case BINDARG: |
case BINDARG: |
bind = BINDDO; |
bind = BINDDO; |
break; |
break; |
case BINDNEXT: |
case BINDNEXT: |
lp->l_text[lp->l_used] = '\0'; |
lp->l_text[lp->l_used] = '\0'; |
if((mp = name_mode(lp->l_text)) == NULL) { |
if ((mp = name_mode(lp->l_text)) == NULL) { |
ewprintf("No such mode: %s", lp->l_text); |
ewprintf("No such mode: %s", lp->l_text); |
status = FALSE; |
status = FALSE; |
free((char *)lp); |
free((char *) lp); |
goto cleanup; |
goto cleanup; |
} |
} |
curmap = mp->p_map; |
curmap = mp->p_map; |
free((char *)lp); |
free((char *) lp); |
bind = BINDARG; |
bind = BINDARG; |
break; |
break; |
default: |
default: |
#endif |
#endif |
lp->l_fp = np->l_fp; |
lp->l_fp = np->l_fp; |
lp->l_bp = np; |
lp->l_bp = np; |
|
|
#endif |
#endif |
} |
} |
#ifdef FKEYS |
#ifdef FKEYS |
switch(bind) { |
switch (bind) { |
default: |
default: |
ewprintf("Bad args to set key"); |
ewprintf("Bad args to set key"); |
status = FALSE; |
status = FALSE; |
break; |
break; |
case BINDDO: |
case BINDDO: |
if(fp != unbindtokey && fp != localunbind) { |
if (fp != unbindtokey && fp != localunbind) { |
lp->l_text[lp->l_used] = '\0'; |
lp->l_text[lp->l_used] = '\0'; |
status = bindkey(&curmap, lp->l_text, key.k_chars, key.k_count); |
status = bindkey(&curmap, lp->l_text, key.k_chars, |
} else status = bindkey(&curmap, (char *)NULL, key.k_chars, key.k_count); |
key.k_count); |
|
} else |
|
status = bindkey(&curmap, (char *) NULL, key.k_chars, |
|
key.k_count); |
break; |
break; |
case BINDNO: |
case BINDNO: |
#endif |
#endif |
inmacro = TRUE; |
inmacro = TRUE; |
maclcur = maclcur->l_fp; |
maclcur = maclcur->l_fp; |
status = (*fp)(f, n); |
status = (*fp) (f, n); |
inmacro = FALSE; |
inmacro = FALSE; |
#ifdef FKEYS |
#ifdef FKEYS |
} |
} |
#endif |
#endif |
cleanup: |
cleanup: |
lp = maclcur->l_fp; |
lp = maclcur->l_fp; |
while(lp!=maclcur) { |
while (lp != maclcur) { |
np = lp->l_fp; |
np = lp->l_fp; |
free((char *)lp); |
free((char *) lp); |
lp = np; |
lp = np; |
} |
} |
free((char *)lp); |
free((char *) lp); |
return status; |
return status; |
} |
} |
|
|
|
|
*/ |
*/ |
static char * |
static char * |
skipwhite(s) |
skipwhite(s) |
register char *s; |
char *s; |
{ |
{ |
while(*s == ' ' || *s == '\t' || *s == ')' || *s == '(') s++; |
|
if (*s == ';') *s = '\0' ; |
while (*s == ' ' || *s == '\t' || *s == ')' || *s == '(') |
|
s++; |
|
if (*s == ';') |
|
*s = '\0'; |
return s; |
return s; |
} |
} |
|
|
static char * |
static char * |
parsetoken(s) |
parsetoken(s) |
register char *s; |
char *s; |
{ |
{ |
|
|
if (*s != '"') { |
if (*s != '"') { |
while(*s && *s!=' ' && *s!='\t' && *s!=')' && *s!='(') s++; |
while (*s && *s != ' ' && *s != '\t' && *s != ')' && *s != '(') |
if(*s==';') *s='\0'; |
s++; |
|
if (*s == ';') |
|
*s = '\0'; |
} else |
} else |
do { /* Strings get special treatment */ |
do { /* Strings get special treatment */ |
/* Beware: You can \ out the end of the string! */ |
/* Beware: You can \ out the end of the string! */ |
if (*s == '\\') ++s; |
if (*s == '\\') |
} while (*++s != '"' && *s != '\0'); |
++s; |
|
} while (*++s != '"' && *s != '\0'); |
return s; |
return s; |
} |
} |
#endif |
#endif |