1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-06-09 19:20:43 +00:00
Commit Graph

74 Commits

Author SHA1 Message Date
John Zaitseff
cc5ee96ceb Update the copyright year to 2024 2024-01-02 12:33:37 +11:00
John Zaitseff
3f3f6157f0 Use -1 instead of EOF for an invalid file descriptor
The POSIX standards specify that the open() and openat() functions
technically return -1, not EOF, on failure -- even though most (perhaps
all) systems define EOF to be -1!
2022-08-02 21:06:18 +10:00
John Zaitseff
30bfcd167a Keep Coverity Scan happy
Coverity Scan (https://scan.coverity.com/projects/trader) complains that
a high-impact defect is present in the scramble() function: "String not
null terminated" -- even though b64encode() does give a NUL-termininated
buffer.
2022-08-01 22:27:56 +10:00
John Zaitseff
e3d5d04774 Eliminate a second TOCTOU bug in xmkdir() itself
The theoretical odds of hitting this time-of-check / time-of-use bug are
extremely remote.  But we do want to keep Coverity Scan happy, don't we?
2022-08-01 22:26:12 +10:00
John Zaitseff
89fdb5a65e Eliminate a TOCTOU bug between data_directory() and xmkdir()
Checking the presence of the traditional data directory using stat()
leads to a time-of-check / time-of-use bug by the time it is possibly
created using xmkdir().  Use file descriptors and openat() to work around
this problem.
2022-08-01 22:23:06 +10:00
John Zaitseff
9f5c0c361e Fix bug when the HOME environment variable is empty 2022-08-01 11:37:28 +10:00
John Zaitseff
9f65939586 Make home_directory() an internal function to utils.c 2022-08-01 11:27:09 +10:00
John Zaitseff
1231c084b8 Update the copyright year to 2022 2022-08-01 04:46:15 +10:00
John Zaitseff
2cc2dfffd5 Allow TEXTDOMAINDIR to specify the message catalog path 2021-01-14 13:06:31 +11:00
John Zaitseff
535f4cf965 Refactor locale initialisation into init_locale() 2021-01-14 12:28:02 +11:00
John Zaitseff
aa0e539540 Prevent the AppImage internal name from leaking out 2021-01-14 12:07:01 +11:00
John Zaitseff
82d460fe31 Rename init_locale() to init_locale_vars() 2021-01-14 12:04:48 +11:00
John Zaitseff
90a815afbb Create parent directories if required during mkdir 2021-01-12 09:48:05 +11:00
John Zaitseff
b132686a63 Use the XDG Base Directory Specification for storing game files 2021-01-07 23:19:41 +11:00
John Zaitseff
0d2462ef41 Update the copyright year to 2021 2021-01-07 17:07:55 +11:00
John Zaitseff
814ce71842 Update the copyright year to 2020 2020-01-02 08:37:36 +11:00
John Zaitseff
fa0cb153ff Update copyright year to 2019 2019-01-05 08:10:28 +11:00
John Zaitseff
d553aca98c Rename ret to n for consistency with other utility functions 2018-08-24 14:53:18 +10:00
John Zaitseff
aed5e8a46d Correct comments about locale 2018-08-24 14:11:21 +10:00
John Zaitseff
98696aa91c Use the wide-character version of EILSEQ_REPL 2018-08-24 13:32:32 +10:00
John Zaitseff
7647561a92 Use the more common post-increment form 2018-08-24 13:21:20 +10:00
John Zaitseff
daab2e94da Convert xstrfmon() into a wide-character version xwcsfmon()
Also work around buggy implementations of strfmon() that do not copy
complete multibyte sequences that may be part of a locale's
mon_thousands_sep, thousands_sep, mon_decimal_point or decimal_point.
2018-08-24 13:20:51 +10:00
John Zaitseff
6ec3beab75 Minor aesthetic cleanup 2018-08-24 10:46:13 +10:00
John Zaitseff
74218edb89 Bug fix: preincrement index when storing EILSEQ_REPL 2018-08-24 10:45:31 +10:00
John Zaitseff
1e0285f6c0 Rename l_strfmon() and rewrite as xstrfmon() to handle POSIX locale better
Current and previous versions of ISO/IEC 9945-1 (POSIX), particularly SUSv3
(2001) and SUSv4 (2008), require strfmon() to return rather meaningless
strings when used with the POSIX "C" locale.  In particular, the standard
POSIX locale does not define a currency symbol, a monetary radix symbol
(decimal point) or a negative sign.  This means strfmon(..., "%n", -123.45)
is supposed to produce "12345" instead of something like "$-123.45"!

The new xstrfmon() overcomes these limitations by using snprintf() as
appropriate.
2018-08-21 21:55:21 +10:00
John Zaitseff
097c9b0e5b Avoid a Clang warning about a comparison that is always false
Rewrite a check that unscramble_table[] is of the right size as an
assertion, which prevents Clang from issuing a warning that the "result
of comparison of constant 256 with expression of type 'const unsigned
char' is always false".

Oh for the day that C11's _Static_assert can be used amongst all
compilers!  But perhaps Gnulib's assert-h module can be used instead...
2018-08-08 13:50:15 +10:00
John Zaitseff
0e656681bc Correct spelling or grammatical mistakes in various comments 2018-08-06 22:09:20 +10:00
John Zaitseff
de6f113d12 Change parameters of apply_xor() from void * to char *
Arithmetic on void * pointers is undefined, according to Section 6.5.6
Paragraph 2, Section 6.2.5 Paragraph 1 and Section 6.2.5 Paragraph 19 of
the ISO/IEC 9899:1999 C99 standard: the void type is incomplete and thus
its size cannot be determined.

GCC allows pointer arithmetic on void * as an extension (and only warns
if "-Wpointer-arith" is given); the Oracle Developer Studio C compiler
issues a warning by default.
2018-08-04 14:31:45 +10:00
John Zaitseff
f45986e88d Pedantically type-cast integer comparisons
The latest versions of the GNU Compiler Collection complain about signed
and unsigned integer comparisons when run with the "-Wextra" flag.  Keep
those compilers happy.
2018-07-27 18:33:14 +10:00
John Zaitseff
c550549783 Correct spelling mistake in utils.c 2018-07-24 18:41:59 +10:00
John Zaitseff
abc9b77bd6 Change all relevant http references to https (secure HTTP) 2018-03-30 12:46:37 +11:00
John Zaitseff
8c6d009611 Update the copyright date to 2018 2018-03-30 11:38:29 +11:00
John Zaitseff
d0e1141355 utils.c: Rename the variable from "signed char c" to "int v" 2017-06-18 05:47:25 +10:00
John Zaitseff
6433c44dee Bug fix: if "char" is unsigned (as on some architectures), b64decode() fails 2017-06-15 11:40:24 +10:00
John Zaitseff
e4d884afc9 Replace U+0060 GRAVE ACCENT with U+0027 APOSTROPHE
In the past, GNU tools used quotes `like this'.  Modern practice is to
use quotes 'like this'.  Update Star Traders to follow this newer
standard, including all PO files.
2017-05-20 09:55:20 +10:00
John Zaitseff
2f79514910 Update the copyright date to 2017 2017-05-14 06:29:44 +10:00
John Zaitseff
a486cd15aa Update the copyright year to 2016 2016-01-05 09:25:51 +11:00
John Zaitseff
f16f78a509 Update the copyright date to 2015 2015-08-18 07:27:22 +10:00
John Zaitseff
9cb3a46693 Completely rewrite the scramble() and unscramble() functions
The file output is now completely in ASCII---and will be much harder to
break for casual cheating!
2014-05-23 18:56:24 +10:00
John Zaitseff
549b2d517d Use separate input and output buffers for scramble() and unscramble() 2014-05-22 15:34:32 +10:00
John Zaitseff
9450fed943 Update the copyright year to 2014 2014-05-22 11:05:51 +10:00
John Zaitseff
c25ec91e99 Update the copyright year to 2013, and the version number to 7.5 2013-02-02 10:48:43 +11:00
John Zaitseff
bc3e1a06a1 Update the copyright year to 2012 2012-03-15 02:36:23 +11:00
John Zaitseff
4ca99815b8 Be a little more diligent when it comes to wchar_t vs. wint_t
The %lc format is actually of type wint_t, according to printf(3), not
wchar_t, even though these are of the same underlying type on most (all?)
platforms.
2011-08-29 14:13:29 +10:00
John Zaitseff
1c2518a78b Minor clean-up: replace character constants with wide-char versions
Wide-char character constants is not strictly needed for most (all?)
modern C compilers, as ASCII maps to wchar_t directly (as long as
__STDC_ISO_10646__ is defined).  However, it doesn't hurt to be pedantic!
2011-08-25 21:34:41 +10:00
John Zaitseff
4733e98e7f Change program_name() to be a global variable
We're using global variables all over the place, in any case...
2011-08-25 14:26:25 +10:00
John Zaitseff
b951b21894 Add global (wide-character) currency and numeric variables
Add the variables decimal_point, thousands_sep, currency_symbol,
mon_decimal_point and mon_thousands_sep, with code to initialise them.
2011-08-25 12:26:15 +10:00
John Zaitseff
b5b211313e Move chstrdup() to utils.c and rename it to xchstrdup()
The new name is for consistency with other XXXdup() functions used in
this program.
2011-08-20 15:17:09 +10:00
John Zaitseff
7b544bbd35 Add the functions xwcrtomb() and xmbstowcs()
The xwcrtomb() and xmbstowcs() functions replace illegal characters with
EILSEQ_REPL ('?').  Adjust other functions, particularly mkchstr() and
friends, to suit.
2011-08-20 13:03:40 +10:00
John Zaitseff
336611559b Add the error-checking function xwcsdup() 2011-08-20 10:40:07 +10:00