emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/xfaces.c


From: Jan Djärv
Subject: [Emacs-diffs] Changes to emacs/src/xfaces.c
Date: Tue, 18 Feb 2003 16:30:09 -0500

Index: emacs/src/xfaces.c
diff -c emacs/src/xfaces.c:1.267 emacs/src/xfaces.c:1.268
*** emacs/src/xfaces.c:1.267    Tue Feb  4 09:03:17 2003
--- emacs/src/xfaces.c  Tue Feb 18 16:30:07 2003
***************
*** 474,480 ****
  static int better_font_p P_ ((int *, struct font_name *, struct font_name *,
                              int, int));
  static int x_face_list_fonts P_ ((struct frame *, char *,
!                                 struct font_name *, int, int));
  static int font_scalable_p P_ ((struct font_name *));
  static int get_lface_attributes P_ ((struct frame *, Lisp_Object, Lisp_Object 
*, int));
  static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned 
*));
--- 474,480 ----
  static int better_font_p P_ ((int *, struct font_name *, struct font_name *,
                              int, int));
  static int x_face_list_fonts P_ ((struct frame *, char *,
!                                 struct font_name **, int, int));
  static int font_scalable_p P_ ((struct font_name *));
  static int get_lface_attributes P_ ((struct frame *, Lisp_Object, Lisp_Object 
*, int));
  static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned 
*));
***************
*** 2435,2444 ****
     fonts that we can't parse.  Value is the number of fonts found.  */
  
  static int
! x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p)
       struct frame *f;
       char *pattern;
!      struct font_name *fonts;
       int nfonts, try_alternatives_p;
  {
    int n, nignored;
--- 2435,2444 ----
     fonts that we can't parse.  Value is the number of fonts found.  */
  
  static int
! x_face_list_fonts (f, pattern, pfonts, nfonts, try_alternatives_p)
       struct frame *f;
       char *pattern;
!      struct font_name **pfonts;
       int nfonts, try_alternatives_p;
  {
    int n, nignored;
***************
*** 2447,2453 ****
--- 2447,2456 ----
       better to do it the other way around. */
    Lisp_Object lfonts;
    Lisp_Object lpattern, tem;
+   struct font_name *fonts = 0;
+   int num_fonts = nfonts;
  
+   *pfonts = 0;
    lpattern = build_string (pattern);
  
    /* Get the list of fonts matching PATTERN.  */
***************
*** 2459,2468 ****
    lfonts = x_list_fonts (f, lpattern, -1, nfonts);
  #endif
  
    /* Make a copy of the font names we got from X, and
       split them into fields.  */
    n = nignored = 0;
!   for (tem = lfonts; CONSP (tem) && n < nfonts; tem = XCDR (tem))
      {
        Lisp_Object elt, tail;
        const char *name = SDATA (XCAR (tem));
--- 2462,2474 ----
    lfonts = x_list_fonts (f, lpattern, -1, nfonts);
  #endif
  
+   if (nfonts < 0 && CONSP (lfonts))
+     num_fonts = Flength (lfonts);
+   
    /* Make a copy of the font names we got from X, and
       split them into fields.  */
    n = nignored = 0;
!   for (tem = lfonts; CONSP (tem) && n < num_fonts; tem = XCDR (tem))
      {
        Lisp_Object elt, tail;
        const char *name = SDATA (XCAR (tem));
***************
*** 2481,2486 ****
--- 2487,2498 ----
          continue;
        }
  
+       if (! fonts)
+         {
+           *pfonts = (struct font_name *) xmalloc (num_fonts * sizeof 
**pfonts);
+           fonts = *pfonts;
+         }
+ 
        /* Make a copy of the font name.  */
        fonts[n].name = xstrdup (name);
  
***************
*** 2504,2509 ****
--- 2516,2523 ----
      {
        Lisp_Object list = Valternate_fontname_alist;
  
+       if (fonts) xfree (fonts);
+       
        while (CONSP (list))
        {
          Lisp_Object entry = XCAR (list);
***************
*** 2527,2533 ****
                    already with no success.  */
                 && (strcmp (SDATA (name), pattern) == 0
                     || (n = x_face_list_fonts (f, SDATA (name),
!                                               fonts, nfonts, 0),
                         n == 0)))
            patterns = XCDR (patterns);
        }
--- 2541,2547 ----
                    already with no success.  */
                 && (strcmp (SDATA (name), pattern) == 0
                     || (n = x_face_list_fonts (f, SDATA (name),
!                                               pfonts, nfonts, 0),
                         n == 0)))
            patterns = XCDR (patterns);
        }
***************
*** 2556,2572 ****
  
    /* Get the list of fonts matching pattern.  100 should suffice.  */
    nfonts = DEFAULT_FONT_LIST_LIMIT;
!   if (INTEGERP (Vfont_list_limit) && XINT (Vfont_list_limit) > 0)
!     nfonts = XFASTINT (Vfont_list_limit);
  
!   *fonts = (struct font_name *) xmalloc (nfonts * sizeof **fonts);
!   nfonts = x_face_list_fonts (f, pattern, *fonts, nfonts, 1);
  
    /* Sort the resulting array and return it in *FONTS.  If no
       fonts were found, make sure to set *FONTS to null.  */
    if (nfonts)
      sort_fonts (f, *fonts, nfonts, cmpfn);
!   else
      {
        xfree (*fonts);
        *fonts = NULL;
--- 2570,2586 ----
  
    /* Get the list of fonts matching pattern.  100 should suffice.  */
    nfonts = DEFAULT_FONT_LIST_LIMIT;
!   if (INTEGERP (Vfont_list_limit))
!     nfonts = XINT (Vfont_list_limit);
  
!   *fonts = NULL;
!   nfonts = x_face_list_fonts (f, pattern, fonts, nfonts, 1);
  
    /* Sort the resulting array and return it in *FONTS.  If no
       fonts were found, make sure to set *FONTS to null.  */
    if (nfonts)
      sort_fonts (f, *fonts, nfonts, cmpfn);
!   else if (*fonts)
      {
        xfree (*fonts);
        *fonts = NULL;
***************
*** 2834,2856 ****
    Lisp_Object result;
    struct gcpro gcpro1;
    int count = SPECPDL_INDEX ();
-   int limit;
- 
-   /* Let's consider all fonts.  Increase the limit for matching
-      fonts until we have them all.  */
-   for (limit = 500;;)
-     {
-       specbind (intern ("font-list-limit"), make_number (limit));
-       nfonts = font_list (f, Qnil, Qnil, Qnil, &fonts);
  
!       if (nfonts == limit)
!       {
!         free_font_names (fonts, nfonts);
!         limit *= 2;
!       }
!       else
!       break;
!     }
  
    result = Qnil;
    GCPRO1 (result);
--- 2848,2857 ----
    Lisp_Object result;
    struct gcpro gcpro1;
    int count = SPECPDL_INDEX ();
  
!   /* Let's consider all fonts.  */
!   specbind (intern ("font-list-limit"), make_number (-1));
!   nfonts = font_list (f, Qnil, Qnil, Qnil, &fonts);
  
    result = Qnil;
    GCPRO1 (result);
***************
*** 2897,2903 ****
    CHECK_STRING (pattern);
  
    if (NILP (maximum))
!     maxnames = 2000;
    else
      {
        CHECK_NATNUM (maximum);
--- 2898,2904 ----
    CHECK_STRING (pattern);
  
    if (NILP (maximum))
!     maxnames = -1;
    else
      {
        CHECK_NATNUM (maximum);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]