code:
@c DO not edit this file.

@set _UNAME ix86-Linux
@set ix86-Linux

repo_name: mthl/texinfo

license: mit


code:
% Id: usercard.tex,v 1.1 2003/08/08 14:27:06 pertusus Exp $

%
% usercard.tex - Singular user quick reference card.
%

\input singcard.tex

\centerline{\hbf SINGULAR Quick Reference}

\centerline{\srm {\ssc Singular} Version 1.2.0}

\bigskip

Do not forget to terminate all commands with a {\tt ;} (semicolon)!

In particular if \Singular\ prints the continuation prompt {\tt .}
(peri\-od) instead of the regular command prompt {\tt >}, then it
waits for a command to be terminated by a {\tt ;}.  If that does
not help, try one or more {\tt "} or {\tt \char`}} to close an
opened string or block.

Comments start with {\tt //} and extend to end of line.

\smallskip
Some of the topics concerning interactive use are system dependent.

\sec Starting SINGULAR(2.5cm)
Singular& 			start \Singular\cr
Singular {\it file} \rep&	read {\it files\/} and prompt for further commands\cr
Singular --help&		print help on command line options and exit\cr
\endsec

\sec Stopping SINGULAR()
quit;&				exit \Singular; also {\tt exit;} or {\tt \$}\cr
\ctl c&				interrupt \Singular\cr
\endsec

\sec Getting help()
help;&				enter online help system\cr
help {\it topic\/};&		describe {\it topic\/}; also {\tt? {\it topic\/};}\cr
\subsec{Inside the online help system:}
\ctl h&				get help on help system\cr
q&				exit from help system\cr
n\rmslash p\rmslash u&		go to next/previous/upper node\cr
m&				pick menu item by name\cr
l&				go to last visited node/exit from help on help\cr
SPC\rmslash DEL&		scroll forward/backward one page\cr
\endsec

\sec Commandline editing()
\sectext
Commandline editing is similar to that of, e.g., {\tt bash} or {\tt tcsh}:\cr
BS\rmslash\ctl d&		remove character on the left/right of cursor\cr
\ctl p\rmslash\ctl n&		get previous/next line from history\cr
\ctl b\rmslash\ctl f&		move cursor left/right\cr
\ctl a\rmslash\ctl e&		go to beginning/end of line\cr
\ctl u\rmslash\ctl k&		delete to beginning/end of line\cr
\endsec

\sec Names and objects()
\sectext
Names (= identifiers) have to be declared before they are used:\cr
\entryskip
\longentry {\it type\/} {\it name\/} \opt{= {\it expression\/}};&
				declare variable {\it name}\cr
kill({\it name\/})&		delete variable {\it name}\cr
\entryskip
\sectext
\parskip=\verysmallskipamount
Names of type {\tt number}, {\tt poly}, {\tt ideal}, {\tt vector}, {\tt
module}, {\tt matrix}, {\tt map}, and {\tt resolution} may be declared
only inside a ring.  They are local to that ring.  The same holds for a {\tt
list} if it contains an object of the above types.  All other types may be
declared at any time.  They are globally visible.

Names may consist of alphanumeric characters including {\tt \_}
(underscore) and have to start with a letter.  Capital and small letters
are distinguished.  Names may be followed by an integer expression in
parentheses, resulting in so-called {\it indexed names}.\cr
\entryskip
{\it name\/}({\it n}..{\it m\/})&
				shortcut for {\tt {\it name\/}({\it
				n\/}), $\ldots$, {\it name\/}({\it
				m\/})}\hfil\break
				(\eg {\tt ring r = 0, x(1..3), dp;})\cr
\_ {\rm (underscore)}&		refers to the value of the last expression
				printed\cr
\endsec

\vfill
\centerline{\srm \copyright 1998 \qquad Permissions on back}

\eject

\sec Ring declaration()
\longentry ring {\it name\/} = {\it basefield}, ({\it ringvars\/}), {\it ordering\/};&
				\hyphenpenalty=50 \tolerance=200 declare ring
				{\it name\/} and make it the new base\-ring.
				{\it ringvars\/} has to be a list of names, the
				other items are described below.  Example:\par
				{\tt ring r = 32003, (x, y, z), dp;}\cr
\longentry qring {\it name\/} = {\it ideal\/};&
				declare quotient ring {\it name\/} of the
				current base\-ring with respect to {\it
				ideal\/}.  {\it ideal\/} has to be a standard
				basis.  Make {\it name\/} the new basering.\cr
\subsec{Available {\bit basefields\/}:}
0&				the rational numbers\cr
\it p&				the finite field $Z_p$ with {\it p\/}
				elements,\par
				$2 \le p \le 32003$ a prime\cr
({\it p\/}\^{}{\it n}, {\it gen\/})&
				the finite field with $p^n$ elements, {\it p\/}
				a prime and\par $4 \le p^n \le 32671$. The name
				{\it gen\/} refers to some generator of the
				cyclic group of unities.\cr
({\it p}, {\it alpha\/})&	algebraic extension of $Q$ or $Z_p$ ($p =
				0$ or as above) by {\it alpha}.  The minpoly
				$\mu_{\hbox{\tit alpha}}$ for {\it alpha\/} has
				to be specified with an assignment to {\tt
				minpoly} (\eg {\tt minpoly=a\^{}2+1;}, for
				$\hbox{\it alpha}=\hbox{\tt a}$).  {\it
				alpha\/} has to be a name.\cr
({\it p}, $t_1$, $\ldots$)&	transcendental extension of $Q$ or $Z_p$
				($p = 0$ or as above) by~$t_i$.  The $t_i$ have
				to be names.\cr
real&				the real numbers represented by floating point
				numbers\cr
\endsec

\sec Term orderings()
\sectext
An {\it ordering\/} as referred to in the ring declaration may either be
a global, local, or matrix ordering or a list of these resulting in a
pro\-duct ordering.  The list may include extra weight vectors and may be
preceded or followed by a module ordering specification.\cr
\subsec{Global orderings}
lp&				lexicographical ordering\cr
dp&				degree reverse lexicographical ordering\cr
Dp&				degree lexicographical ordering\cr
wp($w_1$, $\ldots$)&		weighted reverse lexicographical ordering\cr
Wp($w_1$, $\ldots$)&		weighted lexicographical ordering\cr
&				The $w_i$ have to be positive integers.\cr
\subsec{Local orderings}
ls&				negative lexicographical ordering\cr
ds&				negative degree reverse lexicographical ordering\cr
Ds&				negative degree lexicographical ordering\cr
ws($w_1$, $\ldots$)&		general weighted reverse lexicographical ordering\cr
Ws($w_1$, $\ldots$)&		general weighted lexicographical ordering\cr
&				$w_1$ has to be a non-zero integer, every other
				$w_i$ may be any integer\cr
\subsec{Matrix orderings}
\longentry M($m_{11}$, $m_{12}$, $\ldots$, $m_{nn}$)&
				{\it m\/} has to be an invertible matrix with
				integer coeffi\-cients.  Coefficients have to be
				specified row-wise.\cr
\subsec{Product orderings}
\longentry($o_1$\opt{($k_1$)}, $o_2$\opt{($k_2$)}, $\ldots$, $o_n$\opt{($k_n$)})&
				the $o_i$ have to be any of the above orderings.
				{\tt lp}, {\tt dp}, {\tt Dp}, {\tt ls}, {\tt
				ds}, {\tt Ds} may be followed by an integer
				expression $k_i$ in parentheses specifying the
				number of variables $o_i$ refers to (\eg {\tt
				(lp(3), dp(2))}).\cr
\subsec{Extra weight vector}
a($w_1$, $\ldots$)&		any of the above degree orderings may be
				preceded by an extra weight vector\cr
\noalign{\eject}
\subsec{Module orderings}
({\it c}, $o_1$, $\ldots$)&	sort by components first\cr
($o_1$, $\ldots$, {\it c\/})&	sort by variables first\cr
&				$o_i$ may be any of the above orderings or an
				extra weight vector, {\it c\/} may be one of
				{\tt C} or {\tt c}:\cr
C&				sort generators in ascending order (\ie {\tt
				gen({\it i\/})} $<$ {\tt gen({\it j\/})} iff $i <
				j$)\cr
c&				sort generators in descending order\cr
\endsec

\sec Data types(1.5cm)
\sectext
Examples of ring-independent types:\cr
\entryskip
\longitem
int i1 = 101; int i2 = 13 div 3;\cr
\entryskip
\longitem
intvec iv = 13 div 3, -4, i1;\cr
\entryskip
\longentry
intmat im[2][2] = 13 div 3, -4, i1;&
				a $2\times 2$ matrix.  Entries are filled
				row-wise, missing entries are set to zero, extra
				entries are ignored.  vector/matrix elements are
				accessed using the {\tt[$\ldots$]} operator,
				where the first element has index one (\eg {\tt
				iv[3]; im[1, 2];}).\cr
\entryskip
\longitem
string s1 = "a quote \char"5C " and a backslash \char"5C \char"5C";\par
string s2 = "con" + "catenation";\cr
\entryskip
\sectext
Basering in the following is {\tt ring r = 0, (x, y, z, mu, nu), dp;}\cr
\entryskip
\longitem
number n = 5/3;\cr
\entryskip
\longentry
poly p(1) = 3/4x3yz4+2xy2;\par
poly p(2) = (5/3)*mu\^{}2*nu\^{}3+n*yz2;&
				{\tt p(1)} equals $3/4x^3yz^4+2xy^2$.  Short
				format of mono\-mials is valid for one-character
				ring variables only.\cr
\entryskip
\longentry
ideal i = p(1..2), x+y;&	note the use of indexed names\cr
\entryskip
\longentry
vector v = [p(1), p(2), x+y];\par
vector w = 2*p(1)*gen(6)+n*nu*gen(1);&
				vectors may be written in brackets ({\tt
				[$\ldots$]}) or expressed as linear
				combinations of the canonical generators {\tt
				gen({\it i\/})}\cr
\entryskip
\longitem
module mo = v, w, x+y*gen(1);\cr
\entryskip
\longitem
resolution r = sres(std(mo), 0);\cr
\entryskip
\longentry
matrix ma[2][2] = 5/3, p(1), 101;&
				the rules for declaring, filling, and accessing
				integer matrices apply to types {\tt matrix}
				and {\tt vector}, too\cr
\entryskip
\longentry
list l = iv, v, p(1..2), mo;&
				lists may collect objects of any type.  They are
				ring-dependent iff one of the entries is.\cr
\entryskip
\longentry
def d = read("MPfile:r example.mp");&
				a name of type {\tt def} inherits the type of
				the object assigned first to it.  Useful if the
				actual type of an object is unknown.\cr
\endsec

\sec Monitoring and debugging tools()
timer = 1;&			print time used for commands to execute\cr
\longentry int t = timer; {\it command\/}; \rep; timer-t;&
				print time used for {\it commands\/} to execute\cr
memory(1);&			print number of bytes allocated from system\cr
option(prot);&			show algorithm protocol\cr
option(mem);&			show algorithm memory usage\cr
\entryskip
TRACE = 1;&			print protocol on execution of procedures\cr
listvar(all);&			list all (user-)defined names\cr
\longentry listvar({\it ringname\/});&
				list all names belonging to {\it ringname}\cr
\endsec

\eject

\sec Options()
option();&			show current option settings\cr
\longentry option($option_1$, no$option_2$, $\ldots$);&
				switch $option_1$ on and $option_2$ off, resp.\cr
option(none);&			reset all options to default values\cr
\sectext
Type {\tt help option;} for a list of all options.\cr
\subsec{Monitoring}
debugLib&			show loading of procedures from libraries\cr
mem&				show algorithm memory usage\cr
prot&				show algorithm protocol\cr
\subsec{Standard bases}
fastHC&				try to find highest corner as fast as possible\cr
intStrategy&			avoid divisions\cr
morePairs&			create additional pairs\cr
notSugar&			disable sugar strategy\cr
redSB&				compute reduced standard bases\cr
redTail&			reduce tails\cr
sugarCrit&			use sugar criteria\cr
weightM&			automatically compute weights\cr
\subsec{Resolutions}
minRes&				do additional minimizing\cr
notRegularity&			disable regularity bound\cr
\subsec{Miscellany}
returnSB&			let some functions return standard bases\cr
\endsec

\sec System variables()
\sectext
Type {\tt help System variables;} for a list of all system variables.\cr
\subsec{Standard bases}
degBound&			stop if (weighted) total degree exceeds {\tt
				degBound}\cr
multBound&			stop if multiplicity gets smaller than {\tt
				multBound}\cr
noether&			cut off all monomials above monomial {\tt
				noether}\cr
\subsec{Miscellany}
basering&			current basering\cr
minpoly&			minimal polynomial for algebraic extensions\cr
short&				do not print monomials in short format if zero\cr
timer&				on assignment of a non-zero value show time
				used for execution of executed commands.  On
				evaluation, return system time in seconds used
				by \Singular\ since start\cr
TRACE&				print information on procedures being executed
				if larger than one\cr
\endsec

\sec Input and output()
< "{\it filename\/}";&		load and execute {\it filename\/}\cr
\longentry write("{\it filename\/}", {\it expression}, \rep)&
				write {\it expressions\/} to ASCII file {\it
				filename}\cr
\longentry read("{\it filename\/}");&
				read ASCII file {\it filename\/} and return
				content as a string.  See also example below.\cr
\longentry
dump("MPfile: {\it filename\/}");\par
getdump("MPfile: {\it filename\/}");&
				dump current state of {\sc Singular} to {\it
				filename} and retrieve it, resp.\cr
\entryskip
\sectext
An example how to write one single expression (in this case the
ideal {\tt i}) to a file and read it back from there:

{\tt
write("i.save", i);\par
execute("ideal i=" + read("i.save") + ";");
}\cr
\endsec

\eject

\sec Libraries()
LIB "{\it library\/}";&		load {\it library}\cr
help {\it library\/};&		show help on {\it library}\cr
help all.lib;&			show list of all libraries\cr
\endsec

\sec Mapping(1.5cm)
\longentry map {\it name\/} = {\it ringname}, {\it ideal\/};&
				declare a map {\it name\/} from {\it ringname\/}
				to current basering.  The $i$-th ring variable
				from {\it ringname\/} is mapped to the $i$-th
				generator of {\it ideal}.\cr
\longentry {\it mapname\/}({\it expression\/})&
				apply map {\it mapname\/} to {\it expression}\cr
\entryskip
\sectext
Coefficients between rings with different basefields are mapped in the following
way (non-canonical maps only):\strut
\abovedisplayskip=0pt
\belowdisplayskip=0pt
$$
\eqalign{Z_p \rightarrow Q&  :[i]_p \mapsto i \in [-p/2,p/2] \subset Z\cr
	 Z_p \rightarrow Z_q&:[i]_p \mapsto i \in [-p/2,p/2] \subset Z, i \mapsto [i]_q}
$$
\cr
\noalign{\vskip -9pt} % dirty trick, gobbles the trailing \strut from \sectext
\entryskip
\longentry fetch({\it ringname}, {\it name\/})&
				map from ring {\it ringname\/} to current
				base\-ring.  The rings have to be identical up
				to names of ring variables\cr
\longentry imap({\it ringname}, {\it name\/})&
				map from subring {\it ringname\/} to current
				basering\cr
\longentry subst({\it expression}, {\it ringvar}, {\it monomial\/})&
				substitute {\it ringvar\/} by {\it monomial\/}
				in {\it expression}\cr
\endsec

\sec Miscellany(1.5cm)
\longentry setring({\it ringname\/})&
				make {\it ringname\/} the current basering\cr
\subsec{Data on polynomials}
\longentry ord({\it poly\/\alt vector\/})&
				return (weighted) degree of initial term\cr
\longentry deg({\it poly\/\alt vector\/})&
				return maximal (weighted) degree\cr
\longentry
size({\it ideal\/\alt module\/})\par
size({\it poly\/\alt vector\/})\par
size({\it string\/\alt intvec\/\alt list\/})&
				return (1) number of non-zero generators;
				(2) number of monomials; (3) length\cr
\longentry lead({\it expression\/})&
				return initial term(s)\cr
\subsec{Operations on polynomials}
\longentry gcd({\it $\hbox{poly}_1$}, {\it $\hbox{poly}_2$\/})&
				return greatest common divisor\cr
\longentry factorize({\it poly\/}\opt{, {\it int\/}})&
				return irreducible factors.  Return constant
				factor and multiplicities in dependency on {\it
				int}.\cr
\endsec

\sec Differentiation and jets(1.5cm)
\longentry
diff({\it expression}, {\it ringvar\/})\par
diff({\it $\hbox{ideal}_1$}, {\it $\hbox{ideal}_2$\/})&
				(1) return partial derivation by {\it
				ringvar\/}; (2) differentiate each elt.\ of {\it
				$\hbox{ideal}_2$\/} by the differential
				operators corres\-pon\-ding to the elements of {\it
				$\hbox{ideal}_1$}\cr
\longentry jacob({\it poly\/\alt ideal\/})&
				return jacobi ideal or matrix, resp.\cr
\longentry jet({\it expression}, {\it int\/}\opt{, {\it intvec\/}})&
				return {\it int\/}-jet of {\it expression}.
				Return weighted {\it int\/}-jet if {\it
				intvec\/} is specifified.\cr
\endsec

\eject

\sec Standard bases(1.5cm)
\longentry groebner({\it ideal\/\alt module\/}\opt{, {\it int\/}})&
				compute a standard basis (SB) of {\it ideal\/}
				resp.\ {\it module\/} using a heuristically
				chosen method.  Delimit com\-pu\-tation time to
				{\it int\/} seconds.\cr
\longentry std({\it ideal\/\alt module\/}\opt{, {\it intvec\/}})&
				compute a SB.  Use first Hilbert series {\it
				intvec\/} (result from {\tt hilb($\ldots$, 1)})
				for Hilbert-driven computation.\cr
\longentry stdfglm({\it ideal\/}\opt{, {\it string\/}})&
				use FGLM algorithm to compute a SB from a SB
				w.r.t.\ the ``simpler'' ordering {\it string\/}
				(de\-faults to {\tt dp})\cr
\longentry stdhilb({\it ideal\/}\opt{, {\it intvec\/}})&
				use Hilbert-driven algorithm to compute a SB.
				If Hil\-bert series {\it intvec\/} is not
				specified compute it first.\cr
\longentry fglm({\it ringname}, {\it idealname\/})&
				use FGLM algorithm to transform SB {\it
				idealname\/} from ring {\it ringname\/} to a SB
				w.r.t.\ the ordering of the current basering\cr
\longentry reduce({\it expression}, {\it ideal\/\alt module\/}\opt{, {\it int\/}})&
				reduce {\it expression\/} w.r.t.\ second
				argument which should be a SB.  Use lazy
				reduction if {\it int\/} equals one.\cr
\endsec

\sec Computation of invariants(1.5cm)
\sectext
Most of the results are meaningful only if the input ideal or module is
represented by a standard basis.\cr
\longentry degree({\it ideal\/\alt module\/})&
				display (Krull) dimension, codimension and
				multiplicity\cr
\longentry dim({\it ideal\/\alt module\/})&
				return (Krull) dimension\cr
\longentry hilb({\it ideal\/\alt module\/}\opt{, {\it int\/}})&
				display first and second Hilbert series with one
				argument.  Return {\it int}-th Hilber series
				otherwise (${\it \hbox{int}} = 1,2$).\cr
\longentry mult({\it ideal\/\alt module\/})&
				return multiplicity\cr
\longentry vdim({\it ideal\/\alt module\/})&
				return vector space dimension of current
				basering modulo {\it ideal\/} or {\it module},
				resp.\cr
\endsec

\sec Resolutions(1.5cm)
\sectext
An integer argument {\it length\/} in the following descriptions specifies the
length of the resolution to compute.  If {\it length\/} equals zero, the whole
resolution is computed.\cr
\longentry res({\it ideal\/\alt module}, {\it length\/}\opt{, {\it int\/}})&
				compute a free resolution (FR) of {\it ideal\/}
				resp.\ {\it module\/} using a heuristically
				chosen method.  Compute a minimal resolution if
				a third argument is given.\cr
\longentry mres({\it ideal\/\alt module}, {\it length\/})&
				compute a minimal FR using the standard basis
				method\cr
\longentry lres({\it ideal\/\alt module}, {\it length\/})&
				compute a FR using LaSacala's method\cr
\longentry sres({\it ideal\/\alt module}, {\it length\/})&
				compute a FR using Schreyer's method\cr
\longentry syz({\it ideal\/\alt module\/})&
				compute the first syzygy\cr
\longentry minres({\it resolution\/\alt list\/})&
				minimize a free resolution\cr
\longentry betty({\it resolution\/\alt list\/})&
				compute the graded Betti numbers of a module
				represented by a resolution\cr
\endsec

\bye


code:
@c DO not edit this file.

@set VERSION 2-0-4
@set VERSION_DATE October 2002
@set SHORT_VERSION 2-0
@set RPM_VERSION 2.0.4


code:
# -*-perl-*-
######################################################################
#
# File: t2h_singular.init init file for singular t2h
#

# we only redefine things which ar of relevance to singular
# all the others we simply "include"

# -prefix
# Set the output file prefix, prepended to all .html, .png and .pl files.
set_from_init_file('PREFIX', 'sing');

# -expand
# if set to "tex" (or, "info") expand @iftex and @tex (or, @ifinfo) sections
# else, neither expand @iftex, @tex, nor @ifinfo sections
@EXPAND = ('html', 'tex');

# if set, creates one html file per node
set_from_init_file('SPLIT', 'node');

#if set cross-references are given without section numbers
set_from_init_file('SHORT_REF', 1);

# if set, chatter about what we are doing
set_from_init_file('VERBOSE', 1);

# print index summary for 'cp' index
set_from_init_file('IDX_SUMMARY', 'cp');

my $T2H_SING_base_images = '../singular_images/';

# inside
set_from_init_file('BODYTEXT','lang="en"  background="'.${T2H_SING_base_images}.'Mybg.png"');

# after
$AFTER_BODY_OPEN = <<EOT;
EOT

# before
$PRE_BODY_CLOSE = <<EOT;
EOT

# if using tex4ht, must be in latex mode due to \textbf
$Texi2HTML::TeX4HT::STYLE='latex';

# title is already in the manual
#$print_title = \&T2H_DEFAULT_print_title;
set_from_init_file('SHOW_TITLE', 0);

# footer of top_page

$print_Top_footer = \&T2H_SING_print_Top_footer;
$print_page_foot = \&T2H_SING_print_page_foot;

sub T2H_SING_print_Top_footer
{
#  my $fh = shift;
#  my $buttons = shift;
#  my $nwords = shift;
#  print  $fh "
\n" .
#    &$anchor('', $Texi2HTML::HREF{Contents}, "Table of Contents") .
#      "\n
\n" .
#	&$anchor('', $Texi2HTML::HREF{About}, "About this document") .
#	  "
";
#
#  &$print_foot_navigation($fh);
#  print $fh "$SMALL_RULE\n";
#  if ($SPLIT)
#  {
#     &$print_navigation($fh, $buttons);
#     &$print_page_foot($fh);
#  }
    my $fh = shift;
    #my $buttons = shift;
    #my $nwords = shift;
    my $end_page = shift;
    my $buttons = \@TOP_BUTTONS;
    print  $fh "
\n" .
      &$anchor('', $Texi2HTML::HREF{Contents}, "Table of Contents") .
        "\n
\n" .
	  &$anchor('', $Texi2HTML::HREF{About}, "About this document") .
	    "
";

    &$print_foot_navigation($fh);
    print $fh "$DEFAULT_RULE\n";
    #if ($SPLIT)
    if ($end_page)
    {
        print $fh "".&$print_navigation($buttons);
        &$print_page_foot($fh);
    }
}

# footer of page
sub T2H_SING_print_page_foot
{
  my $fh = shift;
  print $fh <<EOT;

            User manual for Singular version $main::value{VERSION}, $main::value{VERSION_DATE},
generated by $Texi2HTML::THISDOC{'program_and_version'}.

$PRE_BODY_CLOSE

EOT
}

sub singular_banner
{
  my $result = '';
  $result .= <<EOT;

EOT
#  print $fh $result if (defined($fh));
  return $result;
}

# always use bottom navigation
set_default('WORDS_IN_PAGE', 0);

set_from_init_file('VERTICAL_HEAD_NAVIGATION', 1);
@SECTION_BUTTONS =
  (
   \&singular_banner,
   'Back', 'Forward',   'FastBack', 'FastForward',
   'Up', 'Top', 'Contents', 'Index', 'About'
  );

@NODE_FOOTER_BUTTONS = @SECTION_BUTTONS;

# buttons for misc stuff
@MISC_BUTTONS = (\&singular_banner, 'Top', 'Contents', 'Index', 'About');
@TOP_BUTTONS = (\&singular_banner, 'Top', 'Contents', 'Index', 'About');

set_from_init_file('ICONS', 1);

if ($T2H_BLUE_BUTTONS)
{

%ACTIVE_ICONS =
  (
   'Top',      'blue_top.png',
   'Contents', 'blue_dir.png',
   'Overview', '',
   'Index',    'blue_readme.png',
   'Back',     'blue_prev.png',
   'FastBack', 'blue_pprev.png',
   'Prev',     'blue_pprev.png',
   'Up',       'blue_up.png',
   'Next',     'blue_nnext.png',
   'Forward',  'blue_next.png',
   'FastForward', 'blue_nnext.png',
   'About' ,    'blue_help.png',
   ' ',        ''
  );

%PASSIVE_ICONS =
  (
   'Top',      'blue_top.png',
   'Contents', 'blue_dir.png',
   'Overview', '',
   'Index',    'blue_readme.png',
   'Back',     'blue_prev.png',
   'FastBack', 'blue_pprev.png',
   'Prev',     'blue_pprev.png',
   'Up',       'blue_up.png',
   'Next',     'blue_nnext.png',
   'Forward',  'blue_next.png',
   'FastForward', 'blue_nnext.png',
   'About' ,    'blue_help.png',
  );
}
else
{
%ACTIVE_ICONS =
  (
   'Top',      'a_top.png',
   'Contents', 'a_tableofcon.png',
   'Overview', '',
   'Index',    'a_index.png',
   'Back',     'a_left.png',
   'FastBack', 'a_leftdouble.png',
   'Prev',     'a_leftdouble.png',
   'Up',       'a_up.png',
   'Next',     'a_rightdouble.png',
   'Forward',  'a_right.png',
   'FastForward', 'a_rightdouble.png',
   'About' ,    'a_help.png',
   ' ',        'a_empty.png'
  );

%PASSIVE_ICONS =
  (
   'Top',      'a_top_na.png',
   'Contents', 'a_tableofcon_na.png',
   'Overview', '',
   'Index',    'a_index_na.png',
   'Back',     'a_left_na.png',
   'FastBack', 'a_leftdouble_na.png',
   'Prev',     'a_leftdouble_na.png',
   'Up',       'a_up_na.png',
   'Next',     'a_rightdouble_na.png',
   'Forward',  'a_right_na.png',
   'FastForward', 'a_rightdouble_na.png',
   'About' ,    'a_help_na.png',
  );
}

foreach my $hash_ref((\%ACTIVE_ICONS, \%PASSIVE_ICONS))
{
	foreach my $key (keys(%$hash_ref))
	{
		next if ($hash_ref->{$key} eq '');
		$hash_ref->{$key} = $T2H_SING_base_images.$hash_ref->{$key};
	}
}

sub T2H_SING_pre_about
{
  return <<EOT;
This document is the user manual for Singular version $main::value{VERSION}, $main::value{VERSION_DATE}.

For questions and comments about Singular, send email to singular\@mathematik.uni-kl.de.

This document was generated by $Texi2HTML::THISDOC{'program_and_version'}
and LaTeX2<tt>HTML</tt>
and is best  viewed with a 16 or 18 point screen font.

EOT
}

$PRE_ABOUT = \&T2H_SING_pre_about;

# a whole menu
$menu = \&t2h_sing_menu;

sub t2h_sing_menu($)
{
    my $text = shift;

    if ($text =~ /\S/)
    {
        return "

\n" . $text. "

\n";
    }
    return '';
}

1; 	# This must be the last line


code:
EXTRA_DIST = \
 config.texi freemanuals.texi  header.texi snapshot.texi value.texi \
dumpdir.texi  genfile.texi      intern.texi     sparse.texi    version.texi \
fdl.texi      getdate.texi      rendition.texi  tar.texi \
 tests.txt res res_info res_all

DISTCLEANFILES = tests.log tests.out

distclean-local:
	rm -rf out out_all out_info diffs

dist-hook:
	rm -rf `find $(distdir)/res $(distdir)/res_info $(distdir)/res_all -name .svn`


code: @set top_srcdir /home/gray/gnu/tar


code:
@c This is part of the paxutils manual.
@c Copyright (C) 2006 Free Software Foundation, Inc.
@c Written by Sergey Poznyakoff
@c This file is distributed under GFDL 1.1 or any later version
@c published by the Free Software Foundation.

  Incremental archives keep information about contents of each
dumped directory in special data blocks called @dfn{dumpdirs}.

  Dumpdir is a sequence of entries of the following form:

@smallexample
@var{C} @var{filename} \0
@end smallexample

@noindent
where @var{C} is one of the @dfn{control codes} described below,
@var{filename} is the name of the file @var{C} operates upon, and
@samp{\0} represents a nul character (ASCII 0).  The white space
characters were added for readability, real dumpdirs do not contain
them.

  Each dumpdir ends with a single nul character.

  The following table describes control codes and their meanings:

@table @samp
@item Y
@var{filename} is contained in the archive.

@item N
@var{filename} was present in the directory at the time the archive
was made, yet it was not dumped to the archive, because it had not
changed since the last backup.

@item D
@var{filename} is a directory.

@item R
This code requests renaming of the @var{filename} to the name
specified with the following @samp{T} command.

@item T
Specify target file name for @samp{R} command (see below).

@item X
Specify @dfn{temporary directory} name for a rename operation (see below).
@end table

  Codes @samp{Y}, @samp{N} and @samp{D} require @var{filename} argument
to be a relative file name to the directory this dumpdir describes,
whereas codes @samp{R}, @samp{T} and @samp{X} require their argument
to be an absolute file name.

 The three codes @samp{R}, @samp{T} and @samp{X} specify a
@dfn{renaming operation}.  In the simplest case it is:

@smallexample
R@file{source}\0T@file{dest}\0
@end smallexample

@noindent
which means ``rename file @file{source} to file @file{dest}''.

  However, there are cases that require using a @dfn{temporary
directory}.  For example, consider the following scenario:

@enumerate 1
@item
Previous run dumped a directory @file{foo} which contained the
following three directories:

@smallexample
a
b
c
@end smallexample

@item
They were renamed @emph{cyclically}, so that:

@example
@file{a} became @file{b}
@file{b} became @file{c}
@file{c} became @file{a}
@end example

@item
New incremental dump was made.
@end enumerate

  This case cannot be handled by three successive renames, since
renaming @file{a} to @file{b} will destroy existing directory.
To handle such case a temporary directory is required. @GNUTAR{}
will create the following dumpdir (newlines have been added for
readability):

@smallexample
@group
Xfoo\0
Rfoo/a\0T\0
Rfoo/b\0Tfoo/c\0
Rfoo/c\0Tfoo/a\0
R\0Tfoo/a\0
@end group
@end smallexample

  The first command, @samp{Xfoo\0}, instructs the extractor to create a
temporary directory in the directory @file{foo}.  Second command,
@samp{Rfoo/aT\0}, says ``rename file @file{foo/a} to the temporary
directory that has just been created'' (empty file name after a
command means use temporary directory).  Third and fourth commands
work as usual, and, finally, the last command, @samp{R\0Tfoo/a\0}
tells tar to rename the temporary directory to @file{foo/a}.

  The exact placement of a dumpdir in the archive depends on the
archive format (@pxref{Formats}):

@itemize
@item PAX archives

In PAX archives, dumpdir is stored in the extended header of the
corresponding directory, in variable @code{GNU.dumpdir}.

@item GNU and old GNU archives

These formats implement special header type @samp{D}, which is similar
to ustar header @samp{5} (directory), except that it preceeds a data
block containing the dumpdir.
@end itemize

@c End of dumpdir.texi


code:
@node GNU Free Documentation License
@appendixsec GNU Free Documentation License

@cindex FDL, GNU Free Documentation License
@center Version 1.2, November 2002

@display
Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@end display

@enumerate 0
@item
PREAMBLE

The purpose of this License is to make a manual, textbook, or other
functional and useful document @dfn{free} in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.

This License is a kind of ``copyleft'', which means that derivative
works of the document must themselves be free in the same sense.  It
complements the GNU General Public License, which is a copyleft
license designed for free software.

We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does.  But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book.  We recommend this License
principally for works whose purpose is instruction or reference.

@item
APPLICABILITY AND DEFINITIONS

This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License.  Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein.  The ``Document'', below,
refers to any such manual or work.  Any member of the public is a
licensee, and is addressed as ``you''.  You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.

A ``Modified Version'' of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.

A ``Secondary Section'' is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject.  (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.)  The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.

The ``Invariant Sections'' are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License.  If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant.  The Document may contain zero
Invariant Sections.  If the Document does not identify any Invariant
Sections then there are none.

The ``Cover Texts'' are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License.  A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.

A ``Transparent'' copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters.  A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text.  A copy that is not ``Transparent'' is called ``Opaque''.

Examples of suitable formats for Transparent copies include plain
@sc{ascii} without markup, Texinfo input format, La@TeX{} input
format, @acronym{SGML} or @acronym{XML} using a publicly available
@acronym{DTD}, and standard-conforming simple @acronym{HTML},
PostScript or @acronym{PDF} designed for human modification.  Examples
of transparent image formats include @acronym{PNG}, @acronym{XCF} and
@acronym{JPG}.  Opaque formats include proprietary formats that can be
read and edited only by proprietary word processors, @acronym{SGML} or
@acronym{XML} for which the @acronym{DTD} and/or processing tools are
not generally available, and the machine-generated @acronym{HTML},
PostScript or @acronym{PDF} produced by some word processors for
output purposes only.

The ``Title Page'' means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page.  For works in
formats which do not have any title page as such, ``Title Page'' means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.

A section ``Entitled XYZ'' means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language.  (Here XYZ stands for a
specific section name mentioned below, such as ``Acknowledgements'',
``Dedications'', ``Endorsements'', or ``History''.)  To ``Preserve the Title''
of such a section when you modify the Document means that it remains a
section ``Entitled XYZ'' according to this definition.

The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document.  These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.

@item
VERBATIM COPYING

You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License.  You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute.  However, you may accept
compensation in exchange for copies.  If you distribute a large enough
number of copies you must also follow the conditions in section 3.

You may also lend copies, under the same conditions stated above, and
you may publicly display copies.

@item
COPYING IN QUANTITY

If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover.  Both covers must also clearly and legibly identify
you as the publisher of these copies.  The front cover must present
the full title with all words of the title equally prominent and
visible.  You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.

If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.

If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.

It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.

@item
MODIFICATIONS

You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it.  In addition, you must do these things in the Modified Version:

@enumerate A
@item
Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document).  You may use the same title as a previous version
if the original publisher of that version gives permission.

@item
List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.

@item
State on the Title page the name of the publisher of the
Modified Version, as the publisher.

@item
Preserve all the copyright notices of the Document.

@item
Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.

@item
Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.

@item
Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.

@item
Include an unaltered copy of this License.

@item
Preserve the section Entitled ``History'', Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page.  If
there is no section Entitled ``History'' in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.

@item
Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on.  These may be placed in the ``History'' section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.

@item
For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
the Title of the section, and preserve in the section all the
substance and tone of each of the contributor acknowledgements and/or
dedications given therein.

@item
Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles.  Section numbers
or the equivalent are not considered part of the section titles.

@item
Delete any section Entitled ``Endorsements''.  Such a section
may not be included in the Modified Version.

@item
Do not retitle any existing section to be Entitled ``Endorsements'' or
to conflict in title with any Invariant Section.

@item
Preserve any Warranty Disclaimers.
@end enumerate

If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant.  To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.

You may add a section Entitled ``Endorsements'', provided it contains
nothing but endorsements of your Modified Version by various
parties---for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.

You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version.  Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity.  If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.

The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.

@item
COMBINING DOCUMENTS

You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.

The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy.  If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.

In the combination, you must combine any sections Entitled ``History''
in the various original documents, forming one section Entitled
``History''; likewise combine any sections Entitled ``Acknowledgements'',
and any sections Entitled ``Dedications''.  You must delete all
sections Entitled ``Endorsements.''

@item
COLLECTIONS OF DOCUMENTS

You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.

You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.

@item
AGGREGATION WITH INDEPENDENT WORKS

A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an ``aggregate'' if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.

If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.

@item
TRANSLATION

Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections.  You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers.  In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.

If a section in the Document is Entitled ``Acknowledgements'',
``Dedications'', or ``History'', the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.

@item
TERMINATION

You may not copy, modify, sublicense, or distribute the Document except
as expressly provided for under this License.  Any other attempt to
copy, modify, sublicense or distribute the Document is void, and will
automatically terminate your rights under this License.  However,
parties who have received copies, or rights, from you under this
License will not have their licenses terminated so long as such
parties remain in full compliance.

@item
FUTURE REVISIONS OF THIS LICENSE

The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time.  Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.  See
@uref{http://www.gnu.org/copyleft/}.

Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License ``or any later version'' applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation.  If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.
@end enumerate

@page
@appendixsubsec ADDENDUM: How to use this License for your documents

To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:

@smallexample
@group
  Copyright (C)  @var{year}  @var{your name}.
  Permission is granted to copy, distribute and/or modify this document
  under the terms of the GNU Free Documentation License, Version 1.2
  or any later version published by the Free Software Foundation;
  with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
  Texts.  A copy of the license is included in the section entitled ``GNU
  Free Documentation License''.
@end group
@end smallexample

If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the ``with...Texts.'' line with this:

@smallexample
@group
    with the Invariant Sections being @var{list their titles}, with
    the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
    being @var{list}.
@end group
@end smallexample

If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.

If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.

@c Local Variables:
@c ispell-local-pdict: "ispell-dict"
@c End:


code:
@cindex free documentation

The biggest deficiency in the free software community today is not in
the software---it is the lack of good free documentation that we can
include with the free software.  Many of our most important
programs do not come with free reference manuals and free introductory
texts.  Documentation is an essential part of any software package;
when an important free software package does not come with a free
manual and a free tutorial, that is a major gap.  We have many such
gaps today.

Consider Perl, for instance.  The tutorial manuals that people
normally use are non-free.  How did this come about?  Because the
authors of those manuals published them with restrictive terms---no
copying, no modification, source files not available---which exclude
them from the free software world.

That wasn't the first time this sort of thing happened, and it was far
from the last.  Many times we have heard a GNU user eagerly describe a
manual that he is writing, his intended contribution to the community,
only to learn that he had ruined everything by signing a publication
contract to make it non-free.

Free documentation, like free software, is a matter of freedom, not
price.  The problem with the non-free manual is not that publishers
charge a price for printed copies---that in itself is fine.  (The Free
Software Foundation sells printed copies of manuals, too.)  The
problem is the restrictions on the use of the manual.  Free manuals
are available in source code form, and give you permission to copy and
modify.  Non-free manuals do not allow this.

The criteria of freedom for a free manual are roughly the same as for
free software.  Redistribution (including the normal kinds of
commercial redistribution) must be permitted, so that the manual can
accompany every copy of the program, both on-line and on paper.

Permission for modification of the technical content is crucial too.
When people modify the software, adding or changing features, if they
are conscientious they will change the manual too---so they can
provide accurate and clear documentation for the modified program.  A
manual that leaves you no choice but to write a new manual to document
a changed version of the program is not really available to our
community.

Some kinds of limits on the way modification is handled are
acceptable.  For example, requirements to preserve the original
author's copyright notice, the distribution terms, or the list of
authors, are ok.  It is also no problem to require modified versions
to include notice that they were modified.  Even entire sections that
may not be deleted or changed are acceptable, as long as they deal
with nontechnical topics (like this one).  These kinds of restrictions
are acceptable because they don't obstruct the community's normal use
of the manual.

However, it must be possible to modify all the @emph{technical}
content of the manual, and then distribute the result in all the usual
media, through all the usual channels.  Otherwise, the restrictions
obstruct the use of the manual, it is not free, and we need another
manual to replace it.

Please spread the word about this issue.  Our community continues to
lose manuals to proprietary publishing.  If we spread the word that
free software needs free reference manuals and free tutorials, perhaps
the next person who wants to contribute by writing documentation will
realize, before it is too late, that only free manuals contribute to
the free software community.

If you are writing documentation, please insist on publishing it under
the GNU Free Documentation License or another free documentation
license.  Remember that this decision requires your approval---you
don't have to let the publisher decide.  Some commercial publishers
will use a free license if you insist, but they will not propose the
option; it is up to you to raise the issue and say firmly that this is
what you want.  If the publisher you are dealing with refuses, please
try other publishers.  If you're not sure whether a proposed license
is free, write to @email{licensing@@gnu.org}.

You can encourage commercial publishers to sell more free, copylefted
manuals and tutorials by buying them, and particularly by buying
copies from the publishers that paid for their writing or for major
improvements.  Meanwhile, try to avoid buying non-free documentation
at all.  Check the distribution terms of a manual before you buy it,
and insist that whoever seeks your business must respect your freedom.
Check the history of the book, and try reward the publishers that have
paid or pay the authors to work on it.

The Free Software Foundation maintains a list of free documentation
published by other publishers, at
@url{http://www.fsf.org/doc/other-free-books.html}.


code:
@c This is part of the paxutils manual.
@c Copyright (C) 2005, 2006 Free Software Foundation, Inc.
@c Written by Sergey Poznyakoff
@c This file is distributed under GFDL 1.1 or any later version
@c published by the Free Software Foundation.

@cindex genfile
    This appendix describes @command{genfile}, an auxiliary program
used in the GNU tar testsuite. If you are not interested in developing
GNU tar, skip this appendix.

    Initially, @command{genfile} was used to generate data files for
the testsuite, hence its name. However, new operation modes were being
implemented as the testsuite grew more sophisticated, and now
@command{genfile} is a multi-purpose instrument.

    There are three basic operation modes:

@table @asis
@item File Generation
    This is the default mode. In this mode, @command{genfile}
generates data files.

@item File Status
    In this mode @command{genfile} displays status of specified files.

@item Synchronous Execution.
    In this mode @command{genfile} executes the given program with
@option{--checkpoint} option and executes a set of actions when
specified checkpoints are reached.
@end table

@menu
* Generate Mode::     File Generation Mode.
* Status Mode::       File Status Mode.
* Exec Mode::         Synchronous Execution mode.
@end menu

@node Generate Mode
@appendixsec Generate Mode

@cindex Generate Mode, @command{genfile}
@cindex @command{genfile}, generate mode
@cindex @command{genfile}, create file
    In this mode @command{genfile} creates a data file for the test
suite. The size of the file is given with the @option{--length}
(@option{-l}) option. By default the file contents is written to the
standard output, this can be changed using @option{--file}
(@option{-f}) command line option. Thus, the following two commands
are equivalent:

@smallexample
@group
genfile --length 100 > outfile
genfile --length 100 --file outfile
@end group
@end smallexample

    If @option{--length} is not given, @command{genfile} will
generate an empty (zero-length) file.

@cindex @command{genfile}, reading a list of file names
    You can instruct @command{genfile} to create several files at one
go, by giving it @option{--files-from} (@option{-T}) option followed
by a name of file containing a list of file names. Using dash
(@samp{-}) instead of the file name causes @command{genfile} to read
file list from the standard input. For example:

@smallexample
@group
# Read file names from file @file{file.list}
genfile --files-from file.list
# Read file names from standard input
genfile --files-from -
@end group
@end smallexample

@cindex File lists separated by NUL characters
    The list file is supposed to contain one file name per line. To
use file lists separated by ASCII NUL character, use @option{--null}
(@option{-0}) command line option:

@smallexample
genfile --null --files-from file.list
@end smallexample

@cindex pattern, @command{genfile}
    The default data pattern for filling the generated file consists
of first 256 letters of ASCII code, repeated enough times to fill the
entire file. This behavior can be changed with @option{--pattern}
option. This option takes a mandatory argument, specifying pattern
name to use. Currently two patterns are implemented:

@table @option
@item --pattern=default
    The default pattern as described above.

@item --pattern=zero
    Fills the file with zeroes.
@end table

    If no file name was given, the program exits with the code
@code{0}.  Otherwise, it exits with @code{0} only if it was able to
create a file of the specified length.

@cindex Sparse files, creating using @command{genfile}
@cindex @command{genfile}, creating sparse files
    Special option @option{--sparse} (@option{-s}) instructs
@command{genfile} to create a sparse file. Sparse files consist of
@dfn{data fragments}, separated by @dfn{holes} or blocks of zeros. On
many operating systems, actual disk storage is not allocated for
holes, but they are counted in the length of the file. To create a
sparse file, @command{genfile} should know where to put data fragments,
and what data to use to fill them. So, when @option{--sparse} is given
the rest of the command line specifies a so-called @dfn{file map}.

    The file map consists of any number of @dfn{fragment
descriptors}. Each descriptor is composed of two values: a number,
specifying fragment offset from the end of the previous fragment or,
for the very first fragment, from the beginning of the file, and
@dfn{contents string}, i.e. a string of characters, specifying the
pattern to fill the fragment with. File offset can be suffixed with
the following quantifiers:

@table @samp
@item k
@itemx K
The number is expressed in kilobytes.
@item m
@itemx M
The number is expressed in megabytes.
@item g
@itemx G
The number is expressed in gigabytes.
@end table

    For each letter in contents string @command{genfile} will generate
a @dfn{block} of data, filled with this letter and will write it to
the fragment. The size of block is given by @option{--block-size}
option. It defaults to 512. Thus, if the string consists of @var{n}
characters, the resulting file fragment will contain
@code{@var{n}*@var{block-size}} of data.

    Last fragment descriptor can have only file offset part. In this
case @command{genfile} will create a hole at the end of the file up to
the given offset.

    For example, consider the following invocation:

@smallexample
genfile --sparse --file sparsefile 0 ABCD 1M EFGHI 2000K
@end smallexample

@noindent
It will create 3101184-bytes long file of the following structure:

@multitable @columnfractions .35 .20 .45
@item Offset  @tab Length       @tab Contents
@item 0       @tab 4*512=2048   @tab Four 512-byte blocks, filled with
letters @samp{A}, @samp{B}, @samp{C} and @samp{D}.
@item 2048    @tab 1046528      @tab Zero bytes
@item 1050624 @tab 5*512=2560   @tab Five blocks, filled with letters
@samp{E}, @samp{F}, @samp{G}, @samp{H}, @samp{I}.
@item 1053184  @tab 2048000     @tab Zero bytes
@end multitable

    The exit code of @command{genfile --status} command is @code{0}
only if created file is actually sparse.

@node Status Mode
@appendixsec Status Mode

    In status mode, @command{genfile} prints file system status for
each file specified in the command line. This mode is toggled by
@option{--stat} (@option{-S}) command line option. An optional argument to this
option specifies output @dfn{format}: a comma-separated list of
@code{struct stat} fields to be displayed. This list can contain
following identifiers @FIXME{should we also support @samp{%} notations
as in stat(1)??}:

@table @asis
@item name
    The file name.

@item dev
@itemx st_dev
    Device number in decimal.

@item ino
@itemx st_ino
    Inode number.

@item mode[.@var{number}]
@itemx st_mode[.@var{number}]
    File mode in octal.  Optional @var{number} specifies octal mask to
be applied to the mode before outputting.  For example, @code{--stat
mode.777} will preserve lower nine bits of it.  Notice, that you can
use any punctuation caracter in place of @samp{.}.

@item nlink
@itemx st_nlink
    Number of hard links.

@item uid
@itemx st_uid
    User ID of owner.

@item gid
@itemx st_gid
    Group ID of owner.

@item size
@itemx st_size
    File size in decimal.

@item blksize
@itemx st_blksize
    The size in bytes of each file block.

@item blocks
@itemx st_blocks
    Number of blocks allocated.

@item atime
@itemx st_atime
    Time of last access.

@item mtime
@itemx st_mtime
    Time of last modification

@item ctime
@itemx st_ctime
    Time of last status change

@item sparse
    A boolean value indicating whether the file is @samp{sparse}.
@end table

    Modification times are displayed in @acronym{UTC} as
@acronym{UNIX} timestamps, unless suffixed with @samp{H} (for
``human-readable''), as in @samp{ctimeH}, in which case usual
@code{tar tv} output format is used.

    The default output format is: @samp{name,dev,ino,mode,
nlink,uid,gid,size,blksize,blocks,atime,mtime,ctime}.

    For example, the following command will display file names and
corresponding times of last access for each file in the current working
directory:

@smallexample
genfile --stat=name,atime *
@end smallexample

@node Exec Mode
@appendixsec Exec Mode

@cindex Exec Mode, @command{genfile}
    This mode is designed for testing the behavior of @code{paxutils}
commands when some of the files change during archiving. It is an
experimental mode.

    The @samp{Exec Mode} is toggled by @option{--run} command line
option (or its alias @option{-r}). The argument to this option gives
the command line to be executed. The actual command line is
constructed by inserting @option{--checkpoint} option between the
command name and its first argument (if any). Due to this, the
argument to @option{--run} may not use traditional @command{tar}
option syntax, i.e. the following is wrong:

@smallexample
# Wrong!
genfile --run 'tar cf foo bar'
@end smallexample

@noindent

Use the following syntax instead:

@smallexample
genfile --run 'tar -cf foo bar'
@end smallexample

    The rest of command line after @option{--run} or its equivalent
specifies checkpoint values and actions to be executed upon reaching
them. Checkpoint values are introduced with @option{--checkpoint}
command line option. Argument to this option is the number of
checkpoint in decimal.

    Any number of @dfn{actions} may be specified after a
checkpoint. Available actions are

@table @option
@item --cut @var{file}
@itemx --truncate @var{file}
    Truncate @var{file} to the size specified by previous
@option{--length} option (or 0, if it is not given).

@item --append @var{file}
    Append data to @var{file}. The size of data and its pattern are
given by previous @option{--length} and @option{pattern} options.

@item --touch @var{file}
    Update the access and modification times of @var{file}. These
timestamps are changed to the current time, unless @option{--date}
option was given, in which case they are changed to the specified
time. Argument to @option{--date} option is a date specification in
an almost arbitrary format (@pxref{Date input formats}).

@item --exec @var{command}
    Execute given shell command.

@end table

    Option @option{--verbose} instructs @command{genfile} to print on
standard output notifications about checkpoints being executed and to
verbosely describe exit status of the command.

    While the command is being executed its standard output remains
connected to descriptor 1. All messages it prints to file descriptor
2, except checkpoint notifications, are forwarded to standard
error.

    @command{Genfile} exits with the exit status of the executed command.


code:
@c GNU date syntax documentation

@c Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@c 2003, 2004, 2005, 2006 Free Software Foundation, Inc.

@c Permission is granted to copy, distribute and/or modify this document
@c under the terms of the GNU Free Documentation License, Version 1.1 or
@c any later version published by the Free Software Foundation; with no
@c Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
@c Texts.  A copy of the license is included in the ``GNU Free
@c Documentation License'' file as part of this distribution.

@node Date input formats
@chapter Date input formats

@cindex date input formats
@findex get_date

First, a quote:

@quotation
Our units of temporal measurement, from seconds on up to months, are so
complicated, asymmetrical and disjunctive so as to make coherent mental
reckoning in time all but impossible.  Indeed, had some tyrannical god
contrived to enslave our minds to time, to make it all but impossible
for us to escape subjection to sodden routines and unpleasant surprises,
he could hardly have done better than handing down our present system.
It is like a set of trapezoidal building blocks, with no vertical or
horizontal surfaces, like a language in which the simplest thought
demands ornate constructions, useless particles and lengthy
circumlocutions.  Unlike the more successful patterns of language and
science, which enable us to face experience boldly or at least
level-headedly, our system of temporal calculation silently and
persistently encourages our terror of time.

@dots{}  It is as though architects had to measure length in feet, width
in meters and height in ells; as though basic instruction manuals
demanded a knowledge of five different languages.  It is no wonder then
that we often look into our own immediate past or future, last Tuesday
or a week from Sunday, with feelings of helpless confusion.  @dots{}

--- Robert Grudin, @cite{Time and the Art of Living}.
@end quotation

This section describes the textual date representations that @sc{gnu}
programs accept.  These are the strings you, as a user, can supply as
arguments to the various programs.  The C interface (via the
@code{get_date} function) is not described here.

@menu
* General date syntax::            Common rules.
* Calendar date items::            19 Dec 1994.
* Time of day items::              9:20pm.
* Time zone items::                @sc{est}, @sc{pdt}, @sc{gmt}.
* Day of week items::              Monday and others.
* Relative items in date strings:: next tuesday, 2 years ago.
* Pure numbers in date strings::   19931219, 1440.
* Seconds since the Epoch::        @@1078100502.
* Specifying time zone rules::     TZ="America/New_York", TZ="UTC0".
* Authors of get_date::            Bellovin, Eggert, Salz, Berets, et al.
@end menu

@node General date syntax
@section General date syntax

@cindex general date syntax

@cindex items in date strings
A @dfn{date} is a string, possibly empty, containing many items
separated by whitespace.  The whitespace may be omitted when no
ambiguity arises.  The empty string means the beginning of today (i.e.,
midnight).  Order of the items is immaterial.  A date string may contain
many flavors of items:

@itemize @bullet
@item calendar date items
@item time of day items
@item time zone items
@item day of the week items
@item relative items
@item pure numbers.
@end itemize

@noindent We describe each of these item types in turn, below.

@cindex numbers, written-out
@cindex ordinal numbers
@findex first @r{in date strings}
@findex next @r{in date strings}
@findex last @r{in date strings}
A few ordinal numbers may be written out in words in some contexts.  This is
most useful for specifying day of the week items or relative items (see
below).  Among the most commonly used ordinal numbers, the word
@samp{last} stands for @math{-1}, @samp{this} stands for 0, and
@samp{first} and @samp{next} both stand for 1.  Because the word
@samp{second} stands for the unit of time there is no way to write the
ordinal number 2, but for convenience @samp{third} stands for 3,
@samp{fourth} for 4, @samp{fifth} for 5,
@samp{sixth} for 6, @samp{seventh} for 7, @samp{eighth} for 8,
@samp{ninth} for 9, @samp{tenth} for 10, @samp{eleventh} for 11 and
@samp{twelfth} for 12.

@cindex months, written-out
When a month is written this way, it is still considered to be written
numerically, instead of being ``spelled in full''; this changes the
allowed strings.

@cindex language, in dates
In the current implementation, only English is supported for words and
abbreviations like @samp{AM}, @samp{DST}, @samp{EST}, @samp{first},
@samp{January}, @samp{Sunday}, @samp{tomorrow}, and @samp{year}.

@cindex language, in dates
@cindex time zone item
The output of the @command{date} command
is not always acceptable as a date string,
not only because of the language problem, but also because there is no
standard meaning for time zone items like @samp{IST}.  When using
@command{date} to generate a date string intended to be parsed later,
specify a date format that is independent of language and that does not
use time zone items other than @samp{UTC} and @samp{Z}.  Here are some
ways to do this:

@example
$ LC_ALL=C TZ=UTC0 date
Mon Mar  1 00:21:42 UTC 2004
$ TZ=UTC0 date +'%Y-%m-%d %H:%M:%SZ'
2004-03-01 00:21:42Z
$ date --iso-8601=ns | tr T ' '  # --iso-8601 is a GNU extension.
2004-02-29 16:21:42,692722128-0800
$ date --rfc-2822  # a GNU extension
Sun, 29 Feb 2004 16:21:42 -0800
$ date +'%Y-%m-%d %H:%M:%S %z'  # %z is a GNU extension.
2004-02-29 16:21:42 -0800
$ date +'@@%s.%N'  # %s and %N are GNU extensions.
@@1078100502.692722128
@end example

@cindex case, ignored in dates
@cindex comments, in dates
Alphabetic case is completely ignored in dates.  Comments may be introduced
between round parentheses, as long as included parentheses are properly
nested.  Hyphens not followed by a digit are currently ignored.  Leading
zeros on numbers are ignored.

Invalid dates like @samp{2005-02-29} or times like @samp{24:00} are
rejected.  In the typical case of a host that does not support leap
seconds, a time like @samp{23:59:60} is rejected even if it
corresponds to a valid leap second.

@node Calendar date items
@section Calendar date items

@cindex calendar date item

A @dfn{calendar date item} specifies a day of the year.  It is
specified differently, depending on whether the month is specified
numerically or literally.  All these strings specify the same calendar date:

@example
1972-09-24     # @sc{iso} 8601.
72-9-24        # Assume 19xx for 69 through 99,
               # 20xx for 00 through 68.
72-09-24       # Leading zeros are ignored.
9/24/72        # Common U.S. writing.
24 September 1972
24 Sept 72     # September has a special abbreviation.
24 Sep 72      # Three-letter abbreviations always allowed.
Sep 24, 1972
24-sep-72
24sep72
@end example

The year can also be omitted.  In this case, the last specified year is
used, or the current year if none.  For example:

@example
9/24
sep 24
@end example

Here are the rules.

@cindex @sc{iso} 8601 date format
@cindex date format, @sc{iso} 8601
For numeric months, the @sc{iso} 8601 format
@samp{@var{year}-@var{month}-@var{day}} is allowed, where @var{year} is
any positive number, @var{month} is a number between 01 and 12, and
@var{day} is a number between 01 and 31.  A leading zero must be present
if a number is less than ten.  If @var{year} is 68 or smaller, then 2000
is added to it; otherwise, if @var{year} is less than 100,
then 1900 is added to it.  The construct
@samp{@var{month}/@var{day}/@var{year}}, popular in the United States,
is accepted.  Also @samp{@var{month}/@var{day}}, omitting the year.

@cindex month names in date strings
@cindex abbreviations for months
Literal months may be spelled out in full: @samp{January},
@samp{February}, @samp{March}, @samp{April}, @samp{May}, @samp{June},
@samp{July}, @samp{August}, @samp{September}, @samp{October},
@samp{November} or @samp{December}.  Literal months may be abbreviated
to their first three letters, possibly followed by an abbreviating dot.
It is also permitted to write @samp{Sept} instead of @samp{September}.

When months are written literally, the calendar date may be given as any
of the following:

@example
@var{day} @var{month} @var{year}
@var{day} @var{month}
@var{month} @var{day} @var{year}
@var{day}-@var{month}-@var{year}
@end example

Or, omitting the year:

@example
@var{month} @var{day}
@end example

@node Time of day items
@section Time of day items

@cindex time of day item

A @dfn{time of day item} in date strings specifies the time on a given
day.  Here are some examples, all of which represent the same time:

@example
20:02:00.000000
20:02
8:02pm
20:02-0500      # In @sc{est} (U.S. Eastern Standard Time).
@end example

More generally, the time of day may be given as
@samp{@var{hour}:@var{minute}:@var{second}}, where @var{hour} is
a number between 0 and 23, @var{minute} is a number between 0 and
59, and @var{second} is a number between 0 and 59 possibly followed by
@samp{.} or @samp{,} and a fraction containing one or more digits.
Alternatively,
@samp{:@var{second}} can be omitted, in which case it is taken to
be zero.  On the rare hosts that support leap seconds, @var{second}
may be 60.

@findex am @r{in date strings}
@findex pm @r{in date strings}
@findex midnight @r{in date strings}
@findex noon @r{in date strings}
If the time is followed by @samp{am} or @samp{pm} (or @samp{a.m.}
or @samp{p.m.}), @var{hour} is restricted to run from 1 to 12, and
@samp{:@var{minute}} may be omitted (taken to be zero).  @samp{am}
indicates the first half of the day, @samp{pm} indicates the second
half of the day.  In this notation, 12 is the predecessor of 1:
midnight is @samp{12am} while noon is @samp{12pm}.
(This is the zero-oriented interpretation of @samp{12am} and @samp{12pm},
as opposed to the old tradition derived from Latin
which uses @samp{12m} for noon and @samp{12pm} for midnight.)

@cindex time zone correction
@cindex minutes, time zone correction by
The time may alternatively be followed by a time zone correction,
expressed as @samp{@var{s}@var{hh}@var{mm}}, where @var{s} is @samp{+}
or @samp{-}, @var{hh} is a number of zone hours and @var{mm} is a number
of zone minutes.  You can also separate @var{hh} from @var{mm} with a colon.
When a time zone correction is given this way, it
forces interpretation of the time relative to
Coordinated Universal Time (@sc{utc}), overriding any previous
specification for the time zone or the local time zone.  For example,
@samp{+0530} and @samp{+05:30} both stand for the time zone 5.5 hours
ahead of @sc{utc} (e.g., India).  The @var{minute}
part of the time of day may not be elided when a time zone correction
is used.  This is the best way to specify a time zone correction by
fractional parts of an hour.

Either @samp{am}/@samp{pm} or a time zone correction may be specified,
but not both.

@node Time zone items
@section Time zone items

@cindex time zone item

A @dfn{time zone item} specifies an international time zone, indicated
by a small set of letters, e.g., @samp{UTC} or @samp{Z}
for Coordinated Universal
Time.  Any included periods are ignored.  By following a
non-daylight-saving time zone by the string @samp{DST} in a separate
word (that is, separated by some white space), the corresponding
daylight saving time zone may be specified.
Alternatively, a non-daylight-saving time zone can be followed by a
time zone correction, to add the two values.  This is normally done
only for @samp{UTC}; for example, @samp{UTC+05:30} is equivalent to
@samp{+05:30}.

Time zone items other than @samp{UTC} and @samp{Z}
are obsolescent and are not recommended, because they
are ambiguous; for example, @samp{EST} has a different meaning in
Australia than in the United States.  Instead, it's better to use
unambiguous numeric time zone corrections like @samp{-0500}, as
described in the previous section.

If neither a time zone item nor a time zone correction is supplied,
time stamps are interpreted using the rules of the default time zone
(@pxref{Specifying time zone rules}).

@node Day of week items
@section Day of week items

@cindex day of week item

The explicit mention of a day of the week will forward the date
(only if necessary) to reach that day of the week in the future.

Days of the week may be spelled out in full: @samp{Sunday},
@samp{Monday}, @samp{Tuesday}, @samp{Wednesday}, @samp{Thursday},
@samp{Friday} or @samp{Saturday}.  Days may be abbreviated to their
first three letters, optionally followed by a period.  The special
abbreviations @samp{Tues} for @samp{Tuesday}, @samp{Wednes} for
@samp{Wednesday} and @samp{Thur} or @samp{Thurs} for @samp{Thursday} are
also allowed.

@findex next @var{day}
@findex last @var{day}
A number may precede a day of the week item to move forward
supplementary weeks.  It is best used in expression like @samp{third
monday}.  In this context, @samp{last @var{day}} or @samp{next
@var{day}} is also acceptable; they move one week before or after
the day that @var{day} by itself would represent.

A comma following a day of the week item is ignored.

@node Relative items in date strings
@section Relative items in date strings

@cindex relative items in date strings
@cindex displacement of dates

@dfn{Relative items} adjust a date (or the current date if none) forward
or backward.  The effects of relative items accumulate.  Here are some
examples:

@example
1 year
1 year ago
3 years
2 days
@end example

@findex year @r{in date strings}
@findex month @r{in date strings}
@findex fortnight @r{in date strings}
@findex week @r{in date strings}
@findex day @r{in date strings}
@findex hour @r{in date strings}
@findex minute @r{in date strings}
The unit of time displacement may be selected by the string @samp{year}
or @samp{month} for moving by whole years or months.  These are fuzzy
units, as years and months are not all of equal duration.  More precise
units are @samp{fortnight} which is worth 14 days, @samp{week} worth 7
days, @samp{day} worth 24 hours, @samp{hour} worth 60 minutes,
@samp{minute} or @samp{min} worth 60 seconds, and @samp{second} or
@samp{sec} worth one second.  An @samp{s} suffix on these units is
accepted and ignored.

@findex ago @r{in date strings}
The unit of time may be preceded by a multiplier, given as an optionally
signed number.  Unsigned numbers are taken as positively signed.  No
number at all implies 1 for a multiplier.  Following a relative item by
the string @samp{ago} is equivalent to preceding the unit by a
multiplier with value @math{-1}.

@findex day @r{in date strings}
@findex tomorrow @r{in date strings}
@findex yesterday @r{in date strings}
The string @samp{tomorrow} is worth one day in the future (equivalent
to @samp{day}), the string @samp{yesterday} is worth
one day in the past (equivalent to @samp{day ago}).

@findex now @r{in date strings}
@findex today @r{in date strings}
@findex this @r{in date strings}
The strings @samp{now} or @samp{today} are relative items corresponding
to zero-valued time displacement, these strings come from the fact
a zero-valued time displacement represents the current time when not
otherwise changed by previous items.  They may be used to stress other
items, like in @samp{12:00 today}.  The string @samp{this} also has
the meaning of a zero-valued time displacement, but is preferred in
date strings like @samp{this thursday}.

When a relative item causes the resulting date to cross a boundary
where the clocks were adjusted, typically for daylight saving time,
the resulting date and time are adjusted accordingly.

The fuzz in units can cause problems with relative items.  For
example, @samp{2003-07-31 -1 month} might evaluate to 2003-07-01,
because 2003-06-31 is an invalid date.  To determine the previous
month more reliably, you can ask for the month before the 15th of the
current month.  For example:

@example
$ date -R
Thu, 31 Jul 2003 13:02:39 -0700
$ date --date='-1 month' +'Last month was %B?'
Last month was July?
$ date --date="$(date +%Y-%m-15) -1 month" +'Last month was %B!'
Last month was June!
@end example

Also, take care when manipulating dates around clock changes such as
daylight saving leaps.  In a few cases these have added or subtracted
as much as 24 hours from the clock, so it is often wise to adopt
universal time by setting the @env{TZ} environment variable to
@samp{UTC0} before embarking on calendrical calculations.

@node Pure numbers in date strings
@section Pure numbers in date strings

@cindex pure numbers in date strings

The precise interpretation of a pure decimal number depends
on the context in the date string.

If the decimal number is of the form @var{yyyy}@var{mm}@var{dd} and no
other calendar date item (@pxref{Calendar date items}) appears before it
in the date string, then @var{yyyy} is read as the year, @var{mm} as the
month number and @var{dd} as the day of the month, for the specified
calendar date.

If the decimal number is of the form @var{hh}@var{mm} and no other time
of day item appears before it in the date string, then @var{hh} is read
as the hour of the day and @var{mm} as the minute of the hour, for the
specified time of day.  @var{mm} can also be omitted.

If both a calendar date and a time of day appear to the left of a number
in the date string, but no relative item, then the number overrides the
year.

@node Seconds since the Epoch
@section Seconds since the Epoch

If you precede a number with @samp{@@}, it represents an internal time
stamp as a count of seconds.  The number can contain an internal
decimal point (either @samp{.} or @samp{,}); any excess precision not
supported by the internal representation is truncated toward minus
infinity.  Such a number cannot be combined with any other date
item, as it specifies a complete time stamp.

@cindex beginning of time, for @acronym{POSIX}
@cindex epoch, for @acronym{POSIX}
Internally, computer times are represented as a count of seconds since
an epoch---a well-defined point of time.  On @acronym{GNU} and
@acronym{POSIX} systems, the epoch is 1970-01-01 00:00:00 @sc{utc}, so
@samp{@@0} represents this time, @samp{@@1} represents 1970-01-01
00:00:01 @sc{utc}, and so forth.  @acronym{GNU} and most other
@acronym{POSIX}-compliant systems support such times as an extension
to @acronym{POSIX}, using negative counts, so that @samp{@@-1}
represents 1969-12-31 23:59:59 @sc{utc}.

Traditional Unix systems count seconds with 32-bit two's-complement
integers and can represent times from 1901-12-13 20:45:52 through
2038-01-19 03:14:07 @sc{utc}.  More modern systems use 64-bit counts
of seconds with nanosecond subcounts, and can represent all the times
in the known lifetime of the universe to a resolution of 1 nanosecond.

On most hosts, these counts ignore the presence of leap seconds.
For example, on most hosts @samp{@@915148799} represents 1998-12-31
23:59:59 @sc{utc}, @samp{@@915148800} represents 1999-01-01 00:00:00
@sc{utc}, and there is no way to represent the intervening leap second
1998-12-31 23:59:60 @sc{utc}.

@node Specifying time zone rules
@section Specifying time zone rules

@vindex TZ
Normally, dates are interpreted using the rules of the current time
zone, which in turn are specified by the @env{TZ} environment
variable, or by a system default if @env{TZ} is not set.  To specify a
different set of default time zone rules that apply just to one date,
start the date with a string of the form @samp{TZ="@var{rule}"}.  The
two quote characters (@samp{"}) must be present in the date, and any
quotes or backslashes within @var{rule} must be escaped by a
backslash.

For example, with the @acronym{GNU} @command{date} command you can
answer the question ``What time is it in New York when a Paris clock
shows 6:30am on October 31, 2004?'' by using a date beginning with
@samp{TZ="Europe/Paris"} as shown in the following shell transcript:

@example
$ export TZ="America/New_York"
$ date --date='TZ="Europe/Paris" 2004-10-31 06:30'
Sun Oct 31 01:30:00 EDT 2004
@end example

In this example, the @option{--date} operand begins with its own
@env{TZ} setting, so the rest of that operand is processed according
to @samp{Europe/Paris} rules, treating the string @samp{2004-10-31
06:30} as if it were in Paris.  However, since the output of the
@command{date} command is processed according to the overall time zone
rules, it uses New York time.  (Paris was normally six hours ahead of
New York in 2004, but this example refers to a brief Halloween period
when the gap was five hours.)

A @env{TZ} value is a rule that typically names a location in the
@uref{http://www.twinsun.com/tz/tz-link.htm, @samp{tz} database}.
A recent catalog of location names appears in the
@uref{http://twiki.org/cgi-bin/xtra/tzdate, TWiki Date and Time
Gateway}.  A few non-@acronym{GNU} hosts require a colon before a
location name in a @env{TZ} setting, e.g.,
@samp{TZ=":America/New_York"}.

The @samp{tz} database includes a wide variety of locations ranging
from @samp{Arctic/Longyearbyen} to @samp{Antarctica/South_Pole}, but
if you are at sea and have your own private time zone, or if you are
using a non-@acronym{GNU} host that does not support the @samp{tz}
database, you may need to use a @acronym{POSIX} rule instead.  Simple
@acronym{POSIX} rules like @samp{UTC0} specify a time zone without
daylight saving time; other rules can specify simple daylight saving
regimes.  @xref{TZ Variable,, Specifying the Time Zone with @code{TZ},
libc, The GNU C Library}.

@node Authors of get_date
@section Authors of @code{get_date}

@cindex authors of @code{get_date}

@cindex Bellovin, Steven M.
@cindex Salz, Rich
@cindex Berets, Jim
@cindex MacKenzie, David
@cindex Meyering, Jim
@cindex Eggert, Paul
@code{get_date} was originally implemented by Steven M. Bellovin
(@email{smb@@research.att.com}) while at the University of North Carolina
at Chapel Hill.  The code was later tweaked by a couple of people on
Usenet, then completely overhauled by Rich $alz (@email{rsalz@@bbn.com})
and Jim Berets (@email{jberets@@bbn.com}) in August, 1990.  Various
revisions for the @sc{gnu} system were made by David MacKenzie, Jim Meyering,
Paul Eggert and others.

@cindex Pinard, F.
@cindex Berry, K.
This chapter was originally produced by Fran@,{c}ois Pinard
(@email{pinard@@iro.umontreal.ca}) from the @file{getdate.y} source code,
and then edited by K.@: Berry (@email{kb@@cs.umb.edu}).


code:
@comment  GNU tar Archive Format description.
@comment
@comment   Copyright (C) 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
@comment   2000, 2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
@comment
@comment   This program is free software; you can redistribute it and/or modify it
@comment   under the terms of the GNU General Public License as published by the
@comment   Free Software Foundation; either version 2, or (at your option) any later
@comment   version.
@comment
@comment   This program is distributed in the hope that it will be useful, but
@comment   WITHOUT ANY WARRANTY; without even the implied warranty of
@comment   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
@comment   Public License for more details.
@comment
@comment   You should have received a copy of the GNU General Public License along
@comment   with this program; if not, write to the Free Software Foundation, Inc.,
@comment   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

/*@r{ tar Header Block, from POSIX 1003.1-1990.  }*/

/*@r{ POSIX header.  }*/

struct posix_header
@{                              /*@r{ byte offset }*/
  char name[100];               /*@r{   0 }*/
  char mode[8];                 /*@r{ 100 }*/
  char uid[8];                  /*@r{ 108 }*/
  char gid[8];                  /*@r{ 116 }*/
  char size[12];                /*@r{ 124 }*/
  char mtime[12];               /*@r{ 136 }*/
  char chksum[8];               /*@r{ 148 }*/
  char typeflag;                /*@r{ 156 }*/
  char linkname[100];           /*@r{ 157 }*/
  char magic[6];                /*@r{ 257 }*/
  char version[2];              /*@r{ 263 }*/
  char uname[32];               /*@r{ 265 }*/
  char gname[32];               /*@r{ 297 }*/
  char devmajor[8];             /*@r{ 329 }*/
  char devminor[8];             /*@r{ 337 }*/
  char prefix[155];             /*@r{ 345 }*/
                                /*@r{ 500 }*/
@};

#define TMAGIC   "ustar"        /*@r{ ustar and a null }*/
#define TMAGLEN  6
#define TVERSION "00"           /*@r{ 00 and no null }*/
#define TVERSLEN 2

/*@r{ Values used in typeflag field.  }*/
#define REGTYPE  '0'            /*@r{ regular file }*/
#define AREGTYPE '\0'           /*@r{ regular file }*/
#define LNKTYPE  '1'            /*@r{ link }*/
#define SYMTYPE  '2'            /*@r{ reserved }*/
#define CHRTYPE  '3'            /*@r{ character special }*/
#define BLKTYPE  '4'            /*@r{ block special }*/
#define DIRTYPE  '5'            /*@r{ directory }*/
#define FIFOTYPE '6'            /*@r{ FIFO special }*/
#define CONTTYPE '7'            /*@r{ reserved }*/

#define XHDTYPE  'x'            /*@r{ Extended header referring to the
                                   next file in the archive }*/
#define XGLTYPE  'g'            /*@r{ Global extended header }*/

/*@r{ Bits used in the mode field, values in octal.  }*/
#define TSUID    04000          /*@r{ set UID on execution }*/
#define TSGID    02000          /*@r{ set GID on execution }*/
#define TSVTX    01000          /*@r{ reserved }*/
                                /*@r{ file permissions }*/
#define TUREAD   00400          /*@r{ read by owner }*/
#define TUWRITE  00200          /*@r{ write by owner }*/
#define TUEXEC   00100          /*@r{ execute/search by owner }*/
#define TGREAD   00040          /*@r{ read by group }*/
#define TGWRITE  00020          /*@r{ write by group }*/
#define TGEXEC   00010          /*@r{ execute/search by group }*/
#define TOREAD   00004          /*@r{ read by other }*/
#define TOWRITE  00002          /*@r{ write by other }*/
#define TOEXEC   00001          /*@r{ execute/search by other }*/

/*@r{ tar Header Block, GNU extensions.  }*/

/*@r{ In GNU tar, SYMTYPE is for to symbolic links, and CONTTYPE is for
   contiguous files, so maybe disobeying the `reserved' comment in POSIX
   header description.  I suspect these were meant to be used this way, and
   should not have really been `reserved' in the published standards.  }*/

/*@r{ *BEWARE* *BEWARE* *BEWARE* that the following information is still
   boiling, and may change.  Even if the OLDGNU format description should be
   accurate, the so-called GNU format is not yet fully decided.  It is
   surely meant to use only extensions allowed by POSIX, but the sketch
   below repeats some ugliness from the OLDGNU format, which should rather
   go away.  Sparse files should be saved in such a way that they do *not*
   require two passes at archive creation time.  Huge files get some POSIX
   fields to overflow, alternate solutions have to be sought for this.  }*/

/*@r{ Descriptor for a single file hole.  }*/

struct sparse
@{                              /*@r{ byte offset }*/
  char offset[12];              /*@r{   0 }*/
  char numbytes[12];            /*@r{  12 }*/
                                /*@r{  24 }*/
@};

/*@r{ Sparse files are not supported in POSIX ustar format.  For sparse files
   with a POSIX header, a GNU extra header is provided which holds overall
   sparse information and a few sparse descriptors.  When an old GNU header
   replaces both the POSIX header and the GNU extra header, it holds some
   sparse descriptors too.  Whether POSIX or not, if more sparse descriptors
   are still needed, they are put into as many successive sparse headers as
   necessary.  The following constants tell how many sparse descriptors fit
   in each kind of header able to hold them.  }*/

#define SPARSES_IN_EXTRA_HEADER  16
#define SPARSES_IN_OLDGNU_HEADER 4
#define SPARSES_IN_SPARSE_HEADER 21

/*@r{ Extension header for sparse files, used immediately after the GNU extra
   header, and used only if all sparse information cannot fit into that
   extra header.  There might even be many such extension headers, one after
   the other, until all sparse information has been recorded.  }*/

struct sparse_header
@{                              /*@r{ byte offset }*/
  struct sparse sp[SPARSES_IN_SPARSE_HEADER];
                                /*@r{   0 }*/
  char isextended;              /*@r{ 504 }*/
                                /*@r{ 505 }*/
@};

/*@r{ The old GNU format header conflicts with POSIX format in such a way that
   POSIX archives may fool old GNU tar's, and POSIX tar's might well be
   fooled by old GNU tar archives.  An old GNU format header uses the space
   used by the prefix field in a POSIX header, and cumulates information
   normally found in a GNU extra header.  With an old GNU tar header, we
   never see any POSIX header nor GNU extra header.  Supplementary sparse
   headers are allowed, however.  }*/

struct oldgnu_header
@{                              /*@r{ byte offset }*/
  char unused_pad1[345];        /*@r{   0 }*/
  char atime[12];               /*@r{ 345 Incr. archive: atime of the file }*/
  char ctime[12];               /*@r{ 357 Incr. archive: ctime of the file }*/
  char offset[12];              /*@r{ 369 Multivolume archive: the offset of
                                   the start of this volume }*/
  char longnames[4];            /*@r{ 381 Not used }*/
  char unused_pad2;             /*@r{ 385 }*/
  struct sparse sp[SPARSES_IN_OLDGNU_HEADER];
                                /*@r{ 386 }*/
  char isextended;              /*@r{ 482 Sparse file: Extension sparse header
                                   follows }*/
  char realsize[12];            /*@r{ 483 Sparse file: Real size}*/
                                /*@r{ 495 }*/
@};

/*@r{ OLDGNU_MAGIC uses both magic and version fields, which are contiguous.
   Found in an archive, it indicates an old GNU header format, which will be
   hopefully become obsolescent.  With OLDGNU_MAGIC, uname and gname are
   valid, though the header is not truly POSIX conforming.  }*/
#define OLDGNU_MAGIC "ustar  "  /*@r{ 7 chars and a null }*/

/*@r{ The standards committee allows only capital A through capital Z for
   user-defined expansion.  Other letters in use include:

   'A' Solaris Access Control List
   'E' Solaris Extended Attribute File
   'I' Inode only, as in 'star'
   'X' POSIX 1003.1-2001 eXtended (VU version)  }*/

/*@r{ This is a dir entry that contains the names of files that were in the
   dir at the time the dump was made.  }*/
#define GNUTYPE_DUMPDIR 'D'

/*@r{ Identifies the *next* file on the tape as having a long linkname.  }*/
#define GNUTYPE_LONGLINK 'K'

/*@r{ Identifies the *next* file on the tape as having a long name.  }*/
#define GNUTYPE_LONGNAME 'L'

/*@r{ This is the continuation of a file that began on another volume.  }*/
#define GNUTYPE_MULTIVOL 'M'

/*@r{ For storing filenames that do not fit into the main header.  }*/
#define GNUTYPE_NAMES 'N'

/*@r{ This is for sparse files.  }*/
#define GNUTYPE_SPARSE 'S'

/*@r{ This file is a tape/volume header.  Ignore it on extraction.  }*/
#define GNUTYPE_VOLHDR 'V'

/*@r{ Solaris extended header }*/
#define SOLARIS_XHDTYPE 'X'

/*@r{ J@"org Schilling star header }*/

struct star_header
@{                              /*@r{ byte offset }*/
  char name[100];               /*@r{   0 }*/
  char mode[8];                 /*@r{ 100 }*/
  char uid[8];                  /*@r{ 108 }*/
  char gid[8];                  /*@r{ 116 }*/
  char size[12];                /*@r{ 124 }*/
  char mtime[12];               /*@r{ 136 }*/
  char chksum[8];               /*@r{ 148 }*/
  char typeflag;                /*@r{ 156 }*/
  char linkname[100];           /*@r{ 157 }*/
  char magic[6];                /*@r{ 257 }*/
  char version[2];              /*@r{ 263 }*/
  char uname[32];               /*@r{ 265 }*/
  char gname[32];               /*@r{ 297 }*/
  char devmajor[8];             /*@r{ 329 }*/
  char devminor[8];             /*@r{ 337 }*/
  char prefix[131];             /*@r{ 345 }*/
  char atime[12];               /*@r{ 476 }*/
  char ctime[12];               /*@r{ 488 }*/
                                /*@r{ 500 }*/
@};

#define SPARSES_IN_STAR_HEADER      4
#define SPARSES_IN_STAR_EXT_HEADER  21

struct star_in_header
@{
  char fill[345];       /*@r{   0  Everything that is before t_prefix }*/
  char prefix[1];       /*@r{ 345  t_name prefix }*/
  char fill2;           /*@r{ 346  }*/
  char fill3[8];        /*@r{ 347  }*/
  char isextended;      /*@r{ 355  }*/
  struct sparse sp[SPARSES_IN_STAR_HEADER]; /*@r{ 356  }*/
  char realsize[12];    /*@r{ 452  Actual size of the file }*/
  char offset[12];      /*@r{ 464  Offset of multivolume contents }*/
  char atime[12];       /*@r{ 476  }*/
  char ctime[12];       /*@r{ 488  }*/
  char mfill[8];        /*@r{ 500  }*/
  char xmagic[4];       /*@r{ 508  "tar" }*/
@};

struct star_ext_header
@{
  struct sparse sp[SPARSES_IN_STAR_EXT_HEADER];
  char isextended;
@};