aboutsummaryrefslogtreecommitdiff
path: root/util.c
Commit message (Collapse)AuthorAgeFilesLines
* sort and group includesNRK2022-06-281-2/+2
| | | | | | | | | | | | | * includes are sorted alphabetically * their grouping and layout is the following: - nsxiv.h will be the first include - followed by any internal headers (e.g "commands.h" "config.h") - followed by system headers (<stdlib.h> etc) - followed by third party headers (X.h libwebp etc) * also add `llvm-include-order` check to clang-tidy so that it can catch unsorted includes during CI.
* code-style: cleanup includesNRK2022-06-281-1/+2
| | | | | | | | * rm unused include <sys/types.h> * move <sys/time.h> to main.c, it's the only file that needs it. * move TV_* macros to main.c * let *.c files explicitly include what they need instead of including them at nsxiv.h
* [ci]: slience some clang-tidy warningsNRK2022-06-251-0/+2
| | | | | | | | | the warnings on r_readdir(), img_load_gif() and strcpy seems to be false positives. the warning about fmt being unused is valid, but not worth fixing with additional #ifdef guards. use `assert` to silence the false positive cases when possible, otherwise use a NOLINT comment with an explanation.
* fix: memory leak in r_readdir()NRK2022-06-251-1/+3
| | | | | reported by clang-tidy: `filename` gets leaked when this branch gets taken.
* fix: potentially printing wrong error message (#321)NRK2022-06-251-21/+16
| | | | | | | | | | | | it's possible for the close() calls to override the errno resulting in incorrect error message being printed. call error() immediately to avoid such possibilities. also refactor a couple conditions to avoid doing multiple checks. Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/321 Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
* r_mkdir: don't truncate the path on error (#322)NRK2022-06-221-5/+9
| | | | | | | | | | | | | | | | currently, in case of error, r_mkdir will leave the path at a truncated state. a7d39b0ab8 is the commit that introduced this change, and in it the error printing is moved from r_mkdir to the caller, which makes me think it was probably intentional. make it so that the function itself prints the error/warning message and returns the path back to the caller unharmed. Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/322 Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr> Reviewed-by: TAAPArthur <taaparthur@noreply.codeberg.org>
* Add reuseable abstraction over fork/exec/dup2 (#211)N-R-K2022-02-201-0/+76
|
* code-style: prefer calloc over malloc+memsetNRK2022-02-171-0/+10
|
* update copyright yearNRK2022-02-131-1/+1
|
* remove unused function and typedef (#199)N-R-K2022-01-021-10/+0
| | | | | byteorder_t and size_readable is not used anywhere within the code. byteorder_t seems to be a remain from some time sxiv handled exif data itself instead of relying on a library, introduced in 691c6d7, and probably became irrelevant when libexif was added as dependency again. And size_readable from some time it displayed the file size in the window title, introduced in bad9a70.
* code-style: general cleanups (#137)N-R-K2021-10-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * tns_clean_cache: remove unused function arg * remove malloc casting * improve consistency use sizeof(T) at the end * avoid comparing integers of different signedness * use Window type for embed and parent * remove unnecessary comparisons * remove cpp style comments * improve consistency: remove comma from the end of enumerator list * Removed useless _IMAGE_CONFIG defines * consistency: use the same order as snprintf * Resolve c89 warnings Co-authored-by: uidops <uidops@protonmail.com> Co-authored-by: Arthur Williams <taaparthur@gmail.com>
* update copyright notice (#139)eylles2021-10-281-1/+2
|
* code-style: remove extra casts (#130)javad2021-10-241-4/+4
| | | | Co-authored-by: N-R-K <79544946+N-R-K@users.noreply.github.com>
* code-style: fix consistency issues all over the codebase (#94)Berke Kocaoğlu2021-10-111-3/+2
| | | | | | | | | | | | | | | * remove duplicate comment * remove empty tabs and blank lines * move macros and globals ontop * comment to seprate function implementation * fix alignment * switch to *argv[] similar to other suckless code * kill all empty last lines * append comment to endif * reuse existing ARRLEN macro * comment fall through * use while (true) everywhere Co-authored-by: NRK <nrk@disroot.org>
* Rename, Update Docs and Prepare for Release (#9)Berke Kocaoğlu2021-09-161-5/+5
| | | | | | | Co-authored-by: Guilherme Rugai Freire <41879254+GRFreire@users.noreply.github.com> Co-authored-by: N-R-K <79544946+N-R-K@users.noreply.github.com> Co-authored-by: NRK <nrk@disroot.org> Co-authored-by: Arthur Williams <taaparthur@gmail.com> Co-authored-by: eylles <ed.ylles1997@gmail.com>
* Don't skip dot files when cleaning cacheKacper Gutowski2018-07-301-3/+9
|
* Replace utf8codepoint with Chris Wellons' utf8_decodeBert Münnich2017-12-071-28/+0
| | | | | | Code under a different license should be kept in a separate file. This implemention is a single header file with ~65 lines, so it better fits this requirement.
* Try to match a fallback font if neededSquibby2017-12-061-0/+29
| | | | | | | | | | | | | | Fixes #276 Instead of rendering the entire filename at once, Xft will let us do it character by character. This will allow sxiv to query fontconfig for a font that can provide any missing codepoints, if needed. A known issue of this patch is that the "..." dots rendering will not work properly for very long multibyte filenames. That is because we cannot easily predict the final width of the rendered filename before drawing it. I couldn't figure out a clean way to deal with this, so I ended up just truncating the offending filenames.
* One header file for type definitions and function declarationsBert Münnich2017-10-161-3/+2
|
* Allow opening directories non-recursivelyParide Legovini2016-09-281-2/+3
|
* Fix option -q; commit d3a70a2 completely broke it; fixes issue #223Bert Münnich2015-12-281-0/+3
|
* Simplified r_mkdir()Bert Münnich2015-10-281-29/+15
|
* Revised error handlingBert Münnich2015-10-281-34/+21
| | | | | | | - Functions warn() and die() replaced by GNU-like error(3) function - Register cleanup() with atexit(3) - Functions called by cleanup() are marked with CLEANUP and are not allowed to call exit(3)
* Prefix safe allocation functions with 'e' instead of 's_'Bert Münnich2015-10-281-15/+14
|
* Removed unnecessary buffer size constantsBert Münnich2015-10-281-7/+1
|
* Use XSI realpath(3)Bert Münnich2015-10-281-68/+0
|
* Use POSIX.1-2008 getline(3)Bert Münnich2015-10-281-30/+0
|
* Removed feature test macro definitions from source filesBert Münnich2015-10-281-2/+0
|
* Removed overcautious parameter checksBert Münnich2015-10-281-12/+3
|
* Bug #165: Deletion of unnecessary null pointer checksMarkus Elfring2014-08-221-11/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function "free" performs input parameter validation. http://pubs.opengroup.org/onlinepubs/9699919799/functions/free.html It is therefore not needed to check a passed pointer before this function call. A corresponding update suggestion was generated by the software "Coccinelle" from the following semantic patch approach. http://coccinelle.lip6.fr/ @Remove_unnecessary_pointer_checks1@ expression x; @@ -if (x != \(0 \| NULL\)) free(x); @Remove_unnecessary_pointer_checks2@ expression x; @@ -if (x != \(0 \| NULL\)) { free(x); x = \(0 \| NULL\); -} @Remove_unnecessary_pointer_checks3@ expression a, b; @@ -if (a != \(0 \| NULL\) && b != \(0 \| NULL\)) +if (a) free(b); @Remove_unnecessary_pointer_checks4@ expression a, b; @@ -if (a != \(0 \| NULL\) && b != \(0 \| NULL\)) { +if (a) { free(b); b = \(0 \| NULL\); } Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
* Made argument of s_strdup constlucas82014-08-011-1/+1
|
* Create thumbnail cache dir automaticallyBert Münnich2014-06-101-9/+2
|
* Ignore dotfiles for -rBert Münnich2013-02-111-1/+1
|
* Refactored function definitions to use dangling braceBert Münnich2013-02-081-12/+24
|
* Updated/corrected license headerBert Münnich2013-02-081-13/+13
|
* Already in the year 2012Bert Münnich2012-02-151-1/+1
|
* Removed slideshow supportBert Münnich2012-02-111-9/+0
|
* Updated contact informationBert Münnich2011-10-141-1/+1
|
* Strictly adhere to ANSI-C standardBert Münnich2011-10-131-1/+1
|
* Use void for empty argument listsBert Münnich2011-10-121-1/+1
|
* Made all conditionals more preciseBert Münnich2011-09-291-45/+47
|
* Transformed function macros in util.h to inline functionsBert Münnich2011-09-291-1/+1
|
* Added STREQ macroBert Münnich2011-09-261-1/+1
|
* make use of EXIT_ macrosrck2011-09-261-1/+1
|
* Added slideshow supportBert2011-09-101-2/+11
|
* Strict conformance to IEEE Std 1003.1-2001Bert2011-09-081-6/+38
|
* Avoid conflicting macrosBert2011-09-061-2/+2
|
* Reformated license headerBert2011-09-031-11/+11
|
* Data driven timeout handlingBert2011-09-021-13/+0
|
* Added support for gif animationBert2011-08-191-0/+13
|