From c0317ddae53dfd80a6ba174066602cb4d455e045 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 22 Aug 2005 23:58:19 +0000 Subject: [PATCH] eliminated gcc-4 compilation warnings --- ChangeLog | 1 + WINGs/Examples/server.c | 4 ++-- WINGs/connection.c | 6 ++--- WINGs/dragdestination.c | 2 +- WINGs/selection.c | 2 +- WINGs/wcolor.c | 4 ++-- WINGs/wfont.c | 24 ++++++++++---------- WINGs/wfontpanel.c | 10 ++++----- WINGs/widgets.c | 2 +- WINGs/wtext.c | 2 +- WINGs/wview.c | 3 ++- WPrefs.app/FontSimple.c | 36 +++++++++++++++-------------- src/actions.c | 3 ++- src/event.c | 4 ++++ src/icon.c | 2 +- src/misc.c | 2 +- src/moveres.c | 4 ++-- src/properties.c | 4 ++-- src/startup.c | 1 + src/window.c | 10 ++++----- src/window.h | 6 ++--- test/wtest.c | 4 ++-- util/wmsetbg.c | 6 ++--- wrlib/convert.c | 27 +++++++++++----------- wrlib/gradient.c | 2 +- wrlib/ppm.c | 5 +++-- wrlib/raster.c | 24 ++++++++++++-------- wrlib/x86_specific.c | 60 ++++++++++++++++++++++++++++--------------------- 28 files changed, 143 insertions(+), 117 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0efcdbef..579d8021 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ Changes since version 0.92.0: - fixed WPrefs.app to find its icons when not installed under GNUstep paths - fixed gcc-4 compilation issues (Vladimir Nadvornik ) - fixed amd64 compilation issues (Vladimir Nadvornik ) +- eliminated gcc-4 compilation warnings Changes since version 0.91.0: diff --git a/WINGs/Examples/server.c b/WINGs/Examples/server.c index 7c404a1d..d0d0e454 100644 --- a/WINGs/Examples/server.c +++ b/WINGs/Examples/server.c @@ -126,8 +126,8 @@ enqueueMessage(WMConnection *cPtr, char *message) } -static unsigned char* -findDelimiter(unsigned char *data, unsigned const char *endPtr) +static char* +findDelimiter(char *data, const char *endPtr) { wassertrv(data < endPtr, NULL); diff --git a/WINGs/connection.c b/WINGs/connection.c index 30899931..ec5e92ee 100644 --- a/WINGs/connection.c +++ b/WINGs/connection.c @@ -201,7 +201,7 @@ inputHandler(int fd, int mask, void *clientData) if (cPtr->state == WCInProgress) { Bool failed; - int len = sizeof(result); + socklen_t len = sizeof(result); WCErrorCode = 0; if (getsockopt(cPtr->sock, SOL_SOCKET, SO_ERROR, @@ -462,8 +462,8 @@ WMCreateConnectionAsServerAtAddress(char *host, char *service, char *protocol) { WMConnection *cPtr; struct sockaddr_in *socketaddr; + socklen_t size; int sock, on; - int size; WCErrorCode = 0; @@ -678,7 +678,7 @@ WMConnection* WMAcceptConnection(WMConnection *listener) { struct sockaddr_in clientname; - int size; + socklen_t size; int newSock; WMConnection *newConnection; diff --git a/WINGs/dragdestination.c b/WINGs/dragdestination.c index 34f29c4b..a1944a79 100644 --- a/WINGs/dragdestination.c +++ b/WINGs/dragdestination.c @@ -219,7 +219,7 @@ sourceOperationList(WMScreen *scr, Window sourceWin) } operationArray = WMCreateDragOperationArray(count); - description = descriptionList; + description = (char*)descriptionList; for (i=0; count > 0; i++) { size = strlen(description); diff --git a/WINGs/selection.c b/WINGs/selection.c index e5201e38..2f955482 100644 --- a/WINGs/selection.c +++ b/WINGs/selection.c @@ -279,7 +279,7 @@ getSelectionData(Display *dpy, Window win, Atom where) WMData *wdata; unsigned char *data; Atom rtype; - unsigned bits, bpi; + int bits, bpi; unsigned long len, bytes; diff --git a/WINGs/wcolor.c b/WINGs/wcolor.c index f35252bd..cb9ae505 100644 --- a/WINGs/wcolor.c +++ b/WINGs/wcolor.c @@ -7,12 +7,12 @@ #define LIGHT_STIPPLE_WIDTH 4 #define LIGHT_STIPPLE_HEIGHT 4 -static unsigned char LIGHT_STIPPLE_BITS[] = { +static char LIGHT_STIPPLE_BITS[] = { 0x05, 0x0a, 0x05, 0x0a}; #define DARK_STIPPLE_WIDTH 4 #define DARK_STIPPLE_HEIGHT 4 -static unsigned char DARK_STIPPLE_BITS[] = { +static char DARK_STIPPLE_BITS[] = { 0x0a, 0x04, 0x0a, 0x01}; diff --git a/WINGs/wfont.c b/WINGs/wfont.c index 03c6d002..26750fff 100644 --- a/WINGs/wfont.c +++ b/WINGs/wfont.c @@ -27,7 +27,7 @@ xlfdToFcPattern(char *xlfd) /* Just skip old font names that contain %d in them. * We don't support that anymore. */ if (strchr(xlfd, '%')!=NULL) - return FcNameParse(DEFAULT_FONT); + return FcNameParse((FcChar8*)DEFAULT_FONT); fname= wstrdup(xlfd); if ((ptr = strchr(fname, ','))) { @@ -38,7 +38,7 @@ xlfdToFcPattern(char *xlfd) if (!pattern) { wwarning(_("invalid font: %s. Trying '%s'"), xlfd, DEFAULT_FONT); - pattern = FcNameParse(DEFAULT_FONT); + pattern = FcNameParse((FcChar8*)DEFAULT_FONT); } return pattern; @@ -52,7 +52,7 @@ xlfdToFcName(char *xlfd) char *fname; pattern = xlfdToFcPattern(xlfd); - fname = FcNameUnparse(pattern); + fname = (char*)FcNameUnparse(pattern); FcPatternDestroy(pattern); return fname; @@ -102,7 +102,7 @@ makeFontOfSize(char *font, int size, char *fallback) if (font[0]=='-') { pattern = xlfdToFcPattern(font); } else { - pattern = FcNameParse(font); + pattern = FcNameParse((FcChar8*)font); } /*FcPatternPrint(pattern);*/ @@ -116,12 +116,12 @@ makeFontOfSize(char *font, int size, char *fallback) } if (fallback && !hasPropertyWithStringValue(pattern, FC_FAMILY, fallback)) { - FcPatternAddString(pattern, FC_FAMILY, fallback); + FcPatternAddString(pattern, FC_FAMILY, (FcChar8*)fallback); } /*FcPatternPrint(pattern);*/ - result = FcNameUnparse(pattern); + result = (char*)FcNameUnparse(pattern); FcPatternDestroy(pattern); return result; @@ -366,7 +366,7 @@ WMCopyFontWithStyle(WMScreen *scrPtr, WMFont *font, WMFontStyle style) * return the closest match font to what we requested which is the * oblique font. Same goes for using bold for weight. */ - pattern = FcNameParse(WMGetFontName(font)); + pattern = FcNameParse((FcChar8*)WMGetFontName(font)); switch (style) { case WFSNormal: FcPatternDel(pattern, FC_WEIGHT); @@ -374,21 +374,21 @@ WMCopyFontWithStyle(WMScreen *scrPtr, WMFont *font, WMFontStyle style) break; case WFSBold: FcPatternDel(pattern, FC_WEIGHT); - FcPatternAddString(pattern, FC_WEIGHT, "bold"); + FcPatternAddString(pattern, FC_WEIGHT, (FcChar8*)"bold"); break; case WFSItalic: FcPatternDel(pattern, FC_SLANT); - FcPatternAddString(pattern, FC_SLANT, "italic"); + FcPatternAddString(pattern, FC_SLANT, (FcChar8*)"italic"); break; case WFSBoldItalic: FcPatternDel(pattern, FC_WEIGHT); FcPatternDel(pattern, FC_SLANT); - FcPatternAddString(pattern, FC_WEIGHT, "bold"); - FcPatternAddString(pattern, FC_SLANT, "italic"); + FcPatternAddString(pattern, FC_WEIGHT, (FcChar8*)"bold"); + FcPatternAddString(pattern, FC_SLANT, (FcChar8*)"italic"); break; } - name = FcNameUnparse(pattern); + name = (char*)FcNameUnparse(pattern); copy = WMCreateFont(scrPtr, name); FcPatternDestroy(pattern); wfree(name); diff --git a/WINGs/wfontpanel.c b/WINGs/wfontpanel.c index a98a23c7..c9909055 100644 --- a/WINGs/wfontpanel.c +++ b/WINGs/wfontpanel.c @@ -83,7 +83,7 @@ static int scalableFontSizes[] = { -static void setFontPanelFontName(FontPanel *panel, FcChar8 *family, FcChar8 *style, double size); +static void setFontPanelFontName(FontPanel *panel, char *family, char *style, double size); static int isXLFD(char *font, int *length_ret); @@ -370,7 +370,7 @@ WMSetFontPanelFont(WMFontPanel *panel, char *fontName) if (!isXLFD(fontName, &fname_len)) { /* maybe its proper fontconfig and we can parse it */ - pattern = FcNameParse(fontName); + pattern = FcNameParse((FcChar8*)fontName); } else { /* maybe its proper xlfd and we can convert it to an FcPattern */ pattern = XftXlfdParse(fontName, False, False); @@ -383,7 +383,7 @@ WMSetFontPanelFont(WMFontPanel *panel, char *fontName) if (FcPatternGetString(pattern, FC_FAMILY, 0, &family)==FcResultMatch) if (FcPatternGetString(pattern, FC_STYLE, 0, &style)==FcResultMatch) if (FcPatternGetDouble(pattern, "pixelsize", 0, &size)==FcResultMatch) - setFontPanelFontName(panel, family, style, size); + setFontPanelFontName(panel, (char*)family, (char*)style, size); FcPatternDestroy(pattern); } @@ -603,7 +603,7 @@ listFamilies(WMScreen *scr, WMFontPanel *panel) if (FcPatternGetString(fs->fonts[i],FC_FAMILY,0,&family)==FcResultMatch) if (FcPatternGetString(fs->fonts[i],FC_STYLE,0,&style)==FcResultMatch) - addFontToXftFamily(families, family, style); + addFontToXftFamily(families, (char*)family, (char*)style); } FcFontSetDestroy(fs); } @@ -815,7 +815,7 @@ sizeClick(WMWidget *w, void *data) static void -setFontPanelFontName(FontPanel *panel, FcChar8 *family, FcChar8 *style, double size) +setFontPanelFontName(FontPanel *panel, char *family, char *style, double size) { int famrow; int stlrow; diff --git a/WINGs/widgets.c b/WINGs/widgets.c index 4ff5e288..912120cd 100644 --- a/WINGs/widgets.c +++ b/WINGs/widgets.c @@ -305,7 +305,7 @@ static char *CHECK_MARK[] = { #define STIPPLE_WIDTH 8 #define STIPPLE_HEIGHT 8 -static unsigned char STIPPLE_BITS[] = { +static char STIPPLE_BITS[] = { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 }; diff --git a/WINGs/wtext.c b/WINGs/wtext.c index 02322845..3ace1d07 100644 --- a/WINGs/wtext.c +++ b/WINGs/wtext.c @@ -207,7 +207,7 @@ output(char *ptr, int len) #define STIPPLE_WIDTH 8 #define STIPPLE_HEIGHT 8 -static unsigned char STIPPLE_BITS[] = { +static char STIPPLE_BITS[] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa }; diff --git a/WINGs/wview.c b/WINGs/wview.c index 8eb56900..c1ec136c 100644 --- a/WINGs/wview.c +++ b/WINGs/wview.c @@ -715,7 +715,8 @@ WMGetViewScreenPosition(WMView *view) { WMScreen *scr = W_VIEW_SCREEN(view); Window foo; - int x, y, topX, topY, bar; + int x, y, topX, topY; + unsigned int bar; WMView *topView; topView = view; diff --git a/WPrefs.app/FontSimple.c b/WPrefs.app/FontSimple.c index 04be1d45..97e2c7c4 100644 --- a/WPrefs.app/FontSimple.c +++ b/WPrefs.app/FontSimple.c @@ -231,11 +231,11 @@ lookup_available_fonts(_Panel *panel) for (i= 0; i < fonts->nfont; i++) { - FcChar8 *name; + char *name; int weight, slant, width; int j, found; - if (FcPatternGetString(fonts->fonts[i], FC_FAMILY, 0, &name) != FcResultMatch) + if (FcPatternGetString(fonts->fonts[i], FC_FAMILY, 0, (FcChar8**)&name) != FcResultMatch) continue; if (FcPatternGetInteger(fonts->fonts[i], FC_WEIGHT, 0, &weight) != FcResultMatch) @@ -309,7 +309,7 @@ lookup_available_fonts(_Panel *panel) static char* -getSelectedFont(_Panel *panel, char *curfont) +getSelectedFont(_Panel *panel, FcChar8 *curfont) { WMListItem *item; FcPattern *pat= FcNameParse(curfont); @@ -319,7 +319,7 @@ getSelectedFont(_Panel *panel, char *curfont) if (item) { FcPatternDel(pat, FC_FAMILY); - FcPatternAddString(pat, FC_FAMILY, item->text); + FcPatternAddString(pat, FC_FAMILY, (FcChar8*)item->text); } item= WMGetListSelectedItem(panel->styleL); @@ -344,9 +344,9 @@ getSelectedFont(_Panel *panel, char *curfont) FcPatternAddDouble(pat, FC_PIXEL_SIZE, atoi(item->text)); } - name= FcNameUnparse(pat); + name = (char*)FcNameUnparse(pat); FcPatternDestroy(pat); - + return name; } @@ -446,12 +446,13 @@ selectedFamily(WMWidget *w, void *data) { int index= WMGetPopUpButtonSelectedItem(panel->optionP); WMMenuItem *item= WMGetPopUpButtonMenuItem(panel->optionP, index); - char *ofont, *nfont; + FcChar8 *ofont; + char *nfont; - ofont= (char*)WMGetMenuItemRepresentedObject(item); - + ofont= (FcChar8*)WMGetMenuItemRepresentedObject(item); nfont= getSelectedFont(panel, ofont); - free(ofont); + wfree(ofont); + WMSetMenuItemRepresentedObject(item, nfont); } updateSampleFont(panel); @@ -465,12 +466,13 @@ selected(WMWidget *w, void *data) _Panel *panel= (_Panel*)data; int index= WMGetPopUpButtonSelectedItem(panel->optionP); WMMenuItem *item= WMGetPopUpButtonMenuItem(panel->optionP, index); - char *ofont, *nfont; + FcChar8 *ofont; + char *nfont; - ofont= (char*)WMGetMenuItemRepresentedObject(item); - + ofont = (FcChar8*)WMGetMenuItemRepresentedObject(item); nfont= getSelectedFont(panel, ofont); - free(ofont); + wfree(ofont); + WMSetMenuItemRepresentedObject(item, nfont); updateSampleFont(panel); @@ -490,10 +492,10 @@ selectedOption(WMWidget *w, void *data) { FcPattern *pat; - pat= FcNameParse(font); + pat= FcNameParse((FcChar8*)font); if (pat) { - FcChar8 *name; + char *name; int weight, slant, width; double size; int distance, closest, found; @@ -501,7 +503,7 @@ selectedOption(WMWidget *w, void *data) FcDefaultSubstitute(pat); - if (FcPatternGetString(pat, FC_FAMILY, 0, &name) != FcResultMatch) + if (FcPatternGetString(pat, FC_FAMILY, 0, (FcChar8**)&name) != FcResultMatch) name= "sans serif"; found= 0; diff --git a/src/actions.c b/src/actions.c index 6e6e45c1..9298bd20 100644 --- a/src/actions.c +++ b/src/actions.c @@ -365,7 +365,8 @@ wUnshadeWindow(WWindow *wwin) void wMaximizeWindow(WWindow *wwin, int directions) { - int new_width, new_height, new_x, new_y; + int new_x, new_y; + unsigned int new_width, new_height; int changed_h, changed_v, shrink_h, shrink_v; WArea usableArea, totalArea; diff --git a/src/event.c b/src/event.c index 07bd8a98..85046d49 100644 --- a/src/event.c +++ b/src/event.c @@ -559,6 +559,10 @@ handleMapRequest(XEvent *ev) wwin->flags.skip_next_animation = 1; wIconifyWindow(wwin); } + if (wwin->flags.fullscreen) { + wwin->flags.fullscreen = 0; + wFullscreenWindow(wwin); + } if (wwin->flags.hidden) { WApplication *wapp = wApplicationOf(wwin->main_window); diff --git a/src/icon.c b/src/icon.c index 8f88961c..19a918c8 100644 --- a/src/icon.c +++ b/src/icon.c @@ -651,7 +651,7 @@ wIconUpdate(WIcon *icon) if (icon->icon_win!=None) { XWindowAttributes attr; int resize=0; - int width, height, depth; + unsigned int width, height, depth; int theight; Pixmap pixmap; diff --git a/src/misc.c b/src/misc.c index 46bebf8c..31cb35af 100644 --- a/src/misc.c +++ b/src/misc.c @@ -1128,7 +1128,7 @@ UnescapeWM_CLASS(char *str, char **name, char **class) void SendHelperMessage(WScreen *scr, char type, int workspace, char *msg) { - unsigned char *buffer; + char *buffer; int len; int i; char buf[16]; diff --git a/src/moveres.c b/src/moveres.c index 26e6a79f..7d4fccb0 100644 --- a/src/moveres.c +++ b/src/moveres.c @@ -1471,7 +1471,7 @@ wKeyboardMoveResizeWindow(WWindow *wwin) ww=w;wh=h; wh-=vert_border; - wWindowConstrainSize(wwin, &ww, &wh); + wWindowConstrainSize(wwin, (unsigned int*)&ww, (unsigned int*)&wh); wh+=vert_border; if (wPreferences.ws_cycle){ @@ -2070,7 +2070,7 @@ wMouseResizeWindow(WWindow *wwin, XEvent *ev) rh += dh; fw = rw; fh = rh - vert_border; - wWindowConstrainSize(wwin, &fw, &fh); + wWindowConstrainSize(wwin, (unsigned int*)&fw, (unsigned int*)&fh); fh += vert_border; if (res & LEFT) fx = rx2 - fw + 1; diff --git a/src/properties.c b/src/properties.c index 080c1664..07521135 100644 --- a/src/properties.c +++ b/src/properties.c @@ -234,8 +234,8 @@ PropSetIconTileHint(WScreen *scr, RImage *image) if (image->format == RRGBAFormat) { memcpy(&tmp[4], image->data, image->width*image->height*4); } else { - char *ptr = tmp+4; - char *src = image->data; + char *ptr = (char*)(tmp+4); + char *src = (char*)image->data; for (y = 0; y < image->height; y++) { for (x = 0; x < image->width; x++) { diff --git a/src/startup.c b/src/startup.c index bfb55749..8d3f5212 100644 --- a/src/startup.c +++ b/src/startup.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/src/window.c b/src/window.c index 1a82549a..0b6a39a3 100644 --- a/src/window.c +++ b/src/window.c @@ -2043,10 +2043,10 @@ wWindowUpdateName(WWindow *wwin, char *newTitle) *---------------------------------------------------------------------- */ void -wWindowConstrainSize(WWindow *wwin, int *nwidth, int *nheight) +wWindowConstrainSize(WWindow *wwin, unsigned int *nwidth, unsigned int *nheight) { - int width = *nwidth; - int height = *nheight; + int width = (int)*nwidth; + int height = (int)*nheight; int winc = 1; int hinc = 1; int minW = 1, minH = 1; @@ -2143,8 +2143,8 @@ wWindowConstrainSize(WWindow *wwin, int *nwidth, int *nheight) void -wWindowCropSize(WWindow *wwin, int maxW, int maxH, - int *width, int *height) +wWindowCropSize(WWindow *wwin, unsigned int maxW, unsigned int maxH, + unsigned int *width, unsigned int *height) { int baseW = 0, baseH = 0; int winc = 1, hinc = 1; diff --git a/src/window.h b/src/window.h index b543d34e..e8275e25 100644 --- a/src/window.h +++ b/src/window.h @@ -388,9 +388,9 @@ void wWindowFocus(WWindow *wwin, WWindow *owin); void wWindowUnfocus(WWindow *wwin); void wWindowUpdateName(WWindow *wwin, char *newTitle); -void wWindowConstrainSize(WWindow *wwin, int *nwidth, int *nheight); -void wWindowCropSize(WWindow *wwin, int maxw, int maxh, - int *nwidth, int *nheight); +void wWindowConstrainSize(WWindow *wwin, unsigned int *nwidth, unsigned int *nheight); +void wWindowCropSize(WWindow *wwin, unsigned int maxw, unsigned int maxh, + unsigned int *nwidth, unsigned int *nheight); void wWindowConfigure(WWindow *wwin, int req_x, int req_y, int req_width, int req_height); diff --git a/test/wtest.c b/test/wtest.c index 71feeb1f..5d5a0f52 100644 --- a/test/wtest.c +++ b/test/wtest.c @@ -15,11 +15,11 @@ #include #include -static unsigned char bits[] = { +static char bits[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; -static unsigned char mbits[] = { +static char mbits[] = { 0xff, 0x03, 0xff, 0x01, 0xff, 0x00, 0x7f, 0x00, 0x3f, 0x00, 0x1f, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x03, 0x00, 0x01, 0x00}; diff --git a/util/wmsetbg.c b/util/wmsetbg.c index 794af7a1..5e148162 100644 --- a/util/wmsetbg.c +++ b/util/wmsetbg.c @@ -787,7 +787,7 @@ void freeTexture(BackgroundTexture *texture) { if (texture->solid) { - long pixel[1]; + unsigned long pixel[1]; pixel[0] = texture->color.pixel; /* dont free black/white pixels */ @@ -966,7 +966,7 @@ changeTexture(BackgroundTexture *texture) int -readmsg(int fd, unsigned char *buffer, int size) +readmsg(int fd, char *buffer, int size) { int count; @@ -998,7 +998,7 @@ helperLoop(RContext *rc) { BackgroundTexture *textures[WORKSPACE_COUNT]; int maxTextures = 0; - unsigned char buffer[2048], buf[8]; + char buffer[2048], buf[8]; int size; int errcount = 4; diff --git a/wrlib/convert.c b/wrlib/convert.c index bf7851c0..cd543047 100644 --- a/wrlib/convert.c +++ b/wrlib/convert.c @@ -68,8 +68,9 @@ extern int x86_check_mmx(); extern void x86_mmx_TrueColor_32_to_16(unsigned char *image, unsigned short *ximage, short *err, short *nerr, - short *rtable, short *gtable, - short *btable, + const unsigned short *rtable, + const unsigned short *gtable, + const unsigned short *btable, int dr, int dg, int db, unsigned int roffs, unsigned int goffs, @@ -175,9 +176,9 @@ computeStdTable(unsigned int mult, unsigned int max) static void convertTrueColor_generic(RXImage *ximg, RImage *image, signed char *err, signed char *nerr, - const short *rtable, - const short *gtable, - const short *btable, + const unsigned short *rtable, + const unsigned short *gtable, + const unsigned short *btable, const int dr, const int dg, const int db, const unsigned short roffs, const unsigned short goffs, @@ -408,8 +409,8 @@ image2TrueColor(RContext *ctx, RImage *image) } else #endif /* ASM_X86_MMX */ { - char *err; - char *nerr; + signed char *err; + signed char *nerr; int ch = (HAS_ALPHA(image) ? 4 : 3); err = malloc(ch*(image->width+2)); @@ -447,9 +448,9 @@ image2TrueColor(RContext *ctx, RImage *image) static void convertPseudoColor_to_8(RXImage *ximg, RImage *image, signed char *err, signed char *nerr, - const short *rtable, - const short *gtable, - const short *btable, + const unsigned short *rtable, + const unsigned short *gtable, + const unsigned short *btable, const int dr, const int dg, const int db, unsigned long *pixels, int cpc) @@ -459,7 +460,7 @@ convertPseudoColor_to_8(RXImage *ximg, RImage *image, int pixel; int rer, ger, ber; unsigned char *ptr = image->data; - unsigned char *optr = ximg->image->data; + unsigned char *optr = (unsigned char*)ximg->image->data; int channels = (HAS_ALPHA(image) ? 4 : 3); int cpcpc = cpc*cpc; @@ -573,8 +574,8 @@ image2PseudoColor(RContext *ctx, RImage *image) } } else { /* dither */ - char *err; - char *nerr; + signed char *err; + signed char *nerr; const int dr=0xff/rmask; const int dg=0xff/gmask; const int db=0xff/bmask; diff --git a/wrlib/gradient.c b/wrlib/gradient.c index d6b48c0a..38f19df0 100644 --- a/wrlib/gradient.c +++ b/wrlib/gradient.c @@ -242,7 +242,7 @@ renderDGradient(unsigned width, unsigned height, int r0, int g0, int b0, RImage *image, *tmp; int j; float a, offset; - char *ptr; + unsigned char *ptr; if (width == 1) return renderVGradient(width, height, r0, g0, b0, rf, gf, bf); diff --git a/wrlib/ppm.c b/wrlib/ppm.c index c372d2a0..e13ca5a0 100644 --- a/wrlib/ppm.c +++ b/wrlib/ppm.c @@ -43,8 +43,9 @@ load_graymap(char *file_name, FILE *file, int w, int h, int max, int raw) } else { if (max<256) { + unsigned char *ptr; + char *buf; int x, y; - char *buf, *ptr; buf = malloc(w+1); if (!buf) { @@ -83,7 +84,7 @@ load_pixmap(char *file_name, FILE *file, int w, int h, int max, int raw) RImage *image; int i; char buf[3]; - char *ptr; + unsigned char *ptr; image = RCreateImage(w, h, 0); if (!image) { diff --git a/wrlib/raster.c b/wrlib/raster.c index 5296232e..4c1719c3 100644 --- a/wrlib/raster.c +++ b/wrlib/raster.c @@ -283,31 +283,37 @@ RCombineImagesWithOpaqueness(RImage *image, RImage *src, int opaqueness) int calculateCombineArea(RImage *des, RImage *src, int *sx, int *sy, - int *swidth, int *sheight, int *dx, int *dy) + unsigned int *swidth, unsigned int *sheight, int *dx, int *dy) { + int width = (int)*swidth, height = (int)*sheight; + if (*dx < 0) { *sx = -*dx; - *swidth = *swidth + *dx; + width = width + *dx; *dx = 0; } - if (*dx + *swidth > des->width) { - *swidth = des->width - *dx; + if (*dx + width > des->width) { + width = des->width - *dx; } if (*dy < 0) { *sy = -*dy; - *sheight = *sheight + *dy; + height = height + *dy; *dy = 0; } - if (*dy + *sheight > des->height) { - *sheight = des->height - *dy; + if (*dy + height > des->height) { + height = des->height - *dy; } - if (*sheight > 0 && *swidth > 0) { + if (height>0 && width>0) { + *swidth = width; + *sheight = height; return True; - } else return False; + } + + return False; } void diff --git a/wrlib/x86_specific.c b/wrlib/x86_specific.c index acd9503c..a67f5717 100644 --- a/wrlib/x86_specific.c +++ b/wrlib/x86_specific.c @@ -85,9 +85,9 @@ x86_mmx_TrueColor_32_to_16(unsigned char *image, unsigned short *ximage, short *err, short *nerr, - short *rtable, - short *gtable, - short *btable, + unsigned short *rtable, + unsigned short *gtable, + unsigned short *btable, int dr, int dg, int db, @@ -99,13 +99,17 @@ x86_mmx_TrueColor_32_to_16(unsigned char *image, int line_offset) { union { - long long rrggbbaa; - struct {short int rr, gg, bb, aa;} words; + long long rrggbbaa; + struct { + short int rr, gg, bb, aa; + } words; } rrggbbaa; - + union { - long long pixel; - struct {short int rr, gg, bb, aa;} words; + long long pixel; + struct { + short int rr, gg, bb, aa; + } words; } pixel; short *tmp_err; @@ -114,7 +118,7 @@ x86_mmx_TrueColor_32_to_16(unsigned char *image, asm volatile ( - "pushl %%ebx \n\t" + "pushl %%ebx \n\t" // pack dr, dg and db into mm6 "movl %7, %%eax \n\t" @@ -227,7 +231,7 @@ x86_mmx_TrueColor_32_to_16(unsigned char *image, "movq %%mm0, %%mm1 \n\t" "pmullw %%mm5, %%mm1 \n\t" // mm1 = mm1*7 "psrlw %%mm7, %%mm1 \n\t" // mm1 = mm1/16 - "paddw 8(%%ebx), %%mm1 \n\t" + "paddw 8(%%ebx), %%mm1 \n\t" "movq %%mm1, 8(%%ebx) \n\t" // err[x+1,y] = rer*7/16 @@ -236,7 +240,7 @@ x86_mmx_TrueColor_32_to_16(unsigned char *image, "movq %%mm0, %%mm1 \n\t" "pmullw %%mm4, %%mm1 \n\t" // mm1 = mm1*5 "psrlw %%mm7, %%mm1 \n\t" // mm1 = mm1/16 - "paddw -8(%%ebx), %%mm1 \n\t" + "paddw -8(%%ebx), %%mm1 \n\t" "movq %%mm1, -8(%%ebx) \n\t" // err[x-1,y+1] += rer*3/16 "movq %%mm0, %%mm1 \n\t" @@ -282,7 +286,7 @@ x86_mmx_TrueColor_32_to_16(unsigned char *image, // because, punpcklbw is used (which reads 8 bytes) and the last // pixel is only 4 bytes. This is no problem because the image data // was allocated with extra 4 bytes when created. - "addl $4, %%esi \n\t" // image->data += 4 + "addl $4, %%esi \n\t" // image->data += 4 "decl %26 \n\t" // x-- @@ -298,7 +302,7 @@ x86_mmx_TrueColor_32_to_16(unsigned char *image, ".Enda: \n\t" // THE END "emms \n\t" - "popl %%ebx \n\t" + "popl %%ebx \n\t" : : "m" (image), // %0 @@ -317,18 +321,18 @@ x86_mmx_TrueColor_32_to_16(unsigned char *image, "m" (width), // %13 "m" (height), // %14 "m" (line_offset), // %15 - "m" (rrggbbaa.rrggbbaa), // %16 (access to rr) + "m" (rrggbbaa.words.rr), // %16 (access to rr) "m" (rrggbbaa.words.gg), // %17 (access to gg) "m" (rrggbbaa.words.bb), // %18 (access to bb) "m" (rrggbbaa.words.aa), // %19 (access to aa) - "m" (pixel.pixel), // %20 (access to pixel.r) + "m" (pixel.words.rr), // %20 (access to pixel.r) "m" (pixel.words.gg), // %21 (access to pixel.g) "m" (pixel.words.bb), // %22 (access to pixel.b) "m" (pixel.words.aa), // %23 (access to pixel.a) "m" (tmp_err), // %24 "m" (tmp_nerr), // %25 "m" (x) // %26 - : "eax", "ecx", "edx", "esi", "edi" + : "eax", "ecx", "edx", "esi", "edi" ); } @@ -352,13 +356,17 @@ x86_mmx_TrueColor_24_to_16(unsigned char *image, int line_offset) { union { - long long rrggbbaa; - struct {short int rr, gg, bb, aa;} words; + long long rrggbbaa; + struct { + short int rr, gg, bb, aa; + } words; } rrggbbaa; union { - long long pixel; - struct {short int rr, gg, bb, aa;} words; + long long pixel; + struct { + short int rr, gg, bb, aa; + } words; } pixel; short *tmp_err; @@ -370,7 +378,7 @@ x86_mmx_TrueColor_24_to_16(unsigned char *image, asm volatile ( - "pushl %%ebx \n\t" + "pushl %%ebx \n\t" "movl %13, %%eax \n\t" // eax = width "movl %%eax, %%ebx \n\t" @@ -440,7 +448,7 @@ x86_mmx_TrueColor_24_to_16(unsigned char *image, ".Endc: \n\t" // THE END "emms \n\t" - "popl %%ebx \n\t" + "popl %%ebx \n\t" : : "m" (image), // %0 @@ -459,11 +467,11 @@ x86_mmx_TrueColor_24_to_16(unsigned char *image, "m" (width), // %13 "m" (height), // %14 "m" (line_offset), // %15 - "m" (rrggbbaa.rrggbbaa), // %16 (access to rr) + "m" (rrggbbaa.words.rr), // %16 (access to rr) "m" (rrggbbaa.words.gg), // %17 (access to gg) "m" (rrggbbaa.words.bb), // %18 (access to bb) "m" (rrggbbaa.words.aa), // %19 (access to aa) - "m" (pixel.pixel), // %20 (access to pixel.r) + "m" (pixel.words.rr), // %20 (access to pixel.r) "m" (pixel.words.gg), // %21 (access to pixel.g) "m" (pixel.words.bb), // %22 (access to pixel.b) "m" (pixel.words.aa), // %23 (access to pixel.a) @@ -472,7 +480,7 @@ x86_mmx_TrueColor_24_to_16(unsigned char *image, "m" (x), // %26 "m" (w1), // %27 "m" (w2) // %28 - : "eax", "ecx", "edx", "esi", "edi" + : "eax", "ecx", "edx", "esi", "edi" ); } @@ -670,7 +678,7 @@ x86_PseudoColor_32_to_8(unsigned char *image, "movw $0xff, %%dx \n\t" // pixel.blu > 255 "jmp .OKBb \n" ".NEGBb: \n\t" - "xorw %%dx, %%dx \n" + "xorw %%dx, %%dx \n" ".OKBb: \n\t" //partial reg "leal (%%edi, %%edx, 2), %%ecx \n\t" // ecx = &ctable[pixel.blu] -- 2.11.4.GIT