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

Commitb9f698e

Browse files
committed
Fix BSD-only coding in port.c (passing a local variable to putenv).
Also a quick but half-baked attempt to make trim_trailing_separatordo the right thing with path consisting only of '/' --- still needswork for Windows I think.
1 parent82f755e commitb9f698e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

‎src/port/path.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/port/path.c,v 1.20 2004/06/11 17:09:13 momjian Exp $
11+
* $PostgreSQL: pgsql/src/port/path.c,v 1.21 2004/07/10 22:58:42 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -266,21 +266,21 @@ set_pglocale_pgservice(const char *argv0, const char *app)
266266
bindtextdomain(app,path);
267267
textdomain(app);
268268

269-
if (!getenv("PGLOCALEDIR"))
269+
if (getenv("PGLOCALEDIR")==NULL)
270270
{
271271
/* set for libpq to use */
272-
sprintf(env_path,"PGLOCALEDIR=%s",path);
273-
putenv(env_path);
272+
snprintf(env_path,sizeof(env_path),"PGLOCALEDIR=%s",path);
273+
putenv(strdup(env_path));
274274
}
275275
#endif
276276

277-
if (!getenv("PGSYSCONFDIR"))
277+
if (getenv("PGSYSCONFDIR")==NULL)
278278
{
279279
get_etc_path(my_exec_path,path);
280280

281281
/* set for libpq to use */
282-
sprintf(env_path,"PGSYSCONFDIR=%s",path);
283-
putenv(env_path);
282+
snprintf(env_path,sizeof(env_path),"PGSYSCONFDIR=%s",path);
283+
putenv(strdup(env_path));
284284
}
285285
}
286286

@@ -328,11 +328,12 @@ relative_path(const char *bin_path, const char *other_path)
328328
/* Win32 filesystem is case insensitive */
329329
if ((!IS_DIR_SEP(*bin_path)|| !IS_DIR_SEP(*other_path))&&
330330
#ifndefWIN32
331-
*bin_path!=*other_path)
331+
*bin_path!=*other_path
332332
#else
333-
toupper((unsignedchar)*bin_path)!=toupper((unsignedchar)*other_path))
333+
toupper((unsignedchar)*bin_path)!=toupper((unsignedchar)*other_path)
334334
#endif
335-
break;
335+
)
336+
break;
336337

337338
if (IS_DIR_SEP(*other_path))
338339
other_sep=other_path+1;/* past separator */
@@ -377,7 +378,6 @@ trim_directory(char *path)
377378
for (; !IS_DIR_SEP(*p)&&p>path;p--)
378379
;
379380
*p='\0';
380-
return;
381381
}
382382

383383

@@ -392,6 +392,6 @@ trim_trailing_separator(char *path)
392392

393393
/* trim off trailing slashes */
394394
if (p>path)
395-
for (p--;p >=path&&IS_DIR_SEP(*p);p--)
395+
for (p--;p>path&&IS_DIR_SEP(*p);p--)
396396
*p='\0';
397397
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp