CVS commit: xsrc/external/mit/libXaw/dist/src

2021-05-09 Thread Christos Zoulas
Module Name:xsrc
Committed By:   christos
Date:   Sun May  9 16:58:57 UTC 2021

Modified Files:
xsrc/external/mit/libXaw/dist/src: TextAction.c

Log Message:
fix casts and types to make it compile with clang


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.7 -r1.2 xsrc/external/mit/libXaw/dist/src/TextAction.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/libXaw/dist/src/TextAction.c
diff -u xsrc/external/mit/libXaw/dist/src/TextAction.c:1.1.1.7 xsrc/external/mit/libXaw/dist/src/TextAction.c:1.2
--- xsrc/external/mit/libXaw/dist/src/TextAction.c:1.1.1.7	Mon Apr 26 17:23:18 2021
+++ xsrc/external/mit/libXaw/dist/src/TextAction.c	Sun May  9 12:58:57 2021
@@ -89,7 +89,7 @@ static Bool GetBlockBoundaries(TextWidge
 static int FormRegion(TextWidget, XawTextPosition, XawTextPosition,
 		  XawTextPosition*, int);
 static void GetSelection(Widget, Time, String*, Cardinal);
-static char *IfHexConvertHexElseReturnParam(char*, int*);
+static char *IfHexConvertHexElseReturnParam(const char*, int*);
 static void InsertNewCRs(TextWidget, XawTextPosition, XawTextPosition,
 			 XawTextPosition*, int);
 static int InsertNewLineAndBackupInternal(TextWidget);
@@ -421,7 +421,7 @@ _SelectionReceived(Widget w, XtPointer c
 	fprintf(stderr, "Xaw Text Widget: An attempt was made to insert "
 		"an illegal selection.\n");
 
-	textprop.value = (const unsigned char *)" >> ILLEGAL SELECTION << ";
+	textprop.value = (unsigned char *)" >> ILLEGAL SELECTION << ";
 	textprop.nitems = strlen((char *) textprop.value);
 	if (XwcTextPropertyToTextList(d, , , )
 		!=  Success
@@ -3215,9 +3215,9 @@ InsertChar(Widget w, XEvent *event, Stri
  *
  * NOTE:In neither case will there be strings to free. */
 static char *
-IfHexConvertHexElseReturnParam(char *param, int *len_return)
+IfHexConvertHexElseReturnParam(const char *param, int *len_return)
 {
-char *p;		/* steps through param char by char */
+const char *p;	/* steps through param char by char */
 char c;		/* holds the character pointed to by p */
 int ind;		/* steps through hexval buffer char by char */
 static char hexval[XawTextActionMaxHexChars];
@@ -3225,8 +3225,7 @@ IfHexConvertHexElseReturnParam(char *par
 
 /* reject if it doesn't begin with 0x and at least one more character. */
 if ((param[0] != '0') || (param[1] != 'x') || (param[2] == '\0')) {
-	*len_return = (int)strlen(param);
-	return(param);
+	goto out;
 }
 
 /* Skip the 0x; go character by character shifting and adding. */
@@ -3253,8 +3252,7 @@ IfHexConvertHexElseReturnParam(char *par
 	if (++ind < XawTextActionMaxHexChars)
 		hexval[ind] = '\0';
 	else {
-		*len_return = (int)strlen(param);
-		return(param);
+		goto out;
 	}
 	}
 }
@@ -3266,9 +3264,9 @@ IfHexConvertHexElseReturnParam(char *par
 }
 
 /* Else, there were non-hex chars or odd digit count, so... */
-
+out:
 *len_return = (int)strlen(param);
-return (param);			   /* ...return the verbatim string. */
+return ((char *)param);			   /* ...return the verbatim string. */
 }
 
 /* InsertString() - action
@@ -3370,7 +3368,7 @@ DisplayCaret(Widget w, XEvent *event, St
 
 if (*num_params > 0) {	/* default arg is "True" */
 	XrmValue from, to;
-	from.size = (unsigned)strlen(from.addr = params[0]);
+	from.size = (unsigned)strlen(from.addr = (char *)params[0]);
 	XtConvert(w, XtRString, , XtRBoolean, );
 
 	if (to.addr != NULL)



CVS commit: xsrc/external/mit/libXaw/dist/src

2021-05-09 Thread Christos Zoulas
Module Name:xsrc
Committed By:   christos
Date:   Sun May  9 16:58:19 UTC 2021

Modified Files:
xsrc/external/mit/libXaw/dist/src: Pixmap.c

Log Message:
make this compile again under clang:
- factor out duplicated code
- add casts
- plug memory leak


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.6 -r1.2 xsrc/external/mit/libXaw/dist/src/Pixmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/libXaw/dist/src/Pixmap.c
diff -u xsrc/external/mit/libXaw/dist/src/Pixmap.c:1.1.1.6 xsrc/external/mit/libXaw/dist/src/Pixmap.c:1.2
--- xsrc/external/mit/libXaw/dist/src/Pixmap.c:1.1.1.6	Mon Apr 26 17:23:18 2021
+++ xsrc/external/mit/libXaw/dist/src/Pixmap.c	Sun May  9 12:58:19 2021
@@ -699,6 +699,27 @@ GetResourcePixmapPath(Display *display)
 	pixmap_path = default_path;
 }
 
+static const char *
+GetFileName(XawParams *params, Screen *screen)
+{
+  static SubstitutionRec sub[] = {
+{'H',   NULL},
+{'N',   NULL},
+{'T',   "pixmaps"},
+{'P',   PROJECT_ROOT},
+  };
+  if (params->name[0] != '/' && params->name[0] != '.')
+{
+  if (!sub[0].substitution)
+	sub[0].substitution = getenv("HOME");
+  sub[1].substitution = (char *)params->name;
+  if (pixmap_path == NULL)
+	GetResourcePixmapPath(DisplayOfScreen(screen));
+  return XtFindFile(pixmap_path, sub, XtNumber(sub), NULL);
+}
+   return params->name;
+}
+
 static Bool
 BitmapLoader(XawParams *params, Screen *screen, Colormap colormap, int depth,
 	 Pixmap *pixmap_return, Pixmap *mask_return,
@@ -712,13 +733,7 @@ BitmapLoader(XawParams *params, Screen *
   int hotX, hotY;
   XawArgVal *argval;
   Bool retval = False;
-  static SubstitutionRec sub[] = {
-{'H',   NULL},
-{'N',   NULL},
-{'T',   "bitmaps"},
-{'P',   PROJECT_ROOT},
-  };
-  char *filename;
+  const char *filename;
 
   fg = BlackPixelOfScreen(screen);
   bg = WhitePixelOfScreen(screen);
@@ -742,19 +757,9 @@ BitmapLoader(XawParams *params, Screen *
 	return (False);
 }
 
-  if (params->name[0] != '/' && params->name[0] != '.')
-{
-  if (!sub[0].substitution)
-	sub[0].substitution = getenv("HOME");
-  sub[1].substitution = params->name;
-  if (pixmap_path == NULL)
-	GetResourcePixmapPath(DisplayOfScreen(screen));
-  filename = XtFindFile(pixmap_path, sub, XtNumber(sub), NULL);
-  if (!filename)
-	return (FALSE);
-}
-  else
-filename = params->name;
+  filename = GetFileName(params, screen);
+  if (!filename)
+return (FALSE);
 
   if (XReadBitmapFileData(filename, , , ,
 			  , ) == BitmapSuccess)
@@ -774,7 +779,7 @@ BitmapLoader(XawParams *params, Screen *
 }
 
   if (filename != params->name)
-XtFree(filename);
+XtFree((char *)filename);
 
   return (retval);
 }
@@ -827,7 +832,7 @@ GradientLoader(XawParams *params, Screen
 
   value = NULL;
   if ((argval = XawFindArgVal(params, "start")) != NULL)
-value = argval->value;
+value = (char *)argval->value;
   if (value && !XAllocNamedColor(DisplayOfScreen(screen), colormap, value,
 			, ))
 return (False);
@@ -838,7 +843,7 @@ GradientLoader(XawParams *params, Screen
 }
   value = NULL;
   if ((argval = XawFindArgVal(params, "end")) != NULL)
-value = argval->value;
+value = (char *)argval->value;
   if (value && !XAllocNamedColor(DisplayOfScreen(screen), colormap, value,
 			, ))
 return (False);
@@ -932,31 +937,16 @@ XPixmapLoader(XawParams *params, Screen 
   XpmAttributes xpm_attributes;
   XawArgVal *argval;
   unsigned int closeness = 4000;
-  static SubstitutionRec sub[] = {
-{'H',   NULL},
-{'N',   NULL},
-{'T',   "pixmaps"},
-{'P',   PROJECT_ROOT},
-  };
+  Bool retval = False;
   const char *filename;
 
   if ((argval = XawFindArgVal(params, "closeness")) != NULL
   && argval->value)
 closeness = (unsigned)atoi(argval->value);
 
-  if (params->name[0] != '/' && params->name[0] != '.')
-{
-  if (!sub[0].substitution)
-	sub[0].substitution = getenv("HOME");
-  sub[1].substitution = params->name;
-  if (pixmap_path == NULL)
-	GetResourcePixmapPath(DisplayOfScreen(screen));
-  filename = XtFindFile(pixmap_path, sub, XtNumber(sub), NULL);
-  if (!filename)
-	return (False);
-}
-  else
-filename = params->name;
+  filename = GetFileName(params, screen);
+  if (!filename)
+return (FALSE);
 
   xpm_attributes.colormap = colormap;
   xpm_attributes.closeness = closeness;
@@ -968,10 +958,12 @@ XPixmapLoader(XawParams *params, Screen 
   *width_return = (Dimension)xpm_attributes.width;
   *height_return = (Dimension)xpm_attributes.height;
 
-  return (True);
+  retval = True;
 }
 
-  return (False);
+  if (filename != params->name)
+XtFree((char *)filename);
+  return (retval);
 }
 
 void