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

Commitff0b706

Browse files
committed
Fix random breakage in exec.c for platforms where strdup is a macro.
1 parent79c3bf4 commitff0b706

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

‎src/include/port.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/port.h,v 1.36 2004/05/2105:08:03 tgl Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.37 2004/05/2116:06:22 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -60,7 +60,7 @@ extern void get_pkglib_path(const char *my_exec_path, char *ret_path);
6060

6161
/* Portable way to find binaries */
6262
externintfind_my_exec(constchar*argv0,char*retpath);
63-
externintfind_other_exec(constchar*argv0,charconst*target,
63+
externintfind_other_exec(constchar*argv0,constchar*target,
6464
constchar*versionstr,char*retpath);
6565
#if defined(__CYGWIN__)|| defined(WIN32)
6666
#defineEXE ".exe"

‎src/port/exec.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,32 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/port/exec.c,v 1.12 2004/05/20 15:38:11 momjian Exp $
10+
* $PostgreSQL: pgsql/src/port/exec.c,v 1.13 2004/05/21 16:06:23 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414

1515
#ifndefFRONTEND
1616
#include"postgres.h"
17-
#definemalloc(l)palloc(l)
18-
#definefree(p)pfree(p)
19-
#definestrdup(p)pstrdup(p)
2017
#else
2118
#include"postgres_fe.h"
2219
#endif
2320

2421
#include<grp.h>
2522
#include<pwd.h>
2623
#include<sys/stat.h>
24+
#include<sys/wait.h>
2725
#include<unistd.h>
2826

29-
#include<sys/wait.h>
27+
#include"miscadmin.h"
3028

31-
#define_(x) gettext((x))
29+
#define_(x) gettext(x)
3230

33-
#include"miscadmin.h"
31+
#ifdefFRONTEND
32+
#undef pstrdup
33+
#definepstrdup(p)strdup(p)
34+
#definepfree(p)free(p)
35+
#endif
3436

3537
/* $PATH (or %PATH%) path separator */
3638
#ifdefWIN32
@@ -58,8 +60,10 @@
5860
#definelog_error(str,param)fprintf(stderr, (str), (param))
5961
#endif
6062

63+
6164
staticvoidwin32_make_absolute(char*path);
6265

66+
6367
/*
6468
* validate_exec -- validate "path" as an executable file
6569
*
@@ -243,7 +247,7 @@ find_my_exec(const char *argv0, char *retpath)
243247
*/
244248
if ((p=getenv("PATH"))&&*p)
245249
{
246-
path=strdup(p);/* make a modifiable copy */
250+
path=pstrdup(p);/* make a modifiable copy */
247251
for (startp=path,endp=strchr(path,PATHSEP);
248252
startp&&*startp;
249253
startp=endp+1,endp=strchr(startp,PATHSEP))
@@ -263,19 +267,19 @@ find_my_exec(const char *argv0, char *retpath)
263267
{
264268
case0:/* found ok */
265269
win32_make_absolute(retpath);
266-
free(path);
270+
pfree(path);
267271
return0;
268272
case-1:/* wasn't even a candidate, keep looking */
269273
break;
270274
case-2:/* found but disqualified */
271275
log_error("could not read binary \"%s\"",retpath);
272-
free(path);
276+
pfree(path);
273277
return-1;
274278
}
275279
if (!endp)/* last one */
276280
break;
277281
}
278-
free(path);
282+
pfree(path);
279283
}
280284

281285
log_error("could not find a \"%s\" to execute",argv0);
@@ -296,8 +300,9 @@ find_my_exec(const char *argv0, char *retpath)
296300
* Find our binary directory, then make sure the "target" executable
297301
* is the proper version.
298302
*/
299-
intfind_other_exec(constchar*argv0,charconst*target,
300-
constchar*versionstr,char*retpath)
303+
int
304+
find_other_exec(constchar*argv0,constchar*target,
305+
constchar*versionstr,char*retpath)
301306
{
302307
charcmd[MAXPGPATH];
303308
charline[100];
@@ -380,8 +385,6 @@ pclose_check(FILE *stream)
380385
/*
381386
* Windows doesn't like relative paths to executables (other things work fine)
382387
* so we call its builtin function to expand them. Elsewhere this is a NOOP
383-
*
384-
* Returns malloc'ed memory.
385388
*/
386389
staticvoid
387390
win32_make_absolute(char*path)
@@ -391,14 +394,11 @@ win32_make_absolute(char *path)
391394

392395
if (_fullpath(abspath,path,MAXPGPATH)==NULL)
393396
{
394-
log_error("Win32 path expansion failed:%s",strerror(errno));
397+
log_error("Win32 path expansion failed: %s",strerror(errno));
395398
StrNCpy(abspath,path,MAXPGPATH);
396399
}
397400
canonicalize_path(abspath);
398401

399402
StrNCpy(path,abspath,MAXPGPATH);
400403
#endif
401-
return;
402404
}
403-
404-

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp