From nobody Mon Jun 16 19:33:59 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4bLgD774DBz5yJvh; Mon, 16 Jun 2025 19:33:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bLgD76P6Fz3w0j; Mon, 16 Jun 2025 19:33:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750102439; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=81S/8PRVsb8D+cY+QLqfPE8H+7Rrhy6gEDeIhqLR4fU=; b=I2NQ5PYRn5+mNTHdAuDX2DGNhEr9WtsGS9vvOEfmv4gjyHwUf6SeFEO3THhluWrCTIMjrb 6USAn8Q3lL99f9i+3SzeFv/MF8Y1ZI6hOOaF4RJR6tJIN2LAG0Cafah+sBNP8Ssk3fU/gW UsymPMYphkfyM6HS/GHp1OFjrvcMtARdYH0McVS/gXqE4oFUhVKyMKEuVoteGgaiknaIPY gp2G9/Yo3jVOCrNK5IZfrXBmCpJb+Ml8i36VefVudNeY8wrwzGtTfYyeXtimFYUnxlDcQD +h27AIeVcirh6MjBJub29yuhN0F0Rb0+NrxaRPdRlpkzSoP9O899s8FKVy5q0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750102439; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=81S/8PRVsb8D+cY+QLqfPE8H+7Rrhy6gEDeIhqLR4fU=; b=beTuZwz5GqigORMQqyH7ii4BttXVmEJ0byNdwlI9hDmbdIsgj02mezHhVZO83CWu8KbHb3 4VpfnxOgHPHMoCNs/WS4WUbQVxuaeDuaJKkeUC2P0PWR+jfZI/HdOTut7uQ6kn7uefDHNd IstIVCSY6fqlATXM8r2BKOKFmxywAifCsNhEatQwJVe3Fl3yDftnpQ3rfW8eKnh3ZJrd6n 7JV68xY5flK+qT/z0V18NfU5IJ69q2jvkiEhKuatYasLGoYWJXcc2qSjCtZWpU24ZLz4i8 UpjikfBjIiaqN1MLVF+QGPbtunil8efAri5waUcOdJlBgKZJ52J2dUaJnaG2OA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1750102439; a=rsa-sha256; cv=none; b=HDK5OBM65dZLxHOKhzJOaFzG7OcY56qxcDxdd0imqSzL99Pa28HBz3Vxkg/ba4tCLlbhE5 tXO8fkuk7LEDWwJ0BxaaMcfMW+5i1mCvoVNVxuswiWA2x5RJ9wc8MPrSQAY6kf0BkIiBtg 0msXK7f31v7AHCu8X75RPifHv2ixqLu8vlYLi6tk1yoveFA7IgNh7rMTAA4Q9WffxUYkhe hg0HLsa5VbtzL4wuEPaIBkxGs6WqoYXwmVIKLaKc5u0ZAZ8no1Z7J16whUKmq3s0hZ8HIj U32dmDF7adj91f5SplPo+t2L0dCVU0L8AyuJ/xS/2HKL8ecu9NZ9NjGkogkG+w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4bLgD75rRcz19Xg; Mon, 16 Jun 2025 19:33:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 55GJXxm5047058; Mon, 16 Jun 2025 19:33:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 55GJXxga047055; Mon, 16 Jun 2025 19:33:59 GMT (envelope-from git) Date: Mon, 16 Jun 2025 19:33:59 GMT Message-Id: <202506161933.55GJXxga047055@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jose Luis Duran Subject: git: 4dfbc03d6492 - main - dtc: Sync with upstream commit 23387dd List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jlduran X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4dfbc03d6492d9fccb781700cc17d58111dff456 Auto-Submitted: auto-generated The branch main has been updated by jlduran: URL: https://cgit.FreeBSD.org/src/commit/?id=4dfbc03d6492d9fccb781700cc17d58111dff456 commit 4dfbc03d6492d9fccb781700cc17d58111dff456 Author: Jose Luis Duran AuthorDate: 2025-06-16 19:31:43 +0000 Commit: Jose Luis Duran CommitDate: 2025-06-16 19:31:57 +0000 dtc: Sync with upstream commit 23387dd Add the ability to parse char literals needed to compile DTBs currently in base. Reviewed by: theraven, emaste Approved by: emaste (mentor) Differential Revision: https://reviews.freebsd.org/D42438 --- usr.bin/dtc/input_buffer.cc | 53 +++++++++++++++++++++++++++++++++++++++++++++ usr.bin/dtc/input_buffer.hh | 22 +++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/usr.bin/dtc/input_buffer.cc b/usr.bin/dtc/input_buffer.cc index 278dd42b5ac6..20f747f29cd8 100644 --- a/usr.bin/dtc/input_buffer.cc +++ b/usr.bin/dtc/input_buffer.cc @@ -337,6 +337,47 @@ input_buffer::consume(const char *str) return false; } +bool +input_buffer::consume_char_literal(unsigned long long &outInt) +{ + outInt = (unsigned char)((*this)[0]); + cursor++; + + if(outInt != '\\') + { + return true; + } + else if(cursor >= size) + { + return false; + } + + outInt = (unsigned char)((*this)[0]); + cursor++; + + switch (outInt) { + default: + return false; + case 'n': + outInt = (unsigned char)'\n'; + break; + case 'r': + outInt = (unsigned char)'\r'; + break; + case 't': + outInt = (unsigned char)'\t'; + break; + case '0': + outInt = 0; + break; + case '\'': + case '\\': + break; + } + + return true; +} + bool input_buffer::consume_integer(unsigned long long &outInt) { @@ -874,6 +915,18 @@ expression_ptr text_input_buffer::parse_expression(bool stopAtParen) source_location l = location(); switch (*(*this)) { + case '\'': + consume('\''); + if(!consume_char_literal(leftVal)) + { + return nullptr; + } + if (!consume('\'')) + { + return nullptr; + } + lhs.reset(new terminal_expr(l, leftVal)); + break; case '0'...'9': if (!consume_integer(leftVal)) { diff --git a/usr.bin/dtc/input_buffer.hh b/usr.bin/dtc/input_buffer.hh index d6b033952bad..395c7b044df3 100644 --- a/usr.bin/dtc/input_buffer.hh +++ b/usr.bin/dtc/input_buffer.hh @@ -193,6 +193,13 @@ class input_buffer * current point in the input. */ bool consume(const char *str); + /** + * Reads unsigned from char literal. Returns true and advances + * the cursor to next char. + * + * The parsed value is returned via the argument. + */ + bool consume_char_literal(unsigned long long &outInt); /** * Reads an integer in base 8, 10, or 16. Returns true and advances * the cursor to the end of the integer if the cursor points to an @@ -412,6 +419,21 @@ class text_input_buffer } return input_stack.top()->consume(str); } + /** + * Converts next char into unsigned + * + * The parsed value is returned via the argument. + * + * This method does not scan between files. + */ + bool consume_char_literal(unsigned long long &outInt) + { + if (input_stack.empty()) + { + return false; + } + return input_stack.top()->consume_char_literal(outInt); + } /** * Reads an integer in base 8, 10, or 16. Returns true and advances * the cursor to the end of the integer if the cursor points to an