mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Under Windows, if $HOME is not defined, use the directory that
contains the Wget binary instead of hard-coded `C:\'. (wgetrc_file_name): Under Windows, look for $HOME/.wgetrc then, if not found, look for wget.ini in the directory of the Wget binary. Submitted by David Fritz.
This commit is contained in:
parent
94eccf9739
commit
f7193075df
@ -1,3 +1,14 @@
|
|||||||
|
2004-02-16 David Fritz <zeroxdf@att.net>
|
||||||
|
|
||||||
|
* init.c (home_dir): Use aprintf() instead of xmalloc()/sprintf().
|
||||||
|
Under Windows, if $HOME is not defined, use the directory that
|
||||||
|
contains the Wget binary instead of hard-coded `C:\'.
|
||||||
|
(wgetrc_file_name): Under Windows, look for $HOME/.wgetrc then, if
|
||||||
|
not found, look for wget.ini in the directory of the Wget binary.
|
||||||
|
|
||||||
|
* mswindows.c (ws_mypath): Employ slightly more robust methodology.
|
||||||
|
Strip trailing path separator.
|
||||||
|
|
||||||
2004-02-06 Hrvoje Niksic <hniksic@xemacs.org>
|
2004-02-06 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
* http.c (gethttp): Respect --ignore-length.
|
* http.c (gethttp): Respect --ignore-length.
|
||||||
|
35
src/init.c
35
src/init.c
@ -1,5 +1,5 @@
|
|||||||
/* Reading/parsing the initialization file.
|
/* Reading/parsing the initialization file.
|
||||||
Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2003
|
Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2003, 2004
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GNU Wget.
|
This file is part of GNU Wget.
|
||||||
@ -314,9 +314,9 @@ home_dir (void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
home = pwd->pw_dir;
|
home = pwd->pw_dir;
|
||||||
#else /* WINDOWS */
|
#else /* WINDOWS */
|
||||||
home = "C:\\";
|
/* Under Windows, if $HOME isn't defined, use the directory where
|
||||||
/* #### Maybe I should grab home_dir from registry, but the best
|
`wget.exe' resides. */
|
||||||
that I could get from there is user's Start menu. It sucks! */
|
home = ws_mypath ();
|
||||||
#endif /* WINDOWS */
|
#endif /* WINDOWS */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,27 +347,24 @@ wgetrc_file_name (void)
|
|||||||
return xstrdup (env);
|
return xstrdup (env);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WINDOWS
|
|
||||||
/* If that failed, try $HOME/.wgetrc. */
|
/* If that failed, try $HOME/.wgetrc. */
|
||||||
home = home_dir ();
|
home = home_dir ();
|
||||||
if (home)
|
if (home)
|
||||||
{
|
file = aprintf ("%s/.wgetrc", home);
|
||||||
file = (char *)xmalloc (strlen (home) + 1 + strlen (".wgetrc") + 1);
|
|
||||||
sprintf (file, "%s/.wgetrc", home);
|
|
||||||
}
|
|
||||||
xfree_null (home);
|
xfree_null (home);
|
||||||
#else /* WINDOWS */
|
|
||||||
/* Under Windows, "home" is (for the purposes of this function) the
|
|
||||||
directory where `wget.exe' resides, and `wget.ini' will be used
|
|
||||||
as file name. SYSTEM_WGETRC should not be defined under WINDOWS.
|
|
||||||
|
|
||||||
It is not as trivial as I assumed, because on 95 argv[0] is full
|
#ifdef WINDOWS
|
||||||
path, but on NT you get what you typed in command line. --dbudor */
|
/* Under Windows, if we still haven't found .wgetrc, look for the file
|
||||||
home = ws_mypath ();
|
`wget.ini' in the directory where `wget.exe' resides; we do this for
|
||||||
if (home)
|
backward compatibility with previous versions of Wget.
|
||||||
|
SYSTEM_WGETRC should not be defined under WINDOWS. */
|
||||||
|
if (!file || !file_exists_p (file))
|
||||||
{
|
{
|
||||||
file = (char *)xmalloc (strlen (home) + strlen ("wget.ini") + 1);
|
xfree_null (file);
|
||||||
sprintf (file, "%swget.ini", home);
|
file = NULL;
|
||||||
|
home = ws_mypath ();
|
||||||
|
if (home)
|
||||||
|
file = aprintf ("%s/wget.ini", home);
|
||||||
}
|
}
|
||||||
#endif /* WINDOWS */
|
#endif /* WINDOWS */
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* mswindows.c -- Windows-specific support
|
/* mswindows.c -- Windows-specific support
|
||||||
Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
|
Copyright (C) 1995, 1996, 1997, 1998, 2004 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GNU Wget.
|
This file is part of GNU Wget.
|
||||||
|
|
||||||
@ -199,22 +199,25 @@ char *
|
|||||||
ws_mypath (void)
|
ws_mypath (void)
|
||||||
{
|
{
|
||||||
static char *wspathsave = NULL;
|
static char *wspathsave = NULL;
|
||||||
char buffer[MAX_PATH];
|
|
||||||
char *ptr;
|
|
||||||
|
|
||||||
if (wspathsave)
|
if (!wspathsave)
|
||||||
{
|
{
|
||||||
return wspathsave;
|
char buf[MAX_PATH + 1];
|
||||||
|
char *p;
|
||||||
|
DWORD len;
|
||||||
|
|
||||||
|
len = GetModuleFileName (GetModuleHandle (NULL), buf, sizeof (buf));
|
||||||
|
if (!len || (len >= sizeof (buf)))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
p = strrchr (buf, PATH_SEPARATOR);
|
||||||
|
if (!p)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
*p = '\0';
|
||||||
|
wspathsave = xstrdup (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetModuleFileName (NULL, buffer, MAX_PATH) &&
|
|
||||||
(ptr = strrchr (buffer, PATH_SEPARATOR)) != NULL)
|
|
||||||
{
|
|
||||||
*(ptr + 1) = '\0';
|
|
||||||
wspathsave = xstrdup (buffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
wspathsave = NULL;
|
|
||||||
return wspathsave;
|
return wspathsave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user