Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQZ9S-00BTYs-1A for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Dec 2025 22:47:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vQZ9Q-00AJdn-1G for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Dec 2025 22:47:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQZ9Q-00AJdf-0M for pgsql-hackers@lists.postgresql.org; Tue, 02 Dec 2025 22:47:16 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vQZ9N-002pC7-0I for pgsql-hackers@lists.postgresql.org; Tue, 02 Dec 2025 22:47:15 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-297d4ac44fbso1725135ad.0 for ; Tue, 02 Dec 2025 14:47:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764715633; x=1765320433; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=UHPVqHIH4O9ceUrwvMvwkzktjWSxnkgdd5HUIaHIpUw=; b=dQKL+JMrCLIUG5MUGw0tAGsUeytjo20mEYmI/AnuDJBTc7YM/UmPC7AO9kjbH3YiAE IJQK3VPWrSSwtkO/FKPw+j3cJ4vdx0EnwMVdoqirXq8ucEreuEIGg+SLLsEJCzt4QXe8 lWUWVj1dADH5ayVrqEEpUjMt7IUUTkifELiYExSPTd6G9A2hQ82FimBwWq6zUAbcJMvv IqhctGmG4gEJGei2AKS2Zj54vN0CHNOhhwWYo3NB6zaMfs5daxIy8++ZNmlwAhP89kLs x9nNg/rJqigxLbg01DNPalceDdUwXtxjMmgy4cIUsDh1dNEo6eMBLFykPsWPKwrW//nt +kSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764715633; x=1765320433; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=UHPVqHIH4O9ceUrwvMvwkzktjWSxnkgdd5HUIaHIpUw=; b=RT27Nj6SHeFsfvU2IOFzVcRKUbLWKrRDqtAlsW5y1nrwYGcHCd05zHGrZJ5HNHfKUa /4GsccOiqbH5p66HvFsS1zqLgBbtkorx1d7cEe7BChfBZt25fzXl6JtRRxklqvQ2zuuT ciO8roWnIWrFtmSoOoCWl04RLirit9w5EAl91mJtUtFvWGU7aF+N04eYEH1oTPO0edrM HzTXu2z4tSqBpq2bKyprK75Rf/S8LCWVdicPmovfHWFbOyKFKyxjQF/gKLkBs4Nt8Ssq QIQot04kZBeu4EsePhPxwTTRElTBsqWFbcgAhwLErg9kyUWVLYSdw0qUf4iaMgbkxyqT OiLQ== X-Forwarded-Encrypted: i=1; AJvYcCViUQYB8jUR0TV8ezffstuhiJZRZM89b7sOnKLobYT/VGy9sjgJIRRx9Mgh3wfYao6RX2utlXqZ/c5Y7xty@lists.postgresql.org X-Gm-Message-State: AOJu0YwmHs/RDxPeJqn0SSFE3fVjxanYunsW6W01VShDehbjh9PoXJLw F5hfM7mn64NKKbIMH9x+JgUm8wxghANQMiyZ9MNx69wYruzJOfv3fvQW X-Gm-Gg: ASbGncv7efQu5WAAkC0z6TnQ84wlACLU1lim2w9MfXYuJcVypaO2j2chkfB9fddQz74 mnYqx3kML8l5NOWQ+QU8bhJS1wURSMIdWn/MGrRs6C5J5NI8qTrQ7igN1mGOI/FjDZ4AumNWbaK GCT4wnKR6JnxYNYpZqiZxz0XAGrxA+U6JFa7mw7oGdsgSTVLBYsqk3ptT3iXfL9XTggKDhseMyf FyZiXEjj83405LXciCxwEY9YDnaEAEuxq6rZYVfWcq6mfG5qNRpQfhkYdqeWuV+7pKQP6Dw1qR8 ZYPDUL5oxOdn9x9y8Q4GjfJbgjw8Rquw1XhHmSBBoNIVwEfx+NRkiB2rlMUn00/6Pt2BGdkEGFR 4yR2k0xKupR85AkAPN4XZyrRqYtvIDxvRpIGXKYuBqobCrQX7EVvsLRLS8gMrBb+utsyL0BWL41 qTSesJOpPXsrULDPSQkgc= X-Google-Smtp-Source: AGHT+IFjXAlQ+ru1OmLu+L9eHrIKQZvfQM+D4gHNGT0fXywOARatfYTltT1TKK8NccqHyDoFS8LQ4Q== X-Received: by 2002:a17:903:fa5:b0:299:daf0:e044 with SMTP id d9443c01a7336-29d67f2af39mr3337545ad.18.1764715632648; Tue, 02 Dec 2025 14:47:12 -0800 (PST) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29bceb471c6sm162406055ad.79.2025.12.02.14.47.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Dec 2025 14:47:11 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: pgindent versus struct members and typedefs From: Chao Li In-Reply-To: Date: Wed, 3 Dec 2025 06:46:33 +0800 Cc: Rahila Syed , Robert Haas , PostgreSQL Hackers Content-Transfer-Encoding: quoted-printable Message-Id: <347EA055-D626-414C-B10D-7E70041B9B55@gmail.com> References: To: Nathan Bossart X-Mailer: Apple Mail (2.3826.700.81) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Dec 3, 2025, at 06:00, Nathan Bossart = wrote: >=20 > On Mon, Dec 01, 2025 at 05:04:23PM -0600, Nathan Bossart wrote: >> On Tue, Dec 02, 2025 at 05:35:34AM +0800, Chao Li wrote: >>> ``` >>> + else if (entry->type =3D=3D DSMR_ENTRY_TYPE_DSH && >>> + entry->dsh.dsa_handle !=3DDSA_HANDLE_INVALID) >>> ``` >>>=20 >>> Missing a white space after !=3D. >>=20 >> I agree, but for some reason, pgindent insists on removing that = space. I'm >> leaving that for another thread. >=20 > So, this seems to have something to do with the struct member having = the > same name as a typedef. If I rename the member, pgindent adds the = space as > expected. Interestingly, changing the !=3D to a =3D=3D also fixes the = spacing. > There are a couple of other examples in the code: >=20 > src/backend/storage/ipc/dsm_registry.c: entry->dsh.dsa_handle = !=3DDSA_HANDLE_INVALID) > src/backend/replication/logical/logicalfuncs.c: = ctx->options.output_type !=3DOUTPUT_PLUGIN_TEXTUAL_OUTPUT) > src/bin/pg_basebackup/pg_basebackup.c: if (state.manifest_file !=3DNULL)= > src/bin/pg_basebackup/pg_basebackup.c: state->manifest_file !=3DNULL) > src/bin/pg_basebackup/pg_basebackup.c: else if (state->manifest_file = !=3DNULL) >=20 > I used the following command to find these: >=20 > grep -E "!=3D[A-Za-z]" ./* -rI >=20 > AFAICT this is a special case of the note added to pgindent's README = by > commit c4133ec: >=20 > pgindent will mangle both declaration and definition of a C function = whose > name matches a typedef. Currently the best workaround is to choose > non-conflicting names. >=20 > I tried to fix pgindent for a few, but the code is basically = impenetrable. > I didn't find any fixes upstream [0], either. As noted above, we = could > also fix it by avoiding the naming conflicts. However, I can't = imagine > that's worth the churn, and I've already spent way too much time on = this, > so IMHO the best thing to do here is nothing. >=20 I think that=E2=80=99s fine. Actually I see the other problem with pgindent, where if a =E2=80=9Celse=E2= =80=9D clause contains a multiple-line comment and a single statement = without braces, for example: ``` else /* * comment */ printf(=E2=80=A6); ``` Then pgindent will blindly add an empty line after =E2=80=9Celse=E2=80=9D,= so we get: ``` else /* * comment */ printf(=E2=80=A6); ``` I tried to fix but failed. For that problem, a solution is to add braces = to the =E2=80=9Celse=E2=80=9D clause. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/