diff --git a/src/rem2ps.c b/src/rem2ps.c index 5eaa69d6..245ff47a 100644 --- a/src/rem2ps.c +++ b/src/rem2ps.c @@ -32,6 +32,17 @@ #define SPECIAL_WEEK 5 #define SPECIAL_SHADE 6 +/* Array holding how specials sort */ +static int SpecialSortOrder[] = { + 0, /* NORMAL */ + 1, /* POSTSCRIPT */ + 1, /* PSFILE */ + 2, /* MOON */ + 0, /* COLOR */ + 4, /* WEEK */ + 5 /* SHADE */ +}; + typedef struct calentry { struct calentry *next; int special; @@ -338,11 +349,11 @@ void DoPsCal(void) d = PsEntries[DayNum]; p = NULL; /* Slot it into the right place */ - while (d->next && (c->special <= d->special)) { + while (d->next && (SpecialSortOrder[c->special] <= SpecialSortOrder[d->special])) { p = d; d = d->next; } - if (c->special <= d->special) { + if (SpecialSortOrder[c->special] <= SpecialSortOrder[d->special]) { c->next = d->next; d->next = c; } else { diff --git a/tests/file.ps b/tests/file.ps new file mode 100644 index 00000000..8cbbb73f --- /dev/null +++ b/tests/file.ps @@ -0,0 +1 @@ +(Second-Bit-Of-PS) diff --git a/tests/file2.ps b/tests/file2.ps new file mode 100644 index 00000000..71a46a62 --- /dev/null +++ b/tests/file2.ps @@ -0,0 +1 @@ +(Fourth-Bit-Of-PS) \ No newline at end of file diff --git a/tests/shade.rem b/tests/shade.rem index 0dd421e1..523600db 100644 --- a/tests/shade.rem +++ b/tests/shade.rem @@ -15,6 +15,11 @@ IF $PSCAL [trigger(moondate(3))] SPECIAL MOON 3 -1 -1 [moontime(3)] ENDIF +REM 4 PS (First-Bit-Of-PS) +REM 4 PSFILE file.ps +REM 4 PS (Third-Bit-Of-PS) +REM 4 PSFILE file2.ps + REM Mon SPECIAL SHADE 255 255 255 REM Tue SPECIAL SHADE 255 255 204 REM Wed SPECIAL SHADE 255 204 255 diff --git a/tests/test.cmp b/tests/test.cmp index 3ab2e98a..d8f6b198 100644 --- a/tests/test.cmp +++ b/tests/test.cmp @@ -2527,7 +2527,10 @@ _A BoxHeight _A sub lineto closepath BoxWidth _A sub _A lineto BoxWidth _A sub BoxHeight _A sub lineto _A BoxHeight _A sub lineto closepath 1 1 0.8 setrgbcolor fill 0.0 setgray - +(First-Bit-Of-PS) +(Second-Bit-Of-PS) +(Third-Bit-Of-PS) +(Fourth-Bit-Of-PS) SAVESTATE restore /SAVESTATE save def 3 xincr mul MinX add ytop translate