From 69a708fd1b8e651ec5e258a95b71df5f46a23f95 Mon Sep 17 00:00:00 2001 From: Joachim LF Date: Wed, 28 Oct 2020 19:45:05 +0100 Subject: [PATCH 1/2] [Apps/main] Removed strcmp (see #1695) --- apps/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/main.cpp b/apps/main.cpp index d0dcf00b7..2b2ce27b5 100644 --- a/apps/main.cpp +++ b/apps/main.cpp @@ -52,8 +52,10 @@ void ion_main(int argc, const char * const argv[]) { const char * appNames[] = {"home", EPSILON_APPS_NAMES}; for (int j = 0; j < AppsContainer::sharedAppsContainer()->numberOfApps(); j++) { App::Snapshot * snapshot = AppsContainer::sharedAppsContainer()->appSnapshotAtIndex(j); - int cmp = strcmp(argv[i]+2, appNames[j]); - if (cmp == '-') { + const char * s1 = argv[i]+2; + const char * s2 = appNames[j]; + while (*s1 != '\0' && (*s1 == *s2)) {s1++; s2++;} + if (*s2 == '\0' && *s1 == '-') { snapshot->setOpt(argv[i]+2+strlen(appNames[j])+1, argv[i+1]); break; } From a680539b7c920f2c71900b5848fd1bcf97e0d239 Mon Sep 17 00:00:00 2001 From: Joachim LF Date: Wed, 28 Oct 2020 19:49:09 +0100 Subject: [PATCH 2/2] [Apps/main] Added comments --- apps/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/main.cpp b/apps/main.cpp index 2b2ce27b5..9a27bd359 100644 --- a/apps/main.cpp +++ b/apps/main.cpp @@ -52,6 +52,8 @@ void ion_main(int argc, const char * const argv[]) { const char * appNames[] = {"home", EPSILON_APPS_NAMES}; for (int j = 0; j < AppsContainer::sharedAppsContainer()->numberOfApps(); j++) { App::Snapshot * snapshot = AppsContainer::sharedAppsContainer()->appSnapshotAtIndex(j); + // Compare name in order to find if the firsts chars which are different are NULL and '-' + // -> check if the app name is in the argv const char * s1 = argv[i]+2; const char * s2 = appNames[j]; while (*s1 != '\0' && (*s1 == *s2)) {s1++; s2++;}