summaryrefslogtreecommitdiff
path: root/src/pacman/util.c
AgeCommit message (Collapse)Author
2013-03-31pm_asprintf logs 'failed to allocate' alreadySimon Gomizelj
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-26signature_display should also be colourizedSimon Gomizelj
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-14Make "[removal]" translatableAllan McRae
Fixes FS#34241 Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-10remove the duplicate strnlen and strndupSimon Gomizelj
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07colourize the output of -Qi/SiSimon Gomizelj
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07colourize table outputSimon Gomizelj
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07colourize warnings and errorsSimon Gomizelj
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07colourize colon_printf and questionSimon Gomizelj
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07standardize format functionsSimon Gomizelj
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07remove format from statistic messagesSimon Gomizelj
Remove the format component of the "Total Download Size" and related messages. The heading will be colourized, the size won't. However since the length of these messages can vary by language, we need a pretty printer to format them nicely. Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07split "Packages (%zd):" messageSimon Gomizelj
Basically all translation messages that need colouring but _also_ happen to be format strings need to be split up. This makes it easy to conditionally embed colour codes into the output at runtime. Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07remove :: prefix from all messageSimon Gomizelj
This will substantially simplify the logic to add colours to messages. Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-13Add format attributes to all required functionsAllan McRae
Fixes all clang warnings with -Wformat-literal. Also, fix genuine formating issue discovered once adding these attributes and add a cast to prevent a gcc warning. Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-04Fix open braces styleGerardo Exequiel Pozzi
Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-04Fix missing spaces in operatorsGerardo Exequiel Pozzi
Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-04Split common utility functions for libalpm and pacmanAllan McRae
There is duplicated code in the util.c files in the libalpm and pacman source code. Split this into a separate file so that it can be shared via a symlink. This prevents code divergence between the two code bases. Also, move mbasename and mdirname from pacman/util.c into util-common.c in preparation for the following patch that uses them to add an extension to pacsave files. Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-03Update copyright year for 2013Allan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14Plug various minor memory leaksAndrew Gregory
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14Display install status of optdependenciesAllan McRae
When a packages (new) optdepends are printed in install (update), add a note of their current installation status. Packages currently installed are labelled with [installed] and packages to be installed in this transaction are labelled [pending]. Signed-off-by: Allan McRae <allan@archlinux.org>
2012-09-18Avoid interger overflow when calculating remaining line lengthAllan McRae
When the len and cidx were changed to size_t in a8a1b093, it was possible to have an integer overflow when a line ended right at the edge of the terminal width. Signed-off-by: Allan McRae <allan@archlinux.org>
2012-09-18query_fileowner, mdirname: add error checksAndrew Gregory
Also consolidates cleanup for query_fileowner. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2012-09-18query_fileowner: remove assumption that root is "/"Andrew Gregory
Returning "/" from mdirname removes it as a special case which allows us to test it like any other directory. This corrects a false positive when querying a file in / and root is not set to /. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2012-05-20pacman: support group selection delimited by commasDave Reisner
We support multiple arguments being comma separated elsewhere, so this seems like a natural extension to support in our multiparse selection code. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-29Output "Packages" instead of "Targets"Allan McRae
Prefix the list of packages being installed/removed with "Packages" instead of "Targets" as they are package names by this stage. Fixes FS#23123. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-08Various tweaks to support building with excessive GCC warning flagsDan McGee
This fixes a bunch of small issues in order to enable a clean successful build with a crazy number of GCC warning flags. A lot of these changes are covered by -Wshadow, -Wformat-security, and -Wstrict-overflow=5. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-16Change table_display() to be staticDan McGee
It is only used inside util.c. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-16Reduce calls to getcolsDan McGee
This dramatically improves upon a much older attempt in 2008 in commit ce3d70aa99ab86. We don't need to call it once per line we print unless there is a reasonable expectation of being able to resize the terminal mid-operation; this is really only the case during our callback progress bars. Some before and after numbers of ioctl() calls, gleaned from strace of the following operations (no targets to any of them to maximize the amount of output): pacman -Qii : 37768 -> 2616 (93.1% decrease) pacman -Qs : 2616 -> 4 (99.8%) pacman -Sii : 133036 -> 10926 (91.8%) pacman -Ss : 10926 -> 14 (99.9%) Obviously the search results are astounding; we only call getcols() once in the case of -Qs, and once per repo in the case of -Ss. For -Qii and -Sii we are still calling it once per package, but this is much better than once per line of info output. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-16Pass a file descriptor to getcols and flush_term_inputDan McGee
This makes these methods a bit more flexible. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-16Always display download size if it appliesDan McGee
Currently, we try to do a bunch of funkyness constraining download size to print only when doing a -S/--sync operation. However, it is possible we try to download packages on a -U/--upgrade operation, and we currently won't show any itemized download sizes. Fix this ommission by always including the download size stuff in the built table rows; this column will be completely omitted anyway if there are no values due to prior work in commit 33bb7dbd35. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-16Handle printing NULL correctly in table displayDan McGee
Treat this value as the empty string. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-12Minor format-string related cleanupsDan McGee
We had one stubbed out so we didn't require a translation update, and the other is more a code style issue. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-08Hook new optdepend structures upBenedikt Morbach
No new behaviour introduced, everything should work exactly as before. Dan: refactored to use the single alpm_depend_t structure. Signed-off-by: Benedikt Morbach <benedikt.morbach@googlemail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-20Merge branch 'maint'Dan McGee
Conflicts: contrib/pacsysclean.in src/pacman/conf.h
2012-02-19Give better error messages on database locking failuresDan McGee
This was noted when trying to perform an operation on a pacman database on a read-only file system. Print the actual underlying errno string, and only show the "you can remove" message if the lock file actually exists. Before: $ pacman -Su error: failed to init transaction (unable to lock database) if you're sure a package manager is not already running, you can remove /e/db.lck After: $ pacman -Su error: failed to init transaction (unable to lock database) error: could not lock database: Read-only file system Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-13Merge branch 'maint'Dan McGee
Conflicts: lib/libalpm/sync.c src/util/pactree.c
2012-02-06Fix a handful of comment typos or misspellingsDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-06Merge branch 'maint'Dan McGee
Conflicts: lib/libalpm/alpm_list.c
2012-02-06ALPM API adjustments for sanity and consistencyDan McGee
This makes several small adjustments to our exposed method names, and in one case, parameters. The justification here is to make methods less odd in their naming convention. If a method takes an alpm_db_t argument, the method should be named 'alpm_db_*', but perhaps more importantly, if it doesn't take a database as the first parameter, it should not. Summary of changes: alpm_db_register_sync -> alpm_register_syncdb alpm_db_unregister_all -> alpm_unregister_all_syncdbs alpm_option_get_localdb -> aplpm_get_localdb alpm_option_get_syncdbs -> aplpm_get_syncdbs alpm_db_readgroup -> alpm_db_get_group alpm_db_set_pkgreason -> alpm_pkg_set_reason All methods keep the same argument list except for alpm_pkg_set_reason; there we drop the 'handle' argument as it can be retrieved from the passed in package object. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-03Add simple integer-only pow() implementationDan McGee
We hardly need the complexity (or slowness) provided by the libm power function; add a super-cheap one that suits our needs and is specialized for the values we plan on passing in. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-03Fix FS#27924: don't display negative zeroesThomas Dziedzic
Dan: don't compute lower bound unless needed, flip argument order so out values are last, add param Doxygen documentation. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-23Merge branch 'maint'Dan McGee
Conflicts: lib/libalpm/diskspace.c src/pacman/util.h
2012-01-18Update copyright on changed files since beginning of yearDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-18util.c, rmrf(): only create string when neededOlivier Brunel
The entry's name is only used when not "." or ".." so only print the string then. Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-18Fix missing [removal] outputAllan McRae
Currently, a transaction is considered to be purely package removal until the first package install is found. This resulted in the removed packages at the start of a combined upgrade/removal transaction not getting the "[removal]" output. Fixes FS#27981. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-18Fix broken output when asking question and stdin is pipedOlivier Brunel
When asking question and stdin is piped, the response does not get printed out, resulting in a missing \n and broken output (FS#27909); printing the response fixes it. Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-18Remove unused strtoupper() functionDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-23Convert strtrim/strlen paired calls to only strtrimDan McGee
This utilizes the new return value so we don't have to find the length of the string again. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-23pacman/util: return size_t from strtrimDave Reisner
Instead of returning the same value as the parameter to this function, return the length of the string, which can be useful to the caller when its non-zero (e.g. to find the end of the string). Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-12-21include config.h via MakefilesDave Reisner
Ensures that config.h is always ordered correctly (first) in the includes. Also means that new source files get this for free without having to remember to add it. We opt for -imacros over -include as its more portable, and the added constraint by -imacros doesn't bother us for config.h. This also touches the HACKING file to remove the explicit mention of config.h as part of the includes. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-12code syntax cleanupDave Reisner
As per HACKING file, we use 'CTRL(' rather than 'CTRL (' Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>