/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <locale.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
static int article(char *);
static int endcomma(char *);
static void error(char *);
static void eval(char []);
static void onintr(void);
/* sortbib: sort bibliographic database in place */
int
{
int i;
#if !defined(TEXT_DOMAIN)
#endif
(void) textdomain(TEXT_DOMAIN);
\t-s: sort by fields in KEYS (default is AD)"));
exit(1);
}
/* if a key is specified use it, otherwise use default key */
}
gettext("sortbib: More than %d databases specified\n"),
MXFILES);
exit(1);
}
}
return (0);
}
/* read records, prepare list for sorting */
static void
{
/* measure byte offset, then get new line */
if (recno == 0) /* accept record w/o initial newline */
newrec = 1;
if (!rsmode)
if (rsmode == 1)
newrec = 1;
}
if (!rsmode)
if (rsmode == 2)
newrec = 1;
}
if (newrec) { /* by whatever means above */
newrec = 0;
gettext("sortbib: record %d longer than %d "
exit(1);
}
if (recno++) { /* info for sorting */
i, lastoffset, length,
}
}
oneauth = 0; /* reset number of authors */
}
}
gettext("sortbib: record %d longer than %d (%d)\n"),
exit(1);
}
}
}
}
/* deliver sorted entries out of database(s) */
static void
{
long int offset;
int i, length;
/* when sorting, ignore case distinctions; tab char is ':' */
error("sortbib");
}
/* get file pointer, record offset, and length */
/* seek to proper disk location in proper file */
error("sortbib");
}
/* read exactly one record from bibliography */
error("sortbib");
}
/* add newline between unseparated records */
putchar('\n');
/* write record buffer to standard output */
error("sortbib");
}
}
}
/* get fields out of line, prepare for sorting */
static void
{
int n, i, j;
for (i = 0; i < 8; i++) /* zap out old strings */
for (i = 0; i < 4; i++) {
break;
else if (oneauth) /* mult auths */
else { /* jr. or ed. */
n--;
}
for (j = 1; j < n-1; j++)
oneauth = 1;
if (n > 2)
j = 1;
j++;
for (; j < n; j++)
} else /* any other field */
for (j = 1; j < n; j++)
}
/* %Q quorporate or queer author - unreversed %A */
for (j = 1; j < n; j++)
}
}
/* see if string contains an article */
static int
{
return (1);
return (1);
return (1);
return (1);
return (1);
return (1);
return (1);
return (1);
return (1);
return (1);
return (0);
}
/* evaluate key string for A+ marking */
static void
{
int i, j;
for (i = 0, j = 0; keystr[i]; i++, j++) {
if (keystr[i] == '+') {
multauth = 1;
i++;
}
break;
}
}
/* exit in case of various system errors */
static void
error(char *s)
{
perror(s);
exit(1);
}
/* remove tempfile in case of interrupt */
static void
onintr(void)
{
exit(1);
}
static int
{
int n;
if (str[n] == ',') {
return (1);
}
return (0);
}