public inbox for [email protected]
help / color / mirror / Atom feedFrom: Xuneng Zhou <[email protected]>
To: Guoqing Yang <[email protected]>
Cc: [email protected]
Subject: Re: Fix Grammar in Buffer Lock Wait Message
Date: Fri, 10 Jul 2026 11:07:39 +0800
Message-ID: <CABPTF7U2_Qp76EpY5Jmx8eKCJ+oThFvan=L6ehETR5sz5dm00Q@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
Hi Guoqing,
On Wed, Jul 1, 2026 at 9:45 AM Guoqing Yang <[email protected]> wrote:
>
> Fix grammar in buffer lock wait message
>
> Correct the wait message from "Waiting to acquire a exclusive lock on a buffer"
> to "Waiting to acquire an exclusive lock on a buffer".
>
> The word "exclusive" starts with a vowel sound, so the indefinite article
> should be "an" instead of "a".
This seems to be a typo. I asked Sol to check this kind of issue in
the tree, and it found a bunch of them. Do you bother to do a further
check? As John suggested, we better fix grammar issues wholesale[1].
[1] https://www.postgresql.org/message-id/CANWCAZaZgQN54ccVheWd%3Dyg2KW_c1vTPB7hd0CXkqBNLD2-pDA%40mail.g...
--
Regards,
Xuneng Zhou
HighGo Software Co., Ltd.
Attachments:
[application/octet-stream] fix-indefinite-articles.patch (24.2K, ../CABPTF7U2_Qp76EpY5Jmx8eKCJ+oThFvan=L6ehETR5sz5dm00Q@mail.gmail.com/2-fix-indefinite-articles.patch)
download | inline diff:
diff --git a/doc/src/sgml/event-trigger.sgml b/doc/src/sgml/event-trigger.sgml
index c10627554bd..0041294d325 100644
--- a/doc/src/sgml/event-trigger.sgml
+++ b/doc/src/sgml/event-trigger.sgml
@@ -229,9 +229,9 @@
<para>
When a function is called by the event trigger manager, it is not passed
any normal arguments, but it is passed a <quote>context</quote> pointer
- pointing to a <structname>EventTriggerData</structname> structure. C functions can
- check whether they were called from the event trigger manager or not by
- executing the macro:
+ pointing to an <structname>EventTriggerData</structname> structure. C
+ functions can check whether they were called from the event trigger manager
+ or not by executing the macro:
<programlisting>
CALLED_AS_EVENT_TRIGGER(fcinfo)
</programlisting>
diff --git a/doc/src/sgml/func/func-admin.sgml b/doc/src/sgml/func/func-admin.sgml
index 0eae1c1f616..877a32c63e1 100644
--- a/doc/src/sgml/func/func-admin.sgml
+++ b/doc/src/sgml/func/func-admin.sgml
@@ -2257,10 +2257,10 @@ SELECT pg_restore_extended_stats(
and <literal>most_common_base_freqs</literal>.
To accept statistics for any expressions in the extended
statistics object, the parameter <literal>exprs</literal> with a type
- <type>jsonb</type> is available. This should be an one-dimension array
- with a number of expressions matching the definition of the extended
- statistics object, made of json elements for each of the statistical
- columns in
+ <type>jsonb</type> is available. This should be a one-dimensional
+ array with a number of expressions matching the definition of the
+ extended statistics object, made of json elements for each of the
+ statistical columns in
<link linkend="view-pg-stats-ext-exprs"><structname>pg_stats_ext_exprs</structname></link>.
</para>
<para>
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index 7d3c3bb66d8..bd4625f02a2 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -4928,10 +4928,10 @@ char *PQcmdTuples(PGresult *res);
Returns the OID<indexterm><primary>OID</primary><secondary>in libpq</secondary></indexterm>
of the inserted row, if the <acronym>SQL</acronym> command was an
<command>INSERT</command> that inserted exactly one row into a table that
- has OIDs, or a <command>EXECUTE</command> of a prepared query containing
- a suitable <command>INSERT</command> statement. Otherwise, this function
- returns <literal>InvalidOid</literal>. This function will also
- return <literal>InvalidOid</literal> if the table affected by the
+ has OIDs, or an <command>EXECUTE</command> of a prepared query
+ containing a suitable <command>INSERT</command> statement. Otherwise,
+ this function returns <literal>InvalidOid</literal>. This function will
+ also return <literal>InvalidOid</literal> if the table affected by the
<command>INSERT</command> statement does not contain OIDs.
<synopsis>
Oid PQoidValue(const PGresult *res);
diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml
index 690598bff98..37473eeac75 100644
--- a/doc/src/sgml/logical-replication.sgml
+++ b/doc/src/sgml/logical-replication.sgml
@@ -2083,7 +2083,7 @@ Included in publications:
<link linkend="guc-track-commit-timestamp"><varname>track_commit_timestamp</varname></link>
and <link linkend="sql-createsubscription-params-with-retain-dead-tuples"><literal>retain_dead_tuples</literal></link>
are enabled. Note that if a tuple cannot be found due to the table being
- truncated, only a <literal>update_missing</literal> conflict will
+ truncated, only an <literal>update_missing</literal> conflict will
arise. Additionally, if the tuple was deleted by the same origin, an
<literal>update_missing</literal> conflict will arise.
</para>
diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml
index ff7071bef5b..790df05c8b2 100644
--- a/doc/src/sgml/ref/alter_table.sgml
+++ b/doc/src/sgml/ref/alter_table.sgml
@@ -607,7 +607,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
<term><literal>ALTER CONSTRAINT ... NO INHERIT</literal></term>
<listitem>
<para>
- These forms modify a inheritable constraint so that it becomes not
+ These forms modify an inheritable constraint so that it becomes not
inheritable, or vice-versa. Only not-null constraints may be altered
in this fashion at present.
In addition to changing the inheritability status of the constraint,
diff --git a/doc/src/sgml/ref/pg_createsubscriber.sgml b/doc/src/sgml/ref/pg_createsubscriber.sgml
index 3b3038d1891..401f71ae7fb 100644
--- a/doc/src/sgml/ref/pg_createsubscriber.sgml
+++ b/doc/src/sgml/ref/pg_createsubscriber.sgml
@@ -604,7 +604,7 @@ PostgreSQL documentation
Set the replication progress to the replication start point for each
subscription. When the target server starts the recovery process, it
catches up to the replication start point. This is the exact LSN to be
- used as a initial replication location for each subscription. The
+ used as an initial replication location for each subscription. The
replication origin name is obtained since the subscription was created.
The replication origin name and the replication start point are used in
<link
diff --git a/src/backend/access/common/tidstore.c b/src/backend/access/common/tidstore.c
index de3e44d0f5d..81151ac7d30 100644
--- a/src/backend/access/common/tidstore.c
+++ b/src/backend/access/common/tidstore.c
@@ -3,7 +3,7 @@
* tidstore.c
* TID (ItemPointerData) storage implementation.
*
- * TidStore is a in-memory data structure to store TIDs (ItemPointerData).
+ * TidStore is an in-memory data structure to store TIDs (ItemPointerData).
* Internally it uses a radix tree as the storage for TIDs. The key is the
* BlockNumber and the value is a bitmap of offsets, BlocktableEntry.
*
diff --git a/src/backend/access/gin/ginget.c b/src/backend/access/gin/ginget.c
index 6b148e69a8e..6d0e90b8e67 100644
--- a/src/backend/access/gin/ginget.c
+++ b/src/backend/access/gin/ginget.c
@@ -1027,7 +1027,7 @@ keyGetItem(GinState *ginstate, MemoryContext tempCtx, GinScanKey key,
/*
* Find the minimum item > advancePast among the active entry streams.
*
- * Note: a lossy-page entry is encoded by a ItemPointer with max value for
+ * Note: a lossy-page entry is encoded by an ItemPointer with max value for
* offset (0xffff), so that it will sort after any exact entries for the
* same page. So we'll prefer to return exact pointers not lossy
* pointers, which is good.
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 88087654de9..62641916d0e 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -3258,11 +3258,11 @@ check_nested_generated(ParseState *pstate, Node *node)
* To address this, this restricts generation expressions for virtual
* generated columns are restricted to using built-in functions and types. We
* assume that built-in functions and types cannot be exploited for this
- * purpose. Note the overall security also requires that all functions in use
- * a immutable. (For example, there are some built-in non-immutable functions
- * that can run arbitrary SQL.) The immutability is checked elsewhere, since
- * that is a property that needs to hold independent of security
- * considerations.
+ * purpose. Note the overall security also requires that all functions in
+ * use are immutable. (For example, there are some built-in non-immutable
+ * functions that can run arbitrary SQL.) The immutability is checked
+ * elsewhere, since that is a property that needs to hold independent of
+ * security considerations.
*
* In the future, this could be expanded by some new mechanism to declare
* other functions and types as safe or trusted for this purpose, but that is
diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c
index 440adb356ad..679034c4532 100644
--- a/src/backend/commands/publicationcmds.c
+++ b/src/backend/commands/publicationcmds.c
@@ -1583,7 +1583,7 @@ CheckAlterPublication(AlterPublicationStmt *stmt, HeapTuple tup,
{
/*
* If the publication already contains specific tables or schemas, we
- * prevent switching to a ALL state.
+ * prevent switching to an ALL state.
*/
if (is_table_publication(pubform->oid) ||
is_schema_publication(pubform->oid))
diff --git a/src/backend/executor/execExpr.c b/src/backend/executor/execExpr.c
index cfea7e160c2..c3fc3c92039 100644
--- a/src/backend/executor/execExpr.c
+++ b/src/backend/executor/execExpr.c
@@ -1320,8 +1320,8 @@ ExecInitExprRec(Expr *node, ExprState *state,
opexpr->inputcollid, NULL, NULL);
/*
- * If hashfuncid is set, we create a EEOP_HASHED_SCALARARRAYOP
- * step instead of a EEOP_SCALARARRAYOP. This provides much
+ * If hashfuncid is set, we create an EEOP_HASHED_SCALARARRAYOP
+ * step instead of an EEOP_SCALARARRAYOP. This provides much
* faster lookup performance than the normal linear search
* when the number of items in the array is anything but very
* small.
@@ -5039,7 +5039,7 @@ ExecInitJsonExpr(JsonExpr *jsexpr, ExprState *state,
}
/*
- * Initialize a EEOP_JSONEXPR_COERCION step to coerce the value given in resv
+ * Initialize an EEOP_JSONEXPR_COERCION step to coerce the value given in resv
* to the given RETURNING type.
*/
static void
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
index 0634af964a9..a4e54687ef1 100644
--- a/src/backend/executor/execExprInterp.c
+++ b/src/backend/executor/execExprInterp.c
@@ -2437,7 +2437,7 @@ CheckVarSlotCompatibility(TupleTableSlot *slot, int attnum, Oid vartype)
}
/*
- * Verify that the slot is compatible with a EEOP_*_FETCHSOME operation.
+ * Verify that the slot is compatible with an EEOP_*_FETCHSOME operation.
*/
static void
CheckOpSlotCompatibility(ExprEvalStep *op, TupleTableSlot *slot)
diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c
index d47eab2cba0..b34907a1d55 100644
--- a/src/backend/libpq/hba.c
+++ b/src/backend/libpq/hba.c
@@ -280,7 +280,7 @@ free_auth_token(AuthToken *token)
}
/*
- * Copy a AuthToken struct into freshly palloc'd memory.
+ * Copy an AuthToken struct into freshly palloc'd memory.
*/
static AuthToken *
copy_auth_token(AuthToken *in)
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index a7e5c686362..d9149de1d4b 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -130,7 +130,7 @@ LookupOperName(ParseState *pstate, List *opername, Oid oprleft, Oid oprright,
/*
* LookupOperWithArgs
* Like LookupOperName, but the argument types are specified by
- * a ObjectWithArgs node.
+ * an ObjectWithArgs node.
*/
Oid
LookupOperWithArgs(ObjectWithArgs *oper, bool noError)
diff --git a/src/backend/utils/activity/wait_event_names.txt b/src/backend/utils/activity/wait_event_names.txt
index 1016502d042..cc9e737df71 100644
--- a/src/backend/utils/activity/wait_event_names.txt
+++ b/src/backend/utils/activity/wait_event_names.txt
@@ -194,7 +194,7 @@ ABI_compatibility:
#
# Wait Events - IO
#
-# Use this category when a process is waiting for a IO.
+# Use this category when a process is waiting for I/O.
#
Section: ClassName - WaitEventIO
@@ -294,7 +294,7 @@ Section: ClassName - WaitEventBuffer
BUFFER_CLEANUP "Waiting to acquire an exclusive pin on a buffer. Buffer pin waits can be protracted if another process holds an open cursor that last read data from the buffer in question."
BUFFER_SHARED "Waiting to acquire a shared lock on a buffer."
BUFFER_SHARE_EXCLUSIVE "Waiting to acquire a share exclusive lock on a buffer."
-BUFFER_EXCLUSIVE "Waiting to acquire a exclusive lock on a buffer."
+BUFFER_EXCLUSIVE "Waiting to acquire an exclusive lock on a buffer."
ABI_compatibility:
diff --git a/src/backend/utils/adt/pg_dependencies.c b/src/backend/utils/adt/pg_dependencies.c
index 9c3db103d42..3a574330690 100644
--- a/src/backend/utils/adt/pg_dependencies.c
+++ b/src/backend/utils/adt/pg_dependencies.c
@@ -46,7 +46,7 @@ typedef struct
Node *escontext;
bool found_attributes; /* Item has an attributes key */
- bool found_dependency; /* Item has an dependency key */
+ bool found_dependency; /* Item has a dependency key */
bool found_degree; /* Item has degree key */
List *attnum_list; /* Accumulated attribute numbers */
AttrNumber dependency;
diff --git a/src/backend/utils/adt/uuid.c b/src/backend/utils/adt/uuid.c
index 2d33ba2640b..2804717b05c 100644
--- a/src/backend/utils/adt/uuid.c
+++ b/src/backend/utils/adt/uuid.c
@@ -705,10 +705,10 @@ uuidv7_interval(PG_FUNCTION_ARGS)
TimestampTzGetDatum(ts),
IntervalPGetDatum(shift)));
- /* Convert a TimestampTz value back to an UNIX epoch timestamp */
+ /* Convert a TimestampTz value back to a Unix epoch timestamp */
us = ts + (POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY * USECS_PER_SEC;
- /* Generate an UUIDv7 */
+ /* Generate a UUIDv7 */
uuid = generate_uuidv7(us / US_PER_MS, (us % US_PER_MS) * NS_PER_US + ns % NS_PER_US);
PG_RETURN_UUID_P(uuid);
diff --git a/src/backend/utils/misc/queryenvironment.c b/src/backend/utils/misc/queryenvironment.c
index 46ac154fb15..b081c285d67 100644
--- a/src/backend/utils/misc/queryenvironment.c
+++ b/src/backend/utils/misc/queryenvironment.c
@@ -114,7 +114,7 @@ get_ENR(QueryEnvironment *queryEnv, const char *name)
}
/*
- * Gets the TupleDesc for a Ephemeral Named Relation, based on which field was
+ * Gets the TupleDesc for an Ephemeral Named Relation, based on which field was
* filled.
*
* When the TupleDesc is based on a relation from the catalogs, we count on
diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c
index 6a9ea367107..34341b38491 100644
--- a/src/backend/utils/mmgr/aset.c
+++ b/src/backend/utils/mmgr/aset.c
@@ -121,7 +121,7 @@ typedef void *AllocPointer;
/*
* AllocFreeListLink
* When pfreeing memory, if we maintain a freelist for the given chunk's
- * size then we use a AllocFreeListLink to point to the current item in
+ * size then we use an AllocFreeListLink to point to the current item in
* the AllocSetContext's freelist and then set the given freelist element
* to point to the chunk being freed.
*/
@@ -131,7 +131,7 @@ typedef struct AllocFreeListLink
} AllocFreeListLink;
/*
- * Obtain a AllocFreeListLink for the given chunk. Allocation sizes are
+ * Obtain an AllocFreeListLink for the given chunk. Allocation sizes are
* always at least sizeof(AllocFreeListLink), so we reuse the pointer's memory
* itself to store the freelist link.
*/
diff --git a/src/bin/pg_basebackup/astreamer_inject.c b/src/bin/pg_basebackup/astreamer_inject.c
index a5dff0ac1c6..e117a6bf8e2 100644
--- a/src/bin/pg_basebackup/astreamer_inject.c
+++ b/src/bin/pg_basebackup/astreamer_inject.c
@@ -40,7 +40,7 @@ static const astreamer_ops astreamer_recovery_injector_ops = {
};
/*
- * Create a astreamer that can edit recoverydata into an archive stream.
+ * Create an astreamer that can edit recoverydata into an archive stream.
*
* The input should be a series of typed chunks (not ASTREAMER_UNKNOWN) as
* per the conventions described in astreamer.h; the chunks forwarded to
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 84b8d410c9e..f52ad84e0b6 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------
*
* pg_restore.c
- * pg_restore is an utility extracting postgres database definitions
+ * pg_restore is a utility extracting postgres database definitions
* from a backup archive created by pg_dump using the archiver
* interface.
*
diff --git a/src/bin/pg_verifybackup/astreamer_verify.c b/src/bin/pg_verifybackup/astreamer_verify.c
index 2578765b0ca..b1ddec812a3 100644
--- a/src/bin/pg_verifybackup/astreamer_verify.c
+++ b/src/bin/pg_verifybackup/astreamer_verify.c
@@ -132,7 +132,7 @@ astreamer_verify_content(astreamer *streamer, astreamer_member *member,
}
/*
- * End-of-stream processing for a astreamer_verify stream.
+ * End-of-stream processing for an astreamer_verify stream.
*/
static void
astreamer_verify_finalize(astreamer *streamer)
@@ -141,7 +141,7 @@ astreamer_verify_finalize(astreamer *streamer)
}
/*
- * Free memory associated with a astreamer_verify stream.
+ * Free memory associated with an astreamer_verify stream.
*/
static void
astreamer_verify_free(astreamer *streamer)
diff --git a/src/fe_utils/astreamer_file.c b/src/fe_utils/astreamer_file.c
index fb36cecc22a..0fba38da13c 100644
--- a/src/fe_utils/astreamer_file.c
+++ b/src/fe_utils/astreamer_file.c
@@ -69,7 +69,7 @@ static const astreamer_ops astreamer_extractor_ops = {
};
/*
- * Create a astreamer that just writes data to a file.
+ * Create an astreamer that just writes data to a file.
*
* The caller must specify a pathname and may specify a file. The pathname is
* used for error-reporting purposes either way. If file is NULL, the pathname
@@ -163,7 +163,7 @@ astreamer_plain_writer_free(astreamer *streamer)
}
/*
- * Create a astreamer that extracts an archive.
+ * Create an astreamer that extracts an archive.
*
* All pathnames in the archive are interpreted relative to basepath.
*
diff --git a/src/fe_utils/astreamer_gzip.c b/src/fe_utils/astreamer_gzip.c
index bc3d53076e1..db003445d30 100644
--- a/src/fe_utils/astreamer_gzip.c
+++ b/src/fe_utils/astreamer_gzip.c
@@ -81,7 +81,7 @@ static const astreamer_ops astreamer_gzip_decompressor_ops = {
#endif
/*
- * Create a astreamer that just compresses data using gzip, and then writes
+ * Create an astreamer that just compresses data using gzip, and then writes
* it to a file.
*
* The caller must specify a pathname and may specify a file. The pathname is
diff --git a/src/fe_utils/astreamer_tar.c b/src/fe_utils/astreamer_tar.c
index 8ab59e92238..4aa6d72c274 100644
--- a/src/fe_utils/astreamer_tar.c
+++ b/src/fe_utils/astreamer_tar.c
@@ -83,7 +83,7 @@ static const astreamer_ops astreamer_tar_terminator_ops = {
};
/*
- * Create a astreamer that can parse a stream of content as tar data.
+ * Create an astreamer that can parse a stream of content as tar data.
*
* The input should be a series of ASTREAMER_UNKNOWN chunks; the astreamer
* specified by 'next' will receive a series of typed chunks, as per the
@@ -381,7 +381,7 @@ astreamer_tar_parser_free(astreamer *streamer)
}
/*
- * Create a astreamer that can generate a tar archive.
+ * Create an astreamer that can generate a tar archive.
*
* This is intended to be usable either for generating a brand-new tar archive
* or for modifying one on the fly. The input should be a series of typed
@@ -404,7 +404,7 @@ astreamer_tar_archiver_new(astreamer *next)
/*
* Fix up the stream of input chunks to create a valid tar file.
*
- * If a ASTREAMER_MEMBER_HEADER chunk is of size 0, it is replaced with a
+ * If an ASTREAMER_MEMBER_HEADER chunk is of size 0, it is replaced with a
* newly-constructed tar header. If it is of size TAR_BLOCK_SIZE, it is
* passed through without change. Any other size is a fatal error (and
* indicates a bug).
@@ -491,7 +491,7 @@ astreamer_tar_archiver_free(astreamer *streamer)
}
/*
- * Create a astreamer that blindly adds two blocks of NUL bytes to the
+ * Create an astreamer that blindly adds two blocks of NUL bytes to the
* end of an incomplete tarfile that the server might send us.
*/
astreamer *
diff --git a/src/include/access/relscan.h b/src/include/access/relscan.h
index 2ea06a67a63..33695663e85 100644
--- a/src/include/access/relscan.h
+++ b/src/include/access/relscan.h
@@ -79,8 +79,8 @@ typedef struct TableScanDescData *TableScanDesc;
* Each backend participating in a parallel table scan has its own
* TableScanDesc in backend-private memory, and those objects all contain a
* pointer to this structure. The information here must be sufficient to
- * properly initialize each new TableScanDesc as workers join the scan, and it
- * must act as a information what to scan for those workers.
+ * properly initialize each new TableScanDesc as workers join the scan and to
+ * tell those workers what to scan.
*/
typedef struct ParallelTableScanDescData
{
diff --git a/src/include/fe_utils/astreamer.h b/src/include/fe_utils/astreamer.h
index 8329e4efbc5..43655917f6c 100644
--- a/src/include/fe_utils/astreamer.h
+++ b/src/include/fe_utils/astreamer.h
@@ -41,7 +41,7 @@ typedef struct astreamer astreamer;
typedef struct astreamer_ops astreamer_ops;
/*
- * Each chunk of archive data passed to a astreamer is classified into one
+ * Each chunk of archive data passed to an astreamer is classified into one
* of these categories. When data is initially passed to an archive streamer,
* each chunk will be categorized as ASTREAMER_UNKNOWN, and the chunks can
* be of whatever size the caller finds convenient.
@@ -92,7 +92,7 @@ typedef struct
/*
* Generally, each type of astreamer will define its own struct, but the
- * first element should be 'astreamer base'. A astreamer that does not
+ * first element should be 'astreamer base'. An astreamer that does not
* require any additional private data could use this structure directly.
*
* bbs_ops is a pointer to the astreamer_ops object which contains the
@@ -114,7 +114,7 @@ struct astreamer
};
/*
- * There are three callbacks for a astreamer. The 'content' callback is
+ * There are three callbacks for an astreamer. The 'content' callback is
* called repeatedly, as described in the astreamer_archive_context comments.
* Then, the 'finalize' callback is called once at the end, to give the
* astreamer a chance to perform cleanup such as closing files. Finally,
@@ -132,7 +132,7 @@ struct astreamer_ops
void (*free) (astreamer *streamer);
};
-/* Send some content to a astreamer. */
+/* Send some content to an astreamer. */
static inline void
astreamer_content(astreamer *streamer, astreamer_member *member,
const char *data, int len,
@@ -142,7 +142,7 @@ astreamer_content(astreamer *streamer, astreamer_member *member,
streamer->bbs_ops->content(streamer, member, data, len, context);
}
-/* Finalize a astreamer. */
+/* Finalize an astreamer. */
static inline void
astreamer_finalize(astreamer *streamer)
{
@@ -150,7 +150,7 @@ astreamer_finalize(astreamer *streamer)
streamer->bbs_ops->finalize(streamer);
}
-/* Free a astreamer. */
+/* Free an astreamer. */
static inline void
astreamer_free(astreamer *streamer)
{
@@ -159,7 +159,7 @@ astreamer_free(astreamer *streamer)
}
/*
- * This is a convenience method for use when implementing a astreamer; it is
+ * This is a convenience method for use when implementing an astreamer; it is
* not for use by outside callers. It adds the amount of data specified by
* 'nbytes' to the astreamer's buffer and adjusts '*len' and '*data'
* accordingly.
@@ -176,7 +176,7 @@ astreamer_buffer_bytes(astreamer *streamer, const char **data, int *len,
}
/*
- * This is a convenience method for use when implementing a astreamer; it is
+ * This is a convenience method for use when implementing an astreamer; it is
* not for use by outsider callers. It attempts to add enough data to the
* astreamer's buffer to reach a length of target_bytes and adjusts '*len'
* and '*data' accordingly. It returns true if the target length has been
diff --git a/src/include/utils/jsonb.h b/src/include/utils/jsonb.h
index ca13efba0fb..81c62c64a26 100644
--- a/src/include/utils/jsonb.h
+++ b/src/include/utils/jsonb.h
@@ -95,7 +95,7 @@ typedef struct JsonbParseState JsonbParseState;
* is implicitly known that the root node must be an array or an object,
* so we can get away without the type indicator as long as we can distinguish
* the two. For that purpose, both an array and an object begin with a uint32
- * header field, which contains an JB_FOBJECT or JB_FARRAY flag. When a naked
+ * header field, which contains a JB_FOBJECT or JB_FARRAY flag. When a naked
* scalar value needs to be stored as a Jsonb value, what we actually store is
* an array with one element, with the flags in the array's header field set
* to JB_FSCALAR | JB_FARRAY.
[text/x-python-script] check_indefinite_articles.py (9.9K, ../CABPTF7U2_Qp76EpY5Jmx8eKCJ+oThFvan=L6ehETR5sz5dm00Q@mail.gmail.com/3-check_indefinite_articles.py)
download | inline:
#!/usr/bin/env python3
"""Check prose and messages for likely incorrect uses of "a" and "an".
The check is intentionally conservative. English article choice depends on
pronunciation rather than spelling, so this script ignores known exceptions
and ambiguous abbreviation-like words instead of trying to be a grammar
checker. With no path arguments, it scans tracked files in the repository.
"""
import argparse
import os
from pathlib import Path
import re
import subprocess
import sys
ARTICLE_RE = re.compile(
r"(?<![A-Za-z0-9_<./-])\b(a|an)[ \t]{1,3}([A-Za-z][A-Za-z0-9'-]*)",
re.IGNORECASE,
)
TAG_RE = re.compile(r"<[^>]*>")
SGML_BLOCK_OPEN_RE = re.compile(
r"<(programlisting|screen|synopsis|literallayout|cmdsynopsis)\b[^>]*>",
re.IGNORECASE,
)
SGML_EMPTY_RE = re.compile(r"<([A-Za-z][A-Za-z0-9_-]*)\b[^>]*/>")
MARKDOWN_CODE_RE = re.compile(r"`([^`]*)`")
PROSE_SUFFIXES = {".htm", ".html", ".man", ".md", ".rst", ".txt", ".xml", ".xsl"}
C_SOURCE_SUFFIXES = {".c", ".cc", ".cpp", ".h", ".l", ".pgc", ".s", ".y"}
SCRIPT_SUFFIXES = {".pl", ".pm", ".py", ".sh", ".t"}
COMMENT_ONLY_SUFFIXES = {".build", ".conf", ".in", ".mk", ".sample"}
# These vowel-letter prefixes begin with a consonant sound.
A_EXCEPTIONS = (
"eucaly",
"eugen",
"eul",
"eup",
"euro",
"ewe",
"once",
"one",
"ubiquit",
"u-",
"uchar",
"unicast",
"unicode",
"unicorn",
"uniform",
"unifi",
"union",
"unique",
"unit",
"univ",
"unify",
"unilateral",
"uniprocessor",
"unix",
"upc",
"uri",
"unary",
"umask",
"usable",
"usage",
"use",
"user",
"usual",
"utc",
"utf",
"utility",
"uint",
"uuid",
)
SILENT_H_PREFIXES = ("heir", "herb", "honest", "honor", "honour", "hour")
# A consonant in this set unambiguously has a consonant sound in ordinary
# words. Other initial letters are often spoken as abbreviations ("an LSN",
# "an XID"), so treating them as errors would be too noisy.
UNAMBIGUOUS_CONSONANTS = frozenset("bcdgjkpqtvwyz")
# These are commonly adjacent code tokens or verbs, not article/noun pairs.
NON_ARTICLE_FOLLOWERS = frozenset(
(
"a",
"already",
"an",
"and",
"anyelement",
"are",
"as",
"at",
"if",
"in",
"inner",
"int",
"integer",
"into",
"is",
"isnull",
"implies",
"of",
"on",
"or",
"overlap",
"overlaps",
"uint",
"uint8-array",
"used",
"using",
)
)
def repository_root():
return Path(__file__).resolve().parents[2]
def tracked_files(root):
result = subprocess.run(
["git", "ls-files", "-z"],
cwd=root,
check=True,
stdout=subprocess.PIPE,
)
names = result.stdout.decode("utf-8", errors="surrogateescape").split("\0")
return [root / name for name in names if name]
def requested_files(paths):
files = []
for path in paths:
path = path.resolve()
if path.is_dir():
for dirname, dirnames, filenames in os.walk(path):
dirnames[:] = [name for name in dirnames if name != ".git"]
files.extend(Path(dirname) / name for name in filenames)
else:
files.append(path)
return files
def file_mode(path):
suffix = path.suffix.lower()
name = path.name
if suffix == ".sgml":
return "sgml"
if suffix in PROSE_SUFFIXES or name.startswith("README"):
return "prose"
if suffix in C_SOURCE_SUFFIXES:
return "c-source"
if suffix in SCRIPT_SUFFIXES:
return "script"
if suffix in COMMENT_ONLY_SUFFIXES or name in {"GNUmakefile", "Makefile"}:
return "comments"
return None
def quoted_fragment(line, start, quote):
i = start + 1
while i < len(line):
if line[i] == "\\":
i += 2
elif line[i] == quote:
return line[start + 1 : i], i + 1
else:
i += 1
return line[start + 1 :], len(line)
def c_source_fragments(line, in_block_comment):
fragments = []
i = 0
while i < len(line):
if in_block_comment:
end = line.find("*/", i)
if end < 0:
fragments.append(line[i:])
return fragments, True
fragments.append(line[i:end])
i = end + 2
in_block_comment = False
elif line.startswith("/*", i):
in_block_comment = True
i += 2
elif line.startswith("//", i):
fragments.append(line[i + 2 :])
break
elif line[i] == '"':
fragment, i = quoted_fragment(line, i, '"')
fragments.append(fragment)
elif line[i] == "'":
_, i = quoted_fragment(line, i, "'")
else:
i += 1
return fragments, in_block_comment
def script_fragments(line):
in_quote = None
i = 0
while i < len(line):
if in_quote:
if line[i] == "\\":
i += 2
elif line[i] == in_quote:
in_quote = None
i += 1
else:
i += 1
elif line[i] in {'"', "'"}:
in_quote = line[i]
i += 1
elif line[i] == "#":
return [line[i + 1 :]]
else:
i += 1
return []
def comment_fragment(line):
stripped = line.lstrip()
if stripped.startswith("#"):
return [stripped[1:]]
return []
def sgml_fragments(line, blocked_tag):
fragments = []
pos = 0
while pos < len(line):
if blocked_tag:
close = re.search(
r"</{}\s*>".format(re.escape(blocked_tag)),
line[pos:],
re.IGNORECASE,
)
if close is None:
return fragments, blocked_tag
pos += close.end()
blocked_tag = None
continue
opening = SGML_BLOCK_OPEN_RE.search(line, pos)
end = opening.start() if opening else len(line)
fragment = line[pos:end]
fragment = SGML_EMPTY_RE.sub(
lambda match: " {} ".format(match.group(1)), fragment
)
fragments.append(TAG_RE.sub(" ", fragment))
if opening is None:
break
blocked_tag = opening.group(1)
pos = opening.end()
return fragments, blocked_tag
def a_takes_an(word):
lower = word.lower()
if lower[0] not in "aeiou":
return False
if lower.startswith(A_EXCEPTIONS):
return False
if word[0] == "U" and (len(word) == 1 or not word[1].islower()):
return False
return True
def an_takes_a(word):
lower = word.lower()
if lower.startswith(A_EXCEPTIONS):
return True
if lower.startswith(SILENT_H_PREFIXES):
return False
if lower[0] in "aeiou":
return False
if lower[0] in UNAMBIGUOUS_CONSONANTS:
return True
return False
def check_fragment(fragment):
for match in ARTICLE_RE.finditer(fragment):
raw_article = match.group(1)
article = raw_article.lower()
word = match.group(2)
lower_word = word.lower()
if lower_word in NON_ARTICLE_FOLLOWERS:
continue
if word[0].islower() and any(char.isdigit() for char in word):
continue
if raw_article == "A":
prefix = fragment[: match.start()].rstrip()
if prefix and prefix[-1] not in ".!?:":
continue
if article == "a" and a_takes_an(word):
yield "an", word
elif article == "an" and an_takes_a(word):
yield "a", word
def display_path(path, root):
try:
return path.relative_to(root)
except ValueError:
return path
def check_file(path, root):
mode = file_mode(path)
if mode is None:
return 0
try:
lines = path.read_text(encoding="utf-8").splitlines()
except UnicodeDecodeError:
return 0
except OSError as error:
print(
"{}: cannot read: {}".format(display_path(path, root), error),
file=sys.stderr,
)
return 0
findings = 0
in_block_comment = False
blocked_sgml_tag = None
for lineno, line in enumerate(lines, 1):
if mode == "sgml":
fragments, blocked_sgml_tag = sgml_fragments(line, blocked_sgml_tag)
elif mode == "prose":
fragments = [MARKDOWN_CODE_RE.sub(r"\1", line)]
elif mode == "c-source":
fragments, in_block_comment = c_source_fragments(line, in_block_comment)
elif mode == "script":
fragments = script_fragments(line)
else:
fragments = comment_fragment(line)
for fragment in fragments:
for replacement, word in check_fragment(fragment):
context = " ".join(line.strip().split())
if len(context) > 160:
context = context[:157] + "..."
print(
'{}:{}: use "{}" before "{}": {}'.format(
display_path(path, root), lineno, replacement, word, context
)
)
findings += 1
return findings
def parse_arguments():
parser = argparse.ArgumentParser(
description="check likely a/an errors in tracked prose and messages"
)
parser.add_argument(
"paths",
metavar="PATH",
nargs="*",
type=Path,
help="files or directories to scan (default: tracked repository files)",
)
return parser.parse_args()
def main():
args = parse_arguments()
root = repository_root()
files = requested_files(args.paths) if args.paths else tracked_files(root)
findings = sum(check_file(path, root) for path in sorted(set(files)))
if findings:
sys.stdout.flush()
print("{} likely article error(s) found".format(findings), file=sys.stderr)
return 1
return 0
if __name__ == "__main__":
sys.exit(main())
view thread (2+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Fix Grammar in Buffer Lock Wait Message
In-Reply-To: <CABPTF7U2_Qp76EpY5Jmx8eKCJ+oThFvan=L6ehETR5sz5dm00Q@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox