Commit Graph
253 Commits
Author SHA1 Message Date
Erik Auerswald 0793da7bcb replace strncat() with memcpy()
GCC 10 warns about the use of strncat(), but accepts the equivalent
use of memcpy() without warning.

¯\_(ツ)_/¯
2021-10-26 20:54:14 +02:00
Erik Auerswald 9b227e7d64 update reasons for string.h includes 2021-10-26 20:28:36 +02:00
Erik Auerswald 9b4690e68c help.c: remove unused include of string.h 2021-10-26 20:27:59 +02:00
Erik Auerswald 9b31b50154 guard against potential unsigned integer overflow
If the string length of the value of the environment variable TMP
is too big, adding the length of a slash and the temporary file
name might overflow, which would result in an insufficient memory
allocation for the absolute file name.

I do not know if that can actually happen in any existing operating
system and platform combination where ssocr can be used.
2021-10-26 20:18:11 +02:00
Erik Auerswald 8464c5c2b9 INSTALL: adjust to removed -Werror & -pedantic-errors 2021-10-25 20:11:19 +02:00
Erik Auerswald df0f1e35b7 fix compilation on Debian GNU/Linux Buster (11)
GCC has become too aggressive with its warnings, complaining about more
and more perfectly valid code.

In August 2020 I received a report of GCC 10.1 generating a warning
about strncat:

--------8<--------
cc -D_FORTIFY_SOURCE=2 -Wall -W -Wextra -pedantic -Werror -pedantic-errors -fstack-protector-all  -O3    -c -o ssocr.o ssocr.c
In file included from /usr/include/string.h:495,
                 from ssocr.c:29:
In function ‘strncat’,
    inlined from ‘tmp_imgfile’ at ssocr.c:79:12,
    inlined from ‘main’ at ssocr.c:454:15:
/usr/include/bits/string_fortified.h:136:10: error: ‘__builtin_strncat’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
  136 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ssocr.c: In function ‘main’:
ssocr.c:67:19: note: length computed here
   67 |     pattern_len = strlen(dir) + strlen(DIR_SEP TMP_FILE_PATTERN) + 1;
      |                   ^~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [<builtin>: ssocr.o] Error 1
-------->8--------

Basically the same problem has been reported in GitHub issue #15,
"Fails to build on Arm":

--------8<--------
cc -D_FORTIFY_SOURCE=2 -Wall -W -Wextra -pedantic -Werror -pedantic-errors -fstack-protector-all  -O3   -c -o ssocr.o ssocr.c
In file included from /usr/include/string.h:495,
                 from ssocr.c:29:
In function ‘strncat’,
    inlined from ‘tmp_imgfile’ at ssocr.c:79:12,
    inlined from ‘main’ at ssocr.c:529:15:
/usr/include/arm-linux-gnueabihf/bits/string_fortified.h:136:10: error: ‘__builtin_strncat’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
  136 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ssocr.c: In function ‘main’:
ssocr.c:67:19: note: length computed here
   67 |     pattern_len = strlen(dir) + strlen(DIR_SEP TMP_FILE_PATTERN) + 1;
      |                   ^~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [<builtin>: ssocr.o] Error 1
-------->8--------

As described in a Red Hat blog post[1], this warning cannot be avoided
without rewriting the code to not use strncat.  I do not intend to do so,
instead I just accept that GCC will generate warnings.  Thus this commit
removes -Werror and -pedantic-errors from the CFLAGS.

This fixes compilation on a x86_64 Debian Buster (11) GNU/Linux test
system with gcc (Debian 10.2.1-6) 10.2.1 20210110.

This strncat warning is the only warning generated by that gcc version.

[1] I do not link to that blog post here, because it requires JavaScript
    to display textual information, which I find unacceptable.
2021-10-25 19:40:20 +02:00
Erik Auerswald 5c8fb87549 INSTALL: mention X11 as prerequisite 2021-10-24 15:19:35 +02:00
Erik Auerswald 8dac811924 README: fix a typo 2021-10-24 15:09:43 +02:00
Erik Auerswald 36d314889f add more macOS info to INSTALL
GitHub user "watkit" reported to have needed

    make CPPFLAGS=-I/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/

to build ssocr on a 2020 m1 Mac mini.
2021-10-24 15:05:39 +02:00
Erik Auerswald 01051e8313 add character 'j' recognition to full charset 2021-07-18 16:58:23 +02:00
Erik Auerswald 3159b4bc28 add character 'y' recognition to full charset 2021-07-17 14:17:14 +02:00
Erik Auerswald cce3f196f8 defines.h: add commented out three segment N
While I know of seven segment displays that use
     _
    | |

as 'N', ssocr detects the size of the individual seven segment
displays and thus always sees this as

     _
    | |
    | |

unless the digit boundary detection fails.

This commit is intended as a reminder for me that I have already
thought about this issue.
2021-07-11 17:56:42 +02:00
Erik Auerswald 00846d5dd3 Makefile: use man to convert man page to HTML 2021-06-29 20:01:29 +02:00
Erik Auerswald efded91c1d replace "rman" with "mandoc" for man->html conversion
"rman" does not support the URL macros ".UR" and ".UE", but I use
those already.  "mandoc" does support these macros.
2021-06-24 20:33:51 +02:00
Erik Auerswald 24b4d7ab7c INSTALL: use current Homebrew URL 2021-06-24 20:25:59 +02:00
Erik Auerswald ea9e2996cc escape hyphens that shall be minus characters in the man page 2021-06-24 20:23:58 +02:00
Erik Auerswald 3c80d6a935 use URL macros for URLs in man page 2021-06-24 20:16:36 +02:00
Erik Auerswald 6204e113ab update a forgotten copyright info 2021-06-24 20:14:14 +02:00
Erik Auerswald 60735c3ff6 replace http URLs with https 2021-06-24 20:13:10 +02:00
Erik Auerswald 42e35b4c63 add more Google email madness to the README
I have encountered problems sending email to users of GMail, to
users of Google email services using domain names different from
gmail.com, and to Google employees using their corporate email
account.

Google is the only email provider that does not accept my emails,
as far as I know.
2021-05-08 13:35:20 +02:00
Erik Auerswald 3699b42d2a add a copyright section to the man page 2021-05-01 19:11:48 +02:00
Erik Auerswald ab6dab59ad two small corrections in help output 2021-04-27 19:18:02 +02:00
Erik Auerswald 113d665135 add ability to detect and print white space
This adds an option to enable white spece detection, and two
further options to control the operation of white space detection.

White space detection (--print-spaces) is intended for use cases
where digit (resp. character) grouping is important for correct
interpretation.  One use case is the recognition of superimposed
dates in photographic images.

This commit also increases the version number to 2.21.0 and tweaks
some debug output.
v2.21.0
2021-04-25 14:05:51 +02:00
Erik Auerswald 161778751c show default values for decimal separator ratios v2.20.0 2021-04-19 19:37:39 +02:00
Erik Auerswald dc463a5529 options to control decimal separator recognition
Additionally, bump copyright dates and version number.
2021-04-19 19:27:52 +02:00
Erik Auerswald 159f9c1809 INSTALL: fix typo 2021-04-11 18:44:59 +02:00
Erik Auerswald 08a628ff04 how to work around some compilation failures
C compilers are getting more aggressive with warnings and are producing
more false positives.  While I intend to keep ssocr compiling without
warnings (as in the last 15 years), I do not use the newest C compilers,
but rather the GCC version included in a stable GNU/Linux distribution,
it may take some time for me to encounter those problems myself, and thus
it may take some time for me to work around them.

A user reported a compilation failure due to new warnings in GCC 10.1.
Since I currently use GCC 7.5.0 from Ubuntu 18.04 LTS, I do not see
those warnings yet, and thus cannot test any workarounds yet.

A first investigation into the issue hints at a need to replace valid code
with code invalid for GCC's default C standard version (necessitating
the specification of a newer C standard in the CFLAGS) to work around
said problem.  I have no idea if there are additional warnings with GCC
10.1 after working around that one.  Since Google blocks my emails to
the reporting user, I cannot even communicate to find this out.  Thus any
code changes will have to wait for either a GCC version with additional
warnings arriving in my GNU/Linux distribution, or establishment of a
different communication channel, e.g., a GitHub issue.
2020-08-03 23:12:08 +02:00
Erik Auerswald 3a08177381 INSTALL: reword some platform specific advise 2020-08-02 23:51:47 +02:00
Erik Auerswald ddeeaffff7 INSTALL: inform about C compiler security features
There have been issues with the basic security features a modern C
compiler should provide, hindering compilation of ssocr. One way to work
around those is to disable use of the broken features.  Another way is
to use a quality C compiler, e.g., a stable GCC release.
2020-08-02 23:39:07 +02:00
Erik Auerswald bbdc4a179f README: warn against use of @gmail.com addresses
Google is blocking my answer emails to @gmail.com addresses.  So I
can only advise to use a real email provider, not Google.  If one
cannot do that, or does not want to, one can open a GitHub issue
instead.
2020-08-02 23:28:32 +02:00
Erik Auerswald 8a98e381e5 Makefile: cosmetics 2020-08-02 23:24:20 +02:00
Erik Auerswald e65a5c87c8 slightly improve man page...
...by adding that --debug-image can help using ssocr, and that
the image sometimes needs shearing for recognition of a decimal
point.
2020-01-25 20:27:59 +01:00
Erik Auerswald 2b4faf3e7d add info about Google blocking my email to README 2020-01-25 16:39:42 +01:00
Erik Auerswald 2dde9b95e0 README: improve installation information
This adds information relevant to issue #9 to the README file.
Before, the information was added to the ssocr home page and
the GitHub issue tracker only.
2019-05-30 13:37:28 +02:00
Erik Auerswald 4540283ae3 INSTALL: indent verbatim commands 2019-05-30 13:29:47 +02:00
Erik Auerswald 46fe73b6fc INSTALL: .deb package is built with 'make selfdeb' 2019-05-30 13:28:11 +02:00
Erik Auerswald ae3bc107b6 imgproc.c: shorten variable name to shorten line 2019-03-10 18:16:05 +01:00
Erik Auerswald 353ce4a470 imgproc.c: shorten variable name to shorten line 2019-03-10 18:12:00 +01:00
Erik Auerswald a069600590 imgproc.c: delete commented out debugging code 2019-03-10 18:09:12 +01:00
Erik Auerswald 17928b4b76 always use spaces for indentation, not tabs 2019-03-10 18:06:58 +01:00
Erik Auerswald 2031c2c08e refactor scanning for set segments
This introduces a function to scan part of the image for foreground
pixels.

This scanline() function may be of use for distuingishing between
the digit '1' and the symbol ":".

It may also help in segment detection reliability if the "len" parameter
is used to skip scanning image areas between segment positions.
2019-03-10 17:58:04 +01:00
Erik Auerswald 6d787a2683 add packagers to THANKS file
The email addresses are those found in public package maintainer
information already.
2019-02-03 16:27:01 +01:00
Erik Auerswald f17eef899e always use underscore '_' for unknown digits
Before, there was a special case where a blank ' ' could be printed
if no segments were detected in a digit at all. But this would not
happen, since all digits contain at least one pixel which would result
in some set segments.

This commit is a preparatory step for refactoring segement detection
in a digit.
2019-02-03 16:07:14 +01:00
Erik Auerswald d3fdf3b223 cosmetic changes in ssocr.c 2019-02-02 15:09:50 +01:00
Erik Auerswald 535aa89bdb keep line length <= 80 2019-02-02 14:30:41 +01:00
Erik Auerswald 9569289c63 bump copyright year to 2019 2019-02-02 13:08:13 +01:00
Erik Auerswald 07623ef831 make debug output imply verbose operation 2019-02-02 13:03:31 +01:00
Erik Auerswald 3bdd09428f ssocr.c: replace strcat with strncat 2018-12-29 11:40:02 +01:00
Erik Auerswald 592a4044e5 ssocr.c: simplify some string operations 2018-12-29 11:06:37 +01:00
Erik Auerswald 8c2f93d6c2 ssocr.c: replace last malloc() with calloc()
The code actually needs the allocated memory to have a '\0' byte
at the beginning.
2018-12-29 10:49:29 +01:00