sawfish r4276 - trunk/src



Author: tkorvola
Date: Sun Aug 31 13:15:40 2008
New Revision: 4276
URL: http://svn.gnome.org/viewvc/sawfish?rev=4276&view=rev

Log:
Eliminated remaining gpointer abuses.

This involved changing many unsigned char *s to char *s.

Modified:
   trunk/src/fonts.c
   trunk/src/frames.c
   trunk/src/functions.c
   trunk/src/images.c
   trunk/src/keys.c
   trunk/src/libclient.c
   trunk/src/sawmill_subrs.h
   trunk/src/x.c

Modified: trunk/src/fonts.c
==============================================================================
--- trunk/src/fonts.c	(original)
+++ trunk/src/fonts.c	Sun Aug 31 13:15:40 2008
@@ -72,8 +72,8 @@
     const char *type;
     bool (*load) (Lisp_Font *f);
     void (*finalize) (Lisp_Font *f);
-    int (*measure) (Lisp_Font *f, unsigned char *string, size_t length);
-    void (*draw) (Lisp_Font *f, unsigned char *string, size_t length,
+    int (*measure) (Lisp_Font *f, char *string, size_t length);
+    void (*draw) (Lisp_Font *f, char *string, size_t length,
 		  Window id, GC gc, Lisp_Color *fg, int x, int y);
 };
 
@@ -104,13 +104,13 @@
 }
 
 static int
-fontstruct_measure (Lisp_Font *f, unsigned char *string, size_t length)
+fontstruct_measure (Lisp_Font *f, char *string, size_t length)
 {
-    return XTextWidth (f->font, (gpointer) string, length);
+    return XTextWidth (f->font, string, length);
 }
 
 static void
-fontstruct_draw (Lisp_Font *f, unsigned char *string, size_t length,
+fontstruct_draw (Lisp_Font *f, char *string, size_t length,
 		 Window id, GC gc, Lisp_Color *fg, int x, int y)
 {
     XFontStruct *fs;
@@ -122,7 +122,7 @@
     gcv.font = fs->fid;
     XChangeGC (dpy, gc, GCForeground | GCFont, &gcv);
 
-    XDrawString (dpy, id, gc, x, y, (gpointer) string, length);
+    XDrawString (dpy, id, gc, x, y, string, length);
 }
 
 static const Lisp_Font_Class fontstruct_class = {
@@ -309,17 +309,17 @@
 }
 
 static int
-fontset_measure (Lisp_Font *f, unsigned char *string, size_t length)
+fontset_measure (Lisp_Font *f, char *string, size_t length)
 {
 #ifdef X_HAVE_UTF8_STRING
-    return Xutf8TextEscapement (f->font, (gpointer) string, length);
+    return Xutf8TextEscapement (f->font, string, length);
 #else
     return XmbTextEscapement (f->font, string, length);
 #endif
 }
 
 static void
-fontset_draw (Lisp_Font *f, unsigned char *string, size_t length,
+fontset_draw (Lisp_Font *f, char *string, size_t length,
 	      Window id, GC gc, Lisp_Color *fg, int x, int y)
 {
     XGCValues gcv;
@@ -327,7 +327,7 @@
     gcv.foreground = fg->pixel;
     XChangeGC (dpy, gc, GCForeground, &gcv);
 #ifdef X_HAVE_UTF8_STRING
-    Xutf8DrawString (dpy, id, f->font, gc, x, y, (gpointer) string, length);
+    Xutf8DrawString (dpy, id, f->font, gc, x, y, string, length);
 #else
     XmbDrawString (dpy, id, f->font, gc, x, y, string, length);
 #endif
@@ -368,17 +368,17 @@
 }
 
 static int
-xft_measure (Lisp_Font *f, unsigned char *string, size_t length)
+xft_measure (Lisp_Font *f, char *string, size_t length)
 {
     XGlyphInfo info;
 
-    XftTextExtentsUtf8 (dpy, f->font, string, length, &info);
+    XftTextExtentsUtf8 (dpy, f->font, (FcChar8 *)string, length, &info);
 
     return info.xOff; 
 }
 
 static void
-xft_draw (Lisp_Font *f, unsigned char *string, size_t length,
+xft_draw (Lisp_Font *f, char *string, size_t length,
 	  Window id, GC gc, Lisp_Color *fg, int x, int y)
 {
     static XftDraw *draw;
@@ -397,7 +397,7 @@
     xft_color.color.alpha = fg->alpha;
 
     XftDrawStringUtf8 (draw, &xft_color, f->font,
-		    x, y, string, length);
+                       x, y, (FcChar8 *)string, length);
 }
 
 static const Lisp_Font_Class xft_class = {
@@ -485,14 +485,14 @@
 }
 
 static int
-pango_measure (Lisp_Font *f, unsigned char *string, size_t length)
+pango_measure (Lisp_Font *f, char *string, size_t length)
 {
     PangoLayout *layout;
     PangoRectangle rect;
 
     layout = pango_layout_new (pango_context);
     pango_layout_set_font_description(layout, f->font);
-    pango_layout_set_text (layout, (gpointer) string, length);
+    pango_layout_set_text (layout, string, length);
 
     pango_layout_get_extents (layout, NULL, &rect);
 
@@ -527,7 +527,7 @@
 }
 
 static void
-pango_draw (Lisp_Font *f, unsigned char *string, size_t length,
+pango_draw (Lisp_Font *f, char *string, size_t length,
 	    Window id, GC gc, Lisp_Color *fg, int x, int y)
 {
     static XftDraw *draw;
@@ -548,7 +548,7 @@
 
     layout = pango_layout_new (pango_context);
     pango_layout_set_font_description(layout, f->font);
-    pango_layout_set_text (layout, (gpointer) string, length);
+    pango_layout_set_text (layout, string, length);
     iter = pango_layout_get_iter (layout);
 
     do {
@@ -791,7 +791,7 @@
 }
 
 int
-x_text_width (repv font, unsigned char *string, size_t len)
+x_text_width (repv font, char *string, size_t len)
 {
     return (*VFONT (font)->class->measure) (VFONT (font), string, len);
 }
@@ -799,7 +799,7 @@
 /* The foreground pixel of GC is undefined after this function returns. */
 void
 x_draw_string (Window id, repv font, GC gc, Lisp_Color *fg_color,
-	       int x, int y, unsigned char *string, size_t len)
+	       int x, int y, char *string, size_t len)
 {
     (*VFONT (font)->class->draw) (VFONT (font), string, len,
 				  id, gc, fg_color, x, y);
@@ -817,7 +817,7 @@
     if (font == Qnil)
 	font = global_symbol_value (Qdefault_font);
     rep_DECLARE2(font, FONTP);
-    return rep_MAKE_INT (x_text_width (font, (gpointer) rep_STR(string),
+    return rep_MAKE_INT (x_text_width (font, rep_STR(string),
 				       rep_STRING_LEN(string)));
 }
 

Modified: trunk/src/frames.c
==============================================================================
--- trunk/src/frames.c	(original)
+++ trunk/src/frames.c	Sun Aug 31 13:15:40 2008
@@ -722,7 +722,7 @@
 		length = rep_STRING_LEN(result);
 	    }
 
-	    width = x_text_width (font, (gpointer) rep_STR(string), length);
+	    width = x_text_width (font, rep_STR(string), length);
 	    height = VFONT(font)->ascent + VFONT(font)->descent;
 	}
 
@@ -831,7 +831,7 @@
 
 	    x_draw_string (fp->id, font, fp->gc, VCOLOR(fg),
 			   x, y + VFONT(font)->ascent,
-			   (gpointer) rep_STR(string), length);
+                           rep_STR(string), length);
 
 	    fp->drawn.text = string;
 	}

Modified: trunk/src/functions.c
==============================================================================
--- trunk/src/functions.c	(original)
+++ trunk/src/functions.c	Sun Aug 31 13:15:40 2008
@@ -691,7 +691,7 @@
 	int i;
 
     case 8:
-	ret_data = rep_string_dupn ((gpointer) data, nitems);
+	ret_data = rep_string_dupn ((char *) data, nitems);
 	break;
 
     case 16:
@@ -778,7 +778,7 @@
 
     case 8:
 	if (rep_STRINGP(data))
-	    c_data = (gpointer) rep_STR (data);
+	    c_data = (unsigned char *) rep_STR (data);
 	else
 	{
 	    c_data = alloca (nitems);
@@ -1090,7 +1090,7 @@
 		offset = MSG_PAD_X;
 	    else
 	    {
-		int width = x_text_width (message.font, (gpointer) ptr, end - ptr);
+		int width = x_text_width (message.font, ptr, end - ptr);
 		if (message.justify == Qright)
 		    offset = message.width - (width + MSG_PAD_X);
 		else
@@ -1102,7 +1102,7 @@
 			   + row * (VFONT(message.font)->ascent
 				    + VFONT(message.font)->descent
 				    + message.spacing)
-			   + VFONT(message.font)->ascent, (gpointer) ptr, end - ptr);
+			   + VFONT(message.font)->ascent, ptr, end - ptr);
 	    row++;
 	    ptr = end;
 	    if (*ptr == '\n')
@@ -1223,7 +1223,7 @@
 		char *end = strchr (ptr, '\n');
 		if (end == 0)
 		  end = ptr + strlen (ptr);
-		text_width = x_text_width (message.font, (gpointer) ptr, end - ptr);
+		text_width = x_text_width (message.font, ptr, end - ptr);
 		max_width = MAX(max_width, text_width);
 		rows++;
 		ptr = end;

Modified: trunk/src/images.c
==============================================================================
--- trunk/src/images.c	(original)
+++ trunk/src/images.c	Sun Aug 31 13:15:40 2008
@@ -228,7 +228,8 @@
    Drawable d;
    Pixmap mask = 0;
    Window root;
-   int x, y, w, h, bdr, dp;
+   int x, y;
+   unsigned w, h, bdr, dp;
    image_t im;
 
    rep_DECLARE1 (id, rep_INTP);
@@ -236,7 +237,7 @@
    if (rep_INTP (mask_id))
        mask = rep_INT (mask_id);
 
-   if (!XGetGeometry (dpy, d, &root, &x, &y, (gpointer) &w, (gpointer) &h, (gpointer) &bdr, (gpointer) &dp))
+   if (!XGetGeometry (dpy, d, &root, &x, &y, &w, &h, &bdr, &dp))
        return Qnil;
 
 #if defined HAVE_IMLIB

Modified: trunk/src/keys.c
==============================================================================
--- trunk/src/keys.c	(original)
+++ trunk/src/keys.c	Sun Aug 31 13:15:40 2008
@@ -742,19 +742,19 @@
 /* Puts the integers defining the event described in DESC into CODE
    and MODS. */
 static bool
-lookup_event(unsigned long *code, unsigned long *mods, unsigned char *desc)
+lookup_event(unsigned long *code, unsigned long *mods, char *desc)
 {
     char *tem;
     char buf[100];
     *code = *mods = 0;
 
     /* First handle all modifiers */
-    while(*desc && (tem = strchr((gpointer) desc + 1, '-')) != 0)
+    while(*desc && (tem = strchr(desc + 1, '-')) != 0)
     {
 	struct key_def *x = default_mods;
 
-	memcpy(buf, desc, tem - (char *)desc);
-	buf[tem - (char *)desc] = 0;
+	memcpy(buf, desc, tem - desc);
+	buf[tem - desc] = 0;
 
 	while(x->name != 0)
 	{
@@ -777,7 +777,7 @@
 	unsigned int ks;
 	while(x->name != 0)
 	{
-	    if(strcasecmp((gpointer) desc, x->name) == 0)
+	    if(strcasecmp(desc, x->name) == 0)
 	    {
 		*mods |= x->mods;
 		*code = x->code;
@@ -793,7 +793,7 @@
 	    }
 	    x++;
 	}
-	ks = XStringToKeysym((gpointer) desc);
+	ks = XStringToKeysym(desc);
 	if(ks != NoSymbol)
 	{
 	    if (*mods & ShiftMask)
@@ -822,14 +822,16 @@
 
 /* Constructs the name of the event defined by CODE and MODS in BUF.  */
 static bool
-lookup_event_name(unsigned char *buf, unsigned long code, unsigned long mods)
+lookup_event_name(char *buf, unsigned long code, unsigned long mods)
 {
     int i;
     struct key_def *x;
     unsigned long type = mods & EV_TYPE_MASK;
+    char
+        *end = buf,
+        *tem;
 
-    char *end = (gpointer) buf, *tem;
-    *buf = 0;
+    *buf = '\0';
 
     mods &= EV_MOD_MASK;
     for(i = 32; i >= 0 && mods != 0; i--)	/* magic numbers!? */
@@ -878,8 +880,8 @@
 print_event_prefix(void)
 {
     int i;
-    unsigned char buf[256];
-    unsigned char *bufp = buf;
+    char buf[256];
+    char *bufp = buf;
 
     if (next_keymap_path == rep_NULL)
 	return FALSE;
@@ -891,7 +893,7 @@
     {
 	if (lookup_event_name (bufp, event_buf[i], event_buf[i+1]))
 	{
-	    bufp += strlen ((gpointer) bufp);
+	    bufp += strlen (bufp);
 	    *bufp++ = ' ';
 	}
     }
@@ -905,7 +907,7 @@
     }
 
     rep_call_lisp1 (global_symbol_value (Qdisplay_message),
-		    rep_string_dupn ((gpointer) buf, bufp - buf));
+		    rep_string_dupn (buf, bufp - buf));
     printed_this_prefix = TRUE;
 
     return TRUE;
@@ -949,7 +951,7 @@
 	args = rep_CDR(args);
 	if (rep_STRINGP(arg1))
 	{
-	    if (!lookup_event (&code, &mods, (gpointer) rep_STR(arg1)))
+	    if (!lookup_event (&code, &mods, rep_STR(arg1)))
 		return Fsignal (Qbad_event_desc, rep_LIST_1(arg1));
 	}
 	else if(Feventp(arg1) != Qnil)
@@ -996,7 +998,7 @@
 	arg1 = rep_CAR(args);
 	if (rep_STRINGP(arg1))
 	{
-	    if (!lookup_event (&code, &mods, (gpointer) rep_STR(arg1)))
+	    if (!lookup_event (&code, &mods, rep_STR(arg1)))
 		return Fsignal (Qbad_event_desc, rep_LIST_1(arg1));
 	}
 	else if(Feventp(arg1) != Qnil)
@@ -1066,16 +1068,16 @@
 ::end:: */
 {
     KeySym ks;
-    unsigned char buf[256];
+    char buf[256];
     int len;
 
     if(current_x_event == 0)
 	return Fsignal(Qerror, rep_LIST_1(rep_VAL(&not_in_handler)));
 
     len = XLookupString(&current_x_event->xkey,
-			 (gpointer) buf, sizeof (buf) - 1, &ks, NULL);
+                        buf, sizeof (buf) - 1, &ks, NULL);
     if(len > 0)
-	return rep_string_dupn((gpointer) buf, len);
+	return rep_string_dupn(buf, len);
     else
 	return rep_null_string();
 }
@@ -1172,14 +1174,14 @@
 Returns a string naming the event EVENT.
 ::end:: */
 {
-    unsigned char buf[256];
+    char buf[256];
     if(!EVENTP(ev))
 	return rep_signal_arg_error(ev, 1);
 
     if(lookup_event_name(buf, rep_INT(EVENT_CODE(ev)),
 			 rep_INT(EVENT_MODS(ev))))
     {
-	return rep_string_dup((gpointer) buf);
+	return rep_string_dup(buf);
     }
     else
 	return Qnil;
@@ -1195,7 +1197,7 @@
     unsigned long code, mods;
     rep_DECLARE1(name, rep_STRINGP);
 
-    if(lookup_event(&code, &mods, (gpointer) rep_STR(name)))
+    if(lookup_event(&code, &mods, rep_STR(name)))
 	return MAKE_EVENT(rep_MAKE_INT(code), rep_MAKE_INT(mods));
     else
 	return Qnil;

Modified: trunk/src/libclient.c
==============================================================================
--- trunk/src/libclient.c	(original)
+++ trunk/src/libclient.c	Sun Aug 31 13:15:40 2008
@@ -67,7 +67,7 @@
 static char *
 system_name(void)
 {
-    unsigned char buf[256];
+    char buf[256];
     struct hostent *h;
 
     static char *system_name;
@@ -75,7 +75,7 @@
 	return system_name;
 
 #ifdef HAVE_GETHOSTNAME
-    if(gethostname((gpointer) buf, 256))
+    if(gethostname(buf, 256))
 	return rep_NULL;
 #else
     {
@@ -84,7 +84,7 @@
 	strncpy(buf, uts.nodename, 256);
     }
 #endif
-    h = gethostbyname((gpointer) buf);
+    h = gethostbyname(buf);
     if(h)
     {
 	if(!strchr(h->h_name, '.'))
@@ -100,7 +100,7 @@
 	    system_name = strdup(h->h_name);
     }
     else
-	system_name = strdup((gpointer) buf);
+	system_name = strdup(buf);
     return system_name;
 }
 

Modified: trunk/src/sawmill_subrs.h
==============================================================================
--- trunk/src/sawmill_subrs.h	(original)
+++ trunk/src/sawmill_subrs.h	Sun Aug 31 13:15:40 2008
@@ -106,9 +106,9 @@
 /* from fonts.c */
 extern int font_type;
 extern repv Qdefault_font;
-extern int x_text_width (repv font, unsigned char *string, size_t len);
+extern int x_text_width (repv font, char *string, size_t len);
 extern void x_draw_string (Window id, repv font, GC gc, Lisp_Color *fg_color,
-			   int x, int y, unsigned char *string, size_t len);
+			   int x, int y, char *string, size_t len);
 extern repv Fget_font(repv name);
 extern repv Ffont_get(repv font, repv prop);
 extern repv Ffont_put(repv font, repv prop, repv value);

Modified: trunk/src/x.c
==============================================================================
--- trunk/src/x.c	(original)
+++ trunk/src/x.c	Sun Aug 31 13:15:40 2008
@@ -1023,12 +1023,12 @@
     Drawable id = drawable_from_arg (window);
     int x = 0;
     int y = 0;
-    unsigned char *str;
+    char *str;
 
     rep_DECLARE (1, window, id != 0);
     rep_DECLARE (2, gc, X_VALID_GCP (gc, id));
     rep_DECLARE (3, xy, rep_CONSP (xy)
-		 && rep_INTP (rep_CAR (xy)) && rep_INTP (rep_CDR (xy)));
+                 && rep_INTP (rep_CAR (xy)) && rep_INTP (rep_CDR (xy)));
     rep_DECLARE4 (string, rep_STRINGP);
     if (font == Qnil)
 	font = global_symbol_value (Qdefault_font);
@@ -1036,10 +1036,10 @@
 
     x = rep_INT (rep_CAR (xy));
     y = rep_INT (rep_CDR (xy));
-    str = (gpointer) rep_STR (string);
+    str = rep_STR (string);
 
     x_draw_string (id, font, VX_GC (gc)->gc,
-		   &VX_GC (gc)->fg_copy, x, y, str, strlen ((gpointer) str));
+                   &VX_GC (gc)->fg_copy, x, y, str, strlen (str));
     return Qt;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]