зеркало из https://github.com/mozilla/pjs.git
on windows, make /mail be the same as -mail
on linux, make --mail be the same as -mail r=alecf #23501
This commit is contained in:
Родитель
a672e590b3
Коммит
d13816ec32
|
@ -162,6 +162,26 @@ nsCmdLineService::GetProgramName(char ** aResult)
|
|||
|
||||
}
|
||||
|
||||
PRBool nsCmdLineService::ArgsMatch(const char *lookingFor, const char *userGave)
|
||||
{
|
||||
if (!lookingFor || !userGave) return PR_FALSE;
|
||||
|
||||
if (!PL_strcasecmp(lookingFor,userGave)) return PR_TRUE;
|
||||
|
||||
#ifdef XP_UNIX
|
||||
/* on unix, we'll allow --mail for -mail */
|
||||
if ((PL_strlen(lookingFor) > 0) && (PL_strlen(userGave) > 1)) {
|
||||
if (!PL_strcasecmp(lookingFor+1,userGave+2) && (lookingFor[0] == '-') && (userGave[0] == '-') && (userGave[1] == '-')) return PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
#ifdef XP_PC
|
||||
/* on windows /mail is the same as -mail */
|
||||
if ((PL_strlen(lookingFor) > 0) && (PL_strlen(userGave) > 0)) {
|
||||
if (!PL_strcasecmp(lookingFor+1,userGave+1) && (lookingFor[0] == '-') && (userGave[0] == '/')) return PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCmdLineService::GetCmdLineValue(const char * aArg, char ** aResult)
|
||||
|
@ -174,7 +194,7 @@ nsCmdLineService::GetCmdLineValue(const char * aArg, char ** aResult)
|
|||
|
||||
for (int i = 0; i<mArgCount; i++)
|
||||
{
|
||||
if (!PL_strcasecmp(aArg, (char *) mArgList.ElementAt(i))) {
|
||||
if (ArgsMatch(aArg,(char *) mArgList.ElementAt(i))) {
|
||||
*aResult = (char *)mArgValueList.ElementAt(i);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,8 @@ protected:
|
|||
// normally is argc/2.
|
||||
PRInt32 mArgc; // This is argc;
|
||||
char ** mArgv; // This is argv;
|
||||
|
||||
PRBool ArgsMatch(const char *lookingFor, const char *userGave);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -162,6 +162,26 @@ nsCmdLineService::GetProgramName(char ** aResult)
|
|||
|
||||
}
|
||||
|
||||
PRBool nsCmdLineService::ArgsMatch(const char *lookingFor, const char *userGave)
|
||||
{
|
||||
if (!lookingFor || !userGave) return PR_FALSE;
|
||||
|
||||
if (!PL_strcasecmp(lookingFor,userGave)) return PR_TRUE;
|
||||
|
||||
#ifdef XP_UNIX
|
||||
/* on unix, we'll allow --mail for -mail */
|
||||
if ((PL_strlen(lookingFor) > 0) && (PL_strlen(userGave) > 1)) {
|
||||
if (!PL_strcasecmp(lookingFor+1,userGave+2) && (lookingFor[0] == '-') && (userGave[0] == '-') && (userGave[1] == '-')) return PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
#ifdef XP_PC
|
||||
/* on windows /mail is the same as -mail */
|
||||
if ((PL_strlen(lookingFor) > 0) && (PL_strlen(userGave) > 0)) {
|
||||
if (!PL_strcasecmp(lookingFor+1,userGave+1) && (lookingFor[0] == '-') && (userGave[0] == '/')) return PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCmdLineService::GetCmdLineValue(const char * aArg, char ** aResult)
|
||||
|
@ -174,7 +194,7 @@ nsCmdLineService::GetCmdLineValue(const char * aArg, char ** aResult)
|
|||
|
||||
for (int i = 0; i<mArgCount; i++)
|
||||
{
|
||||
if (!PL_strcasecmp(aArg, (char *) mArgList.ElementAt(i))) {
|
||||
if (ArgsMatch(aArg,(char *) mArgList.ElementAt(i))) {
|
||||
*aResult = (char *)mArgValueList.ElementAt(i);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,8 @@ protected:
|
|||
// normally is argc/2.
|
||||
PRInt32 mArgc; // This is argc;
|
||||
char ** mArgv; // This is argv;
|
||||
|
||||
PRBool ArgsMatch(const char *lookingFor, const char *userGave);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче