[comp.sources.bugs] Monthtool from comp.sources.unix

apl_aimh@jhunix.UUCP (Marty Hall) (11/06/87)

Has anyone out there gotten monthtool to work on the Sun?  With me,
it seemed to compile OK, and looked nice.  The only anomoly was that
when I clicked on any reminder icon, I got "^?" in the text window,
instead of that icon.  However, when I saved anything, so that there
was a ".monthtool" file in my home directory, the next time I
brought up monthtool it would give me a segmentation fault and
dump the core.  Deleting ".monthtool" would solve the problem until
the next time I saved anything, exited monthtool, and came back.

Monthtool looks nice (and useful), so if anyone has gotten it to work,
please let me know.

Thanks!
                                                - Marty Hall

wagner@rocky.STANFORD.EDU (Juergen Wagner) (11/09/87)

I have it running on Suns. The problem with your version seems to be the fact
that you haven't installed the font correctly. In fact, the four characters
used to indicate the type of entry (once, daily, monthly, yearly) are special
characters in a special font. See the source for the parameter to tweak. That
shouldn't be too complicated (I unshar'ed the package, entered local params,
and compiled it: everything ran well).

Juergen Wagner,			        gandalf@Russell.stanford.edu
Center for the Study of Language and Information (CSLI), Stanford CA

barnett@vdsvax.steinmetz.UUCP (Bruce G Barnett) (11/11/87)

In article <743@rocky.STANFORD.EDU> wagner@rocky.UUCP (Juergen Wagner) writes:
|I have it running on Suns. The problem with your version seems to be the fact
|that you haven't installed the font correctly. 
| []
| See the source for the parameter to tweak. That
|shouldn't be too complicated (I unshar'ed the package, entered local params,
|and compiled it: everything ran well).
|
|Juergen Wagner,			        gandalf@Russell.stanford.edu
|Center for the Study of Language and Information (CSLI), Stanford CA

Well - I also had problems with monthtool. I tweaked the Makefile
modifying SRCDIR and MANDIR, did a make install - and I, too, get the
^? as the first character of each reminder - which should - i believe -
be one of the four special characters for month, day, year or the
plain box. I get the proper characters in the panel above the text
subwindow.

As far as I can tell - I click a date, type in a reminder, and click
the reminder type button. - This should insert the special character 
before the current text line. But I just get "^?".

I'm running SunOS 3.4.2. What gives?


-- 
	Bruce G. Barnett 	<barnett@ge-crd.ARPA> <barnett@steinmetz.UUCP>
				uunet!steinmetz!barnett

maeder@symcom.math.uiuc.EDU (11/11/87)

responding to the 'monthtool' problems on the Sun:

The special characters to denote the type of entry in the text subwindow
printed as ^?. Making sure the special font was available was not enough
though. I found out that the parameter in the window_create call setting
the font was ignored! it looks like this:

    notesDsply = window_create(frame, TEXTSW,
			       WIN_X, 0,
			       WIN_BELOW, notesPanel,
			       WIN_HEIGHT, WIN_EXTEND_TO_EDGE,
			       WIN_WIDTH, 10000	/* very large number, cuts
			           to actual width */ ,
			>>     WIN_FONT, notesFont,
			       TEXTSW_IGNORE_LIMIT, TEXTSW_INFINITY,
			       0);

I followed this call by:

			       window_set(notesDsply, WIN_FONT, notesFont, 0);

and then it worked fine....

Is there a problem with the sunview library?


Roman E. Maeder
Dept. of Mathematics			UUCP:       ...!uiucuxc!symcom!maeder
Univ. of Illinois at Urbana-Champaign	Internet: maeder@symcom.math.uiuc.edu
---------------------------------------------------------------------------

It is now pitch dark. If you proceed you are likely to be eaten by a grue.

gandalf@russell.UUCP (11/12/87)

Monthtool definitively runs. I believe, the problems with the original
distribution is the special font which has to be installed where monthtool
expects it to be. Actually, I haven't got the original files around, and
the files I am keeping have a number of changes, so I can't compare my
version with the original one. Please, be sure that FONTDIR is set to
the correct value. Personally, I don't like setting these variables inside
a program, so my Makefile looks like

LIBS    = -lsuntool -lsunwindow -lpixrect

monthtool:      monthtool.o
        cc $(LDFLAGS) -o monthtool monthtool.o $(LIBS)

monthtool.o:    monthtool.c
        cc $(CFLAGS) -DSTANDALONE -DFONTDIR=\"${LIBDIR}/fonts/\" \
           -c monthtool.c

The font (monthtool.font) is installed in "${LIBDIR}/fonts/". (The trailing
slash is important!! If you omit it you will get ^?, too!) The STANDALONE
is needed if I wish to build a standalone program rather than merging the
tool into my suntools.

Good luck,
Juergen Wagner					gandalf@Russell.stanford.edu
Center for the Study of Language and Information (CSLI), Stanford University

gandalf@russell.UUCP (11/12/87)

Oh, by the way: try
	% file monthtool.font
It should print something like "vfont definition." If not...well, you'd 
better get a new font description file.

--Juergen

steve@mahendo.Jpl.Nasa.Gov (3171) (11/12/87)

The icon for the button in the Reminder types: window comes from the same
font that is supposed to be used in the bottom window.  Since these are
coming out correctly, the program must be finding the font file OK.  The
major difference between these two windows is that the first is a Panel
while the second is a Text window.  In the Release notes for 3.4, on page
108, it says:

	"You cannot create a text subwindow with a given font; you have
	to create the text subwindow, then use window_set() to set the font."

and this is where the problem arises.  If you modify the source to do the
window_set() suggested by Sun the problem goes away.  Diffs follow:


*** monthtool.c.old	Thu Nov 12 12:12:13 1987
--- monthtool.c	Thu Nov 12 12:12:19 1987
***************
*** 380,385 ****
--- 380,386 ----
  				WIN_FONT, notesFont,
  				TEXTSW_IGNORE_LIMIT, TEXTSW_INFINITY,
  				0);
+ 	window_set( notesDsply, WIN_FONT, notesFont, 0);
  
  	/* Set up panels */
  

dan@rna.UUCP (Dan Ts'o) (11/13/87)

	Monthtool is a really nice program that was just what I wanted.
However it suffers from some bad bugs. For example, it is extremely finicky
about the format of the .monthtool file and will easily core dump if this
file is constructed improperly. I have some bug fixes and plan on working on
it some more... but watch out for the .monthtool format if you're getting
core dumps...

barnett@steinmetz.UUCP (Bruce G Barnett) (11/13/87)

In article <672@russell.STANFORD.EDU> gandalf@russell.UUCP (Juergen Wagner) writes:
|Monthtool definitively runs. 

under SunOS 3.2

|The font (monthtool.font) is installed in "${LIBDIR}/fonts/". (The trailing
|slash is important!! If you omit it you will get ^?, too!)

If you compile under SunOS 3.4 you will get the ^? instead of the
proper [D], [M], [Y] characters.

The problem is because these characters are located in the second  half
of the font characters ( i.e. >128 ).

Yet the source defines them using a type of 'char' instead of
'unsigned char'. SunOS 3.4 is VERY strict in type checking, and
the dbxtool gave me an error 'out of range' when I did

	set typeMark[0]='\220'

I changes typeMark and typeChar to be 'unsigned char' but there was
still some problems. I gave up and recompiled it under a SunOS 3.2
system, and the program finally worked properly.

Perhaps someone whom has more time than I can chase this down further.

|
|Good luck,

Ditto

|Juergen Wagner					gandalf@Russell.stanford.edu
|Center for the Study of Language and Information (CSLI), Stanford University

apl_aimh@jhunix.UUCP (Marty Hall) (11/13/87)

Many thanks to the folks who tried to help me out.  Here is what I learned,
which seems to do the job:

Kevin Weiler (kjw@steinmetz.uucp) pointed out that if you make your lines
too long in the text window, even though it seems to take it, it will
cause the segmentation fault/core dump I had when it reads in the .monthtools
file..  I erased my long lines, and no longer have any problems.

Steve (steve@mahendo.jpl.nasa.gov) pointed out that if you have a problem
with "^?" instad of the reminder icons in the text window (there should
be no problem getting the icons in the window where you click on them),
and if you bring up monthtool automatically from you .suntools file,
you can fix the problem by adding "-Wt <pathname to monthtool.font>"
to the line in the .suntools that brings up monthtool.

Thanks again to the people who helped, and hope this helps anyone
else who had similar problems.
				- Marty Hall
-- 
ARPA (preferred) - hall@hopkins-eecs-alpha.arpa
UUCP   - ..seismo!umcp-cs!jhunix!apl_aimh | Bitnet  - apl_aimh@jhunix.bitnet
Artificial Intelligence Group, MS 100/601,  AAI Corp, PO Box 126,
Hunt Valley, MD  21030   (301) 683-6455

sarahm@cognos.uucp (Sarah Metcalfe) (11/17/87)

In article <5419@jhunix.UUCP> apl_aimh@jhunix.UUCP (Marty Hall) writes:
>when I clicked on any reminder icon, I got "^?" in the text window,
>instead of that icon.  

This problem has been reported to me by a number of people.  Someone figured
out that it was a problem with SunOS 3.4;  unfortunately, I only have access
to 3.2, so I was unable to try things out.  Luckily, I just received this fix
from D. Brent Chapman (capmkt!brent) [thank you!].  It works for him under 3.4 
and causes me no problems under 3.2:

---------------------- Start of forwarded message ----------------------

In the current version of SunOS (3.4), SunView ignores the WIN_FONT
parameter in the window_create() function call if you are creating a
window of type TEXTSW, and always uses the user's default font.  This
has been demonstrated, and is documented in passing in the WIN_FONT 
entry on page 332 of the SunView Programmer's Guide (Revision A, 15 Oct 86).
What this means is that notes in the notesDsply window show up in the
default font, rather than in monthtool.font, and therefore don't have
their typeChar (the little 'D', 'T', or 'Y' in a box, or the filled-in
box) displayed properly (they all show up as "^?").  Because of the way 
monthtool is written, I assume that in some past release WIN_FONT 
was _not_ ignored.  

It turns out the workaround for the problem I described previously is 
relatively simple; you just set the environment variable "DEFAULT_FONT"
to the monthtool font before you make any SunView calls.  Appended is a 
set of context diffs between your original code and my modified code.

======== Output of "diff -c monthtool.c.orig monthtool.c"

*** monthtool.c.orig    Mon Nov  9 10:54:17 1987
--- monthtool.c Mon Nov  9 10:58:32 1987
***************
*** 10,15 ****
--- 10,23 ----
      Discussion: Displays a calendar to the screen for a given month.  
                  User may move the mouse to any day of the
                  month and view or enter appointments for that date. 
+ 
+     Modified:   D. Brent Chapman (capmkt!brent), 9 Nov 87
+                     Set the default font (via the "DEFAULT_FONT"
+                     environment variable) to the monthtool font,
+                     so that the program works properly under
+                     SunOS 3.4 (which, for some reason, ignores
+                     the WIN_FONT attribute when creating a TEXTSW
+                     window such as the notesDsply window).
  */
***************
*** 284,289 ****
--- 292,299 ----
                                      31, 31, 30, 
                                      31, 30, 31, 
                                };
+ 
+ char                 fontEnv[80];
  ^L
  main(argc, argv)
  
***************
*** 296,301 ****
--- 306,323 ----
      int     type;
  
  
+     /* set default font */
+ 
+     strcpy(fontString, FONTDIR);
+     strcat(fontString, NORMALFONT);
+ 
+     strcpy(fontEnv, "DEFAULT_FONT=");
+     strcat(fontEnv, fontString);
+     putenv(fontEnv);
+ 
+     font = pf_open(LARGEFONT);              /* Open large sized font. */
+     notesFont = pf_open(fontString);        /* Open regular sized font. */
+ 
      /* Set up menus */
  
      fileMenu = menu_create(MENU_ITEM,
***************
*** 324,334 ****
  
  ^L
      /*  Set up windows */
- 
-     font = pf_open(LARGEFONT);              /* Open large sized font. */
-     strcpy(fontString, FONTDIR);
-     strcat(fontString, NORMALFONT);
-     notesFont ^L= pf_open(fontString);        /* Open regular sized font. */
      frame = window_create(0, FRAME,
                  FRAME_ICON, &monthIcon,
--- 346,351 ----

---------------------- End of forwarded message ----------------------

Hope it helps.

>However, when I saved anything, so that there
>was a ".monthtool" file in my home directory, the next time I
>brought up monthtool it would give me a segmentation fault and
>dump the core.  Deleting ".monthtool" would solve the problem until
>the next time I saved anything, exited monthtool, and came back.

I am at a loss to explain this one.  Please repost if this occurs again.

					
										Sarah Metcalfe

-------

P.S. to Marty Hall:  	I received your mail message and have been trying to
						reply for a while, but we have a very flakey mailer
						and all my messages to you get returned.  I'm glad
						you posted so that I could reply!



-- 
Sarah Metcalfe         decvax!utzoo!dciem!nrcaer!cognos!sarahm
Cognos Incorporated    P.O. Box 9707, 3755 Riverside Drive, 
                       Ottawa, Ontario, CANADA  K1G 3Z4
                       (613) 738-1440

chapman@eris.BERKELEY.EDU (Brent Chapman) (11/24/87)

In article <1770@cognos.UUCP> sarahm@batman.UUCP (Sarah Metcalfe) writes:
>In article <5419@jhunix.UUCP> apl_aimh@jhunix.UUCP (Marty Hall) writes:
>>when I clicked on any reminder icon, I got "^?" in the text window,
>>instead of that icon.  
>
>This problem has been reported to me by a number of people.  Someone figured
>out that it was a problem with SunOS 3.4;  unfortunately, I only have access
>to 3.2, so I was unable to try things out.  Luckily, I just received this fix
>from D. Brent Chapman (capmkt!brent) [thank you!].  It works for him under 3.4 
>and causes me no problems under 3.2:

My overly long and complicated commentary and fix deleted; it turns 
out there is a simple one-line fix that does the same thing.  BTW, yes,
I am capmkt!brent, and yes, that's not where this article is coming 
from.

Instead of all that crap I sent to Sarah (a late-night hack that should
never have seen the light of day), just put the following line _after_
the line that says "notesDsply = window_create(...);" (I don't have the 
source available on this machine, so I'm working from memory):

    window_set(notesDsply, WIN_FONT, notesFont, 0);

For some damn dumb reason, the 3.4 window_create() call ignores the WIN_FONT
parameter when initially setting up the window, but calling window_set()
immediately after window_create() works just fine.  I've been using monthtool
for a couple of weeks now with no other major problems.  It _is_ documented
that calls to window_create() for TEXTSW windows ignore WIN_FONT parameters
in the SunView Programmer's Guide (page 332), but the documentation is skimpy
at best, and seems to imply that WIN_FONT _never_ has any effect on TEXTSW
windows.

As far as I could tell, the overlapping "Today" and arrow buttons are because
the program can't find the "monthtool.font" file, and is using the default font
to display "Today", which is too large.  Make sure your path to the 
monthtool.font file is set correctly (in the Makefile, if I remember right),
and everything should work.

My users and I really love the tool; most of us have it rigged to come up open
to today's messages in our .suntools files so it's there when we log in.  Many
thanks to Sarah (& Co., if any; like I said, I don't have the source available 
to check right now) for a very useful tool.


-Brent
--
Brent Chapman					Capital Market Technology, Inc.
Senior Programmer/Analyst			1995 University Ave., Suite 390
{lll-tis,ucbvax!cogsci}!capmkt!brent		Berkeley, CA  94704
capmkt!brent@{lll-tis.arpa,cogsci.berkeley.edu} Phone: 415/540-6400