ändere ++ vom ende zum anfang ( bis auf die, mit optarg, beidenen ist es nötig), da keine copy des wertes vor der vergrößerung nötig ist, der zurückgegeben wird

This commit is contained in:
Markus 2019-09-04 22:05:41 +02:00
parent bdce2135fa
commit 92fdecab39
4 changed files with 14 additions and 13 deletions

View File

@ -46,7 +46,7 @@ Account AccountManager::getNextAccount()
exit(36); exit(36);
} }
size_t accountNumber = getLastAccountNumber(); size_t accountNumber = getLastAccountNumber();
accountNumber++; ++accountNumber;


if( accountNumber >= accounts.size() ) if( accountNumber >= accounts.size() )
accountNumber=0; accountNumber=0;

View File

@ -242,7 +242,7 @@ std::string PageManager::replace(std::string str, std::string substr1, std::stri
int PageManager::counterContains(std::string text, std::string substring_with_prozent_i_for_number, int starte_mit_dieser_Zahl) int PageManager::counterContains(std::string text, std::string substring_with_prozent_i_for_number, int starte_mit_dieser_Zahl)
{ {
int i = starte_mit_dieser_Zahl; int i = starte_mit_dieser_Zahl;
for (; text.find( replace(substring_with_prozent_i_for_number, "%i", std::to_string(i)) ) != std::string::npos; i++); for (; text.find( replace(substring_with_prozent_i_for_number, "%i", std::to_string(i)) ) != std::string::npos; ++i);
return i-1; return i-1;
} }



View File

@ -462,9 +462,9 @@ int unterOption_default(Settings *settings, int argc, char ** argv)
//Alle nicht verwendeten Parameter == Name //Alle nicht verwendeten Parameter == Name
while (optind < argc) { while (optind < argc) {
if(argv[optind][0]) { if(argv[optind][0]) {
settings->name.append(argv[optind++]).append(" "); settings->name.append(argv[optind++]).append(" "); // optind++ gives the value before ++ back
} else } else
optind++; ++optind;
} }


if(settings->name.length() > 0) if(settings->name.length() > 0)
@ -637,7 +637,7 @@ int unterOption_url(Settings *settings, int argc, char **argv)
if(argv[optind][0]) { if(argv[optind][0]) {
settings->name.append(argv[optind++]).append(","); settings->name.append(argv[optind++]).append(",");
} else } else
optind++; ++optind;
} }


if(settings->name.length() > 0) if(settings->name.length() > 0)
@ -737,7 +737,7 @@ int unterOption_search(Settings *settings, int argc, char **argv)
if(argv[optind][0]) { if(argv[optind][0]) {
settings->name.append(argv[optind++]).append(" "); settings->name.append(argv[optind++]).append(" ");
} else } else
optind++; ++optind;
} }
if(settings->name.length() > 0) if(settings->name.length() > 0)
settings->name.pop_back(); settings->name.pop_back();
@ -831,7 +831,7 @@ int unterOption_info(Settings *settings, int argc, char **argv)
if(argv[optind][0]) { if(argv[optind][0]) {
settings->name.append(argv[optind++]).append(" "); settings->name.append(argv[optind++]).append(" ");
} else } else
optind++; ++optind;
} }
if(settings->name.length() > 0) if(settings->name.length() > 0)
settings->name.pop_back(); settings->name.pop_back();
@ -879,15 +879,15 @@ void unterOption_clean(Settings * settings, int argc, char **argv)
perror(( " => Error: Das löschen von " + settings->cookieFilePath + " ist fehlgeschlagen: ").c_str()); perror(( " => Error: Das löschen von " + settings->cookieFilePath + " ist fehlgeschlagen: ").c_str());
return; return;
} else } else
count++; ++count;
} }


for (unsigned i = 0; i < UINT_MAX && fileExists(settings->cookieFilePath + std::to_string(i)); i++) { for (unsigned i = 0; i < UINT_MAX && fileExists(settings->cookieFilePath + std::to_string(i)); ++i) {
if(remove( (settings->cookieFilePath + std::to_string(i)).c_str() ) != 0) { if(remove( (settings->cookieFilePath + std::to_string(i)).c_str() ) != 0) {
perror((" => Error: Das löschen von " + settings->cookieFilePath + std::to_string(i) + " ist fehlgeschlagen: ").c_str()); perror((" => Error: Das löschen von " + settings->cookieFilePath + std::to_string(i) + " ist fehlgeschlagen: ").c_str());
return; return;
} else { } else {
count++; ++count;
} }
} }


@ -1003,6 +1003,7 @@ int setS5ProxytoSettings(Settings &settings, std::string Optarg)
std::cout << " > Defaults: Proxy Addresse: "<< settings.proxy_ip << ":" << settings.proxy_port << std::endl; std::cout << " > Defaults: Proxy Addresse: "<< settings.proxy_ip << ":" << settings.proxy_port << std::endl;


return 0; return 0;

} }





View File

@ -303,7 +303,7 @@ int ProgramManager::defaultModus(Settings *settings)
perror("pthread_creat failed"); perror("pthread_creat failed");
return 48; return 48;
} }
nextThread++; ++nextThread;
} else { // Sonnst warte bis alle Fertig sind und restarte die Folge } else { // Sonnst warte bis alle Fertig sind und restarte die Folge
if(waitForThreads() != 0) if(waitForThreads() != 0)
return 231; return 231;
@ -678,7 +678,7 @@ int ProgramManager::searchModus_update(Settings *settings)
ssize_t countBef = 0; ssize_t countBef = 0;
std::ifstream myFileBef(settings->serienListPath); std::ifstream myFileBef(settings->serienListPath);
if(myFileBef.is_open()) if(myFileBef.is_open())
for(countBef = 0; std::getline(myFileBef,line); countBef++); for(countBef = 0; std::getline(myFileBef,line); ++countBef);
myFileBef.close(); myFileBef.close();


//Schreibe die Liste in das TextFile //Schreibe die Liste in das TextFile
@ -694,7 +694,7 @@ int ProgramManager::searchModus_update(Settings *settings)
ssize_t countAf = 0; ssize_t countAf = 0;
std::ifstream myFileAf(settings->serienListPath); std::ifstream myFileAf(settings->serienListPath);
if(myFileAf.is_open()) if(myFileAf.is_open())
for(countAf = 0; std::getline(myFileAf,line); countAf++); for(countAf = 0; std::getline(myFileAf,line); ++countAf);
myFileAf.close(); myFileAf.close();


std::cout << "Serienunterschied: " << ( ((countAf - countBef) > 0) ? "+" : "") << countAf - countBef << " Serien." << std::endl; std::cout << "Serienunterschied: " << ( ((countAf - countBef) > 0) ? "+" : "") << countAf - countBef << " Serien." << std::endl;