From f658209d25477c490bf1892e68a0fd1384c1dded Mon Sep 17 00:00:00 2001 From: scuri Date: Tue, 23 Jun 2009 20:55:28 +0000 Subject: *** empty log message *** --- src/x11/cdx11.c | 19 ++++++++------- src/x11/xvertex.c | 69 ++++++++++++++++++++++++++++--------------------------- src/x11/xvertex.h | 4 ++-- 3 files changed, 46 insertions(+), 46 deletions(-) (limited to 'src/x11') diff --git a/src/x11/cdx11.c b/src/x11/cdx11.c index 62e81ed..4f427e3 100644 --- a/src/x11/cdx11.c +++ b/src/x11/cdx11.c @@ -1224,9 +1224,9 @@ static int cd2xvertex [12] = {XR_TCENTRE, XR_BCENTRE, XR_MCENTRE, XR_LEFT, XR_CENTRE, XR_RIGHT}; -static void cdtext(cdCtxCanvas *ctxcanvas, int x, int y, const char *s) +static void cdtext(cdCtxCanvas *ctxcanvas, int x, int y, const char *s, int len) { - int w, h, n, dir = -1; + int w, h, dir = -1; if (ctxcanvas->canvas->text_orientation != 0) { @@ -1239,13 +1239,13 @@ static void cdtext(cdCtxCanvas *ctxcanvas, int x, int y, const char *s) { sPrepareRegion(ctxcanvas); XRotDrawString(ctxcanvas->dpy, ctxcanvas->font, ctxcanvas->canvas->text_orientation, - ctxcanvas->region_aux, ctxcanvas->region_aux_gc, x, y, s, + ctxcanvas->region_aux, ctxcanvas->region_aux_gc, x, y, s, len, cd2xvertex[ctxcanvas->canvas->text_alignment], 0); sCombineRegion(ctxcanvas); } else XRotDrawString(ctxcanvas->dpy, ctxcanvas->font, ctxcanvas->canvas->text_orientation, - ctxcanvas->wnd, ctxcanvas->gc, x, y, s, + ctxcanvas->wnd, ctxcanvas->gc, x, y, s, len, cd2xvertex[ctxcanvas->canvas->text_alignment], 0); cdxCheckSolidStyle(ctxcanvas, 0); @@ -1253,8 +1253,7 @@ static void cdtext(cdCtxCanvas *ctxcanvas, int x, int y, const char *s) return; } - n = strlen(s); - w = XTextWidth(ctxcanvas->font, s, n); + w = XTextWidth(ctxcanvas->font, s, len); h = ctxcanvas->font->ascent + ctxcanvas->font->descent; switch (ctxcanvas->canvas->text_alignment) @@ -1315,19 +1314,19 @@ static void cdtext(cdCtxCanvas *ctxcanvas, int x, int y, const char *s) { sPrepareRegion(ctxcanvas); XSetFont(ctxcanvas->dpy, ctxcanvas->region_aux_gc, ctxcanvas->font->fid); - XDrawString(ctxcanvas->dpy, ctxcanvas->region_aux, ctxcanvas->region_aux_gc, x, y+1, s, n); + XDrawString(ctxcanvas->dpy, ctxcanvas->region_aux, ctxcanvas->region_aux_gc, x, y+1, s, len); sCombineRegion(ctxcanvas); } else - XDrawString(ctxcanvas->dpy, ctxcanvas->wnd, ctxcanvas->gc, x, y+1, s, n); + XDrawString(ctxcanvas->dpy, ctxcanvas->wnd, ctxcanvas->gc, x, y+1, s, len); cdxCheckSolidStyle(ctxcanvas, 0); } -static void cdgettextsize(cdCtxCanvas *ctxcanvas, const char *s, int *width, int *height) +static void cdgettextsize(cdCtxCanvas *ctxcanvas, const char *s, int len, int *width, int *height) { if (!ctxcanvas->font) return; - if (width) *width = XTextWidth(ctxcanvas->font, s, strlen(s)); + if (width) *width = XTextWidth(ctxcanvas->font, s, len); if (height) *height = ctxcanvas->font->ascent + ctxcanvas->font->descent; } diff --git a/src/x11/xvertex.c b/src/x11/xvertex.c index d58af13..e1ca7ee 100644 --- a/src/x11/xvertex.c +++ b/src/x11/xvertex.c @@ -122,7 +122,7 @@ static struct style_template { /* ---------------------------------------------------------------------- */ -static RotatedTextItem *XRotCreateTextItem(Display *dpy, XFontStruct *font, double angle, char *text, int align); +static RotatedTextItem *XRotCreateTextItem(Display *dpy, XFontStruct *font, double angle, const char *text, int len, int align); static void XRotAddToLinkedList(Display *dpy, RotatedTextItem *item); static XImage *XRotMagnifyImage(Display *dpy, XImage *ximage); static void XRotFreeTextItem(Display *dpy, RotatedTextItem *item); @@ -133,18 +133,19 @@ static void XRotFreeTextItem(Display *dpy, RotatedTextItem *item); /* Routine to mimic `my_strdup()' (some machines don't have it) */ /**************************************************************************/ -static char *my_strdup(const char *str) +static char *my_strdup(const char *str, int len) { char *s; - int len; if(str==NULL) return NULL; - len = (int)strlen(str); s=(char *)malloc((unsigned)(len+1)); - if(s!=NULL) - memcpy(s, str, len+1); + if(s!=NULL) + { + memcpy(s, str, len); + s[len]=0; + } return s; } @@ -157,7 +158,7 @@ static char *my_strdup(const char *str) static char *my_strtok(char *str1, const char *str2) { char *ret; - int i, j, stop; + int i, j, stop, len2; static int start, len; static char *stext; @@ -176,12 +177,14 @@ static char *my_strtok(char *str1, const char *str2) if(start>=len) return NULL; + len2 = strlen(str2); + /* loop through characters */ for(i=start; itext=my_strdup(text); + item->text=my_strdup(text, len); /* fontname or ID */ if(font_name!=NULL) { - item->font_name=my_strdup(font_name); + item->font_name=my_strdup(font_name, strlen(font_name)); item->fid=0; } else @@ -477,7 +480,7 @@ static RotatedTextItem *XRotRetrieveFromCache(Display *dpy, XFontStruct *font, d /* Create a rotated text item */ /**************************************************************************/ -static RotatedTextItem *XRotCreateTextItem(Display *dpy, XFontStruct *font, double angle, char *text, int align) +static RotatedTextItem *XRotCreateTextItem(Display *dpy, XFontStruct *font, double angle, const char *text, int len, int align) { RotatedTextItem *item=NULL; Pixmap canvas; @@ -507,7 +510,7 @@ static RotatedTextItem *XRotCreateTextItem(Display *dpy, XFontStruct *font, doub /* count number of sections in string */ item->nl=1; if(align!=XR_LEFT) - for(i=0; inl++; @@ -518,7 +521,7 @@ static RotatedTextItem *XRotCreateTextItem(Display *dpy, XFontStruct *font, doub str2=str2_b; /* find width of longest section */ - str1=my_strdup(text); + str1=my_strdup(text, len); if(str1==NULL) return NULL; @@ -535,8 +538,7 @@ static RotatedTextItem *XRotCreateTextItem(Display *dpy, XFontStruct *font, doub if(str3!=NULL) { - XTextExtents(font, str3, strlen(str3), &dir, &asc, &desc, - &overall); + XTextExtents(font, str3, strlen(str3), &dir, &asc, &desc, &overall); if(overall.rbearing>item->max_width) item->max_width=overall.rbearing; @@ -590,7 +592,7 @@ static RotatedTextItem *XRotCreateTextItem(Display *dpy, XFontStruct *font, doub /* start at top of bitmap */ yp=font->ascent; - str1=my_strdup(text); + str1=my_strdup(text, len); if(str1==NULL) return NULL; @@ -641,8 +643,7 @@ static RotatedTextItem *XRotCreateTextItem(Display *dpy, XFontStruct *font, doub return NULL; /* extract horizontal text */ - XGetSubImage(dpy, canvas, 0, 0, item->cols_in, item->rows_in, - 1, XYPixmap, I_in, 0, 0); + XGetSubImage(dpy, canvas, 0, 0, item->cols_in, item->rows_in, 1, XYPixmap, I_in, 0, 0); I_in->format=XYBitmap; /* magnify horizontal text */ @@ -1073,7 +1074,7 @@ void XRotSetBoundingBoxPad(int p) /* Calculate the bounding box some text will have when painted */ /**************************************************************************/ -XPoint *XRotTextExtents(Display* dpy, XFontStruct* font, double angle, int x, int y, const char* text, int align) +XPoint *XRotTextExtents(Display* dpy, XFontStruct* font, double angle, int x, int y, const char* text, int len, int align) { register int i; char *str1, *str2, *str3; @@ -1099,7 +1100,7 @@ XPoint *XRotTextExtents(Display* dpy, XFontStruct* font, double angle, int x, in /* count number of sections in string */ nl=1; if(align!=XR_LEFT) - for(i=0; i