/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1992-2010 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* rev [-l] [file ...]
*
* reverse the characters or lines of one or more files
*
* David Korn
* AT&T Laboratories
* dgk@research.att.com
*
*/
static const char usage[] =
"[-?\n@(#)$Id: rev (AT&T Research) 2007-11-29 $\n]"
"[+NAME?rev - reverse the characters or lines of one or more files]"
"[+DESCRIPTION?\brev\b copies one or more files to standard output "
"reversing the order of characters on every line of the file "
"or reversing the order of lines of the file if \b-l\b is specified.]"
"[+?If no \afile\a is given, or if the \afile\a is \b-\b, \brev\b "
"copies from standard input starting at the current offset.]"
"[l:line?Reverse the lines of the file.]"
"\n"
"\n[file ...]\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?All files copied successfully.]"
"[+>0?One or more files did not copy.]"
"}"
"[+SEE ALSO?\bcat\b(1), \btail\b(1)]"
;
#include <cmd.h>
#include <rev.h>
/*
* reverse the characters within a line
*/
{
register int c;
register size_t n;
register size_t w;
if (mbwide())
{
wp = 0;
w = 0;
{
if (n > w)
{
{
return 0;
}
}
*cp++ = '\n';
return -1;
}
if (wp)
}
else
{
{
c = *--ep;
*bp++ = c;
}
return(-1);
}
return(0);
}
int
{
register char *cp;
register int n, line=0;
{
case 'l':
line=1;
break;
case ':':
break;
case '?':
break;
}
if(error_info.errors)
n=0;
argv++;
do
{
{
n=1;
continue;
}
if(line)
else
if(line < 0)
}
return(n);
}