[BACK]Return to extend.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mg

Diff for /src/usr.bin/mg/extend.c between version 1.53 and 1.54

version 1.53, 2012/05/25 04:56:58 version 1.54, 2014/03/20 07:47:29
Line 115 
Line 115 
                         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();
                                 ewprintf("Out of memory");                                  ewprintf("Out of memory");
                                 return (FALSE);                                  return (FALSE);
                         }                          }
Line 129 
Line 130 
                 } 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();
                                 ewprintf("Out of memory");                                  ewprintf("Out of memory");
                                 return (FALSE);                                  return (FALSE);
                         }                          }
Line 147 
Line 149 
                                 curmap = newmap;                                  curmap = newmap;
                         }                          }
                         if ((pfp = malloc(sizeof(PF))) == NULL) {                          if ((pfp = malloc(sizeof(PF))) == NULL) {
                                   dobeep();
                                 ewprintf("Out of memory");                                  ewprintf("Out of memory");
                                 return (FALSE);                                  return (FALSE);
                         }                          }
Line 170 
Line 173 
                         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();
                                         ewprintf("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;
Line 199 
Line 203 
                                         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();
                                                 ewprintf("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;
Line 226 
Line 231 
                         }                          }
                         if ((pfp = calloc(ele->k_num - c + !n2,                          if ((pfp = calloc(ele->k_num - c + !n2,
                             sizeof(PF))) == NULL) {                              sizeof(PF))) == NULL) {
                                   dobeep();
                                 ewprintf("Out of memory");                                  ewprintf("Out of memory");
                                 return (FALSE);                                  return (FALSE);
                         }                          }
Line 248 
Line 254 
                         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();
                                         ewprintf("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;
Line 276 
Line 283 
         int      i;          int      i;
   
         if (curmap->map_max > SHRT_MAX - MAPGROW) {          if (curmap->map_max > SHRT_MAX - MAPGROW) {
                   dobeep();
                 ewprintf("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();
                 ewprintf("Out of memory");                  ewprintf("Out of memory");
                 return (NULL);                  return (NULL);
         }          }
Line 338 
Line 347 
                  * 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();
                 ewprintf("Can't rebind key in macro");                  ewprintf("Can't rebind key in macro");
                 return (FALSE);                  return (FALSE);
         }          }
Line 378 
Line 388 
                         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();
                         ewprintf("[No match]");                          ewprintf("[No match]");
                         return (FALSE);                          return (FALSE);
                 }                  }
Line 404 
Line 415 
                 funct = rescan;                  funct = rescan;
         else if (((funct = name_function(fname)) == NULL) ?          else if (((funct = name_function(fname)) == NULL) ?
             (pref_map = name_map(fname)) == NULL : funct == NULL) {              (pref_map = name_map(fname)) == NULL : funct == NULL) {
                   dobeep();
                 ewprintf("[No match: %s]", fname);                  ewprintf("[No match: %s]", fname);
                 return (FALSE);                  return (FALSE);
         }          }
Line 509 
Line 521 
                 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();
                 ewprintf("Unknown map %s", tmp);                  ewprintf("Unknown map %s", tmp);
                 return (FALSE);                  return (FALSE);
         }          }
Line 563 
Line 576 
                 }                  }
                 return ((*funct)(f, n));                  return ((*funct)(f, n));
         }          }
           dobeep();
         ewprintf("[No match]");          ewprintf("[No match]");
         return (FALSE);          return (FALSE);
 }  }
Line 668 
Line 682 
                 excbuf[nbytes] = '\0';                  excbuf[nbytes] = '\0';
                 if (excline(excbuf) != TRUE) {                  if (excline(excbuf) != TRUE) {
                         s = FIOERR;                          s = FIOERR;
                           dobeep();
                         ewprintf("Error loading file %s at line %d", fname, line);                          ewprintf("Error loading file %s at line %d", fname, line);
                         break;                          break;
                 }                  }
Line 708 
Line 723 
         lp = NULL;          lp = NULL;
   
         if (macrodef || inmacro) {          if (macrodef || inmacro) {
                   dobeep();
                 ewprintf("Not now!");                  ewprintf("Not now!");
                 return (FALSE);                  return (FALSE);
         }          }
Line 735 
Line 751 
                 n = (int)nl;                  n = (int)nl;
         }          }
         if ((fp = name_function(funcp)) == NULL) {          if ((fp = name_function(funcp)) == NULL) {
                   dobeep();
                 ewprintf("Unknown function: %s", funcp);                  ewprintf("Unknown function: %s", funcp);
                 return (FALSE);                  return (FALSE);
         }          }
Line 876 
Line 893 
                 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();
                                 ewprintf("No such mode: %s", lp->l_text);                                  ewprintf("No such mode: %s", lp->l_text);
                                 status = FALSE;                                  status = FALSE;
                                 free(lp);                                  free(lp);
Line 897 
Line 915 
 #ifdef  FKEYS  #ifdef  FKEYS
         switch (bind) {          switch (bind) {
         default:          default:
                   dobeep();
                 ewprintf("Bad args to set key");                  ewprintf("Bad args to set key");
                 status = FALSE;                  status = FALSE;
                 break;                  break;

Legend:
Removed from v.1.53  
changed lines
  Added in v.1.54