CVS commit: src/doc
Module Name:src Committed By: darcy Date: Tue Jul 31 20:33:06 UTC 2018 Modified Files: src/doc: TODO.npf Log Message: Suggest command line variables. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/doc/TODO.npf Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/TODO.npf diff -u src/doc/TODO.npf:1.3 src/doc/TODO.npf:1.4 --- src/doc/TODO.npf:1.3 Tue Jul 31 19:43:24 2018 +++ src/doc/TODO.npf Tue Jul 31 20:33:06 2018 @@ -53,3 +53,5 @@ Another TODO list is available here: -- support large IPv6 options, as explained here: http://mail-index.netbsd.org/tech-net/2018/04/08/msg006786.html But it's not a big problem - perhaps we don't care at all. + +-- add command line variables. See -D option in pf.
CVS commit: src/bin/cp
Module Name:src Committed By: darcy Date: Tue Jul 17 13:04:58 UTC 2018 Modified Files: src/bin/cp: utils.c Log Message: Re-order the code to short circuit all the opens and closes if linking. Discussed on tech-userlevel and agreed to by christos@. Testing suggests an order of magnitude improvement when linking. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/bin/cp/utils.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/cp/utils.c diff -u src/bin/cp/utils.c:1.45 src/bin/cp/utils.c:1.46 --- src/bin/cp/utils.c:1.45 Mon Feb 29 04:22:21 2016 +++ src/bin/cp/utils.c Tue Jul 17 13:04:58 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: utils.c,v 1.45 2016/02/29 04:22:21 mrg Exp $ */ +/* $NetBSD: utils.c,v 1.46 2018/07/17 13:04:58 darcy Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94"; #else -__RCSID("$NetBSD: utils.c,v 1.45 2016/02/29 04:22:21 mrg Exp $"); +__RCSID("$NetBSD: utils.c,v 1.46 2018/07/17 13:04:58 darcy Exp $"); #endif #endif /* not lint */ @@ -99,7 +99,17 @@ copy_file(FTSENT *entp, int dne) int ch, checkch, from_fd, rcount, rval, to_fd, tolnk, wcount; char *p; off_t ptotal = 0; - + + /* if hard linking then simply link and return */ + if (lflag) { + (void)unlink(to.p_path); + if (link(entp->fts_path, to.p_path)) { + warn("%s", to.p_path); + return (1); + } + return (0); + } + if ((from_fd = open(entp->fts_path, O_RDONLY, 0)) == -1) { warn("%s", entp->fts_path); return (1); @@ -164,18 +174,6 @@ copy_file(FTSENT *entp, int dne) rval = 0; - /* if hard linking then simply close the open fds, link and return */ - if (lflag) { - (void)close(from_fd); - (void)close(to_fd); - (void)unlink(to.p_path); - if (link(entp->fts_path, to.p_path)) { - warn("%s", to.p_path); - return (1); - } - return (0); - } - /* * There's no reason to do anything other than close the file * now if it's empty, so let's not bother.
CVS commit: src/sys/arch/amd64/conf
Module Name:src Committed By: darcy Date: Fri Jun 22 02:51:17 UTC 2018 Modified Files: src/sys/arch/amd64/conf: XEN3_DOM0 Log Message: PR port-xen/50446 With approval from bouyer@ and acceptance, sometimes grudgingly, from others I have removed the AGP lines from the XEN3_DOM0 config. I have left a note in the PR suggesting that if it ever gets a proper fix that those lines can be considered for re-inclusion. To generate a diff of this commit: cvs rdiff -u -r1.151 -r1.152 src/sys/arch/amd64/conf/XEN3_DOM0 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/conf/XEN3_DOM0 diff -u src/sys/arch/amd64/conf/XEN3_DOM0:1.151 src/sys/arch/amd64/conf/XEN3_DOM0:1.152 --- src/sys/arch/amd64/conf/XEN3_DOM0:1.151 Thu Jun 7 13:36:28 2018 +++ src/sys/arch/amd64/conf/XEN3_DOM0 Fri Jun 22 02:51:17 2018 @@ -1,4 +1,4 @@ -# $NetBSD: XEN3_DOM0,v 1.151 2018/06/07 13:36:28 thorpej Exp $ +# $NetBSD: XEN3_DOM0,v 1.152 2018/06/22 02:51:17 darcy Exp $ include "arch/amd64/conf/std.xen" @@ -10,7 +10,7 @@ options INCLUDE_CONFIG_FILE # embed con #options UVMHIST_PRINT #options SYSCALL_DEBUG -#ident "XEN3_DOM0-$Revision: 1.151 $" +#ident "XEN3_DOM0-$Revision: 1.152 $" maxusers 32 # estimated number of users @@ -256,13 +256,10 @@ ichlpcib* at pci? dev ? function ? # Int # watchdog and SpeedStep support pcib* at pci? dev ? function ? # PCI-ISA bridges pchb* at pci? dev ? function ? # PCI-Host bridges -options AGP_X86 ppb* at pci? dev ? function ? # PCI-PCI bridges # XXX 'puc's aren't really bridges, but there's no better place for them here puc* at pci? dev ? function ? # PCI "universal" comm. cards -agp* at pchb? - # ISA bus support isa0 at ichlpcib? isa0 at pcib?
CVS commit: src/tests/lib/libc
Module Name:src Committed By: darcy Date: Fri Aug 26 01:31:43 UTC 2016 Modified Files: src/tests/lib/libc/net/getaddrinfo: Makefile src/tests/lib/libc/regex: Makefile Log Message: Replace MKMAN with NOMAN as suggested by christos@. Allows userland to build when building man pages. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/net/getaddrinfo/Makefile cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/regex/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/net/getaddrinfo/Makefile diff -u src/tests/lib/libc/net/getaddrinfo/Makefile:1.1 src/tests/lib/libc/net/getaddrinfo/Makefile:1.2 --- src/tests/lib/libc/net/getaddrinfo/Makefile:1.1 Wed Jan 12 02:58:40 2011 +++ src/tests/lib/libc/net/getaddrinfo/Makefile Fri Aug 26 01:31:43 2016 @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.1 2011/01/12 02:58:40 pgoyette Exp $ +# $NetBSD: Makefile,v 1.2 2016/08/26 01:31:43 darcy Exp $ -MKMAN= no +NOMAN= .include Index: src/tests/lib/libc/regex/Makefile diff -u src/tests/lib/libc/regex/Makefile:1.9 src/tests/lib/libc/regex/Makefile:1.10 --- src/tests/lib/libc/regex/Makefile:1.9 Fri Aug 24 20:24:40 2012 +++ src/tests/lib/libc/regex/Makefile Fri Aug 26 01:31:43 2016 @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.9 2012/08/24 20:24:40 jmmv Exp $ +# $NetBSD: Makefile,v 1.10 2016/08/26 01:31:43 darcy Exp $ -MKMAN= no +NOMAN= .include
CVS commit: src/etc
Module Name:src Committed By: darcy Date: Sat Nov 28 14:20:32 UTC 2015 Modified Files: src/etc: weekly Log Message: Of course we can always not do something. Doesn't mean that we "can't" (or "cannot"). In any case make the messages consistent and move the period to inside the quotes. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/etc/weekly Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/etc/weekly diff -u src/etc/weekly:1.30 src/etc/weekly:1.31 --- src/etc/weekly:1.30 Wed Mar 4 14:54:38 2015 +++ src/etc/weekly Sat Nov 28 14:20:32 2015 @@ -1,6 +1,6 @@ #!/bin/sh - # -# $NetBSD: weekly,v 1.30 2015/03/04 14:54:38 christos Exp $ +# $NetBSD: weekly,v 1.31 2015/11/28 14:20:32 darcy Exp $ # from: @(#)weekly 8.2 (Berkeley) 1/2/94 # @@ -31,7 +31,7 @@ WEEKLYDIR=$(mktemp -d -t _weekly) || exi trap "/bin/rm -rf $WEEKLYDIR ; exit 0" EXIT INT QUIT PIPE if ! cd "$WEEKLYDIR"; then - echo "Can not cd to $WEEKLYDIR". + echo "Can't cd to $WEEKLYDIR; aborting." exit 1 fi
CVS commit: src/etc
Module Name:src Committed By: darcy Date: Sat Dec 17 12:27:42 UTC 2011 Modified Files: src/etc: daily src/etc/defaults: daily.conf Log Message: Add option to include daily insecurity output in daily output. PR bin/17029 To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/etc/daily cvs rdiff -u -r1.14 -r1.15 src/etc/defaults/daily.conf Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/etc/daily diff -u src/etc/daily:1.77 src/etc/daily:1.78 --- src/etc/daily:1.77 Mon Dec 27 03:38:52 2010 +++ src/etc/daily Sat Dec 17 12:27:42 2011 @@ -1,6 +1,6 @@ #!/bin/sh - # -# $NetBSD: daily,v 1.77 2010/12/27 03:38:52 christos Exp $ +# $NetBSD: daily,v 1.78 2011/12/17 12:27:42 darcy Exp $ # @(#)daily 8.2 (Berkeley) 1/25/94 # @@ -272,8 +272,13 @@ if checkyesno run_security; then fi fi if [ -s $SECOUT ]; then - mail -s $host daily insecurity output for $date \ - $MAILTO $SECOUT + if checkyesno separate_security_email; then + mail -s $host daily insecurity output for $date $MAILTO $SECOUT + else + echo + echo $host daily insecurity output for $date: + cat $SECOUT + fi fi fi Index: src/etc/defaults/daily.conf diff -u src/etc/defaults/daily.conf:1.14 src/etc/defaults/daily.conf:1.15 --- src/etc/defaults/daily.conf:1.14 Fri Feb 5 16:29:02 2010 +++ src/etc/defaults/daily.conf Sat Dec 17 12:27:42 2011 @@ -1,4 +1,4 @@ -# $NetBSD: daily.conf,v 1.14 2010/02/05 16:29:02 jmmv Exp $ +# $NetBSD: daily.conf,v 1.15 2011/12/17 12:27:42 darcy Exp $ # # /etc/defaults/daily.conf -- # default configuration of /etc/daily.conf @@ -27,6 +27,7 @@ run_fsck=NO run_fsck_flags= run_rdist=YES run_security=YES +separate_security_email=YES run_skeyaudit=YES fetch_pkg_vulnerabilities=NO
CVS commit: src/etc
Module Name:src Committed By: darcy Date: Mon Nov 21 20:56:21 UTC 2011 Modified Files: src/etc/defaults: rc.conf src/etc/rc.d: pf Log Message: Allow pf flags to be specified in rc.conf. Add default to defaults/rc.d as suggested by lukem@ To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/etc/defaults/rc.conf cvs rdiff -u -r1.9 -r1.10 src/etc/rc.d/pf Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/etc/defaults/rc.conf diff -u src/etc/defaults/rc.conf:1.115 src/etc/defaults/rc.conf:1.116 --- src/etc/defaults/rc.conf:1.115 Tue Sep 6 21:32:29 2011 +++ src/etc/defaults/rc.conf Mon Nov 21 20:56:21 2011 @@ -1,4 +1,4 @@ -# $NetBSD: rc.conf,v 1.115 2011/09/06 21:32:29 riz Exp $ +# $NetBSD: rc.conf,v 1.116 2011/11/21 20:56:21 darcy Exp $ # # /etc/defaults/rc.conf -- # default configuration of /etc/rc.conf @@ -167,7 +167,7 @@ ipnat=NO # uses /etc/ipnat.conf ipfs=NO ipfs_flags= # save/load ipnat and ipf states ipsec=NO # uses /etc/ipsec.conf ipmon=NO ipmon_flags=-Dns # syslog ipfilter messages -pf=NO pf_rules=/etc/pf.conf +pf=NO pf_rules=/etc/pf.conf pf_flags= pflogd=NO ftp_proxy=NO racoon=NO # IKE daemon Index: src/etc/rc.d/pf diff -u src/etc/rc.d/pf:1.9 src/etc/rc.d/pf:1.10 --- src/etc/rc.d/pf:1.9 Sat Nov 22 20:23:33 2008 +++ src/etc/rc.d/pf Mon Nov 21 20:56:21 2011 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: pf,v 1.9 2008/11/22 20:23:33 tsutsui Exp $ +# $NetBSD: pf,v 1.10 2011/11/21 20:56:21 darcy Exp $ # # PROVIDE: pf @@ -35,11 +35,11 @@ pf_start() # The pf_boot script has enabled pf already. if [ $autoboot != yes ]; then - /sbin/pfctl -q -e + /sbin/pfctl -q ${pf_flags} -e fi if [ -f ${pf_rules} ]; then - /sbin/pfctl -q -f ${pf_rules} + /sbin/pfctl -q ${pf_flags} -f ${pf_rules} else warn ${pf_rules} not found; no pf rules loaded. fi @@ -48,14 +48,14 @@ pf_start() pf_stop() { echo Disabling pf firewall. - /sbin/pfctl -q -Fa -d + /sbin/pfctl -q ${pf_flags} -Fa -d } pf_reload() { echo Reloading pf rules. if [ -f ${pf_rules} ]; then - /sbin/pfctl -q -f ${pf_rules} + /sbin/pfctl -q ${pf_flags} -f ${pf_rules} else warn ${pf_rules} not found; no pf rules loaded. fi @@ -63,7 +63,7 @@ pf_reload() pf_status() { - /sbin/pfctl -s info + /sbin/pfctl ${pf_flags} -s info } load_rc_config $name
CVS commit: src/bin/cp
Module Name:src Committed By: darcy Date: Sun Feb 6 12:37:49 UTC 2011 Modified Files: src/bin/cp: cp.1 cp.c extern.h utils.c Log Message: Add -l option to copy a tree as links. Non-standard option similar to Gnutools cp(1) Approved by core. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/bin/cp/cp.1 cvs rdiff -u -r1.54 -r1.55 src/bin/cp/cp.c cvs rdiff -u -r1.15 -r1.16 src/bin/cp/extern.h cvs rdiff -u -r1.38 -r1.39 src/bin/cp/utils.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/cp/cp.1 diff -u src/bin/cp/cp.1:1.35 src/bin/cp/cp.1:1.36 --- src/bin/cp/cp.1:1.35 Mon Jan 24 07:22:57 2011 +++ src/bin/cp/cp.1 Sun Feb 6 12:37:48 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: cp.1,v 1.35 2011/01/24 07:22:57 wiz Exp $ +.\ $NetBSD: cp.1,v 1.36 2011/02/06 12:37:48 darcy Exp $ .\ .\ Copyright (c) 1989, 1990, 1993, 1994 .\ The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\ .\ @(#)cp.1 8.3 (Berkeley) 4/18/94 .\ -.Dd December 21, 2010 +.Dd February 6, 2010 .Dt CP 1 .Os .Sh NAME @@ -45,7 +45,7 @@ .Op Fl H | Fl L | Fl P .Oc .Op Fl f | i -.Op Fl aNpv +.Op Fl alNpv .Ar source_file target_file .Nm cp .Oo @@ -53,7 +53,7 @@ .Op Fl H | Fl L | Fl P .Oc .Op Fl f | i -.Op Fl aNpv +.Op Fl alNpv .Ar source_file ... target_directory .Sh DESCRIPTION In the first synopsis form, the @@ -104,6 +104,9 @@ If the .Fl R option is specified, all symbolic links are followed. +.It Fl l +Create hard links to regular files in a hierarchy instead of copying. +The -l option is expected to behave similar to cp(1) in GNU coreutils. .It Fl N When used with .Fl p , Index: src/bin/cp/cp.c diff -u src/bin/cp/cp.c:1.54 src/bin/cp/cp.c:1.55 --- src/bin/cp/cp.c:1.54 Tue Dec 21 20:56:01 2010 +++ src/bin/cp/cp.c Sun Feb 6 12:37:49 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cp.c,v 1.54 2010/12/21 20:56:01 christos Exp $ */ +/* $NetBSD: cp.c,v 1.55 2011/02/06 12:37:49 darcy Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = @(#)cp.c 8.5 (Berkeley) 4/29/95; #else -__RCSID($NetBSD: cp.c,v 1.54 2010/12/21 20:56:01 christos Exp $); +__RCSID($NetBSD: cp.c,v 1.55 2011/02/06 12:37:49 darcy Exp $); #endif #endif /* not lint */ @@ -86,7 +86,7 @@ PATH_T to = { .p_end = to.p_path, .target_end = empty }; uid_t myuid; -int Hflag, Lflag, Rflag, Pflag, fflag, iflag, pflag, rflag, vflag, Nflag; +int Hflag, Lflag, Rflag, Pflag, fflag, iflag, lflag, pflag, rflag, vflag, Nflag; mode_t myumask; enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE }; @@ -106,7 +106,7 @@ (void)setlocale(LC_ALL, ); Hflag = Lflag = Pflag = Rflag = 0; - while ((ch = getopt(argc, argv, HLNPRfaiprv)) != -1) + while ((ch = getopt(argc, argv, HLNPRfailprv)) != -1) switch (ch) { case 'H': Hflag = 1; @@ -140,6 +140,9 @@ iflag = isatty(fileno(stdin)); fflag = 0; break; + case 'l': + lflag = 1; + break; case 'p': pflag = 1; break; Index: src/bin/cp/extern.h diff -u src/bin/cp/extern.h:1.15 src/bin/cp/extern.h:1.16 --- src/bin/cp/extern.h:1.15 Sun Jul 16 16:22:24 2006 +++ src/bin/cp/extern.h Sun Feb 6 12:37:49 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.15 2006/07/16 16:22:24 jschauma Exp $ */ +/* $NetBSD: extern.h,v 1.16 2011/02/06 12:37:49 darcy Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -42,7 +42,7 @@ extern PATH_T to; extern uid_t myuid; -extern int Rflag, rflag, Hflag, Lflag, Pflag, fflag, iflag, pflag, Nflag; +extern int Rflag, rflag, Hflag, Lflag, Pflag, fflag, iflag, lflag, pflag, Nflag; extern mode_t myumask; #include sys/cdefs.h Index: src/bin/cp/utils.c diff -u src/bin/cp/utils.c:1.38 src/bin/cp/utils.c:1.39 --- src/bin/cp/utils.c:1.38 Tue Jan 4 10:35:10 2011 +++ src/bin/cp/utils.c Sun Feb 6 12:37:49 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: utils.c,v 1.38 2011/01/04 10:35:10 wiz Exp $ */ +/* $NetBSD: utils.c,v 1.39 2011/02/06 12:37:49 darcy Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = @(#)utils.c 8.3 (Berkeley) 4/1/94; #else -__RCSID($NetBSD: utils.c,v 1.38 2011/01/04 10:35:10 wiz Exp $); +__RCSID($NetBSD: utils.c,v 1.39 2011/02/06 12:37:49 darcy Exp $); #endif #endif /* not lint */ @@ -145,11 +145,23 @@ rval = 0; + /* if hard linking then simply close the open fds, link and return */ + if (lflag) { + (void)close(from_fd); + (void)close(to_fd); + (void)unlink(to.p_path); + if (link(entp-fts_path, to.p_path)) { + warn(%s, to.p_path); + return (1); + } + return (0); + } + /* NOTREACHED */ + /* * There's no reason to do anything other than close the file * now if it's empty, so let's not bother. */ - if (fs-st_size 0) { /* * Mmap and write if less than 8M (the limit is so @@ -215,8 +227,9 @@ } } + (void)close(from_fd); + if (rval == 1) { - (void)close(from_fd); (void)close(to_fd);
CVS commit: src/usr.bin/comm
Module Name:src Committed By: darcy Date: Sat Nov 28 03:56:38 UTC 2009 Modified Files: src/usr.bin/comm: comm.c Log Message: Don't include newlines when comparing to prevent errors when lines have characters that sort lower such as tabs. This is a temporary fix to allow pullups to existing, supported versions of NetBSD. I will follow up with a version for current using the new getline function. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/usr.bin/comm/comm.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/comm/comm.c diff -u src/usr.bin/comm/comm.c:1.17 src/usr.bin/comm/comm.c:1.18 --- src/usr.bin/comm/comm.c:1.17 Sat Apr 11 12:18:45 2009 +++ src/usr.bin/comm/comm.c Sat Nov 28 03:56:38 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: comm.c,v 1.17 2009/04/11 12:18:45 lukem Exp $ */ +/* $NetBSD: comm.c,v 1.18 2009/11/28 03:56:38 darcy Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = @(#)comm.c 8.4 (Berkeley) 5/4/95; #endif -__RCSID($NetBSD: comm.c,v 1.17 2009/04/11 12:18:45 lukem Exp $); +__RCSID($NetBSD: comm.c,v 1.18 2009/11/28 03:56:38 darcy Exp $); #endif /* not lint */ #include err.h @@ -60,6 +60,7 @@ FILE *file(const char *); void show(FILE *, const char *, char *); void usage(void); +char *getnextln(char *buf, FILE *); int main(int argc, char **argv) @@ -116,9 +117,9 @@ for (read1 = read2 = 1;;) { /* read next line, check for EOF */ if (read1) - file1done = !fgets(line1, MAXLINELEN, fp1); + file1done = !getnextln(line1, fp1); if (read2) - file2done = !fgets(line2, MAXLINELEN, fp2); + file2done = !getnextln(line2, fp2); /* if one file done, display the rest of the other file */ if (file1done) { @@ -136,7 +137,7 @@ if (!(comp = compare(line1, line2))) { read1 = read2 = 1; if (col3) -if (printf(%s%s, col3, line1) 0) +if (printf(%s%s\n, col3, line1) 0) break; continue; } @@ -146,13 +147,13 @@ read1 = 1; read2 = 0; if (col1) -if (printf(%s%s, col1, line1) 0) +if (printf(%s%s\n, col1, line1) 0) break; } else { read1 = 0; read2 = 1; if (col2) -if (printf(%s%s, col2, line2) 0) +if (printf(%s%s\n, col2, line2) 0) break; } } @@ -166,7 +167,7 @@ void show(FILE *fp, const char *offset, char *buf) { - while (printf(%s%s, offset, buf) = 0 fgets(buf, MAXLINELEN, fp)) + while (printf(%s%s\n, offset, buf) = 0 getnextln(buf, fp)) ; } @@ -189,3 +190,24 @@ (void)fprintf(stderr, usage: comm [-123f] file1 file2\n); exit(1); } + +char * +getnextln(char *buf, FILE *fp) +{ + size_t i = 0; + int c; + + while ((c = fgetc(fp)) != '\n' c != EOF) { + buf[i++] = c; + + if (i = MAXLINELEN) + i--; /* consumes extra characters till newline */ + } + + if (c == EOF !i) + return NULL; + + buf[i] = 0; + return buf; +} +