Mercurial > emacs
comparison src/xterm.c @ 3558:f7f187debe2d
(x_caught_error_message): Change type to char* from char*[].
(X_CAUGHT_ERROR_MESSAGE_SIZE): New macro.
(x_error_catcher): Corresponding changes.
(x_catch_errors): Corresponding changes.
(x_check_errors): Do not free x_caught_error_message.
(x_uncatch_errors): Set x_caught_error_message to 0 after freeing it.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 07 Jun 1993 23:52:45 +0000 |
parents | 21fae09a3ad2 |
children | 19aab2d09a4d |
comparison
equal
deleted
inserted
replaced
3557:009b22e07a63 | 3558:f7f187debe2d |
---|---|
3799 | 3799 |
3800 x_connection_closed (); | 3800 x_connection_closed (); |
3801 } | 3801 } |
3802 | 3802 |
3803 /* A buffer for storing X error messages. */ | 3803 /* A buffer for storing X error messages. */ |
3804 static char (*x_caught_error_message)[200]; | 3804 static char *x_caught_error_message; |
3805 #define X_CAUGHT_ERROR_MESSAGE_SIZE 200 | |
3805 | 3806 |
3806 /* An X error handler which stores the error message in | 3807 /* An X error handler which stores the error message in |
3807 x_caught_error_message. This is what's installed when | 3808 x_caught_error_message. This is what's installed when |
3808 x_catch_errors is in effect. */ | 3809 x_catch_errors is in effect. */ |
3809 static int | 3810 static int |
3810 x_error_catcher (display, error) | 3811 x_error_catcher (display, error) |
3811 Display *display; | 3812 Display *display; |
3812 XErrorEvent *error; | 3813 XErrorEvent *error; |
3813 { | 3814 { |
3814 XGetErrorText (display, error->error_code, | 3815 XGetErrorText (display, error->error_code, |
3815 *x_caught_error_message, sizeof (*x_caught_error_message)); | 3816 x_caught_error_message, X_CAUGHT_ERROR_MESSAGE_SIZE); |
3816 } | 3817 } |
3817 | 3818 |
3818 | 3819 |
3819 /* Begin trapping X errors. | 3820 /* Begin trapping X errors. |
3820 | 3821 |
3834 /* Make sure any errors from previous requests have been dealt with. */ | 3835 /* Make sure any errors from previous requests have been dealt with. */ |
3835 XSync (x_current_display, False); | 3836 XSync (x_current_display, False); |
3836 | 3837 |
3837 /* Set up the error buffer. */ | 3838 /* Set up the error buffer. */ |
3838 x_caught_error_message | 3839 x_caught_error_message |
3839 = (char (*)[200]) xmalloc (sizeof (*x_caught_error_message)); | 3840 = (char*) xmalloc (X_CAUGHT_ERROR_MESSAGE_SIZE); |
3840 (*x_caught_error_message)[0] = '\0'; | 3841 x_caught_error_message[0] = '\0'; |
3841 | 3842 |
3842 /* Install our little error handler. */ | 3843 /* Install our little error handler. */ |
3843 XHandleError (x_error_catcher); | 3844 XHandleError (x_error_catcher); |
3844 } | 3845 } |
3845 | 3846 |
3851 char *format; | 3852 char *format; |
3852 { | 3853 { |
3853 /* Make sure to catch any errors incurred so far. */ | 3854 /* Make sure to catch any errors incurred so far. */ |
3854 XSync (x_current_display, False); | 3855 XSync (x_current_display, False); |
3855 | 3856 |
3856 if ((*x_caught_error_message)[0]) | 3857 if (x_caught_error_message[0]) |
3857 { | 3858 { |
3858 char buf[256]; | 3859 char buf[X_CAUGHT_ERROR_MESSAGE_SIZE + 56]; |
3859 | 3860 |
3860 sprintf (buf, format, *x_caught_error_message); | 3861 sprintf (buf, format, x_caught_error_message); |
3861 xfree (x_caught_error_message); | |
3862 | |
3863 x_uncatch_errors (); | 3862 x_uncatch_errors (); |
3864 error (buf); | 3863 error (buf); |
3865 } | 3864 } |
3866 } | 3865 } |
3867 | 3866 |
3868 void | 3867 void |
3869 x_uncatch_errors () | 3868 x_uncatch_errors () |
3870 { | 3869 { |
3871 xfree (x_caught_error_message); | 3870 xfree (x_caught_error_message); |
3871 x_caught_error_message = 0; | |
3872 XHandleError (x_error_quitter); | 3872 XHandleError (x_error_quitter); |
3873 } | 3873 } |
3874 | 3874 |
3875 #if 0 | 3875 #if 0 |
3876 static unsigned int x_wire_count; | 3876 static unsigned int x_wire_count; |