Skip to content

Commit 1a44811

Browse files
committed
Strip file names reported in error messages in vpath builds
In vpath builds, the __FILE__ macro that is used in verbose error reports contains the full absolute file name, which makes the error messages excessively verbose. So keep only the base name, thus matching the behavior of non-vpath builds.
1 parent e53724f commit 1a44811

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/backend/utils/error/elog.c

+16-2
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,14 @@ errstart(int elevel, const char *filename, int lineno,
325325
edata->elevel = elevel;
326326
edata->output_to_server = output_to_server;
327327
edata->output_to_client = output_to_client;
328-
edata->filename = filename;
328+
if (filename)
329+
{
330+
const char *slash;
331+
332+
/* keep only base name, useful especially for vpath builds */
333+
slash = strrchr(filename, '/');
334+
edata->filename = slash ? slash + 1 : filename;
335+
}
329336
edata->lineno = lineno;
330337
edata->funcname = funcname;
331338
/* Select default errcode based on elevel */
@@ -943,7 +950,14 @@ elog_start(const char *filename, int lineno, const char *funcname)
943950
}
944951

945952
edata = &errordata[errordata_stack_depth];
946-
edata->filename = filename;
953+
if (filename)
954+
{
955+
const char *slash;
956+
957+
/* keep only base name, useful especially for vpath builds */
958+
slash = strrchr(filename, '/');
959+
edata->filename = slash ? slash + 1 : filename;
960+
}
947961
edata->lineno = lineno;
948962
edata->funcname = funcname;
949963
/* errno is saved now so that error parameter eval can't change it */

0 commit comments

Comments
 (0)