]> granicus.if.org Git - postgresql/commitdiff
Simplify new pg_ctl newline termination code.
authorBruce Momjian <bruce@momjian.us>
Thu, 6 Oct 2011 14:59:50 +0000 (10:59 -0400)
committerBruce Momjian <bruce@momjian.us>
Thu, 6 Oct 2011 14:59:50 +0000 (10:59 -0400)
src/bin/pg_ctl/pg_ctl.c

index e633d0c18fee85aac2e639f4d40128b72f0de2ad..c9007eded92a6b9a99f003e018307dcda0e8e665 100644 (file)
@@ -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);