aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2011-10-06 10:59:50 -0400
committerBruce Momjian <bruce@momjian.us>2011-10-06 10:59:50 -0400
commit416e82ce9f0c8c4ec6d377368d670b8ca74097a6 (patch)
tree9399a99d33a74b769328a91016895eb073f5fc66 /src
parentaaa6e1def292cdacb6b27088898793b1b879fedf (diff)
downloadpostgresql-416e82ce9f0c8c4ec6d377368d670b8ca74097a6.tar.gz
postgresql-416e82ce9f0c8c4ec6d377368d670b8ca74097a6.zip
Simplify new pg_ctl newline termination code.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_ctl/pg_ctl.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index e633d0c18fe..c9007eded92 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -1934,8 +1934,10 @@ adjust_data_dir(void)
pclose(fd);
free(my_exec_path);
- if (strlen(filename) > 0 && filename[strlen(filename) - 1] == '\n')
- filename[strlen(filename) - 1] = '\0';
+ /* Remove trailing newline */
+ if (strchr(filename, '\n') != NULL)
+ *strchr(filename, '\n') = '\0';
+
free(pg_data);
pg_data = xstrdup(filename);
canonicalize_path(pg_data);