From 8b6731d706b085e7832a3d7b732ae729fd8f87ed Mon Sep 17 00:00:00 2001 From: VincentWei Date: Thu, 18 Jan 2018 09:57:50 +0800 Subject: [PATCH] tune code for 64-bit --- src/gui/window.c | 3 +- src/newgal/RLEaccel.c | 5 +-- src/newgal/fbcon/fb3dfx.c | 10 +++--- src/newgal/fbcon/fbneomagic.c | 2 +- src/newgal/pcxvfb/pcxvfb.c | 10 ++++-- src/newgal/stretch.c | 2 -- src/newgal/video.c | 8 +---- src/newgdi/bidi.c | 7 +++- src/newgdi/bitmap.c | 8 ++--- src/newgdi/drawtext.c | 2 +- src/newgdi/gdi.c | 2 +- src/newgdi/icon.c | 62 ++++++++++++++++++++++++----------- src/newgdi/miarc.c | 7 ++-- src/newgdi/miwideline.c | 8 +++-- src/newgdi/rotatebmp.c | 6 ++-- src/newgdi/tabbedtextout.c | 6 ++-- src/textedit/mtextedit.c | 15 +++------ src/textedit/object.c | 15 ++++++--- src/textedit/object.h | 21 ++++++++---- 19 files changed, 119 insertions(+), 80 deletions(-) diff --git a/src/gui/window.c b/src/gui/window.c index d3270320..27270b90 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -5838,12 +5838,11 @@ static RECT4MASK* CalcXYBannedRects (HDC hdc, const void* mask, int * rect_size, int pitch = bmp->bmAlphaPitch; sA = bmp->bmAlphaMask[y * pitch + x/bmp->bmBytesPerPixel]; DISEMBLE_RGB (p, bpp, pixfmt, pixel, sR, sG, sB); - sR += sG + sB; /* suspend the warning */ } else { DISEMBLE_RGBA (p, bpp, pixfmt, pixel, sR, sG, sB, sA); - sR += sG + sB; /* suspend the warning */ } + sR ^= sG & sB; /* prevent unused-but-set-variable warning */ } else { pixel = bits [y * ((MYBITMAP*)mask)->pitch + x]; diff --git a/src/newgal/RLEaccel.c b/src/newgal/RLEaccel.c index 13249722..d08db111 100644 --- a/src/newgal/RLEaccel.c +++ b/src/newgal/RLEaccel.c @@ -1210,9 +1210,8 @@ static int RLEColorkeySurface(GAL_Surface *surface) Uint8 *rlebuf, *dst; int maxn; int y; - Uint8 *srcbuf, *curbuf, *lastline; + Uint8 *srcbuf, *lastline; int maxsize = 0; - int skip, run; int bpp = surface->format->BytesPerPixel; getpix_func getpix; Uint32 ckey, rgbmask; @@ -1246,9 +1245,7 @@ static int RLEColorkeySurface(GAL_Surface *surface) /* Set up the conversion */ srcbuf = (Uint8 *)surface->pixels+surface->offset; - curbuf = srcbuf; maxn = bpp == 4 ? 65535 : 255; - skip = run = 0; dst = rlebuf; rgbmask = ~surface->format->Amask; ckey = surface->format->colorkey & rgbmask; diff --git a/src/newgal/fbcon/fb3dfx.c b/src/newgal/fbcon/fb3dfx.c index 86179105..cda0f062 100644 --- a/src/newgal/fbcon/fb3dfx.c +++ b/src/newgal/fbcon/fb3dfx.c @@ -55,7 +55,7 @@ static int FillHWRect(_THIS, GAL_Surface *dst, GAL_Rect *rect, Uint32 color) /* Execute the fill command */ tdfx_wait(6); - tdfx_out32(DSTBASE, (Uint32)dst_base); + tdfx_out32(DSTBASE, (UINT_PTR)dst_base); tdfx_out32(DSTFORMAT, format); tdfx_out32(COLORFORE, color); tdfx_out32(COMMAND_2D, COMMAND_2D_FILLRECT); @@ -73,7 +73,7 @@ static int HWAccelBlit(GAL_Surface *src, GAL_Rect *srcrect, GAL_VideoDevice *this = current_video; int bpp; Uint32 src_format; - Uint32 dst_format; + /* Uint32 dst_format; */ char *src_base; char *dst_base; int srcX, srcY; @@ -89,7 +89,7 @@ static int HWAccelBlit(GAL_Surface *src, GAL_Rect *srcrect, src_format = src->pitch | ((bpp+((bpp==8) ? 0 : 8)) << 13); dst_base = (char *)((char *)dst->pixels - mapped_mem); bpp = dst->format->BitsPerPixel; - dst_format = dst->pitch | ((bpp+((bpp==8) ? 0 : 8)) << 13); + /* dst_format = dst->pitch | ((bpp+((bpp==8) ? 0 : 8)) << 13); */ srcX = srcrect->x; srcY = srcrect->y; @@ -120,9 +120,9 @@ static int HWAccelBlit(GAL_Surface *src, GAL_Rect *srcrect, use_colorkey = 0; } tdfx_wait(9); - tdfx_out32(SRCBASE, (Uint32)src_base); + tdfx_out32(SRCBASE, (UINT_PTR)src_base); tdfx_out32(SRCFORMAT, src_format); - tdfx_out32(DSTBASE, (Uint32)dst_base); + tdfx_out32(DSTBASE, (UINT_PTR)dst_base); tdfx_out32(DSTFORMAT, src_format); tdfx_out32(COMMAND_2D, blitop); tdfx_out32(COMMANDEXTRA_2D, use_colorkey); diff --git a/src/newgal/fbcon/fbneomagic.c b/src/newgal/fbcon/fbneomagic.c index 27304ed7..849090f1 100644 --- a/src/newgal/fbcon/fbneomagic.c +++ b/src/newgal/fbcon/fbneomagic.c @@ -99,7 +99,7 @@ static int FillHWRect(_THIS, GAL_Surface *dst, GAL_Rect *rect, Uint32 color) NEO_BC0_SRC_IS_FG | NEO_BC3_SKIP_MAPPING | 0x0c0000; - neo2200->dstStart = (Uint32) dst_base + + neo2200->dstStart = (UINT_PTR) dst_base + (rect->y * dst->pitch) + (rect->x * dst->format->BytesPerPixel); diff --git a/src/newgal/pcxvfb/pcxvfb.c b/src/newgal/pcxvfb/pcxvfb.c index d4c27f05..2ef7db18 100644 --- a/src/newgal/pcxvfb/pcxvfb.c +++ b/src/newgal/pcxvfb/pcxvfb.c @@ -516,7 +516,13 @@ static int PCXVFB_VideoInit (_THIS, GAL_PixelFormat *vformat) return -1; } } - read(__mg_pcxvfb_client_sockfd, &shmid, sizeof(int)); + + if (read(__mg_pcxvfb_client_sockfd, &shmid, sizeof(int)) < sizeof (int)) { + GAL_SetError ("NEWGAL>PCXVFB: read error from client socket.\n"); + close (__mg_pcxvfb_client_sockfd); + close (__mg_pcxvfb_server_sockfd); + return -1; + } if (shmid != -1) { data->shmrgn = (unsigned char *)shmat (shmid, 0, 0); @@ -548,7 +554,7 @@ static int PCXVFB_VideoInit (_THIS, GAL_PixelFormat *vformat) #endif #endif //end of os (windows, cygwin, linux) - if ((int)data->shmrgn == -1 || data->shmrgn == NULL) { + if ((INT_PTR)data->shmrgn == -1 || data->shmrgn == NULL) { GAL_SetError ("NEWGAL>PCXVFB: Unable to attach to " "virtual FrameBuffer server.\n"); return -1; diff --git a/src/newgal/stretch.c b/src/newgal/stretch.c index 1aef1032..ef140b13 100644 --- a/src/newgal/stretch.c +++ b/src/newgal/stretch.c @@ -157,7 +157,6 @@ int GAL_SoftStretch(GAL_Surface *src, GAL_Rect *srcrect, GAL_Surface *dst, GAL_Rect *dstrect) { int pos, inc; - int dst_width; int dst_maxrow; int src_row, dst_row; Uint8 *srcp = NULL; @@ -209,7 +208,6 @@ int GAL_SoftStretch(GAL_Surface *src, GAL_Rect *srcrect, inc = (srcrect->h << 16) / dstrect->h; src_row = srcrect->y; dst_row = dstrect->y; - dst_width = dstrect->w*bpp; #ifdef USE_ASM_STRETCH /* Write the opcodes for this stretch */ diff --git a/src/newgal/video.c b/src/newgal/video.c index c6f51e55..b4b0da25 100644 --- a/src/newgal/video.c +++ b/src/newgal/video.c @@ -925,13 +925,7 @@ static GAL_Surface *Slave_CreateSurface (GAL_VideoDevice *this, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { - GAL_Surface *screen, *surface; - - if (this) { - screen = this->screen; - } else { - screen = NULL; - } + GAL_Surface *surface; surface = (GAL_Surface *)malloc(sizeof(*surface)); diff --git a/src/newgdi/bidi.c b/src/newgdi/bidi.c index b98c042a..6492ced6 100644 --- a/src/newgdi/bidi.c +++ b/src/newgdi/bidi.c @@ -364,11 +364,16 @@ static int _gdi_output_glyphs_direct(PDC pdc, const unsigned char* text, int prev_len = 0; const unsigned char* prev_mchar = NULL; int i = 0; - int limit_width = -1, line_width = 0; + int line_width = 0; DRAWTEXTEX2_CTXT* ctxt = (DRAWTEXTEX2_CTXT*)context; + +#if 0 + int limit_width = -1; if(if_break){ limit_width = ctxt->max_extent; } +#endif + while (left_bytes > 0){ if(mbc_devfont){ len_cur_char = mbc_devfont->charset_ops->len_first_char diff --git a/src/newgdi/bitmap.c b/src/newgdi/bitmap.c index 97ba7a5e..f4dfe4e4 100644 --- a/src/newgdi/bitmap.c +++ b/src/newgdi/bitmap.c @@ -2486,14 +2486,14 @@ void GUIAPI ExpandPart16CBitmapEx (HDC hdc, BYTE* bits, Uint32 pitch, const BYTE Uint32 x, y; BYTE *dst, *dst_line; const BYTE *src, *src_line; - int index, bpp; + int index; + //int bpp; Uint32 pixel; BYTE byte = 0; int bnum,continum,i; - pdc = dc_HDC2PDC(hdc); - bpp = GAL_BytesPerPixel (pdc->surface); + // bpp = GAL_BytesPerPixel (pdc->surface); dst_line = bits; if (flags & MYBMP_FLOW_UP) @@ -2945,7 +2945,6 @@ void GUIAPI HFlipBitmap (BITMAP* bmp, unsigned char* inter_buff) void GUIAPI VFlipBitmap (BITMAP* bmp, unsigned char* inter_buff) { int y; - int bpp; unsigned char* sline, *dline; if (bmp->bmType & BMP_TYPE_ALPHA_MASK) { @@ -2967,7 +2966,6 @@ void GUIAPI VFlipBitmap (BITMAP* bmp, unsigned char* inter_buff) free(alpha_inter_buff); } - bpp = bmp->bmBytesPerPixel; sline = bmp->bmBits; dline = bmp->bmBits + bmp->bmPitch * bmp->bmHeight; diff --git a/src/newgdi/drawtext.c b/src/newgdi/drawtext.c index 10da0120..35a5461a 100644 --- a/src/newgdi/drawtext.c +++ b/src/newgdi/drawtext.c @@ -289,7 +289,7 @@ static BOOL cb_drawtextex2 (void* context, Glyph32 glyph_value, int glyph_type) { DRAWTEXTEX2_CTXT* ctxt = (DRAWTEXTEX2_CTXT*)context; - int adv_x, adv_y; + int adv_x = 0, adv_y = 0; BBOX bbox; int bkmode; diff --git a/src/newgdi/gdi.c b/src/newgdi/gdi.c index 5616cec1..63571f64 100644 --- a/src/newgdi/gdi.c +++ b/src/newgdi/gdi.c @@ -608,7 +608,7 @@ static void _dc_draw_pixel_span_set_2 (COMP_CTXT* comp_ctxt, int w) | (Uint16)comp_ctxt->cur_pixel); Uint32 * dest32; int count; - if ((Uint32)comp_ctxt->cur_dst & 3) // Ensure 4-byte alignment. + if ((UINT_PTR)comp_ctxt->cur_dst & 3) // Ensure 4-byte alignment. { *dest16++ = (Uint16)comp_ctxt->cur_pixel; --w; diff --git a/src/newgdi/icon.c b/src/newgdi/icon.c index e81f568b..616a22c0 100644 --- a/src/newgdi/icon.c +++ b/src/newgdi/icon.c @@ -109,18 +109,18 @@ static void read_bmicolors_m (int ncols, RGB *pal, const Uint8 *p) HICON GUIAPI LoadIconFromFile (HDC hdc, const char* filename, int which) { FILE* fp; - WORD wTemp; + WORD16 wTemp; BYTE bTemp; int w, h, colornum; - DWORD size, offset; - DWORD imagesize, imagew, imageh; + DWORD32 offset; + DWORD32 imagesize; BYTE* image; HICON icon = 0; RGB pal[256]; - if( !(fp = fopen(filename, "rb")) ) return 0; + if (!(fp = fopen (filename, "rb"))) return 0; - fseek(fp, sizeof(WORD), SEEK_SET); + fseek (fp, sizeof (WORD16), SEEK_SET); /* the cbType of struct ICONDIR.*/ wTemp = MGUI_ReadLE16FP (fp); @@ -151,14 +151,25 @@ HICON GUIAPI LoadIconFromFile (HDC hdc, const char* filename, int which) wTemp = MGUI_ReadLE16FP (fp); /* the wBitCount*/ if(wTemp > 8) goto error; +#if 0 + DWORD32 size; size = MGUI_ReadLE32FP (fp); +#else + fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the wSize member.*/ +#endif offset = MGUI_ReadLE32FP (fp); /* read the cursor image info. */ fseek(fp, offset, SEEK_SET); - fseek(fp, sizeof(DWORD), SEEK_CUR); /* skip the biSize member.*/ + fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the biSize member.*/ +#if 0 + DWORD32 imagew, imageh; imagew = MGUI_ReadLE32FP (fp); imageh = MGUI_ReadLE32FP (fp); +#else + fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the biWidth member.*/ + fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the biHeight member.*/ +#endif /* check the biPlanes member;*/ wTemp = MGUI_ReadLE16FP (fp); @@ -169,7 +180,7 @@ HICON GUIAPI LoadIconFromFile (HDC hdc, const char* filename, int which) if(wTemp > 8) goto error; colornum = (int)wTemp; - fseek(fp, sizeof(DWORD), SEEK_CUR); /* skip the biCompression members.*/ + fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the biCompression members.*/ if (colornum == 1) imagesize = align_32_bits(w>>3) * h; @@ -179,10 +190,10 @@ HICON GUIAPI LoadIconFromFile (HDC hdc, const char* filename, int which) imagesize = align_32_bits(w) * h; imagesize += align_32_bits(w>>3) * h; - fseek(fp, sizeof(DWORD), SEEK_CUR); + fseek(fp, sizeof(DWORD32), SEEK_CUR); /* skip the rest members and the color table.*/ - fseek(fp, sizeof(DWORD)*4, SEEK_CUR); + fseek(fp, sizeof(DWORD32)*4, SEEK_CUR); read_bmicolors_f (1 << colornum, pal, fp); /* allocate memory for image.*/ @@ -195,12 +206,15 @@ HICON GUIAPI LoadIconFromFile (HDC hdc, const char* filename, int which) goto error; /* read image*/ - fread (image, imagesize, 1, fp); + if (fread (image, imagesize, 1, fp) < imagesize) { + goto error_free; + } icon = CreateIconEx (hdc, w, h, image + (imagesize - (align_32_bits(w>>3) * h)), image, colornum, pal); +error_free: #ifndef HAVE_ALLOCA free (image); #endif @@ -213,15 +227,15 @@ error: HICON GUIAPI LoadIconFromMem (HDC hdc, const void* area, int which) { const Uint8* p = (Uint8*)area; - WORD wTemp; + WORD16 wTemp; BYTE bTemp; int w, h, colornum; - DWORD size, offset; - DWORD imagesize, imagew, imageh; + DWORD32 offset; + DWORD32 imagesize; RGB pal[256]; - p += sizeof (WORD); + p += sizeof (WORD16); /* the cbType of struct ICONDIR.*/ wTemp = MGUI_ReadLE16Mem (&p); @@ -252,15 +266,25 @@ HICON GUIAPI LoadIconFromMem (HDC hdc, const void* area, int which) if (wTemp != 0 && wTemp != 1) goto error; wTemp = MGUI_ReadLE16Mem (&p); /* the wBitCount */ if (wTemp > 8) goto error; +#if 0 + DWORD32 size; size = MGUI_ReadLE32Mem (&p); +#else + p += sizeof(DWORD32); +#endif offset = MGUI_ReadLE32Mem (&p); /* read the cursor image info. */ p = (Uint8*)area + offset; /* skip the biSize member. */ - p += sizeof(DWORD); + p += sizeof(DWORD32); +#if 0 + DWORD32 imagew, imageh; imagew = MGUI_ReadLE32Mem (&p); imageh = MGUI_ReadLE32Mem (&p); +#else + p += sizeof(DWORD32); +#endif /* check the biPlanes member; */ wTemp = MGUI_ReadLE16Mem (&p); if (wTemp != 1) goto error; @@ -269,7 +293,7 @@ HICON GUIAPI LoadIconFromMem (HDC hdc, const void* area, int which) if (wTemp > 8) goto error; colornum = (int)wTemp; /* skip the biCompression members. */ - p += sizeof (DWORD); + p += sizeof (DWORD32); if (colornum == 1) imagesize = align_32_bits(w>>3) * h; @@ -279,10 +303,10 @@ HICON GUIAPI LoadIconFromMem (HDC hdc, const void* area, int which) imagesize = align_32_bits(w) * h; imagesize += align_32_bits(w>>3) * h; - p += sizeof (DWORD); + p += sizeof (DWORD32); /* skip the rest members and the color table. */ - p += sizeof(DWORD)*4; + p += sizeof(DWORD32)*4; read_bmicolors_m (1 << colornum, pal, p); p += sizeof(BYTE)*(4<surface); if( (w%16) != 0 || (h%16) != 0 ) return 0; diff --git a/src/newgdi/miarc.c b/src/newgdi/miarc.c index e36ff4db..90e8edd2 100644 --- a/src/newgdi/miarc.c +++ b/src/newgdi/miarc.c @@ -1,7 +1,7 @@ /* $Id: miarc.c 12871 2010-05-07 06:13:42Z wanzheng $ */ /*********************************************************** -Copyright (C) 2005 ~ 2007 Feynman Software +Copyright (C) 2005 ~ 2018 FMSoft Copyright 1987, 1998 The Open Group @@ -1465,7 +1465,6 @@ static int miGetArcPts (SppArcPtr parc, int cpt, SppPointPtr *ppPts) xc, yc; /* the center point */ int count, i; SppPointPtr poly; - POINT last; /* last point on integer boundaries */ /* The spec says that positive angles indicate counterclockwise motion. * Given our coordinate system (with 0,0 in the upper left corner), @@ -1512,8 +1511,12 @@ static int miGetArcPts (SppArcPtr parc, int cpt, SppPointPtr *ppPts) poly[cpt].x = (xc + x0); poly[cpt].y = (yc + y0); + +#if 0 + POINT last; /* last point on integer boundaries */ last.x = ROUNDTOINT( poly[cpt + 1].x = (xc + x1) ); last.y = ROUNDTOINT( poly[cpt + 1].y = (yc + y1) ); +#endif for(i = 2; i < count; i++) { diff --git a/src/newgdi/miwideline.c b/src/newgdi/miwideline.c index 041b452e..d818933d 100644 --- a/src/newgdi/miwideline.c +++ b/src/newgdi/miwideline.c @@ -1374,19 +1374,23 @@ static void miWideDashSegment (PDC pdc, SpanDataPtr spanData, int* pDashOffset, double saveK = 0.0; BOOL first = TRUE; double lcenterx, lcentery, rcenterx = 0.0, rcentery = 0.0; - gal_pixel fgPixel, bgPixel; dx = x2 - x1; dy = y2 - y1; dashIndex = *pDashIndex; pDash = pdc->dash_list; dashRemain = pDash[dashIndex] - *pDashOffset; + +#if 0 + gal_pixel fgPixel; + gal_pixel bgPixel; + fgPixel = pdc->pencolor; bgPixel = pdc->bkcolor; - if (pdc->brush_type == BT_OPAQUE_STIPPLED || pdc->brush_type == BT_TILED) { bgPixel = fgPixel; } +#endif l = ((double) pdc->pen_width) / 2.0; if (dx == 0) { diff --git a/src/newgdi/rotatebmp.c b/src/newgdi/rotatebmp.c index d0142771..f3b22bda 100644 --- a/src/newgdi/rotatebmp.c +++ b/src/newgdi/rotatebmp.c @@ -149,7 +149,7 @@ static void _parallelogram_map(HDC hdc, const BITMAP *bmp, fixed sx[4], int right_index; /* Loop variables. */ - int index, i, y; + int index, i; /* Coordinates in bmp ordered as top-right-bottom-left. */ fixed corner_dc_x[4], corner_dc_y[4]; @@ -329,7 +329,9 @@ static void _parallelogram_map(HDC hdc, const BITMAP *bmp, fixed sx[4], } fill_info.dst_rect.h = 1; - y = 0; +#if 0 + int y = 0; +#endif while (1) { if (scanline > MIN(dc_maxh, fixtoi(bottom_dc_y))) break; diff --git a/src/newgdi/tabbedtextout.c b/src/newgdi/tabbedtextout.c index 6dc35e69..c89e19d5 100644 --- a/src/newgdi/tabbedtextout.c +++ b/src/newgdi/tabbedtextout.c @@ -366,12 +366,14 @@ int _gdi_tabbedex_text_out (PDC pdc, int x, int y, int nTabs, int *pTabPos, int nTabOrig, POINT* cur_pos) { TABBEDTEXTOUTEX_CTXT ctxt; - DEVFONT* sbc_devfont; - DEVFONT* mbc_devfont; int nr_delim_newline = 0, line_len = 0; +#if 0 + DEVFONT* sbc_devfont; + DEVFONT* mbc_devfont; sbc_devfont = pdc->pLogFont->sbc_devfont; mbc_devfont = pdc->pLogFont->mbc_devfont; +#endif ctxt.pdc = pdc; ctxt.start_x = x; diff --git a/src/textedit/mtextedit.c b/src/textedit/mtextedit.c index 93f79bda..bfac2020 100644 --- a/src/textedit/mtextedit.c +++ b/src/textedit/mtextedit.c @@ -432,7 +432,7 @@ static int mTextBuffer_find(mTextBuffer* self, int start, if(start >= self->char_len) return -1; - if((int)str == TI_LINERETURN || (int) str == TI_EOF) + if((INT_PTR)str == TI_LINERETURN || (INT_PTR)str == TI_EOF) { pos = findnstr(self->buffer + start, self->char_len - start, "\n", 1); } @@ -1155,13 +1155,10 @@ static void textlayout_updateselection(mTextLayout* self) && self->old_height != self->new_height) { int max; - int min; if(self->old_height > self->new_height) { - min = self->new_height; max = self->old_height; }else{ - min = self->old_height; max = self->new_height; } @@ -1367,7 +1364,7 @@ static void textlayout_relayout(mTextLayout* self, int begin, { mTextLayoutNodeSearchInfo searchInfo; mTextLayoutNode *begin_node=NULL, *end_node = NULL; - int begin_index, end_index; + int begin_index; ITextIterator* txtit; mCommBTreeLeafIterator node_it; BOOL bHeightChanged = FALSE; /* Very important for unequal height*/ @@ -1393,7 +1390,7 @@ static void textlayout_relayout(mTextLayout* self, int begin, if(begin_node == NULL) { end_node = begin_node = textlayout_get_last_node(self, FALSE); - end_index = begin_index = textlayout_get_str_count(self); + begin_index = textlayout_get_str_count(self); } else { @@ -6405,7 +6402,6 @@ static int mTextEditor_wndProc(mTextEditor *self, int message, WPARAM wParam, LP static void mTextEditor_setTitle(mTextEditor* self, const char* buff, int len) { //repalce - int old_title_idx; int slen ; if(!(GetWindowStyle(self->hwnd) & NCSS_TE_TITLE)) @@ -6417,7 +6413,6 @@ static void mTextEditor_setTitle(mTextEditor* self, const char* buff, int len) if(len <= 0) len = -1; - old_title_idx = self->title_idx; _c(pTextBuffer)->replace(pTextBuffer, 0, self->title_idx, buff, len); if(buff == NULL || len <= 0) { @@ -6555,7 +6550,7 @@ static void init_textedit(void) } /*======== The following is textedit control implementation. =========*/ -static int mTextEditCtrlProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam) +static LRESULT mTextEditCtrlProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { mTextEditor *self = NULL; @@ -6565,7 +6560,7 @@ static int mTextEditCtrlProc (HWND hWnd, int message, WPARAM wParam, LPARAM lPar switch(message) { case MSG_CREATE: - if (!(self = NEWEX(mTextEditor, hWnd))) + if (!(self = NEWEX(mTextEditor, (DWORD)hWnd))) return -1; SetWindowAdditionalData2 (hWnd, (DWORD)self); diff --git a/src/textedit/object.c b/src/textedit/object.c index f631afc2..9ff266ab 100644 --- a/src/textedit/object.c +++ b/src/textedit/object.c @@ -207,8 +207,13 @@ int ncsParseConstructParams(va_list args, const char* signature, ...) int argc; int i; + /* + ** the implementation of GET_ARG_COUNT is bad, because some systems + ** define va_list as a pointer, and others define it as an array of + ** pointers (of length 1). if(GET_ARG_COUNT(args) <= 0) return 0; + */ argc = va_arg(args, int); if(argc <= 0) @@ -226,11 +231,11 @@ int ncsParseConstructParams(va_list args, const char* signature, ...) break; case 'f': //float -/* FIXME gcc says: - * warning: 'float' is promoted to 'double' when passed through '...' - * warning: (so you should pass 'double' not 'float' to 'va_arg') - * note: if this code is reached, the program will abort. - */ + /* FIXME gcc says: + ** warning: 'float' is promoted to 'double' when passed through '...' + ** warning: (so you should pass 'double' not 'float' to 'va_arg') + ** note: if this code is reached, the program will abort. + */ *(va_arg(params, float*)) = va_arg(args, double); break; case 'i': //integer diff --git a/src/textedit/object.h b/src/textedit/object.h index e661af11..2ca7322e 100644 --- a/src/textedit/object.h +++ b/src/textedit/object.h @@ -56,12 +56,13 @@ static ClassType(clss) * clss##ClassConstructor(ClassType(clss)* _class); \ ClassType(clss) Class(clss) = { (PClassConstructor)clss##ClassConstructor }; \ static const char* clss##_type_name = #clss; \ static ClassType(clss) * clss##ClassConstructor(ClassType(clss)* _class) { \ - unsigned short * _pintfOffset; \ + unsigned short * _pintfOffset = NULL; \ + _pintfOffset = (PVOID)((UINT_PTR)_pintfOffset ^ 0); /* prevent unused-but-set-variable warning */ \ _class = (ClassType(clss)*)((PClassConstructor)(Class(superCls).classConstructor))((mObjectClass*)_class); \ + _pintfOffset = &_class->intfOffset; \ _class->super = &Class(superCls); \ _class->typeName = clss##_type_name; \ - _class->objSize = sizeof(clss); \ - _pintfOffset = &_class->intfOffset; + _class->objSize = sizeof(clss); #define END_MINI_CLASS return _class; } @@ -126,9 +127,9 @@ static ClassType(clss) * clss##ClassConstructor(ClassType(clss)* _class) { \ struct _##Interface { Interface##VTable *_vtable; }; #define IMPLEMENT(Clss,Interface) \ - _class->_##Interface##_obj_offset = (unsigned int)(void*)&(((Clss*)0)->Interface##_); \ + _class->_##Interface##_obj_offset = (UINT_PTR)(void*)&(((Clss*)0)->Interface##_); \ _class->_##Interface##_next_offset = 0; \ - *_pintfOffset = (unsigned short)(unsigned int)(void*)&(((ClassType(Clss)*)0)->_##Interface##_obj_offset); \ + *_pintfOffset = (unsigned short)(UINT_PTR)(void*)&(((ClassType(Clss)*)0)->_##Interface##_obj_offset); \ _pintfOffset = &_class->_##Interface##_next_offset; #define INTERFACE_CAST(Interface, pobj) \ @@ -266,12 +267,18 @@ MGNCS_EXPORT mObject* mgInitObjectArgs(mObject* pobj, mObjectClass* _class, ...) #define INIT_OBJ(Clss, pobj) INIT_OBJEX(Clss, pobj, 0) #define INIT_OBJV(Clss, pobj, ...) ((Clss* )initObjectArgs((mObject*)((void*)(pobj)), \ (mObjectClass*)((void*)(&(Class(Clss)))), ##__VA_ARGS__)) + +/* +** the implementation of GET_ARG_COUNT is bad, because some systems +** define va_list as a pointer, and others define it as an array of +** pointers (of length 1). static inline int MGGET_ARG_COUNT(va_list va) { union { va_list va; DWORD dva; - }_va; + } _va; + _va.va = va; if(_va.dva == 0) return 0; @@ -282,6 +289,8 @@ static inline int MGGET_ARG_COUNT(va_list va) return 1; } #define GET_ARG_COUNT MGGET_ARG_COUNT +*/ + #define UNIT_OBJ(pobj) (_c(pobj)->destroy(pobj))