Prana <[EMAIL PROTECTED]> writes:
> Attached file: drakupdatetxt.tar.bz2
[...]
Here are some comments about the code...
> if (strncmp(downloaded_files->d_name,".",1) != 0 &&
> strncmp(downloaded_files->d_name,"..",2) != 0)
why use strncmp ?
> vector <string *> *installed_rpms;
why this fascination for pointers?
why not
: vector<string> downloaded_rpms;
at least, you can remove
"downloaded_rpms = new vector<string *>;" and "delete downloaded_rpms"
and you will not have plenty of memory leaks because of not destroying elements
in downloaded_rpms. C++ can do automatic (little) memory management, use it!
(of course, if you're sharing the strings, i'm saying bulshit :)
same pb ftp_site which should be string and not *string :pp
Function "get_package_name_position" is bad, what will happen with package like
kernel22? The only working solution is something like
/^(.*)-([^-]+)-([^-]+)\.[^.]+\.rpm$/
aka remove .rpm, remove the arch (must not contain .), remove the release (must
not contain -), remove the version (must not contain -)
I wonder if there is an easy C++ regexp engine that could be used to remove some
crap like:
colon_location = ftp_site->find(":");
if (ftp_site->substr(0,colon_location) == *machine)
// Is it the right update?
{
mirrors->push_back(new string( ftp_site->substr(colon_location+1,
ftp_site->length()) ));
}
which really is
push @mirrors, $1 if $ftp_site =~ /$machine:(.*)/
(which one is more readable?)
Happy coding, cu Pixel.