int matchOperReg(OPerKind container, OPerKind input ) { if(container == input) return 2; if((((input == oper_EAX)||(input == oper_RAX)||(input ==oper_AX)) &&(container == oper_rAX)) || (((input == oper_EAX)||(input ==oper_AX)) &&(container == oper_eAX))) return 1; int g = (input & (7<<3)) >> 3 ; switch(g){ case 0: //! byte if((container == oper_r8) || (container == oper_rm8)) return 1; break; case 1: //! w if( EQ8(container, r16, rm16, rWDQ, rmWDQ, rWD, rmWD, rWQ, rmWQ )) return 1; break; case 2: //! d if( EQ8(container, r32, rm32, rWDQ, rmWDQ, rDQ, rmDQ, rWD, rmWD)) return 1; break; case 3: //! q if( EQ8(container, r64, rm64, rWDQ, rmWDQ, rDQ, rmDQ, rWQ, rmWQ )) return 1; break; case 4: //! qext if( EQ8(container, r64, rm64, rWDQ, rmWDQ, rDQ, rmDQ, rWQ, rmWQ )) return 1; break; case 5: //! xmm if( EQ2(container, xmm, Xm128 )) return 1; break; case 6: //! xmm ext if( EQ2(container, xmm, Xm128 )) return 1; break; case 7: //! st default: break; } return 0; }
bool charset_conv::update_begin(const char* fromCharset, const char* toCharset) { #ifdef HAVE_H_ICONV if (EQ2(fromCharset, toCharset)) return (true); if (fromCharset == NULL || toCharset == NULL) { if (m_iconv != (iconv_t) -1) return (true); logger_error("input invalid, from: %s, to: %s, m_conv: %s", fromCharset ? fromCharset : "null", toCharset ? toCharset : "null", m_iconv == (iconv_t) -1 ? "invalid" : "valud"); m_errmsg = "input invalid"; return (false); } // 如果源是 UTF-8 编码,则 m_pTuf8Pre 从 UTF8_HEADER 头部第 // 一个字节开始进行匹配,否则从最后一个字节 '\0' 开始匹配, // 即跳过 UTF-8 头部匹配过程 if (EQ(fromCharset, "utf-8") || EQ(fromCharset, "utf8")) m_pUtf8Pre = UTF8_HEADER; else m_pUtf8Pre = &UTF8_HEADER[3]; if (m_iconv != (iconv_t) -1 && EQ(m_fromCharset, fromCharset) && EQ(m_toCharset, toCharset)) { return (true); } SCOPY(m_fromCharset, fromCharset, sizeof(m_fromCharset)); SCOPY(m_toCharset, toCharset, sizeof(m_toCharset)); if (m_iconv != (iconv_t) -1) __iconv_close(m_iconv); m_iconv = __iconv_open(toCharset, fromCharset); if (m_iconv == (iconv_t) -1) { logger_error("iconv_open(%s, %s) error(%s)", toCharset, fromCharset, acl_last_serror()); m_errmsg.format("iconv_open(%s, %s) error(%s)", toCharset, fromCharset, acl_last_serror()); return (false); } else { #ifdef WIN32 # ifndef USE_WIN_ICONV int n = 1; __iconvctl(m_iconv, ICONV_TRIVIALP, &n); n = 1; __iconvctl(m_iconv, ICONV_SET_DISCARD_ILSEQ, &n); n = 1; __iconvctl(m_iconv, ICONV_SET_TRANSLITERATE, &n); # endif // USE_WIN_ICONV #endif char *pNil = NULL; size_t zero = 0; #ifdef WIN32 # ifdef USE_WIN_ICONV __iconv(m_iconv, (const char**) &pNil, &zero, &pNil, &zero); # else __iconv(m_iconv, (const char**) &pNil, &zero, &pNil, &zero, NULL); # endif // USE_WIN_ICONV #elif defined(ACL_SUNOS5) || defined(ACL_FREEBSD) __iconv(m_iconv, (const char**) &pNil, &zero, &pNil, &zero); #else __iconv(m_iconv, &pNil, &zero, &pNil, &zero); #endif return (true); } #else logger_error("no iconv lib"); m_errmsg = "no iconv lib"; return (false); #endif }