Merge branch 'v4.7.x' into master
authorArun Persaud <arun@nubati.net>
Wed, 10 Sep 2014 03:15:45 +0000 (20:15 -0700)
committerArun Persaud <arun@nubati.net>
Wed, 10 Sep 2014 03:18:18 +0000 (20:18 -0700)
Conflicts:
configure.ac
po/da.po
po/de.po
po/es.po
po/it.po
po/ru.po
po/tr.po
po/uk.po
po/vi.po
po/xboard.pot
po/zh_CN.po
po/zh_HK.po
po/zh_TW.po
winboard/config.h

1  2 
xaw/xboard.c

diff --combined xaw/xboard.c
@@@ -183,6 -183,13 +183,6 @@@ extern char *getenv()
  // [HGM] bitmaps: put before incuding the bitmaps / pixmaps, to know how many piece types there are.
  #include "common.h"
  
 -#if HAVE_LIBXPM
 -#include <X11/xpm.h>
 -#define IMAGE_EXT "xpm"
 -#else
 -#define IMAGE_EXT "xim"
 -#endif
 -
  #include "bitmaps/icon_white.bm"
  #include "bitmaps/icon_black.bm"
  #include "bitmaps/checkmark.bm"
  #include "draw.h"
  
  #define SLASH '/'
+ #define DATADIR "~~"
  
  #ifdef __EMX__
  #ifndef HAVE_USLEEP
@@@ -423,6 -431,128 +424,6 @@@ String xboardResources[] = 
  /* Max possible square size */
  #define MAXSQSIZE 256
  
 -static int xpm_avail[MAXSQSIZE];
 -
 -#ifdef HAVE_DIR_STRUCT
 -
 -/* Extract piece size from filename */
 -static int
 -xpm_getsize (char *name, int len, char *ext)
 -{
 -    char *p, *d;
 -    char buf[10];
 -
 -    if (len < 4)
 -      return 0;
 -
 -    if ((p=strchr(name, '.')) == NULL ||
 -      StrCaseCmp(p+1, ext) != 0)
 -      return 0;
 -
 -    p = name + 3;
 -    d = buf;
 -
 -    while (*p && isdigit(*p))
 -      *(d++) = *(p++);
 -
 -    *d = 0;
 -    return atoi(buf);
 -}
 -
 -/* Setup xpm_avail */
 -static int
 -xpm_getavail (char *dirname, char *ext)
 -{
 -    DIR *dir;
 -    struct dirent *ent;
 -    int  i;
 -
 -    for (i=0; i<MAXSQSIZE; ++i)
 -      xpm_avail[i] = 0;
 -
 -    if (appData.debugMode)
 -      fprintf(stderr, "XPM dir:%s:ext:%s:\n", dirname, ext);
 -
 -    dir = opendir(dirname);
 -    if (!dir)
 -      {
 -        fprintf(stderr, _("%s: Can't access XPM directory %s\n"),
 -                programName, dirname);
 -        exit(1);
 -      }
 -
 -    while ((ent=readdir(dir)) != NULL) {
 -      i = xpm_getsize(ent->d_name, NAMLEN(ent), ext);
 -      if (i > 0 && i < MAXSQSIZE)
 -        xpm_avail[i] = 1;
 -    }
 -
 -    closedir(dir);
 -
 -    return 0;
 -}
 -
 -void
 -xpm_print_avail (FILE *fp, char *ext)
 -{
 -    int i;
 -
 -    fprintf(fp, _("Available `%s' sizes:\n"), ext);
 -    for (i=1; i<MAXSQSIZE; ++i) {
 -      if (xpm_avail[i])
 -        printf("%d\n", i);
 -    }
 -}
 -
 -/* Return XPM piecesize closest to size */
 -int
 -xpm_closest_to (char *dirname, int size, char *ext)
 -{
 -    int i;
 -    int sm_diff = MAXSQSIZE;
 -    int sm_index = 0;
 -    int diff;
 -
 -    xpm_getavail(dirname, ext);
 -
 -    if (appData.debugMode)
 -      xpm_print_avail(stderr, ext);
 -
 -    for (i=1; i<MAXSQSIZE; ++i) {
 -      if (xpm_avail[i]) {
 -          diff = size - i;
 -          diff = (diff<0) ? -diff : diff;
 -          if (diff < sm_diff) {
 -              sm_diff = diff;
 -              sm_index = i;
 -          }
 -      }
 -    }
 -
 -    if (!sm_index) {
 -      fprintf(stderr, _("Error: No `%s' files!\n"), ext);
 -      exit(1);
 -    }
 -
 -    return sm_index;
 -}
 -#else /* !HAVE_DIR_STRUCT */
 -/* If we are on a system without a DIR struct, we can't
 -   read the directory, so we can't collect a list of
 -   filenames, etc., so we can't do any size-fitting. */
 -int
 -xpm_closest_to (char *dirname, int size, char *ext)
 -{
 -    fprintf(stderr, _("\
 -Warning: No DIR structure found on this system --\n\
 -         Unable to autosize for XPM/XIM pieces.\n\
 -   Please report this error to %s.\n\
 -   Include system type & operating system in message.\n"), PACKAGE_BUGREPORT););
 -    return size;
 -}
 -#endif /* HAVE_DIR_STRUCT */
 -
 -
  /* Arrange to catch delete-window events */
  Atom wm_delete_window;
  void
@@@ -496,8 -626,7 +497,8 @@@ ParseFont (char *name, int number
    if(sscanf(name, "size%d:", &size)) {
      // [HGM] font: font is meant for specific boardSize (likely from settings file);
      //       defer processing it until we know if it matches our board size
 -    if(size >= 0 && size<MAX_SIZE) { // for now, fixed limit
 +    if(strstr(name, "-*-") &&        // only pay attention to things that look like X-fonts
 +       size >= 0 && size<MAX_SIZE) { // for now, fixed limit
        fontTable[number][size] = strdup(strchr(name, ':')+1);
        fontValid[number][size] = True;
      }
@@@ -538,12 -667,6 +539,12 @@@ ParseColor (int n, char *name
    if(colorVariable[n]) *(char**)colorVariable[n] = strdup(name);
  }
  
 +char *
 +Col2Text (int n)
 +{
 +    return *(char**)colorVariable[n];
 +}
 +
  void
  ParseTextAttribs (ColorClass cc, char *s)
  {
@@@ -646,12 -769,6 +647,12 @@@ GetActualPlacement (Widget wg, WindowPl
  }
  
  void
 +GetPlacement (DialogClass dlg, WindowPlacement *wp)
 +{ // wrapper to shield back-end from widget type
 +  if(shellUp[dlg]) GetActualPlacement(shells[dlg], wp);
 +}
 +
 +void
  GetWindowCoords ()
  { // wrapper to shield use of window handles from back-end (make addressible by number?)
    // In XBoard this will have to wait until awareness of window parameters is implemented
@@@ -833,8 -950,6 +834,8 @@@ PrintArg (ArgType t
      case ArgTwo:
      case ArgNone:
      case ArgCommSettings:
 +    case ArgMaster:
 +    case ArgInstall:
        break;
    }
    return p;
@@@ -844,18 -959,17 +845,18 @@@ char 
  GenerateGlobalTranslationTable (void)
  {
    /* go through all menu items and extract the keyboard shortcuts, so that X11 can load them */
 -  char *output;
 +  char *output[2];
  
 -  int i,j;
 +  int i,j,n=0;
    MenuItem *mi;
  
 -  output = strdup("");
 +  output[0] = strdup(""); // build keystrokes with and wo mod keys separately
 +  output[1] = strdup(""); // so the more specific can preceed the other
  
    /* loop over all menu entries */
 -  for( i=0; menuBar[i].mi ; i++)
 +  for( i=0; menuBar[i-n].mi || !n++; i++)
      {
 -      mi = menuBar[i].mi;
 +      mi = menuBar[i+n].mi; // kludge to access 'noMenu' behind sentinel
        for(j=0; mi[j].proc; j++)
        {
          if (mi[j].accel)
                mods[strlen(mods)-1]='\0';
  
              /* get the name for the callback, we can use MenuItem() here that will call KeyBindingProc */
 -            size_t namesize = snprintf(NULL, 0, "%s.%s", menuBar[i].ref, mi[j].ref);
 -            char *name = malloc(namesize+1);
 -            snprintf(name, namesize+1, "%s.%s", menuBar[i].ref, mi[j].ref);
 +            char *name = malloc(MSG_SIZ);
 +            if(n) snprintf(name, MSG_SIZ, "%s", mi[j].ref);
 +            else  snprintf(name, MSG_SIZ, "%s.%s", menuBar[i].ref, mi[j].ref);
  
 -            size_t buffersize = snprintf(NULL, 0, ":%s<Key>%s: MenuItem(%s) \n ", mods, key, name);
 -            char *buffer = malloc(buffersize+1);
 -            snprintf(buffer, buffersize+1, ":%s<Key>%s: MenuItem(%s) \n ", mods, key, name);
 +            char *buffer = malloc(MSG_SIZ);
 +            snprintf(buffer, MSG_SIZ, ":%s<Key>%s: MenuItem(%s) \n ", mods, key, name);
  
              /* add string to the output */
 -            output = realloc(output, strlen(output) + strlen(buffer)+1);
 -            strncat(output, buffer, strlen(buffer));
 +            output[shift|alt|ctrl] = realloc(output[shift|alt|ctrl], strlen(output[shift|alt|ctrl]) + strlen(buffer)+1);
 +            strncat(output[shift|alt|ctrl], buffer, strlen(buffer));
  
              /* clean up */
              free(key);
            }
        }
      }
 -  return output;
 +  output[1] = realloc(output[1], strlen(output[1]) + strlen(output[0])+1);
 +  strncat(output[1], output[0], strlen(output[0]));
 +  free(output[0]);
 +  return output[1];
  }
  
  
@@@ -990,9 -1102,6 +991,9 @@@ main (int argc, char **argv
      char *p;
      int forceMono = False;
  
 +    extern Option chatOptions[]; // FIXME: adapt Chat window, removing ICS pane and Hide button
 +    chatOptions[6].type = chatOptions[10].type = Skip;
 +
      srandom(time(0)); // [HGM] book: make random truly random
  
      setbuf(stdout, NULL);
      debugFP = stderr;
  
      if(argc > 1 && (!strcmp(argv[1], "-v" ) || !strcmp(argv[1], "--version" ))) {
 -      printf("%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION);
 +      printf("%s version %s\n\n  configure options: %s\n", PACKAGE_NAME, PACKAGE_VERSION, CONFIGURE_OPTIONS);
        exit(0);
      }
  
        exit(0);
      }
  
 +    if(argc > 1 && !strcmp(argv[1], "--show-config")) { // [HGM] install: called to print config info
 +      typedef struct {char *name, *value; } Config;
 +      static Config configList[] = {
 +        { "Datadir", DATADIR },
 +        { "Sysconfdir", SYSCONFDIR },
 +        { NULL }
 +      };
 +      int i;
 +
 +      for(i=0; configList[i].name; i++) {
 +          if(argc > 2 && strcmp(argv[2], configList[i].name)) continue;
 +          if(argc > 2) printf("%s", configList[i].value);
 +          else printf("%-12s: %s\n", configList[i].name, configList[i].value);
 +      }
 +      exit(0);
 +    }
 +
      programName = strrchr(argv[0], '/');
      if (programName == NULL)
        programName = argv[0];
                    programName, appData.boardSize);
            exit(2);
        }
 +      if(BOARD_WIDTH > 8)
 +          squareSize = (squareSize*8 + BOARD_WIDTH/2)/BOARD_WIDTH; // scale height
        if (i < 7) {
            /* Find some defaults; use the nearest known size */
            SizeDefaults *szd, *nearest;
      } else {
          SizeDefaults *szd = sizeDefaults;
          if (*appData.boardSize == NULLCHAR) {
 -          while (DisplayWidth(xDisplay, xScreen) < szd->minScreenSize ||
 -                 DisplayHeight(xDisplay, xScreen) < szd->minScreenSize) {
 +          while (DisplayWidth(xDisplay, xScreen)  < (szd->minScreenSize*BOARD_WIDTH  + 4)/8 ||
 +                 DisplayHeight(xDisplay, xScreen) < (szd->minScreenSize*BOARD_HEIGHT + 4)/8) {
              szd++;
            }
            if (szd->name == NULL) szd--;
        EngineOutputPopUp();
      }
  
 +    gameInfo.boardWidth = 0; // [HGM] pieces: kludge to ensure InitPosition() calls InitDrawingSizes()
 +    InitPosition(TRUE);
 +
      InitBackEnd2();
  
      if (errorExitStatus == -1) {
        }
      }
  
 -    gameInfo.boardWidth = 0; // [HGM] pieces: kludge to ensure InitPosition() calls InitDrawingSizes()
 -    InitPosition(TRUE);
      UpdateLogos(TRUE);
  //    XtSetKeyboardFocus(shellWidget, formWidget);
      XSetInputFocus(xDisplay, XtWindow(formWidget), RevertToPointerRoot, CurrentTime);
      return 0;
  }
  
 +void
 +DoEvents ()
 +{
 +    XtInputMask m;
 +    while((m = XtAppPending(appContext))) XtAppProcessEvent(appContext, m);
 +}
 +
  RETSIGTYPE
  TermSizeSigHandler (int sig)
  {