CVS commit: src/usr.bin/ul
Module Name:src Committed By: abhinav Date: Fri Jun 24 12:03:22 UTC 2016 Modified Files: src/usr.bin/ul: ul.1 Log Message: Add a FILES section and add references to terminfo(3), terminfo(5) in SEE ALSO. Ok by wiz To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/ul/ul.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ul/ul.1 diff -u src/usr.bin/ul/ul.1:1.11 src/usr.bin/ul/ul.1:1.12 --- src/usr.bin/ul/ul.1:1.11 Sat Apr 21 12:27:30 2012 +++ src/usr.bin/ul/ul.1 Fri Jun 24 12:03:22 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: ul.1,v 1.11 2012/04/21 12:27:30 roy Exp $ +.\" $NetBSD: ul.1,v 1.12 2016/06/24 12:03:22 abhinav Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)ul.1 8.1 (Berkeley) 6/6/93 .\" -.Dd April 5, 2012 +.Dd June 23, 2016 .Dt UL 1 .Os .Sh NAME @@ -89,10 +89,17 @@ or as set during the login process by th file (see for example .Xr csh 1 Ns 's Ic setenv ) . .El +.Sh FILES +.Bl -tag -width /usr/share/misc/terminfo -compact +.It Pa /usr/share/misc/terminfo +File containing terminal descriptions. +.El .Sh SEE ALSO .Xr colcrt 1 , .Xr man 1 , -.Xr nroff 1 +.Xr nroff 1 , +.Xr terminfo 3 , +.Xr terminfo 5 .Sh HISTORY The .Nm
CVS commit: src/usr.bin/ul
Module Name:src Committed By: abhinav Date: Thu Jun 23 03:58:13 UTC 2016 Modified Files: src/usr.bin/ul: ul.c Log Message: Make all the global variables and functions static. While there, remove unused variables and function prototypes. Ok from christos To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/usr.bin/ul/ul.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ul/ul.c diff -u src/usr.bin/ul/ul.c:1.18 src/usr.bin/ul/ul.c:1.19 --- src/usr.bin/ul/ul.c:1.18 Mon Jun 13 14:58:57 2016 +++ src/usr.bin/ul/ul.c Thu Jun 23 03:58:13 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ul.c,v 1.18 2016/06/13 14:58:57 abhinav Exp $ */ +/* $NetBSD: ul.c,v 1.19 2016/06/23 03:58:13 abhinav Exp $ */ /* * Copyright (c) 1980, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)ul.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: ul.c,v 1.18 2016/06/13 14:58:57 abhinav Exp $"); +__RCSID("$NetBSD: ul.c,v 1.19 2016/06/23 03:58:13 abhinav Exp $"); #endif /* not lint */ #include @@ -65,34 +65,29 @@ __RCSID("$NetBSD: ul.c,v 1.18 2016/06/13 #define UNDERL 010 /* Ul */ #define BOLD 020 /* Bold */ -struct tinfo *info; -int must_overstrike; -const char *CURS_UP, *CURS_RIGHT, *CURS_LEFT, - *ENTER_STANDOUT, *EXIT_STANDOUT, *ENTER_UNDERLINE, *EXIT_UNDERLINE, - *ENTER_DIM, *ENTER_BOLD, *ENTER_REVERSE, *UNDER_CHAR, *EXIT_ATTRIBUTES; +static int must_overstrike; struct CHAR { char c_mode; char c_char; } ; -size_t col, maxcol; -int mode; -int halfpos; -int upln; -int iflag; - -void filter(FILE *); -void flushln(struct CHAR *, size_t); -void fwd(struct CHAR *, size_t); -void iattr(struct CHAR *); -void initbuf(struct CHAR *, size_t); -void initcap(void); -void outc(int); -int outchar(int); -void overstrike(struct CHAR *); -void reverse(struct CHAR *, size_t); -void setulmode(int); +static size_t col, maxcol; +static int mode; +static int halfpos; +static int upln; +static int iflag; + +static void filter(FILE *); +static void flushln(struct CHAR *, size_t); +static void fwd(struct CHAR *, size_t); +static void iattr(struct CHAR *); +static void initbuf(struct CHAR *, size_t); +static void outc(int); +static int outchar(int); +static void overstrike(struct CHAR *); +static void reverse(struct CHAR *, size_t); +static void setulmode(int); static void alloc_buf(struct CHAR **, size_t *); static void set_mode(void); @@ -147,7 +142,7 @@ main(int argc, char **argv) exit(0); } -void +static void filter(FILE *f) { int c; @@ -270,7 +265,7 @@ filter(FILE *f) free(obuf); } -void +static void flushln(struct CHAR *obuf, size_t obuf_size) { int lastmode; @@ -312,7 +307,7 @@ flushln(struct CHAR *obuf, size_t obuf_s * For terminals that can overstrike, overstrike underlines and bolds. * We don't do anything with halfline ups and downs, or Greek. */ -void +static void overstrike(struct CHAR *obuf) { size_t i; @@ -350,7 +345,7 @@ overstrike(struct CHAR *obuf) } } -void +static void iattr(struct CHAR *obuf) { size_t i; @@ -374,7 +369,7 @@ iattr(struct CHAR *obuf) putchar('\n'); } -void +static void initbuf(struct CHAR *obuf, size_t obuf_size) { @@ -390,7 +385,7 @@ set_mode(void) mode &= ALTSET; } -void +static void fwd(struct CHAR *obuf, size_t obuf_size) { int oldcol, oldmax; @@ -402,7 +397,7 @@ fwd(struct CHAR *obuf, size_t obuf_size) maxcol = oldmax; } -void +static void reverse(struct CHAR *obuf, size_t obuf_size) { upln++; @@ -412,7 +407,7 @@ reverse(struct CHAR *obuf, size_t obuf_s upln++; } -int +static int outchar(int c) { return (putchar(c & 0177)); @@ -420,7 +415,7 @@ outchar(int c) static int curmode = 0; -void +static void outc(int c) { putchar(c); @@ -433,7 +428,7 @@ outc(int c) } } -void +static void setulmode(int newmode) { if (!iflag) {
CVS commit: src/usr.bin/ul
Module Name:src Committed By: abhinav Date: Mon Jun 13 14:58:57 UTC 2016 Modified Files: src/usr.bin/ul: ul.c Log Message: Make the function static in the definition (prototype was already declared static). Missed in my last commit. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/usr.bin/ul/ul.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ul/ul.c diff -u src/usr.bin/ul/ul.c:1.17 src/usr.bin/ul/ul.c:1.18 --- src/usr.bin/ul/ul.c:1.17 Sun Jun 12 13:29:29 2016 +++ src/usr.bin/ul/ul.c Mon Jun 13 14:58:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ul.c,v 1.17 2016/06/12 13:29:29 abhinav Exp $ */ +/* $NetBSD: ul.c,v 1.18 2016/06/13 14:58:57 abhinav Exp $ */ /* * Copyright (c) 1980, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)ul.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: ul.c,v 1.17 2016/06/12 13:29:29 abhinav Exp $"); +__RCSID("$NetBSD: ul.c,v 1.18 2016/06/13 14:58:57 abhinav Exp $"); #endif /* not lint */ #include @@ -507,7 +507,7 @@ setulmode(int newmode) * Reallocates the buffer pointed to by *buf and sets * the newly allocated set of bytes to 0. */ -void +static void alloc_buf(struct CHAR **buf, size_t *size) { size_t osize = *size;
CVS commit: src/usr.bin/ul
Module Name:src Committed By: abhinav Date: Sun Jun 12 14:28:26 UTC 2016 Modified Files: src/usr.bin/ul: Makefile Log Message: Add libutil to the DPADD variable. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.bin/ul/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ul/Makefile diff -u src/usr.bin/ul/Makefile:1.7 src/usr.bin/ul/Makefile:1.8 --- src/usr.bin/ul/Makefile:1.7 Sun Jun 12 13:29:29 2016 +++ src/usr.bin/ul/Makefile Sun Jun 12 14:28:26 2016 @@ -1,8 +1,8 @@ -# $NetBSD: Makefile,v 1.7 2016/06/12 13:29:29 abhinav Exp $ +# $NetBSD: Makefile,v 1.8 2016/06/12 14:28:26 abhinav Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 PROG= ul -DPADD= ${LIBTERMINFO} +DPADD= ${LIBTERMINFO} ${LIBUTIL} LDADD= -lterminfo -lutil .include
CVS commit: src/usr.bin/ul
Module Name:src Committed By: abhinav Date: Sun Jun 12 13:29:29 UTC 2016 Modified Files: src/usr.bin/ul: Makefile ul.c Log Message: Fix a buffer overflow when reading from files containing extra long lines. Instead of using a statically allocated buffer, manage the buffer at run-time and reallocate as needed. It was dumping core for following two cases: man evrpc | ul man xdm | ul While there, also remove __P macro from function prototypes. Ok from Christos. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.bin/ul/Makefile cvs rdiff -u -r1.16 -r1.17 src/usr.bin/ul/ul.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ul/Makefile diff -u src/usr.bin/ul/Makefile:1.6 src/usr.bin/ul/Makefile:1.7 --- src/usr.bin/ul/Makefile:1.6 Wed Feb 3 15:34:46 2010 +++ src/usr.bin/ul/Makefile Sun Jun 12 13:29:29 2016 @@ -1,8 +1,8 @@ -# $NetBSD: Makefile,v 1.6 2010/02/03 15:34:46 roy Exp $ +# $NetBSD: Makefile,v 1.7 2016/06/12 13:29:29 abhinav Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 PROG= ul DPADD= ${LIBTERMINFO} -LDADD= -lterminfo +LDADD= -lterminfo -lutil .include Index: src/usr.bin/ul/ul.c diff -u src/usr.bin/ul/ul.c:1.16 src/usr.bin/ul/ul.c:1.17 --- src/usr.bin/ul/ul.c:1.16 Tue Mar 20 20:34:59 2012 +++ src/usr.bin/ul/ul.c Sun Jun 12 13:29:29 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ul.c,v 1.16 2012/03/20 20:34:59 matt Exp $ */ +/* $NetBSD: ul.c,v 1.17 2016/06/12 13:29:29 abhinav Exp $ */ /* * Copyright (c) 1980, 1993 @@ -39,14 +39,16 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)ul.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: ul.c,v 1.16 2012/03/20 20:34:59 matt Exp $"); +__RCSID("$NetBSD: ul.c,v 1.17 2016/06/12 13:29:29 abhinav Exp $"); #endif /* not lint */ +#include #include #include #include #include #include +#include #define IESC '\033' #define SO '\016' @@ -74,25 +76,25 @@ struct CHAR { char c_char; } ; -struct CHAR obuf[MAXBUF]; -int col, maxcol; +size_t col, maxcol; int mode; int halfpos; int upln; int iflag; -int main __P((int, char **)); -void filter __P((FILE *)); -void flushln __P((void)); -void fwd __P((void)); -void iattr __P((void)); -void initbuf __P((void)); -void initcap __P((void)); -void outc __P((int)); -int outchar __P((int)); -void overstrike __P((void)); -void reverse __P((void)); -void setulmode __P((int)); +void filter(FILE *); +void flushln(struct CHAR *, size_t); +void fwd(struct CHAR *, size_t); +void iattr(struct CHAR *); +void initbuf(struct CHAR *, size_t); +void initcap(void); +void outc(int); +int outchar(int); +void overstrike(struct CHAR *); +void reverse(struct CHAR *, size_t); +void setulmode(int); +static void alloc_buf(struct CHAR **, size_t *); +static void set_mode(void); #define PRINT(s) if (s == NULL) /* void */; else tputs(s, 1, outchar) @@ -128,19 +130,19 @@ main(int argc, char **argv) setupterm(termtype, 0, NULL); if ((over_strike && enter_bold_mode == NULL) || (transparent_underline && enter_underline_mode == NULL && - underline_char == NULL)) - initbuf(); + underline_char == NULL)) { + set_mode(); + } if (optind == argc) filter(stdin); - else for (; optindmaxcol) maxcol = col; + if (col >= obuf_size) + alloc_buf(, _size); continue; case '\r': @@ -187,7 +194,7 @@ filter(FILE *f) halfpos--; } else { halfpos = 0; -reverse(); +reverse(obuf, obuf_size); } continue; @@ -200,12 +207,12 @@ filter(FILE *f) halfpos++; } else { halfpos = 0; -fwd(); +fwd(obuf, obuf_size); } continue; case FREV: - reverse(); + reverse(obuf, obuf_size); continue; default: @@ -214,7 +221,6 @@ filter(FILE *f) IESC, c); exit(1); } - continue; case '_': if (obuf[col].c_char) @@ -225,14 +231,16 @@ filter(FILE *f) col++; if (col > maxcol) maxcol = col; + if (col >= obuf_size) + alloc_buf(, _size); continue; case '\n': - flushln(); + flushln(obuf, obuf_size); continue; case '\f': - flushln(); + flushln(obuf, obuf_size); putchar('\f'); continue; @@ -252,17 +260,21 @@ filter(FILE *f) col++; if (col > maxcol) maxcol = col; + if (col >= obuf_size) + alloc_buf(, _size); continue; } if (maxcol) -
CVS commit: src/usr.bin/ul
Module Name:src Committed By: lukem Date: Tue Apr 14 05:46:25 UTC 2009 Modified Files: src/usr.bin/ul: ul.c Log Message: Fix -Wcast-qual issues To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/usr.bin/ul/ul.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ul/ul.c diff -u src/usr.bin/ul/ul.c:1.13 src/usr.bin/ul/ul.c:1.14 --- src/usr.bin/ul/ul.c:1.13 Mon Jul 21 14:19:27 2008 +++ src/usr.bin/ul/ul.c Tue Apr 14 05:46:25 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ul.c,v 1.13 2008/07/21 14:19:27 lukem Exp $ */ +/* $NetBSD: ul.c,v 1.14 2009/04/14 05:46:25 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = @(#)ul.c 8.1 (Berkeley) 6/6/93; #endif -__RCSID($NetBSD: ul.c,v 1.13 2008/07/21 14:19:27 lukem Exp $); +__RCSID($NetBSD: ul.c,v 1.14 2009/04/14 05:46:25 lukem Exp $); #endif /* not lint */ #include stdio.h @@ -65,7 +65,7 @@ struct tinfo *info; int must_use_uc, must_overstrike; -char *CURS_UP, *CURS_RIGHT, *CURS_LEFT, +const char *CURS_UP, *CURS_RIGHT, *CURS_LEFT, *ENTER_STANDOUT, *EXIT_STANDOUT, *ENTER_UNDERLINE, *EXIT_UNDERLINE, *ENTER_DIM, *ENTER_BOLD, *ENTER_REVERSE, *UNDER_CHAR, *EXIT_ATTRIBUTES; @@ -103,7 +103,7 @@ char **argv; { int c; - char *termtype; + const char *termtype; FILE *f; termtype = getenv(TERM);