This project is mirrored from https://github.com/resurrecting-open-source-projects/scrot.git. Pull mirroring updated .
  1. 11 Jan, 2022 2 commits
    • guijan's avatar
      Add link time optimization and warnings · 9b72c0f7
      guijan authored
      Quoting
      [GCC Documentation](https://gcc.gnu.org/wiki/LinkTimeOptimization):
      > Link Time Optimization (LTO) gives GCC the capability of dumping its
      > internal representation (GIMPLE) to disk, so that all the different
      > compilation units that make up a single executable can be optimized as
      > a single module. This expands the scope of inter-procedural
      > optimizations to encompass the whole program (or, rather, everything
      > that is visible at link time).
      
      It also has the nice side effect of allowing warnings across translation
      units, as attested by these internet blogs:
      [gcc 8: link time and interprocedura optimization](https://hubicka.blogspot.com/2018/06/gcc-8-link-time-and-interprocedural.html)
      [gnu link time optimization finds non-matching declarations](https://mcuoneclipse.com/2018/05/31/gnu-link-time-optimization-finds-non-matching-declarations/)
      > A new user-visible feature is warning about type mismatches across
      > units.
      
      Some Linux distros are migrating towards enabling it by default for all
      packages, as
      [Phoronix](https://www.phoronix.com/scan.php?page=news_item&px=Ubuntu-21.04-LTO-Packages)
      claims.
      Some OSes (like OpenBSD) don't touch the compile flags of their packages
      though, so we should do it ourselves.
      
      This change adds autoconf-archive back as a dependency because I used
      autoconf-archive macros to get it done. Sorry, I only had the idea after
      the commit that removed it was pushed to master.
      
      This change replaces the CFLAGS with "-O2 -flto -g" and appends the same
      flags to LDFLAGS (LTO requires this) if the user hasn't set CFLAGS,
      effectively changing AC_PROG_CC's default of "-O2 -g". I checked
      out scrot 1.6, 1.7, and commit 6d299f58 (current master as of writing
      this), and compiled all 3 of them with CFLAGS='-O2', copying each
      resulting binary to /tmp/. Then I compiled 6d299f58 with
      CFLAGS='-O2 -flto' to show the difference made by this change:
      
      ```console
      $ size /tmp/scrot-*
      text    data    bss     dec     hex
      45417   2952    392     48761   be79    /tmp/scrot-1.6
      43724   3232    208     47164   b83c    /tmp/scrot-1.7
      42592   3168    208     45968   b390    /tmp/scrot-6d299f58
      39649   2880    200     42729   a6e9    /tmp/scrot-6d299f58-flto
      ```
      
      There's an overall trend with scrot getting 5% smaller with all the
      cleanups that have been made so far, and now LTO on top of 6d299f58
      reduces the binary by a further 7% for a total 12% reduction in binary
      size. LTO and code quality aren't purely there for smaller binaries, but
      smaller executables are an easy way to notice them.
      
      I also turned on all warnings by default.
      9b72c0f7
    • guijan's avatar
      Small CI revamp · addf1582
      guijan authored
      - Add Cygwin to the CI
      
      This is mainly to test portability further.
      Cygwin uses the newlib libc on top of Windows. The newlib libc
      implements a lot of BSD functions. It's a weird platform so maybe it'll
      catch a bug in the future.
      
      - Add distcheck CI target
      
      I noticed that in PR #175 @daltomi noticed the PR broke
      `make distcheck`, this could have been caught by the CI, now it will.
      I also noticed that the Github Actions CI was doing almost all of
      https://www.gnu.org/software/automake/manual/html_node/Checking-the-Distribution.html
      by hand, so the lines were deleted as `make distcheck` now fills
      their role.
      
      - Bring the Cirrus CI in line with Github Actions
      
      The Cirrus actions I wrote didn't run `scrot -v` or do the equivalent of
      `make distcheck`, now they do.
      I had to add the gzip package to the Alpine Linux VM as distcheck
      depends on it.
      
      - Update MacOS version in Cirrus CI
      
      - Update actions/checkout in Github Actions CI
      addf1582
  2. 10 Jan, 2022 1 commit
  3. 09 Jan, 2022 1 commit
    • guijan's avatar
      Untangle headers files · 6d299f58
      guijan authored
      untangle headers (#173)
      
      - rename src/main.c to src/scrot.c
      
      To follow the typical C organization where a header's filename only
      differs from its corresponding .c file in the extension, either scrot.h 
      needed to become main.h or main.c needed to become scrot.c.
      I follow the convention of naming the source file containing main()
      after the project, so I renamed main.c to scrot.c.
      
      - untangle src/scrot.h
      
      This file declared pretty much all of the scrot.c functions, which
      mostly aren't used in other source files, and it also declared functions
      and globals belonging to other source files (like initXAndImlib() and
      disp from src/imlib.c).
      I initially tried removing function declarations one by one and seeing
      where they were missed and where they were defined until I realized
      what was going on exactly, and then I simply deleted every single line
      in the file and rewrote it from scratch. For this reason, I consider
      that every line in the file is original and now it only contains my
      copyright.
      @daltomi mentioned that "the types of variables and their names, the
      names of functions as well as the types of parameters and number of
      parameters, have authorship over time" so the file has a notice pointing
      out where those were taken from and that they still retain the copyright
      of their authors. The same applies to the new file, src/imlib.h
      
      - untangle all the other headers
      
      With src/scrot.h previously being the central file holding
      system/Imlib/X11/scrot #includes, the other headers included it to get
      what they needed, and incidentally they also got a lot of extra baggage.
      
      The most important effect of this is that now the interactions between
      scrot's source files are strictly defined in code through the headers.
      
      This change has also made the fact that a lot of functions aren't used
      elsewhere obvious.Every function that is not declared in a header
      should be made static after this patch, and only functions that are
      used in other .c files should be declared in a header.
      
      - make every source file include its own header
      
      When your .c file doesn't include its own header, you run into the
      possibility of a function declaration used by other source files not
      matching its definition in the .c file. Maintaining this is brittle and
      requires human oversight which is prone to human error, and failure to
      do so can invoke undefined behavior.
      
      When your source file includes its own header, the compiler can warn you
      of mismatching types between declaration and definition.
      
      - remove the AX_PREFIX_CONFIG_H macro from configure.ac
      
      I did it because I considered this part of untangling headers. The macro
      created a copy of src/config.h with the name src/scrot_config.h.
      Here's the autotools documentation of the macro:
      https://www.gnu.org/software/autoconf-archive/ax_prefix_config_h.html
      scrot isn't a library and we don't install our header, so I removed it.
      
      Code using the C macros provided by autotools should #include "config.h"
      now, and the parts of the code that do have been updated to match this.
      
      - create a src/imlib.h header corresponding to src/imlib.c
      
      - make every .h file #include what it needs
      
      Now all the headers #include only what they need to get the types in
      their declarations, they have only what they need and nothing more, so
      scrot headers can't depend on a specific order of inclusion anymore.
      
      - make every .c file #include what it needs
      
      The inclusion order I used is "<sys/*> headers -> C/POSIX/BSD headers ->
      libraries -> local headers" with each group of headers alphabetically
      sorted and separated by a blank line.
      
      - misc small changes
      
      Some lines that were over 80 columns were broken up.
      The '*' symbol in struct, variable and function declarations was moved
      to be adjacent to the identifier and not the type, as per the WebKit
      style for C programs.
      
      - remove autoconf-archive dependency
      
      I noticed that the autoconf-archive dependency was not needed anymore
      because the only autotools macro with a name starting with `AX_` was
      removed.
      As you can see in the
      [autoconf-archive](https://www.gnu.org/software/autoconf-archive/The-Macros.html)
      reference, we don't use any of those macros.
      
      * make functions static
      
      This makes functions that aren't used across translation units static.
      It also includes some style fixes.
      6d299f58
  4. 05 Jan, 2022 2 commits
    • guijan's avatar
      Remove src/stamp-h.in · 8e28164c
      guijan authored
      Autotools documentation has an "Automatic Remaking" chapter, as you can
      see at: https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.70/html_node/Automatic-Remaking.html
      
      In it, there's a snippet about using a "stamp-h.in" file to
      "automatically update the configuration information when you change the
      configuration files" to quote the page, by adding a few rules to
      Makefile.in.
      
      Except we don't have such rules in our Makefile.in, so we're not using
      that file. The file dates back to old scrot so maybe it was in use then,
      but it's not now.
      8e28164c
    • Sam James's avatar
      autotools: respect --docdir · ee8121c6
      Sam James authored
      Before this patch with --docdir=/usr/share/doc/scrot-1.7-r1 (example downstream
      versioning for patches):
      
      >>> /usr/share/doc/scrot-1.7-r1/
      >>> /usr/share/doc/scrot-1.7-r1/README.md.bz2
      >>> /usr/share/doc/scrot-1.7-r1/ChangeLog.bz2
      >>> /usr/share/doc/scrot-1.7-r1/AUTHORS.bz2
      >>> /usr/share/doc/scrot/
      >>> /usr/share/doc/scrot/scrot.png
      >>> /usr/share/doc/scrot/README.md.bz2
      >>> /usr/share/doc/scrot/ChangeLog.bz2
      >>> /usr/share/doc/scrot/AUTHORS.bz2
      
      After:
      
      >>> /usr/share/doc/scrot-1.7-r1/scrot.png
      >>> /usr/share/doc/scrot-1.7-r1/README.md.bz2
      >>> /usr/share/doc/scrot-1.7-r1/ChangeLog.bz2
      >>> /usr/share/doc/scrot-1.7-r1/AUTHORS.bz2
      
      This avoids installing duplicate files & installs them to the
      same location but it's overridable by --docdir in ./configure which
      helps downstreams.
      
      Bug: https://bugs.gentoo.org/828928
      ee8121c6
  5. 29 Dec, 2021 1 commit
    • Daniel T. Borelli's avatar
      Fix issue when not showing counting progress in terminal · c68cd276
      Daniel T. Borelli authored
      Fix "--count --delay" rendering issue when not showing counting progress in terminal.
      
      This happens when using the "--freeze" option and the "hide/hole/blur" selection modes with the classic line style.
      
      In this scenario, the "--freeze" option acts twice, generating the failure.
      c68cd276
  6. 09 Dec, 2021 2 commits
    • guijan's avatar
      Rename reserved identifiers · d0f5bf4b
      guijan authored
      This patch renames 2 identifiers that use reserved names, and removes a
      source file containing typedefs for them.
      
      Ref.: https://www.iso-9899.info/n1570.html#7.1.3
      d0f5bf4b
    • guijan's avatar
      Add estrdup function · ed172eff
      guijan authored
      This patch adds an estrdup() fuction which is merely a strdup() which
      never returns NULL because it terminates execution on error. It replaces
      strdup() calls with the new function, none of the calls check if the
      returned pointer is NULL.
      ed172eff
  7. 08 Dec, 2021 2 commits
    • guijan's avatar
      Check for more libbsd functions · 429468cc
      guijan authored
      This patch adds checks for the presence of the warn() and warnx()
      functions, and it also adds checks for the presence of the sys/queue.h
      header.
      429468cc
    • guijan's avatar
      C99 forbids empty initializer braces · 67ffdde8
      guijan authored
      An empty initializer list is a GNU extension. The Standard C way of
      initializing a struct with nulls is to initialize the first member with
      a 0, which implicity null-initializes all the other members of the
      struct.
      67ffdde8
  8. 07 Dec, 2021 1 commit
  9. 06 Dec, 2021 2 commits
    • Guilherme Janczak's avatar
      bring the logo up to speed and use it · a5dcbfdf
      Guilherme Janczak authored
      This patch does several things all at once:
      - delete scrot-128x128.png
      
      It's not used in the project and we're not a GUI program, so what is it
      for?
      
      - move the layer containing the "camera flash" effect in the .xcf logo
      to the top layer
      
      It's a bit weird if the camera's flash is behind the camera.
      
      - move the camera flash one pixel to the left
      
      This seems to center it better.
      
      - output the lightly modified logo to doc/scrot.png and add the logo to
      the README
      
      I noticed that this project https://github.com/kohler/gifsicle has their
      fancy logo at the top of the readme and I thought it was pretty cool. I
      think we should do the same.
      a5dcbfdf
    • Guilherme Janczak's avatar
      remove reference to oldstable in CONTRIBUTING.md · a552268c
      Guilherme Janczak authored
      It seems the CI definitions only build against Debian Testing and Debian
      Unstable now, this patch removes the mention of Debian Oldstable.
      a552268c
  10. 10 Nov, 2021 7 commits
  11. 08 Nov, 2021 2 commits
  12. 27 Oct, 2021 1 commit
  13. 24 Oct, 2021 1 commit
    • Daniel T. Borelli's avatar
      New feature: selection mode 'hide' supports image · edca8d90
      Daniel T. Borelli authored
      It allows to optionally indicate an image file as a stamp, it has priority over the color.
      
      This commit also introduces a new format for SELECTION MODE
      
      Thanks to this format, the amount in 'blur' mode is no longer a constant but an optional parameter to it.
      edca8d90
  14. 21 Oct, 2021 1 commit
  15. 15 Oct, 2021 1 commit
  16. 13 Oct, 2021 1 commit
  17. 11 Oct, 2021 1 commit
  18. 10 Oct, 2021 1 commit
  19. 05 Oct, 2021 2 commits
  20. 04 Oct, 2021 1 commit
  21. 03 Oct, 2021 1 commit
  22. 23 Sep, 2021 1 commit
  23. 10 Sep, 2021 1 commit
  24. 09 Sep, 2021 1 commit
  25. 27 Aug, 2021 3 commits