/[weechat]/weechat/src/common/completion.c
ViewVC logotype

Diff of /weechat/src/common/completion.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.32 by flashcode, Tue Oct 25 17:37:13 2005 UTC revision 1.33 by flashcode, Fri Oct 28 13:07:32 2005 UTC
# Line 904  completion_command_arg (t_completion *co Line 904  completion_command_arg (t_completion *co
904  }  }
905    
906  /*  /*
907     * completion_is_only_alphanum: return 1 if there is only alpha/num chars
908     *                              in a string
909     */
910    
911    int
912    completion_is_only_alphanum (char *string)
913    {
914        while (string[0])
915        {
916            if (strchr (cfg_look_nick_completion_ignore, string[0]))
917                return 0;
918            string++;
919        }
920        return 1;
921    }
922    
923    /*
924     * completion_strdup_alphanum: duplicate alpha/num chars in a string
925     */
926    
927    char *
928    completion_strdup_alphanum (char *string)
929    {
930        char *result, *pos;
931        
932        result = (char *)malloc (strlen (string) + 1);
933        pos = result;
934        while (string[0])
935        {
936            if (!strchr (cfg_look_nick_completion_ignore, string[0]))
937            {
938                pos[0] = string[0];
939                pos++;
940            }
941            string++;
942        }
943        pos[0] = '\0';
944        return result;
945    }
946    
947    /*
948     * completion_nickncmp: locale and case independent string comparison
949     *                      with max length for nicks (alpha or digits only)
950     */
951    
952    int
953    completion_nickncmp (char *base_word, char *nick, int max)
954    {
955        char *base_word2, *nick2;
956        int return_cmp;
957        
958        if (!cfg_look_nick_completion_ignore
959            || !cfg_look_nick_completion_ignore[0]
960            || !base_word || !nick || !base_word[0] || !nick[0]
961            || (!completion_is_only_alphanum (base_word)))
962            return ascii_strncasecmp (base_word, nick, max);
963        
964        base_word2 = completion_strdup_alphanum (base_word);
965        nick2 = completion_strdup_alphanum (nick);
966        
967        return_cmp = ascii_strncasecmp (base_word2, nick2, strlen (base_word2));
968        
969        free (base_word2);
970        free (nick2);
971        
972        return return_cmp;
973    }
974    
975    /*
976   * completion_nick: complete a nick   * completion_nick: complete a nick
977   */   */
978    
# Line 927  completion_nick (t_completion *completio Line 996  completion_nick (t_completion *completio
996      other_completion = 0;      other_completion = 0;
997      for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)      for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
998      {      {
999          if (ascii_strncasecmp (ptr_nick->nick, completion->base_word, length) == 0)          if (completion_nickncmp (completion->base_word, ptr_nick->nick, length) == 0)
1000          {          {
1001              if ((!completion->word_found) || word_found_seen)              if ((!completion->word_found) || word_found_seen)
1002              {              {
# Line 935  completion_nick (t_completion *completio Line 1004  completion_nick (t_completion *completio
1004                  for (ptr_nick2 = ptr_nick->next_nick; ptr_nick2;                  for (ptr_nick2 = ptr_nick->next_nick; ptr_nick2;
1005                       ptr_nick2 = ptr_nick2->next_nick)                       ptr_nick2 = ptr_nick2->next_nick)
1006                  {                  {
1007                      if (ascii_strncasecmp (ptr_nick2->nick,                      if (completion_nickncmp (completion->base_word,
1008                          completion->base_word, length) == 0)                                               ptr_nick2->nick,
1009                                                 length) == 0)
1010                          other_completion++;                          other_completion++;
1011                  }                  }
1012                  if (other_completion == 0)                  if (other_completion == 0)

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26