diff options
| -rw-r--r-- | src/fns.c | 100 |
1 files changed, 96 insertions, 4 deletions
| @@ -30,11 +30,10 @@ Boston, MA 02111-1307, USA. */ | |||
| 30 | so make sure we don't use that name in this file. */ | 30 | so make sure we don't use that name in this file. */ |
| 31 | #undef vector | 31 | #undef vector |
| 32 | #define vector ***** | 32 | #define vector ***** |
| 33 | |||
| 34 | #include "lisp.h" | 33 | #include "lisp.h" |
| 35 | #include "commands.h" | 34 | #include "commands.h" |
| 36 | #include "charset.h" | 35 | #include "charset.h" |
| 37 | 36 | #include "coding.h" | |
| 38 | #include "buffer.h" | 37 | #include "buffer.h" |
| 39 | #include "keyboard.h" | 38 | #include "keyboard.h" |
| 40 | #include "keymap.h" | 39 | #include "keymap.h" |
| @@ -47,7 +46,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 47 | #endif | 46 | #endif |
| 48 | 47 | ||
| 49 | #ifndef NULL | 48 | #ifndef NULL |
| 50 | #define NULL (void *)0 | 49 | #define NULL ((POINTER_TYPE *)0) |
| 51 | #endif | 50 | #endif |
| 52 | 51 | ||
| 53 | /* Nonzero enables use of dialog boxes for questions | 52 | /* Nonzero enables use of dialog boxes for questions |
| @@ -56,11 +55,13 @@ int use_dialog_box; | |||
| 56 | 55 | ||
| 57 | extern int minibuffer_auto_raise; | 56 | extern int minibuffer_auto_raise; |
| 58 | extern Lisp_Object minibuf_window; | 57 | extern Lisp_Object minibuf_window; |
| 58 | extern Lisp_Object Vlocale_coding_system; | ||
| 59 | 59 | ||
| 60 | Lisp_Object Qstring_lessp, Qprovide, Qrequire; | 60 | Lisp_Object Qstring_lessp, Qprovide, Qrequire; |
| 61 | Lisp_Object Qyes_or_no_p_history; | 61 | Lisp_Object Qyes_or_no_p_history; |
| 62 | Lisp_Object Qcursor_in_echo_area; | 62 | Lisp_Object Qcursor_in_echo_area; |
| 63 | Lisp_Object Qwidget_type; | 63 | Lisp_Object Qwidget_type; |
| 64 | Lisp_Object Qcodeset, Qdays, Qmonths, Qpaper; | ||
| 64 | 65 | ||
| 65 | extern Lisp_Object Qinput_method_function; | 66 | extern Lisp_Object Qinput_method_function; |
| 66 | 67 | ||
| @@ -2659,7 +2660,7 @@ The key is always a possible IDX argument to `aref'. */) | |||
| 2659 | 2660 | ||
| 2660 | CHECK_CHAR_TABLE (char_table); | 2661 | CHECK_CHAR_TABLE (char_table); |
| 2661 | 2662 | ||
| 2662 | map_char_table ((void *) call2, Qnil, char_table, function, 0, indices); | 2663 | map_char_table ((POINTER_TYPE *) call2, Qnil, char_table, function, 0, indices); |
| 2663 | return Qnil; | 2664 | return Qnil; |
| 2664 | } | 2665 | } |
| 2665 | 2666 | ||
| @@ -3389,6 +3390,85 @@ usage: (widget-apply WIDGET PROPERTY &rest ARGS) */) | |||
| 3389 | UNGCPRO; | 3390 | UNGCPRO; |
| 3390 | return result; | 3391 | return result; |
| 3391 | } | 3392 | } |
| 3393 | |||
| 3394 | #ifdef HAVE_LANGINFO_CODESET | ||
| 3395 | #include <langinfo.h> | ||
| 3396 | #endif | ||
| 3397 | |||
| 3398 | DEFUN ("langinfo", Flanginfo, Slanginfo, 1, 1, 0, | ||
| 3399 | doc: /* Access locale category ITEM, if available. | ||
| 3400 | |||
| 3401 | ITEM may be one of the following: | ||
| 3402 | `codeset', returning the character set as a string (CODESET); | ||
| 3403 | `days', returning a 7-element vector of day names (DAY_n); | ||
| 3404 | `months', returning a 12-element vector of month names (MON_n). | ||
| 3405 | |||
| 3406 | If the system can't provide such information through a call to | ||
| 3407 | nl_langinfo(3), return nil. | ||
| 3408 | |||
| 3409 | The data read from the system are decoded using `locale-coding-system'. */) | ||
| 3410 | (item) | ||
| 3411 | Lisp_Object item; | ||
| 3412 | { | ||
| 3413 | char *str = NULL; | ||
| 3414 | #ifdef HAVE_LANGINFO_CODESET | ||
| 3415 | Lisp_Object val; | ||
| 3416 | if (EQ (item, Qcodeset)) | ||
| 3417 | { | ||
| 3418 | str = nl_langinfo (CODESET); | ||
| 3419 | return build_string (str); | ||
| 3420 | } | ||
| 3421 | #ifdef DAY_1 | ||
| 3422 | else if (EQ (item, Qdays)) /* e.g. for calendar-day-name-array */ | ||
| 3423 | { | ||
| 3424 | Lisp_Object v = Fmake_vector (make_number (7), Qnil); | ||
| 3425 | int days[7] = {DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, DAY_6, DAY_7}; | ||
| 3426 | int i; | ||
| 3427 | synchronize_system_time_locale (); | ||
| 3428 | for (i = 0; i < 7; i++) | ||
| 3429 | { | ||
| 3430 | str = nl_langinfo (days[i]); | ||
| 3431 | val = make_unibyte_string (str, strlen (str)); | ||
| 3432 | /* Fixme: Is this coding system necessarily right, even if | ||
| 3433 | it is consistent with CODESET? If not, what to do? */ | ||
| 3434 | Faset (v, make_number (i), | ||
| 3435 | code_convert_string_norecord (val, Vlocale_coding_system, | ||
| 3436 | Qnil)); | ||
| 3437 | } | ||
| 3438 | return v; | ||
| 3439 | } | ||
| 3440 | #endif /* DAY_1 */ | ||
| 3441 | #ifdef MON_1 | ||
| 3442 | else if (EQ (item, Qmonths)) /* e.g. for calendar-month-name-array */ | ||
| 3443 | { | ||
| 3444 | struct Lisp_Vector *p = allocate_vector (12); | ||
| 3445 | int months[12] = {MON_1, MON_2, MON_3, MON_4, MON_5, MON_6, MON_7, | ||
| 3446 | MON_8, MON_9, MON_10, MON_11, MON_12}; | ||
| 3447 | int i; | ||
| 3448 | synchronize_system_time_locale (); | ||
| 3449 | for (i = 0; i < 12; i++) | ||
| 3450 | { | ||
| 3451 | str = nl_langinfo (months[i]); | ||
| 3452 | val = make_unibyte_string (str, strlen (str)); | ||
| 3453 | p->contents[i] = | ||
| 3454 | code_convert_string_norecord (val, Vlocale_coding_system, Qnil); | ||
| 3455 | } | ||
| 3456 | XSETVECTOR (val, p); | ||
| 3457 | return val; | ||
| 3458 | } | ||
| 3459 | #endif /* MON_1 */ | ||
| 3460 | /* LC_PAPER stuff isn't defined as accessible in glibc as of 2.3.1, | ||
| 3461 | but is in the locale files. This could be used by ps-print. */ | ||
| 3462 | #ifdef PAPER_WIDTH | ||
| 3463 | else if (EQ (item, Qpaper)) | ||
| 3464 | { | ||
| 3465 | return list2 (make_number (nl_langinfo (PAPER_WIDTH)), | ||
| 3466 | make_number (nl_langinfo (PAPER_HEIGHT))); | ||
| 3467 | } | ||
| 3468 | #endif /* PAPER_WIDTH */ | ||
| 3469 | #endif /* HAVE_LANGINFO_CODESET*/ | ||
| 3470 | return Qnil; | ||
| 3471 | } | ||
| 3392 | 3472 | ||
| 3393 | /* base64 encode/decode functions (RFC 2045). | 3473 | /* base64 encode/decode functions (RFC 2045). |
| 3394 | Based on code from GNU recode. */ | 3474 | Based on code from GNU recode. */ |
| @@ -5429,6 +5509,17 @@ Used by `featurep' and `require', and altered by `provide'. */); | |||
| 5429 | Qsubfeatures = intern ("subfeatures"); | 5509 | Qsubfeatures = intern ("subfeatures"); |
| 5430 | staticpro (&Qsubfeatures); | 5510 | staticpro (&Qsubfeatures); |
| 5431 | 5511 | ||
| 5512 | #ifdef HAVE_LANGINFO_CODESET | ||
| 5513 | Qcodeset = intern ("codeset"); | ||
| 5514 | staticpro (&Qcodeset); | ||
| 5515 | Qdays = intern ("days"); | ||
| 5516 | staticpro (&Qdays); | ||
| 5517 | Qmonths = intern ("months"); | ||
| 5518 | staticpro (&Qmonths); | ||
| 5519 | Qpaper = intern ("paper"); | ||
| 5520 | staticpro (&Qpaper); | ||
| 5521 | #endif /* HAVE_LANGINFO_CODESET */ | ||
| 5522 | |||
| 5432 | DEFVAR_BOOL ("use-dialog-box", &use_dialog_box, | 5523 | DEFVAR_BOOL ("use-dialog-box", &use_dialog_box, |
| 5433 | doc: /* *Non-nil means mouse commands use dialog boxes to ask questions. | 5524 | doc: /* *Non-nil means mouse commands use dialog boxes to ask questions. |
| 5434 | This applies to `y-or-n-p' and `yes-or-no-p' questions asked by commands | 5525 | This applies to `y-or-n-p' and `yes-or-no-p' questions asked by commands |
| @@ -5505,6 +5596,7 @@ invoked by mouse clicks and mouse menu items. */); | |||
| 5505 | defsubr (&Sbase64_encode_string); | 5596 | defsubr (&Sbase64_encode_string); |
| 5506 | defsubr (&Sbase64_decode_string); | 5597 | defsubr (&Sbase64_decode_string); |
| 5507 | defsubr (&Smd5); | 5598 | defsubr (&Smd5); |
| 5599 | defsubr (&Slanginfo); | ||
| 5508 | } | 5600 | } |
| 5509 | 5601 | ||
| 5510 | 5602 | ||