[comp.windows.interviews] fix3 for 3.0-beta

interran@lurch.Stanford.EDU (John Interrante) (05/03/91)

I've archived some more fixes in ~ftp/pub/3.0-fixes/fix3 on
interviews.stanford.edu.  For people's convenience, I'll enclose the
contents of fix3 in this message.
-- 
	Apply with ``patch -p -N < fix3'' at the top of the source tree.

Newsgroups: comp.windows.interviews
From: tkacik@hobbes.cs.gmr.com (Tom Tkacik CS/50)
Date: 26 Apr 91 21:16:53 GMT
Subject: Re: Graphics library problems

In article <9104262050.AA13330@sleepy.cs.wisc.edu>, locascio@CS.WISC.EDU
(James Locascio) writes: 
|> Hi.  I'm trying to link in the graphics library to an application I
am develop-
|> ing.  The code compiles correctly, but every time I try to link, I get and
|> error message stating:
|> 
|> ld: Undefined symbol
|>    Graphic::p
|>    Graphic::identity
|>    Graphic::painters
|>    Graphic::caching

I had the same problem. 

|> When I look at the file "base.h", I notice that these variables are all 
|> declared "static" in the Graphic definition.  Could this be causing the
|> problems?

Yes.  Another file is rasterrect.c.  It contains a static member ColorMaker. 

|> Does anyone have any suggestions?  I am using a SUN 4 workstation.  I
suspect
|> that my compilation/linking options aren't working as I expect, but I don't
|> know where to start to find a fix.

I made the following changes, and things now seem to work.  I even sent them
to the authors and was told that it was the right thing to do.
Hopefully, it will appear with the next set of official patches.
In the mean time, this should do the job for you.

*** /interviews/dist/3.0-beta/iv/src/lib/graphic/base.c	Sat Jan  5 16:59:45 1991
--- iv/src/lib/graphic/base.c	Thu Apr 25 14:00:07 1991
***************
*** 31,36 ****
--- 31,43 ----
  #include <InterViews/Graphic/hash.h>
  #include <InterViews/Graphic/util.h>
  
+ /*****************************************************************************/
+ 
+ Transformer* Graphic::identity;
+ boolean Graphic::caching;
+ GraphicToPainter* Graphic::painters;
+ Painter* Graphic::p;
+ 
  Graphic& Graphic::operator =(Graphic& p) {
      SetColors(p.GetFgColor(), p.GetBgColor());
      FillBg(p.BgFilled());
*** /interviews/dist/3.0-beta/iv/src/lib/graphic/rasterrect.c	Wed Jan 23 11:37:04 1991
--- iv/src/lib/graphic/rasterrect.c	Thu Apr 25 14:00:08 1991
***************
*** 96,101 ****
--- 96,103 ----
  
  /*****************************************************************************/
  
+ ColorMaker* RasterRect::colorMaker;
+ 
  void RasterRect::draw(Canvas *c, Graphic* gs) {
      update(gs);
      pRasterRect(c, 0, 0, raster);

Newsgroups: comp.windows.interviews
From: interran@lurch.Stanford.EDU (John Interrante)
Subject: Re: Installation Report 3.0-beta
In-Reply-To: ege@scs.fiu.edu's message of 27 Apr 91 14:28:50 GMT
Date: 27 Apr 91 23:32:16

In article <3429@kluge.fiu.edu> ege@scs.fiu.edu (Raimund K. Ege) writes:

   During installation we encountered a minor problem for the script files:

   + install -c -m 0755 cpu ../../.././installed/bin/SUN4
   cp: 0755: No such file or directory
   chmod: ../../.././installed/bin/SUN4/0755: No such file or directory

I never saw this problem before, but I can guess what happened.  It
was a combination of three mistakes, two ours and one yours:

 1) We had an executable script called `install' in src/bin/scripts.
 2) You had `.' ahead of /usr/bin in your PATH.
 3) The script had a bug in it.

We should never have had an executable script called install in
src/bin/scripts, but we weren't careful enough when we made the
3.0-beta snapshot.  When you tried to install the script files, make
invoked src/bin/scripts/install instead of /usr/bin/install because
you had `.' ahead of /usr/bin in your PATH.  The script was very old
(it came from X11R3), so it had a bug which caused the error messages
you saw.

You should delete src/bin/scripts/install and you should put `.' last
in your PATH to make sure you don't accidentally invoke an executable
file in the current directory again because it has the same name as a
command.

For anybody who needs it, here's a patch for install.sh which upgrades
it to the version distributed with X11R4.

*** iv/src/bin/scripts/install.sh.save	Wed Nov 28 09:28:44 1990
--- iv/src/bin/scripts/install.sh	Thu May  2 15:33:47 1991
***************
*** 3,9 ****
  #
  # install - install a program, script, or datafile
  #
! # $XConsortium: install.sh,v 1.1 88/11/14 09:46:24 jim Exp $
  #
  # This script is compatible with the BSD install script, but was written
  # from scratch.
--- 3,9 ----
  #
  # install - install a program, script, or datafile
  #
! # $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
  #
  # This script is compatible with the BSD install script, but was written
  # from scratch.
***************
*** 42,54 ****
--- 42,57 ----
  
  	-m) chmodcmd="$chmodprog $2"
  	    shift
+ 	    shift
  	    continue;;
  
  	-o) chowncmd="$chownprog $2"
  	    shift
+ 	    shift
  	    continue;;
  
  	-g) chgrpcmd="$chgrpprog $2"
+ 	    shift
  	    shift
  	    continue;;
  
From: interran@lurch.stanford.edu (John Interrante)
To: rapatel@khnphwzhn.njin.net
CC: dowd@madness.rutgers.edu, vlis@interviews.stanford.edu
In-reply-to: Rocky - Rakesh Patel's message of Mon, 29 Apr 1991 14:59:47 -0400 (EDT) <Mc76oX_01V8X8PHnVq@khnphwzhn.njin.net>
Subject: fix for idraw problem

I had to fix three problems in all with idraw's dashed brushes:

1.  The dash algorithm in brush.c had an off by one error in counting
the number of dashes.

2.  The dash algorithm in brush.c generated an incorrect dash list
when the input pattern started with some zero bits.  Now it
left-shifts the input pattern until it starts with a one bit.

3.  The dash algorithm in pspaint.c unecessarily duplicated the
algorithm in brush.c.  Furthermore, it needed two changes to make the
printout look exactly like the screen.  Now pspaint.c uses brush.c's
algorithm and then makes two changes: it pads the dash list with a
zero if necessary to make its length an even number and it sets the
dash offset to zero since the X11 drawing code always uses a zero dash
offset anyway.

The last change also eliminates the special behavior of "0000"
brushes.  It used to be the case that if you created a brush with
"0000," the printout would say "[] -1 SetB" which had the effect of
drawing a *white* line.  However, the screen would display a solid
line with the current foreground color (usually black) because the X11
drawing code doesn't implement the special case programmed into SetB.
I suspect this special case was a holdover from Modula-2 idraw or
implemented before support for foreground and background colors made
it superfluous.  The user can draw white lines now by setting their
foreground color to white.  These white lines will even appear white
on the screen, while the "0000" lines appeared white only on the
printout.  Therefore, new printouts will no longer say "[] -1 SetB"
for a "0000" brush; instead, they will say "[] 0 SetB" which will make
the line look exactly the same on the printout as it did on the
screen.

*** iv/src/include/InterViews/brush.h.save	Thu Jan 24 12:36:38 1991
--- iv/src/include/InterViews/brush.h	Thu May  2 03:32:31 1991
***************
*** 49,54 ****
--- 49,56 ----
      virtual Coord overlap(Transformer&);
  
      BrushRep* rep();
+ protected:
+     void calc_dashes(int pat, int* dash, int& count);
  private:
      BrushRep* rep_;
  
*** iv/src/lib/InterViews/brush.c.save	Thu Jan 24 13:02:11 1991
--- iv/src/lib/InterViews/brush.c	Thu May  2 03:33:06 1991
***************
*** 28,90 ****
  Brush::Brush(int* p, int c, Coord w) { init_rep(p, c, w); }
  
  Brush::Brush(int pat, Coord w) {
!     int r[16];
      int count;
      unsigned int p = pat & 0xffff;
      
!     if (p == 0xffff || p == 0) {
          count = 0;
-     } else if (p == 0x5555 || p == 0xaaaa) {
-         r[0] = 1;
-         r[1] = 1;
-         count = 2;
-     } else if (p == 0xcccc || p == 0x3333) {
-         r[0] = 2;
-         r[1] = 2;
-         count = 2;
-     } else if (p == 0xf0f0 || p == 0x0f0f) {
-         r[0] = 4;
-         r[1] = 4;
-         count = 2;
-     } else if (p == 0xf000 || p == 0x000f) {
-         r[0] = 4;
-         r[1] = 12;
-         count = 2;
-     } else if (p == 0xff00 || p == 0x00ff) {
-         r[0] = 8;
-         r[1] = 8;
-         count = 2;
-     } else if (p == 0xfff0 || p == 0x0fff) {
-         r[0] = 12;
-         r[1] = 4;
-         count = 2;
      } else {
!         unsigned int m = 1<<15;
!         while ((p & m) == 0) {
!             m >>= 1;
!         }
!         int index = 0;
!         while (m != 0) {
!             int length = 0;
!             while (m != 0 && (p & m) != 0) {
!                 ++length;
!                 m >>= 1;
!             }
!             if (length > 0) {
!                 r[index] = length;
!                 ++index;
!             }
!             length = 0;
!             while (m != 0 && (p & m) == 0) {
!                 ++length;
!                 m >>= 1;
!             }
!             if (length > 0) {
!                 r[index] = length;
!                 ++index;
!             }
!         }
!         count = index - 1;
      }
-     init_rep(r, count, w);
  }
--- 28,88 ----
  Brush::Brush(int* p, int c, Coord w) { init_rep(p, c, w); }
  
  Brush::Brush(int pat, Coord w) {
!     int dash[16];
      int count;
+ 
+     calc_dashes(pat, dash, count);
+     init_rep(dash, count, w);
+ }
+ 
+ void Brush::calc_dashes(int pat, int* dash, int& count) {
      unsigned int p = pat & 0xffff;
      
!     if (p == 0 || p == 0xffff) {
          count = 0;
      } else {
! 	const unsigned int MSB = 1<<15;
! 	while ((p & MSB) == 0) {
! 	    p <<= 1;
! 	}
! 
! 	if (p == 0x8888) {
! 	    dash[0] = 1;
! 	    dash[1] = 3;
! 	    count = 2;
! 	} else if (p == 0xaaaa) {
! 	    dash[0] = 1;
! 	    dash[1] = 1;
! 	    count = 2;
! 	} else if (p == 0xcccc) {
! 	    dash[0] = 2;
! 	    dash[1] = 2;
! 	    count = 2;
! 	} else if (p == 0xeeee) {
! 	    dash[0] = 3;
! 	    dash[1] = 1;
! 	    count = 2;
! 	} else {
! 	    unsigned int m = MSB;
! 	    int index = 0;
! 	    while (m != 0) {
! 		int length = 0;	/* count the consecutive one bits */
! 		while (m != 0 && (p & m) != 0) {
! 		    ++length;
! 		    m >>= 1;
! 		}
! 		dash[index++] = length;
! 
! 		length = 0;	/* count the consecutive zero bits */
! 		while (m != 0 && (p & m) == 0) {
! 		    ++length;
! 		    m >>= 1;
! 		}
! 		if (length > 0) {
! 		    dash[index++] = length;
! 		}
! 	    }
! 	    count = index;
! 	}
      }
  }
*** /tmp/,RCSt1a04276	Thu May  2 03:35:28 1991
--- iv/src/lib/Unidraw/pspaint.c	Thu May  2 03:33:34 1991
***************
*** 31,44 ****
  
  #include <OS/memory.h>
  
- #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  
  /*****************************************************************************/
  
- static const int PSDASHLIMIT = 11;
- 
  PSBrush::PSBrush () : Brush(0) { _none = true; }
  
  PSBrush::PSBrush (int p, int w) : Brush(p, w) {
--- 31,41 ----
***************
*** 49,111 ****
  
  int PSBrush::Width () { return _none ? 0 : Brush::Width(); }
  
! void PSBrush::CalcDashPat (int linepat) {
!     linepat &= 0xffff;		    // mask should always match patternWidth
  
!     if (linepat == 0x0000) {	    // clear brush
! 	_dashpatsize = 0;
! 	_dashoffset = -1;
! 
!     } else if (linepat == 0xffff) { // solid brush
! 	_dashpatsize = 0;
! 	_dashoffset = 0;
! 
!     } else if (linepat == 0x5555) { // dotted brush, store 1 element not 16
! 	_dashpat[0] = 1;
! 	_dashpatsize = 1;
! 	_dashoffset = 1;
! 
!     } else if (linepat == 0xaaaa) { // dotted brush, store 1 element not 16
! 	_dashpat[0] = 1;
! 	_dashpatsize = 1;
! 	_dashoffset = 0;
! 
!     } else {
! 	int i = 0;
! 	while (!((linepat << i) & 0x8000)) {
! 	    ++i;
! 	}
! 	_dashoffset = patternWidth - i + 1;
! 
! 	int j = 0;
! 	boolean currentrun = true;
! 	int length = 0;
! 
! 	for (int k = 0; k < patternWidth; k++) {
!             boolean run = ((linepat << i) & 0x8000) != 0;
! 
! 	    if (run == currentrun) {
! 		++length;
! 	    } else {
! 		_dashpat[j++] = length;
! 		currentrun = !currentrun;
! 		length = 1;
! 	    }
! 	    i = (i == patternWidth) ? 0 : i + 1;
! 	}
! 	if (length > 0) {
! 	    _dashpat[j] = length;
! 	}
! 	_dashpatsize = j + 1;
      }
! 
!     if (_dashpatsize > PSDASHLIMIT) {
! 	fprintf(stderr, "Brush dash pattern 0x%x exceeds maximum ", _linepat);
! 	fprintf(stderr, "length of PostScript dash pattern with ");
! 	fprintf(stderr, "%d elements; truncated to ", _dashpatsize);
! 	fprintf(stderr, "%d elements\n", PSDASHLIMIT);
! 	_dashpatsize = PSDASHLIMIT;
!     }
  }
  
  /*****************************************************************************/
--- 46,59 ----
  
  int PSBrush::Width () { return _none ? 0 : Brush::Width(); }
  
! void PSBrush::CalcDashPat (int pat) {
!     calc_dashes(pat, _dashpat, _dashpatsize);
  
!     /* needed to make printout look exactly like screen */
!     if (_dashpatsize & 1) {
! 	_dashpat[_dashpatsize++] = 0;
      }
!     _dashoffset = 0;
  }
  
  /*****************************************************************************/
--
John Interrante / interran@lurch.stanford.edu