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
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
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
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
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
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
1f734e960b
Replace spaces with tabs and vice versa
...
For Star Traders, all text files use spaces only (no tabs); for C source
code files, tabs are used, except in comments, where spaces only are used.
2018-08-08 14:55:58 +10:00
John Zaitseff
0e656681bc
Correct spelling or grammatical mistakes in various comments
2018-08-06 22:09:20 +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
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
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
cf944c58f6
Minor fix: we don't use mbrtowc() in our program
2011-08-20 15:49:19 +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
John Zaitseff
5bb48fe35f
Add wrapper functions xmalloc() and xstrdup() to do error handling
2011-08-13 08:50:34 +10:00
John Zaitseff
4b4efd7851
Replace the global variable localeconv_info with lconvinfo
...
In general, verbosity is not really to be encouraged...
2011-07-22 10:23:58 +10:00
John Zaitseff
b3f1820418
Add the restrict keyword where appropriate
2011-07-20 21:18:49 +10:00
John Zaitseff
da7477dc28
Compensate for the POSIX locale not having a currency symbol
...
The function l_strfmon() will insert MOD_POSIX_CURRENCY_SYMBOL in the
appropriate place when used with the POSIX ("C") locale.
2011-07-20 10:44:44 +10:00
John Zaitseff
c3d265a9ff
Clean up utils.c and utils.h
...
Move all function interface comments to the header file (where they
should have been in the first place), remove superfluous parentheses
where allowed by the precedence of C operators.
2011-07-19 21:38:27 +10:00
John Zaitseff
c19feab652
Clean up various comments, etc, in header files
2011-07-19 20:32:00 +10:00
John Zaitseff
ccbe7405f8
Replace "out of memory" errors with calls to err_exit_nomem()
2011-07-19 19:16:34 +10:00
John Zaitseff
16c421574f
Add the scramble() and unscramble() functions
...
These functions provide simple encryption and decryption to thwart casual
cheating!
2011-07-11 23:21:10 +10:00
John Zaitseff
dd281f795b
Add gettxline() to read a line of input from the keyboard
2011-07-11 10:31:19 +10:00
John Zaitseff
c0943b9f7d
Move (and abstract) the random number functions to utils.c
2011-07-04 17:13:29 +10:00
John Zaitseff
2a3e18460e
Rename intto_game_filename() to game_filename()
2011-07-04 10:28:50 +10:00
John Zaitseff
6c90801102
Add the err_exit() and errno_exit() functions
2011-07-02 14:23:35 +10:00
John Zaitseff
7fa5833fb6
Complete the command line argument processing routines
2011-06-30 15:25:30 +10:00
John Zaitseff
6910370557
Add various header files
...
Add the system.h header file for all system header includes, and utils.c
and utils.h for various low-level utility functions.
2011-06-15 22:34:28 +10:00