Fix 2000/rince/README.md + update bugs.md

There is a known crash in the program if DISPLAY is unset.

Typo fixed and format fixed.
This commit is contained in:
Cody Boone Ferguson committed 2023-04-20 09:24:39 -07:00
1 parent 132518a399
commit 4d19b7a11c
2 files changed
+94 -82

No files matched your search

+87 -82
View File
@@ -19,6 +19,11 @@ make
./rince number number2 ./rince number number2
``` ```
### INABIAF - it's not a bug it's a feature! :-)
If `DISPLAY` is not set the program will very likely crash or do something
different.
## Try: ## Try:
```sh ```sh
@@ -28,11 +33,11 @@ make dmy2jd
## Judges' remarks: ## Judges' remarks:
This program may have you going around in circles :-) Try running it This program may have you going around in circles :-) Try running it first
first before reading the author's remarks below. before reading the author's remarks below.
The judges verified the correctness of output for recent dates The judges verified the correctness of output for recent dates through visual
through visual observation. observation.
## Author's remarks: ## Author's remarks:
@@ -67,19 +72,22 @@ Julian day number (given as a fractional component). E.g.:
./rince 0.01 2441193.6 ./rince 0.01 2441193.6
``` ```
A Julian day is defined to be the number of days since January 1st in A Julian day is defined to be the number of days since January 1st in the year
the year -4712 (4713BC), starting at 12 noon GMT.[1] To aid conversion `-4712 (4713BC)`, starting at 12 noon GMT.\[1\] To aid conversion from our time
from our time (GMT) to Julian day there is a supplementary program (GMT) to Julian day there is a supplementary program named:
named: dmy2jd.c. Run it with `day_float month year` as arguments. See [dmy2jd.c](dmy2jd.c). Run it with `day_float month year` as arguments. See below
below for an example. for an example.
### What it does ### What it does
This program plots the positions of the four Galilean moons of Jupiter, This program plots the positions of the four [Galilean
as seen from earth. It doesn't correct for your location on earth, but I moons](https://en.wikipedia.org/wiki/Galilean_moons) of
assure you that the parallax is minimal! [Jupiter](https://en.wikipedia.org/wiki/Jupiter), as seen from
[Earth](https://en.wikipedia.org/wiki/Earth). It doesn't correct for your
location on Earth, but I assure you that the
[parallax](https://en.wikipedia.org/wiki/Parallax#Astronomy) is minimal!
The moons are labelled with roman numerals from I to IV. I being the The moons are labelled with Roman numerals from I to IV. I being the
closest to the planet and IV being the furthest. They are: closest to the planet and IV being the furthest. They are:
``` ```
@@ -174,39 +182,46 @@ Galileo discovered the fourth moon a few days later.
I've tried typing these dates in to two Java based Jovian moon plotters, I've tried typing these dates in to two Java based Jovian moon plotters,
but both I tried had problems dealing with dates earlier than 1900. More but both I tried had problems dealing with dates earlier than 1900. More
professional software, such as the SkyMap program [3] gets these values professional software, such as the
[SkyMap](http://www.bmsoftware.com/skymappro9.htm) gets these values
correct and this compares well with the above description and with this correct and this compares well with the above description and with this
IOCCC entry. IOCCC entry.
The year 4713BC was chosen by [Joseph Justus
The year 4713BC was chosen by Joseph Justus Scaliger in the 16th Century, Scaliger](https://en.wikipedia.org/wiki/Joseph_Justus_Scaliger) in the 16th
so clearly this program has a long history :-) A more complete description Century, so clearly this program has a long history :-) A more complete
of the origins of Julian Days can be found at description of the origins of Julian Days can be found at
<https://web.archive.org/web/20001206152200/http://aa.usno.navy.mil/AA/faq/docs/millennium.html>. <https://web.archive.org/web/20001206152200/http://aa.usno.navy.mil/AA/faq/docs/millennium.html>.
### Assumptions ### Assumptions
This program assumes:
1. The ASCII character set is used. 1. The ASCII character set is used.
2. That an enormous comet hasn't changed the course of Jupiter (or Earth!). 2. That an enormous comet hasn't changed the course of Jupiter (or Earth!).
3. That the date has not been specified as the gap between the Julian and Gregorian calendar. 3. That the date has not been specified as the gap between the
[Julian](https://en.wikipedia.org/wiki/Julian_calendar) and
[Gregorian](https://en.wikipedia.org/wiki/Gregorian_calendar) calendar.
4. That the DISPLAY environment variable is set and the X display can opened. If this is not the case the program will crash. 4. That the `DISPLAY` environment variable is set and the X display can opened.
If this is not the case the program will crash.
5. There is a year 2000BC problem :-) 5. There is a year 2000BC problem :-)
More specifically, the plots for dates that far back are too inaccurate More specifically, the plots for dates that far back are too inaccurate to
to be of realistic use. Comparisons against SkyMap Pro [3] show that be of realistic use. Comparisons against [SkyMap
there is a good similarity (but not much more) up to about 500BC. Pro](http://www.bmsoftware.com/skymappro9.htm) show that there is a good
similarity (but not much more) up to about 500BC.
6. The code definitely is not portable - it will produce incorrect results if run from the surface of Mars. 6. The code definitely is not portable - it will produce incorrect results if run from the surface of Mars.
### Obfuscations ### Obfuscations
In addition to the normal obfuscations, I feel that the code contains In addition to the normal obfuscations, I feel that the code contains some less
some less common tricks. Taken through the standard rounds listed in the common tricks. Taken through the standard rounds listed in the
guidelines, the code attempts to pass these as follows: [guidelines](/2000/guidelines.txt), the code attempts to pass these as follows:
1. Look at the original source 1. Look at the original source
@@ -219,26 +234,26 @@ guidelines, the code attempts to pass these as follows:
large string constant could not be split up using a "partA" large string constant could not be split up using a "partA"
"partB" method which clearly limits the code layout. However the "partB" method which clearly limits the code layout. However the
space saved by using a single long string constant is more than space saved by using a single long string constant is more than
outweighed by ability to further obfuscate. outweighed by the ability to further obfuscate.
2. convert ANSI tri-graphs to ASCII 2. convert ANSI tri-graphs to ASCII
These are not used. These are not used.
3. C pre-process the source ignoring #include lines 3. C pre-process the source ignoring `#include` lines
4. C pre-process the source ignoring #define and #include lines 4. C pre-process the source ignoring `#define` and `#include` lines
This does a good job of expanding out the code, but it does not This does a good job of expanding out the code, but it does not
clarify things greatly. The use of #defines has been restricted clarify things greatly. The use of `#defines` has been restricted
primarily to a space-saving mechanism. primarily to a space-saving mechanism.
Additionally, the use of typedefs means that the types used are Additionally, the use of `typedef`s means that the types used are
still obscured unless further replacement edits are made. still obscured unless further replacement edits are made.
5. Run it through a C beautifier. 5. Run it through a C beautifier.
GNU indent seems to do a reasonable job, provided that the GNU indent seems to do a reasonable job, provided that the
#defines are expanded first. This doesn't lay the algorithm `#define`s are expanded first. This doesn't lay the algorithm
particularly bare though as most of the obfuscations are not particularly bare though as most of the obfuscations are not
simple code layouts. simple code layouts.
@@ -246,15 +261,14 @@ guidelines, the code attempts to pass these as follows:
The algorithm operates on two levels. The main visible level is The algorithm operates on two levels. The main visible level is
by taking a large string and breaking this down into a series of by taking a large string and breaking this down into a series of
op-codes (which I have termed J-code). These are then executed. opcodes (which I have termed J-code). These are then executed.
To get to the real method of how it works, you need to decode To get to the real method of how it works, you need to decode
the op-code string (which deliberately contains as many ; { and the opcode string (which deliberately contains as many `;`, `{` and
} symbols as possible), which will give you a reverse-polish `}` symbols as possible), which will give you a reverse-polish
notation chunk of mathematics. notation chunk of mathematics.
Sensible people amongst you will simply refer to the referenced Sensible people amongst you will simply refer to the referenced book :-)
book :-)
7. Lint it. 7. Lint it.
@@ -269,69 +283,63 @@ guidelines, the code attempts to pass these as follows:
I'm sorry to say that there are several warnings issued by the I'm sorry to say that there are several warnings issued by the
compiler. compiler.
Firstly, the return type for X() is not specified, so it Firstly, the return type for `X()` is not specified, so it defaults to int.
defaults to int. Horror of all horrors - this function does not Horror of all horrors - this function does not return an integer type (it
return an integer type (it doesn't contain any specific doesn't contain any specific returns). The return value from `X()` is not
returns). The return value from X() is not accessed. The same accessed. The same problem occurs in `main()` - it does not return. However
problem occurs in main - it does not return. However main never `main()` never exits unless there is a serious error.
exits unless there is a serious error.
The 6th argument of XDrawText (which should be XTextItem) is The 6th argument of `XDrawText` (which should be `XTextItem`) is
passed as a compatible structure, but without casting. This is passed as a compatible structure, but without casting. This is
to reduce code space. A more elegant solution is to remove the to reduce code space. A more elegant solution is to remove the
"struct {...} Z" completely and use "XTextItem `struct {...} Z` completely and use `XTextItem
f={i-127+r/3*2,r%3+r/3+1,0,E}" at the start of XDrawText f={i-127+r/3*2,r%3+r/3+1,0,E}` at the start of `XDrawText`
block. Although this is accepted by several compilers, it is not block. Although this is accepted by several compilers, it is not
strict ANSI due to the non-constant initialisers. A pity. strict ANSI due to the non-constant initialisers. A pity.
Note that I make use of usleep(). This is a POSIX call (it is Note that I make use of `usleep()`. This is a POSIX call (it is BSD), but it's
BSD), but it supported on many systems. It may be implemented supported on many systems. It may be implemented using `select()` or `poll()` if
using select() or poll() if required, or as a final solution you required, or as a final solution you can change the `usleep(10000)` to
may change the usleep(10000) to sleep(1). To compile on systems `sleep(1)`. To compile on systems which do not have `usleep()`, but do have
which do not have usleep, but do have select, the following may `select()`, the following may suffice as an additional compiler argument:
suffice as an additional compiler argument:
```sh ```
-Dusleep={time_t v[2]={0,10000};select(0,0,0,0,v);} -Dusleep={time_t v[2]={0,10000};select(0,0,0,0,v);}
``` ```
Gcc complains about "unreachable code at beginning of switch gcc complains about "unreachable code at beginning of switch
statement", although removing some of this code will prevent statement", although removing some of this code will prevent
the algorithm from working. the algorithm from working.
Gcc also suggests that I should be using extra parenthesis, but gcc also suggests that I should be using extra parenthesis, but
I'm taking this as good comment :-) I'm taking this as good comment :-)
In addition to the above, the program has the following useful(?) In addition to the above, the program has the following useful(?)
obfuscations: obfuscations:
1. The algorithm requires many floating point numbers (about 1. The algorithm requires many floating point numbers (about 50). These are
50). These are encoded as ASCII. encoded as ASCII.
2. The J-code algorithm has op-codes designed to be space 2. The J-code algorithm has opcodes designed to be space saving. They are all
saving. They are all one byte, but many are also considered as one byte, but many are also considered as whitespace by the rules. This
white-space by the rules. This algorithm forms part of the same algorithm forms part of the same string that the floating point constants are
string that the floating point constants are embedded embedded within. What does the `;` command do in J-code?
within. What does the ";" command do in J-code?
3. The J-code language is both stack based and variable based. This 3. The J-code language is both stack based and variable based. This
"uncleanliness" is not ideal from a computer science angle, but "uncleanliness" is not ideal from a computer science angle, but when has
when has cleanliness been considered as good in IOCCC? :-) cleanliness been considered as good in IOCCC? :-)
4. Association of unconnected data by implied function usage. Eg 4. Association of unconnected data by implied function usage. E.g. use of
use of strlen() and sizeof() simply to return useful numerical `strlen()` and `sizeof()` simply to return useful numerical values, using
values, using irrelevant arguments. irrelevant arguments.
5. As we already have a dependency on ASCII this has been abused 5. As we already have a dependency on ASCII this has been abused further.
further. Specifically some integer constants are specified as Specifically some integer constants are specified as ASCII and some ASCII
ASCII and some ASCII constants are integers. This hides the true constants are integers. This hides the true meaning for the values.
meaning for the values.
6. Red herrings: there's a couple of pieces of code whose 6. Red herrings: there are a couple of pieces of code whose appearance is just
appearance is just there to mislead the unfirm of mind. there to mislead the infirm of mind. I've only tried to include such examples
I've only tried to include such examples in places where at in places where at first glance the code appears to be executed.
first glance the code appears to be executed.
### References ### References
@@ -341,9 +349,6 @@ Jean Meeus. Published by Willmann-Bell Inc.
[2] Astronomical algorithms (1st ed): pages 285-299. [2] Astronomical algorithms (1st ed): pages 285-299.
Jean Meeus. Published by Willmann-Bell Inc. Jean Meeus. Published by Willmann-Bell Inc.
[3] Skymap Pro, by Chris Marriott
http://www.skymap.com/
## Copyright and CC BY-SA 4.0 License: ## Copyright and CC BY-SA 4.0 License:
This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved. This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
+7
View File
@@ -1019,6 +1019,13 @@ fix this (in fact it was originally done but rolled back).
As well there is a known crash that's also a feature. As well there is a known crash that's also a feature.
## [2000/rince](2000/rince/rince.c) ([README.md](2000/rince/README.md))
## STATUS: INABIAF - please **DO NOT** fix
If `DISPLAY` is not set the program will very likely crash, do something strange
(or if you're very unlucky your computer might [halt and catch
fire](https://en.wikipedia.org/wiki/Halt_and_Catch_Fire_(computing))! :-) ).
# 2001 # 2001