summaryrefslogtreecommitdiff
path: root/sysutils/xperfmon3/files/patch-aa
blob: d39791572c8c6e1b77d699d4516dde6842f8a4e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
*** ../xperfmon++/StripChart.c	Wed Jul 27 22:29:30 1994
--- ./StripChart.c	Sun Jan 10 21:14:40 1999
***************
*** 1,4 ****
! /* $XConsortium: StripChart.c,v 1.20 91/05/24 17:20:42 converse Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
--- 1,9 ----
! /*
!  * Enhancement and error correction for FreeBSD-3.X
!  * COPYRIGHT 1998 by Lars K�ller <Lars.Koeller@Uni-Bielefeld.de>
!  *
!  *      $Id: StripChart.c,v 3.8 1999/01/10 20:14:30 lkoeller Exp lkoeller $
!  */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
***************
*** 6,18 ****
  
                          All Rights Reserved
  
! Permission to use, copy, modify, and distribute this software and its 
! documentation for any purpose and without fee is hereby granted, 
  provided that the above copyright notice appear in all copies and that
! both that copyright notice and this permission notice appear in 
  supporting documentation, and that the names of Digital or MIT not be
  used in advertising or publicity pertaining to distribution of the
! software without specific, written prior permission.  
  
  DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
--- 11,23 ----
  
                          All Rights Reserved
  
! Permission to use, copy, modify, and distribute this software and its
! documentation for any purpose and without fee is hereby granted,
  provided that the above copyright notice appear in all copies and that
! both that copyright notice and this permission notice appear in
  supporting documentation, and that the names of Digital or MIT not be
  used in advertising or publicity pertaining to distribution of the
! software without specific, written prior permission.
  
  DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
***************
*** 28,34 ****
   * documentation for any purpose and without fee is hereby granted, provided that
   * the above copyright notice appear in all copies and that both that
   * copyright notice and this permission notice appear in supporting
!  * documentation, and that the name of NASA and Sterling Software (collectively 
   * or individually) are not be used in advertising or
   * publicity pertaining to distribution of the software without specific,
   * written prior permission.  NASA and Sterling Software makes no representations about the
--- 33,39 ----
   * documentation for any purpose and without fee is hereby granted, provided that
   * the above copyright notice appear in all copies and that both that
   * copyright notice and this permission notice appear in supporting
!  * documentation, and that the name of NASA and Sterling Software (collectively
   * or individually) are not be used in advertising or
   * publicity pertaining to distribution of the software without specific,
   * written prior permission.  NASA and Sterling Software makes no representations about the
***************
*** 39,45 ****
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NASA & STERLING SOFTWARE
   * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
!  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   *
   * 1994 Revision
--- 44,50 ----
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NASA & STERLING SOFTWARE
   * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
!  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   *
   * 1994 Revision
***************
*** 48,58 ****
--- 53,71 ----
  
  ******************************************************************/
  
+ #ifndef LINT
+ static char rcsid[] = "$Id: StripChart.c,v 3.8 1999/01/10 20:14:30 lkoeller Exp lkoeller $";
+ #endif
+ 
+ #include "fbsd_vers.h"
+ 
  #include <stdio.h>
  #include <X11/IntrinsicP.h>
  #include <X11/StringDefs.h>
  #include <X11/Xaw/XawInit.h>
  #include "StripCharP.h"
+ 
+ #include "system.h"
  #include <X11/Xfuncs.h>
  
  #define MS_PER_SEC 100
***************
*** 109,114 ****
--- 122,128 ----
  
  #undef offset
  #define LABEL_ROOM 100
+ 
  static void Initialize(), Destroy(), Redisplay(), MoveChart(), SetPoints();
  static Boolean SetValues();
  static int repaint_window();
***************
*** 204,213 ****
  PerfChartWidget w;
  unsigned int which;
  {
!   if (which & FOREGROUND) 
      XtReleaseGC((Widget) w, w->strip_chart.fgGC);
  
!   if (which & HIGHLIGHT) 
      XtReleaseGC((Widget) w, w->strip_chart.hiGC);
  }
  
--- 218,227 ----
  PerfChartWidget w;
  unsigned int which;
  {
!   if (which & FOREGROUND)
      XtReleaseGC((Widget) w, w->strip_chart.fgGC);
  
!   if (which & HIGHLIGHT)
      XtReleaseGC((Widget) w, w->strip_chart.hiGC);
  }
  
***************
*** 215,222 ****
--- 229,251 ----
  static void Initialize (greq, gnew)
      Widget greq, gnew;
  {
+     int i;
+ 
      PerfChartWidget w = (PerfChartWidget)gnew;
  
+     /*
+      * XXX The missing initializations have been made obvious by FreeBSD 2.2's
+      * new (`phk') malloc that doesn't initialize the malloc'ed areas to 0.
+      * Perhaps more bogons will lurk around, but the floating arithmetic ones
+      * have been the most annoying ones since they most likely cause a trap
+      * at startup time.
+      *
+      * Strange that people in the 90's still rely on malloc()
+      * returning an initialized region.
+      */
+     for ( i = 0; i < NUM_VALUES; i++ )
+         w->strip_chart.valuedata[i] = 0.0;
+ 
  /* if we are working with a mono screen then turn off all warnings and alarms */
  
      if ( mono_screen ) {
***************
*** 247,257 ****
      w->strip_chart.currentBG = w->core.background_pixel;
      w->strip_chart.interval = LABEL_ROOM;
      w->strip_chart.max_value = 0.0;
!     w->strip_chart.min_value = 99999.99;
      w->strip_chart.points = NULL;
      SetPoints(w);
  }
!  
  static void Destroy (gw)
       Widget gw;
  {
--- 276,286 ----
      w->strip_chart.currentBG = w->core.background_pixel;
      w->strip_chart.interval = LABEL_ROOM;
      w->strip_chart.max_value = 0.0;
!     w->strip_chart.min_value = 99999;
      w->strip_chart.points = NULL;
      SetPoints(w);
  }
! 
  static void Destroy (gw)
       Widget gw;
  {
***************
*** 265,271 ****
  }
  
  /*
!  * NOTE: This function really needs to recieve graphics exposure 
   *       events, but since this is not easily supported until R4 I am
   *       going to hold off until then.
   */
--- 294,300 ----
  }
  
  /*
!  * NOTE: This function really needs to recieve graphics exposure
   *       events, but since this is not easily supported until R4 I am
   *       going to hold off until then.
   */
***************
*** 295,301 ****
     double value, checkValue;
     Display *dpy = XtDisplay(w);
     Window win = XtWindow(w);
!    
  /*   if (w->strip_chart.update > 0)
         w->strip_chart.interval_id =
         XtAppAddTimeOut(XtWidgetToApplicationContext( (Widget) w),
--- 324,330 ----
     double value, checkValue;
     Display *dpy = XtDisplay(w);
     Window win = XtWindow(w);
! 
  /*   if (w->strip_chart.update > 0)
         w->strip_chart.interval_id =
         XtAppAddTimeOut(XtWidgetToApplicationContext( (Widget) w),
***************
*** 311,321 ****
  
     XtCallCallbacks( (Widget)w, XtNgetValue, (XtPointer)&value );
  
!    /* 
!     * Keep w->strip_chart.max_value up to date, and if this data 
!     * point is off the graph, change the scale to make it fit. 
      */
!    
     if (value > w->strip_chart.max_value) {
         w->strip_chart.max_value = value;
         if (w->strip_chart.max_value > w->strip_chart.scale) {
--- 340,350 ----
  
     XtCallCallbacks( (Widget)w, XtNgetValue, (XtPointer)&value );
  
!    /*
!     * Keep w->strip_chart.max_value up to date, and if this data
!     * point is off the graph, change the scale to make it fit.
      */
! 
     if (value > w->strip_chart.max_value) {
         w->strip_chart.max_value = value;
         if (w->strip_chart.max_value > w->strip_chart.scale) {
***************
*** 323,330 ****
  	   w->strip_chart.interval = repaint_window(w, 0, (int) w->core.width);
         }
     }
!    if (value < w->strip_chart.min_value) 
!        w->strip_chart.min_value = value;
  
     w->strip_chart.valuedata[w->strip_chart.interval] = value;
     if (XtIsRealized((Widget)w)) {
--- 352,359 ----
  	   w->strip_chart.interval = repaint_window(w, 0, (int) w->core.width);
         }
     }
!    if (value < w->strip_chart.min_value)
!      w->strip_chart.min_value = value;
  
     w->strip_chart.valuedata[w->strip_chart.interval] = value;
     if (XtIsRealized((Widget)w)) {
***************
*** 332,391 ****
  		       (int)(w->core.height * value) / w->strip_chart.scale);
  
  /* Check for high warnings and alarms */
!    
         if ( w->strip_chart.highWarn != 99999 ||
  	   w->strip_chart.highAlarm != 99999 ) {
  
  	   if ( w->strip_chart.immediate )
! 	       checkValue = value;
  	   else
! 	       checkValue = w->strip_chart.max_value;
  
  	   if ( checkValue >= w->strip_chart.highAlarm ) { /* check for high alarm */
  	       if ( w->strip_chart.currentBG != w->strip_chart.alarmColor ) {
! 		   XtVaSetValues(w, XtNbackground, w->strip_chart.alarmColor, NULL );
  		   w->strip_chart.currentBG = w->strip_chart.alarmColor;
  	       }
  	   }
  	   else if ( checkValue >= w->strip_chart.highWarn ) { /* check for high warning */
  	       if ( w->strip_chart.currentBG != w->strip_chart.warnColor ) {
! 		   XtVaSetValues(w, XtNbackground, w->strip_chart.warnColor, NULL );
  		   w->strip_chart.currentBG = w->strip_chart.warnColor;
  	       }
  	   }
  	   else {
  	       if ( w->strip_chart.currentBG != w->strip_chart.okColor ) { /* reset to okColor? */
! 		   XtVaSetValues(w, XtNbackground, w->strip_chart.okColor, NULL );
  		   w->strip_chart.currentBG = w->strip_chart.okColor;
  	       }
  	   }
         }
! 	   
  /* Check for low warnings and alarms */
!    
         else if ( w->strip_chart.lowWarn != 0 ||
  	   w->strip_chart.lowAlarm != 0 ) {
  
  	   if ( w->strip_chart.immediate )
! 	       checkValue = value;
  	   else
! 	       checkValue = w->strip_chart.min_value;
  
  	   if ( checkValue <= w->strip_chart.lowAlarm ) { /* check for low alarm */
  	       if ( w->strip_chart.currentBG != w->strip_chart.alarmColor ) {
! 		   XtVaSetValues(w, XtNbackground, w->strip_chart.alarmColor, NULL );
  		   w->strip_chart.currentBG = w->strip_chart.alarmColor;
  	       }
  	   }
  	   else if ( checkValue <= w->strip_chart.lowWarn ) { /* check for low warning */
  	       if ( w->strip_chart.currentBG != w->strip_chart.warnColor ) {
! 		   XtVaSetValues(w, XtNbackground, w->strip_chart.warnColor, NULL );
  		   w->strip_chart.currentBG = w->strip_chart.warnColor;
  	       }
  	   }
  	   else {
  	       if ( w->strip_chart.currentBG != w->strip_chart.okColor ) { /* reset to okColor? */
! 		   XtVaSetValues(w, XtNbackground, w->strip_chart.okColor, NULL );
  		   w->strip_chart.currentBG = w->strip_chart.okColor;
  	       }
  	   }
--- 361,420 ----
  		       (int)(w->core.height * value) / w->strip_chart.scale);
  
  /* Check for high warnings and alarms */
! 
         if ( w->strip_chart.highWarn != 99999 ||
  	   w->strip_chart.highAlarm != 99999 ) {
  
  	   if ( w->strip_chart.immediate )
! 	       checkValue = value / SCALE_HACK;
  	   else
! 	       checkValue = w->strip_chart.max_value / SCALE_HACK;
  
  	   if ( checkValue >= w->strip_chart.highAlarm ) { /* check for high alarm */
  	       if ( w->strip_chart.currentBG != w->strip_chart.alarmColor ) {
! 		   XtVaSetValues((Widget)w, XtNbackground, w->strip_chart.alarmColor, NULL );
  		   w->strip_chart.currentBG = w->strip_chart.alarmColor;
  	       }
  	   }
  	   else if ( checkValue >= w->strip_chart.highWarn ) { /* check for high warning */
  	       if ( w->strip_chart.currentBG != w->strip_chart.warnColor ) {
! 		   XtVaSetValues((Widget)w, XtNbackground, w->strip_chart.warnColor, NULL );
  		   w->strip_chart.currentBG = w->strip_chart.warnColor;
  	       }
  	   }
  	   else {
  	       if ( w->strip_chart.currentBG != w->strip_chart.okColor ) { /* reset to okColor? */
! 		   XtVaSetValues((Widget)w, XtNbackground, w->strip_chart.okColor, NULL );
  		   w->strip_chart.currentBG = w->strip_chart.okColor;
  	       }
  	   }
         }
! 
  /* Check for low warnings and alarms */
! 
         else if ( w->strip_chart.lowWarn != 0 ||
  	   w->strip_chart.lowAlarm != 0 ) {
  
  	   if ( w->strip_chart.immediate )
! 	       checkValue = value / SCALE_HACK;
  	   else
! 	       checkValue = w->strip_chart.min_value / SCALE_HACK;
  
  	   if ( checkValue <= w->strip_chart.lowAlarm ) { /* check for low alarm */
  	       if ( w->strip_chart.currentBG != w->strip_chart.alarmColor ) {
! 		   XtVaSetValues((Widget)w, XtNbackground, w->strip_chart.alarmColor, NULL );
  		   w->strip_chart.currentBG = w->strip_chart.alarmColor;
  	       }
  	   }
  	   else if ( checkValue <= w->strip_chart.lowWarn ) { /* check for low warning */
  	       if ( w->strip_chart.currentBG != w->strip_chart.warnColor ) {
! 		   XtVaSetValues((Widget)w, XtNbackground, w->strip_chart.warnColor, NULL );
  		   w->strip_chart.currentBG = w->strip_chart.warnColor;
  	       }
  	   }
  	   else {
  	       if ( w->strip_chart.currentBG != w->strip_chart.okColor ) { /* reset to okColor? */
! 		   XtVaSetValues((Widget)w, XtNbackground, w->strip_chart.okColor, NULL );
  		   w->strip_chart.currentBG = w->strip_chart.okColor;
  	       }
  	   }
***************
*** 393,413 ****
  
         if ( !w->strip_chart.fillRect ) {			  /* draw line graph */
  	   int y = (int) (w->core.height -
! 			  (int)(w->core.height * 
! 				w->strip_chart.valuedata[w->strip_chart.interval-1] ) / 
  			  w->strip_chart.scale);
  	   XDrawLine(dpy, win, w->strip_chart.fgGC,
! 		     w->strip_chart.interval-1, y, 
  		     w->strip_chart.interval, y1);
         }
         else							  /* draw filled graph */
  	   XFillRectangle(dpy, win, w->strip_chart.fgGC,
! 			  w->strip_chart.interval, y1, 
  			  (unsigned int) 1, w->core.height - y1);
  
         /*
  	* Fill in the graph lines we just painted over.
! 	
  
  	if (w->strip_chart.points != NULL) {
  	w->strip_chart.points[0].x = w->strip_chart.interval;
--- 422,442 ----
  
         if ( !w->strip_chart.fillRect ) {			  /* draw line graph */
  	   int y = (int) (w->core.height -
! 			  (int)(w->core.height *
! 				w->strip_chart.valuedata[w->strip_chart.interval-1] ) /
  			  w->strip_chart.scale);
  	   XDrawLine(dpy, win, w->strip_chart.fgGC,
! 		     w->strip_chart.interval-1, y,
  		     w->strip_chart.interval, y1);
         }
         else							  /* draw filled graph */
  	   XFillRectangle(dpy, win, w->strip_chart.fgGC,
! 			  w->strip_chart.interval, y1,
  			  (unsigned int) 1, w->core.height - y1);
  
         /*
  	* Fill in the graph lines we just painted over.
! 
  
  	if (w->strip_chart.points != NULL) {
  	w->strip_chart.points[0].x = w->strip_chart.interval;
***************
*** 434,440 ****
  #define XDS(s) XDrawString(XtDisplay(w), XtWindow(w), \
  			   w->strip_chart.hiGC, x, y, s, strlen(s))
  
! static int 
  repaint_window(w, left, width)
  PerfChartWidget w;
  int left, width;
--- 463,469 ----
  #define XDS(s) XDrawString(XtDisplay(w), XtWindow(w), \
  			   w->strip_chart.hiGC, x, y, s, strlen(s))
  
! static int
  repaint_window(w, left, width)
  PerfChartWidget w;
  int left, width;
***************
*** 448,455 ****
  
      /* Compute the minimum scale required to graph the data, but don't go
         lower than min_scale. */
!     if (w->strip_chart.interval != 0 || scale <= (int)w->strip_chart.max_value)
        scale = ((int) (w->strip_chart.max_value)) + 1;
      if (scale < w->strip_chart.min_scale)
        scale = w->strip_chart.min_scale;
  
--- 477,486 ----
  
      /* Compute the minimum scale required to graph the data, but don't go
         lower than min_scale. */
! 
!     if (w->strip_chart.interval != 0 || scale <= (int)w->strip_chart.max_value) {
        scale = ((int) (w->strip_chart.max_value)) + 1;
+     }
      if (scale < w->strip_chart.min_scale)
        scale = w->strip_chart.min_scale;
  
***************
*** 461,467 ****
  
        SetPoints(w);
  
!       if (XtIsRealized ((Widget) w)) 
  	XClearWindow (XtDisplay (w), XtWindow (w));
  
      }
--- 492,498 ----
  
        SetPoints(w);
  
!       if (XtIsRealized ((Widget) w))
  	XClearWindow (XtDisplay (w), XtWindow (w));
  
      }
***************
*** 479,502 ****
  /* draw titles */
  
  	if ( w->strip_chart.topLabel ) {
! 	    y = w->core.height/2;
  	    x = 4;
  	    XDS(w->strip_chart.topLabel);
  	}
  	if ( w->strip_chart.botLabel ) {
! 	    y = (w->core.height/2) + w->strip_chart.font_height;
  	    x = 4;
  	    XDS(w->strip_chart.botLabel);
  	}
  
  /* draw scale labels */
! 
  	(void) sprintf(numstring, "%d ", 0);
  	x = LABEL_ROOM - XTW(numstring);
  	y = w->core.height - 1;
  	XDS(numstring);		/* draw min value */
  
  	(void) sprintf(numstring, "%d ", (int)w->strip_chart.max_value );
  	x = LABEL_ROOM - XTW(numstring);
  	y = w->strip_chart.font_height - 4;
  	XDS(numstring);		/* draw max value */
--- 510,540 ----
  /* draw titles */
  
  	if ( w->strip_chart.topLabel ) {
! 	    y = w->core.height/2 - 2;
  	    x = 4;
  	    XDS(w->strip_chart.topLabel);
  	}
  	if ( w->strip_chart.botLabel ) {
! 	    y = (w->core.height/2 - 2) + w->strip_chart.font_height;
  	    x = 4;
  	    XDS(w->strip_chart.botLabel);
  	}
  
  /* draw scale labels */
! #ifdef __FreeBSD__
! 	(void) sprintf(numstring, "%1.1f ", 0.0);
! #else
  	(void) sprintf(numstring, "%d ", 0);
+ #endif
  	x = LABEL_ROOM - XTW(numstring);
  	y = w->core.height - 1;
  	XDS(numstring);		/* draw min value */
  
+ #ifdef __FreeBSD__
+ 	(void) sprintf(numstring, "%01.1f ", w->strip_chart.max_value / SCALE_HACK );
+ #else
  	(void) sprintf(numstring, "%d ", (int)w->strip_chart.max_value );
+ #endif
  	x = LABEL_ROOM - XTW(numstring);
  	y = w->strip_chart.font_height - 4;
  	XDS(numstring);		/* draw max value */
***************
*** 511,525 ****
  
  		if ( i == left && left + 1 == width && width != next ) {
  		    y1 = (int) (w->core.height -
! 				(int)(w->core.height * w->strip_chart.valuedata[i-1]) /
! 				w->strip_chart.scale);
  		    XDrawLine(dpy, win, w->strip_chart.fgGC,
  			      i-1, y1, i, y);
  		}
  		else if ( i == left )	{ /* If this is the leftmost point, then just plot it. */
! 		    
  		    XDrawPoint(dpy, win, w->strip_chart.fgGC, i, y);
! 		} 
  		else	{
  		    /* If this is not the left most point, then draw a line
  		     * connecting this point with the one to its left.
--- 549,562 ----
  
  		if ( i == left && left + 1 == width && width != next ) {
  		    y1 = (int) (w->core.height -
! 				(int)(w->core.height * w->strip_chart.valuedata[i-1]) /	w->strip_chart.scale);
  		    XDrawLine(dpy, win, w->strip_chart.fgGC,
  			      i-1, y1, i, y);
  		}
  		else if ( i == left )	{ /* If this is the leftmost point, then just plot it. */
! 
  		    XDrawPoint(dpy, win, w->strip_chart.fgGC, i, y);
! 		}
  		else	{
  		    /* If this is not the left most point, then draw a line
  		     * connecting this point with the one to its left.
***************
*** 536,542 ****
  		int y = (int) (w->core.height -
  				(int)(w->core.height * w->strip_chart.valuedata[i]) /
  				w->strip_chart.scale);
! 		XFillRectangle(dpy, win, w->strip_chart.fgGC, 
  			       i,	                                  /* x */
  			       y,					  /* y */
  			       (unsigned int) 1,			  /* width */
--- 573,579 ----
  		int y = (int) (w->core.height -
  				(int)(w->core.height * w->strip_chart.valuedata[i]) /
  				w->strip_chart.scale);
! 		XFillRectangle(dpy, win, w->strip_chart.fgGC,
  			       i,	                                  /* x */
  			       y,					  /* y */
  			       (unsigned int) 1,			  /* width */
***************
*** 545,551 ****
  
  	}
  
! 	/************** Draw graph reference lines 
  	for (i = 1; i < w->strip_chart.scale; i++) {
  	    j = i * ((int)w->core.height / w->strip_chart.scale);
  	    XDrawLine(dpy, win, w->strip_chart.hiGC, left , j, scalewidth, j);
--- 582,588 ----
  
  	}
  
! 	/************** Draw graph reference lines
  	for (i = 1; i < w->strip_chart.scale; i++) {
  	    j = i * ((int)w->core.height / w->strip_chart.scale);
  	    XDrawLine(dpy, win, w->strip_chart.hiGC, left , j, scalewidth, j);
***************
*** 582,598 ****
      bcopy((char *)(w->strip_chart.valuedata + next - j),
  	  (char *)(w->strip_chart.valuedata), j * sizeof(double));
      next = w->strip_chart.interval = j;
! 	
      /*
!      * Since we just lost some data, recompute the 
!      * w->strip_chart.max_value, and min_value. 
       */
  
      old_max = w->strip_chart.max_value;
      w->strip_chart.max_value = 0.0;
!     w->strip_chart.min_value = 99999.99;
      for (i = LABEL_ROOM; i < next; i++) {
!       if (w->strip_chart.valuedata[i] > w->strip_chart.max_value) 
  	w->strip_chart.max_value = w->strip_chart.valuedata[i];
        if ( w->strip_chart.valuedata[i] < w->strip_chart.min_value )
  	  w->strip_chart.min_value = w->strip_chart.valuedata[i];
--- 619,645 ----
      bcopy((char *)(w->strip_chart.valuedata + next - j),
  	  (char *)(w->strip_chart.valuedata), j * sizeof(double));
      next = w->strip_chart.interval = j;
! 
      /*
!      * Since we just lost some data, recompute the
!      * w->strip_chart.max_value, and min_value.
       */
  
      old_max = w->strip_chart.max_value;
+     /*
+      * To avoid scaling of Free Swap cause it changes so slow, it's
+      * better to not change the max value of 100%
+      */
+ #ifdef __FreeBSD__
+     if ( strcmp(w->strip_chart.botLabel, botNames[FRE_MEM]) != 0 )
+ 	w->strip_chart.max_value = 0.0;
+ #else
      w->strip_chart.max_value = 0.0;
! #endif
! 
!     w->strip_chart.min_value = 99999;
      for (i = LABEL_ROOM; i < next; i++) {
!       if (w->strip_chart.valuedata[i] > w->strip_chart.max_value)
  	w->strip_chart.max_value = w->strip_chart.valuedata[i];
        if ( w->strip_chart.valuedata[i] < w->strip_chart.min_value )
  	  w->strip_chart.min_value = w->strip_chart.valuedata[i];
***************
*** 611,622 ****
  	      (unsigned int) j-LABEL_ROOM, (unsigned int) w->core.height,
  	      LABEL_ROOM, 0);
  
!     XClearArea(XtDisplay((Widget)w), XtWindow((Widget)w), 
! 	       (int) j, 0, 
  	       (unsigned int) w->core.width - j, (unsigned int)w->core.height,
  	       FALSE);
  
!     /* Draw graph reference lines 
      left = j;
      for (i = 1; i < w->strip_chart.scale; i++) {
        j = i * ((int)w->core.height / w->strip_chart.scale);
--- 658,669 ----
  	      (unsigned int) j-LABEL_ROOM, (unsigned int) w->core.height,
  	      LABEL_ROOM, 0);
  
!     XClearArea(XtDisplay((Widget)w), XtWindow((Widget)w),
! 	       (int) j, 0,
  	       (unsigned int) w->core.width - j, (unsigned int)w->core.height,
  	       FALSE);
  
!     /* Draw graph reference lines
      left = j;
      for (i = 1; i < w->strip_chart.scale; i++) {
        j = i * ((int)w->core.height / w->strip_chart.scale);
***************
*** 645,663 ****
  				draw_graph, (XtPointer)w);
      }
  */
      if ( w->strip_chart.min_scale > (int) ((w->strip_chart.max_value) + 1) )
        ret_val = TRUE;
!      
      if ( w->strip_chart.fgpixel != old->strip_chart.fgpixel ) {
        new_gc |= FOREGROUND;
        ret_val = True;
      }
!     
      if ( w->strip_chart.hipixel != old->strip_chart.hipixel ) {
        new_gc |= HIGHLIGHT;
        ret_val = True;
      }
!     
      DestroyGC(old, new_gc);
      CreateGC(w, new_gc);
  
--- 692,714 ----
  				draw_graph, (XtPointer)w);
      }
  */
+ #ifdef __FreeBSD__
+     if ( w->strip_chart.min_scale > ((w->strip_chart.max_value)) )
+ #else
      if ( w->strip_chart.min_scale > (int) ((w->strip_chart.max_value) + 1) )
+ #endif
        ret_val = TRUE;
! 
      if ( w->strip_chart.fgpixel != old->strip_chart.fgpixel ) {
        new_gc |= FOREGROUND;
        ret_val = True;
      }
! 
      if ( w->strip_chart.hipixel != old->strip_chart.hipixel ) {
        new_gc |= HIGHLIGHT;
        ret_val = True;
      }
! 
      DestroyGC(old, new_gc);
      CreateGC(w, new_gc);
  
***************
*** 686,701 ****
  	w->strip_chart.points = NULL;
  	return;
      }
!     
!     size = sizeof(XPoint) * (w->strip_chart.scale - 1);
  
      points = (XPoint *) XtRealloc( (XtPointer) w->strip_chart.points, size);
      w->strip_chart.points = points;
  
      /* Draw graph reference lines into clip mask */
  
!     for (i = 1; i < w->strip_chart.scale; i++) {
  	points[i - 1].x = 0;
  	points[i - 1].y = HEIGHT / w->strip_chart.scale;
      }
  }
--- 737,753 ----
  	w->strip_chart.points = NULL;
  	return;
      }
! 
!     size = sizeof(XPoint) * (w->strip_chart.scale - 1) / SCALE_HACK;
  
      points = (XPoint *) XtRealloc( (XtPointer) w->strip_chart.points, size);
      w->strip_chart.points = points;
  
      /* Draw graph reference lines into clip mask */
  
!     for (i = 1; i < w->strip_chart.scale / SCALE_HACK; i++) {
  	points[i - 1].x = 0;
  	points[i - 1].y = HEIGHT / w->strip_chart.scale;
      }
+ 
  }