Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite2d3932

Browse files
committed
Move PGPORT envar handling to ResetAllOptions(). Improve long options
parsing to not clobber the optarg string -- so that we can bringSetOptsFile() up to speed.
1 parent51afb93 commite2d3932

File tree

5 files changed

+72
-31
lines changed

5 files changed

+72
-31
lines changed

‎src/backend/libpq/pqcomm.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
3030
* Portions Copyright (c) 1994, Regents of the University of California
3131
*
32-
*$Id: pqcomm.c,v 1.98 2000/06/14 18:17:28 petere Exp $
32+
*$Id: pqcomm.c,v 1.99 2000/07/03 20:45:57 petere Exp $
3333
*
3434
*-------------------------------------------------------------------------
3535
*/
@@ -41,7 +41,6 @@
4141
*StreamServerPort- Open postmaster's server port
4242
*StreamConnection- Create new connection with client
4343
*StreamClose- Close a client/backend connection
44-
*pq_getport- return the PGPORT setting
4544
*pq_init- initialize libpq at backend startup
4645
*pq_close- shutdown libpq at backend exit
4746
*

‎src/backend/postmaster/postmaster.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.151 2000/07/02 15:20:48 petere Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.152 2000/07/0320:45:58 petere Exp $
1515
*
1616
* NOTES
1717
*
@@ -383,9 +383,6 @@ PostmasterMain(int argc, char *argv[])
383383
if (getenv("PGDATA"))
384384
DataDir=strdup(getenv("PGDATA"));/* default value */
385385

386-
if (getenv("PGPORT"))
387-
PostPortName=atoi(getenv("PGPORT"));
388-
389386
ResetAllOptions();
390387

391388
/*
@@ -504,7 +501,6 @@ PostmasterMain(int argc, char *argv[])
504501
strcpy(original_extraoptions,optarg);
505502
break;
506503
case'p':
507-
/* Set PGPORT by hand. */
508504
PostPortName=atoi(optarg);
509505
break;
510506
case'S':
@@ -529,17 +525,16 @@ PostmasterMain(int argc, char *argv[])
529525
break;
530526
case'-':
531527
{
532-
/* A little 'long argument' simulation */
533-
size_tequal_pos=strcspn(optarg,"=");
534-
char*cp;
528+
char*name,*value;
535529

536-
if (optarg[equal_pos]!='=')
530+
ParseLongOption(optarg,&name,&value);
531+
if (!value)
537532
elog(ERROR,"--%s requires argument",optarg);
538-
optarg[equal_pos]='\0';
539-
for(cp=optarg;*cp;cp++)
540-
if (*cp=='-')
541-
*cp='_';
542-
SetConfigOption(optarg,optarg+equal_pos+1,PGC_POSTMASTER);
533+
534+
SetConfigOption(name,value,PGC_POSTMASTER);
535+
free(name);
536+
if (value)
537+
free(value);
543538
break;
544539
}
545540
default:

‎src/backend/tcop/postgres.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.163 2000/06/29 07:35:57 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.164 2000/07/03 20:46:00 petere Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -1167,18 +1167,16 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
11671167

11681168
case'-':
11691169
{
1170-
/* A little 'long argument' simulation */
1171-
/* (copy&pasted from PostmasterMain() */
1172-
size_tequal_pos=strcspn(optarg,"=");
1173-
char*cp;
1170+
char*name,*value;
11741171

1175-
if (optarg[equal_pos]!='=')
1172+
ParseLongOption(optarg,&name,&value);
1173+
if (!value)
11761174
elog(ERROR,"--%s requires argument",optarg);
1177-
optarg[equal_pos]='\0';
1178-
for(cp=optarg;*cp;cp++)
1179-
if (*cp=='-')
1180-
*cp='_';
1181-
SetConfigOption(optarg,optarg+equal_pos+1,PGC_BACKEND);
1175+
1176+
SetConfigOption(name,value,PGC_BACKEND);
1177+
free(name);
1178+
if (value)
1179+
free(value);
11821180
break;
11831181
}
11841182

@@ -1408,7 +1406,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
14081406
if (!IsUnderPostmaster)
14091407
{
14101408
puts("\nPOSTGRES backend interactive interface ");
1411-
puts("$Revision: 1.163 $ $Date: 2000/06/29 07:35:57 $\n");
1409+
puts("$Revision: 1.164 $ $Date: 2000/07/03 20:46:00 $\n");
14121410
}
14131411

14141412
/*

‎src/backend/utils/misc/guc.c

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Support for grand unified configuration scheme, including SET
55
* command, configuration file, and command line options.
66
*
7-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.4 2000/06/22 22:31:21 petere Exp $
7+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.5 2000/07/03 20:46:05 petere Exp $
88
*
99
* Copyright 2000 by PostgreSQL Global Development Group
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
@@ -354,6 +354,9 @@ ResetAllOptions(void)
354354
}
355355
ConfigureNamesString[i].variable=str;
356356
}
357+
358+
if (getenv("PGPORT"))
359+
PostPortName=atoi(getenv("PGPORT"));
357360
}
358361

359362

@@ -718,3 +721,49 @@ GetConfigOption(const char * name)
718721
}
719722
returnNULL;
720723
}
724+
725+
726+
727+
/*
728+
* A little "long argument" simulation, although not quite GNU
729+
* compliant. Takes a string of the form "some-option=some value" and
730+
* returns name = "some_option" and value = "some value" in malloc'ed
731+
* storage. Note that '-' is converted to '_' in the option name. If
732+
* there is no '=' in the input string then value will be NULL.
733+
*/
734+
void
735+
ParseLongOption(constchar*string,char**name,char**value)
736+
{
737+
size_tequal_pos;
738+
char*cp;
739+
740+
AssertArg(string);
741+
AssertArg(name);
742+
AssertArg(value);
743+
744+
equal_pos=strcspn(string,"=");
745+
746+
if (string[equal_pos]=='=')
747+
{
748+
*name=malloc(equal_pos+1);
749+
if (!*name)
750+
elog(FATAL,"out of memory");
751+
strncpy(*name,string,equal_pos);
752+
(*name)[equal_pos]='\0';
753+
754+
*value=strdup(&string[equal_pos+1]);
755+
if (!*value)
756+
elog(FATAL,"out of memory");
757+
}
758+
else/* no equal sign in string */
759+
{
760+
*name=strdup(string);
761+
if (!*name)
762+
elog(FATAL,"out of memory");
763+
*value=NULL;
764+
}
765+
766+
for(cp=*name;*cp;cp++)
767+
if (*cp=='-')
768+
*cp='_';
769+
}

‎src/include/utils/guc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* External declarations pertaining to backend/utils/misc/guc.c and
55
* backend/utils/misc/guc-file.l
66
*
7-
* $Header: /cvsroot/pgsql/src/include/utils/guc.h,v 1.2 2000/06/22 22:31:24 petere Exp $
7+
* $Header: /cvsroot/pgsql/src/include/utils/guc.h,v 1.3 2000/07/03 20:46:10 petere Exp $
88
*/
99
#ifndefGUC_H
1010
#defineGUC_H
@@ -51,7 +51,7 @@ void SetConfigOption(const char * name, const char * value, GucContext c
5151
constchar*GetConfigOption(constchar*name);
5252
voidProcessConfigFile(GucContextcontext);
5353
voidResetAllOptions(void);
54-
54+
voidParseLongOption(constchar*string,char**name,char**value);
5555
boolset_config_option(constchar*name,constchar*value,GucContextcontext,boolDoIt);
5656

5757

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp