diff options
| author | Stefan Monnier | 2019-03-21 23:55:28 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2019-03-21 23:55:28 -0400 |
| commit | 76fea1eba1332440eab2e3daecce053daccd3782 (patch) | |
| tree | 944ea8279b8a52cb715fe3493d909bc581776430 /src/coding.c | |
| parent | 57a60db2b88dfa5dea41a3a05b736cd7cd17a953 (diff) | |
| download | emacs-76fea1eba1332440eab2e3daecce053daccd3782.tar.gz emacs-76fea1eba1332440eab2e3daecce053daccd3782.zip | |
Fix misuses of NULL when talking about the NUL character
* lisp/subr.el (inhibit-null-byte-detection): Make it an obsolete alias.
* src/coding.c (setup_coding_system): Use new name.
(detect_coding): Rename null_byte_found => nul_byte_found.
(detect_coding_system): Use new name.
Rename null_byte_found => nul_byte_found.
(Fdefine_coding_system_internal): Use new name.
(syms_of_coding): Rename inhibit-null-byte-detection to
inhibit-nul-byte-detection.
* src/w16select.c (get_clipboard_data): null_char => nul_char.
* src/json.c (check_string_without_embedded_nuls): Rename from
check_string_without_embedded_nulls.
(Fjson_parse_string): Adjust accordingly.
* src/coding.h (enum define_coding_undecided_arg_index)
(enum coding_attr_index): ...null_byte... => ...nul_byte....
* lisp/info.el (info-insert-file-contents, Info-insert-dir):
* lisp/international/mule.el (define-coding-system):
* lisp/vc/vc-git.el (vc-git--call):
* doc/lispref/nonascii.texi (Lisp and Coding Systems): Use the new name.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/coding.c b/src/coding.c index a216460fc2c..905c7ced849 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -5719,7 +5719,7 @@ setup_coding_system (Lisp_Object coding_system, struct coding_system *coding) | |||
| 5719 | coding->common_flags |= CODING_REQUIRE_DETECTION_MASK; | 5719 | coding->common_flags |= CODING_REQUIRE_DETECTION_MASK; |
| 5720 | coding->spec.undecided.inhibit_nbd | 5720 | coding->spec.undecided.inhibit_nbd |
| 5721 | = (encode_inhibit_flag | 5721 | = (encode_inhibit_flag |
| 5722 | (AREF (attrs, coding_attr_undecided_inhibit_null_byte_detection))); | 5722 | (AREF (attrs, coding_attr_undecided_inhibit_nul_byte_detection))); |
| 5723 | coding->spec.undecided.inhibit_ied | 5723 | coding->spec.undecided.inhibit_ied |
| 5724 | = (encode_inhibit_flag | 5724 | = (encode_inhibit_flag |
| 5725 | (AREF (attrs, coding_attr_undecided_inhibit_iso_escape_detection))); | 5725 | (AREF (attrs, coding_attr_undecided_inhibit_iso_escape_detection))); |
| @@ -6514,9 +6514,9 @@ detect_coding (struct coding_system *coding) | |||
| 6514 | { | 6514 | { |
| 6515 | int c, i; | 6515 | int c, i; |
| 6516 | struct coding_detection_info detect_info; | 6516 | struct coding_detection_info detect_info; |
| 6517 | bool null_byte_found = 0, eight_bit_found = 0; | 6517 | bool nul_byte_found = 0, eight_bit_found = 0; |
| 6518 | bool inhibit_nbd = inhibit_flag (coding->spec.undecided.inhibit_nbd, | 6518 | bool inhibit_nbd = inhibit_flag (coding->spec.undecided.inhibit_nbd, |
| 6519 | inhibit_null_byte_detection); | 6519 | inhibit_nul_byte_detection); |
| 6520 | bool inhibit_ied = inhibit_flag (coding->spec.undecided.inhibit_ied, | 6520 | bool inhibit_ied = inhibit_flag (coding->spec.undecided.inhibit_ied, |
| 6521 | inhibit_iso_escape_detection); | 6521 | inhibit_iso_escape_detection); |
| 6522 | bool prefer_utf_8 = coding->spec.undecided.prefer_utf_8; | 6522 | bool prefer_utf_8 = coding->spec.undecided.prefer_utf_8; |
| @@ -6529,7 +6529,7 @@ detect_coding (struct coding_system *coding) | |||
| 6529 | if (c & 0x80) | 6529 | if (c & 0x80) |
| 6530 | { | 6530 | { |
| 6531 | eight_bit_found = 1; | 6531 | eight_bit_found = 1; |
| 6532 | if (null_byte_found) | 6532 | if (nul_byte_found) |
| 6533 | break; | 6533 | break; |
| 6534 | } | 6534 | } |
| 6535 | else if (c < 0x20) | 6535 | else if (c < 0x20) |
| @@ -6544,7 +6544,7 @@ detect_coding (struct coding_system *coding) | |||
| 6544 | if (! (detect_info.rejected & CATEGORY_MASK_ISO_7_ELSE)) | 6544 | if (! (detect_info.rejected & CATEGORY_MASK_ISO_7_ELSE)) |
| 6545 | { | 6545 | { |
| 6546 | /* We didn't find an 8-bit code. We may | 6546 | /* We didn't find an 8-bit code. We may |
| 6547 | have found a null-byte, but it's very | 6547 | have found a NUL-byte, but it's very |
| 6548 | rare that a binary file conforms to | 6548 | rare that a binary file conforms to |
| 6549 | ISO-2022. */ | 6549 | ISO-2022. */ |
| 6550 | src = src_end; | 6550 | src = src_end; |
| @@ -6556,7 +6556,7 @@ detect_coding (struct coding_system *coding) | |||
| 6556 | } | 6556 | } |
| 6557 | else if (! c && !inhibit_nbd) | 6557 | else if (! c && !inhibit_nbd) |
| 6558 | { | 6558 | { |
| 6559 | null_byte_found = 1; | 6559 | nul_byte_found = 1; |
| 6560 | if (eight_bit_found) | 6560 | if (eight_bit_found) |
| 6561 | break; | 6561 | break; |
| 6562 | } | 6562 | } |
| @@ -6588,7 +6588,7 @@ detect_coding (struct coding_system *coding) | |||
| 6588 | coding->head_ascii++; | 6588 | coding->head_ascii++; |
| 6589 | } | 6589 | } |
| 6590 | 6590 | ||
| 6591 | if (null_byte_found || eight_bit_found | 6591 | if (nul_byte_found || eight_bit_found |
| 6592 | || coding->head_ascii < coding->src_bytes | 6592 | || coding->head_ascii < coding->src_bytes |
| 6593 | || detect_info.found) | 6593 | || detect_info.found) |
| 6594 | { | 6594 | { |
| @@ -6606,7 +6606,7 @@ detect_coding (struct coding_system *coding) | |||
| 6606 | } | 6606 | } |
| 6607 | else | 6607 | else |
| 6608 | { | 6608 | { |
| 6609 | if (null_byte_found) | 6609 | if (nul_byte_found) |
| 6610 | { | 6610 | { |
| 6611 | detect_info.checked |= ~CATEGORY_MASK_UTF_16; | 6611 | detect_info.checked |= ~CATEGORY_MASK_UTF_16; |
| 6612 | detect_info.rejected |= ~CATEGORY_MASK_UTF_16; | 6612 | detect_info.rejected |= ~CATEGORY_MASK_UTF_16; |
| @@ -6679,7 +6679,7 @@ detect_coding (struct coding_system *coding) | |||
| 6679 | else | 6679 | else |
| 6680 | found = CODING_ID_NAME (this->id); | 6680 | found = CODING_ID_NAME (this->id); |
| 6681 | } | 6681 | } |
| 6682 | else if (null_byte_found) | 6682 | else if (nul_byte_found) |
| 6683 | found = Qno_conversion; | 6683 | found = Qno_conversion; |
| 6684 | else if ((detect_info.rejected & CATEGORY_MASK_ANY) | 6684 | else if ((detect_info.rejected & CATEGORY_MASK_ANY) |
| 6685 | == CATEGORY_MASK_ANY) | 6685 | == CATEGORY_MASK_ANY) |
| @@ -8448,7 +8448,7 @@ from_unicode (Lisp_Object str) | |||
| 8448 | Lisp_Object | 8448 | Lisp_Object |
| 8449 | from_unicode_buffer (const wchar_t *wstr) | 8449 | from_unicode_buffer (const wchar_t *wstr) |
| 8450 | { | 8450 | { |
| 8451 | /* We get one of the two final null bytes for free. */ | 8451 | /* We get one of the two final NUL bytes for free. */ |
| 8452 | ptrdiff_t len = 1 + sizeof (wchar_t) * wcslen (wstr); | 8452 | ptrdiff_t len = 1 + sizeof (wchar_t) * wcslen (wstr); |
| 8453 | AUTO_STRING_WITH_LEN (str, (char *) wstr, len); | 8453 | AUTO_STRING_WITH_LEN (str, (char *) wstr, len); |
| 8454 | return from_unicode (str); | 8454 | return from_unicode (str); |
| @@ -8461,7 +8461,7 @@ to_unicode (Lisp_Object str, Lisp_Object *buf) | |||
| 8461 | /* We need to make another copy (in addition to the one made by | 8461 | /* We need to make another copy (in addition to the one made by |
| 8462 | code_convert_string_norecord) to ensure that the final string is | 8462 | code_convert_string_norecord) to ensure that the final string is |
| 8463 | _doubly_ zero terminated --- that is, that the string is | 8463 | _doubly_ zero terminated --- that is, that the string is |
| 8464 | terminated by two zero bytes and one utf-16le null character. | 8464 | terminated by two zero bytes and one utf-16le NUL character. |
| 8465 | Because strings are already terminated with a single zero byte, | 8465 | Because strings are already terminated with a single zero byte, |
| 8466 | we just add one additional zero. */ | 8466 | we just add one additional zero. */ |
| 8467 | str = make_uninit_string (SBYTES (*buf) + 1); | 8467 | str = make_uninit_string (SBYTES (*buf) + 1); |
| @@ -8577,7 +8577,7 @@ detect_coding_system (const unsigned char *src, | |||
| 8577 | ptrdiff_t id; | 8577 | ptrdiff_t id; |
| 8578 | struct coding_detection_info detect_info; | 8578 | struct coding_detection_info detect_info; |
| 8579 | enum coding_category base_category; | 8579 | enum coding_category base_category; |
| 8580 | bool null_byte_found = 0, eight_bit_found = 0; | 8580 | bool nul_byte_found = 0, eight_bit_found = 0; |
| 8581 | 8581 | ||
| 8582 | if (NILP (coding_system)) | 8582 | if (NILP (coding_system)) |
| 8583 | coding_system = Qundecided; | 8583 | coding_system = Qundecided; |
| @@ -8604,7 +8604,7 @@ detect_coding_system (const unsigned char *src, | |||
| 8604 | struct coding_system *this UNINIT; | 8604 | struct coding_system *this UNINIT; |
| 8605 | int c, i; | 8605 | int c, i; |
| 8606 | bool inhibit_nbd = inhibit_flag (coding.spec.undecided.inhibit_nbd, | 8606 | bool inhibit_nbd = inhibit_flag (coding.spec.undecided.inhibit_nbd, |
| 8607 | inhibit_null_byte_detection); | 8607 | inhibit_nul_byte_detection); |
| 8608 | bool inhibit_ied = inhibit_flag (coding.spec.undecided.inhibit_ied, | 8608 | bool inhibit_ied = inhibit_flag (coding.spec.undecided.inhibit_ied, |
| 8609 | inhibit_iso_escape_detection); | 8609 | inhibit_iso_escape_detection); |
| 8610 | bool prefer_utf_8 = coding.spec.undecided.prefer_utf_8; | 8610 | bool prefer_utf_8 = coding.spec.undecided.prefer_utf_8; |
| @@ -8616,7 +8616,7 @@ detect_coding_system (const unsigned char *src, | |||
| 8616 | if (c & 0x80) | 8616 | if (c & 0x80) |
| 8617 | { | 8617 | { |
| 8618 | eight_bit_found = 1; | 8618 | eight_bit_found = 1; |
| 8619 | if (null_byte_found) | 8619 | if (nul_byte_found) |
| 8620 | break; | 8620 | break; |
| 8621 | } | 8621 | } |
| 8622 | else if (c < 0x20) | 8622 | else if (c < 0x20) |
| @@ -8631,7 +8631,7 @@ detect_coding_system (const unsigned char *src, | |||
| 8631 | if (! (detect_info.rejected & CATEGORY_MASK_ISO_7_ELSE)) | 8631 | if (! (detect_info.rejected & CATEGORY_MASK_ISO_7_ELSE)) |
| 8632 | { | 8632 | { |
| 8633 | /* We didn't find an 8-bit code. We may | 8633 | /* We didn't find an 8-bit code. We may |
| 8634 | have found a null-byte, but it's very | 8634 | have found a NUL-byte, but it's very |
| 8635 | rare that a binary file confirm to | 8635 | rare that a binary file confirm to |
| 8636 | ISO-2022. */ | 8636 | ISO-2022. */ |
| 8637 | src = src_end; | 8637 | src = src_end; |
| @@ -8643,7 +8643,7 @@ detect_coding_system (const unsigned char *src, | |||
| 8643 | } | 8643 | } |
| 8644 | else if (! c && !inhibit_nbd) | 8644 | else if (! c && !inhibit_nbd) |
| 8645 | { | 8645 | { |
| 8646 | null_byte_found = 1; | 8646 | nul_byte_found = 1; |
| 8647 | if (eight_bit_found) | 8647 | if (eight_bit_found) |
| 8648 | break; | 8648 | break; |
| 8649 | } | 8649 | } |
| @@ -8654,7 +8654,7 @@ detect_coding_system (const unsigned char *src, | |||
| 8654 | coding.head_ascii++; | 8654 | coding.head_ascii++; |
| 8655 | } | 8655 | } |
| 8656 | 8656 | ||
| 8657 | if (null_byte_found || eight_bit_found | 8657 | if (nul_byte_found || eight_bit_found |
| 8658 | || coding.head_ascii < coding.src_bytes | 8658 | || coding.head_ascii < coding.src_bytes |
| 8659 | || detect_info.found) | 8659 | || detect_info.found) |
| 8660 | { | 8660 | { |
| @@ -8669,7 +8669,7 @@ detect_coding_system (const unsigned char *src, | |||
| 8669 | } | 8669 | } |
| 8670 | else | 8670 | else |
| 8671 | { | 8671 | { |
| 8672 | if (null_byte_found) | 8672 | if (nul_byte_found) |
| 8673 | { | 8673 | { |
| 8674 | detect_info.checked |= ~CATEGORY_MASK_UTF_16; | 8674 | detect_info.checked |= ~CATEGORY_MASK_UTF_16; |
| 8675 | detect_info.rejected |= ~CATEGORY_MASK_UTF_16; | 8675 | detect_info.rejected |= ~CATEGORY_MASK_UTF_16; |
| @@ -8716,7 +8716,7 @@ detect_coding_system (const unsigned char *src, | |||
| 8716 | } | 8716 | } |
| 8717 | 8717 | ||
| 8718 | if ((detect_info.rejected & CATEGORY_MASK_ANY) == CATEGORY_MASK_ANY | 8718 | if ((detect_info.rejected & CATEGORY_MASK_ANY) == CATEGORY_MASK_ANY |
| 8719 | || null_byte_found) | 8719 | || nul_byte_found) |
| 8720 | { | 8720 | { |
| 8721 | detect_info.found = CATEGORY_MASK_RAW_TEXT; | 8721 | detect_info.found = CATEGORY_MASK_RAW_TEXT; |
| 8722 | id = CODING_SYSTEM_ID (Qno_conversion); | 8722 | id = CODING_SYSTEM_ID (Qno_conversion); |
| @@ -8818,7 +8818,7 @@ detect_coding_system (const unsigned char *src, | |||
| 8818 | { | 8818 | { |
| 8819 | if (detect_info.found & ~CATEGORY_MASK_UTF_16) | 8819 | if (detect_info.found & ~CATEGORY_MASK_UTF_16) |
| 8820 | { | 8820 | { |
| 8821 | if (null_byte_found) | 8821 | if (nul_byte_found) |
| 8822 | normal_eol = EOL_SEEN_LF; | 8822 | normal_eol = EOL_SEEN_LF; |
| 8823 | else | 8823 | else |
| 8824 | normal_eol = detect_eol (coding.source, src_bytes, | 8824 | normal_eol = detect_eol (coding.source, src_bytes, |
| @@ -10478,8 +10478,8 @@ usage: (define-coding-system-internal ...) */) | |||
| 10478 | { | 10478 | { |
| 10479 | if (nargs < coding_arg_undecided_max) | 10479 | if (nargs < coding_arg_undecided_max) |
| 10480 | goto short_args; | 10480 | goto short_args; |
| 10481 | ASET (attrs, coding_attr_undecided_inhibit_null_byte_detection, | 10481 | ASET (attrs, coding_attr_undecided_inhibit_nul_byte_detection, |
| 10482 | args[coding_arg_undecided_inhibit_null_byte_detection]); | 10482 | args[coding_arg_undecided_inhibit_nul_byte_detection]); |
| 10483 | ASET (attrs, coding_attr_undecided_inhibit_iso_escape_detection, | 10483 | ASET (attrs, coding_attr_undecided_inhibit_iso_escape_detection, |
| 10484 | args[coding_arg_undecided_inhibit_iso_escape_detection]); | 10484 | args[coding_arg_undecided_inhibit_iso_escape_detection]); |
| 10485 | ASET (attrs, coding_attr_undecided_prefer_utf_8, | 10485 | ASET (attrs, coding_attr_undecided_prefer_utf_8, |
| @@ -11234,18 +11234,18 @@ to explicitly specify some coding system that doesn't use ISO-2022 | |||
| 11234 | escape sequence (e.g., `latin-1') on reading by \\[universal-coding-system-argument]. */); | 11234 | escape sequence (e.g., `latin-1') on reading by \\[universal-coding-system-argument]. */); |
| 11235 | inhibit_iso_escape_detection = 0; | 11235 | inhibit_iso_escape_detection = 0; |
| 11236 | 11236 | ||
| 11237 | DEFVAR_BOOL ("inhibit-null-byte-detection", | 11237 | DEFVAR_BOOL ("inhibit-nul-byte-detection", |
| 11238 | inhibit_null_byte_detection, | 11238 | inhibit_nul_byte_detection, |
| 11239 | doc: /* If non-nil, Emacs ignores null bytes on code detection. | 11239 | doc: /* If non-nil, Emacs ignores NUL bytes on code detection. |
| 11240 | By default, Emacs treats it as binary data, and does not attempt to | 11240 | By default, Emacs treats it as binary data, and does not attempt to |
| 11241 | decode it. The effect is as if you specified `no-conversion' for | 11241 | decode it. The effect is as if you specified `no-conversion' for |
| 11242 | reading that text. | 11242 | reading that text. |
| 11243 | 11243 | ||
| 11244 | Set this to non-nil when a regular text happens to include null bytes. | 11244 | Set this to non-nil when a regular text happens to include NUL bytes. |
| 11245 | Examples are Index nodes of Info files and null-byte delimited output | 11245 | Examples are Index nodes of Info files and NUL-byte delimited output |
| 11246 | from GNU Find and GNU Grep. Emacs will then ignore the null bytes and | 11246 | from GNU Find and GNU Grep. Emacs will then ignore the NUL bytes and |
| 11247 | decode text as usual. */); | 11247 | decode text as usual. */); |
| 11248 | inhibit_null_byte_detection = 0; | 11248 | inhibit_nul_byte_detection = 0; |
| 11249 | 11249 | ||
| 11250 | DEFVAR_BOOL ("disable-ascii-optimization", disable_ascii_optimization, | 11250 | DEFVAR_BOOL ("disable-ascii-optimization", disable_ascii_optimization, |
| 11251 | doc: /* If non-nil, Emacs does not optimize code decoder for ASCII files. | 11251 | doc: /* If non-nil, Emacs does not optimize code decoder for ASCII files. |
| @@ -11304,7 +11304,7 @@ internal character representation. */); | |||
| 11304 | "automatic conversion on decoding."); | 11304 | "automatic conversion on decoding."); |
| 11305 | plist[15] = args[coding_arg_eol_type] = Qnil; | 11305 | plist[15] = args[coding_arg_eol_type] = Qnil; |
| 11306 | args[coding_arg_plist] = CALLMANY (Flist, plist); | 11306 | args[coding_arg_plist] = CALLMANY (Flist, plist); |
| 11307 | args[coding_arg_undecided_inhibit_null_byte_detection] = make_fixnum (0); | 11307 | args[coding_arg_undecided_inhibit_nul_byte_detection] = make_fixnum (0); |
| 11308 | args[coding_arg_undecided_inhibit_iso_escape_detection] = make_fixnum (0); | 11308 | args[coding_arg_undecided_inhibit_iso_escape_detection] = make_fixnum (0); |
| 11309 | Fdefine_coding_system_internal (coding_arg_undecided_max, args); | 11309 | Fdefine_coding_system_internal (coding_arg_undecided_max, args); |
| 11310 | 11310 | ||