home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume22 / sc / patch01b < prev    next >
Encoding:
Text File  |  1991-09-20  |  26.2 KB  |  1,133 lines

  1. Newsgroups: comp.sources.misc
  2. From: uunet!sawmill!prslnk!buhrt (Jeff Buhrt)
  3. Subject:  REPOST: v22i096:  sc - The SC Spreadsheet, release 6.16, Patch01b/2
  4. Message-ID: <1991Sep20.143406.6061@sparky.imd.sterling.com>
  5. X-Md4-Signature: e1b770411fc08e86cafebaec1e697876
  6. Date: Fri, 20 Sep 1991 14:34:06 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: uunet!sawmill!prslnk!buhrt (Jeff Buhrt)
  10. Posting-number: Volume 22, Issue 96
  11. Archive-name: sc/patch01b
  12. Environment: UNIX, VMS, MS-DOS
  13. Patch-To: sc: Volume 20, Issue 35-41
  14.  
  15. #!/bin/sh
  16. # this is sc-P.02 (part 2 of a multipart archive)
  17. # do not concatenate these parts, unpack them in order with /bin/sh
  18. # file pch616-617 continued
  19. #
  20. if test ! -r _shar_seq_.tmp; then
  21.     echo 'Please unpack part 1 first!'
  22.     exit 1
  23. fi
  24. (read Scheck
  25.  if test "$Scheck" != 2; then
  26.     echo Please unpack part "$Scheck" next!
  27.     exit 1
  28.  else
  29.     exit 0
  30.  fi
  31. ) < _shar_seq_.tmp || exit 1
  32. if test ! -f _shar_wnt_.tmp; then
  33.     echo 'x - still skipping pch616-617'
  34. else
  35. echo 'x - continuing file pch616-617'
  36. sed 's/^X//' << 'SHAR_EOF' >> 'pch616-617' &&
  37. X          }
  38. X          if ((p->cellerror = cellerror) || (v != p->v)) {
  39. X          p->v = v;
  40. --- 1372,1379 ----
  41. X          v = (double)0.0;
  42. X          } else {
  43. X          cellerror = CELLOK;
  44. X          gmyrow=i; gmycol=j;
  45. +         v = eval (p->expr);
  46. X          }
  47. X          if ((p->cellerror = cellerror) || (v != p->v)) {
  48. X          p->v = v;
  49. ***************
  50. *** 1379,1385 ****
  51. X  double a1;
  52. X  {
  53. X      register struct enode *p;
  54. !     if (freeenodes)
  55. X      {    p = freeenodes;
  56. X      freeenodes = p->e.o.left;
  57. X      }
  58. --- 1443,1449 ----
  59. X  double a1;
  60. X  {
  61. X      register struct enode *p;
  62. !     if (freeenodes)    /* reuse an already free'd enode */
  63. X      {    p = freeenodes;
  64. X      freeenodes = p->e.o.left;
  65. X      }
  66. ***************
  67. *** 1396,1402 ****
  68. X  {
  69. X      register struct enode *p;
  70. X  
  71. !     if (freeenodes)
  72. X      {    p = freeenodes;
  73. X      freeenodes = p->e.o.left;
  74. X      }
  75. --- 1460,1466 ----
  76. X  {
  77. X      register struct enode *p;
  78. X  
  79. !     if (freeenodes)    /* reuse an already free'd enode */
  80. X      {    p = freeenodes;
  81. X      freeenodes = p->e.o.left;
  82. X      }
  83. ***************
  84. *** 1466,1471 ****
  85. --- 1530,1536 ----
  86. X      for (dc=vc, sc=minsc; sc<=maxsc; sc++, dc++) {
  87. X          if (p = *ATBL(tbl, sr, sc))
  88. X          {    n = lookat (dr, dc);
  89. +         if (n->flags&is_locked) continue;
  90. X          (void) clearent(n);
  91. X          copyent( n, p, dr - sr, dc - sc);
  92. X          }
  93. ***************
  94. *** 1692,1697 ****
  95. --- 1757,1763 ----
  96. X      for (r = minr; r<=maxr; r++)
  97. X      for (c = minc; c<=maxc; c++) {
  98. X          n = lookat (r, c);
  99. +         if (n->flags&is_locked) continue;
  100. X          (void) clearent(n);
  101. X          n->v = start;
  102. X          start += inc;
  103. ***************
  104. *** 1712,1717 ****
  105. --- 1778,1839 ----
  106. X      changed++;
  107. X  }
  108. X  
  109. + /* lock a range of cells */
  110. + void
  111. + lock_cells (v1, v2)
  112. + struct ent *v1, *v2;
  113. + {
  114. +     register r,c;
  115. +     register struct ent *n;
  116. +     int maxr, maxc;
  117. +     int minr, minc;
  118. +     maxr = v2->row;
  119. +     maxc = v2->col;
  120. +     minr = v1->row;
  121. +     minc = v1->col;
  122. +     if (minr>maxr) r = maxr, maxr = minr, minr = r;
  123. +     if (minc>maxc) c = maxc, maxc = minc, minc = c;
  124. +     checkbounds(&maxr, &maxc);
  125. +     if (minr < 0) minr = 0;
  126. +     if (minc < 0) minc = 0;
  127. +     for (r = minr; r<=maxr; r++)
  128. +     for (c = minc; c<=maxc; c++) {
  129. +         n = lookat (r, c);
  130. +         n->flags |= is_locked;
  131. +     }
  132. + }
  133. + /* unlock a range of cells */
  134. + void
  135. + unlock_cells (v1, v2)
  136. + struct ent *v1, *v2;
  137. + {
  138. +     register r,c;
  139. +     register struct ent *n;
  140. +     int maxr, maxc;
  141. +     int minr, minc;
  142. +     maxr = v2->row;
  143. +     maxc = v2->col;
  144. +     minr = v1->row;
  145. +     minc = v1->col;
  146. +     if (minr>maxr) r = maxr, maxr = minr, minr = r;
  147. +     if (minc>maxc) c = maxc, maxc = minc, minc = c;
  148. +     checkbounds(&maxr, &maxc);
  149. +     if (minr < 0) minr = 0;
  150. +     if (minc < 0) minc = 0;
  151. +     for (r = minr; r<=maxr; r++)
  152. +     for (c = minc; c<=maxc; c++) {
  153. +         n = lookat (r, c);
  154. +         n->flags &= ~is_locked;
  155. +     }
  156. + }
  157. X  /* set the numeric part of a cell */
  158. X  void
  159. X  let (v, e)
  160. ***************
  161. *** 1749,1756 ****
  162. X      }
  163. X  
  164. X      if (isconstant) {
  165. !     if (!loading && prescale < (double)0.9999999)
  166. X          val *= prescale;
  167. X      v->v = val;
  168. X  
  169. X      if (!(v->flags & is_strexpr)) {
  170. --- 1871,1881 ----
  171. X      }
  172. X  
  173. X      if (isconstant) {
  174. !     /* prescale input unless it has a decimal */
  175. !     if (!loading && (prescale < (double)0.9999999) &&
  176. !                 (fmod(val, (double)1.0) == (double)0))
  177. X          val *= prescale;
  178. X      v->v = val;
  179. X  
  180. X      if (!(v->flags & is_strexpr)) {
  181. ***************
  182. *** 1847,1852 ****
  183. --- 1972,1981 ----
  184. X      for (r = minr; r <= maxr; r++)
  185. X      for (c = minc; c <= maxc; c++) {
  186. X          n = lookat (r, c);
  187. +         if (n->flags&is_locked) {
  188. +         error("Cell %s%d is locked", coltoa(n->col), n->row);
  189. +         continue;
  190. +         }
  191. X          if (n->format)
  192. X          xfree(n->format);
  193. X          n->format = 0;
  194. ***************
  195. *** 2109,2114 ****
  196. --- 2238,2246 ----
  197. X      case DAY:    one_arg( "@day(", e); break;
  198. X      case YEAR:    one_arg( "@year(", e); break;
  199. X      case DATE:    one_arg( "@date(", e); break;
  200. +     case UPPER:    one_arg( "@upper(", e); break;
  201. +     case LOWER:    one_arg( "@lower(", e); break;
  202. +     case CAPITAL:    one_arg( "@capital(", e); break;
  203. X      case DTS:    three_arg( "@dts(", e); break;
  204. X      case TTS:    three_arg( "@tts(", e); break;
  205. X      case STON:    one_arg( "@ston(", e); break;
  206. *** 6.16    1991/06/04 18:55:36
  207. --- lex.c    1991/09/04 14:28:14
  208. ***************
  209. *** 7,13 ****
  210. X   *
  211. X   *              More mods Robert Bond, 12/86
  212. X   *        More mods by Alan Silverstein, 3/88, see list of changes.
  213. !  *        $Revision: 6.16 $
  214. X   *
  215. X   */
  216. X  
  217. --- 7,13 ----
  218. X   *
  219. X   *              More mods Robert Bond, 12/86
  220. X   *        More mods by Alan Silverstein, 3/88, see list of changes.
  221. !  *        $Revision: 6.17 $
  222. X   *
  223. X   */
  224. X  
  225. ***************
  226. *** 48,56 ****
  227. --- 48,64 ----
  228. X  extern YYSTYPE yylval;
  229. X  extern int VMS_read_raw;   /*sigh*/
  230. X  #else    /* VMS */
  231. + #if defined(MSDOS)
  232. + #include "y_tab.h"
  233. + #else
  234. X  #include "y.tab.h"
  235. + #endif /* MSDOS */
  236. X  #endif /* VMS */
  237. X  
  238. + #ifdef hpux
  239. + extern YYSTYPE yylval;
  240. + #endif /* hpux */
  241. X  char *strtof();
  242. X  
  243. X  jmp_buf wakeup;
  244. ***************
  245. *** 201,218 ****
  246. X      (void) signal(SIGFPE, sig_save);
  247. X      } else if (*p=='"') {
  248. X      char *ptr;
  249. !         ptr = p+1;
  250. !         while(*ptr && *ptr++ != '"');
  251. X          ptr = xmalloc((unsigned)(ptr-p));
  252. X      yylval.sval = ptr;
  253. X      p += 1;
  254. !     while (*p && *p!='"') *ptr++ = *p++;
  255. X      *ptr = 0;
  256. !     if (*p) p += 1;
  257. X      ret = STRING;
  258. X      } else if (*p=='[') {
  259. !     while (*p && *p!=']') p++;
  260. !     if (*p) p++;
  261. X      linelim = p-line;
  262. X      return yylex();
  263. X      } else ret = *p++;
  264. --- 209,231 ----
  265. X      (void) signal(SIGFPE, sig_save);
  266. X      } else if (*p=='"') {
  267. X      char *ptr;
  268. !         ptr = p+1;    /* "string" or "string\"quoted\"" */
  269. !         while(*ptr && ((*ptr != '"') || (*(ptr-1) == '\\')))
  270. !         ptr++;
  271. X          ptr = xmalloc((unsigned)(ptr-p));
  272. X      yylval.sval = ptr;
  273. X      p += 1;
  274. !     while (*p && ((*p != '"') || (*(p-1) == '\\')))
  275. !         *ptr++ = *p++;
  276. X      *ptr = 0;
  277. !     if (*p)
  278. !         p += 1;
  279. X      ret = STRING;
  280. X      } else if (*p=='[') {
  281. !     while (*p && *p!=']')
  282. !         p++;
  283. !     if (*p)
  284. !         p++;
  285. X      linelim = p-line;
  286. X      return yylex();
  287. X      } else ret = *p++;
  288. ***************
  289. *** 300,306 ****
  290. X      case SMG$K_TRM_RIGHT: c = ctl('f'); break;
  291. X      case SMG$K_TRM_UP:    c = ctl('p'); break;
  292. X      case SMG$K_TRM_DOWN:  c = ctl('n'); break;
  293. !     default:   c = c & 0x7f;
  294. X      }
  295. X      return (c);
  296. X  }
  297. --- 313,319 ----
  298. X      case SMG$K_TRM_RIGHT: c = ctl('f'); break;
  299. X      case SMG$K_TRM_UP:    c = ctl('p'); break;
  300. X      case SMG$K_TRM_DOWN:  c = ctl('n'); break;
  301. !     default:   c = c & A_CHARTEXT;
  302. X      }
  303. X      return (c);
  304. X  }
  305. ***************
  306. *** 526,532 ****
  307. X  
  308. X  #endif
  309. X  
  310. ! #if defined(SYSV2) || defined(SYSV3)
  311. X  
  312. X  void
  313. X  initkbd()
  314. --- 539,545 ----
  315. X  
  316. X  #endif
  317. X  
  318. ! #if defined(SYSV2) || defined(SYSV3) || defined(MSDOS)
  319. X  
  320. X  void
  321. X  initkbd()
  322. ***************
  323. *** 553,563 ****
  324. --- 566,595 ----
  325. X  
  326. X      c = getch();
  327. X      switch (c) {
  328. + #ifdef KEY_LEFT
  329. X      case KEY_LEFT:  c = ctl('b'); break;
  330. + #endif
  331. + #ifdef KEY_RIGHT
  332. X      case KEY_RIGHT: c = ctl('f'); break;
  333. + #endif
  334. + #ifdef KEY_UP
  335. X      case KEY_UP:    c = ctl('p'); break;
  336. + #endif
  337. + #ifdef KEY_DOWN
  338. X      case KEY_DOWN:  c = ctl('n'); break;
  339. + #endif
  340. + #ifdef KEY_BACKSPACE
  341. X      case KEY_BACKSPACE:  c = ctl('h'); break;
  342. + #endif
  343. + #ifdef KEY_NPAGE
  344. +     case KEY_NPAGE:    break;
  345. + #endif
  346. + #ifdef KEY_PPAGE
  347. +     case KEY_PPAGE:    break;
  348. + #endif
  349. + #ifdef KEY_HOME
  350. +     case KEY_HOME:    break;
  351. + #endif
  352. X  #ifdef KEY_C1
  353. X  /* This stuff works for a wyse wy75 in ANSI mode under 5.3.  Good luck. */
  354. X  /* It is supposed to map the curses keypad back to the numeric equiv. */
  355. *** 6.16    1991/06/04 18:57:22
  356. --- psc.c    1991/09/04 14:28:15
  357. ***************
  358. *** 17,23 ****
  359. X   *  Author: Robert Bond
  360. X   *  Adjustments: Jeff Buhrt and Eric Putz
  361. X   */
  362. ! char *rev = "$Revision: 6.16 $";
  363. X  
  364. X  #include <ctype.h>
  365. X  #include <stdio.h>
  366. --- 17,23 ----
  367. X   *  Author: Robert Bond
  368. X   *  Adjustments: Jeff Buhrt and Eric Putz
  369. X   */
  370. ! char *rev = "$Revision: 6.17 $";
  371. X  
  372. X  #include <ctype.h>
  373. X  #include <stdio.h>
  374. ***************
  375. *** 30,38 ****
  376. X  #define EOL    4
  377. X  
  378. X  extern char *optarg;
  379. ! extern int   optind;
  380. ! char *coltoa();
  381. ! char *progname;
  382. X  
  383. X  #ifdef SYSV3
  384. X  extern void exit();
  385. --- 30,39 ----
  386. X  #define EOL    4
  387. X  
  388. X  extern char *optarg;
  389. ! extern int   optind, getopt(), atoi();
  390. ! char    *coltoa();
  391. ! char    *progname;
  392. ! int    getrow(), getcol(), scan();
  393. X  
  394. X  #ifdef SYSV3
  395. X  extern void exit();
  396. ***************
  397. *** 240,245 ****
  398. --- 241,247 ----
  399. X      }
  400. X  }
  401. X  
  402. + int
  403. X  scan()
  404. X  {
  405. X      register int c;
  406. ***************
  407. *** 310,315 ****
  408. --- 312,318 ----
  409. X  }
  410. X      
  411. X  /* turns [A-Z][A-Z] into a number */
  412. + int
  413. X  getcol(p)
  414. X  char *p;
  415. X  {
  416. ***************
  417. *** 329,334 ****
  418. --- 332,338 ----
  419. X  }
  420. X  
  421. X  /* given a string turn it into a row number */
  422. + int
  423. X  getrow(p)
  424. X  char *p;
  425. X  {
  426. *** 6.16    1991/06/04 18:57:22
  427. --- range.c    1991/09/04 14:28:15
  428. ***************
  429. *** 4,10 ****
  430. X   *
  431. X   *              Robert Bond, 4/87
  432. X   *
  433. !  *        $Revision: 6.16 $
  434. X   */
  435. X  
  436. X  #include <sys/types.h>
  437. --- 4,10 ----
  438. X   *
  439. X   *              Robert Bond, 4/87
  440. X   *
  441. !  *        $Revision: 6.17 $
  442. X   */
  443. X  
  444. X  #include <sys/types.h>
  445. *** 6.16    1991/06/04 18:55:36
  446. --- sc.c    1991/09/04 14:28:17
  447. ***************
  448. *** 8,14 ****
  449. X   *              More mods Robert Bond, 12/86
  450. X   *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  451. X   *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  452. !  *        $Revision: 6.16 $
  453. X   *
  454. X   */
  455. X  
  456. --- 8,14 ----
  457. X   *              More mods Robert Bond, 12/86
  458. X   *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  459. X   *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  460. !  *        $Revision: 6.17 $
  461. X   *
  462. X   */
  463. X  
  464. ***************
  465. *** 149,154 ****
  466. --- 149,155 ----
  467. X      p->next = to_fix;
  468. X      to_fix = p;
  469. X      p->flags |= is_deleted;
  470. +     p->flags &= ~is_locked;
  471. X  }
  472. X  
  473. X  /* free deleted cells */
  474. ***************
  475. *** 199,205 ****
  476. --- 200,210 ----
  477. X  
  478. X      int tempx, tempy;     /* Temp versions of curx, cury */
  479. X  
  480. + #if defined(MSDOS)
  481. +     if ((revi = strrchr(argv[0], '\\')) != NULL)
  482. + #else
  483. X      if ((revi = strrchr(argv[0], '/')) != NULL)
  484. + #endif
  485. X      progname = revi+1;
  486. X      else
  487. X      progname = argv[0];
  488. ***************
  489. *** 209,216 ****
  490. X      argc--;
  491. X          switch (argv[0][1]) {
  492. X          case 'x':
  493. ! #ifdef VMS
  494. !             (void) fprintf(stderr, "Crypt not available for VMS\n");
  495. X              exit(1);
  496. X  #else 
  497. X              Crypt = 1;
  498. --- 214,221 ----
  499. X      argc--;
  500. X          switch (argv[0][1]) {
  501. X          case 'x':
  502. ! #if defined(VMS) || defined(MSDOS)
  503. !             (void) fprintf(stderr, "Crypt not available for VMS or MS-DOS\n");
  504. X              exit(1);
  505. X  #else 
  506. X              Crypt = 1;
  507. ***************
  508. *** 293,299 ****
  509. X  #ifdef    SIGWINCH
  510. X      /* got a SIGWINCH? */
  511. X      if (hitwinch)
  512. !     {    stopdisp();
  513. X          startdisp();
  514. X          FullUpdate++;
  515. X      }
  516. --- 298,305 ----
  517. X  #ifdef    SIGWINCH
  518. X      /* got a SIGWINCH? */
  519. X      if (hitwinch)
  520. !     {    hitwinch = 0;
  521. !         stopdisp();
  522. X          startdisp();
  523. X          FullUpdate++;
  524. X      }
  525. ***************
  526. *** 321,327 ****
  527. X  #if    pyr
  528. X         if ( iscntrl(c) || (c >= 011 && c <= 015) )    /* iscntrl broken in OSx4.1 */
  529. X  #else
  530. !        if ( iscntrl(c) )
  531. X  #endif
  532. X          switch (c) {
  533. X  #ifdef SIGTSTP
  534. --- 327,333 ----
  535. X  #if    pyr
  536. X         if ( iscntrl(c) || (c >= 011 && c <= 015) )    /* iscntrl broken in OSx4.1 */
  537. X  #else
  538. !        if ( iscntrl(c) || (c == 020 ) )    /* iscntrl broken in OSx4.1 */
  539. X  #endif
  540. X          switch (c) {
  541. X  #ifdef SIGTSTP
  542. ***************
  543. *** 340,345 ****
  544. --- 346,354 ----
  545. X              FullUpdate++;
  546. X              ClearScreen++;
  547. X              (void) clearok(stdscr,1);
  548. +             /* Centering the display with cursor for middle */
  549. +             if(currow > (LINES-RESROW)/2)
  550. +             strow = currow - ((LINES-RESROW)/2);
  551. X              break;
  552. X          case ctl('x'):
  553. X              FullUpdate++;
  554. ***************
  555. *** 629,634 ****
  556. --- 638,645 ----
  557. X          case '0': case '1': case '2': case '3': case '4':
  558. X          case '5': case '6': case '7': case '8': case '9':
  559. X          case '-': case '.': case '+':
  560. +             if (locked_cell(currow, curcol))
  561. +             break;
  562. X              numeric_field = 1;
  563. X              (void) sprintf(line,"let %s = %c",
  564. X                  v_name(currow, curcol), c);
  565. ***************
  566. *** 637,642 ****
  567. --- 648,655 ----
  568. X              break;
  569. X  
  570. X          case '=':
  571. +             if (locked_cell(currow, curcol))
  572. +             break;
  573. X              (void) sprintf(line,"let %s = ",
  574. X                      v_name(currow, curcol));
  575. X              linelim = strlen (line);
  576. ***************
  577. *** 650,657 ****
  578. X               *  "!"    forks a shell
  579. X               *  "!!" repeats last command
  580. X               */
  581. ! #ifdef VMS
  582. !             error("Not implemented on VMS");
  583. X  #else /* VMS */
  584. X              char *shl;
  585. X              int pid, temp;
  586. --- 663,670 ----
  587. X               *  "!"    forks a shell
  588. X               *  "!!" repeats last command
  589. X               */
  590. ! #if VMS || MSDOS
  591. !             error("Not implemented on VMS or MS-DOS");
  592. X  #else /* VMS */
  593. X              char *shl;
  594. X              int pid, temp;
  595. ***************
  596. *** 703,712 ****
  597. X  
  598. X          case '/':
  599. X              error (
  600. ! "Range:  x:erase  v:value  c:copy  f:fill  d:define  s:show  u:undefine  F:fmt");
  601. X              (void) refresh();
  602. X  
  603. X              switch (nmgetch()) {
  604. X              case 'c':
  605. X              (void) sprintf(line,"copy [dest_range src_range] ");
  606. X              linelim = strlen(line);
  607. --- 716,737 ----
  608. X  
  609. X          case '/':
  610. X              error (
  611. ! "Range: x:erase v:value c:copy f:fill d:def l:lock U:unlock s:show u:undef F:fmt");
  612. X              (void) refresh();
  613. X  
  614. X              switch (nmgetch()) {
  615. +             case 'l':
  616. +             (void) sprintf(line,"lock [range] ");
  617. +             linelim = strlen(line);
  618. +             startshow();
  619. +             insert_mode();
  620. +             break;
  621. +             case 'U':
  622. +             (void) sprintf(line,"unlock [range] ");
  623. +             linelim = strlen(line);
  624. +             startshow();
  625. +             insert_mode();
  626. +             break;
  627. X              case 'c':
  628. X              (void) sprintf(line,"copy [dest_range src_range] ");
  629. X              linelim = strlen(line);
  630. ***************
  631. *** 926,955 ****
  632. X              help();
  633. X              break;
  634. X          case '"':
  635. !             (void) sprintf (line, "label %s = \"",
  636. !                     v_name(currow, curcol));
  637. !             linelim = strlen (line);
  638. !             insert_mode();
  639. X              break;
  640. X          case '<':
  641. !             (void) sprintf (line, "leftstring %s = \"",
  642. !                 v_name(currow, curcol));
  643. !             linelim = strlen (line);
  644. !             insert_mode();
  645. X              break;
  646. X          case '>':
  647. !             (void) sprintf (line, "rightstring %s = \"",
  648. !                v_name(currow, curcol));
  649. !             linelim = strlen (line);
  650. !             insert_mode();
  651. X              break;
  652. X          case 'e':
  653. !             editv (currow, curcol);
  654. !             edit_mode();
  655. X              break;
  656. X          case 'E':
  657. !             edits (currow, curcol);
  658. !             edit_mode();
  659. X              break;
  660. X          case 'f':
  661. X              if (arg == 1)
  662. --- 951,992 ----
  663. X              help();
  664. X              break;
  665. X          case '"':
  666. !             if (!locked_cell(currow, curcol)) {
  667. !                (void) sprintf (line, "label %s = \"",
  668. !                        v_name(currow, curcol));
  669. !                linelim = strlen (line);
  670. !                insert_mode();
  671. !             }
  672. X              break;
  673. X          case '<':
  674. !             if (!locked_cell(currow, curcol)) {
  675. !                (void) sprintf (line, "leftstring %s = \"",
  676. !                    v_name(currow, curcol));
  677. !                linelim = strlen (line);
  678. !                insert_mode();
  679. !             }
  680. X              break;
  681. X          case '>':
  682. !             if (!locked_cell(currow, curcol)) {
  683. !                (void) sprintf (line, "rightstring %s = \"",
  684. !                   v_name(currow, curcol));
  685. !                linelim = strlen (line);
  686. !                insert_mode();
  687. !             }
  688. X              break;
  689. X          case 'e':
  690. !             if (!locked_cell(currow, curcol)) {
  691. !                editv (currow, curcol);
  692. !                edit_mode();
  693. !             }
  694. X              break;
  695. X          case 'E':
  696. !             if (!locked_cell(currow, curcol)) {
  697. !                edits (currow, curcol);
  698. !                edit_mode();
  699. !             }
  700. X              break;
  701. X          case 'f':
  702. X              if (arg == 1)
  703. ***************
  704. *** 1043,1061 ****
  705. X              if(calc_order == BYROWS) {
  706. X                for (c1 = curcol; arg-- && c1 < maxcols; c1++) {
  707. X              pp = ATBL(tbl, currow, c1);
  708. !             if (*pp) {
  709. !                 free_ent(*pp);
  710. !                 *pp = (struct ent *)0;
  711. !             }
  712. X                }
  713. X              }
  714. X              else {
  715. X                for (c1 = currow; arg-- && c1 < maxrows; c1++) {
  716. X              pp = ATBL(tbl, c1, curcol);
  717. !             if (*pp) {
  718. !                 free_ent(*pp);
  719. !                 *pp = (struct ent *)0;
  720. !             }
  721. X                }
  722. X              }
  723. X              sync_refs();
  724. --- 1080,1102 ----
  725. X              if(calc_order == BYROWS) {
  726. X                for (c1 = curcol; arg-- && c1 < maxcols; c1++) {
  727. X              pp = ATBL(tbl, currow, c1);
  728. !                 if ((*pp) && !locked_cell(currow, curcol)) {
  729. !                if (*pp) {
  730. !                    free_ent(*pp);
  731. !                    *pp = (struct ent *)0;
  732. !                }
  733. !                 }
  734. X                }
  735. X              }
  736. X              else {
  737. X                for (c1 = currow; arg-- && c1 < maxrows; c1++) {
  738. X              pp = ATBL(tbl, c1, curcol);
  739. !                 if ((*pp) && !locked_cell(currow, curcol)) {
  740. !                if (*pp) {
  741. !                    free_ent(*pp);
  742. !                    *pp = (struct ent *)0;
  743. !                }
  744. !                 }
  745. X                }
  746. X              }
  747. X              sync_refs();
  748. ***************
  749. *** 1091,1096 ****
  750. --- 1132,1144 ----
  751. X          case 'K':
  752. X              backrow((currow-strow+1)+3);
  753. X              break;
  754. + #ifdef KEY_HOME
  755. +         case KEY_HOME:
  756. +             currow = 0;
  757. +             curcol = 0;
  758. +             FullUpdate++;
  759. +             break;
  760. + #endif
  761. X          case 'L':
  762. X              forwcol(cols-(curcol-stcol)+1);
  763. X              break;
  764. ***************
  765. *** 1197,1208 ****
  766. X  #endif
  767. X  
  768. X      (void) signal(SIGINT, SIG_IGN);
  769. X      (void) signal(SIGQUIT, dump_me);
  770. X      (void) signal(SIGPIPE, quit);
  771. -     (void) signal(SIGTERM, quit);
  772. X      (void) signal(SIGALRM, time_out);
  773. -     (void) signal(SIGFPE, quit);
  774. X      (void) signal(SIGBUS, quit);
  775. X  #ifdef    SIGWINCH
  776. X      (void) signal(SIGWINCH, winchg);
  777. X  #endif
  778. --- 1245,1258 ----
  779. X  #endif
  780. X  
  781. X      (void) signal(SIGINT, SIG_IGN);
  782. + #if !defined(MSDOS)
  783. X      (void) signal(SIGQUIT, dump_me);
  784. X      (void) signal(SIGPIPE, quit);
  785. X      (void) signal(SIGALRM, time_out);
  786. X      (void) signal(SIGBUS, quit);
  787. + #endif
  788. +     (void) signal(SIGTERM, quit);
  789. +     (void) signal(SIGFPE, quit);
  790. X  #ifdef    SIGWINCH
  791. X      (void) signal(SIGWINCH, winchg);
  792. X  #endif
  793. ***************
  794. *** 1216,1221 ****
  795. --- 1266,1272 ----
  796. X  #endif
  797. X  winchg()
  798. X  {    hitwinch++;
  799. +     (void) signal(SIGWINCH, winchg);
  800. X  }
  801. X  #endif
  802. X  
  803. ***************
  804. *** 1285,1288 ****
  805. --- 1336,1369 ----
  806. X          return(yn_ans);
  807. X      }
  808. X      return(0);
  809. + }
  810. + /* Returns 1 if cell is locked, 0 otherwise */
  811. + int
  812. + locked_cell (r, c)
  813. +     int r, c;
  814. + {
  815. +     struct ent *p = *ATBL(tbl, r, c);
  816. +     if (p && (p->flags & is_locked)) {
  817. +         error("Cell %s%d is locked", coltoa(c), r) ;
  818. +         return(1);
  819. +     }
  820. +     return(0);
  821. + }
  822. + /* Check if area contains locked cells */
  823. + int
  824. + any_locked_cells(r1, c1, r2, c2)
  825. +     int r1, c1, r2, c2 ;
  826. + {
  827. +     int r, c;
  828. +     struct ent *p ;
  829. +     for (r=r1; r<=r2; r++)
  830. +         for (c=c1; c<=c2; c++) {
  831. +             p = *ATBL(tbl, r, c);
  832. +             if (p->flags&is_locked)
  833. +                 return(1);
  834. +         }
  835. +     return(0);
  836. X  }
  837. *** 6.16    1991/06/04 18:57:22
  838. --- sc.h    1991/09/04 14:28:18
  839. ***************
  840. *** 6,15 ****
  841. X   *            University of Maryland
  842. X   *        R. Bond  12/86
  843. X   *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  844. !  *        $Revision: 6.16 $
  845. X   *
  846. X   */
  847. X  
  848. X  #define    ATBL(tbl, row, col)    (*(tbl + row) + (col))
  849. X  
  850. X  #define MINROWS 100     /* minimum size at startup */
  851. --- 6,19 ----
  852. X   *            University of Maryland
  853. X   *        R. Bond  12/86
  854. X   *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  855. !  *        $Revision: 6.17 $
  856. X   *
  857. X   */
  858. X  
  859. + #if defined(MSDOS)
  860. + #include <stdio.h>
  861. + #endif
  862. X  #define    ATBL(tbl, row, col)    (*(tbl + row) + (col))
  863. X  
  864. X  #define MINROWS 100     /* minimum size at startup */
  865. ***************
  866. *** 78,83 ****
  867. --- 82,88 ----
  868. X  /*
  869. X   * Some not too obvious things about the flags:
  870. X   *    is_valid means there is a valid number in v.
  871. +  *    is_locked means that the cell cannot be edited.
  872. X   *    label set means it points to a valid constant string.
  873. X   *    is_strexpr set means expr yields a string expression.
  874. X   *    If is_strexpr is not set, and expr points to an expression tree, the
  875. ***************
  876. *** 189,194 ****
  877. --- 194,202 ----
  878. X  #define MYROW OP_BASE + 52
  879. X  #define MYCOL OP_BASE + 53
  880. X  #define COLTOA OP_BASE + 54
  881. + #define UPPER OP_BASE + 55
  882. + #define LOWER OP_BASE + 56
  883. + #define CAPITAL OP_BASE + 57
  884. X  
  885. X  /* flag values */
  886. X  #define is_valid     0001
  887. ***************
  888. *** 196,201 ****
  889. --- 204,210 ----
  890. X  #define is_strexpr   0004
  891. X  #define is_leftflush 0010
  892. X  #define is_deleted   0020
  893. + #define is_locked    0040
  894. X  
  895. X  /* cell error (1st generation (ERROR) or 2nd+ (INVALID)) */
  896. X  #define    CELLOK        0
  897. ***************
  898. *** 247,252 ****
  899. --- 256,262 ----
  900. X  extern    int showsc, showsr;
  901. X  
  902. X  extern    FILE *openout();
  903. + extern    FILE *fdopen(), *fopen();
  904. X  extern    char *coltoa();
  905. X  extern    char *findhome();
  906. X  extern    char *r_name();
  907. ***************
  908. *** 254,259 ****
  909. --- 264,270 ----
  910. X  extern    char *v_name();
  911. X  extern    char *xmalloc();
  912. X  extern    char *xrealloc();
  913. + extern    int any_locked_cells();
  914. X  extern    int are_ranges();
  915. X  extern    int atocol();
  916. X  extern    int cwritefile();
  917. ***************
  918. *** 263,268 ****
  919. --- 274,280 ----
  920. X  extern    int format();
  921. X  extern    int get_rcqual();
  922. X  extern    int growtbl();
  923. + extern    int locked_cell();
  924. X  extern    int modcheck();
  925. X  extern    int nmgetch();
  926. X  extern    int writefile();
  927. ***************
  928. *** 327,332 ****
  929. --- 339,345 ----
  930. X  extern    void label();
  931. X  extern    void let();
  932. X  extern    void list_range();
  933. + extern    void lock_cells();
  934. X  extern    void moveto();
  935. X  extern    void num_search();
  936. X  extern    void opencol();
  937. ***************
  938. *** 349,354 ****
  939. --- 362,368 ----
  940. X  extern    void sync_ranges();
  941. X  extern    void sync_refs();
  942. X  extern    void tblprintfile();
  943. + extern    void unlock_cells();
  944. X  extern    void valueize_area();
  945. X  extern    void write_fd();
  946. X  extern    void write_line();
  947. *** 6.16    1991/06/04 18:55:36
  948. --- screen.c    1991/09/04 14:28:18
  949. ***************
  950. *** 8,14 ****
  951. X   *              More mods Robert Bond, 12/86
  952. X   *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  953. X   *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  954. !  *        $Revision: 6.16 $
  955. X   *
  956. X   */
  957. X  
  958. --- 8,14 ----
  959. X   *              More mods Robert Bond, 12/86
  960. X   *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  961. X   *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  962. !  *        $Revision: 6.17 $
  963. X   *
  964. X   */
  965. X  
  966. ***************
  967. *** 436,441 ****
  968. --- 436,444 ----
  969. X          }
  970. X          if (! printed)
  971. X          (void) addstr ("[]");
  972. +         /* Display if cell is locked */
  973. +         if (p1->flags&is_locked)
  974. +         (void) addstr(" locked");
  975. X      }
  976. X      (void) move(lastmy, lastmx+fwidth[lastcol]);
  977. X      }
  978. ***************
  979. *** 486,495 ****
  980. --- 489,517 ----
  981. X  void
  982. X  startdisp()
  983. X  {
  984. + #if sun
  985. +     int     fd;
  986. +     fd = dup(0);
  987. + #endif
  988. + #ifdef TIOCGSIZE
  989. +     {    struct ttysize size;
  990. +     if (ioctl(0, TIOCGSIZE, &size) == 0)
  991. +     { 
  992. +         LINES = size.ts_lines;
  993. +         COLS = size.ts_cols;
  994. +     }
  995. +     }
  996. + #endif
  997. X  #ifdef XENIX2_3
  998. X      (void) ioctl (fileno (stdin), TCGETA, & tmio);
  999. X  #endif
  1000. X      (void) initscr();
  1001. + #if sun
  1002. +     close(0);
  1003. +     dup(fd);
  1004. +     close(fd);
  1005. + #endif
  1006. X      (void) clear();
  1007. X  #ifdef VMS
  1008. X      VMS_read_raw = 1;
  1009. *** 6.16    1991/06/04 18:57:22
  1010. --- version.c    1991/09/04 14:28:19
  1011. ***************
  1012. *** 4,7 ****
  1013. X   * The part after the first colon, except the last char, appears on the screen.
  1014. X   */
  1015. X  
  1016. ! char *rev = "$Revision: 6.16 $";
  1017. --- 4,7 ----
  1018. X   * The part after the first colon, except the last char, appears on the screen.
  1019. X   */
  1020. X  
  1021. ! char *rev = "$Revision: 6.17 $";
  1022. *** 6.16    1991/06/04 18:57:22
  1023. --- vi.c    1991/09/04 14:28:20
  1024. ***************
  1025. *** 1,7 ****
  1026. X  /*    SC    A Spreadsheet Calculator
  1027. X   *
  1028. X   *    One line vi emulation
  1029. !  *    $Revision: 6.16 $
  1030. X   */
  1031. X  
  1032. X  #include <sys/types.h>
  1033. --- 1,7 ----
  1034. X  /*    SC    A Spreadsheet Calculator
  1035. X   *
  1036. X   *    One line vi emulation
  1037. !  *    $Revision: 6.17 $
  1038. X   */
  1039. X  
  1040. X  #include <sys/types.h>
  1041. *** 6.16    1991/06/04 18:57:22
  1042. --- vmtbl.c    1991/09/04 14:28:21
  1043. ***************
  1044. *** 8,14 ****
  1045. X   *              More mods Robert Bond, 12/86
  1046. X   *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1047. X   *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  1048. !  *        $Revision: 6.16 $
  1049. X   *
  1050. X   */
  1051. X  #ifdef PSC
  1052. --- 8,14 ----
  1053. X   *              More mods Robert Bond, 12/86
  1054. X   *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1055. X   *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  1056. !  *        $Revision: 6.17 $
  1057. X   *
  1058. X   */
  1059. X  #ifdef PSC
  1060. *** 6.16    1991/06/04 18:57:22
  1061. --- xmalloc.c    1991/09/04 14:28:22
  1062. ***************
  1063. *** 1,6 ****
  1064. X  /*
  1065. X   * A safer saner malloc, for careless programmers
  1066. !  * $Revision: 6.16 $
  1067. X   */
  1068. X  
  1069. X  #include <stdio.h>
  1070. --- 1,6 ----
  1071. X  /*
  1072. X   * A safer saner malloc, for careless programmers
  1073. !  * $Revision: 6.17 $
  1074. X   */
  1075. X  
  1076. X  #include <stdio.h>
  1077. SHAR_EOF
  1078. echo 'File pch616-617 is complete' &&
  1079. chmod 0666 pch616-617 ||
  1080. echo 'restore of pch616-617 failed'
  1081. Wc_c="`wc -c < 'pch616-617'`"
  1082. test 72450 -eq "$Wc_c" ||
  1083.     echo 'pch616-617: original size 72450, current size' "$Wc_c"
  1084. rm -f _shar_wnt_.tmp
  1085. fi
  1086. # ============= torev ==============
  1087. if test -f 'torev' -a X"$1" != X"-c"; then
  1088.     echo 'x - skipping torev (File already exists)'
  1089.     rm -f _shar_wnt_.tmp
  1090. else
  1091. > _shar_wnt_.tmp
  1092. echo 'x - extracting torev (Text)'
  1093. sed 's/^X//' << 'SHAR_EOF' > 'torev' &&
  1094. REVISION=`sed -e '/Revision/!D' -e 's/.*$Revision: \([0-9.]*\) .*/\1/' version.c` 
  1095. sed -e s/pname/$name/g -e s/PNAME/$NAME/g \
  1096. X    -e "s%#LIBDIR#%$LIBDIR%g" \
  1097. X    -e "s/#REVISION#/$REVISION/" $1
  1098. SHAR_EOF
  1099. chmod 0444 torev ||
  1100. echo 'restore of torev failed'
  1101. Wc_c="`wc -c < 'torev'`"
  1102. test 189 -eq "$Wc_c" ||
  1103.     echo 'torev: original size 189, current size' "$Wc_c"
  1104. rm -f _shar_wnt_.tmp
  1105. fi
  1106. rm -f _shar_seq_.tmp
  1107. echo You have unpacked the last part
  1108. exit 0
  1109. exit 0 # Just in case...
  1110. exit 0 # Just in case...
  1111. -- 
  1112. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1113. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1114. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1115. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1116.