Mercurial > emacs
comparison src/xfns.c @ 26401:9457656ded8b
(QCuser_data): Removed.
(syms_of_xfns): Initialization of QCuser_data removed.
(parse_image_spec): Don't handle :user-data specially. Allow
unknown keys. Remove parameter ALLOW_OTHER_KEYS.
(xbm_image_p, xbm_load, xpm_image_p, pbm_image_p, png_image_p)
(tiff_image_p, jpeg_image_p, gif_image_p, gs_image_p): Call
parse_image_spec accordingly.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Wed, 10 Nov 1999 22:05:36 +0000 |
parents | b3aa5203ccf0 |
children | 027b7c42a65b |
comparison
equal
deleted
inserted
replaced
26400:53eeb3b7c785 | 26401:9457656ded8b |
---|---|
5439 /* Keywords. */ | 5439 /* Keywords. */ |
5440 | 5440 |
5441 Lisp_Object QCtype, QCdata, QCascent, QCmargin, QCrelief; | 5441 Lisp_Object QCtype, QCdata, QCascent, QCmargin, QCrelief; |
5442 extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground, QCfile; | 5442 extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground, QCfile; |
5443 Lisp_Object QCalgorithm, QCcolor_symbols, QCheuristic_mask; | 5443 Lisp_Object QCalgorithm, QCcolor_symbols, QCheuristic_mask; |
5444 Lisp_Object QCindex, QCuser_data; | 5444 Lisp_Object QCindex; |
5445 | 5445 |
5446 /* Other symbols. */ | 5446 /* Other symbols. */ |
5447 | 5447 |
5448 Lisp_Object Qlaplace; | 5448 Lisp_Object Qlaplace; |
5449 | 5449 |
5574 /* The value that was found. */ | 5574 /* The value that was found. */ |
5575 Lisp_Object value; | 5575 Lisp_Object value; |
5576 }; | 5576 }; |
5577 | 5577 |
5578 | 5578 |
5579 static int parse_image_spec P_ ((Lisp_Object spec, | 5579 static int parse_image_spec P_ ((Lisp_Object, struct image_keyword *, |
5580 struct image_keyword *keywords, | 5580 int, Lisp_Object)); |
5581 int nkeywords, Lisp_Object type, | |
5582 int allow_other_keys_p)); | |
5583 static Lisp_Object image_spec_value P_ ((Lisp_Object, Lisp_Object, int *)); | 5581 static Lisp_Object image_spec_value P_ ((Lisp_Object, Lisp_Object, int *)); |
5584 | 5582 |
5585 | 5583 |
5586 /* Parse image spec SPEC according to KEYWORDS. A valid image spec | 5584 /* Parse image spec SPEC according to KEYWORDS. A valid image spec |
5587 has the format (image KEYWORD VALUE ...). One of the keyword/ | 5585 has the format (image KEYWORD VALUE ...). One of the keyword/ |
5588 value pairs must be `:type TYPE'. KEYWORDS is a vector of | 5586 value pairs must be `:type TYPE'. KEYWORDS is a vector of |
5589 image_keywords structures of size NKEYWORDS describing other | 5587 image_keywords structures of size NKEYWORDS describing other |
5590 allowed keyword/value pairs. ALLOW_OTHER_KEYS_P non-zero means | 5588 allowed keyword/value pairs. Value is non-zero if SPEC is valid. */ |
5591 allow KEYWORD/VALUE pairs other than those described by KEYWORDS | |
5592 without checking them. Value is non-zero if SPEC is valid. */ | |
5593 | 5589 |
5594 static int | 5590 static int |
5595 parse_image_spec (spec, keywords, nkeywords, type, allow_other_keys_p) | 5591 parse_image_spec (spec, keywords, nkeywords, type) |
5596 Lisp_Object spec; | 5592 Lisp_Object spec; |
5597 struct image_keyword *keywords; | 5593 struct image_keyword *keywords; |
5598 int nkeywords; | 5594 int nkeywords; |
5599 Lisp_Object type; | 5595 Lisp_Object type; |
5600 int allow_other_keys_p; | |
5601 { | 5596 { |
5602 int i; | 5597 int i; |
5603 Lisp_Object plist; | 5598 Lisp_Object plist; |
5604 | 5599 |
5605 if (!CONSP (spec) || !EQ (XCAR (spec), Qimage)) | 5600 if (!CONSP (spec) || !EQ (XCAR (spec), Qimage)) |
5620 if (!CONSP (plist)) | 5615 if (!CONSP (plist)) |
5621 return 0; | 5616 return 0; |
5622 value = XCAR (plist); | 5617 value = XCAR (plist); |
5623 plist = XCDR (plist); | 5618 plist = XCDR (plist); |
5624 | 5619 |
5625 /* Always ignore :user-data DATA. */ | |
5626 if (EQ (key, QCuser_data)) | |
5627 continue; | |
5628 | |
5629 /* Find key in KEYWORDS. Error if not found. */ | 5620 /* Find key in KEYWORDS. Error if not found. */ |
5630 for (i = 0; i < nkeywords; ++i) | 5621 for (i = 0; i < nkeywords; ++i) |
5631 if (strcmp (keywords[i].name, XSYMBOL (key)->name->data) == 0) | 5622 if (strcmp (keywords[i].name, XSYMBOL (key)->name->data) == 0) |
5632 break; | 5623 break; |
5633 | 5624 |
5634 if (i == nkeywords) | 5625 if (i == nkeywords) |
5635 { | 5626 continue; |
5636 if (!allow_other_keys_p) | |
5637 return 0; | |
5638 continue; | |
5639 } | |
5640 | 5627 |
5641 /* Record that we recognized the keyword. If a keywords | 5628 /* Record that we recognized the keyword. If a keywords |
5642 was found more than once, it's an error. */ | 5629 was found more than once, it's an error. */ |
5643 keywords[i].value = value; | 5630 keywords[i].value = value; |
5644 ++keywords[i].count; | 5631 ++keywords[i].count; |
6428 Lisp_Object object; | 6415 Lisp_Object object; |
6429 { | 6416 { |
6430 struct image_keyword kw[XBM_LAST]; | 6417 struct image_keyword kw[XBM_LAST]; |
6431 | 6418 |
6432 bcopy (xbm_format, kw, sizeof kw); | 6419 bcopy (xbm_format, kw, sizeof kw); |
6433 if (!parse_image_spec (object, kw, XBM_LAST, Qxbm, 0)) | 6420 if (!parse_image_spec (object, kw, XBM_LAST, Qxbm)) |
6434 return 0; | 6421 return 0; |
6435 | 6422 |
6436 xassert (EQ (kw[XBM_TYPE].value, Qxbm)); | 6423 xassert (EQ (kw[XBM_TYPE].value, Qxbm)); |
6437 | 6424 |
6438 if (kw[XBM_FILE].count) | 6425 if (kw[XBM_FILE].count) |
6844 char *bits; | 6831 char *bits; |
6845 int parsed_p; | 6832 int parsed_p; |
6846 | 6833 |
6847 /* Parse the list specification. */ | 6834 /* Parse the list specification. */ |
6848 bcopy (xbm_format, fmt, sizeof fmt); | 6835 bcopy (xbm_format, fmt, sizeof fmt); |
6849 parsed_p = parse_image_spec (img->spec, fmt, XBM_LAST, Qxbm, 0); | 6836 parsed_p = parse_image_spec (img->spec, fmt, XBM_LAST, Qxbm); |
6850 xassert (parsed_p); | 6837 xassert (parsed_p); |
6851 | 6838 |
6852 /* Get specified width, and height. */ | 6839 /* Get specified width, and height. */ |
6853 img->width = XFASTINT (fmt[XBM_WIDTH].value); | 6840 img->width = XFASTINT (fmt[XBM_WIDTH].value); |
6854 img->height = XFASTINT (fmt[XBM_HEIGHT].value); | 6841 img->height = XFASTINT (fmt[XBM_HEIGHT].value); |
7003 xpm_image_p (object) | 6990 xpm_image_p (object) |
7004 Lisp_Object object; | 6991 Lisp_Object object; |
7005 { | 6992 { |
7006 struct image_keyword fmt[XPM_LAST]; | 6993 struct image_keyword fmt[XPM_LAST]; |
7007 bcopy (xpm_format, fmt, sizeof fmt); | 6994 bcopy (xpm_format, fmt, sizeof fmt); |
7008 return (parse_image_spec (object, fmt, XPM_LAST, Qxpm, 0) | 6995 return (parse_image_spec (object, fmt, XPM_LAST, Qxpm) |
7009 /* Either `:file' or `:data' must be present. */ | 6996 /* Either `:file' or `:data' must be present. */ |
7010 && fmt[XPM_FILE].count + fmt[XPM_DATA].count == 1 | 6997 && fmt[XPM_FILE].count + fmt[XPM_DATA].count == 1 |
7011 /* Either no `:color-symbols' or it's a list of conses | 6998 /* Either no `:color-symbols' or it's a list of conses |
7012 whose car and cdr are strings. */ | 6999 whose car and cdr are strings. */ |
7013 && (fmt[XPM_COLOR_SYMBOLS].count == 0 | 7000 && (fmt[XPM_COLOR_SYMBOLS].count == 0 |
7673 { | 7660 { |
7674 struct image_keyword fmt[PBM_LAST]; | 7661 struct image_keyword fmt[PBM_LAST]; |
7675 | 7662 |
7676 bcopy (pbm_format, fmt, sizeof fmt); | 7663 bcopy (pbm_format, fmt, sizeof fmt); |
7677 | 7664 |
7678 if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm, 0) | 7665 if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm) |
7679 || (fmt[PBM_ASCENT].count | 7666 || (fmt[PBM_ASCENT].count |
7680 && XFASTINT (fmt[PBM_ASCENT].value) > 100)) | 7667 && XFASTINT (fmt[PBM_ASCENT].value) > 100)) |
7681 return 0; | 7668 return 0; |
7682 return 1; | 7669 return 1; |
7683 } | 7670 } |
7987 Lisp_Object object; | 7974 Lisp_Object object; |
7988 { | 7975 { |
7989 struct image_keyword fmt[PNG_LAST]; | 7976 struct image_keyword fmt[PNG_LAST]; |
7990 bcopy (png_format, fmt, sizeof fmt); | 7977 bcopy (png_format, fmt, sizeof fmt); |
7991 | 7978 |
7992 if (!parse_image_spec (object, fmt, PNG_LAST, Qpng, 1) | 7979 if (!parse_image_spec (object, fmt, PNG_LAST, Qpng) |
7993 || (fmt[PNG_ASCENT].count | 7980 || (fmt[PNG_ASCENT].count |
7994 && XFASTINT (fmt[PNG_ASCENT].value) > 100)) | 7981 && XFASTINT (fmt[PNG_ASCENT].value) > 100)) |
7995 return 0; | 7982 return 0; |
7996 return 1; | 7983 return 1; |
7997 } | 7984 } |
8408 { | 8395 { |
8409 struct image_keyword fmt[JPEG_LAST]; | 8396 struct image_keyword fmt[JPEG_LAST]; |
8410 | 8397 |
8411 bcopy (jpeg_format, fmt, sizeof fmt); | 8398 bcopy (jpeg_format, fmt, sizeof fmt); |
8412 | 8399 |
8413 if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg, 0) | 8400 if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg) |
8414 || (fmt[JPEG_ASCENT].count | 8401 || (fmt[JPEG_ASCENT].count |
8415 && XFASTINT (fmt[JPEG_ASCENT].value) > 100)) | 8402 && XFASTINT (fmt[JPEG_ASCENT].value) > 100)) |
8416 return 0; | 8403 return 0; |
8417 return 1; | 8404 return 1; |
8418 } | 8405 } |
8655 Lisp_Object object; | 8642 Lisp_Object object; |
8656 { | 8643 { |
8657 struct image_keyword fmt[TIFF_LAST]; | 8644 struct image_keyword fmt[TIFF_LAST]; |
8658 bcopy (tiff_format, fmt, sizeof fmt); | 8645 bcopy (tiff_format, fmt, sizeof fmt); |
8659 | 8646 |
8660 if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff, 1) | 8647 if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff) |
8661 || (fmt[TIFF_ASCENT].count | 8648 || (fmt[TIFF_ASCENT].count |
8662 && XFASTINT (fmt[TIFF_ASCENT].value) > 100)) | 8649 && XFASTINT (fmt[TIFF_ASCENT].value) > 100)) |
8663 return 0; | 8650 return 0; |
8664 return 1; | 8651 return 1; |
8665 } | 8652 } |
8831 Lisp_Object object; | 8818 Lisp_Object object; |
8832 { | 8819 { |
8833 struct image_keyword fmt[GIF_LAST]; | 8820 struct image_keyword fmt[GIF_LAST]; |
8834 bcopy (gif_format, fmt, sizeof fmt); | 8821 bcopy (gif_format, fmt, sizeof fmt); |
8835 | 8822 |
8836 if (!parse_image_spec (object, fmt, GIF_LAST, Qgif, 1) | 8823 if (!parse_image_spec (object, fmt, GIF_LAST, Qgif) |
8837 || (fmt[GIF_ASCENT].count | 8824 || (fmt[GIF_ASCENT].count |
8838 && XFASTINT (fmt[GIF_ASCENT].value) > 100)) | 8825 && XFASTINT (fmt[GIF_ASCENT].value) > 100)) |
8839 return 0; | 8826 return 0; |
8840 return 1; | 8827 return 1; |
8841 } | 8828 } |
9100 Lisp_Object tem; | 9087 Lisp_Object tem; |
9101 int i; | 9088 int i; |
9102 | 9089 |
9103 bcopy (gs_format, fmt, sizeof fmt); | 9090 bcopy (gs_format, fmt, sizeof fmt); |
9104 | 9091 |
9105 if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript, 1) | 9092 if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript) |
9106 || (fmt[GS_ASCENT].count | 9093 || (fmt[GS_ASCENT].count |
9107 && XFASTINT (fmt[GS_ASCENT].value) > 100)) | 9094 && XFASTINT (fmt[GS_ASCENT].value) > 100)) |
9108 return 0; | 9095 return 0; |
9109 | 9096 |
9110 /* Bounding box must be a list or vector containing 4 integers. */ | 9097 /* Bounding box must be a list or vector containing 4 integers. */ |
10426 staticpro (&QCpt_width); | 10413 staticpro (&QCpt_width); |
10427 QCpt_height = intern (":pt-height"); | 10414 QCpt_height = intern (":pt-height"); |
10428 staticpro (&QCpt_height); | 10415 staticpro (&QCpt_height); |
10429 QCindex = intern (":index"); | 10416 QCindex = intern (":index"); |
10430 staticpro (&QCindex); | 10417 staticpro (&QCindex); |
10431 QCuser_data = intern (":user-data"); | |
10432 staticpro (&QCuser_data); | |
10433 Qpbm = intern ("pbm"); | 10418 Qpbm = intern ("pbm"); |
10434 staticpro (&Qpbm); | 10419 staticpro (&Qpbm); |
10435 | 10420 |
10436 #if HAVE_XPM | 10421 #if HAVE_XPM |
10437 Qxpm = intern ("xpm"); | 10422 Qxpm = intern ("xpm"); |