(void) sprintf( msg, "'%s' with '%s'. ***", find.ptr, replace.ptr);
char *pmsg; int len; char *msg1 = "' with '"; char *msg2 = "'. ***";  len = 1 + strlen(msg1) + strlen(msg2) + strlen(find.ptr) + strlen(replace.ptr) + 1; pmsg = XtStackAlloc(len, msg); if (pmsg != NULL) { (void) sprintf( pmsg, "`%s%s%s%s", find.ptr, msg1, replace.ptr, msg2); } else { pmsg = msg; (void) sprintf(pmsg, "string ***"); }
Replace(search, once_only, show_current)struct SearchAndReplace * search;Boolean once_only, show_current;{  XawTextPosition pos, new_pos, end_pos;  XawTextScanDirection dir;  XawTextBlock find, replace;  Widget tw = XtParent(search->search_popup);  int count = 0;  TextWidget ctx = (TextWidget)tw;  find.ptr = GetStringRaw( search->search_text);  if ((find.format = _XawTextFormat(ctx)) == XawFmtWide)      find.length = wcslen((wchar_t*)find.ptr);  else      find.length = strlen(find.ptr);  find.firstPos = 0;  replace.ptr = GetStringRaw(search->rep_text);  replace.firstPos = 0;  if ((replace.format = _XawTextFormat(ctx)) == XawFmtWide)      replace.length = wcslen((wchar_t*)replace.ptr);  else      replace.length = strlen(replace.ptr);      dir = (XawTextScanDirection)(long) ((XPointer)XawToggleGetCurrent(search->left_toggle) -				R_OFFSET);  /* CONSTCOND */  while (TRUE) {    if (count != 0) {      new_pos = XawTextSearch( tw, dir, &find);            if ( (new_pos == XawTextSearchError) ) {	if (count == 0) {	  char msg[BUFSIZ];             /* The Raw string in find.ptr may be WC I can't use here, 		so I call GetString to get a tame version.*/	  (void) sprintf( msg, "%s %s %s", "*** Error: Could not find string ``",		  GetString( search->search_text ), "''. ***");	  SetSearchLabels(search, msg, "", TRUE);	  return(FALSE);	}	else	  break;      }      pos = new_pos;      end_pos = pos + find.length;    }    else {      XawTextGetSelectionPos(tw, &pos, &end_pos);      if (search->selection_changed) {	SetSearchLabels(search, "Selection has been modified, aborting.",			"", TRUE);	return(FALSE);      }      if (pos == end_pos) 	  return(FALSE);    }    if (XawTextReplace(tw, pos, end_pos, &replace) != XawEditDone) {      char msg[BUFSIZ];            (void) sprintf( msg, "'%s' with '%s'. ***", find.ptr, replace.ptr);      SetSearchLabels(search, "*** Error while replacing", msg, TRUE);      return(FALSE);    }          if (dir == XawsdRight)      XawTextSetInsertionPoint( tw, pos + replace.length);    else      XawTextSetInsertionPoint( tw, pos);    if (once_only)       if (show_current)	break;      else {	DoSearch(search);	return(TRUE);      }    count++;  }  if (replace.length == 0)    XawTextUnsetSelection(tw);  else    XawTextSetSelection( tw, pos, pos + replace.length);  return(TRUE);}