strncpy (CycleLast, buffer, sizeof (CycleLast)); if (cycle) CycleNum = 1; else CycleNum++;
int mutt_command_complete (char *buffer, size_t len, int pos){  char completed[STRING] = { 0 };  char *pt;  int num, cycle = CycleNum;    if (buffer[0] == 0)    return 0;  if (strncmp (buffer, CycleLast, len))  {    CycleStart[0] = 0;    cycle = CycleNum = 1;  }  pt = buffer + pos;  while ((pt > buffer) && !isspace ((unsigned char) *pt))    pt--;  if (pt == buffer) /* complete cmd */  {    if (CycleStart[0] == 0)      strncpy (CycleStart, pt, sizeof (CycleStart));    for (num = 0; Commands[num].name; num++)    {      if (candidate (completed, CycleStart, Commands[num].name, sizeof (completed), &cycle))	break;    }    if (completed[0] == 0)      return 0;    strncpy (buffer, completed, len);  }  else if (!strncmp (buffer, "set", 3)	   || !strncmp (buffer, "unset", 5)	   || !strncmp (buffer, "reset", 5)	   || !strncmp (buffer, "toggle", 6))  { 		/* complete variables */    char *prefixes[] = { "no", "inv", "?", "&", 0 };    int  prefix_index;    char tmpbuffer[STRING];    int  prefix_len;    /* remember if the command is set to decide whether we want to attempt the     * prefixes */    int  cmd_is_set = !strncmp (buffer, "set", 3);         pt++;    if (*pt == 0)      return 0;    if (CycleStart[0] == 0)      strncpy (CycleStart, pt, sizeof (CycleStart));        for (num = 0; MuttVars[num].option; num++)    {      if (candidate (completed, CycleStart, MuttVars[num].option, sizeof (completed), &cycle))	break;    }      if ( cmd_is_set ) {      /* loop through all the possible prefixes (no, inv, ...) */      for ( prefix_index = 0; prefixes[prefix_index]; prefix_index++ )      {        prefix_len = strlen(prefixes[prefix_index]);        strncpy( tmpbuffer, prefixes[prefix_index], sizeof(tmpbuffer) );          /* if the current option is prepended with the prefix */        if ( !strncmp(pt, tmpbuffer, prefix_len )) {          for (num = 0; MuttVars[num].option; num++) {            strncpy( &tmpbuffer[prefix_len],                      MuttVars[num].option,                      sizeof(tmpbuffer) - prefix_len );	    if (candidate (completed, CycleStart, tmpbuffer, sizeof (completed), &cycle))	      break;	  }	}      }    }    if (completed[0] == 0)      return 0;    strncpy (pt, completed, buffer + len - pt);  }  else    return 0;  strncpy (CycleLast, buffer, sizeof (CycleLast));  if (cycle)    CycleNum = 1;  else    CycleNum++;  return 1;}