summaryrefslogtreecommitdiffstats
path: root/src/pacman/util.c
AgeCommit message (Collapse)AuthorFilesLines
2014-01-28Remove ts and sw from vim modeline when noet is setFlorian Pritz1-1/+1
Forcing vim users to view files with a tabstop of 2 seems really unnecessary when noet is set. I find it much easier to read code with ts=4 and I dislike having to override the modeline by hand. Command run: find . -type f -exec sed -i '/vim.* noet/s# ts=2 sw=2##' {} + Signed-off-by: Florian Pritz <bluewind@xinu.at> Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-10create_verbose_row: free malloc'd stringsAndrew Gregory1-5/+5
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06Update copyright years for 2014Allan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-12-15Color output from pm_vasprintfAllan McRae1-2/+4
This makes sure warning and error messages from _alpm_log are colored. Fixes FS#35160. Signed-off-by: Allan McRae <allan@archlinux.org>
2013-11-15Fix whitespace and other formatting issuesJason St. John1-1/+1
This commit: -- replaces space-based indents with tabs per the coding standards -- removes extraneous whitespace (e.g. extra spaces between function args) -- adds missing braces for a one-line if statement Signed-off-by: Jason St. John <jstjohn@purdue.edu>
2013-11-08Remove spaces between the opening "if" and the opening parenthesisJason St. John1-1/+1
Signed-off-by: Jason St. John <jstjohn@purdue.edu> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-14pacman/util: remove strsplitAndrew Gregory1-34/+0
strsplit was used in only one place and did the same thing as strtok. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-09-04pacman/util.c: use switch when there are fall through statementsSami Kerola1-8/+6
An 'if' clause with empty statement is allowed, but unusual construct. When 'if' is used this way the statement should at least have orphan semicolon ';'. For empty statements 'switch' feels like a native way express what is meant. Signed-off-by: Sami Kerola <kerolasa@iki.fi> [Allan] Keep comment Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-08-21Do not refer to FlySpray numbersAllan McRae1-2/+2
These references to bug numbers assume we will forever be using that bug tracker. It is better to properly comment the code instead (which was done in almost all cases anyway). Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-05Consolidate and improve table implementationsSimon Gomizelj1-115/+122
Implement both the VerbosePkgList and the summary message with the same table. Improve VerbosePkgList by caching attributes and cell's lengths instead of recaculating them. Right align every cell that containing a file size in both the VerbosePkgList and the summary. Simplify the printf statements and the alignment application. Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-05-07pacman/util.c: add missing bracesAndrew Gregory1-1/+2
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-05-07pacman/util.c: fix output flushing in questionsAndrew Gregory1-3/+3
Flush stream before taking input in select_question() and only flush once during question(). Also fix some tabs inside related fprintf statements. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-18Fix spelling errors using 'codespell' toolAnatol Pomozov1-4/+4
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-04-06use off_t for table_row_t.sizeAndrew Gregory1-2/+2
size went from off_t in _display_targets to int in add_transaction_sizes and back to off_t in humanize_size leading to potential overflows. Fixes FS#34616. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-31pm_asprintf logs 'failed to allocate' alreadySimon Gomizelj1-1/+0
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-26signature_display should also be colourizedSimon Gomizelj1-1/+1
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-14Make "[removal]" translatableAllan McRae1-2/+2
Fixes FS#34241 Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-10remove the duplicate strnlen and strndupSimon Gomizelj1-22/+0
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07colourize the output of -Qi/SiSimon Gomizelj1-3/+3
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07colourize table outputSimon Gomizelj1-1/+3
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07colourize warnings and errorsSimon Gomizelj1-2/+4
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07colourize colon_printf and questionSimon Gomizelj1-2/+7
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07standardize format functionsSimon Gomizelj1-8/+8
Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07remove format from statistic messagesSimon Gomizelj1-11/+46
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 Gomizelj1-1/+1
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 Gomizelj1-2/+15
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 McRae1-2/+3
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 Pozzi1-1/+2
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 Pozzi1-3/+3
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 McRae1-50/+0
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 McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14Plug various minor memory leaksAndrew Gregory1-0/+2
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 McRae1-2/+18
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 McRae1-1/+1
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 Gregory1-1/+4
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 Gregory1-0/+5
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-21pacman: support group selection delimited by commasDave Reisner1-1/+1
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-30Output "Packages" instead of "Targets"Allan McRae1-1/+1
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-09Various tweaks to support building with excessive GCC warning flagsDan McGee1-1/+1
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-17Change table_display() to be staticDan McGee1-1/+1
It is only used inside util.c. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-16Reduce calls to getcolsDan McGee1-28/+35
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 McGee1-15/+16
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 McGee1-17/+12
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 McGee1-0/+3
Treat this value as the empty string. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-13Minor format-string related cleanupsDan McGee1-1/+1
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-09Hook new optdepend structures upBenedikt Morbach1-12/+67
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-21Merge branch 'maint'Dan McGee1-3/+7
Conflicts: contrib/pacsysclean.in src/pacman/conf.h
2012-02-20Give better error messages on database locking failuresDan McGee1-3/+7
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 McGee1-1/+1
Conflicts: lib/libalpm/sync.c src/util/pactree.c
2012-02-07Fix a handful of comment typos or misspellingsDan McGee1-1/+1
Signed-off-by: Dan McGee <dan@archlinux.org>