Print this page
5083 avoid undefined order of operations in assignments


  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  28 /*        All Rights Reserved   */
  29 
  30 /*
  31  * University Copyright- Copyright (c) 1982, 1986, 1988
  32  * The Regents of the University of California
  33  * All Rights Reserved
  34  *
  35  * University Acknowledgment- Portions of this document are derived from
  36  * software developed by the University of California, Berkeley, and its
  37  * contributors.
  38  */
  39 
  40 #pragma ident   "%Z%%M% %I%     %E% SMI"
  41 
  42 /*
  43  * t6.c
  44  * 
  45  * width functions, sizes and fonts
  46  */
  47 
  48 #include "tdef.h"
  49 #include "dev.h"
  50 #include <ctype.h>
  51 #include "ext.h"
  52 
  53 /* fitab[f][c] is 0 if c is not on font f */
  54         /* if it's non-zero, c is in fontab[f] at position
  55          * fitab[f][c].
  56          */
  57 extern  struct Font *fontbase[NFONT+1];
  58 extern  char *codetab[NFONT+1];
  59 extern int nchtab;
  60 
  61 int     fontlab[NFONT+1];


 483         if ((j = findft(i)) == -1)
 484                 if ((j = setfp(0, i, 0)) == -1) /* try to put it in position 0 */
 485                         return (0);
 486 s0:
 487         font1 = font;
 488         font = j;
 489         mchbits();
 490 
 491         return (0);
 492 }
 493 
 494 
 495 int
 496 setwd()
 497 {
 498         int     base, wid;
 499         tchar i;
 500         int     delim, emsz, k;
 501         int     savhp, savapts, savapts1, savfont, savfont1, savpts, savpts1;
 502 
 503         base = numtab[ST].val = numtab[ST].val = wid = numtab[CT].val = 0;
 504         if (ismot(i = getch()))
 505                 return (0);
 506         delim = cbits(i);
 507         savhp = numtab[HP].val;
 508         numtab[HP].val = 0;
 509         savapts = apts;
 510         savapts1 = apts1;
 511         savfont = font;
 512         savfont1 = font1;
 513         savpts = pts;
 514         savpts1 = pts1;
 515         setwdf++;
 516         while (cbits(i = getch()) != delim && !nlflg) {
 517                 k = width(i);
 518                 wid += k;
 519                 numtab[HP].val += k;
 520                 if (!ismot(i)) {
 521                         emsz = POINT * xpts;
 522                 } else if (isvmot(i)) {
 523                         k = absmot(i);




  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  28 /*        All Rights Reserved   */
  29 
  30 /*
  31  * University Copyright- Copyright (c) 1982, 1986, 1988
  32  * The Regents of the University of California
  33  * All Rights Reserved
  34  *
  35  * University Acknowledgment- Portions of this document are derived from
  36  * software developed by the University of California, Berkeley, and its
  37  * contributors.
  38  */
  39 


  40 /*
  41  * t6.c
  42  *
  43  * width functions, sizes and fonts
  44  */
  45 
  46 #include "tdef.h"
  47 #include "dev.h"
  48 #include <ctype.h>
  49 #include "ext.h"
  50 
  51 /* fitab[f][c] is 0 if c is not on font f */
  52         /* if it's non-zero, c is in fontab[f] at position
  53          * fitab[f][c].
  54          */
  55 extern  struct Font *fontbase[NFONT+1];
  56 extern  char *codetab[NFONT+1];
  57 extern int nchtab;
  58 
  59 int     fontlab[NFONT+1];


 481         if ((j = findft(i)) == -1)
 482                 if ((j = setfp(0, i, 0)) == -1) /* try to put it in position 0 */
 483                         return (0);
 484 s0:
 485         font1 = font;
 486         font = j;
 487         mchbits();
 488 
 489         return (0);
 490 }
 491 
 492 
 493 int
 494 setwd()
 495 {
 496         int     base, wid;
 497         tchar i;
 498         int     delim, emsz, k;
 499         int     savhp, savapts, savapts1, savfont, savfont1, savpts, savpts1;
 500 
 501         base = numtab[ST].val = wid = numtab[CT].val = 0;
 502         if (ismot(i = getch()))
 503                 return (0);
 504         delim = cbits(i);
 505         savhp = numtab[HP].val;
 506         numtab[HP].val = 0;
 507         savapts = apts;
 508         savapts1 = apts1;
 509         savfont = font;
 510         savfont1 = font1;
 511         savpts = pts;
 512         savpts1 = pts1;
 513         setwdf++;
 514         while (cbits(i = getch()) != delim && !nlflg) {
 515                 k = width(i);
 516                 wid += k;
 517                 numtab[HP].val += k;
 518                 if (!ismot(i)) {
 519                         emsz = POINT * xpts;
 520                 } else if (isvmot(i)) {
 521                         k = absmot(i);