From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Allow inserting non-BMP characters Date: Tue, 26 Dec 2017 06:46:53 +0200 Message-ID: <83d132hz9e.fsf@gnu.org> References: <20171225210115.13789-1-phst@google.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1514263502 24533 195.159.176.226 (26 Dec 2017 04:45:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 26 Dec 2017 04:45:02 +0000 (UTC) Cc: phst@google.com, emacs-devel@gnu.org To: Philipp Stephani Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 26 05:44:58 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eTh6n-0005qh-HL for ged-emacs-devel@m.gmane.org; Tue, 26 Dec 2017 05:44:57 +0100 Original-Received: from localhost ([::1]:51884 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eTh8k-0003KC-7A for ged-emacs-devel@m.gmane.org; Mon, 25 Dec 2017 23:46:58 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eTh8d-0003Ho-9Y for emacs-devel@gnu.org; Mon, 25 Dec 2017 23:46:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eTh8c-00024a-Hd for emacs-devel@gnu.org; Mon, 25 Dec 2017 23:46:51 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:48947) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eTh8X-0001zS-81; Mon, 25 Dec 2017 23:46:45 -0500 Original-Received: from [176.228.60.248] (port=3187 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eTh8W-0000X7-Ay; Mon, 25 Dec 2017 23:46:44 -0500 In-reply-to: <20171225210115.13789-1-phst@google.com> (message from Philipp Stephani on Mon, 25 Dec 2017 22:01:15 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:221415 Archived-At: > From: Philipp Stephani > Date: Mon, 25 Dec 2017 22:01:15 +0100 > Cc: Philipp Stephani > > +/* Return the Unicode code point for the given UTF-16 surrogates. */ > + > +INLINE int > +surrogates_to_codepoint (int low, int high) > +{ > + eassert (char_low_surrogate_p (low)); > + eassert (char_high_surrogate_p (high)); > + return 0x10000 + (low - 0xDC00) + ((high - 0xD800) * 0x400); > +} > + > /* Data type for Unicode general category. Suggest to move surrogates_to_codepoint to coding.c, and then use the macros UTF_16_HIGH_SURROGATE_P and UTF_16_LOW_SURROGATE_P defined there. Also, a single-liner sounds like too little to justify a function, so maybe make all of that macros in coding.h, and include the latter in nsterm.m. > + USE_SAFE_ALLOCA; > + unichar *utf16_buffer; > + SAFE_NALLOCA (utf16_buffer, 1, len); Maximum length of a UTF-16 sequence is known in advance, so why do you need SAFE_NALLOCA here? Couldn't you use a buffer of fixed length instead? Thanks.