pjbk@cs.hw.ac.uk (Peter King) (03/28/89)
The following is a small patch to the recently posted `sc' spreadsheet
package to overcome a small problem that arises when incorporating
some new data, prepared by `psc' in a spreadsheet. Without this
patch, the column widths that `psc' calculates override the ones
calculated in the already loaded spreadsheet. This may upset
carefully laid out screens and printouts. The solution is to add a
flag to `psc' which suppresses the inclusion of the column widths in
the generated spreadsheet. Its a trivial modification and has been in
use here for about 6 months. Bob Bond has a copy, so I expect it will
appear in the next version of `sc'.
What follows after the +++ line is a context diff. Either feed it to
patch, or apply it by hand.
Peter King, Computer Science Department JANET: pjbk@uk.ac.hw.cs
Heriot-Watt University ARPA: pjbk@cs.hw.ac.uk
79 Grassmarket, Edinburgh EH1 2HJ or pjbk%cs.hw.ac.uk@ucl-cs
Phone: (+44) 31 225 6465 Ext. 555 UUCP: ..!ukc!cs.hw.ac.uk!pjbk
+++++++++++++++++++++++++++++++++++++++++++++++
diff -c sc/psc.c /usr/src/local/vc/psc.c
*** sc/psc.c Thu Mar 23 16:55:48 1989
--- /usr/src/local/vc/psc.c Thu Nov 10 10:11:26 1988
***************
*** 10,15
* -s v Top left location in the spreadsheet should be v; eg, k5
* -d c Use c as the delimiter between the fields.
* -k Keep all delimiters - Default is strip multiple delimiters to 1.
*
* Author: Robert Bond
* $Revision: 6.1 $
--- 10,16 -----
* -s v Top left location in the spreadsheet should be v; eg, k5
* -d c Use c as the delimiter between the fields.
* -k Keep all delimiters - Default is strip multiple delimiters to 1.
+ * -f suppress 'format' lines in output
*
* Author: Robert Bond
* $Revision: 6.1 $
***************
*** 46,51
char delim1 = ' ';
char delim2 = '\t';
int strip_delim = 1;
int fwidth[MAXCOLS];
int precision[MAXCOLS];
--- 47,53 -----
char delim1 = ' ';
char delim2 = '\t';
int strip_delim = 1;
+ int drop_format = 0;
int fwidth[MAXCOLS];
int precision[MAXCOLS];
***************
*** 65,71
register char *p;
progname = argv[0];
! while ((c = getopt(argc, argv, "rLks:R:C:n:d:")) != EOF) {
switch(c) {
case 'r':
colfirst = 1;
--- 67,73 -----
register char *p;
progname = argv[0];
! while ((c = getopt(argc, argv, "rfLks:R:C:n:d:")) != EOF) {
switch(c) {
case 'r':
colfirst = 1;
***************
*** 93,98
case 'k':
strip_delim = 0;
break;
default:
(void) fprintf(stderr,"Usage: %s [-rkL] [-s v] [-R i] [-C i] [-n i] [-d c]\n", progname);
exit(1);
--- 95,103 -----
case 'k':
strip_delim = 0;
break;
+ case 'f':
+ drop_format = 1;
+ break;
default:
(void) fprintf(stderr,"Usage: %s [-rkfL] [-s v] [-R i] [-C i] [-n i] [-d c]\n", progname);
exit(1);
***************
*** 94,100
strip_delim = 0;
break;
default:
! (void) fprintf(stderr,"Usage: %s [-rkL] [-s v] [-R i] [-C i] [-n i] [-d c]\n", progname);
exit(1);
}
}
--- 99,105 -----
drop_format = 1;
break;
default:
! (void) fprintf(stderr,"Usage: %s [-rkfL] [-s v] [-R i] [-C i] [-n i] [-d c]\n", progname);
exit(1);
}
}
***************
*** 116,121
switch(scan()) {
case END:
for (i = 0; i<MAXCOLS; i++) {
if (precision[i])
(void) printf("format %s %d %d\n", coltoa(i), precision[i]+1,
--- 121,127 -----
switch(scan()) {
case END:
+ if(drop_format) exit(0);
for (i = 0; i<MAXCOLS; i++) {
if (precision[i])
(void) printf("format %s %d %d\n", coltoa(i), precision[i]+1,
diff -c sc/psc.doc /usr/src/local/vc/psc.doc
*** sc/psc.doc Thu Mar 23 16:53:18 1989
--- /usr/src/local/vc/psc.doc Thu Nov 10 10:12:43 1988
***************
*** 5,11
.SH SYNOPSIS
.B ppname
[
! .I -Lkr
]
[
.I -s cell
--- 5,11 -----
.SH SYNOPSIS
.B ppname
[
! .I -fLkr
]
[
.I -s cell
***************
*** 41,46
in the column.
Options:
.IP "\-L"
Left justify strings.
--- 41,53 -----
in the column.
Options:
+
+ .IP "\-f"
+ Omit column width calculations. This option is for preparing
+ data to be merged with an existing spreadsheet. If the option is not
+ specified, the column widths calculated for the data read by
+ .I ppname
+ will override those already set in the existing spreadsheet.
.IP "\-L"
Left justify strings.
--
Peter King, Computer Science Department JANET: pjbk@uk.ac.hw.cs
Heriot-Watt University ARPA: pjbk@cs.hw.ac.uk
79 Grassmarket, Edinburgh EH1 2HJ or pjbk%cs.hw.ac.uk@ucl-cs
Phone: (+44) 31 225 6465 Ext. 555 UUCP: ..!ukc!cs.hw.ac.uk!pjbk