8 Commits

Author SHA1 Message Date
Juergen Daubert
ca0a3c3524 update version to 5.19.2 2019-03-02 11:29:39 +01:00
James Buren
041feb25c1 fix misc compile warnings 2019-03-01 21:44:35 +01:00
James Buren
2993a9ad57 fix several compile warnings (-Wreorder) 2019-03-01 21:33:11 +01:00
James Buren
75285a0dd9 fix several compile warnings (-Wsign-compare) 2019-03-01 20:56:46 +01:00
James Buren
decb4e383c fix wrong use of close() instead of fclose() in commit 2fd99a3c8f, fix for FS#1646 2019-03-01 19:42:22 +01:00
James Buren
4b6998eade fix compile warning and segfault caused by a missing return statement
we had the following compile warning:
prt-get.cpp: In member function 'virtual SignalHandler::HandlerResult PrtGet::handleSignal(int)':
prtget.cpp:1628:1: warning: no return statement in function returning non-void [-Wreturn-type] }

which leads to a segfault if we compile prt-get with optimalization, e.g. -O2,
and interrupt prt-get with ^C
2019-03-01 19:21:48 +01:00
Thomas Penteker
2fd99a3c8f FS#1646 close fp in error case to avoid resource leak 2018-06-01 01:03:13 +02:00
Fredrik Rinnestam
54dc911470 FS#593 isatty(1) check for quickdep to increase usability 2017-06-17 20:29:44 +02:00
12 changed files with 90 additions and 55 deletions

2
configure vendored
View File

@@ -2585,7 +2585,7 @@ fi
# Define the identity of the package.
PACKAGE=prt-get
VERSION=5.19.1
VERSION=5.19.2
cat >>confdefs.h <<_ACEOF

View File

@@ -1,7 +1,7 @@
# Process this file with autoconf to produce a configure script.
AC_INIT
AC_CONFIG_SRCDIR([src/prtget.cpp])
AM_INIT_AUTOMAKE(prt-get,5.19.1)
AM_INIT_AUTOMAKE(prt-get,5.19.2)
dnl Determine default prefix

View File

@@ -25,18 +25,9 @@ ArgParser::ArgParser( int argc, char** argv )
m_isAlternateConfigGiven( false ),
m_useCache( false ),
m_calledAsPrtCache( false ),
m_alternateConfigFile( "" ),
m_pkgmkArgs( "" ),
m_pkgaddArgs( "" ),
m_pkgrmArgs( "" ),
m_installRoot( "" ),
m_ignore( "" ),
m_argc( argc ),
m_argv( argv ),
m_verbose( 0 ),
m_writeLog( false ),
m_hasFilter( false ),
m_noStdConfig( false ),
m_writeLog( false ),
m_nodeps( false ),
m_all( false ),
m_printPath( false ),
@@ -48,7 +39,21 @@ ArgParser::ArgParser( int argc, char** argv )
m_fullPath(false),
m_recursive(false),
m_printTree(false),
m_depSort(false)
m_depSort(false),
m_alternateConfigFile( "" ),
m_pkgmkArgs( "" ),
m_pkgaddArgs( "" ),
m_pkgrmArgs( "" ),
m_sortArgs( "" ),
m_filter( "" ),
m_commandName( "" ),
m_unknownOption( "" ),
m_installRoot( "" ),
m_ignore( "" ),
m_commandType(HELP),
m_argc( argc ),
m_argv( argv ),
m_verbose( 0 )
{
}

View File

@@ -24,11 +24,12 @@ Configuration::Configuration( const std::string& configFile,
const ArgParser* parser )
: m_configFile( configFile ),
m_parser( parser ),
m_cacheFile( "" ),
m_rootList(),
m_logFilePattern( "" ),
m_writeLog( false ),
m_appendLog( false ),
m_removeLogOnSuccess( false ),
m_logFilePattern( "" ),
m_cacheFile( "" ),
m_readmeMode( VERBOSE_README ),
m_runScripts( false ),
m_preferHigher( false ),

View File

@@ -51,9 +51,17 @@ InstallTransaction::InstallTransaction( const list<string>& names,
const Repository* repo,
PkgDB* pkgDB,
const Configuration* config )
: m_repo( repo ),
m_pkgDB( pkgDB ),
: m_pkgDB( pkgDB ),
m_resolver(),
m_repo( repo ),
m_depCalced( false ),
m_installedPackages(),
m_alreadyInstalledPackages(),
m_ignoredPackages(),
m_depNameList(),
m_depList(),
m_missingPackages(),
m_installErrors(),
m_config( config )
{
list<string>::const_iterator it = names.begin();
@@ -73,9 +81,17 @@ InstallTransaction::InstallTransaction( const list<char*>& names,
const Repository* repo,
PkgDB* pkgDB,
const Configuration* config )
: m_repo( repo ),
m_pkgDB( pkgDB ),
: m_pkgDB( pkgDB ),
m_resolver(),
m_repo( repo ),
m_depCalced( false ),
m_installedPackages(),
m_alreadyInstalledPackages(),
m_ignoredPackages(),
m_depNameList(),
m_depList(),
m_missingPackages(),
m_installErrors(),
m_config( config )
{
list<char*>::const_iterator it = names.begin();
@@ -97,9 +113,17 @@ InstallTransaction::InstallTransaction( const string& name,
const Repository* repo,
PkgDB* pkgDB,
const Configuration* config )
: m_repo( repo ),
m_pkgDB( pkgDB ),
: m_pkgDB( pkgDB ),
m_resolver(),
m_repo( repo ),
m_depCalced( false ),
m_installedPackages(),
m_alreadyInstalledPackages(),
m_ignoredPackages(),
m_depNameList(),
m_depList(),
m_missingPackages(),
m_installErrors(),
m_config( config )
{
m_packages.push_back( make_pair( name, m_repo->getPackage( name ) ) );

View File

@@ -316,10 +316,8 @@ void Package::expandShellCommands(std::string& input,
for (int i = 0; i < TAG_COUNT; ++i) {
string::size_type pos, dpos = 0;
int len;
pos = 0;
while ((pos = input.find(startTag[i], pos)) != string::npos) {
len = input.length();
if (unameBuf.release) {
input = replaceAll(input,

View File

@@ -56,10 +56,11 @@ const string PrtGet::DEFAULT_CACHE_FILE = LOCALSTATEDIR"/lib/pkg/prt-get.cache";
PrtGet::PrtGet( const ArgParser* parser )
: m_repo( 0 ),
m_config( 0 ),
m_currentTransaction( 0 ),
m_locker(),
m_parser( parser ),
m_cacheFile( DEFAULT_CACHE_FILE ),
m_returnValue( PG_OK ),
m_currentTransaction( 0 )
m_returnValue( PG_OK )
{
if ( m_parser->wasCalledAsPrtCached() ) {
m_appName = "prt-cache";
@@ -552,7 +553,7 @@ void PrtGet::listInstalled()
l.erase(mit);
InstallTransaction trans( name, m_repo, m_pkgDB, m_config );
InstallTransaction::InstallResult result = trans.calcDependencies();
InstallTransaction::InstallResult result __attribute__((unused)) = trans.calcDependencies();
const list<string>& depRef = trans.dependencies();
list<string>::const_iterator it = depRef.begin();
@@ -754,12 +755,15 @@ void PrtGet::printDepends( bool simpleListing )
const list<string>& deps = transaction.dependencies();
if ( simpleListing ) {
/* check if stdout is a tty, for package exclusion via: prt-get install `prt-get quickdep foobar | grep -v ^gnome-` */
bool const tty = isatty(1);
if ( deps.size() > 0 ) {
list<string>::const_iterator it = deps.begin();
for ( ; it != deps.end(); ++it ) {
cout << *it << " ";
}
cout << endl;
for ( ; it != deps.end(); ++it )
cout << *it << (tty ? " " : "\n");
if (tty)
cout << endl;
}
} else {
if ( deps.size() > 0 ) {
@@ -923,7 +927,7 @@ void PrtGet::printDiff()
const map<string, string>& installed = m_pkgDB->installedPackages();
map<string, string>::const_iterator it = installed.begin();
const Package* p = 0;
int count = 0;
size_t count = 0;
COMP_RESULT result;
for ( ; it != installed.end(); ++it ) {
@@ -1625,6 +1629,8 @@ SignalHandler::HandlerResult PrtGet::handleSignal( int signal )
if ( m_currentTransaction ) {
evaluateResult( *m_currentTransaction, false, true );
}
return EXIT;
}
/*!
@@ -1804,7 +1810,7 @@ void PrtGet::ls()
DIR* dir = opendir(dirname.c_str());
struct dirent* entry;
vector<string> files;
while (entry = readdir(dir)) {
while ((entry = readdir(dir))) {
string dName = entry->d_name;
if (dName != "." && dName != "..") {
files.push_back(dName);
@@ -1936,28 +1942,28 @@ void PrtGet::remove()
}
void PrtGet::assertMaxArgCount(int count)
void PrtGet::assertMaxArgCount(size_t count)
{
if ( m_parser->otherArgs().size() > count ) {
argCountFailure(count, "at most");
}
}
void PrtGet::assertExactArgCount(int count)
void PrtGet::assertExactArgCount(size_t count)
{
if ( m_parser->otherArgs().size() != count ) {
argCountFailure(count, "exactly");
}
}
void PrtGet::assertMinArgCount(int count)
void PrtGet::assertMinArgCount(size_t count)
{
if ( m_parser->otherArgs().size() < count ) {
argCountFailure(count, "at least");
}
}
void PrtGet::argCountFailure(int count, const string& specifier)
void PrtGet::argCountFailure(size_t count, const string& specifier)
{
cerr << m_appName << " "
<< m_parser->commandName() << " takes " << specifier << " "

View File

@@ -146,10 +146,10 @@ protected:
static const string DEFAULT_CACHE_FILE;
void assertMinArgCount(int count);
void assertMaxArgCount(int count);
void assertExactArgCount(int count);
void argCountFailure(int count, const string& specifier);
void assertMinArgCount(size_t count);
void assertMaxArgCount(size_t count);
void assertExactArgCount(size_t count);
void argCountFailure(size_t count, const string& specifier);
VersionComparator::COMP_RESULT
compareVersions( const string& v1, const string& v2 );

View File

@@ -256,6 +256,7 @@ Repository::initFromCache( const string& cacheFile )
if ( fgets( input, length, fp ) ) {
line = stripWhiteSpace( input );
if ( line != CACHE_VERSION ) {
fclose( fp );
return FORMAT_ERR;
}
}

View File

@@ -58,18 +58,18 @@ string stripWhiteSpace( const string& s )
return s;
}
int pos = 0;
size_t pos = 0;
string line = s;
string::size_type len = line.length();
size_t len = line.length();
while ( pos < len && isspace( line[pos] ) ) {
++pos;
}
line.erase( 0, pos );
pos = line.length()-1;
while ( pos > -1 && isspace( line[pos] ) ) {
while ( pos != (size_t) -1 && isspace( line[pos] ) ) {
--pos;
}
if ( pos != -1 ) {
if ( pos != (size_t) -1 ) {
line.erase( pos+1 );
}
return line;

View File

@@ -39,16 +39,16 @@ COMP_RESULT compareVersions(const string& v1, const string& v2)
tokenizeIntoBlocks(v1, blocks1);
tokenizeIntoBlocks(v2, blocks2);
int blockLen = normalizeVectors(blocks1, blocks2);
size_t blockLen = normalizeVectors(blocks1, blocks2);
for (int i = 0; i < blockLen; ++i) {
for (size_t i = 0; i < blockLen; ++i) {
vector<string> tokens1;
vector<string> tokens2;
split(blocks1[i], '.', tokens1);
split(blocks2[i], '.', tokens2);
int tokLen = normalizeVectors(tokens1, tokens2);
size_t tokLen = normalizeVectors(tokens1, tokens2);
for (int j = 0; j < tokLen; ++j) {
for (size_t j = 0; j < tokLen; ++j) {
if (tokens1[j] == tokens2[j]) {
continue;
}
@@ -67,8 +67,8 @@ COMP_RESULT compareVersions(const string& v1, const string& v2)
tokenizeMixed(tokens1[j], subtokens1);
tokenizeMixed(tokens2[j], subtokens2);
int subTokLen = normalizeVectors(subtokens1, subtokens2);
for (int k = 0; k < subTokLen; ++k) {
size_t subTokLen = normalizeVectors(subtokens1, subtokens2);
for (size_t k = 0; k < subTokLen; ++k) {
long sl1 = strtol(subtokens1[k].c_str(), &error1, 10);
long sl2 = strtol(subtokens2[k].c_str(), &error2, 10);
if (*error1 == 0 && *error2 == 0) {
@@ -123,9 +123,9 @@ COMP_RESULT compareVersions(const string& v1, const string& v2)
return EQUAL;
}
int normalizeVectors(vector<string>& v1, vector<string>& v2)
size_t normalizeVectors(vector<string>& v1, vector<string>& v2)
{
int length = max(v1.size(), v2.size());
size_t length = max(v1.size(), v2.size());
while (v1.size() < length) {
v1.push_back("-1");
@@ -140,14 +140,14 @@ int normalizeVectors(vector<string>& v1, vector<string>& v2)
void tokenizeMixed(const string& s, vector<string>& tokens)
{
vector<bool> digitMask;
for (int i = 0; i < s.length(); ++i) {
for (size_t i = 0; i < s.length(); ++i) {
digitMask.push_back(isdigit(s[i]));
}
bool state = digitMask[0];
string tok;
tok = s[0];
for (int i = 1; i < digitMask.size(); ++i) {
for (size_t i = 1; i < digitMask.size(); ++i) {
if (digitMask[i] != state) {
tokens.push_back(tok);
tok = s[i];

View File

@@ -19,7 +19,7 @@ enum COMP_RESULT { LESS, GREATER, EQUAL, UNDEFINED };
COMP_RESULT compareVersions(const string& v1, const string& v2) ;
void tokenizeIntoBlocks(const string& version, vector<string>& blocks);
int normalizeVectors(vector<string>& v1, vector<string>& v2);
size_t normalizeVectors(vector<string>& v1, vector<string>& v2);
void tokenizeMixed(const string& s, vector<string>& tokens);
}