postgres.git / summary / log / commit / refs

commit    dd136052bcc8281dd3faa77e717cd7cec216f7c7
Author:   Peter Eisentraut <peter_e@gmx.net>
Date:     Tue Nov 29 20:04:59 2011 +0000
First released in: 9.2.0, 8.2.23, 8.3.17, 8.4.10, 9.0.6, 9.1.2

    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.


src/backend/utils/error/elog.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 9a99fc7402b..0131c06ba4d 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -343,7 +343,14 @@ errstart(int elevel, const char *filename, int lineno, edata->elevel = elevel; edata->output_to_server = output_to_server; edata->output_to_client = output_to_client; - edata->filename = filename; + if (filename) + { + const char *slash; + + /* keep only base name, useful especially for vpath builds */ + slash = strrchr(filename, '/'); + edata->filename = slash ? slash + 1 : filename; + } edata->lineno = lineno; edata->funcname = funcname; /* the default text domain is the backend's */ @@ -1142,7 +1149,14 @@ elog_start(const char *filename, int lineno, const char *funcname) } edata = &errordata[errordata_stack_depth]; - edata->filename = filename; + if (filename) + { + const char *slash; + + /* keep only base name, useful especially for vpath builds */ + slash = strrchr(filename, '/'); + edata->filename = slash ? slash + 1 : filename; + } edata->lineno = lineno; edata->funcname = funcname; /* errno is saved now so that error parameter eval can't change it */ [parent: be2f909200ec]