Mercurial > hg > xemacs-beta
comparison src/text.h @ 5939:96fb76dd98df cygwin
fix bad interaction with Cygwin 3.3
author | Henry Thompson <ht@markup.co.uk> |
---|---|
date | Wed, 08 Dec 2021 18:49:22 +0000 |
parents | b3824b7f5627 |
children |
comparison
equal
deleted
inserted
replaced
5938:699264ac20f1 | 5939:96fb76dd98df |
---|---|
827 return (Bytecount) (len >> 2); | 827 return (Bytecount) (len >> 2); |
828 default: | 828 default: |
829 text_checking_assert (fmt == FORMAT_8_BIT_FIXED); | 829 text_checking_assert (fmt == FORMAT_8_BIT_FIXED); |
830 return (Bytecount) len; | 830 return (Bytecount) len; |
831 } | 831 } |
832 } | |
833 | |
834 #ifdef EFFICIENT_INT_128_BIT | |
835 # define STRIDE_TYPE INT_128_BIT | |
836 # define HIGH_BIT_MASK \ | |
837 MAKE_128_BIT_UNSIGNED_CONSTANT (0x80808080808080808080808080808080) | |
838 #elif defined (EFFICIENT_INT_64_BIT) | |
839 # define STRIDE_TYPE INT_64_BIT | |
840 # define HIGH_BIT_MASK MAKE_64_BIT_UNSIGNED_CONSTANT (0x8080808080808080) | |
841 #else | |
842 # define STRIDE_TYPE INT_32_BIT | |
843 # define HIGH_BIT_MASK MAKE_32_BIT_UNSIGNED_CONSTANT (0x80808080) | |
844 #endif | |
845 | |
846 #define ALIGN_BITS ((EMACS_UINT) (ALIGNOF (STRIDE_TYPE) - 1)) | |
847 #define ALIGN_MASK (~ ALIGN_BITS) | |
848 #define ALIGNED(ptr) ((((EMACS_UINT) ptr) & ALIGN_BITS) == 0) | |
849 #define STRIDE sizeof (STRIDE_TYPE) | |
850 | |
851 /* Skip as many ASCII bytes as possible in the memory block [PTR, END). | |
852 Return pointer to the first non-ASCII byte. optimized for long | |
853 stretches of ASCII. */ | |
854 DECLARE_INLINE_HEADER ( | |
855 const Ibyte * | |
856 skip_ascii (const Ibyte *ptr, const Ibyte *end) | |
857 ) | |
858 { | |
859 const unsigned STRIDE_TYPE *ascii_end; | |
860 | |
861 /* Need to do in 3 sections -- before alignment start, aligned chunk, | |
862 after alignment end. */ | |
863 while (!ALIGNED (ptr)) | |
864 { | |
865 if (ptr == end || !byte_ascii_p (*ptr)) | |
866 return ptr; | |
867 ptr++; | |
868 } | |
869 ascii_end = (const unsigned STRIDE_TYPE *) ptr; | |
870 /* This loop screams, because we can detect ASCII | |
871 characters 4 or 8 at a time. */ | |
872 while ((const Ibyte *) ascii_end + STRIDE <= end | |
873 && !(*ascii_end & HIGH_BIT_MASK)) | |
874 ascii_end++; | |
875 ptr = (Ibyte *) ascii_end; | |
876 while (ptr < end && byte_ascii_p (*ptr)) | |
877 ptr++; | |
878 return ptr; | |
879 } | |
880 | |
881 /* Skip as many ASCII bytes as possible in the memory block [END, PTR), | |
882 going downwards. Return pointer to the location above the first | |
883 non-ASCII byte. Optimized for long stretches of ASCII. */ | |
884 DECLARE_INLINE_HEADER ( | |
885 const Ibyte * | |
886 skip_ascii_down (const Ibyte *ptr, const Ibyte *end) | |
887 ) | |
888 { | |
889 const unsigned STRIDE_TYPE *ascii_end; | |
890 | |
891 /* Need to do in 3 sections -- before alignment start, aligned chunk, | |
892 after alignment end. */ | |
893 while (!ALIGNED (ptr)) | |
894 { | |
895 if (ptr == end || !byte_ascii_p (*(ptr - 1))) | |
896 return ptr; | |
897 ptr--; | |
898 } | |
899 ascii_end = (const unsigned STRIDE_TYPE *) ptr - 1; | |
900 /* This loop screams, because we can detect ASCII | |
901 characters 4 or 8 at a time. */ | |
902 while ((const Ibyte *) ascii_end >= end | |
903 && !(*ascii_end & HIGH_BIT_MASK)) | |
904 ascii_end--; | |
905 ptr = (Ibyte *) (ascii_end + 1); | |
906 while (ptr > end && byte_ascii_p (*(ptr - 1))) | |
907 ptr--; | |
908 return ptr; | |
909 } | 832 } |
910 | 833 |
911 /* Return the character count of an lstream or coding buffer of internal | 834 /* Return the character count of an lstream or coding buffer of internal |
912 format text, counting partial characters at the beginning of the buffer | 835 format text, counting partial characters at the beginning of the buffer |
913 as whole characters, and *not* counting partial characters at the end of | 836 as whole characters, and *not* counting partial characters at the end of |