~ubuntu-branches/ubuntu/wily/weechat/wily

« back to all changes in this revision

Viewing changes to src/plugins/aspell/weechat-aspell.c

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bouthenot
  • Date: 2014-09-28 17:41:10 UTC
  • mfrom: (29.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20140928174110-bwlsn7gqmqfftnmb
Tags: 1.0.1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
433
433
int
434
434
weechat_aspell_string_is_simili_number (const char *word)
435
435
{
436
 
    int utf8_char_int;
 
436
    int code_point;
437
437
 
438
438
    if (!word || !word[0])
439
439
        return 0;
440
440
 
441
441
    while (word && word[0])
442
442
    {
443
 
        utf8_char_int = weechat_utf8_char_int (word);
444
 
        if (!iswpunct (utf8_char_int) && !iswdigit (utf8_char_int))
 
443
        code_point = weechat_utf8_char_int (word);
 
444
        if (!iswpunct (code_point) && !iswdigit (code_point))
445
445
            return 0;
446
446
        word = weechat_utf8_next_char (word);
447
447
    }
614
614
    char *word_for_suggestions, *old_suggestions, *suggestions;
615
615
    char *word_and_suggestions;
616
616
    const char *color_normal, *color_error, *ptr_suggestions;
617
 
    int utf8_char_int, char_size;
 
617
    int code_point, char_size;
618
618
    int length, index_result, length_word, word_ok;
619
619
    int length_color_normal, length_color_error, rc;
620
620
    int input_pos, current_pos, word_start_pos, word_end_pos, word_end_pos_valid;
740
740
            ptr_string_orig = NULL;
741
741
 
742
742
            /* find start of word: it must start with an alphanumeric char */
743
 
            utf8_char_int = weechat_utf8_char_int (ptr_string);
744
 
            while ((!iswalnum (utf8_char_int)) || iswspace (utf8_char_int))
 
743
            code_point = weechat_utf8_char_int (ptr_string);
 
744
            while ((!iswalnum (code_point)) || iswspace (code_point))
745
745
            {
746
 
                if (!ptr_string_orig && !iswspace (utf8_char_int))
 
746
                if (!ptr_string_orig && !iswspace (code_point))
747
747
                    ptr_string_orig = ptr_string;
748
748
                char_size = weechat_utf8_char_size (ptr_string);
749
749
                memcpy (result + index_result, ptr_string, char_size);
752
752
                current_pos++;
753
753
                if (!ptr_string[0])
754
754
                    break;
755
 
                utf8_char_int = weechat_utf8_char_int (ptr_string);
 
755
                code_point = weechat_utf8_char_int (ptr_string);
756
756
            }
757
757
            if (!ptr_string[0])
758
758
                break;
766
766
            /* find end of word: ' and - allowed in word, but not at the end */
767
767
            ptr_end_valid = ptr_string;
768
768
            ptr_end = weechat_utf8_next_char (ptr_string);
769
 
            utf8_char_int = weechat_utf8_char_int (ptr_end);
770
 
            while (iswalnum (utf8_char_int) || (utf8_char_int == '\'')
771
 
                   || (utf8_char_int == '-'))
 
769
            code_point = weechat_utf8_char_int (ptr_end);
 
770
            while (iswalnum (code_point) || (code_point == '\'')
 
771
                   || (code_point == '-'))
772
772
            {
773
773
                word_end_pos++;
774
 
                if (iswalnum (utf8_char_int))
 
774
                if (iswalnum (code_point))
775
775
                {
776
776
                    /* pointer to last alphanumeric char in the word */
777
777
                    ptr_end_valid = ptr_end;
780
780
                ptr_end = weechat_utf8_next_char (ptr_end);
781
781
                if (!ptr_end[0])
782
782
                    break;
783
 
                utf8_char_int = weechat_utf8_char_int (ptr_end);
 
783
                code_point = weechat_utf8_char_int (ptr_end);
784
784
            }
785
785
            ptr_end = weechat_utf8_next_char (ptr_end_valid);
786
786
            word_end_pos = word_end_pos_valid;
795
795
                word_ok = 1;
796
796
                if (ptr_end[0])
797
797
                {
798
 
                    utf8_char_int = weechat_utf8_char_int (ptr_end);
799
 
                    while (!iswspace (utf8_char_int))
 
798
                    code_point = weechat_utf8_char_int (ptr_end);
 
799
                    while (!iswspace (code_point))
800
800
                    {
801
801
                        ptr_end = weechat_utf8_next_char (ptr_end);
802
802
                        if (!ptr_end[0])
803
803
                            break;
804
 
                        utf8_char_int = weechat_utf8_char_int (ptr_end);
 
804
                        code_point = weechat_utf8_char_int (ptr_end);
805
805
                    }
806
806
                }
807
807
            }
912
912
            && (strcmp (old_suggestions, ptr_suggestions) != 0)))
913
913
    {
914
914
        weechat_bar_item_update ("aspell_suggest");
915
 
        weechat_hook_signal_send ("aspell_suggest",
916
 
                                  WEECHAT_HOOK_SIGNAL_POINTER, buffer);
 
915
        (void) weechat_hook_signal_send ("aspell_suggest",
 
916
                                         WEECHAT_HOOK_SIGNAL_POINTER, buffer);
917
917
    }
918
918
    if (old_suggestions)
919
919
        free (old_suggestions);
1002
1002
    (void) signal_data;
1003
1003
 
1004
1004
#ifdef USE_ENCHANT
 
1005
#ifdef HAVE_ENCHANT_GET_VERSION
1005
1006
    weechat_printf (NULL, "  %s: enchant %s",
1006
1007
                    ASPELL_PLUGIN_NAME, enchant_get_version ());
1007
1008
#else
 
1009
    weechat_printf (NULL, "  %s: enchant (?)", ASPELL_PLUGIN_NAME);
 
1010
#endif /* HAVE_ENCHANT_GET_VERSION */
 
1011
#else
1008
1012
#ifdef HAVE_ASPELL_VERSION_STRING
1009
1013
    weechat_printf (NULL, "  %s: aspell %s",
1010
1014
                    ASPELL_PLUGIN_NAME, aspell_version_string ());
1011
1015
#else
1012
1016
    weechat_printf (NULL, "  %s: aspell (?)", ASPELL_PLUGIN_NAME);
1013
 
#endif
 
1017
#endif /* HAVE_ASPELL_VERSION_STRING */
1014
1018
#endif /* USE_ENCHANT */
1015
1019
 
1016
1020
    return WEECHAT_RC_OK;