Date: Thu, 17 Jun 2010 00:36:55 GMT From: Benjamin Fiedler <bfiedler@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 179693 for review Message-ID: <201006170036.o5H0atou096452@repoman.freebsd.org>
index | next in thread | raw e-mail
http://p4web.freebsd.org/@@179693?ac=10 Change 179693 by bfiedler@freebsd-7803 on 2010/06/17 00:36:53 Implement -tabsize=X, which invokes --expand-tabs Affected files ... .. //depot/projects/soc2010/bsdtextproc/diff/diff.c#7 edit .. //depot/projects/soc2010/bsdtextproc/diff/diff.h#4 edit .. //depot/projects/soc2010/bsdtextproc/diff/diffreg.c#6 edit Differences ... ==== //depot/projects/soc2010/bsdtextproc/diff/diff.c#7 (text+ko) ==== @@ -48,7 +48,7 @@ int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag; int sflag, tflag, Tflag, wflag; int Bflag, yflag; -int strip_cr; +int strip_cr, tabsize=8; char ignore_file_case = 0; int format, context, status; char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; @@ -91,12 +91,12 @@ { "GTYPE-group-format", required_argument, NULL, OPT_GTYPE }, { "line-format", required_argument, NULL, OPT_LF }, { "LTYPE-line-format", required_argument, NULL, OPT_LLF }, - { "tabsize", optional_argument, NULL, OPT_TSIZE }, { "unidirectional-new-file", no_argument, NULL, OPT_UNINF }, { "from-file", required_argument, NULL, OPT_FFILE }, { "to-file", required_argument, NULL, OPT_TOFILE }, { "horizon-lines", required_argument, NULL, OPT_HLINES }, { "speed-large-files", no_argument, NULL, OPT_LFILES }, */ + { "tabsize", optional_argument, NULL, OPT_TSIZE }, { "strip-trailing-cr", no_argument, NULL, OPT_STRIPCR }, { "help", no_argument, NULL, OPT_HELP }, { "ignore-file-name-case", no_argument, NULL, OPT_IGN_FN_CASE }, @@ -296,6 +296,15 @@ case 'y': yflag = 1; break; + case OPT_TSIZE: + if (optarg != NULL) { + l = strtol(optarg, &ep, 10); + if (*ep != '\0' || l < 1 || l >= INT_MAX) + usage(); + tabsize = (int)l; + } else + tabsize = 8; + break; case OPT_STRIPCR: strip_cr=1; break; ==== //depot/projects/soc2010/bsdtextproc/diff/diff.h#4 (text+ko) ==== @@ -77,7 +77,7 @@ extern int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag, sflag, tflag, Tflag, wflag; -extern int Bflag, strip_cr; +extern int Bflag, strip_cr, tabsize; extern int format, context, status; extern char ignore_file_case; extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats; ==== //depot/projects/soc2010/bsdtextproc/diff/diffreg.c#6 (text+ko) ==== @@ -1166,6 +1166,7 @@ fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile) { int i, j, c, lastc, col, nc; + int newcol; /* * When doing #ifdef's, copy down to current line @@ -1214,9 +1215,10 @@ return (0); } if (c == '\t' && tflag) { + newcol = ((col/tabsize)+1)*tabsize; do { putchar(' '); - } while (++col & 7); + } while (++col < newcol); } else { if (format == D_EDIT && j == 1 && c == '\n' && lastc == '.') {help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006170036.o5H0atou096452>
