4
4
*
5
5
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
6
6
*
7
- * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.100 2008/06/26 01:35:45 momjian Exp $
7
+ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.101 2008/06/26 02:47:19 momjian Exp $
8
8
*
9
9
*-------------------------------------------------------------------------
10
10
*/
@@ -573,11 +573,11 @@ read_post_opts(void)
573
573
{
574
574
if (post_opts == NULL )
575
575
{
576
- char * * optlines ;
577
-
578
576
post_opts = "" ; /* defatult */
579
577
if (ctl_command == RESTART_COMMAND )
580
578
{
579
+ char * * optlines ;
580
+
581
581
optlines = readfile (postopts_file );
582
582
if (optlines == NULL )
583
583
{
@@ -593,20 +593,26 @@ read_post_opts(void)
593
593
else
594
594
{
595
595
int len ;
596
- char * optline = NULL ;
596
+ char * optline ;
597
597
char * arg1 ;
598
598
599
599
optline = optlines [0 ];
600
+ /* trim off line endings */
600
601
len = strcspn (optline , "\r\n" );
601
602
optline [len ] = '\0' ;
602
603
603
- arg1 = strchr (optline , * SYSTEMQUOTE );
604
- if (arg1 == NULL || arg1 == optline )
605
- post_opts = "" ;
606
- else
604
+ for (arg1 = optline ; * arg1 ; arg1 ++ )
607
605
{
608
- * (arg1 - 1 ) = '\0' ; /* this should be a space */
609
- post_opts = arg1 ;
606
+ /*
607
+ * Are we at the first option, as defined by space,
608
+ * double-quote, and a dash?
609
+ */
610
+ if (* arg1 == ' ' && * (arg1 + 1 ) == '"' && * (arg1 + 2 ) == '-' )
611
+ {
612
+ * arg1 = '\0' ; /* terminate so we get only program name */
613
+ post_opts = arg1 + 1 ; /* point past whitespace */
614
+ break ;
615
+ }
610
616
}
611
617
if (postgres_path != NULL )
612
618
postgres_path = optline ;
0 commit comments