Mercurial > hg > xemacs-beta
comparison src/fns.c @ 563:183866b06e0b
[xemacs-hg @ 2001-05-24 07:50:48 by ben]
Makefile.in.in, abbrev.c, alloc.c, buffer.c, bytecode.c, callint.c, callproc.c, casetab.c, chartab.c, cmdloop.c, cmds.c, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console.c, data.c, database.c, debug.c, device-gtk.c, device-msw.c, device-tty.c, device-x.c, device.c, dialog-gtk.c, dialog-msw.c, dialog-x.c, dialog.c, dired-msw.c, dired.c, doc.c, doprnt.c, dragdrop.c, editfns.c, eldap.c, eldap.h, elhash.c, emacs-widget-accessors.c, emacs.c, emodules.c, esd.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, filelock.c, floatfns.c, fns.c, font-lock.c, frame-gtk.c, frame-x.c, frame.c, general-slots.h, glade.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-gtk.c, gui-x.c, gui.c, gutter.c, hpplay.c, indent.c, input-method-xlib.c, insdel.c, intl.c, keymap.c, libsst.c, libsst.h, linuxplay.c, lisp.h, lread.c, lstream.c, lstream.h, macros.c, marker.c, md5.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, miscplay.c, miscplay.h, mule-ccl.c, mule-charset.c, mule-wnnfns.c, mule.c, nas.c, ntplay.c, ntproc.c, objects-gtk.c, objects-msw.c, objects-x.c, objects.c, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, ralloc.c, rangetab.c, redisplay.c, scrollbar.c, search.c, select-gtk.c, select-x.c, select.c, sgiplay.c, sheap.c, sound.c, specifier.c, sunplay.c, symbols.c, symeval.h, symsinit.h, syntax.c, sysdep.c, toolbar-msw.c, toolbar.c, tooltalk.c, ui-byhand.c, ui-gtk.c, undo.c, unexaix.c, unexapollo.c, unexconvex.c, unexec.c, widget.c, win32.c, window.c:
-- defsymbol -> DEFSYMBOL.
-- add an error type to all errors.
-- eliminate the error functions in eval.c that let you just
use Qerror as the type.
-- redo the error API to be more consistent, sensibly named,
and easier to use.
-- redo the error hierarchy somewhat. create new errors:
structure-formation-error, gui-error, invalid-constant,
stack-overflow, out-of-memory, process-error, network-error,
sound-error, printing-unreadable-object, base64-conversion-
error; coding-system-error renamed to text-conversion error;
some others.
-- fix Mule problems in error strings in emodules.c, tooltalk.c.
-- fix error handling in mswin open-network-stream.
-- Mule-ize all sound files and clean up the headers.
-- nativesound.h -> sound.h and used for all sound files.
-- move some shared stuff into glyphs-shared.c: first attempt
at eliminating some of the massive GTK code duplication.
xemacs.mak: add glyphs-shared.c.
xemacs-faq.texi: document how to debug X errors
subr.el: fix doc string to reflect reality
author | ben |
---|---|
date | Thu, 24 May 2001 07:51:33 +0000 |
parents | e7ef97881643 |
children | d5e8f5ad5043 |
comparison
equal
deleted
inserted
replaced
562:c775bd016b32 | 563:183866b06e0b |
---|---|
52 /* NOTE: This symbol is also used in lread.c */ | 52 /* NOTE: This symbol is also used in lread.c */ |
53 #define FEATUREP_SYNTAX | 53 #define FEATUREP_SYNTAX |
54 | 54 |
55 Lisp_Object Qstring_lessp; | 55 Lisp_Object Qstring_lessp; |
56 Lisp_Object Qidentity; | 56 Lisp_Object Qidentity; |
57 | |
58 Lisp_Object Qbase64_conversion_error; | |
57 | 59 |
58 static int internal_old_equal (Lisp_Object, Lisp_Object, int); | 60 static int internal_old_equal (Lisp_Object, Lisp_Object, int); |
59 Lisp_Object safe_copy_tree (Lisp_Object arg, Lisp_Object vecp, int depth); | 61 Lisp_Object safe_copy_tree (Lisp_Object arg, Lisp_Object vecp, int depth); |
60 | 62 |
61 static Lisp_Object | 63 static Lisp_Object |
203 | 205 |
204 void | 206 void |
205 check_losing_bytecode (const char *function, Lisp_Object seq) | 207 check_losing_bytecode (const char *function, Lisp_Object seq) |
206 { | 208 { |
207 if (COMPILED_FUNCTIONP (seq)) | 209 if (COMPILED_FUNCTIONP (seq)) |
208 error_with_frob | 210 signal_ferror_with_frob |
209 (seq, | 211 (Qinvalid_argument, seq, |
210 "As of 20.3, `%s' no longer works with compiled-function objects", | 212 "As of 20.3, `%s' no longer works with compiled-function objects", |
211 function); | 213 function); |
212 } | 214 } |
213 | 215 |
214 DEFUN ("length", Flength, 1, 1, 0, /* | 216 DEFUN ("length", Flength, 1, 1, 0, /* |
869 | 871 |
870 Lisp_Object | 872 Lisp_Object |
871 safe_copy_tree (Lisp_Object arg, Lisp_Object vecp, int depth) | 873 safe_copy_tree (Lisp_Object arg, Lisp_Object vecp, int depth) |
872 { | 874 { |
873 if (depth > 200) | 875 if (depth > 200) |
874 signal_simple_error ("Stack overflow in copy-tree", arg); | 876 stack_overflow ("Stack overflow in copy-tree", arg); |
875 | 877 |
876 if (CONSP (arg)) | 878 if (CONSP (arg)) |
877 { | 879 { |
878 Lisp_Object rest; | 880 Lisp_Object rest; |
879 rest = arg = Fcopy_sequence (arg); | 881 rest = arg = Fcopy_sequence (arg); |
2567 Lisp_Object val; | 2569 Lisp_Object val; |
2568 | 2570 |
2569 if (LRECORDP (object) && XRECORD_LHEADER_IMPLEMENTATION (object)->getprop) | 2571 if (LRECORDP (object) && XRECORD_LHEADER_IMPLEMENTATION (object)->getprop) |
2570 val = XRECORD_LHEADER_IMPLEMENTATION (object)->getprop (object, property); | 2572 val = XRECORD_LHEADER_IMPLEMENTATION (object)->getprop (object, property); |
2571 else | 2573 else |
2572 signal_simple_error ("Object type has no properties", object); | 2574 invalid_operation ("Object type has no properties", object); |
2573 | 2575 |
2574 return UNBOUNDP (val) ? default_ : val; | 2576 return UNBOUNDP (val) ? default_ : val; |
2575 } | 2577 } |
2576 | 2578 |
2577 DEFUN ("put", Fput, 3, 3, 0, /* | 2579 DEFUN ("put", Fput, 3, 3, 0, /* |
2589 | 2591 |
2590 if (LRECORDP (object) && XRECORD_LHEADER_IMPLEMENTATION (object)->putprop) | 2592 if (LRECORDP (object) && XRECORD_LHEADER_IMPLEMENTATION (object)->putprop) |
2591 { | 2593 { |
2592 if (! XRECORD_LHEADER_IMPLEMENTATION (object)->putprop | 2594 if (! XRECORD_LHEADER_IMPLEMENTATION (object)->putprop |
2593 (object, property, value)) | 2595 (object, property, value)) |
2594 signal_simple_error ("Can't set property on object", property); | 2596 invalid_change ("Can't set property on object", property); |
2595 } | 2597 } |
2596 else | 2598 else |
2597 signal_simple_error ("Object type has no settable properties", object); | 2599 invalid_change ("Object type has no settable properties", object); |
2598 | 2600 |
2599 return value; | 2601 return value; |
2600 } | 2602 } |
2601 | 2603 |
2602 DEFUN ("remprop", Fremprop, 2, 2, 0, /* | 2604 DEFUN ("remprop", Fremprop, 2, 2, 0, /* |
2613 | 2615 |
2614 if (LRECORDP (object) && XRECORD_LHEADER_IMPLEMENTATION (object)->remprop) | 2616 if (LRECORDP (object) && XRECORD_LHEADER_IMPLEMENTATION (object)->remprop) |
2615 { | 2617 { |
2616 ret = XRECORD_LHEADER_IMPLEMENTATION (object)->remprop (object, property); | 2618 ret = XRECORD_LHEADER_IMPLEMENTATION (object)->remprop (object, property); |
2617 if (ret == -1) | 2619 if (ret == -1) |
2618 signal_simple_error ("Can't remove property from object", property); | 2620 invalid_change ("Can't remove property from object", property); |
2619 } | 2621 } |
2620 else | 2622 else |
2621 signal_simple_error ("Object type has no removable properties", object); | 2623 invalid_change ("Object type has no removable properties", object); |
2622 | 2624 |
2623 return ret ? Qt : Qnil; | 2625 return ret ? Qt : Qnil; |
2624 } | 2626 } |
2625 | 2627 |
2626 DEFUN ("object-plist", Fobject_plist, 1, 1, 0, /* | 2628 DEFUN ("object-plist", Fobject_plist, 1, 1, 0, /* |
2633 (object)) | 2635 (object)) |
2634 { | 2636 { |
2635 if (LRECORDP (object) && XRECORD_LHEADER_IMPLEMENTATION (object)->plist) | 2637 if (LRECORDP (object) && XRECORD_LHEADER_IMPLEMENTATION (object)->plist) |
2636 return XRECORD_LHEADER_IMPLEMENTATION (object)->plist (object); | 2638 return XRECORD_LHEADER_IMPLEMENTATION (object)->plist (object); |
2637 else | 2639 else |
2638 signal_simple_error ("Object type has no properties", object); | 2640 invalid_operation ("Object type has no properties", object); |
2639 | 2641 |
2640 return Qnil; | 2642 return Qnil; |
2641 } | 2643 } |
2642 | 2644 |
2643 | 2645 |
2644 int | 2646 int |
2645 internal_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) | 2647 internal_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) |
2646 { | 2648 { |
2647 if (depth > 200) | 2649 if (depth > 200) |
2648 error ("Stack overflow in equal"); | 2650 stack_overflow ("Stack overflow in equal", Qunbound); |
2649 QUIT; | 2651 QUIT; |
2650 if (EQ_WITH_EBOLA_NOTICE (obj1, obj2)) | 2652 if (EQ_WITH_EBOLA_NOTICE (obj1, obj2)) |
2651 return 1; | 2653 return 1; |
2652 /* Note that (equal 20 20.0) should be nil */ | 2654 /* Note that (equal 20 20.0) should be nil */ |
2653 if (XTYPE (obj1) != XTYPE (obj2)) | 2655 if (XTYPE (obj1) != XTYPE (obj2)) |
2673 | 2675 |
2674 static int | 2676 static int |
2675 internal_old_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) | 2677 internal_old_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) |
2676 { | 2678 { |
2677 if (depth > 200) | 2679 if (depth > 200) |
2678 error ("Stack overflow in equal"); | 2680 stack_overflow ("Stack overflow in equal", Qunbound); |
2679 QUIT; | 2681 QUIT; |
2680 if (HACKEQ_UNSAFE (obj1, obj2)) | 2682 if (HACKEQ_UNSAFE (obj1, obj2)) |
2681 return 1; | 2683 return 1; |
2682 /* Note that (equal 20 20.0) should be nil */ | 2684 /* Note that (equal 20 20.0) should be nil */ |
2683 if (XTYPE (obj1) != XTYPE (obj2)) | 2685 if (XTYPE (obj1) != XTYPE (obj2)) |
3176 double load_ave[3]; | 3178 double load_ave[3]; |
3177 int loads = getloadavg (load_ave, countof (load_ave)); | 3179 int loads = getloadavg (load_ave, countof (load_ave)); |
3178 Lisp_Object ret = Qnil; | 3180 Lisp_Object ret = Qnil; |
3179 | 3181 |
3180 if (loads == -2) | 3182 if (loads == -2) |
3181 error ("load-average not implemented for this operating system"); | 3183 signal_error (Qunimplemented, |
3184 "load-average not implemented for this operating system", | |
3185 Qunbound); | |
3182 else if (loads < 0) | 3186 else if (loads < 0) |
3183 signal_simple_error ("Could not get load-average", | 3187 invalid_operation ("Could not get load-average", lisp_strerror (errno)); |
3184 lisp_strerror (errno)); | |
3185 | 3188 |
3186 while (loads-- > 0) | 3189 while (loads-- > 0) |
3187 { | 3190 { |
3188 Lisp_Object load = (NILP (use_floats) ? | 3191 Lisp_Object load = (NILP (use_floats) ? |
3189 make_int ((int) (100.0 * load_ave[loads])) | 3192 make_int ((int) (100.0 * load_ave[loads])) |
3347 call4 (Qload, NILP (filename) ? Fsymbol_name (feature) : filename, | 3350 call4 (Qload, NILP (filename) ? Fsymbol_name (feature) : filename, |
3348 Qnil, Qt, Qnil); | 3351 Qnil, Qt, Qnil); |
3349 | 3352 |
3350 tem = Fmemq (feature, Vfeatures); | 3353 tem = Fmemq (feature, Vfeatures); |
3351 if (NILP (tem)) | 3354 if (NILP (tem)) |
3352 error ("Required feature %s was not provided", | 3355 invalid_state ("Required feature was not provided", feature); |
3353 string_data (XSYMBOL (feature)->name)); | |
3354 | 3356 |
3355 /* Once loading finishes, don't undo it. */ | 3357 /* Once loading finishes, don't undo it. */ |
3356 Vautoload_queue = Qt; | 3358 Vautoload_queue = Qt; |
3357 return unbind_to (speccount, feature); | 3359 return unbind_to (speccount, feature); |
3358 } | 3360 } |
3417 `--------+--------+--------+--------' | 3419 `--------+--------+--------+--------' |
3418 | 3420 |
3419 The octets are divided into 6 bit chunks, which are then encoded into | 3421 The octets are divided into 6 bit chunks, which are then encoded into |
3420 base64 characters. */ | 3422 base64 characters. */ |
3421 | 3423 |
3422 #define ADVANCE_INPUT(c, stream) \ | 3424 DOESNT_RETURN |
3423 ((ec = Lstream_get_emchar (stream)) == -1 ? 0 : \ | 3425 base64_conversion_error (const char *reason, Lisp_Object frob) |
3424 ((ec > 255) ? \ | 3426 { |
3425 (signal_simple_error ("Non-ascii character in base64 input", \ | 3427 signal_error (Qbase64_conversion_error, reason, frob); |
3426 make_char (ec)), 0) \ | 3428 } |
3429 | |
3430 #define ADVANCE_INPUT(c, stream) \ | |
3431 ((ec = Lstream_get_emchar (stream)) == -1 ? 0 : \ | |
3432 ((ec > 255) ? \ | |
3433 (base64_conversion_error ("Non-ascii character in base64 input", \ | |
3434 make_char (ec)), 0) \ | |
3427 : (c = (Bufbyte)ec), 1)) | 3435 : (c = (Bufbyte)ec), 1)) |
3428 | 3436 |
3429 static Bytind | 3437 static Bytind |
3430 base64_encode_1 (Lstream *istream, Bufbyte *to, int line_break) | 3438 base64_encode_1 (Lstream *istream, Bufbyte *to, int line_break) |
3431 { | 3439 { |
3516 /* Process first byte of a quadruplet. */ | 3524 /* Process first byte of a quadruplet. */ |
3517 ADVANCE_INPUT_IGNORE_NONBASE64 (ec, istream, streampos); | 3525 ADVANCE_INPUT_IGNORE_NONBASE64 (ec, istream, streampos); |
3518 if (ec < 0) | 3526 if (ec < 0) |
3519 break; | 3527 break; |
3520 if (ec == '=') | 3528 if (ec == '=') |
3521 signal_simple_error ("Illegal `=' character while decoding base64", | 3529 base64_conversion_error ("Illegal `=' character while decoding base64", |
3522 make_int (streampos)); | 3530 make_int (streampos)); |
3523 value = base64_char_to_value[ec] << 18; | 3531 value = base64_char_to_value[ec] << 18; |
3524 | 3532 |
3525 /* Process second byte of a quadruplet. */ | 3533 /* Process second byte of a quadruplet. */ |
3526 ADVANCE_INPUT_IGNORE_NONBASE64 (ec, istream, streampos); | 3534 ADVANCE_INPUT_IGNORE_NONBASE64 (ec, istream, streampos); |
3527 if (ec < 0) | 3535 if (ec < 0) |
3528 error ("Premature EOF while decoding base64"); | 3536 base64_conversion_error ("Premature EOF while decoding base64", |
3537 Qunbound); | |
3529 if (ec == '=') | 3538 if (ec == '=') |
3530 signal_simple_error ("Illegal `=' character while decoding base64", | 3539 base64_conversion_error ("Illegal `=' character while decoding base64", |
3531 make_int (streampos)); | 3540 make_int (streampos)); |
3532 value |= base64_char_to_value[ec] << 12; | 3541 value |= base64_char_to_value[ec] << 12; |
3533 STORE_BYTE (e, value >> 16, ccnt); | 3542 STORE_BYTE (e, value >> 16, ccnt); |
3534 | 3543 |
3535 /* Process third byte of a quadruplet. */ | 3544 /* Process third byte of a quadruplet. */ |
3536 ADVANCE_INPUT_IGNORE_NONBASE64 (ec, istream, streampos); | 3545 ADVANCE_INPUT_IGNORE_NONBASE64 (ec, istream, streampos); |
3537 if (ec < 0) | 3546 if (ec < 0) |
3538 error ("Premature EOF while decoding base64"); | 3547 base64_conversion_error ("Premature EOF while decoding base64", |
3548 Qunbound); | |
3539 | 3549 |
3540 if (ec == '=') | 3550 if (ec == '=') |
3541 { | 3551 { |
3542 ADVANCE_INPUT_IGNORE_NONBASE64 (ec, istream, streampos); | 3552 ADVANCE_INPUT_IGNORE_NONBASE64 (ec, istream, streampos); |
3543 if (ec < 0) | 3553 if (ec < 0) |
3544 error ("Premature EOF while decoding base64"); | 3554 base64_conversion_error ("Premature EOF while decoding base64", |
3555 Qunbound); | |
3545 if (ec != '=') | 3556 if (ec != '=') |
3546 signal_simple_error ("Padding `=' expected but not found while decoding base64", | 3557 base64_conversion_error |
3547 make_int (streampos)); | 3558 ("Padding `=' expected but not found while decoding base64", |
3559 make_int (streampos)); | |
3548 continue; | 3560 continue; |
3549 } | 3561 } |
3550 | 3562 |
3551 value |= base64_char_to_value[ec] << 6; | 3563 value |= base64_char_to_value[ec] << 6; |
3552 STORE_BYTE (e, 0xff & value >> 8, ccnt); | 3564 STORE_BYTE (e, 0xff & value >> 8, ccnt); |
3553 | 3565 |
3554 /* Process fourth byte of a quadruplet. */ | 3566 /* Process fourth byte of a quadruplet. */ |
3555 ADVANCE_INPUT_IGNORE_NONBASE64 (ec, istream, streampos); | 3567 ADVANCE_INPUT_IGNORE_NONBASE64 (ec, istream, streampos); |
3556 if (ec < 0) | 3568 if (ec < 0) |
3557 error ("Premature EOF while decoding base64"); | 3569 base64_conversion_error ("Premature EOF while decoding base64", |
3570 Qunbound); | |
3558 if (ec == '=') | 3571 if (ec == '=') |
3559 continue; | 3572 continue; |
3560 | 3573 |
3561 value |= base64_char_to_value[ec]; | 3574 value |= base64_char_to_value[ec]; |
3562 STORE_BYTE (e, 0xff & value, ccnt); | 3575 STORE_BYTE (e, 0xff & value, ccnt); |
3764 void | 3777 void |
3765 syms_of_fns (void) | 3778 syms_of_fns (void) |
3766 { | 3779 { |
3767 INIT_LRECORD_IMPLEMENTATION (bit_vector); | 3780 INIT_LRECORD_IMPLEMENTATION (bit_vector); |
3768 | 3781 |
3769 defsymbol (&Qstring_lessp, "string-lessp"); | 3782 DEFSYMBOL (Qstring_lessp); |
3770 defsymbol (&Qidentity, "identity"); | 3783 DEFSYMBOL (Qidentity); |
3771 defsymbol (&Qyes_or_no_p, "yes-or-no-p"); | 3784 DEFSYMBOL (Qyes_or_no_p); |
3785 | |
3786 DEFERROR_STANDARD (Qbase64_conversion_error, Qconversion_error); | |
3772 | 3787 |
3773 DEFSUBR (Fidentity); | 3788 DEFSUBR (Fidentity); |
3774 DEFSUBR (Frandom); | 3789 DEFSUBR (Frandom); |
3775 DEFSUBR (Flength); | 3790 DEFSUBR (Flength); |
3776 DEFSUBR (Fsafe_length); | 3791 DEFSUBR (Fsafe_length); |