From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: Re: Is copy_string_contents in emacs-module.h give us a proper UTF-8 string? Date: Thu, 08 Oct 2020 09:40:02 +0200 Message-ID: References: <79bc0bc2.1982.17506d48b4d.Coremail.all_but_last@163.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18034"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "emacs-devel@gnu.org" To: "Zhu Zihao" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Oct 08 09:40:47 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQQXf-0004b6-E3 for ged-emacs-devel@m.gmane-mx.org; Thu, 08 Oct 2020 09:40:47 +0200 Original-Received: from localhost ([::1]:40318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQQXe-0003Wi-Fz for ged-emacs-devel@m.gmane-mx.org; Thu, 08 Oct 2020 03:40:46 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQQX5-0002tq-Nd for emacs-devel@gnu.org; Thu, 08 Oct 2020 03:40:11 -0400 Original-Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:34890) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kQQX0-0007p4-EH for emacs-devel@gnu.org; Thu, 08 Oct 2020 03:40:11 -0400 Original-Received: by mail-wr1-x429.google.com with SMTP id n15so5424344wrq.2 for ; Thu, 08 Oct 2020 00:40:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:gmane-reply-to-list:date:in-reply-to :message-id:mime-version; bh=O2N2lHG3F2rtHkc0GNG7Bpg0QvLOZCuclHyQb0zncxw=; b=RlJlqrMcjyJFYiOFKoW47aZvcvwBaoF7XvcTcd4Gj/kGPX5C3iwY3ar+CRKN68BfiQ G/b969HdjqohCNCT+4+QyBSBlT/M8LS0R68YcMWTFdBUiMG9VDnORpHW7oP9LoUH4cJg nl7E4tZGyD/DGJ+SQlsX8ekHV9exvm59DDX1J+u08BTx6KS6dJTifdcbNslbNnCSXPEn yZ1Tz4WzAFLxTtwV8OMROH0o4UnE9CFQH4uR6VXqPQUhqi6KX/4Bi46yR2l8ZhnzoToZ vWrvoJXQWO219/MbOxUdZNpLOdcmJkqjueXPDSZjpR6ueCgWS1s+IXwmeEfYwZ7kp872 rwPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references :gmane-reply-to-list:date:in-reply-to:message-id:mime-version; bh=O2N2lHG3F2rtHkc0GNG7Bpg0QvLOZCuclHyQb0zncxw=; b=XKScAGgr6LlNB13mlDqFZk7NUIHjt9j1PMNNI0gh3vFrs/IBfolDMutmHjy0hhVWgY +OlsQEN0soR1PqXM889qWi4gg2n8GPAlmF/cVhvxsYv2JAkfUskkEul6N4ubTnhotSA8 vuHdv3x/bV65xQg2Q6qIAp5bUOe6ull2ljox5DAPFZbawWZqPHOJtbhy7oJSgZmXdYBX Xl0MMX7ZCSZnXj+jA/KwR+VpMxtp/WaIPED6XATApOYEEKcTNFDeyZWM7SPhLxSm2v8r zVXdjEO0K7+3SorWEi20A7+7r9rtX/79oNZN2h4s2FPy02lDFlcUDg+kl/HLKtaFJo6m bu0Q== X-Gm-Message-State: AOAM532rSrMBzI6LA66rdYLqq7AUUO4pmre7Lidl+s7kqVYaZjQcZbpo hC+5SKyIVYmwthh+/v28bDKGXKbPeRU= X-Google-Smtp-Source: ABdhPJyrVtMFIVttbPIMmJPuC2cIKyyUyMEMT/bbz6agWQvo2ufVZ/oJ97X+kPdDdQmpAZqTCNYXRw== X-Received: by 2002:a5d:6944:: with SMTP id r4mr7726062wrw.151.1602142804163; Thu, 08 Oct 2020 00:40:04 -0700 (PDT) Original-Received: from rpluim-mac ([2a01:e34:ecfc:a860:683b:48ba:13fe:a576]) by smtp.gmail.com with ESMTPSA id y11sm5946329wrs.16.2020.10.08.00.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2020 00:40:03 -0700 (PDT) Gmane-Reply-To-List: yes In-Reply-To: <79bc0bc2.1982.17506d48b4d.Coremail.all_but_last@163.com> (Zhu Zihao's message of "Thu, 8 Oct 2020 14:09:53 +0800 (CST)") Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=rpluim@gmail.com; helo=mail-wr1-x429.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:257200 Archived-At: >>>>> On Thu, 8 Oct 2020 14:09:53 +0800 (CST), "Zhu Zihao" said: Zhu> I see the comment in emacs-module.h says Zhu> /* Copy the content of the Lisp string VALUE to BUFFER as an utf8 Zhu> NUL-terminated string. Zhu> SIZE must point to the total size of the buffer. If BUFFER is Zhu> NULL or if SIZE is not big enough, write the required buffer size Zhu> to SIZE and return true. Zhu> Note that SIZE must include the last NUL byte (e.g. "abc" needs Zhu> a buffer of size 4). Zhu> Return true if the string was successfully copied. */ >From emacs-module.c:module_copy_string_contents: We set HANDLE-8-BIT and HANDLE-OVER-UNI to nil to signal an error if the argument is not a valid Unicode string. While it isn't documented how copy_string_contents behaves in this case, signaling an error is the most defensive and obvious reaction. */ Zhu> Will "copy_string_contents" always give us a proper UTF-8 string. Or it will give us a mix of bytevector and UTF8? It will either give a UTF-8 string or signal an error. Robert --