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

Commite2ab82f

Browse files
committed
Fix longopts_to_optstring(): use proper length of opts array
1 parentedfad8c commite2ab82f

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

‎Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ PG_CPPFLAGS = -I$(libpq_srcdir) ${PTHREAD_CFLAGS} -Isrc
3939
overrideCPPFLAGS := -DFRONTEND$(CPPFLAGS)$(PG_CPPFLAGS)
4040
PG_LIBS =$(libpq_pgport) ${PTHREAD_CFLAGS}
4141

42-
all: checksrcdir$(INCLUDES)$(PROGRAM);
42+
all: checksrcdir$(INCLUDES);
4343

4444
$(PROGRAM):$(OBJS)
45-
$(CC)$(CFLAGS)$(OBJS)$(PG_LIBS)$(LDFLAGS)$(LDFLAGS_EX)$(LIBS) -o$@$(X)
4645

4746
src/xlogreader.c:$(top_srcdir)/src/backend/access/transam/xlogreader.c
4847
rm -f$@&&$(LN_S)$(srchome)/src/backend/access/transam/xlogreader.c$@

‎src/utils/pgut.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -669,22 +669,21 @@ parse_int(const char *value, int *result, int flags, const char **hintmsg)
669669
}
670670

671671
staticchar*
672-
longopts_to_optstring(conststructoptionopts[])
672+
longopts_to_optstring(conststructoptionopts[],constsize_tlen)
673673
{
674-
size_tlen;
675-
char*result;
676-
char*s;
674+
size_ti;
675+
char*result;
676+
char*s;
677677

678-
for (len=0;opts[len].name;len++) { }
679678
result=pgut_malloc(len*2+1);
680679

681680
s=result;
682-
for (len=0;opts[len].name;len++)
681+
for (i=0;i<len;i++)
683682
{
684-
if (!isprint(opts[len].val))
683+
if (!isprint(opts[i].val))
685684
continue;
686-
*s++=opts[len].val;
687-
if (opts[len].has_arg!=no_argument)
685+
*s++=opts[i].val;
686+
if (opts[i].has_arg!=no_argument)
688687
*s++=':';
689688
}
690689
*s='\0';
@@ -731,18 +730,18 @@ pgut_getopt_env(pgut_option options[])
731730
int
732731
pgut_getopt(intargc,char**argv,pgut_optionoptions[])
733732
{
734-
intc;
735-
intoptindex=0;
736-
char*optstring;
737-
pgut_option*opt;
733+
intc;
734+
intoptindex=0;
735+
char*optstring;
736+
pgut_option*opt;
738737
structoption*longopts;
739-
size_tlen1;
738+
size_tlen;
740739

741-
len1=option_length(options);
742-
longopts=pgut_newarray(structoption,len1+1);
743-
option_copy(longopts,options,len1);
740+
len=option_length(options);
741+
longopts=pgut_newarray(structoption,len+1);
742+
option_copy(longopts,options,len);
744743

745-
optstring=longopts_to_optstring(longopts);
744+
optstring=longopts_to_optstring(longopts,len);
746745

747746
/* Assign named options */
748747
while ((c=getopt_long(argc,argv,optstring,longopts,&optindex))!=-1)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp