Sun Aug 28 07:49:16 2011 UTC ()
use strpct(3) from libutil.


(christos)
diff -r1.32 -r1.33 src/bin/csh/Makefile
diff -r1.8 -r0 src/bin/csh/strpct.c
diff -r1.17 -r1.18 src/bin/csh/time.c

cvs diff -r1.32 -r1.33 src/bin/csh/Makefile (expand / switch to unified diff)

--- src/bin/csh/Makefile 2011/08/25 15:44:51 1.32
+++ src/bin/csh/Makefile 2011/08/28 07:49:16 1.33
@@ -1,29 +1,29 @@ @@ -1,29 +1,29 @@
1# $NetBSD: Makefile,v 1.32 2011/08/25 15:44:51 joerg Exp $ 1# $NetBSD: Makefile,v 1.33 2011/08/28 07:49:16 christos Exp $
2# @(#)Makefile 8.1 (Berkeley) 5/31/93 2# @(#)Makefile 8.1 (Berkeley) 5/31/93
3# 3#
4# C Shell with process control; VM/UNIX VAX Makefile 4# C Shell with process control; VM/UNIX VAX Makefile
5# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria 5# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria
6# 6#
7# To profile, put -DPROF in DFLAGS and -pg in COPTS, and recompile. 7# To profile, put -DPROF in DFLAGS and -pg in COPTS, and recompile.
8 8
9.include <bsd.own.mk> 9.include <bsd.own.mk>
10 10
11PROG= csh 11PROG= csh
12DFLAGS=-DBUILTIN -DFILEC -DNLS -DSHORT_STRINGS 12DFLAGS=-DBUILTIN -DFILEC -DNLS -DSHORT_STRINGS
13CPPFLAGS+=-I${.CURDIR} -I. ${DFLAGS} 13CPPFLAGS+=-I${.CURDIR} -I. ${DFLAGS}
14SRCS= alloc.c char.c const.c csh.c dir.c dol.c err.c exec.c exp.c file.c \ 14SRCS= alloc.c char.c const.c csh.c dir.c dol.c err.c exec.c exp.c file.c \
15 func.c glob.c hist.c init.c lex.c misc.c parse.c printf.c proc.c \ 15 func.c glob.c hist.c init.c lex.c misc.c parse.c printf.c proc.c \
16 sem.c set.c str.c strpct.c time.c 16 sem.c set.c str.c time.c
17.PATH: ${NETBSDSRCDIR}/usr.bin/printf 17.PATH: ${NETBSDSRCDIR}/usr.bin/printf
18 18
19MLINKS= csh.1 limit.1 csh.1 alias.1 csh.1 bg.1 csh.1 dirs.1 csh.1 fg.1 \ 19MLINKS= csh.1 limit.1 csh.1 alias.1 csh.1 bg.1 csh.1 dirs.1 csh.1 fg.1 \
20 csh.1 foreach.1 csh.1 history.1 csh.1 jobs.1 csh.1 popd.1 \ 20 csh.1 foreach.1 csh.1 history.1 csh.1 jobs.1 csh.1 popd.1 \
21 csh.1 pushd.1 csh.1 rehash.1 csh.1 repeat.1 csh.1 suspend.1 \ 21 csh.1 pushd.1 csh.1 rehash.1 csh.1 repeat.1 csh.1 suspend.1 \
22 csh.1 stop.1 csh.1 source.1 22 csh.1 stop.1 csh.1 source.1
23 23
24DPSRCS+= errnum.h const.h 24DPSRCS+= errnum.h const.h
25CLEANFILES+= errnum.h const.h 25CLEANFILES+= errnum.h const.h
26 26
27errnum.h: err.c 27errnum.h: err.c
28 ${_MKTARGET_CREATE} 28 ${_MKTARGET_CREATE}
29 rm -f ${.TARGET} 29 rm -f ${.TARGET}
@@ -45,17 +45,19 @@ const.h: const.c @@ -45,17 +45,19 @@ const.h: const.c
45 sort >> ${.TARGET} 45 sort >> ${.TARGET}
46 46
47.if make(install) 47.if make(install)
48SUBDIR+=USD.doc 48SUBDIR+=USD.doc
49.endif 49.endif
50 50
51# XXX Only GCC 4.1 problem 51# XXX Only GCC 4.1 problem
52.if defined(HAVE_GCC) && ${HAVE_GCC} == 4 && ${MACHINE_ARCH} == "vax" 52.if defined(HAVE_GCC) && ${HAVE_GCC} == 4 && ${MACHINE_ARCH} == "vax"
53COPTS.parse.c+= -O0 53COPTS.parse.c+= -O0
54.endif 54.endif
55COPTS.err.c = -Wno-format-nonliteral 55COPTS.err.c = -Wno-format-nonliteral
56COPTS.printf.c = -Wno-format-nonliteral 56COPTS.printf.c = -Wno-format-nonliteral
57COPTS.proc.c = -Wno-format-nonliteral 57COPTS.proc.c = -Wno-format-nonliteral
58COPTS.strpct.c = -Wno-format-nonliteral 58
 59LDADD+=-lutil
 60DPADD+=${LIBUTIL}
59 61
60.include <bsd.prog.mk> 62.include <bsd.prog.mk>
61.include <bsd.subdir.mk> 63.include <bsd.subdir.mk>

File Deleted: src/bin/csh/Attic/strpct.c

cvs diff -r1.17 -r1.18 src/bin/csh/time.c (expand / switch to unified diff)

--- src/bin/csh/time.c 2008/02/24 05:20:17 1.17
+++ src/bin/csh/time.c 2011/08/28 07:49:16 1.18
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: time.c,v 1.17 2008/02/24 05:20:17 dholland Exp $ */ 1/* $NetBSD: time.c,v 1.18 2011/08/28 07:49:16 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1980, 1991, 1993 4 * Copyright (c) 1980, 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,43 +24,43 @@ @@ -24,43 +24,43 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 5/31/93"; 35static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 5/31/93";
36#else 36#else
37__RCSID("$NetBSD: time.c,v 1.17 2008/02/24 05:20:17 dholland Exp $"); 37__RCSID("$NetBSD: time.c,v 1.18 2011/08/28 07:49:16 christos Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#ifndef NOT_CSH 41#ifndef NOT_CSH
42#include <sys/types.h> 42#include <sys/types.h>
43#include <stdarg.h> 43#include <stdarg.h>
44#include "csh.h" 44#include "csh.h"
45#include "extern.h" 45#include "extern.h"
46#endif 46#endif
 47#include <util.h>
47 48
48/* 49/*
49 * C Shell - routines handling process timing and niceing 50 * C Shell - routines handling process timing and niceing
50 */ 51 */
51static void pdeltat(FILE *, struct timeval *, struct timeval *); 52static void pdeltat(FILE *, struct timeval *, struct timeval *);
52static void pcsecs(FILE *, long); 53static void pcsecs(FILE *, long);
53extern char *strpct(u_long, u_long, u_int); 
54 54
55#ifndef NOT_CSH 55#ifndef NOT_CSH
56void 56void
57settimes(void) 57settimes(void)
58{ 58{
59 struct rusage ruch; 59 struct rusage ruch;
60 60
61 (void)gettimeofday(&time0, NULL); 61 (void)gettimeofday(&time0, NULL);
62 (void)getrusage(RUSAGE_SELF, &ru0); 62 (void)getrusage(RUSAGE_SELF, &ru0);
63 (void)getrusage(RUSAGE_CHILDREN, &ruch); 63 (void)getrusage(RUSAGE_CHILDREN, &ruch);
64 ruadd(&ru0, &ruch); 64 ruadd(&ru0, &ruch);
65} 65}
66 66
@@ -176,27 +176,29 @@ prusage(FILE *fp, struct rusage *r0, str @@ -176,27 +176,29 @@ prusage(FILE *fp, struct rusage *r0, str
176 (r0->ru_ixrss + r0->ru_idrss + r0->ru_isrss)) / t)); 176 (r0->ru_ixrss + r0->ru_idrss + r0->ru_isrss)) / t));
177 break; 177 break;
178 case 'M': /* max. Resident Set Size */ 178 case 'M': /* max. Resident Set Size */
179 (void)fprintf(fp, "%ld", r1->ru_maxrss / 2L); 179 (void)fprintf(fp, "%ld", r1->ru_maxrss / 2L);
180 break; 180 break;
181 case 'O': /* FS blocks out */ 181 case 'O': /* FS blocks out */
182 (void)fprintf(fp, "%ld", r1->ru_oublock - r0->ru_oublock); 182 (void)fprintf(fp, "%ld", r1->ru_oublock - r0->ru_oublock);
183 break; 183 break;
184 case 'P': /* percent time spent running */ 184 case 'P': /* percent time spent running */
185 /* check if it did not run at all */ 185 /* check if it did not run at all */
186 if (ms == 0) { 186 if (ms == 0) {
187 (void)fputs("0.0%", fp); 187 (void)fputs("0.0%", fp);
188 } else { 188 } else {
189 (void)fputs(strpct((ulong)t, (ulong)ms, 1), fp); 189 char pb[32];
 190 (void)fputs(strpct(pb, sizeof(pb), t, ms, 1), fp);
 191 (void)fputc('%', fp);
190 } 192 }
191 break; 193 break;
192 case 'R': /* page reclaims */ 194 case 'R': /* page reclaims */
193 (void)fprintf(fp, "%ld", r1->ru_minflt - r0->ru_minflt); 195 (void)fprintf(fp, "%ld", r1->ru_minflt - r0->ru_minflt);
194 break; 196 break;
195 case 'S': /* system CPU time used */ 197 case 'S': /* system CPU time used */
196 pdeltat(fp, &r1->ru_stime, &r0->ru_stime); 198 pdeltat(fp, &r1->ru_stime, &r0->ru_stime);
197 break; 199 break;
198 case 'U': /* user CPU time used */ 200 case 'U': /* user CPU time used */
199 pdeltat(fp, &r1->ru_utime, &r0->ru_utime); 201 pdeltat(fp, &r1->ru_utime, &r0->ru_utime);
200 break; 202 break;
201 case 'W': /* number of swaps */ 203 case 'W': /* number of swaps */
202 i = r1->ru_nswap - r0->ru_nswap; 204 i = r1->ru_nswap - r0->ru_nswap;