(void) sprintf(error_buf, "MenuButton: %s %s.", "Could not find menu widget named", mbw->menu_button.menu_name); XtAppWarning(XtWidgetToApplicationContext(w), error_buf);
char *err1 = "MenuButton: Could not find menu widget named "; char *perr; int len;  len = strlen(err1) + strlen(mbw->menu_button.menu_name) + 1 + 1; perr = XtStackAlloc(len, error_buf); if (perr == NULL) return; sprintf(perr, "%s%s.", err1, mbw->menu_button.menu_name); XtAppWarning(XtWidgetToApplicationContext(w), perr); XtStackFree(perr, error_buf);
PopupMenu(w, event, params, num_params)Widget w;XEvent * event;String * params;Cardinal * num_params;{  MenuButtonWidget mbw = (MenuButtonWidget) w;  Widget menu, temp;  Arg arglist[2];  Cardinal num_args;  int menu_x, menu_y, menu_width, menu_height, button_height;  Position button_x, button_y;  temp = w;  while(temp != NULL) {    menu = XtNameToWidget(temp, mbw->menu_button.menu_name);    if (menu == NULL)       temp = XtParent(temp);    else      break;  }  if (menu == NULL) {    char error_buf[BUFSIZ];    (void) sprintf(error_buf, "MenuButton: %s %s.",	    "Could not find menu widget named", mbw->menu_button.menu_name);    XtAppWarning(XtWidgetToApplicationContext(w), error_buf);    return;  }  if (!XtIsRealized(menu))    XtRealizeWidget(menu);    menu_width = menu->core.width + 2 * menu->core.border_width;  button_height = w->core.height + 2 * w->core.border_width;  menu_height = menu->core.height + 2 * menu->core.border_width;  XtTranslateCoords(w, 0, 0, &button_x, &button_y);  menu_x = button_x;  menu_y = button_y + button_height;  if (menu_x >= 0) {    int scr_width = WidthOfScreen(XtScreen(menu));    if (menu_x + menu_width > scr_width)      menu_x = scr_width - menu_width;  }  if (menu_x < 0)     menu_x = 0;  if (menu_y >= 0) {    int scr_height = HeightOfScreen(XtScreen(menu));    if (menu_y + menu_height > scr_height)      menu_y = scr_height - menu_height;  }  if (menu_y < 0)    menu_y = 0;  num_args = 0;  XtSetArg(arglist[num_args], XtNx, menu_x); num_args++;  XtSetArg(arglist[num_args], XtNy, menu_y); num_args++;  XtSetValues(menu, arglist, num_args);  XtPopupSpringLoaded(menu);}