diff --git a/configure.ac b/configure.ac index a7fc75a0..85694c61 100644 --- a/configure.ac +++ b/configure.ac @@ -83,6 +83,7 @@ dnl User selectable options dnl System wide options devel_mode="no" +detail_debug="no" trace_message="no" message_string="no" @@ -285,6 +286,10 @@ AC_ARG_ENABLE(develmode, [ --enable-develmode developer mode ], devel_mode=$enableval) +AC_ARG_ENABLE(detaildebug, +[ --enable-detaildebug detailed debug info ], +detail_debug=$enableval) + AC_ARG_ENABLE(tracemsg, [ --enable-tracemsg trace messages of MiniGUI ], trace_message=$enableval) @@ -1638,6 +1643,9 @@ fi if test "x$devel_mode" = "xyes"; then message_string="yes" + if test "x$detail_debug" = "xyes"; then + trace_message="yes" + fi build_auto_ial_engine="yes" build_random_ial_engine="yes" @@ -2425,7 +2433,11 @@ dnl define _GNU_SOURCE for pthread_rwlock_t CFLAGS="$CFLAGS -D_GNU_SOURCE" if test "x$devel_mode" = "xyes"; then - CPPFLAGS="$CPPFLAGS -DDEBUG -D_DEBUG" + CPPFLAGS="$CPPFLAGS -D_DEBUG" + if test "x$detail_debug" = "xyes"; then + CPPFLAGS="$CPPFLAGS -DDEBUG" + fi + if test "$ac_cv_prog_gcc" = "yes"; then CPPFLAGS="$CPPFLAGS -Wall -Werror" fi diff --git a/include/common.h b/include/common.h index 29833a20..fcd06a9e 100644 --- a/include/common.h +++ b/include/common.h @@ -719,9 +719,17 @@ typedef UINT_PTR LPARAM; */ #define HISWORD(l) ((SWORD)((((DWORD)(l)) >> NR_BITS_WORD) & BITMASK_WORD)) +/** + * \def MAKELONG32(low, high) + * \brief Makes a 32-bit double word from \a low word and \a high word which are both in 16-bit. + * \sa MAKELONG + */ +#define MAKELONG32(low, high) ((DWORD32)(((WORD16)(low)) | (((DWORD32)((WORD16)(high))) << 16))) + /** * \def MAKELONG(low, high) - * \brief Makes a double word from \a low word and \a high word. + * \brief Makes a double word with pointer precision from \a low word and \a high word. + * \sa MAKELONG32 */ #define MAKELONG(low, high) ((DWORD)(((WORD)(low)) | (((DWORD)((WORD)(high))) << NR_BITS_WORD))) @@ -1934,8 +1942,12 @@ int init_minigui_printf (int (*output_char) (int ch), #if defined(__GNUC__) # define _ERR_PRINTF(fmt...) fprintf (stderr, fmt) # ifdef _DEBUG -# define _MG_PRINTF(fmt...) fprintf (stderr, fmt) -# define _DBG_PRINTF(fmt...) fprintf (stdout, fmt) +# define _MG_PRINTF(fmt...) fprintf (stdout, fmt) +# ifdef DEBUG +# define _DBG_PRINTF(fmt...) fprintf (stdout, fmt) +# else +# define _DBG_PRINTF(fmt...) +# endif # else # define _MG_PRINTF(fmt...) # define _DBG_PRINTF(fmt...) @@ -1952,7 +1964,18 @@ static inline void _ERR_PRINTF(const char* fmt, ...) } static inline void _MG_PRINTF(const char* fmt, ...) { -#ifdef _DEBUG +#ifdef DEBUG + va_list ap; + va_start (ap, fmt); + vfprintf (stdout, fmt, ap); + fprintf (stdout, "\n"); + va_end (ap); +#endif +} + +static inline void _DBG_PRINTF(const char* fmt, ...) +{ +#if defined(DEBUG) && defined(_DEBUG) va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); @@ -1960,18 +1983,7 @@ static inline void _MG_PRINTF(const char* fmt, ...) va_end(ap); #endif } - -static inline void _DBG_PRINTF(const char* fmt, ...) -{ -#ifdef _DEBUG - va_list ap; - va_start(ap, fmt); - vfprintf(stdout, fmt, ap); - fprintf(stdout, "\n"); - va_end(ap); -#endif -} -#endif /* __GNUC__ */ +#endif /* !__GNUC__ */ #ifdef _MGRM_THREADS diff --git a/include/window.h b/include/window.h index 774c14f1..c4f6b2f8 100644 --- a/include/window.h +++ b/include/window.h @@ -427,6 +427,9 @@ extern "C" { * \param ch The ASCII code of the pressed key. * \param key_flags The shift key status when this message occurred. * + * \note Please use \a LOBYTE_WORD16 and \a HIBYTE_WORD16 to get the bytes + * if the character is a two-byte character. + * * \sa MSG_SYSCHAR, TranslateMessage, key_defs */ #define MSG_CHAR 0x0011 diff --git a/src/control/textedit.c b/src/control/textedit.c index c870ccbe..2a00cc4d 100644 --- a/src/control/textedit.c +++ b/src/control/textedit.c @@ -2004,8 +2004,8 @@ static void teOnChar (HWND hWnd, PTEDATA ptedata, WPARAM wParam) return; } - ch [0] = LOBYTE (wParam); - ch [1] = HIBYTE (wParam); + ch [0] = LOBYTE_WORD16 (wParam); + ch [1] = HIBYTE_WORD16 (wParam); ch [2] = (0x0ff0000 & wParam) >> 16; if (ch[2]) { diff --git a/src/font/charset.c b/src/font/charset.c index 56a7ccef..930f0dc2 100644 --- a/src/font/charset.c +++ b/src/font/charset.c @@ -3525,7 +3525,7 @@ static int utf16le_len_first_char (const unsigned char* mstr, int len) if (len < 2) return 0; - w1 = MAKEWORD (mstr[0], mstr[1]); + w1 = MAKEWORD16 (mstr[0], mstr[1]); if (w1 < 0xD800 || w1 > 0xDFFF) return 2; @@ -3533,7 +3533,7 @@ static int utf16le_len_first_char (const unsigned char* mstr, int len) if (w1 >= 0xD800 && w1 <= 0xDBFF) { if (len < 4) return 0; - w2 = MAKEWORD (mstr[2], mstr[3]); + w2 = MAKEWORD16 (mstr[2], mstr[3]); if (w2 < 0xDC00 || w2 > 0xDFFF) return 0; } @@ -3547,12 +3547,12 @@ static Glyph32 utf16le_char_glyph_value (const unsigned char* pre_mchar, UChar16 w1, w2; UChar32 wc; - w1 = MAKEWORD (cur_mchar[0], cur_mchar[1]); + w1 = MAKEWORD16 (cur_mchar[0], cur_mchar[1]); if (w1 < 0xD800 || w1 > 0xDFFF) return w1; - w2 = MAKEWORD (cur_mchar[2], cur_mchar[3]); + w2 = MAKEWORD16 (cur_mchar[2], cur_mchar[3]); wc = w1; wc <<= 10; @@ -3765,7 +3765,7 @@ static int utf16be_len_first_char (const unsigned char* mstr, int len) if (len < 2) return 0; - w1 = MAKEWORD (mstr[1], mstr[0]); + w1 = MAKEWORD16 (mstr[1], mstr[0]); if (w1 < 0xD800 || w1 > 0xDFFF) return 2; @@ -3773,7 +3773,7 @@ static int utf16be_len_first_char (const unsigned char* mstr, int len) if (w1 >= 0xD800 && w1 <= 0xDBFF) { if (len < 4) return 0; - w2 = MAKEWORD (mstr[3], mstr[2]); + w2 = MAKEWORD16 (mstr[3], mstr[2]); if (w2 < 0xDC00 || w2 > 0xDFFF) return 0; } @@ -3787,12 +3787,12 @@ static Glyph32 utf16be_char_glyph_value (const unsigned char* pre_mchar, UChar16 w1, w2; UChar32 wc; - w1 = MAKEWORD (cur_mchar[1], cur_mchar[0]); + w1 = MAKEWORD16 (cur_mchar[1], cur_mchar[0]); if (w1 < 0xD800 || w1 > 0xDFFF) return w1; - w2 = MAKEWORD (cur_mchar[3], cur_mchar[2]); + w2 = MAKEWORD16 (cur_mchar[3], cur_mchar[2]); wc = w1; wc <<= 10; diff --git a/src/font/utils/makepytab.c b/src/font/utils/makepytab.c index 58334c75..85d240f5 100644 --- a/src/font/utils/makepytab.c +++ b/src/font/utils/makepytab.c @@ -113,7 +113,7 @@ static int set_gbhz_pinyin (unsigned char ch1, unsigned char ch2, unsigned short p = gbhz_py_tab + index; - p->encoding = MAKEWORD (ch2, ch1); + p->encoding = MAKEWORD16 (ch2, ch1); for (i = 0; i < MAX_NR_PINYIN; i++) { if (p->pinyin [i] == 0) { p->pinyin [i] = no_py; diff --git a/src/gui/keyboard.c b/src/gui/keyboard.c index d4e10e14..aeae6014 100644 --- a/src/gui/keyboard.c +++ b/src/gui/keyboard.c @@ -561,7 +561,7 @@ BOOL GUIAPI TranslateMessage (PMSG pMsg) else if (__mg_kinfo.pos == 2 && arabic_compose_flag) { /* SendNotifyMessage (pMsg->hwnd, MSG_CHAR, - MAKEWORD (__mg_kinfo.buff[0], __mg_kinfo.buff[1]), + MAKEWORD16 (__mg_kinfo.buff[0], __mg_kinfo.buff[1]), pMsg->lParam); */ SendNotifyMessage (pMsg->hwnd, MSG_CHAR, __mg_kinfo.buff[0], pMsg->lParam); @@ -571,7 +571,7 @@ BOOL GUIAPI TranslateMessage (PMSG pMsg) else { for (i = 0; i < __mg_kinfo.pos; i++) SendNotifyMessage (pMsg->hwnd, MSG_KEYSYM, - MAKEWORD (__mg_kinfo.buff[i], i), pMsg->lParam); + MAKEWORD16 (__mg_kinfo.buff[i], i), pMsg->lParam); } return FALSE; @@ -612,7 +612,7 @@ BOOL GUIAPI TranslateMessage (PMSG pMsg) else if (kinfo.pos == 2 && arabic_compose_flag) { /* SendNotifyMessage (pMsg->hwnd, MSG_CHAR, - MAKEWORD (__mg_kinfo.buff[0], __mg_kinfo.buff[1]), + MAKEWORD16 (__mg_kinfo.buff[0], __mg_kinfo.buff[1]), pMsg->lParam); */ SendNotifyMessage (pMsg->hwnd, MSG_CHAR, kinfo.buff[0], pMsg->lParam); diff --git a/src/ime/hzinput.c b/src/ime/hzinput.c index 6e7d4a5f..8fd91521 100644 --- a/src/ime/hzinput.c +++ b/src/ime/hzinput.c @@ -1348,7 +1348,7 @@ void __mg_ime_writemsg (BYTE *buffer, int len, LPARAM lParam, BOOL bDByte) if (bDByte) { for (i=0; istep == 1 && !((Uint32)row & 3) && !(w & 3) && (w > 3)) { - Uint16 _w = MAKEWORD (comp_ctxt->cur_pixel, comp_ctxt->cur_pixel); - Uint32 _u = MAKELONG (_w, _w); + Uint16 _w = MAKEWORD16 (comp_ctxt->cur_pixel, comp_ctxt->cur_pixel); + Uint32 _u = MAKELONG32 (_w, _w); ASM_memandset4 (row, _u, w >> 2); return; } @@ -751,8 +751,8 @@ static void _dc_draw_pixel_span_or_1 (COMP_CTXT* comp_ctxt, int w) #ifdef ASM_memorset4 if (comp_ctxt->step == 1 && !((Uint32)row & 3) && !(w & 3) && (w > 3)) { - Uint16 _w = MAKEWORD (comp_ctxt->cur_pixel, comp_ctxt->cur_pixel); - Uint32 _u = MAKELONG (_w, _w); + Uint16 _w = MAKEWORD16 (comp_ctxt->cur_pixel, comp_ctxt->cur_pixel); + Uint32 _u = MAKELONG32 (_w, _w); ASM_memorset4 (row, _u, w >> 2); return; } @@ -826,8 +826,8 @@ static void _dc_draw_pixel_span_xor_1 (COMP_CTXT* comp_ctxt, int w) #ifdef ASM_memxorset4 if (comp_ctxt->step == 1 && !((Uint32)comp_ctxt->cur_dst & 3) && !(w & 3) && (w > 3)) { - Uint16 _w = MAKEWORD (comp_ctxt->cur_pixel, comp_ctxt->cur_pixel); - Uint32 _u = MAKELONG (_w, _w); + Uint16 _w = MAKEWORD16 (comp_ctxt->cur_pixel, comp_ctxt->cur_pixel); + Uint32 _u = MAKELONG32 (_w, _w); ASM_memxorset4 (comp_ctxt->cur_dst, _u, w >> 2); return; } diff --git a/src/sysres/resmgr.c b/src/sysres/resmgr.c index 153927a1..7655052f 100644 --- a/src/sysres/resmgr.c +++ b/src/sysres/resmgr.c @@ -830,7 +830,7 @@ RES_KEY Str2Key (const char* str) l = (strlen(str)+1) / 2; for (i=0; i