summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>2000-05-03 14:56:20 +0000
committerwollman <wollman@FreeBSD.org>2000-05-03 14:56:20 +0000
commitd504a441ec53b5a5de54f347795e7b32658e47a6 (patch)
tree28a9a68de4236eb8e7386c9a0bec06252b385e4f
parent5087dcbf104d3287287687e3052af8c4ef1da6ea (diff)
downloadFreeBSD-src-d504a441ec53b5a5de54f347795e7b32658e47a6.zip
FreeBSD-src-d504a441ec53b5a5de54f347795e7b32658e47a6.tar.gz
Print files submitted at the same instant in deterministic order.
PR: 18361 Submitted by: Garance A Drosehn <gad@freefour.acs.rpi.edu>
-rw-r--r--usr.sbin/lpr/common_source/common.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c
index ebc7bfd..9a70f80 100644
--- a/usr.sbin/lpr/common_source/common.c
+++ b/usr.sbin/lpr/common_source/common.c
@@ -175,11 +175,26 @@ static int
compar(p1, p2)
const void *p1, *p2;
{
- if ((*(struct queue **)p1)->q_time < (*(struct queue **)p2)->q_time)
- return(-1);
- if ((*(struct queue **)p1)->q_time > (*(struct queue **)p2)->q_time)
- return(1);
- return(0);
+ const struct queue *qe1, *qe2;
+ qe1 = *(const struct queue **)p1;
+ qe2 = *(const struct queue **)p2;
+
+ if (qe1->q_time < qe2->q_time)
+ return (-1);
+ if (qe1->q_time > qe2->q_time)
+ return (1);
+ /*
+ * At this point, the two files have the same last-modification time.
+ * return a result based on filenames, so that 'cfA001some.host' will
+ * come before 'cfA002some.host'. Since the jobid ('001') will wrap
+ * around when it gets to '999', we also assume that '9xx' jobs are
+ * older than '0xx' jobs.
+ */
+ if ((qe1->q_name[3] == '9') && (qe2->q_name[3] == '0'))
+ return (-1);
+ if ((qe1->q_name[3] == '0') && (qe2->q_name[3] == '9'))
+ return (1);
+ return (strcmp(qe1->q_name,qe2->q_name));
}
/* sleep n milliseconds */
OpenPOWER on IntegriCloud