|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/port/path.c,v 1.36 2004/09/2405:16:35 tgl Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/port/path.c,v 1.37 2004/10/2422:08:19 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -175,15 +175,38 @@ canonicalize_path(char *path)
|
175 | 175 |
|
176 | 176 |
|
177 | 177 | /*
|
178 |
| - * Extracts the actual name of the program as called. |
| 178 | + * Extracts the actual name of the program as called - |
| 179 | + * stripped of .exe suffix if any |
179 | 180 | */
|
180 | 181 | constchar*
|
181 | 182 | get_progname(constchar*argv0)
|
182 | 183 | {
|
| 184 | +constchar*nodir_name; |
| 185 | + |
183 | 186 | if (!last_dir_separator(argv0))
|
184 |
| -returnargv0; |
| 187 | +nodir_name=argv0; |
185 | 188 | else
|
186 |
| -returnlast_dir_separator(argv0)+1; |
| 189 | +nodir_name=last_dir_separator(argv0)+1; |
| 190 | + |
| 191 | +#if defined(__CYGWIN__)|| defined(WIN32) |
| 192 | +/* strip .exe suffix, regardless of case */ |
| 193 | +if (strlen(nodir_name)>4&& |
| 194 | +stricmp(nodir_name+ (strlen(nodir_name)-4),EXE)==0) |
| 195 | +{ |
| 196 | +char*progname; |
| 197 | + |
| 198 | +progname=strdup(nodir_name); |
| 199 | +if (progname==NULL) |
| 200 | +{ |
| 201 | +fprintf(stderr,"%s: out of memory\n",nodir_name); |
| 202 | +exit(1); |
| 203 | +} |
| 204 | +progname[strlen(progname)-4]='\0'; |
| 205 | +nodir_name=progname; |
| 206 | +} |
| 207 | +#endif |
| 208 | + |
| 209 | +returnnodir_name; |
187 | 210 | }
|
188 | 211 |
|
189 | 212 |
|
|