From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MUb+EqCV12r5DzsAWB0awg (envelope-from ) for ; Tue, 20 Oct 2026 12:24:00 -0400 Received: by simark.ca (Postfix, from userid 112) id 4B5531E04D; Tue, 20 Oct 2026 12:24:00 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id A44631E04D for ; Tue, 20 Oct 2026 12:23:59 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 416FF4A9A884 for ; Tue, 20 Oct 2026 16:23:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 416FF4A9A884 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id C0C4E4A9A884 for ; Tue, 20 Oct 2026 16:23:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C0C4E4A9A884 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C0C4E4A9A884 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792513381; cv=none; b=Op9e0R0V1rNcqIOp/BHkYoRR4y+hXdZ3lMfYETGp47jKx900Gp4nfR1J0jhMl6mXp7wIdnvEpY2cUIkbSBic+o1s8BXovZcQ9CUkXtIKIxTOO3lJkg1orAT3PNQCQN6Vw1+g82TQo5+FCXcjSenE1h6Nsc8cP2udUnBujcAv9EE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792513381; c=relaxed/simple; bh=cx0tAs7jbhwKPQlczh8BohCdjOIA08wIHDed+XFe5tU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=iQhKtWWHnFJQmx25i3Mw7+ic4mDwHNbjMMjtLY5VTCPmxHMCiE25hm7mT1JZGUS/B4ET/g3zPo0Qx23ltotvlX2CLbAu4DJ0q0VsuiIecQ+fuGrdrDZtnvmmTcEfN9s2rBgqqhy8+lpGeBv3GbUQXhodu645q/bP1uMdWTqsMdw= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C0C4E4A9A884 Received: by simark.ca (Postfix) id 488EA1E04F; Tue, 20 Oct 2026 12:23:01 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 09/13] gdb: remove backslash-newline handling from cp_parse_escape Date: Tue, 20 Oct 2026 12:17:31 -0400 Message-ID: <20261020162054.2140671-10-simon.marchi@efficios.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261020162054.2140671-1-simon.marchi@efficios.com> References: <20261020162054.2140671-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org From: Simon Marchi cp_parse_escape returns -2 when the backslash is followed by a newline. In source code, a backslash-newline is a line splice, which can appear anywhere, including in string literals. But cp_parse_escape does not need to handle that. This comes from GDB's old generic parse_escape function, where a negative value told the caller to treat the sequence as nothing at all, emulating a line splice. lex_char_literal doesn't even handle that: it uses the returned -2 as the value of the character, so C<'\'> canonicalizes to "C<(char)-2>". Remove the special case. A backslash followed by a newline is now handled like any other unknown escape sequence, giving the character following the backslash. So now, C<'\'> canonicalizes to "C<(char)10>". cp_parse_escape doesn't reject unknown escape sequences in general, which is acceptable, and we don't expect to see this one in practice anyway. Update the comment of cp_parse_escape, which mentioned the negative value for backslash-newline. Change-Id: I25a4587309f201ac8da2ae87361ad4f3e89d7327 --- gdb/cp-name-parser.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/gdb/cp-name-parser.c b/gdb/cp-name-parser.c index 4c5f18c9851f..931f74e8ed51 100644 --- a/gdb/cp-name-parser.c +++ b/gdb/cp-name-parser.c @@ -470,9 +470,6 @@ c_parse_backslash (int host_char, int *target_char) is updated past the characters we use. The value of the escape sequence is returned. - A negative value means the sequence \ newline was seen, - which is supposed to be equivalent to nothing at all. - If \ is followed by a null character, we return a negative value and leave the string pointer pointing at the null character. @@ -489,8 +486,6 @@ cp_parse_escape (const char **string_ptr) else switch (c) { - case '\n': - return -2; case 0: (*string_ptr)--; return 0; -- 2.56.0