Commit ea35e757 authored by Hiroshi Sumita's avatar Hiroshi Sumita
Browse files

Check a input character on insert().

BUG=None
TEST=Manual

Review URL: http://codereview.appspot.com/5528073
parent 98b613a1
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -56,14 +56,10 @@ DoublePinyinContext::~DoublePinyinContext ()
bool
DoublePinyinContext::insert (char ch)
{
    int id;
    /* is full */
    if (G_UNLIKELY (m_text.length () >= MAX_PINYIN_LEN))
        return true;
    const int id = ID (ch);

    id = ID (ch);
    if (id == -1) {
        /* it is not availidate ch */
        /* it is not available ch */
        return false;
    }

@@ -72,6 +68,10 @@ DoublePinyinContext::insert (char ch)
        return false;
    }

    /* is full */
    if (G_UNLIKELY (m_text.length () >= MAX_PINYIN_LEN))
        return true;

    m_text.insert (m_cursor++, ch);

    if (m_cursor > m_pinyin_len + 2 || updatePinyin (false) == false) {
@@ -447,5 +447,3 @@ DoublePinyinContext::updatePinyin (bool all)
}

};  // namespace PyZy

+7 −0
Original line number Diff line number Diff line
@@ -19,10 +19,12 @@
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */
#include <cctype>
#include "PyZyFullPinyinContext.h"
#include "PyZyConfig.h"
#include "PyZyPinyinParser.h"


namespace PyZy {

FullPinyinContext::FullPinyinContext (Config & config, PhoneticContext::Observer *observer)
@@ -37,6 +39,11 @@ FullPinyinContext::~FullPinyinContext (void)
bool
FullPinyinContext::insert (char ch)
{
    if (!islower(ch) && ch != '\'') {
        /* it is not available ch */
        return false;
    }

    /* is full */
    if (G_UNLIKELY (m_text.length () >= MAX_PINYIN_LEN))
        return true;