diff options
| author | Stephen Leake | 2019-04-14 09:24:42 -0700 |
|---|---|---|
| committer | Stephen Leake | 2019-04-14 09:24:42 -0700 |
| commit | 5ee5895f9b7b829783bc0f217095748076cc77e9 (patch) | |
| tree | 82eb5163502b447425eba24d2d368e878813ab77 /src | |
| parent | ca449fb1c1f86589cbf4da49cda1750ffdb2cad4 (diff) | |
| parent | 890440a44cd5f4f09742f521c7783785d114fffc (diff) | |
| download | emacs-5ee5895f9b7b829783bc0f217095748076cc77e9.tar.gz emacs-5ee5895f9b7b829783bc0f217095748076cc77e9.zip | |
Merge commit '890440a44cd5f4f09742f521c7783785d114fffc'
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs.c | 9 | ||||
| -rw-r--r-- | src/json.c | 116 | ||||
| -rw-r--r-- | src/minibuf.c | 3 | ||||
| -rw-r--r-- | src/xfns.c | 2 | ||||
| -rw-r--r-- | src/xterm.c | 9 |
5 files changed, 110 insertions, 29 deletions
diff --git a/src/emacs.c b/src/emacs.c index 68835cac985..6ed4b0ed87a 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -157,9 +157,14 @@ static uprintmax_t heap_bss_diff; | |||
| 157 | /* To run as a background daemon under Cocoa or Windows, | 157 | /* To run as a background daemon under Cocoa or Windows, |
| 158 | we must do a fork+exec, not a simple fork. | 158 | we must do a fork+exec, not a simple fork. |
| 159 | 159 | ||
| 160 | On Cocoa, CoreFoundation lib fails in forked process: | 160 | On Cocoa, CoreFoundation lib fails in forked process, see Mac OS X |
| 161 | Leopard Developer Release Notes for CoreFoundation Framework: | ||
| 162 | |||
| 161 | http://developer.apple.com/ReleaseNotes/ | 163 | http://developer.apple.com/ReleaseNotes/ |
| 162 | CoreFoundation/CoreFoundation.html) | 164 | CoreFoundation/CoreFoundation.html |
| 165 | |||
| 166 | Note: the above is no longer available on-line, but it can be found | ||
| 167 | via the "Wayback machine", https://web.archive.org. | ||
| 163 | 168 | ||
| 164 | On Windows, a Cygwin fork child cannot access the USER subsystem. | 169 | On Windows, a Cygwin fork child cannot access the USER subsystem. |
| 165 | 170 | ||
diff --git a/src/json.c b/src/json.c index 5e1439f881a..74e0534065f 100644 --- a/src/json.c +++ b/src/json.c | |||
| @@ -337,8 +337,14 @@ enum json_object_type { | |||
| 337 | json_object_plist | 337 | json_object_plist |
| 338 | }; | 338 | }; |
| 339 | 339 | ||
| 340 | enum json_array_type { | ||
| 341 | json_array_array, | ||
| 342 | json_array_list | ||
| 343 | }; | ||
| 344 | |||
| 340 | struct json_configuration { | 345 | struct json_configuration { |
| 341 | enum json_object_type object_type; | 346 | enum json_object_type object_type; |
| 347 | enum json_array_type array_type; | ||
| 342 | Lisp_Object null_object; | 348 | Lisp_Object null_object; |
| 343 | Lisp_Object false_object; | 349 | Lisp_Object false_object; |
| 344 | }; | 350 | }; |
| @@ -521,7 +527,7 @@ static void | |||
| 521 | json_parse_args (ptrdiff_t nargs, | 527 | json_parse_args (ptrdiff_t nargs, |
| 522 | Lisp_Object *args, | 528 | Lisp_Object *args, |
| 523 | struct json_configuration *conf, | 529 | struct json_configuration *conf, |
| 524 | bool configure_object_type) | 530 | bool parse_object_types) |
| 525 | { | 531 | { |
| 526 | if ((nargs % 2) != 0) | 532 | if ((nargs % 2) != 0) |
| 527 | wrong_type_argument (Qplistp, Flist (nargs, args)); | 533 | wrong_type_argument (Qplistp, Flist (nargs, args)); |
| @@ -531,7 +537,7 @@ json_parse_args (ptrdiff_t nargs, | |||
| 531 | for (ptrdiff_t i = nargs; i > 0; i -= 2) { | 537 | for (ptrdiff_t i = nargs; i > 0; i -= 2) { |
| 532 | Lisp_Object key = args[i - 2]; | 538 | Lisp_Object key = args[i - 2]; |
| 533 | Lisp_Object value = args[i - 1]; | 539 | Lisp_Object value = args[i - 1]; |
| 534 | if (configure_object_type && EQ (key, QCobject_type)) | 540 | if (parse_object_types && EQ (key, QCobject_type)) |
| 535 | { | 541 | { |
| 536 | if (EQ (value, Qhash_table)) | 542 | if (EQ (value, Qhash_table)) |
| 537 | conf->object_type = json_object_hashtable; | 543 | conf->object_type = json_object_hashtable; |
| @@ -542,12 +548,22 @@ json_parse_args (ptrdiff_t nargs, | |||
| 542 | else | 548 | else |
| 543 | wrong_choice (list3 (Qhash_table, Qalist, Qplist), value); | 549 | wrong_choice (list3 (Qhash_table, Qalist, Qplist), value); |
| 544 | } | 550 | } |
| 551 | else if (parse_object_types && EQ (key, QCarray_type)) | ||
| 552 | { | ||
| 553 | if (EQ (value, Qarray)) | ||
| 554 | conf->array_type = json_array_array; | ||
| 555 | else if (EQ (value, Qlist)) | ||
| 556 | conf->array_type = json_array_list; | ||
| 557 | else | ||
| 558 | wrong_choice (list2 (Qarray, Qlist), value); | ||
| 559 | } | ||
| 545 | else if (EQ (key, QCnull_object)) | 560 | else if (EQ (key, QCnull_object)) |
| 546 | conf->null_object = value; | 561 | conf->null_object = value; |
| 547 | else if (EQ (key, QCfalse_object)) | 562 | else if (EQ (key, QCfalse_object)) |
| 548 | conf->false_object = value; | 563 | conf->false_object = value; |
| 549 | else if (configure_object_type) | 564 | else if (parse_object_types) |
| 550 | wrong_choice (list3 (QCobject_type, | 565 | wrong_choice (list4 (QCobject_type, |
| 566 | QCarray_type, | ||
| 551 | QCnull_object, | 567 | QCnull_object, |
| 552 | QCfalse_object), | 568 | QCfalse_object), |
| 553 | value); | 569 | value); |
| @@ -604,7 +620,8 @@ usage: (json-serialize OBJECT &rest ARGS) */) | |||
| 604 | } | 620 | } |
| 605 | #endif | 621 | #endif |
| 606 | 622 | ||
| 607 | struct json_configuration conf = {json_object_hashtable, QCnull, QCfalse}; | 623 | struct json_configuration conf = |
| 624 | {json_object_hashtable, json_array_array, QCnull, QCfalse}; | ||
| 608 | json_parse_args (nargs - 1, args + 1, &conf, false); | 625 | json_parse_args (nargs - 1, args + 1, &conf, false); |
| 609 | 626 | ||
| 610 | json_t *json = lisp_to_json_toplevel (args[0], &conf); | 627 | json_t *json = lisp_to_json_toplevel (args[0], &conf); |
| @@ -701,7 +718,8 @@ usage: (json-insert OBJECT &rest ARGS) */) | |||
| 701 | } | 718 | } |
| 702 | #endif | 719 | #endif |
| 703 | 720 | ||
| 704 | struct json_configuration conf = {json_object_hashtable, QCnull, QCfalse}; | 721 | struct json_configuration conf = |
| 722 | {json_object_hashtable, json_array_array, QCnull, QCfalse}; | ||
| 705 | json_parse_args (nargs - 1, args + 1, &conf, false); | 723 | json_parse_args (nargs - 1, args + 1, &conf, false); |
| 706 | 724 | ||
| 707 | json_t *json = lisp_to_json (args[0], &conf); | 725 | json_t *json = lisp_to_json (args[0], &conf); |
| @@ -817,10 +835,35 @@ json_to_lisp (json_t *json, struct json_configuration *conf) | |||
| 817 | size_t size = json_array_size (json); | 835 | size_t size = json_array_size (json); |
| 818 | if (PTRDIFF_MAX < size) | 836 | if (PTRDIFF_MAX < size) |
| 819 | overflow_error (); | 837 | overflow_error (); |
| 820 | Lisp_Object result = make_vector (size, Qunbound); | 838 | Lisp_Object result; |
| 821 | for (ptrdiff_t i = 0; i < size; ++i) | 839 | switch (conf->array_type) |
| 822 | ASET (result, i, | 840 | { |
| 823 | json_to_lisp (json_array_get (json, i), conf)); | 841 | case json_array_array: |
| 842 | { | ||
| 843 | result = make_vector (size, Qunbound); | ||
| 844 | for (ptrdiff_t i = 0; i < size; ++i) | ||
| 845 | { | ||
| 846 | rarely_quit (i); | ||
| 847 | ASET (result, i, | ||
| 848 | json_to_lisp (json_array_get (json, i), conf)); | ||
| 849 | } | ||
| 850 | break; | ||
| 851 | } | ||
| 852 | case json_array_list: | ||
| 853 | { | ||
| 854 | result = Qnil; | ||
| 855 | for (ptrdiff_t i = size - 1; i >= 0; --i) | ||
| 856 | { | ||
| 857 | rarely_quit (i); | ||
| 858 | result = Fcons (json_to_lisp (json_array_get (json, i), conf), | ||
| 859 | result); | ||
| 860 | } | ||
| 861 | break; | ||
| 862 | } | ||
| 863 | default: | ||
| 864 | /* Can't get here. */ | ||
| 865 | emacs_abort (); | ||
| 866 | } | ||
| 824 | --lisp_eval_depth; | 867 | --lisp_eval_depth; |
| 825 | return result; | 868 | return result; |
| 826 | } | 869 | } |
| @@ -905,18 +948,22 @@ json_to_lisp (json_t *json, struct json_configuration *conf) | |||
| 905 | DEFUN ("json-parse-string", Fjson_parse_string, Sjson_parse_string, 1, MANY, | 948 | DEFUN ("json-parse-string", Fjson_parse_string, Sjson_parse_string, 1, MANY, |
| 906 | NULL, | 949 | NULL, |
| 907 | doc: /* Parse the JSON STRING into a Lisp object. | 950 | doc: /* Parse the JSON STRING into a Lisp object. |
| 908 | |||
| 909 | This is essentially the reverse operation of `json-serialize', which | 951 | This is essentially the reverse operation of `json-serialize', which |
| 910 | see. The returned object will be a vector, hashtable, alist, or | 952 | see. The returned object will be a vector, list, hashtable, alist, or |
| 911 | plist. Its elements will be the JSON null value, the JSON false | 953 | plist. Its elements will be the JSON null value, the JSON false |
| 912 | value, t, numbers, strings, or further vectors, hashtables, alists, or | 954 | value, t, numbers, strings, or further vectors, hashtables, alists, or |
| 913 | plists. If there are duplicate keys in an object, all but the last | 955 | plists. If there are duplicate keys in an object, all but the last |
| 914 | one are ignored. If STRING doesn't contain a valid JSON object, an | 956 | one are ignored. If STRING doesn't contain a valid JSON object, this |
| 915 | error of type `json-parse-error' is signaled. The arguments ARGS are | 957 | function signals an error of type `json-parse-error'. |
| 916 | a list of keyword/argument pairs: | 958 | |
| 959 | The arguments ARGS are a list of keyword/argument pairs: | ||
| 917 | 960 | ||
| 918 | The keyword argument `:object-type' specifies which Lisp type is used | 961 | The keyword argument `:object-type' specifies which Lisp type is used |
| 919 | to represent objects; it can be `hash-table', `alist' or `plist'. | 962 | to represent objects; it can be `hash-table', `alist' or `plist'. It |
| 963 | defaults to `hash-table'. | ||
| 964 | |||
| 965 | The keyword argument `:array-type' specifies which Lisp type is used | ||
| 966 | to represent arrays; it can be `array' (the default) or `list'. | ||
| 920 | 967 | ||
| 921 | The keyword argument `:null-object' specifies which object to use | 968 | The keyword argument `:null-object' specifies which object to use |
| 922 | to represent a JSON null value. It defaults to `:null'. | 969 | to represent a JSON null value. It defaults to `:null'. |
| @@ -946,7 +993,8 @@ usage: (json-parse-string STRING &rest ARGS) */) | |||
| 946 | Lisp_Object string = args[0]; | 993 | Lisp_Object string = args[0]; |
| 947 | Lisp_Object encoded = json_encode (string); | 994 | Lisp_Object encoded = json_encode (string); |
| 948 | check_string_without_embedded_nuls (encoded); | 995 | check_string_without_embedded_nuls (encoded); |
| 949 | struct json_configuration conf = {json_object_hashtable, QCnull, QCfalse}; | 996 | struct json_configuration conf = |
| 997 | {json_object_hashtable, json_array_array, QCnull, QCfalse}; | ||
| 950 | json_parse_args (nargs - 1, args + 1, &conf, true); | 998 | json_parse_args (nargs - 1, args + 1, &conf, true); |
| 951 | 999 | ||
| 952 | json_error_t error; | 1000 | json_error_t error; |
| @@ -993,9 +1041,32 @@ json_read_buffer_callback (void *buffer, size_t buflen, void *data) | |||
| 993 | DEFUN ("json-parse-buffer", Fjson_parse_buffer, Sjson_parse_buffer, | 1041 | DEFUN ("json-parse-buffer", Fjson_parse_buffer, Sjson_parse_buffer, |
| 994 | 0, MANY, NULL, | 1042 | 0, MANY, NULL, |
| 995 | doc: /* Read JSON object from current buffer starting at point. | 1043 | doc: /* Read JSON object from current buffer starting at point. |
| 996 | This is similar to `json-parse-string', which see. Move point after | 1044 | Move point after the end of the object if parsing was successful. |
| 997 | the end of the object if parsing was successful. On error, point is | 1045 | On error, don't move point. |
| 998 | not moved. | 1046 | |
| 1047 | The returned object will be a vector, list, hashtable, alist, or | ||
| 1048 | plist. Its elements will be the JSON null value, the JSON false | ||
| 1049 | value, t, numbers, strings, or further vectors, lists, hashtables, | ||
| 1050 | alists, or plists. If there are duplicate keys in an object, all | ||
| 1051 | but the last one are ignored. | ||
| 1052 | |||
| 1053 | If the current buffer doesn't contain a valid JSON object, the | ||
| 1054 | function signals an error of type `json-parse-error'. | ||
| 1055 | |||
| 1056 | The arguments ARGS are a list of keyword/argument pairs: | ||
| 1057 | |||
| 1058 | The keyword argument `:object-type' specifies which Lisp type is used | ||
| 1059 | to represent objects; it can be `hash-table', `alist' or `plist'. It | ||
| 1060 | defaults to `hash-table'. | ||
| 1061 | |||
| 1062 | The keyword argument `:array-type' specifies which Lisp type is used | ||
| 1063 | to represent arrays; it can be `array' (the default) or `list'. | ||
| 1064 | |||
| 1065 | The keyword argument `:null-object' specifies which object to use | ||
| 1066 | to represent a JSON null value. It defaults to `:null'. | ||
| 1067 | |||
| 1068 | The keyword argument `:false-object' specifies which object to use to | ||
| 1069 | represent a JSON false value. It defaults to `:false'. | ||
| 999 | usage: (json-parse-buffer &rest args) */) | 1070 | usage: (json-parse-buffer &rest args) */) |
| 1000 | (ptrdiff_t nargs, Lisp_Object *args) | 1071 | (ptrdiff_t nargs, Lisp_Object *args) |
| 1001 | { | 1072 | { |
| @@ -1016,7 +1087,8 @@ usage: (json-parse-buffer &rest args) */) | |||
| 1016 | } | 1087 | } |
| 1017 | #endif | 1088 | #endif |
| 1018 | 1089 | ||
| 1019 | struct json_configuration conf = {json_object_hashtable, QCnull, QCfalse}; | 1090 | struct json_configuration conf = |
| 1091 | {json_object_hashtable, json_array_array, QCnull, QCfalse}; | ||
| 1020 | json_parse_args (nargs, args, &conf, true); | 1092 | json_parse_args (nargs, args, &conf, true); |
| 1021 | 1093 | ||
| 1022 | ptrdiff_t point = PT_BYTE; | 1094 | ptrdiff_t point = PT_BYTE; |
| @@ -1095,10 +1167,12 @@ syms_of_json (void) | |||
| 1095 | Fput (Qjson_parse_string, Qside_effect_free, Qt); | 1167 | Fput (Qjson_parse_string, Qside_effect_free, Qt); |
| 1096 | 1168 | ||
| 1097 | DEFSYM (QCobject_type, ":object-type"); | 1169 | DEFSYM (QCobject_type, ":object-type"); |
| 1170 | DEFSYM (QCarray_type, ":array-type"); | ||
| 1098 | DEFSYM (QCnull_object, ":null-object"); | 1171 | DEFSYM (QCnull_object, ":null-object"); |
| 1099 | DEFSYM (QCfalse_object, ":false-object"); | 1172 | DEFSYM (QCfalse_object, ":false-object"); |
| 1100 | DEFSYM (Qalist, "alist"); | 1173 | DEFSYM (Qalist, "alist"); |
| 1101 | DEFSYM (Qplist, "plist"); | 1174 | DEFSYM (Qplist, "plist"); |
| 1175 | DEFSYM (Qarray, "array"); | ||
| 1102 | 1176 | ||
| 1103 | defsubr (&Sjson_serialize); | 1177 | defsubr (&Sjson_serialize); |
| 1104 | defsubr (&Sjson_insert); | 1178 | defsubr (&Sjson_insert); |
diff --git a/src/minibuf.c b/src/minibuf.c index a0025e22720..10fd5e56ac3 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -995,7 +995,8 @@ the current input method and the setting of`enable-multibyte-characters'. */) | |||
| 995 | DEFUN ("read-command", Fread_command, Sread_command, 1, 2, 0, | 995 | DEFUN ("read-command", Fread_command, Sread_command, 1, 2, 0, |
| 996 | doc: /* Read the name of a command and return as a symbol. | 996 | doc: /* Read the name of a command and return as a symbol. |
| 997 | Prompt with PROMPT. By default, return DEFAULT-VALUE or its first element | 997 | Prompt with PROMPT. By default, return DEFAULT-VALUE or its first element |
| 998 | if it is a list. */) | 998 | if it is a list. If DEFAULT-VALUE is omitted or nil, and the user enters |
| 999 | null input, return a symbol whose name is an empty string. */) | ||
| 999 | (Lisp_Object prompt, Lisp_Object default_value) | 1000 | (Lisp_Object prompt, Lisp_Object default_value) |
| 1000 | { | 1001 | { |
| 1001 | Lisp_Object name, default_string; | 1002 | Lisp_Object name, default_string; |
diff --git a/src/xfns.c b/src/xfns.c index 13f66f07183..e521ed12e40 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -5030,7 +5030,7 @@ Internal use only, use `display-monitor-attributes-list' instead. */) | |||
| 5030 | mi->mm_height = height_mm; | 5030 | mi->mm_height = height_mm; |
| 5031 | 5031 | ||
| 5032 | #if GTK_CHECK_VERSION (3, 22, 0) | 5032 | #if GTK_CHECK_VERSION (3, 22, 0) |
| 5033 | mi->name = xstrdup (gdk_monitor_get_model (monitor)); | 5033 | dupstring (&mi->name, (gdk_monitor_get_model (monitor))); |
| 5034 | #elif GTK_CHECK_VERSION (2, 14, 0) | 5034 | #elif GTK_CHECK_VERSION (2, 14, 0) |
| 5035 | mi->name = gdk_screen_get_monitor_plug_name (gscreen, i); | 5035 | mi->name = gdk_screen_get_monitor_plug_name (gscreen, i); |
| 5036 | #endif | 5036 | #endif |
diff --git a/src/xterm.c b/src/xterm.c index 5aa3e3ff25c..def6915d62e 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -922,16 +922,17 @@ x_set_frame_alpha (struct frame *f) | |||
| 922 | else | 922 | else |
| 923 | alpha = f->alpha[1]; | 923 | alpha = f->alpha[1]; |
| 924 | 924 | ||
| 925 | if (alpha < 0.0) | ||
| 926 | return; | ||
| 927 | |||
| 925 | if (FLOATP (Vframe_alpha_lower_limit)) | 928 | if (FLOATP (Vframe_alpha_lower_limit)) |
| 926 | alpha_min = XFLOAT_DATA (Vframe_alpha_lower_limit); | 929 | alpha_min = XFLOAT_DATA (Vframe_alpha_lower_limit); |
| 927 | else if (FIXNUMP (Vframe_alpha_lower_limit)) | 930 | else if (FIXNUMP (Vframe_alpha_lower_limit)) |
| 928 | alpha_min = (XFIXNUM (Vframe_alpha_lower_limit)) / 100.0; | 931 | alpha_min = (XFIXNUM (Vframe_alpha_lower_limit)) / 100.0; |
| 929 | 932 | ||
| 930 | if (alpha < 0.0) | 933 | if (alpha > 1.0) |
| 931 | return; | ||
| 932 | else if (alpha > 1.0) | ||
| 933 | alpha = 1.0; | 934 | alpha = 1.0; |
| 934 | else if (0.0 <= alpha && alpha < alpha_min && alpha_min <= 1.0) | 935 | else if (alpha < alpha_min && alpha_min <= 1.0) |
| 935 | alpha = alpha_min; | 936 | alpha = alpha_min; |
| 936 | 937 | ||
| 937 | opac = alpha * OPAQUE; | 938 | opac = alpha * OPAQUE; |