Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37479911
en ru br
Репозитории ALT
S:1.18-alt1
5.1: 1.14-alt4
4.1: 1.14-alt2
4.0: 1.7-alt16
3.0: 1.7-alt13
www.altlinux.org/Changes

Группа :: Система/Библиотеки
Пакет: libpopt

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: popt-1.18-alt-poptBadOption.patch
Скачать


diff --git a/popt/src/popt.c b/popt/src/popt.c
index 2db2bbd..f93971e 100644
--- a/popt/src/popt.c
+++ b/popt/src/popt.c
@@ -1602,20 +1602,23 @@ int poptAddItem(poptContext con, poptItem newItem, int flags)
 
 const char * poptBadOption(poptContext con, unsigned int flags)
 {
-    struct optionStackEntry * os = NULL;
-    const char *badOpt = NULL;
-
-    if (con != NULL) {
-       /* Stupid hack to return something semi-meaningful from exec failure */
-       if (con->execFail) {
-           badOpt = con->execFail;
-       } else {
-           os = (flags & POPT_BADOPTION_NOALIAS) ? con->optionStack : con->os;
-           badOpt = os->argv[os->next - 1];
-       }
-    }
+    struct optionStackEntry * os;
+
+    if (!con)
+	return NULL;
+
+    /* Stupid hack to return something semi-meaningful from exec failure */
+    if (con->execFail)
+	return con->execFail;
+
+    os = (flags & POPT_BADOPTION_NOALIAS) ? con->optionStack : con->os;
+    if (!os)
+	return NULL;
+
+    if (con->doExec && con->doExec->argv && !os->nextCharArg && os->next == os->argc)
+	return con->doExec->argv[0];
 
-    return badOpt;
+    return ((os->argv && (os->next > 0)) ? os->argv[os->next - 1] : NULL);
 }
 
 const char * poptStrerror(const int error)
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin