Changeset 1679

Show
Ignore:
Timestamp:
02/17/98 01:45:17 (11 years ago)
Author:
himi
Message:

Emacs 20.3.5 FSF import

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/GNU/src/w16select.c

    r1651 r1679  
    7878/* The segment address and the size of the buffer in low 
    7979   memory used to move data between us and WinOldAp module.  */ 
     80 
    8081static struct { 
    8182  unsigned long size; 
    8283  unsigned short rm_segment; 
    8384} clipboard_xfer_buf_info; 
    84  
    85 /* The last text we put into the clipboard.  This is used to prevent 
    86    passing back our own text from the clipboard, instead of using the 
    87    kill ring.  The former is undesirable because the clipboard data 
    88    could be MULEtilated by inappropriately chosen 
    89    (next-)selection-coding-system.  For this reason, we must store the 
    90    text *after* it was encoded/Unix-to-DOS-converted.  */ 
    91 static unsigned char *last_clipboard_text; 
    92  
    93 /* The size of allocated storage for storing the clipboard data.  */ 
    94 static size_t clipboard_storage_size; 
    9585  
    9686/* Emulation of `__dpmi_int' and friends for DJGPP v1.x  */ 
     
    274264  /* Move the buffer into the low memory, convert LF into CR-LF if needed.  */ 
    275265  if (Raw) 
    276     { 
    277       dosmemput (Data, Size, xbuf_addr); 
    278  
    279       /* Terminate with a null, otherwise Windows does strange things 
    280          when the text size is an integral multiple of 32 bytes. */ 
    281       _farpokeb (_dos_ds, xbuf_addr + Size, '\0'); 
    282     } 
     266    dosmemput (Data, truelen, __tb); 
    283267  else 
    284268    { 
     
    296280          _farnspokeb (buf_offset++, *dp++); 
    297281        } 
    298  
    299       /* Terminate with a null, otherwise Windows does strange things 
    300          when the text size is an integral multiple of 32 bytes. */ 
    301       _farnspokeb (buf_offset, '\0'); 
    302     } 
    303  
    304   /* Stash away the data we are about to put into the clipboard, so we 
    305      could later check inside get_clipboard_data whether the clipboard 
    306      still holds our data.  */ 
    307   if (clipboard_storage_size < truelen) 
    308     { 
    309       clipboard_storage_size = truelen + 100; 
    310       last_clipboard_text = 
    311         (char *) xrealloc (last_clipboard_text, clipboard_storage_size); 
    312     } 
    313   if (last_clipboard_text) 
    314     dosmemget (xbuf_addr, truelen, last_clipboard_text); 
     282    } 
     283 
     284  /* Terminate with a null, otherwise Windows does strange things when 
     285     the text size is an integral multiple of 32 bytes. */ 
     286  _farnspokeb (buf_offset, *dp); 
    315287 
    316288  /* Calls Int 2Fh/AX=1703h with: 
     
    330302  free_xfer_buf (); 
    331303 
    332   /* If the above failed, invalidate the local copy of the clipboard.  */ 
    333   if (regs.x.ax == 0) 
    334     *last_clipboard_text = '\0'; 
    335  
    336304  /* Zero means success, otherwise (1 or 2) it's an error.  */ 
    337305  return regs.x.ax > 0 ? 0 : 1; 
     
    370338  unsigned long xbuf_addr; 
    371339  unsigned char *dp = Data; 
     340  /* The last 32-byte aligned block of data.  See commentary below.  */ 
     341  unsigned char *last_block = dp + ((Size & 0x1f) 
     342                                    ? (Size & 0x20) 
     343                                    : Size - 0x20); 
    372344 
    373345  if (Format != CF_OEMTEXT) 
     
    393365  if (regs.x.ax != 0) 
    394366    { 
    395       unsigned char null_char = '\0'; 
    396       unsigned long xbuf_beg = xbuf_addr; 
    397  
    398       /* If last_clipboard_text is NULL, we don't want to slow down 
    399          the next loop by an additional test.  */ 
    400       register unsigned char *lcdp = 
    401         last_clipboard_text == NULL ? &null_char : last_clipboard_text; 
    402          
    403367      /* Copy data from low memory, remove CR 
    404368         characters before LF if needed.  */ 
     
    408372          register unsigned char c = _farnspeekb (xbuf_addr++); 
    409373 
    410           if (*lcdp == c) 
    411             lcdp++; 
    412  
    413374          if ((*dp++ = c) == '\r' && !Raw && _farnspeekb (xbuf_addr) == '\n') 
    414375            { 
     
    416377              *dp++ = '\n'; 
    417378              xbuf_addr++; 
    418               if (*lcdp == '\n') 
    419                 lcdp++; 
     379              last_block--;     /* adjust the beginning of the last 32 bytes */ 
    420380            } 
    421381          /* Windows reportedly rounds up the size of clipboard data 
    422              (passed in SIZE) to a multiple of 32, and removes trailing 
    423              spaces from each line without updating SIZE.  We therefor
    424              bail out when we see the first null character.  */ 
    425           else if (c == '\0'
     382             (passed in SIZE) to a multiple of 32.  We therefore bail 
     383             out when we see the first null character in the last 32-byt
     384             block.  */ 
     385          else if (c == '\0' && dp > last_block
    426386            break; 
    427387        } 
    428  
    429       /* If the text in clipboard is identical to what we put there 
    430          last time set_clipboard_data was called, pretend there's no 
    431          data in the clipboard.  This is so we don't pass our own text 
    432          from the clipboard (which might be troublesome if the killed 
    433          text includes null characters).  */ 
    434       if (last_clipboard_text && 
    435           xbuf_addr - xbuf_beg == (long)(lcdp - last_clipboard_text)) 
    436         dp = (unsigned char *)Data + 1; 
    437388    } 
    438389 
     
    539490      encode_coding (&coding, src, dst, nbytes, bufsize); 
    540491      no_crlf_conversion = 1; 
    541       nbytes = coding.produced; 
    542       src = dst; 
    543492    } 
    544493 
  • branches/GNU/src/w32.c

    r1651 r1679  
    640640 
    641641void 
    642 init_environment (char ** argv
     642init_environment (
    643643{ 
    644644  int len; 
     
    759759  { 
    760760    char *p; 
    761     static char modname[MAX_PATH]; 
     761    char modname[MAX_PATH]; 
    762762 
    763763    if (!GetModuleFileName (NULL, modname, MAX_PATH)) 
     
    768768 
    769769    SetCurrentDirectory (modname); 
    770  
    771     /* Ensure argv[0] has the full path to Emacs.  */ 
    772     *p = '\\'; 
    773     argv[0] = modname; 
    774770  } 
    775771 
  • branches/GNU/src/w32console.c

    r1663 r1679  
    7777#endif 
    7878 
    79 /* Determine whether to make frame dimensions match the screen buffer, 
    80    or the current window size.  The former is desirable when running 
    81    over telnet, while the latter is more useful when working directly at 
    82    the console with a large scroll-back buffer.  */ 
    83 int w32_use_full_screen_buffer; 
    84  
    8579 
    8680/* Setting this as the ctrl handler prevents emacs from being killed when 
     
    130124  COORD      dest; 
    131125  int        n, r; 
    132   CONSOLE_SCREEN_BUFFER_INFO info; 
    133  
    134   GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &info); 
    135126 
    136127  hl_mode (0); 
    137128   
    138   /* Remember that the screen buffer might be wider than the window.  */ 
    139   n = FRAME_HEIGHT (f) * info.dwSize.X; 
     129  n = FRAME_HEIGHT (f) * FRAME_WIDTH (f); 
    140130  dest.X = dest.Y = 0; 
    141131 
     
    344334  register char *ptr; 
    345335  GLYPH glyph; 
     336  WORD *attrs; 
    346337  char *chars; 
    347338  int i; 
     
    350341    return; 
    351342 
     343  attrs = alloca (len * sizeof (*attrs)); 
    352344  chars = alloca (len * sizeof (*chars)); 
    353   if (chars == NULL) 
     345  if (attrs == NULL || chars == NULL) 
    354346    { 
    355347      printf ("alloca failed in write_glyphs\n"); 
     
    388380  len = ptr-chars; 
    389381   
    390   /* Set the attribute for these characters.  */ 
    391   if (!FillConsoleOutputAttribute (cur_screen, char_attr, len, cursor_coords, &i)) 
     382  /* Fill in the attributes for these characters.  */ 
     383  for (i = 0; i < len; i++) 
     384    attrs[i] = char_attr; 
     385   
     386  /* Write the attributes.  */ 
     387  if (!WriteConsoleOutputAttribute (cur_screen, attrs, len, cursor_coords, &i)) 
    392388    { 
    393389      printf ("Failed writing console attributes: %d\n", GetLastError ()); 
     
    570566#endif 
    571567 
    572   /* Respect setting of LINES and COLUMNS environment variables.  */ 
    573   { 
    574     char * lines = getenv("LINES"); 
    575     char * columns = getenv("COLUMNS"); 
    576  
    577     if (lines != NULL && columns != NULL) 
    578       { 
    579         SMALL_RECT new_win_dims; 
    580         COORD new_size; 
    581  
    582         new_size.X = atoi (columns); 
    583         new_size.Y = atoi (lines); 
    584  
    585         GetConsoleScreenBufferInfo (cur_screen, &info); 
    586  
    587         /* Shrink the window first, so the buffer dimensions can be 
    588            reduced if necessary.  */ 
    589         new_win_dims.Top = 0; 
    590         new_win_dims.Left = 0; 
    591         new_win_dims.Bottom = min (new_size.Y, info.dwSize.Y) - 1; 
    592         new_win_dims.Right = min (new_size.X, info.dwSize.X) - 1; 
    593         SetConsoleWindowInfo (cur_screen, TRUE, &new_win_dims); 
    594  
    595         SetConsoleScreenBufferSize (cur_screen, new_size); 
    596  
    597         /* Set the window size to match the buffer dimension.  */ 
    598         new_win_dims.Top = 0; 
    599         new_win_dims.Left = 0; 
    600         new_win_dims.Bottom = new_size.Y - 1; 
    601         new_win_dims.Right = new_size.X - 1; 
    602         SetConsoleWindowInfo (cur_screen, TRUE, &new_win_dims); 
    603       } 
    604   } 
    605  
    606568  GetConsoleScreenBufferInfo (cur_screen, &info); 
    607569   
     
    611573  char_attr_reverse = ((char_attr & 0xf) << 4) + ((char_attr & 0xf0) >> 4); 
    612574 
    613   if (w32_use_full_screen_buffer) 
    614     { 
    615       FRAME_HEIGHT (selected_frame) = info.dwSize.Y;    /* lines per page */ 
    616       SET_FRAME_WIDTH (selected_frame, info.dwSize.X);  /* characters per line */ 
    617     } 
    618   else 
    619     { 
    620       /* Lines per page.  Use buffer coords instead of buffer size.  */ 
    621       FRAME_HEIGHT (selected_frame) = 1 + info.srWindow.Bottom -  
    622         info.srWindow.Top;  
    623       /* Characters per line.  Use buffer coords instead of buffer size.  */ 
    624       SET_FRAME_WIDTH (selected_frame, 1 + info.srWindow.Right -  
    625                        info.srWindow.Left); 
    626     } 
     575  /* Lines per page.  Use buffer coords instead of buffer size.  */ 
     576  FRAME_HEIGHT (selected_frame) = 1 + info.srWindow.Bottom -  
     577    info.srWindow.Top;  
     578  /* Characters per line.  Use buffer coords instead of buffer size.  */ 
     579  SET_FRAME_WIDTH (selected_frame, 1 + info.srWindow.Right -  
     580                   info.srWindow.Left); 
    627581} 
    628582 
     
    673627syms_of_ntterm () 
    674628{ 
    675   DEFVAR_BOOL ("w32-use-full-screen-buffer", 
    676                &w32_use_full_screen_buffer, 
    677   "Non-nil means make terminal frames use the full screen buffer dimensions.\n\ 
    678 This is desirable when running Emacs over telnet, and is the default.\n\ 
    679 A value of nil means use the current console window dimensions; this\n\ 
    680 may be preferrable when working directly at the console with a large\n\ 
    681 scroll-back buffer."); 
    682   w32_use_full_screen_buffer = 1; 
    683  
    684629  defsubr (&Sset_screen_color); 
    685630  defsubr (&Sset_cursor_size); 
  • branches/GNU/src/w32fns.c

    r1651 r1679  
    3838#include "keyboard.h" 
    3939#include "blockinput.h" 
    40 #include "epaths.h" 
     40#include "paths.h" 
    4141#include "w32heap.h" 
    4242#include "termhooks.h" 
     
    6464Lisp_Object Vw32_alt_is_meta; 
    6565 
    66 /* If non-zero, the windows virtual key code for an alternative quit key. */ 
    67 Lisp_Object Vw32_quit_key; 
    68  
    6966/* Non nil if left window key events are passed on to Windows (this only 
    7067   affects whether "tapping" the key opens the Start menu).  */ 
     
    139136Lisp_Object Vx_pixel_size_width_font_regexp; 
    140137 
    141 /* Alist of bdf fonts and the files that define them.  */ 
    142 Lisp_Object Vw32_bdf_filename_alist; 
    143  
    144 Lisp_Object Vw32_system_coding_system; 
    145  
    146138/* A flag to control how to display unibyte 8-bit character.  */ 
    147139int unibyte_display_via_language_environment; 
    148  
    149 /* A flag to control whether fonts are matched strictly or not.  */ 
    150 int w32_strict_fontnames; 
    151140 
    152141/* Evaluate this expression to rebuild the section of syms_of_w32fns 
     
    537526/* Remove reference to bitmap with id number ID.  */ 
    538527 
    539 void 
     528int 
    540529x_destroy_bitmap (f, id) 
    541530     FRAME_PTR f; 
     
    697686  int icon_left_no_change = 0, icon_top_no_change = 0; 
    698687 
    699   struct gcpro gcpro1, gcpro2; 
    700  
    701688  i = 0; 
    702689  for (tail = alist; CONSP (tail); tail = Fcdr (tail)) 
     
    719706    } 
    720707 
    721   /* TAIL and ALIST are not used again below here.  */ 
    722   alist = tail = Qnil; 
    723  
    724   GCPRO2 (*parms, *values); 
    725   gcpro1.nvars = i; 
    726   gcpro2.nvars = i; 
    727  
    728   /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP, 
    729      because their values appear in VALUES and strings are not valid.  */ 
    730708  top = left = Qunbound; 
    731709  icon_left = icon_top = Qunbound; 
     
    891869      x_wm_set_icon_position (f, XINT (icon_left), XINT (icon_top)); 
    892870  } 
    893  
    894   UNGCPRO; 
    895871} 
    896872 
     
    19731949} 
    19741950 
    1975 /* Set the border-color of frame F to pixel value PIX. 
    1976    Note that this does not fully take effect if done before 
    1977    F has an window.  */ 
    1978 void 
    1979 x_set_border_pixel (f, pix) 
    1980      struct frame *f; 
    1981      int pix; 
    1982 { 
    1983   f->output_data.w32->border_pixel = pix; 
    1984  
    1985   if (FRAME_W32_WINDOW (f) != 0 && f->output_data.w32->border_width > 0) 
    1986     { 
    1987       if (FRAME_VISIBLE_P (f)) 
    1988         redraw_frame (f); 
    1989     } 
    1990 } 
    1991  
    19921951/* Set the border-color of frame F to value described by ARG. 
    19931952   ARG can be a string naming a color. 
     
    20101969 
    20111970  x_set_border_pixel (f, pix); 
     1971} 
     1972 
     1973/* Set the border-color of frame F to pixel value PIX. 
     1974   Note that this does not fully take effect if done before 
     1975   F has an window.  */ 
     1976 
     1977x_set_border_pixel (f, pix) 
     1978     struct frame *f; 
     1979     int pix; 
     1980{ 
     1981  f->output_data.w32->border_pixel = pix; 
     1982 
     1983  if (FRAME_W32_WINDOW (f) != 0 && f->output_data.w32->border_width > 0) 
     1984    { 
     1985      if (FRAME_VISIBLE_P (f)) 
     1986        redraw_frame (f); 
     1987    } 
    20121988} 
    20131989 
     
    36283604    if (isalpha (c) && wmsg.dwModifiers == ctrl_modifier) 
    36293605      c = make_ctrl_char (c) & 0377; 
    3630     if (c == quit_char 
    3631         || (wmsg.dwModifiers == 0 && 
    3632             XFASTINT (Vw32_quit_key) && wParam == XFASTINT (Vw32_quit_key))) 
     3606    if (c == quit_char) 
    36333607      { 
    36343608        Vquit_flag = Qt; 
     
    36803654  W32Msg wmsg; 
    36813655  int windows_translate; 
    3682   int key; 
    36833656 
    36843657  /* Note that it is okay to call x_window_to_frame, even though we are 
     
    37823755        { 
    37833756          dpyinfo->faked_key = 0; 
    3784           /* Make sure TranslateMessage sees them though (as long as 
    3785              they don't produce WM_CHAR messages).  This ensures that 
    3786              indicator lights are toggled promptly on Windows 9x, for 
    3787              example.  */ 
    3788           if (lispy_function_keys[wParam] != 0) 
    3789             { 
    3790               windows_translate = 1; 
    3791               goto translate; 
    3792             } 
    3793           return 0; 
     3757          /* Make sure TranslateMessage sees them though.  */ 
     3758          windows_translate = 1; 
     3759          goto translate; 
    37943760        } 
    37953761 
     
    38123778                { 
    38133779                  if (NUMBERP (Vw32_phantom_key_code)) 
    3814                     key = XUINT (Vw32_phantom_key_code) & 255; 
     3780                    wParam = XUINT (Vw32_phantom_key_code) & 255; 
    38153781                  else 
    3816                     key = VK_SPACE; 
    3817                   dpyinfo->faked_key = key
    3818                   keybd_event (key, (BYTE) MapVirtualKey (key, 0), 0, 0); 
     3782                    wParam = VK_SPACE; 
     3783                  dpyinfo->faked_key = wParam
     3784                  keybd_event (wParam, (BYTE) MapVirtualKey (wParam, 0), 0, 0); 
    38193785                } 
    38203786            } 
    38213787          if (!NILP (Vw32_lwindow_modifier)) 
    38223788            return 0; 
     3789          windows_translate = 1; 
    38233790          break; 
    38243791        case VK_RWIN: 
     
    38283795                { 
    38293796                  if (NUMBERP (Vw32_phantom_key_code)) 
    3830                     key = XUINT (Vw32_phantom_key_code) & 255; 
     3797                    wParam = XUINT (Vw32_phantom_key_code) & 255; 
    38313798                  else 
    3832                     key = VK_SPACE; 
    3833                   dpyinfo->faked_key = key
    3834                   keybd_event (key, (BYTE) MapVirtualKey (key, 0), 0, 0); 
     3799                    wParam = VK_SPACE; 
     3800                  dpyinfo->faked_key = wParam
     3801                  keybd_event (wParam, (BYTE) MapVirtualKey (wParam, 0), 0, 0); 
    38353802                } 
    38363803            } 
    38373804          if (!NILP (Vw32_rwindow_modifier)) 
    38383805            return 0; 
     3806          windows_translate = 1; 
    38393807          break; 
    3840       case VK_APPS: 
     3808      case VK_APPS: 
    38413809          if (!NILP (Vw32_apps_modifier)) 
    38423810            return 0; 
     3811          windows_translate = 1; 
    38433812          break; 
    38443813        case VK_MENU: 
     
    44354404      goto dflt; 
    44364405 
    4437     case WM_GETMINMAXINFO: 
    4438       /* Hack to correct bug that allows Emacs frames to be resized 
    4439          below the Minimum Tracking Size.  */ 
    4440       ((LPMINMAXINFO) lParam)->ptMinTrackSize.y++; 
    4441       return 0; 
    4442  
    44434406    case WM_EMACS_CREATESCROLLBAR: 
    44444407      return (LRESULT) w32_createscrollbar ((struct frame *) wParam, 
     
    47804743          font = x_new_fontset (f, XSTRING (tem)->data); 
    47814744        else 
    4782           font = x_new_font (f, XSTRING (font)->data); 
     4745      font = x_new_font (f, XSTRING (font)->data); 
    47834746      } 
    47844747    /* Try out a font which we hope has bold and italic variations.  */ 
     
    49564919 
    49574920  
    4958 struct font_info *w32_load_bdf_font (struct frame *f, char *fontname, 
    4959                                      int size, char* filename); 
    4960  
     4921/* Load font named FONTNAME of size SIZE for frame F, and return a 
     4922   pointer to the structure font_info while allocating it dynamically. 
     4923   If loading fails, return NULL. */ 
    49614924struct font_info * 
    4962 w32_load_system_font (f,fontname,size) 
     4925w32_load_font (f,fontname,size) 
    49634926struct frame *f; 
    49644927char * fontname; 
     
    49674930  struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); 
    49684931  Lisp_Object font_names; 
     4932 
     4933#if 0   /* x_load_font attempts to get a list of fonts - presumably to 
     4934           allow a fuzzier fontname to be specified. w32_list_fonts 
     4935           appears to be a bit too fuzzy for this purpose. */ 
    49694936 
    49704937  /* Get a list of all the fonts that match this name.  Once we 
     
    49774944      Lisp_Object tail; 
    49784945      int i; 
     4946 
    49794947#if 0 /* This code has nasty side effects that cause Emacs to crash.  */ 
    49804948 
     
    49894957            return (dpyinfo->font_table + i); 
    49904958#endif 
     4959 
    49914960      fontname = (char *) XSTRING (XCONS (font_names)->car)->data; 
    49924961    } 
    4993   else if (w32_strict_fontnames) 
    4994     { 
    4995       /* If EnumFontFamiliesEx was available, we got a full list of 
    4996          fonts back so stop now to avoid the possibility of loading a 
    4997          random font.  If we had to fall back to EnumFontFamilies, the 
    4998          list is incomplete, so continue whether the font we want was 
    4999          listed or not. */ 
    5000       HMODULE gdi32 = GetModuleHandle ("gdi32.dll"); 
    5001       FARPROC enum_font_families_ex 
    5002         = GetProcAddress (gdi32, "EnumFontFamiliesExA"); 
    5003       if (enum_font_families_ex) 
    5004         return NULL; 
    5005     } 
     4962  else 
     4963    return NULL; 
     4964#endif 
    50064965 
    50074966  /* Load the font and add it to the table. */ 
    50084967  { 
    5009     char *full_name, *encoding
     4968    char *full_name
    50104969    XFontStruct *font; 
    50114970    struct font_info *fontp; 
     
    50264985    font = (XFontStruct *) xmalloc (sizeof (XFontStruct)); 
    50274986 
    5028     /* Set bdf to NULL to indicate that this is a Windows font.  */ 
    5029     font->bdf = NULL; 
     4987    if (!font) return (NULL); 
    50304988 
    50314989    BLOCK_INPUT; 
     
    51085066       which is never used by any charset.  If mapping can't be 
    51095067       decided, set FONT_ENCODING_NOT_DECIDED.  */ 
    5110  
    5111     /* SJIS fonts need to be set to type 4, all others seem to work as 
    5112        type FONT_ENCODING_NOT_DECIDED.  */ 
    5113     encoding = strrchr (fontp->name, '-'); 
    5114     if (encoding && stricmp (encoding+1, "sjis") == 0) 
    5115         fontp->encoding[1] = 4; 
    5116     else 
    51175068    fontp->encoding[1] = FONT_ENCODING_NOT_DECIDED; 
    51185069 
     
    51215072    fontp->baseline_offset = 0; 
    51225073    fontp->relative_compose = 0; 
    5123     fontp->default_ascent = 0
     5074    fontp->default_ascent = FONT_BASE (font)
    51245075 
    51255076    UNBLOCK_INPUT; 
     
    51295080  } 
    51305081} 
    5131  
    5132 /* Load font named FONTNAME of size SIZE for frame F, and return a 
    5133    pointer to the structure font_info while allocating it dynamically. 
    5134    If loading fails, return NULL. */ 
    5135 struct font_info * 
    5136 w32_load_font (f,fontname,size) 
    5137 struct frame *f; 
    5138 char * fontname; 
    5139 int size; 
    5140 { 
    5141   Lisp_Object bdf_fonts; 
    5142   struct font_info *retval = NULL; 
    5143  
    5144   bdf_fonts = w32_list_bdf_fonts (build_string (fontname)); 
    5145  
    5146   while (!retval && CONSP (bdf_fonts)) 
    5147     { 
    5148       char *bdf_name, *bdf_file; 
    5149       Lisp_Object bdf_pair; 
    5150  
    5151       bdf_name = XSTRING (XCONS (bdf_fonts)->car)->data; 
    5152       bdf_pair = Fassoc (XCONS (bdf_fonts)->car, Vw32_bdf_filename_alist); 
    5153       bdf_file = XSTRING (XCONS (bdf_pair)->cdr)->data; 
    5154  
    5155       retval = w32_load_bdf_font (f, bdf_name, size, bdf_file); 
    5156  
    5157       bdf_fonts = XCONS (bdf_fonts)->cdr; 
    5158     } 
    5159  
    5160   if (retval) 
    5161     return retval; 
    5162  
    5163   return w32_load_system_font(f, fontname, size); 
    5164 } 
    5165  
    51665082 
    51675083void  
     
    51725088  if (font)  
    51735089    { 
    5174       if (font->bdf) w32_free_bdf_font (font->bdf); 
    5175  
    51765090      if (font->hfont) DeleteObject(font->hfont); 
    51775091      xfree (font); 
     
    52995213  if (stricmp (lpcs,"ansi") == 0)                return ANSI_CHARSET; 
    53005214  else if (stricmp (lpcs,"iso8859-1") == 0)      return ANSI_CHARSET; 
    5301   else if (stricmp (lpcs, "ms-symbol") == 0)     return SYMBOL_CHARSET; 
     5215  else if (stricmp (lpcs, "symbol") == 0)        return SYMBOL_CHARSET; 
    53025216  else if (stricmp (lpcs, "jis") == 0)           return SHIFTJIS_CHARSET; 
    5303   else if (stricmp (lpcs, "ksc5601.1987") == 0)  return HANGEUL_CHARSET; 
     5217  else if (stricmp (lpcs, "ksc5601") == 0)       return HANGEUL_CHARSET; 
    53045218  else if (stricmp (lpcs, "gb2312") == 0)        return GB2312_CHARSET; 
    53055219  else if (stricmp (lpcs, "big5") == 0)          return CHINESEBIG5_CHARSET; 
    5306   else if (stricmp (lpcs, "ms-oem") == 0)      return OEM_CHARSET; 
     5220  else if (stricmp (lpcs, "oem") == 0)          return OEM_CHARSET; 
    53075221 
    53085222#ifdef EASTEUROPE_CHARSET 
     
    53205234  else if (stricmp (lpcs, "tis620") == 0)        return THAI_CHARSET; 
    53215235  else if (stricmp (lpcs, "mac") == 0)           return MAC_CHARSET; 
    5322   else if (stricmp (lpcs, "ksc5601.1992") == 0)  return JOHAB_CHARSET; 
    5323   /* For backwards compatibility with previous 20.4 pretests.  */ 
    5324   else if (stricmp (lpcs, "ksc5601") == 0)       return HANGEUL_CHARSET; 
    5325   else if (stricmp (lpcs, "johab") == 0)         return JOHAB_CHARSET; 
    53265236#endif 
    53275237 
     
    53465256    case ANSI_CHARSET:        return "iso8859-1"; 
    53475257    case DEFAULT_CHARSET:     return "ascii-*"; 
    5348     case SYMBOL_CHARSET:      return "ms-symbol"; 
     5258    case SYMBOL_CHARSET:      return "*-symbol"; 
    53495259    case SHIFTJIS_CHARSET:    return "jisx0208-sjis"; 
    5350     case HANGEUL_CHARSET:     return "ksc5601.1987-*"; 
     5260    case HANGEUL_CHARSET:     return "ksc5601-*"; 
    53515261    case GB2312_CHARSET:      return "gb2312-*"; 
    53525262    case CHINESEBIG5_CHARSET: return "big5-*"; 
    5353     case OEM_CHARSET:         return "ms-oem"; 
     5263    case OEM_CHARSET:         return "*-oem"; 
    53545264 
    53555265      /* More recent versions of Windows (95 and NT4.0) define more 
     
    53595269    case TURKISH_CHARSET:    return "iso8859-9"; 
    53605270    case BALTIC_CHARSET:     return "iso8859-4"; 
    5361  
    5362       /* W95 with international support but not IE4 often has the 
    5363          KOI8-R codepage but not ISO8859-5.  */ 
    5364     case RUSSIAN_CHARSET: 
    5365       if (!IsValidCodePage(28595) && IsValidCodePage(20886)) 
    5366         return "koi8-r"; 
    5367       else 
    5368         return "iso8859-5"; 
     5271    case RUSSIAN_CHARSET:    return "koi8-r"; 
    53695272    case ARABIC_CHARSET:     return "iso8859-6"; 
    53705273    case GREEK_CHARSET:      return "iso8859-7"; 
     
    53725275    case VIETNAMESE_CHARSET: return "viscii1.1-*"; 
    53735276    case THAI_CHARSET:       return "tis620-*"; 
    5374     case MAC_CHARSET:        return "mac-*"; 
    5375     case JOHAB_CHARSET:      return "ksc5601.1992-*"; 
     5277    case MAC_CHARSET:        return "*-mac"; 
     5278      /* Johab is Korean, but Hangeul is the standard - what is this? */ 
     5279    case JOHAB_CHARSET:      return "*-johab"; 
    53765280 
    53775281#endif 
     
    53925296     int len; 
    53935297{ 
    5394   char *fontname
     5298  char fontname[50]
    53955299  char height_pixels[8]; 
    53965300  char height_dpi[8]; 
    53975301  char width_pixels[8]; 
    53985302  char *fontname_dash; 
    5399   int display_resy = one_w32_display_info.height_in; 
    5400   int display_resx = one_w32_display_info.width_in; 
    5401   int bufsz; 
    5402   struct coding_system coding; 
    54035303 
    54045304  if (!lpxstr) abort (); 
     
    54075307    return FALSE; 
    54085308 
    5409   setup_coding_system (Fcheck_coding_system (Vw32_system_coding_system), 
    5410                        &coding); 
    5411   coding.mode |= CODING_MODE_LAST_BLOCK; 
    5412   bufsz = decoding_buffer_size (&coding, LF_FACESIZE); 
    5413  
    5414   fontname = alloca(sizeof(*fontname) * bufsz); 
    5415   decode_coding (&coding, lplogfont->lfFaceName, fontname, 
    5416                  strlen(lplogfont->lfFaceName), bufsz - 1); 
    5417   *(fontname + coding.produced) = '\0'; 
     5309  strncpy (fontname, lplogfont->lfFaceName, 50); 
     5310  fontname[49] = '\0'; /* Just in case */ 
    54185311 
    54195312  /* Replace dashes with underscores so the dashes are not 
    5420      misinterpreted. */ 
     5313     misinterpreted */ 
    54215314  fontname_dash = fontname; 
    54225315  while (fontname_dash = strchr (fontname_dash, '-')) 
     
    54275320      sprintf (height_pixels, "%u", abs (lplogfont->lfHeight)); 
    54285321      sprintf (height_dpi, "%u", 
    5429                abs (lplogfont->lfHeight) * 720 / display_resy); 
     5322               (abs (lplogfont->lfHeight) * 720) / one_w32_display_info.height_in); 
    54305323    } 
    54315324  else 
     
    54405333 
    54415334  _snprintf (lpxstr, len - 1, 
    5442              "-*-%s-%s-%c-*-*-%s-%s-%d-%d-%c-%s-%s", 
     5335             "-*-%s-%s-%c-*-*-%s-%s-*-*-%c-%s-%s", 
    54435336                                                     /* foundry */ 
    54445337             fontname,                               /* family */ 
     
    54495342             height_pixels,                          /* pixel size */ 
    54505343             height_dpi,                             /* point size */ 
    5451              display_resx,                           /* resx */ 
    5452              display_resy,                           /* resy */ 
     5344                                                     /* resx */ 
     5345                                                     /* resy */ 
    54535346             ((lplogfont->lfPitchAndFamily & 0x3) == VARIABLE_PITCH) 
    54545347             ? 'p' : 'c',                            /* spacing */ 
     
    54675360     LOGFONT * lplogfont; 
    54685361{ 
    5469   struct coding_system coding; 
    5470  
    54715362  if (!lplogfont) return (FALSE); 
    5472  
     5363   
    54735364  memset (lplogfont, 0, sizeof (*lplogfont)); 
    54745365 
     
    55005391  if (*lpxstr == '-') 
    55015392    { 
    5502       int fields, tem; 
    5503       char name[50], weight[20], slant, pitch, pixels[10], height[10], 
    5504         width[10], resy[10], remainder[20]; 
     5393      int fields; 
     5394      char name[50], weight[20], slant, pitch, pixels[10], height[10], width[10], remainder[20]; 
    55055395      char * encoding; 
    5506       int dpi = one_w32_display_info.height_in; 
    55075396 
    55085397      fields = sscanf (lpxstr, 
    5509                        "-%*[^-]-%49[^-]-%19[^-]-%c-%*[^-]-%*[^-]-%9[^-]-%9[^-]-%*[^-]-%9[^-]-%c-%9[^-]-%19s", 
    5510                        name, weight, &slant, pixels, height, resy, &pitch, width, remainder); 
     5398                       "-%*[^-]-%49[^-]-%19[^-]-%c-%*[^-]-%*[^-]-%9[^-]-%9[^-]-%*[^-]-%*[^-]-%c-%9[^-]-%19s", 
     5399                       name, weight, &slant, pixels, height, &pitch, width, remainder); 
     5400 
    55115401      if (fields == EOF) return (FALSE); 
    55125402 
    55135403      if (fields > 0 && name[0] != '*') 
    55145404        { 
    5515           int bufsize; 
    5516           unsigned char *buf; 
    5517  
    5518           setup_coding_system 
    5519             (Fcheck_coding_system (Vw32_system_coding_system), &coding); 
    5520           bufsize = encoding_buffer_size (&coding, strlen (name)); 
    5521           buf = (unsigned char *) alloca (bufsize); 
    5522           coding.mode |= CODING_MODE_LAST_BLOCK; 
    5523           encode_coding (&coding, name, buf, strlen (name), bufsize); 
    5524           if (coding.produced >= LF_FACESIZE) 
    5525             coding.produced = LF_FACESIZE - 1; 
    5526           buf[coding.produced] = 0; 
    5527           strcpy (lplogfont->lfFaceName, buf); 
     5405          strncpy (lplogfont->lfFaceName,name, LF_FACESIZE); 
     5406          lplogfont->lfFaceName[LF_FACESIZE-1] = 0; 
    55285407        } 
    55295408      else 
     
    55475426 
    55485427      fields--; 
     5428 
     5429      if (fields > 0 && lplogfont->lfHeight == 0 && height[0] != '*') 
     5430        lplogfont->lfHeight = (atoi (height) 
     5431                               * one_w32_display_info.height_in) / 720; 
     5432 
    55495433      fields--; 
    5550       if (fields > 0 && resy[0] != '*') 
    5551         { 
    5552           tem = atoi (pixels); 
    5553           if (tem > 0) dpi = tem; 
    5554         } 
    5555  
    5556       if (fields > -1 && lplogfont->lfHeight == 0 && height[0] != '*') 
    5557         lplogfont->lfHeight = atoi (height) * dpi / 720; 
    5558  
    5559       if (fields > 0) 
     5434 
    55605435      lplogfont->lfPitchAndFamily = 
    55615436        (fields > 0 && pitch == 'p') ? VARIABLE_PITCH : FIXED_PITCH; 
     
    56275502    char * lpszfont2; 
    56285503{ 
    5629   char * s1 = lpszfont1, *e1, *w1
    5630   char * s2 = lpszfont2, *e2, *w2
     5504  char * s1 = lpszfont1, *e1
     5505  char * s2 = lpszfont2, *e2
    56315506   
    56325507  if (s1 == NULL || s2 == NULL) return (FALSE); 
     
    56375512  while (1)  
    56385513    { 
    5639       int len1, len2, len3=0
     5514      int len1, len2
    56405515 
    56415516      e1 = strchr (s1, '-'); 
    56425517      e2 = strchr (s2, '-'); 
    5643       w1 = strchr (s1, '*'); 
    5644       w2 = strchr (s2, '*'); 
    5645  
    5646       if (e1 == NULL) 
    5647         len1 = strlen (s1); 
    5648       else 
     5518 
     5519      if (e1 == NULL || e2 == NULL) return (TRUE); 
     5520 
    56495521      len1 = e1 - s1; 
    5650       if (e2 == NULL) 
    5651         len2 = strlen (s1); 
    5652       else 
    56535522      len2 = e2 - s2; 
    56545523 
    5655       if (w1 && w1 < e1) 
    5656         len3 = w1 - s1; 
    5657       if (w2 && w2 < e2 && ( len3 == 0 || (w2 - s2) < len3)) 
    5658         len3 = w2 - s2; 
    5659  
    5660       /* Whole field is not a wildcard, and ...*/ 
    5661       if (*s1 != '*' && *s2 != '*' && *s1 != '-' && *s2 != '-' 
    5662           /* Lengths are different and there are no wildcards, or ... */ 
    5663           && ((len1 != len2 && len3 == 0) || 
    5664               /* strings don't match up until first wildcard or end.  */ 
    5665               strnicmp (s1, s2, len3 > 0 ? len3 : len1) != 0)) 
     5524      if (*s1 != '*' && *s2 != '*' 
     5525          && (len1 != len2 || strnicmp (s1, s2, len1) != 0)) 
    56665526        return (FALSE); 
    5667  
    5668       if (e1 == NULL || e2 == NULL) 
    5669         return (TRUE); 
    56705527 
    56715528      s1 = e1 + 1; 
     
    56735530    } 
    56745531} 
    5675  
    5676 /* Callback functions, and a structure holding info they need, for 
    5677    listing system fonts on W32. We need one set of functions to do the 
    5678    job properly, but these don't work on NT 3.51 and earlier, so we 
    5679    have a second set which don't handle character sets properly to 
    5680    fall back on. 
    5681  
    5682    In both cases, there are two passes made. The first pass gets one 
    5683    font from each family, the second pass lists all the fonts from 
    5684    each family.  */ 
    56855532 
    56865533typedef struct enumfont_t  
     
    56915538  XFontStruct *size_ref; 
    56925539  Lisp_Object *pattern; 
     5540  Lisp_Object *head; 
    56935541  Lisp_Object *tail; 
    56945542} enumfont_t; 
     
    57215569        lplf->elfLogFont.lfWidth = lpef->logfont.lfWidth; 
    57225570      } 
    5723     /* Make sure the height used here is the same as everywhere 
    5724        else (ie character height, not cell height).  */ 
    5725     else if (lplf->elfLogFont.lfHeight > 0) 
    5726       lplf->elfLogFont.lfHeight = lptm->tmInternalLeading - lptm->tmHeight; 
    57275571 
    57285572    /* The MaxCharWidth is not valid at this stage for scalable fonts. */ 
     
    57305574        width = make_number (lptm->tmMaxCharWidth); 
    57315575 
    5732     if (!w32_to_x_font (&(lplf->elfLogFont), buf, 100)) 
    5733       return (0); 
    5734  
    5735     if (NILP (*(lpef->pattern)) 
    5736         || w32_font_match (buf, XSTRING (*(lpef->pattern))->data)) 
     5576    if (!w32_to_x_font (lplf, buf, 100)) return (0); 
     5577 
     5578    if (NILP (*(lpef->pattern)) || w32_font_match (buf, XSTRING (*(lpef->pattern))->data)) 
    57375579      { 
    57385580        *lpef->tail = Fcons (Fcons (build_string (buf), width), Qnil); 
     
    57595601 
    57605602 
    5761 int CALLBACK 
    5762 enum_fontex_cb2 (lplf, lptm, font_type, lpef) 
    5763      ENUMLOGFONTEX * lplf; 
    5764      NEWTEXTMETRICEX * lptm; 
    5765      int font_type; 
    5766      enumfont_t * lpef; 
    5767 { 
    5768   /* We are not interested in the extra info we get back from the 'Ex 
    5769      version - only the fact that we get character set variations 
    5770      enumerated seperately.  */ 
    5771   return enum_font_cb2 ((ENUMLOGFONT *) lplf, (NEWTEXTMETRIC *) lptm, 
    5772                         font_type, lpef); 
    5773 } 
    5774  
    5775 int CALLBACK 
    5776 enum_fontex_cb1 (lplf, lptm, font_type, lpef) 
    5777      ENUMLOGFONTEX * lplf; 
    5778      NEWTEXTMETRICEX * lptm; 
    5779      int font_type; 
    5780      enumfont_t * lpef; 
    5781 { 
    5782   HMODULE gdi32 = GetModuleHandle ("gdi32.dll"); 
    5783   FARPROC enum_font_families_ex 
    5784     = GetProcAddress ( gdi32, "EnumFontFamiliesExA"); 
    5785   /* We don't really expect EnumFontFamiliesEx to disappear once we 
    5786      get here, so don't bother handling it gracefully.  */ 
    5787   if (enum_font_families_ex == NULL) 
    5788     error ("gdi32.dll has disappeared!"); 
    5789   return enum_font_families_ex (lpef->hdc, 
    5790                                 &lplf->elfLogFont, 
    5791                                 (FONTENUMPROC) enum_fontex_cb2, 
    5792                                 (LPARAM) lpef, 0); 
    5793 } 
    5794  
    57955603/* Interface to fontset handler. (adapted from mw32font.c in Meadow 
    57965604   and xterm.c in Emacs 20.3) */ 
    5797  
    5798 Lisp_Object w32_list_bdf_fonts (Lisp_Object pattern, int max_names) 
    5799 { 
    5800   char *fontname, *ptnstr; 
    5801   Lisp_Object list, tem, newlist = Qnil; 
    5802   int n_fonts; 
    5803  
    5804   list = Vw32_b