version 1.67, 2019/07/11 18:20:18 |
version 1.68, 2019/07/17 18:18:37 |
|
|
if (n1 <= MAPELEDEF && n1 <= n2) { |
if (n1 <= MAPELEDEF && n1 <= n2) { |
ele--; |
ele--; |
if ((pfp = calloc(c - ele->k_base + 1, |
if ((pfp = calloc(c - ele->k_base + 1, |
sizeof(PF))) == NULL) { |
sizeof(PF))) == NULL) |
dobeep(); |
return (dobeep_msg("Out of memory")); |
ewprintf("Out of memory"); |
|
return (FALSE); |
|
} |
|
nold = ele->k_num - ele->k_base + 1; |
nold = ele->k_num - ele->k_base + 1; |
for (i = 0; i < nold; i++) |
for (i = 0; i < nold; i++) |
pfp[i] = ele->k_funcp[i]; |
pfp[i] = ele->k_funcp[i]; |
|
|
ele->k_funcp = pfp; |
ele->k_funcp = pfp; |
} else if (n2 <= MAPELEDEF) { |
} else if (n2 <= MAPELEDEF) { |
if ((pfp = calloc(ele->k_num - c + 1, |
if ((pfp = calloc(ele->k_num - c + 1, |
sizeof(PF))) == NULL) { |
sizeof(PF))) == NULL) |
dobeep(); |
return (dobeep_msg("Out of memory")); |
ewprintf("Out of memory"); |
|
return (FALSE); |
|
} |
|
nold = ele->k_num - ele->k_base + 1; |
nold = ele->k_num - ele->k_base + 1; |
for (i = 0; i < nold; i++) |
for (i = 0; i < nold; i++) |
pfp[i + n2] = ele->k_funcp[i]; |
pfp[i + n2] = ele->k_funcp[i]; |
|
|
return (FALSE); |
return (FALSE); |
curmap = newmap; |
curmap = newmap; |
} |
} |
if ((pfp = malloc(sizeof(PF))) == NULL) { |
if ((pfp = malloc(sizeof(PF))) == NULL) |
dobeep(); |
return (dobeep_msg("Out of memory")); |
ewprintf("Out of memory"); |
|
return (FALSE); |
|
} |
|
pfp[0] = funct; |
pfp[0] = funct; |
for (mep = &curmap->map_element[curmap->map_num]; |
for (mep = &curmap->map_element[curmap->map_num]; |
mep > ele; mep--) { |
mep > ele; mep--) { |
|
|
else { |
else { |
if ((mp = malloc(sizeof(KEYMAP) + |
if ((mp = malloc(sizeof(KEYMAP) + |
(MAPINIT - 1) * sizeof(struct map_element))) == NULL) { |
(MAPINIT - 1) * sizeof(struct map_element))) == NULL) { |
dobeep(); |
(void)dobeep_msg("Out of memory"); |
ewprintf("Out of memory"); |
|
ele->k_funcp[c - ele->k_base] = |
ele->k_funcp[c - ele->k_base] = |
curmap->map_default; |
curmap->map_default; |
return (FALSE); |
return (FALSE); |
|
|
if ((mp = malloc(sizeof(KEYMAP) + |
if ((mp = malloc(sizeof(KEYMAP) + |
(MAPINIT - 1) * |
(MAPINIT - 1) * |
sizeof(struct map_element))) == NULL) { |
sizeof(struct map_element))) == NULL) { |
dobeep(); |
(void)dobeep_msg("Out of memory"); |
ewprintf("Out of memory"); |
|
ele->k_funcp[c - ele->k_base] = |
ele->k_funcp[c - ele->k_base] = |
curmap->map_default; |
curmap->map_default; |
return (FALSE); |
return (FALSE); |
|
|
curmap = newmap; |
curmap = newmap; |
} |
} |
if ((pfp = calloc(ele->k_num - c + !n2, |
if ((pfp = calloc(ele->k_num - c + !n2, |
sizeof(PF))) == NULL) { |
sizeof(PF))) == NULL) |
dobeep(); |
return (dobeep_msg("Out of memory")); |
ewprintf("Out of memory"); |
|
return (FALSE); |
|
} |
|
ele->k_funcp[n1] = NULL; |
ele->k_funcp[n1] = NULL; |
for (i = n1 + n2; i <= ele->k_num - ele->k_base; i++) |
for (i = n1 + n2; i <= ele->k_num - ele->k_base; i++) |
pfp[i - n1 - n2] = ele->k_funcp[i]; |
pfp[i - n1 - n2] = ele->k_funcp[i]; |
|
|
if (pref_map == NULL) { |
if (pref_map == NULL) { |
if ((mp = malloc(sizeof(KEYMAP) + (MAPINIT - 1) |
if ((mp = malloc(sizeof(KEYMAP) + (MAPINIT - 1) |
* sizeof(struct map_element))) == NULL) { |
* sizeof(struct map_element))) == NULL) { |
dobeep(); |
(void)dobeep_msg("Out of memory"); |
ewprintf("Out of memory"); |
|
ele->k_funcp[c - ele->k_base] = |
ele->k_funcp[c - ele->k_base] = |
curmap->map_default; |
curmap->map_default; |
return (FALSE); |
return (FALSE); |
|
|
int i; |
int i; |
|
|
if (curmap->map_max > SHRT_MAX - MAPGROW) { |
if (curmap->map_max > SHRT_MAX - MAPGROW) { |
dobeep(); |
(void)dobeep_msg("keymap too large"); |
ewprintf("keymap too large"); |
|
return (NULL); |
return (NULL); |
} |
} |
if ((mp = malloc(sizeof(KEYMAP) + (curmap->map_max + (MAPGROW - 1)) * |
if ((mp = malloc(sizeof(KEYMAP) + (curmap->map_max + (MAPGROW - 1)) * |
sizeof(struct map_element))) == NULL) { |
sizeof(struct map_element))) == NULL) { |
dobeep(); |
(void)dobeep_msg("Out of memory"); |
ewprintf("Out of memory"); |
|
return (NULL); |
return (NULL); |
} |
} |
mp->map_num = curmap->map_num; |
mp->map_num = curmap->map_num; |
|
|
* Keystrokes aren't collected. Not hard, but pretty useless. |
* Keystrokes aren't collected. Not hard, but pretty useless. |
* Would not work for function keys in any case. |
* Would not work for function keys in any case. |
*/ |
*/ |
dobeep(); |
return (dobeep_msg("Can't rebind key in macro")); |
ewprintf("Can't rebind key in macro"); |
|
return (FALSE); |
|
} |
} |
if (inmacro) { |
if (inmacro) { |
for (s = 0; s < maclcur->l_used - 1; s++) { |
for (s = 0; s < maclcur->l_used - 1; s++) { |
|
|
else if (bufp[0] == '\0') |
else if (bufp[0] == '\0') |
return (FALSE); |
return (FALSE); |
if (((funct = name_function(bprompt)) == NULL) ? |
if (((funct = name_function(bprompt)) == NULL) ? |
(pref_map = name_map(bprompt)) == NULL : funct == NULL) { |
(pref_map = name_map(bprompt)) == NULL : funct == NULL) |
dobeep(); |
return (dobeep_msg("[No match]")); |
ewprintf("[No match]"); |
|
return (FALSE); |
|
} |
|
} |
} |
return (remap(curmap, c, funct, pref_map)); |
return (remap(curmap, c, funct, pref_map)); |
} |
} |
|
|
else if (bufp[0] == '\0') |
else if (bufp[0] == '\0') |
return (FALSE); |
return (FALSE); |
(void)strlcat(buf, tmp, sizeof(buf)); |
(void)strlcat(buf, tmp, sizeof(buf)); |
if ((mp = name_map(tmp)) == NULL) { |
if ((mp = name_map(tmp)) == NULL) |
dobeep(); |
return (dobeep_msgs("Unknown map ", tmp)); |
ewprintf("Unknown map %s", tmp); |
|
return (FALSE); |
|
} |
|
if (strlcat(buf, "key: ", sizeof(buf)) >= sizeof(buf)) |
if (strlcat(buf, "key: ", sizeof(buf)) >= sizeof(buf)) |
return (FALSE); |
return (FALSE); |
|
|
|
|
} |
} |
return ((*funct)(f, n)); |
return ((*funct)(f, n)); |
} |
} |
dobeep(); |
return (dobeep_msg("[No match]")); |
ewprintf("[No match]"); |
|
return (FALSE); |
|
} |
} |
|
|
/* |
/* |
|
|
*p = '\0'; |
*p = '\0'; |
/* we now know that string starts with '(' and ends with ')' */ |
/* we now know that string starts with '(' and ends with ')' */ |
if (regcomp(®ex_buff, "^[(][\t ]*[)]$", REG_EXTENDED)) { |
if (regcomp(®ex_buff, "^[(][\t ]*[)]$", REG_EXTENDED)) { |
dobeep(); |
|
ewprintf("Could not compile regex"); |
|
regfree(®ex_buff); |
regfree(®ex_buff); |
return(FALSE); |
return (dobeep_msg("Could not compile regex")); |
} |
} |
if (!regexec(®ex_buff, funstr, 0, NULL, 0)) { |
if (!regexec(®ex_buff, funstr, 0, NULL, 0)) { |
dobeep(); |
|
ewprintf("No command found"); |
|
regfree(®ex_buff); |
regfree(®ex_buff); |
return(FALSE); |
return (dobeep_msg("No command found")); |
} |
} |
/* currently there are no mg commands that don't have a letter */ |
/* currently there are no mg commands that don't have a letter */ |
if (regcomp(®ex_buff, "^[(][\t ]*[A-Za-z-]+[\t ]*[)]$", |
if (regcomp(®ex_buff, "^[(][\t ]*[A-Za-z-]+[\t ]*[)]$", |
REG_EXTENDED)) { |
REG_EXTENDED)) { |
dobeep(); |
|
ewprintf("Could not compile regex"); |
|
regfree(®ex_buff); |
regfree(®ex_buff); |
return(FALSE); |
return (dobeep_msg("Could not compile regex")); |
} |
} |
if (!regexec(®ex_buff, funstr, 0, NULL, 0)) |
if (!regexec(®ex_buff, funstr, 0, NULL, 0)) |
singlecmd = 1; |
singlecmd = 1; |
|
|
* If no extant mg command found, line could be a (define of some kind. |
* If no extant mg command found, line could be a (define of some kind. |
* Since no defines exist at the moment, just return. |
* Since no defines exist at the moment, just return. |
*/ |
*/ |
if ((funcp = name_function(cmdp)) == NULL) { |
if ((funcp = name_function(cmdp)) == NULL) |
dobeep(); |
return (dobeep_msgs("Unknown command: %s", cmdp)); |
ewprintf("Unknown command: %s", cmdp); |
|
return (FALSE); |
|
} |
|
numparams = numparams_function(funcp); |
numparams = numparams_function(funcp); |
if (numparams == 0) { |
if (numparams == 0) |
dobeep(); |
return (dobeep_msgs("Command takes no arguments: %s", cmdp)); |
ewprintf("Command takes no arguments: %s", cmdp); |
|
return (FALSE); |
|
} |
|
|
|
/* now find the first argument */ |
/* now find the first argument */ |
p = fendp + 1; |
p = fendp + 1; |
|
|
*p = '\0'; /* terminate arg string */ |
*p = '\0'; /* terminate arg string */ |
excbuf[0] = '\0'; |
excbuf[0] = '\0'; |
if (strlcpy(excbuf, cmdp, sizeof(excbuf)) |
if (strlcpy(excbuf, cmdp, sizeof(excbuf)) |
>= sizeof(excbuf)) { |
>= sizeof(excbuf)) |
dobeep(); |
return (dobeep_msg("strlcpy error")); |
ewprintf("strlcpy error"); |
|
return (FALSE); |
|
} |
|
if (strlcat(excbuf, s, sizeof(excbuf)) |
if (strlcat(excbuf, s, sizeof(excbuf)) |
>= sizeof(excbuf)) { |
>= sizeof(excbuf)) |
dobeep(); |
return (dobeep_msg("strlcpy error")); |
ewprintf("strlcpy error"); |
|
return (FALSE); |
|
} |
|
if (strlcat(excbuf, argp, sizeof(excbuf)) |
if (strlcat(excbuf, argp, sizeof(excbuf)) |
>= sizeof(excbuf)) { |
>= sizeof(excbuf)) |
dobeep(); |
return (dobeep_msg("strlcpy error")); |
ewprintf("strlcpy error"); |
|
return (FALSE); |
|
} |
|
excline(excbuf); |
excline(excbuf); |
*p = ' '; /* so 'for' loop can continue */ |
*p = ' '; /* so 'for' loop can continue */ |
} |
} |
|
|
|
|
lp = NULL; |
lp = NULL; |
|
|
if (macrodef || inmacro) { |
if (macrodef || inmacro) |
dobeep(); |
return (dobeep_msg("Not now!")); |
ewprintf("Not now!"); |
|
return (FALSE); |
|
} |
|
f = 0; |
f = 0; |
n = 1; |
n = 1; |
funcp = skipwhite(line); |
funcp = skipwhite(line); |
|
|
return (FALSE); |
return (FALSE); |
n = (int)nl; |
n = (int)nl; |
} |
} |
if ((fp = name_function(funcp)) == NULL) { |
if ((fp = name_function(funcp)) == NULL) |
dobeep(); |
return (dobeep_msgs("Unknown function: ", funcp)); |
ewprintf("Unknown function: %s", funcp); |
|
return (FALSE); |
|
} |
|
if (fp == bindtokey || fp == unbindtokey) { |
if (fp == bindtokey || fp == unbindtokey) { |
bind = BINDARG; |
bind = BINDARG; |
curmap = fundamental_map; |
curmap = fundamental_map; |
|
|
case BINDNEXT: |
case BINDNEXT: |
lp->l_text[lp->l_used] = '\0'; |
lp->l_text[lp->l_used] = '\0'; |
if ((curmap = name_map(lp->l_text)) == NULL) { |
if ((curmap = name_map(lp->l_text)) == NULL) { |
dobeep(); |
(void)dobeep_msgs("No such mode: ", lp->l_text); |
ewprintf("No such mode: %s", lp->l_text); |
|
status = FALSE; |
status = FALSE; |
free(lp); |
free(lp); |
goto cleanup; |
goto cleanup; |
|
|
} |
} |
switch (bind) { |
switch (bind) { |
default: |
default: |
dobeep(); |
(void)dobeep_msg("Bad args to set key"); |
ewprintf("Bad args to set key"); |
|
status = FALSE; |
status = FALSE; |
break; |
break; |
case BINDDO: |
case BINDDO: |