From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 29 06:01:14 2023 Received: (at submit) by debbugs.gnu.org; 29 Jan 2023 11:01:14 +0000 Received: from localhost ([127.0.0.1]:42326 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pM5Qv-0005vc-Ou for submit@debbugs.gnu.org; Sun, 29 Jan 2023 06:01:14 -0500 Received: from lists.gnu.org ([209.51.188.17]:55994) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pM5Qt-0005vU-Ah for submit@debbugs.gnu.org; Sun, 29 Jan 2023 06:01:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pM5Qt-0001dc-19 for bug-gnu-emacs@gnu.org; Sun, 29 Jan 2023 06:01:11 -0500 Received: from sonic311-23.consmr.mail.ne1.yahoo.com ([66.163.188.204]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pM5Qo-0003hh-UJ for bug-gnu-emacs@gnu.org; Sun, 29 Jan 2023 06:01:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1674990061; bh=8Z874G/hFGS0HCaw4duE4Mv+b2mk5IkB+r8i2hv3H1Q=; h=From:To:Subject:Date:References:From:Subject:Reply-To; b=APd36Bvk6TmhR8pF0tmYQCHRDHgPEigOpGD7ksSWLlNXCWTpYj2S8zZOv2Zs6+M7OkR9jlJAJ3DOj+POvUkPlhmg2CjbucYStHq62o5IdfOUTmF2RwiZAcNe4vFy/eljBesAGOXWaeXGrXt7ZtwoVDcpS4TsRXFUrN73dzUxNDl3jiBJ4jSTL7KyGxddmm/qsM1d3uI8AGFhoLq83vrgRax0JNAfgInphI25Xwv7Q5EpHzSA9GvqpYX5EzUkElk/KoxdaPu40lpBOpc58F6vVzNSVBNnWXcUY2YcYN//HoBbqd5s6ATD+REGQ6XVBGnmRJCPcOQlYKFwL285BRZvhw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1674990061; bh=8w6HNkIltBoVjKoCMyJcNK7MNxzRChvisabBfYUGIPt=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=Qie634m1gaDDjFmh3BDuRwdmQGaeurc/t3PjvSoCHbs8GeWqi2ssP7umRd7KjeSSf+1DQnKCTmc/EHAuEPTxmRqajkRzdQslSxhnFLsEGVXVJ9QlWpQ4V5A4mfHkyGd/JoIpIapFG+9bwPDeVT8fFVFU46OcwP28c8GdsBgEYI1WxnWylHuPpo/yZgsGqWBXl7Roiol9CZKr+BPOqf4Xn45fLvkKgiWX3xaHt0We+1ieNVD2jxYRPdoR5TD5+RoU9ecgCaRluBuiwYits8LSNhgp+fThHoZU+CWUU/hD/CSG5EXBpNAIqDyhvavrpJUReMA8qm+s1P582iD21IUXEQ== X-YMail-OSG: 0LqxHIcVM1nMoJHTZh69qyCVpIUeAHYoDDo3B5pHNloVVUQIKGmqR0TSfyH2_vr Qro6i05w3hsEHxATnrDvMDxS7g41XmkIgFVLAKrGRCyyBKPkKRbaWRw.kCbg7xiNncI05rzszNSR W0obq4e31lj2xwRVQQ8mcXI9bCme1DY80L4A_w66p4inmosRDElXDY4J18RtnMKo65dqJyesYSE3 6bpyNdB1tfCxJVVm5ddQ5h3xZ0oVVQGgDKOzVU7QCCuXXJqSkfE85zsX.gAzm3vAdJZ66l2Inex_ jPvCTjx1qOXwtBGsmDRzhdS1OxE8lpj644FuzBLvAHkE6lHj5Febe_tyagj2KlvySJ2_cqrvvxKs dOLRqtcx2SSYDSpWXkdf7nM1LLONxpgctGnkV7jh7v4OgMitbjOdozVtb0GaQAILOv2qPHwCqE8D YYZAgV2SBGPFXWIDkV3_OZ1poMphk0Ujym71cDJ7gG1imFszL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7LRVHr ptCkmVQW_OIKokRFrez6_SLeJakBMvrN7p.R95dZ2sat4NmHE6RbYsPKe5078UZCtpXclPhwq3Ec Ctln5UJSys9WnbdEI6iGkvb4mUiUvQC6WcotAX6lEoz8vioekWEX5OrZM8GYjfbkuf.lZE9UJXI_ X.iQZfTBZQeejjfmivxbcNDM8RkRcbT4S5bjzy9zGqVPV6vBWDcwb53v_VRNOeU2fnBjlilQLQ6n c2l0pgzNNIY9xt2e_0YYkRtklKe9TFCBdnInCKxotvd3X8D3OniCUmK8d8JndCo5rVVw.pg2_vW5 HrTR6asOo4xATwPxyCQvuc5QKE54P7NurnEMmv48cgJghlBYTAcbixGyEkvuXW0GQL6EFP3cFs3V ZXeEBL8PSWbU.Mrvezif4s0HeVdvUMzNCPGMM8dEjvv2QSvtfnhhCTllz2QSnSlqIq_YE0KsirfG WA1w4cRJ.TAwULfnBSl9TWbnvHMRBdOajcSg3bQ8YK8luJQQ7zvD4exIP3toPGqBmsKjmdoSOM0U lnPmzc9ZkTL1fy5MPSSenz4fm1j7HTKRG3wMuN7fY.huJEOKlNGcBe07.iplWnYEGQDFEDXyaIKI RYu._h2yNGqX6E1IX7CUDbxzfjQ2qxm5zAWtxNRV1S1tWRhrgrqpJcnGQZhd4kimNjWlYyIeu55M oWfjMMJPp3LqUsZenVVIkwSm3qD_xRaKdUFOxYY5dZJzND8d2Bw-- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic311.consmr.mail.ne1.yahoo.com with HTTP; Sun, 29 Jan 2023 11:01:01 +0000 Received: by hermes--production-sg3-9fc5746c8-8hlql (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 8cefd7fdd6fde7a1a32a4bd90166c8d5; Sun, 29 Jan 2023 11:00:54 +0000 (UTC) From: Po Lu To: bug-gnu-emacs@gnu.org Subject: CC Mode 5.35.2 (C/*l); Incorrect fontification (but different from last time) X-Debbugs-Package: cc-mode Date: Sun, 29 Jan 2023 19:00:47 +0800 Message-ID: <87wn55zjts.fsf@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable References: <87wn55zjts.fsf.ref@yahoo.com> X-Mailer: WebService/1.1.21123 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 5348 Received-SPF: pass client-ip=66.163.188.204; envelope-from=luangruo@yahoo.com; helo=sonic311-23.consmr.mail.ne1.yahoo.com 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-Spam-Score: -0.6 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.6 (-) Package: cc-mode Emacs : GNU Emacs 30.0.50 (build 41, x86_64-pc-linux-gnu) of 2023-01-29 Package: CC Mode 5.35.2 (C/*l) Buffer Style: gnu c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-st= ring-delim gen-comment-delim syntax-properties category-properties 1-bit) Insert the following text in a C Mode buffer: static sfnt_f26dot6 sfnt_mul_f26dot6 (sfnt_f26dot6 a, sfnt_f26dot6 b) { #ifdef INT64_MAX return (sfnt_f26dot6) ((int64_t) a * b + (1 << 5) >> 6); #else int negative; unsigned short al, bl, ah, bh; unsigned int lowlong, midlong, hilong; negative =3D 0; /* Compensate for complement and determine if the result will be negative. */ if (a < 0) { a =3D -a; negative =3D 1; } if (b < 0) { b =3D -b; negative ^=3D true; } /* Load low and high words from A and B. */ al =3D a & 0xffff; bl =3D b & 0xffff; ah =3D a >> 16; bh =3D b >> 16; /* Multiply the various bits separately. */ midlong =3D (unsigned int) al * bh; #endif } In ``al * bh'', al is fontified as a type, and bh an identifier. current state: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (setq c-basic-offset 2 c-comment-only-line-offset '(0 . 0) c-indent-comment-alist '((anchored-comment column . 0) (end-block space . = 1) (cpp-end-block space . 2)) c-indent-comments-syntactically-p nil c-block-comment-prefix "" c-comment-prefix-regexp '((pike-mode . "//+!?\\|\\**") (awk-mode . "#+") (other . "//+\\|\\**")) c-doc-comment-style '((java-mode . javadoc) (pike-mode . autodoc) (c-mode . gtkdoc) (c++-mode . gtkdoc)) c-cleanup-list '(scope-operator) c-hanging-braces-alist '((substatement-open before after) (arglist-cont-nonempty)) c-hanging-colons-alist nil c-hanging-semi&comma-criteria '(c-semi&comma-inside-parenlist) c-backslash-column 48 c-backslash-max-column 72 c-special-indent-hook '(t c-gnu-impose-minimum) c-label-minimum-indentation 1 c-offsets-alist '((inexpr-class . +) (inexpr-statement . +) (lambda-intro-cont . +) (inlambda . 0) (template-args-cont c-lineup-template-args +) (incomposition . +) (inmodule . +) (innamespace . +) (inextern-lang . +) (composition-close . 0) (module-close . 0) (namespace-close . 0) (extern-lang-close . 0) (composition-open . 0) (module-open . 0) (namespace-open . 0) (extern-lang-open . 0) (objc-method-call-cont c-lineup-ObjC-method-call-colons c-lineup-ObjC-method-call + ) (objc-method-args-cont . c-lineup-ObjC-method-args) (objc-method-intro . [0]) (friend . 0) (cpp-define-intro c-lineup-cpp-define +) (cpp-macro-cont . +) (cpp-macro . [0]) (inclass . +) (stream-op . c-lineup-streamop) (arglist-cont-nonempty c-lineup-gcc-asm-reg c-lineup-arglist ) (arglist-cont c-lineup-gcc-asm-reg 0) (comment-intro c-lineup-knr-region-comment c-lineup-comment ) (catch-clause . 0) (else-clause . 0) (do-while-closure . 0) (access-label . -) (case-label . 0) (substatement . +) (statement-case-intro . +) (statement . 0) (brace-entry-open . 0) (brace-list-entry . 0) (brace-list-close . 0) (block-close . 0) (block-open . 0) (inher-cont . c-lineup-multi-inher) (inher-intro . +) (member-init-cont . c-lineup-multi-inher) (member-init-intro . +) (annotation-var-cont . +) (annotation-top-cont . 0) (topmost-intro . 0) (knr-argdecl . 0) (func-decl-cont . +) (inline-close . 0) (class-close . 0) (class-open . 0) (defun-block-intro . +) (defun-close . 0) (defun-open . 0) (c . c-lineup-C-comments) (string . c-lineup-dont-change) (topmost-intro-cont first c-lineup-topmost-intro-cont c-lineup-gnu-DEFUN-intro-cont ) (brace-list-intro first c-lineup-2nd-brace-entry-in-arglist c-lineup-class-decl-init-+ + ) (brace-list-open . +) (inline-open . 0) (arglist-close . c-lineup-arglist) (arglist-intro . c-lineup-arglist-intro-after-paren) (statement-cont . +) (statement-case-open . +) (label . 0) (substatement-label . 0) (substatement-open . +) (knr-argdecl-intro . 5) (statement-block-intro . +) ) c-buffer-is-cc-mode 'c-mode c-tab-always-indent t c-syntactic-indentation t c-syntactic-indentation-in-macros t c-ignore-auto-fill '(string cpp code) c-auto-align-backslashes t c-backspace-function 'backward-delete-char-untabify c-delete-function 'delete-char c-electric-pound-behavior nil c-default-style '((java-mode . "java") (awk-mode . "awk") (other . "gnu")) c-enable-xemacs-performance-kludge-p nil c-old-style-variable-behavior nil defun-prompt-regexp nil tab-width 8 comment-column 32 parse-sexp-ignore-comments t parse-sexp-lookup-properties t auto-fill-function nil comment-multi-line t comment-start-skip "\\(?://+\\|/\\*+\\)\\s *" fill-prefix nil fill-column 70 paragraph-start "[ ]*\\(//+\\|\\**\\)[ ]*$\\|^\f" adaptive-fill-mode t adaptive-fill-regexp "[ ]*\\(//+\\|\\**\\)[ ]*\\([ ]*\\([-=E2=80=93!|#%= ;>*=C2=B7=E2=80=A2=E2=80=A3=E2=81=83=E2=97=A6]+[ ]*\\)*\\)" ) From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 30 16:53:21 2023 Received: (at 61144) by debbugs.gnu.org; 30 Jan 2023 21:53:21 +0000 Received: from localhost ([127.0.0.1]:50785 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMc5Y-0008E3-Sq for submit@debbugs.gnu.org; Mon, 30 Jan 2023 16:53:21 -0500 Received: from mx3.muc.de ([193.149.48.5]:13719) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMc5X-0008Dp-6a for 61144@debbugs.gnu.org; Mon, 30 Jan 2023 16:53:19 -0500 Received: (qmail 78439 invoked by uid 3782); 30 Jan 2023 22:53:12 +0100 Received: from acm.muc.de (p4fe15765.dip0.t-ipconnect.de [79.225.87.101]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 30 Jan 2023 22:53:11 +0100 Received: (qmail 8007 invoked by uid 1000); 30 Jan 2023 21:53:11 -0000 Date: Mon, 30 Jan 2023 21:53:11 +0000 To: Po Lu Subject: Re: bug#61144: CC Mode 5.35.2 (C/*l); Incorrect fontification (but different from last time) Message-ID: References: <87wn55zjts.fsf.ref@yahoo.com> <87wn55zjts.fsf@yahoo.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="pl6SfnFgYUoIZTaD" Content-Disposition: inline In-Reply-To: <87wn55zjts.fsf@yahoo.com> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61144 Cc: 61144@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --pl6SfnFgYUoIZTaD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello, Po. On Sun, Jan 29, 2023 at 19:00:47 +0800, Po Lu via CC-Mode-help wrote: > Package: cc-mode > Emacs : GNU Emacs 30.0.50 (build 41, x86_64-pc-linux-gnu) > of 2023-01-29 > Package: CC Mode 5.35.2 (C/*l) > Buffer Style: gnu > c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-string-delim gen-comment-delim syntax-properties category-properties 1-bit) > Insert the following text in a C Mode buffer: > static sfnt_f26dot6 > sfnt_mul_f26dot6 (sfnt_f26dot6 a, sfnt_f26dot6 b) > { > #ifdef INT64_MAX > return (sfnt_f26dot6) ((int64_t) a * b + (1 << 5) >> 6); > #else > int negative; > unsigned short al, bl, ah, bh; > unsigned int lowlong, midlong, hilong; > negative = 0; > /* Compensate for complement and determine if the result will be > negative. */ > if (a < 0) > { > a = -a; > negative = 1; > } > if (b < 0) > { > b = -b; > negative ^= true; > } > /* Load low and high words from A and B. */ > al = a & 0xffff; > bl = b & 0xffff; > ah = a >> 16; > bh = b >> 16; > /* Multiply the various bits separately. */ > midlong = (unsigned int) al * bh; > #endif > } > In ``al * bh'', al is fontified as a type, and bh an identifier. Yes. foo * bar is a difficult case, since it can either be a multiplication or a declaration of bar as a pointer to foo. There is no reliable way to distinguish these two cases without a full parser. No doubt c-ts-mode will do better here. In another similar case, I have disambiguated these with "whitespace asymmetry" - If there's WS both before and after the "*" or neither, it's treated as a multiplication. Otherwise it's a declaration. I've extended this heuristic to treat the case in your test file. Would you try out the attached patch, please (it applies cleanly to the master branch). I would be in favour of putting the patch into the release branch, but given the patch is ~90 lines long, Eli might object. Anyhow, please try it out, and let me know what you think about it. Thanks! [ .... ] -- Alan Mackenzie (Nuremberg, Germany). --pl6SfnFgYUoIZTaD Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="diff.20230130.diff" diff -r 15a49bc02b66 cc-engine.el --- a/cc-engine.el Mon Jan 30 19:39:13 2023 +0000 +++ b/cc-engine.el Mon Jan 30 21:39:55 2023 +0000 @@ -10167,6 +10167,24 @@ ;; This identifier is bound only in the inner let. '(setq start id-start)))) +(defmacro c-fdoc-assymetric-space-about-asterisk () + ;; We've got a "*" at `id-start' between two identifiers, the first at + ;; `type-start'. Return non-nil when there is either whitespace between the + ;; first id and the "*" or between the "*" and the second id, but not both. + `(let ((space-before-id + (save-excursion + (goto-char id-start) ; Position of "*". + (and (> (skip-chars-forward "* \t\n\r") 0) + (memq (char-before) '(?\ ?\t ?\n ?\r))))) + (space-after-type + (save-excursion + (goto-char type-start) + (and (c-forward-type nil t) + (or (eolp) + (memq (char-after) '(?\ ?\t))))))) + (not (eq (not space-before-id) + (not space-after-type))))) + (defun c-forward-decl-or-cast-1 (preceding-token-end context last-cast-end &optional inside-macro) ;; Move forward over a declaration or a cast if at the start of one. @@ -11185,19 +11203,25 @@ ;; CASE 16 (when (and got-prefix-before-parens at-type - (or at-decl-end (looking-at "=[^=]")) (memq context '(nil top)) (or (not got-suffix) at-decl-start)) ;; Got something like "foo * bar;". Since we're not inside ;; an arglist it would be a meaningless expression because ;; the result isn't used. We therefore choose to recognize - ;; it as a declaration. We only allow a suffix (which makes - ;; the construct look like a function call) when - ;; `at-decl-start' provides additional evidence that we do - ;; have a declaration. + ;; it as a declaration when there's "symmetrical WS" around + ;; the "*" or the flag `c-assymetry-fontification-flag' is + ;; not set. We only allow a suffix (which makes the + ;; construct look like a function call) when `at-decl-start' + ;; provides additional evidence that we do have a + ;; declaration. (setq maybe-expression t) - (throw 'at-decl-or-cast t)) + (when (or (not c-asymmetry-fontification-flag) + (looking-at "=[^=]") + (c-fdoc-assymetric-space-about-asterisk)) + (when (eq at-type 'maybe) + (setq unsafe-maybe t)) + (throw 'at-decl-or-cast t))) ;; CASE 17 (when (and (or got-suffix-after-parens @@ -11216,24 +11240,12 @@ got-prefix-before-parens at-type (or (not got-suffix) - at-decl-start)) - (let ((space-before-id - (save-excursion - (goto-char id-start) ; Position of "*". - (and (> (skip-chars-forward "* \t\n\r") 0) - (memq (char-before) '(?\ ?\t ?\n ?\r))))) - (space-after-type - (save-excursion - (goto-char type-start) - (and (c-forward-type nil t) - (or (eolp) - (memq (char-after) '(?\ ?\t))))))) - (when (not (eq (not space-before-id) - (not space-after-type))) - (when (eq at-type 'maybe) - (setq unsafe-maybe t)) - (setq maybe-expression t) - (throw 'at-decl-or-cast t))))) + at-decl-start) + (c-fdoc-assymetric-space-about-asterisk)) + (when (eq at-type 'maybe) + (setq unsafe-maybe t)) + (setq maybe-expression t) + (throw 'at-decl-or-cast t))) ;; CASE 18 (when (and at-decl-end --pl6SfnFgYUoIZTaD-- From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 30 20:23:23 2023 Received: (at 61144) by debbugs.gnu.org; 31 Jan 2023 01:23:23 +0000 Received: from localhost ([127.0.0.1]:50985 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMfMo-0005HY-Ua for submit@debbugs.gnu.org; Mon, 30 Jan 2023 20:23:23 -0500 Received: from sonic313-10.consmr.mail.ne1.yahoo.com ([66.163.185.33]:34225) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMfMn-0005HJ-2x for 61144@debbugs.gnu.org; Mon, 30 Jan 2023 20:23:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1675128193; bh=rlm0lcnwOmKr8n37SPzhXS5Q5rhJmyMzgoup8yJ4RLA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=PwisV3yXL7q0r7htH+Zl7EdZBChHIMaPFWh4LOyGHc4YzyX9ea6pRo8Z7XyK+GG0ZPG1oFNQ6tBfx1lQIXzjdzJAurpEm5cJ/e/UftT7qa6JjpFunBWYGZSQ68t3upaIwat7Xvf5QeYNFIOAi4RcaQbOkqNgrp8z4qtqvZWKLgilbF6WWsN9kgx9zNsTsRqRpXOuC+TIeWjO318aCVV8u3upuINaEAvbu8Az+2ZyXhDwM/RH/1wHx9tewCzvSeAT/ijKBjkcdjsFtf00+4eGPGmJIaasn+kgnwKcLpg9BKZNrBTutFJduYTIk3kJnYnnFeBGiP6nryLQty95B9ojFw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1675128193; bh=oZCFTJcTulN0e9tLglC/x3ab35RIfF+H7Lm2goy5Doh=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=dDbEfewLW03xmMPUOKXugKg3U75Na8Bmr+Blg4U6+564QY3Q6QUt5tdPEf8Lzlb/5UphHle/IRvl6hFEd3qoDo52GKT6EYnkuTM1Dv02/3CNj5g0mLXOQjbG71S2hzeeZA+qn7IRaV4kJ53ywQnJv9OrZh/Mr3W7D3it4U32rckJhcsrKOPupKMvX7lZZkP/bFW/tIDiLco0e+mcV8rApI8zV3wynYUatHxJUiZvuX59k5vx5yfPz6Sv+D96DCEhRKJ9BtijOQmq44J1zv6DT9h8MxuPHqv/r/J//nRPW3VIJLb2jian8hSGD4+gto2RcQZ4BAx7PYR2eUEd1YsiDQ== X-YMail-OSG: GyOzRfAVM1l4R1UoHxroa4PolJO5JBY57C0nlGyFG0_I2ehCPQ2CLRiw8e_kU9W XIXcXrI09YZx565MoOkjWTDJCD0ya6tDuxPOFlFFFmEEnuX1ZKJnq.z8uskS45p5NqbOHdl4_xW3 8HIaR1CZAvK0gInKtTJb9O0MfU_oyMh8rGRWJkliuucaAle_StPBel4sFAM.wKYMoHnK.nk6BCyx SdNWYr2cnlY7NIeVg_ZIW48B6fwV6zWFzaeWNuaw.hDYQ37fMLHLIz0WftCCw7kFi4HSajXbko8q CHY1JJt39dK2opNEtUxcyrlL7H_BGbATnovOsVVGP1MjWkmmfQ.E1EB3W0egblMB4ywgciAW5QcH fE23vYS5nhiwH6jbMf92krQfLQ83CSZSWGE3B4fqKOBjfq3r57Wy6aGJxOg_2xh8mNon9RErm__2 xz5BHnQjHsIwnM6DwM9O0IUFNJocJ9l6Y1xJO6OQgEXWdoJWrQWbd43aUWt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Hz8FN SmK1n7lga2qdJ1vfeVNOB4gRMpQsK8t0EX2m7ErM59eR1mXFUPiS0gV7bh8gZclKGMCFJ7JS8M1e RXpmzG2ZUUYrqey3pUvFm_2L8Y.URsMUEYARK8MA6MDQ5vU81xWWgzoCw74UuP42uA_d.p2f7.He xLpRP_1Y7mn.TqwQepdJ_YmoBnORKZ.fsAYh9VI9lgTdGnOLH2Fm2OZqMCbUIjpQIACY2QonRlDl ikv.rU2Wf1stCiAox6gDSJoTAetUFqEjwBq2kUb.l8n5K3j_zdzhioods9.GwN0DZXCGCAIqqnBh .AokO.1RZmVLEE2rWg6x8RTeGYb0VY5adAXnWrAHM_ODd0kxTteD5NbUlZE4Pmx9tkcC4ky8aL9Z 0_w3DoCmFvNsVFpIPWO2LC5YxZO_uEccxJjB11YBHY9WTuGdIEjsS5PMM9fo8w0uAAk9ZSCLUivT 4ZeR3Kd3eN4Qp_G7a54w7d1MnK4__94kvwQJKDBL9qK8gyUSaQNp9XHapyDASkW3BlNYmyEGyhAO x7SOk7gvdqk5x5r1C5_thrzkfPsgbWL8DHwdhb3P_PtcOBFen0xyigfxcPnZ50KMmUop.Ra0Bv0s gX7qtX24ld625FoZXMKFvukIGsRG9Rq_XcXvfmoWHrprHdRd8XdZWgGsNMGqfzTLwuEPXRYOiicM hUvRcyefWlw3mvB_LLPTi5UAxXG2a753s8fVJjqBnTti2gG_KxFAL9ke6hZmaPw-- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.ne1.yahoo.com with HTTP; Tue, 31 Jan 2023 01:23:13 +0000 Received: by hermes--production-sg3-9fc5746c8-b8cx5 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 0aa824a75a3d5c640066b98eb4b0555f; Tue, 31 Jan 2023 01:23:07 +0000 (UTC) From: Po Lu To: Alan Mackenzie Subject: Re: bug#61144: CC Mode 5.35.2 (C/*l); Incorrect fontification (but different from last time) In-Reply-To: (Alan Mackenzie's message of "Mon, 30 Jan 2023 21:53:11 +0000") References: <87wn55zjts.fsf.ref@yahoo.com> <87wn55zjts.fsf@yahoo.com> Date: Tue, 31 Jan 2023 09:23:01 +0800 Message-ID: <874js7zedm.fsf@yahoo.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Mailer: WebService/1.1.21123 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 2216 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61144 Cc: 61144@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Alan Mackenzie writes: > Hello, Po. > > On Sun, Jan 29, 2023 at 19:00:47 +0800, Po Lu via CC-Mode-help wrote: >> Package: cc-mode > >> Emacs : GNU Emacs 30.0.50 (build 41, x86_64-pc-linux-gnu) >> of 2023-01-29 >> Package: CC Mode 5.35.2 (C/*l) >> Buffer Style: gnu >> c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-string-delim gen-comment-delim syntax-properties category-properties 1-bit) > >> Insert the following text in a C Mode buffer: > >> static sfnt_f26dot6 >> sfnt_mul_f26dot6 (sfnt_f26dot6 a, sfnt_f26dot6 b) >> { >> #ifdef INT64_MAX >> return (sfnt_f26dot6) ((int64_t) a * b + (1 << 5) >> 6); >> #else >> int negative; >> unsigned short al, bl, ah, bh; >> unsigned int lowlong, midlong, hilong; > >> negative = 0; > >> /* Compensate for complement and determine if the result will be >> negative. */ > >> if (a < 0) >> { >> a = -a; >> negative = 1; >> } > >> if (b < 0) >> { >> b = -b; >> negative ^= true; >> } > >> /* Load low and high words from A and B. */ >> al = a & 0xffff; >> bl = b & 0xffff; >> ah = a >> 16; >> bh = b >> 16; > >> /* Multiply the various bits separately. */ >> midlong = (unsigned int) al * bh; >> #endif >> } > >> In ``al * bh'', al is fontified as a type, and bh an identifier. > > Yes. foo * bar is a difficult case, since it can either be a > multiplication or a declaration of bar as a pointer to foo. There is no > reliable way to distinguish these two cases without a full parser. No > doubt c-ts-mode will do better here. > > In another similar case, I have disambiguated these with "whitespace > asymmetry" - If there's WS both before and after the "*" or neither, > it's treated as a multiplication. Otherwise it's a declaration. > > I've extended this heuristic to treat the case in your test file. Would > you try out the attached patch, please (it applies cleanly to the master > branch). I would be in favour of putting the patch into the release > branch, but given the patch is ~90 lines long, Eli might object. > > Anyhow, please try it out, and let me know what you think about it. > Thanks! > > [ .... ] Thank you, this works here. From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 03 16:01:20 2023 Received: (at 61144-done) by debbugs.gnu.org; 3 Feb 2023 21:01:20 +0000 Received: from localhost ([127.0.0.1]:40035 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pO3BP-00039J-O3 for submit@debbugs.gnu.org; Fri, 03 Feb 2023 16:01:19 -0500 Received: from mx3.muc.de ([193.149.48.5]:14988) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pO3BK-000390-Tm for 61144-done@debbugs.gnu.org; Fri, 03 Feb 2023 16:01:18 -0500 Received: (qmail 92111 invoked by uid 3782); 3 Feb 2023 22:01:07 +0100 Received: from acm.muc.de (pd953ab76.dip0.t-ipconnect.de [217.83.171.118]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 03 Feb 2023 22:01:06 +0100 Received: (qmail 5919 invoked by uid 1000); 3 Feb 2023 21:01:06 -0000 Date: Fri, 3 Feb 2023 21:01:06 +0000 To: Po Lu Subject: Re: bug#61144: CC Mode 5.35.2 (C/*l); Incorrect fontification (but different from last time) Message-ID: References: <87wn55zjts.fsf.ref@yahoo.com> <87wn55zjts.fsf@yahoo.com> <874js7zedm.fsf@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <874js7zedm.fsf@yahoo.com> X-Submission-Agent: TMDA/1.3.x (Ph3nix) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 61144-done Cc: 61144-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Po. On Tue, Jan 31, 2023 at 09:23:01 +0800, Po Lu wrote: > Alan Mackenzie writes: > > On Sun, Jan 29, 2023 at 19:00:47 +0800, Po Lu via CC-Mode-help wrote: > >> Package: cc-mode > >> Emacs : GNU Emacs 30.0.50 (build 41, x86_64-pc-linux-gnu) > >> of 2023-01-29 > >> Package: CC Mode 5.35.2 (C/*l) > >> Buffer Style: gnu > >> c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-string-delim gen-comment-delim syntax-properties category-properties 1-bit) [ .... ] > > Anyhow, please try it out, and let me know what you think about it. > > Thanks! > > [ .... ] > Thank you, this works here. Thanks! I've committed the patch and I'm closing the bug with this post. -- Alan Mackenzie (Nuremberg, Germany). From unknown Tue Jun 24 19:10:35 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 04 Mar 2023 12:24:11 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator