Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/resize Add a maintainable version of resize, with a ...
details: https://anonhg.NetBSD.org/src/rev/ab850bce64f6
branches: trunk
changeset: 959862:ab850bce64f6
user: christos <christos%NetBSD.org@localhost>
date: Sat Feb 27 15:36:39 2021 +0000
description:
Add a maintainable version of resize, with a copy target and a header that
provides all the glue needed without other X headers.
diffstat:
usr.bin/resize/Makefile | 30 ++++-
usr.bin/resize/resize.1 | 219 --------------------------------------
usr.bin/resize/resize.c | 260 ++++++++++++++++++++++++++++++++++++++++++---
usr.bin/resize/resize.h | 92 ++++++++++++++++
usr.bin/resize/resize.man | 235 +++++++++++++++++++++++++++++++++++++++++
5 files changed, 596 insertions(+), 240 deletions(-)
diffs (truncated from 1036 to 300 lines):
diff -r 643b329dcd6c -r ab850bce64f6 usr.bin/resize/Makefile
--- a/usr.bin/resize/Makefile Sat Feb 27 15:29:15 2021 +0000
+++ b/usr.bin/resize/Makefile Sat Feb 27 15:36:39 2021 +0000
@@ -1,7 +1,33 @@
-# $NetBSD: Makefile,v 1.1 2020/12/27 21:13:18 reinoud Exp $
+# $NetBSD: Makefile,v 1.2 2021/02/27 15:36:39 christos Exp $
+
+.include <bsd.own.mk>
WARNS= 3
PROG= resize
-SRCS= resize.c xstrings.c
+SRCS= resize.c
+
+CPPFLAGS+=-DRESIZE_ONLY
+DPADD+= ${LIBUTIL}
+LDADD+= -lutil
.include <bsd.prog.mk>
+
+XTERM=${X11SRCDIR}/external/mit/xterm/dist
+
+.for i in resize.c resize.man
+copy:: ${.CURDIR}/${i}
+${.CURDIR}/${i}: ${XTERM}/${i}
+ cp -p ${.ALLSRC} ${.TARGET}
+.endfor
+
+CLEANFILES+=resize.1
+
+resize.1: resize.man
+ @rm -f ${.TARGET}
+ ${TOOL_SED} \
+ -e "s@__app_date__@1970-01-01@" \
+ -e "s@__app_version__@NetBSD@" \
+ -e "s@__default_termname__@vt100@" \
+ -e "s@__mansuffix__@1@" \
+ -e "s@__miscmansuffix__@7@" \
+ < ${.ALLSRC} > ${.TARGET}
diff -r 643b329dcd6c -r ab850bce64f6 usr.bin/resize/resize.1
--- a/usr.bin/resize/resize.1 Sat Feb 27 15:29:15 2021 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,219 +0,0 @@
-.\" $XTermId: resize.man,v 1.32 2016/09/24 11:14:15 tom Exp $
-.\"
-.\" Copyright 1998-2013,2016 by Thomas E. Dickey
-.\"
-.\" All Rights Reserved
-.\"
-.\" Permission is hereby granted, free of charge, to any person obtaining a
-.\" copy of this software and associated documentation files (the
-.\" "Software"), to deal in the Software without restriction, including
-.\" without limitation the rights to use, copy, modify, merge, publish,
-.\" distribute, sublicense, and/or sell copies of the Software, and to
-.\" permit persons to whom the Software is furnished to do so, subject to
-.\" the following conditions:
-.\"
-.\" The above copyright notice and this permission notice shall be included
-.\" in all copies or substantial portions of the Software.
-.\"
-.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-.\" IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
-.\" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-.\" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-.\" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-.\"
-.\" Except as contained in this notice, the name(s) of the above copyright
-.\" holders shall not be used in advertising or otherwise to promote the
-.\" sale, use or other dealings in this Software without prior written
-.\" authorization.
-.\"
-.\" updated by Thomas E. Dickey for XFree86, 1998-2006.
-.\"
-.ds N Resize
-.ds n resize
-.\"
-.\" Bulleted paragraph
-.de bP
-.IP \(bu 4
-..
-.\" Escape single quotes in literal strings from groff's Unicode transform.
-.ie \n(.g .ds AQ \(aq
-.el .ds AQ '
-.ie \n(.g .ds `` \(lq
-.el .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el .ds '' ''
-.TH RESIZE 1 "2017-06-20" "Patch 330" "X Window System"
-.SH NAME
-resize \- set environment and terminal settings to current xterm window size
-.SH SYNOPSIS
-.B \*n
-[ \fB\-v\fP | \fB\-u\fP | \fB\-c\fP ] [ \fB\-s\fP [ \fIrow col\fP ] ]
-.SH DESCRIPTION
-.I \*N
-prints a shell command for setting the appropriate environment variables
-to indicate the current size of \fIxterm\fP window from which the command
-is run.
-.PP
-.I \*N
-determines the command through several steps:
-.bP
-first, it finds the name of the user's shell program.
-It uses the \fBSHELL\fP variable if set,
-otherwise it uses the user's data from /etc/passwd.
-.bP
-then it decides whether to use Bourne shell syntax or C-Shell syntax.
-It uses a built-in table of known shells,
-which can be overridden by the \fB\-u\fP and \fB\-c\fP options.
-.bP
-then \fI\*n\fP asks the operating system for the terminal settings.
-This is the same information which can be manipulated using \fIstty\fP.
-.bP
-then \fI\*n\fP asks the terminal for its size in characters.
-Depending on whether the "\fB\-s\fP option is given,
-\fI\*n\fP uses a different escape sequence to ask for this information.
-.bP
-at this point, \fI\*n\fP attempts to update the terminal settings
-to reflect the terminal window's size in pixels:
-.RS
-.bP
-if the \fB\-s\fP option is used,
-\fI\*n\fP then asks the terminal for its size in pixels.
-.bP
-otherwise,
-\fI\*n\fP asks the operating system for the information
-and updates that after ensuring that the window's dimensions are
-a multiple of the character height and width.
-.bP
-in either case, the updated terminal settings are done
-using a different system call than used for \fIstty\fP.
-.RE
-.bP
-then \fI\*n\fP updates the terminal settings to reflect any altered
-values such as its size in rows or columns.
-This affects the values shown by \fIstty\fP.
-.bP
-finally, \fI\*n\fP writes the shell command for setting the
-environment variables to the standard output.
-.SH EXAMPLES
-For \*n's output to take effect,
-\fI\*n\fP must either be evaluated
-as part of the command line (usually done with a shell alias or function) or
-else redirected to a file which can then be read in.
-From the C shell (usually
-known as \fI/bin/csh\fP), the following alias could be defined in the
-user's \fI.cshrc\fP:
-.sp
-.nf
- % alias rs \*(AQset noglob; eval \fC\`\fP\*n\fC\`\fP\*(AQ
-.fi
-.sp
-After resizing the window, the user would type:
-.sp
-.nf
- % rs
-.fi
-.sp
-Users of versions of the Bourne shell (usually known as \fI/bin/sh\fP) that
-don't have command
-functions will need to send the output to a temporary file and then read it back
-in with the \*(``.\*('' command:
-.sp
-.nf
- $ \*n > /tmp/out
- $ .\0/tmp/out
-.fi
-.SH OPTIONS
-The following options may be used with \fI\*n\fP:
-.TP 8
-.B \-c
-This option indicates that C shell commands should be generated even if the
-user's current shell is not \fI/bin/csh\fP.
-.TP 8
-.B \-s \fR[\fIrows columns\fP]
-This option indicates that Sun console escape sequences will be used
-instead of the VT100-style \fIxterm\fP escape codes.
-If \fIrows\fP and
-\fIcolumns\fP are given,
-\fI\*n\fP will ask the \fIxterm\fP to resize itself using those values.
-.IP
-Both of the escape sequences used for this option
-(first to obtain the window size and
-second to modify it)
-are subject to \fIxterm\fP's \fBallowWindowOps\fP resource setting.
-The window manager may also choose to disallow the change.
-.IP
-The VT100-style escape sequence used to determine the
-screen size always works for VT100-compatible terminals.
-VT100s have no corresponding way to modify the screensize.
-.TP 8
-.B \-u
-This option indicates that Bourne shell commands should be generated even if
-the user's current shell is not \fI/bin/sh\fP.
-.TP 8
-.B \-v
-This causes \fI\*n\fP to print a version number to the standard output,
-and then exit.
-.PP
-Note that the Sun console escape sequences are recognized
-by XFree86 \fIxterm\fP and
-by \fIdtterm\fP.
-The \fI\*n\fP program may be installed as \fIsunsize\fP,
-which causes makes it assume the \fB\-s\fP option.
-.PP
-The \fIrows\fP and
-\fIcolumns\fP arguments must appear last; though they are normally
-associated with the \fB\-s\fP option, they are parsed separately.
-.SH FILES
-.TP 15
-/etc/termcap
-for the base termcap entry to modify.
-.TP 15
-~/.cshrc
-user's alias for the command.
-.SH ENVIRONMENT
-.TP 15
-SHELL
-.I \*N
-determines the user's current shell by first checking if \fB$SHELL\fP
-is set, and using that.
-Otherwise it determines the user's shell by looking in the password file
-(/etc/passwd).
-Generally Bourne-shell variants (including \fIksh\fP)
-do not modify \fB$SHELL\fP,
-so it is possible for \fI\*n\fP to be confused if one runs
-\fI\*n\fP from a Bourne shell spawned from a C shell.
-.TP 15
-TERM
-.I \*N
-sets this to "xterm" if not already set.
-.TP 15
-TERMCAP
-.I \*N
-sets this variable on systems using termcap,
-e.g., when \*n is linked with the \fItermcap\fP library
-rather than a \fIterminfo\fP library.
-The latter does not provide the complete text for a termcap entry.
-.TP 15
-COLUMNS, LINES
-.I \*N
-sets these variables on systems using terminfo.
-Many applications (including the curses library)
-use those variables when set to override their screensize.
-.SH "SEE ALSO"
-use_env(3x)
-.br
-csh(1), stty(1), tset(1)
-.br
-xterm(1)
-.SH AUTHORS
-Mark Vandevoorde (MIT-Athena), Edward Moy (Berkeley)
-.br
-Thomas Dickey (invisible-island.net).
-.br
-Copyright (c) 1984, 1985 by X Consortium
-.br
-See
-.IR X (7)
-for a complete copyright notice.
diff -r 643b329dcd6c -r ab850bce64f6 usr.bin/resize/resize.c
--- a/usr.bin/resize/resize.c Sat Feb 27 15:29:15 2021 +0000
+++ b/usr.bin/resize/resize.c Sat Feb 27 15:36:39 2021 +0000
@@ -1,8 +1,7 @@
-/* $NetBSD: resize.c,v 1.1 2020/12/27 21:13:18 reinoud Exp $ */
-/* $XTermId: resize.c,v 1.139 2017/05/31 08:58:56 tom Exp $ */
+/* $XTermId: resize.c,v 1.144 2020/06/03 00:26:23 tom Exp $ */
/*
- * Copyright 2003-2015,2017 by Thomas E. Dickey
+ * Copyright 2003-2018,2020 by Thomas E. Dickey
*
* All Rights Reserved
*
@@ -53,32 +52,51 @@
* SOFTWARE.
*/
-/*
- * Extracted version from Xterm tailored for NetBSD
- */
/* resize.c */
#include <stdio.h>
#include <ctype.h>
-#include <stdlib.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <errno.h>
-#include <unistd.h>
-#include <strings.h>
-#include <libgen.h>
-#include <termios.h>
-#include "xstrings.h"
+
+#ifdef RESIZE_ONLY
+#include "resize.h"
+#else
Home |
Main Index |
Thread Index |
Old Index