File: jpc_utils.c

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (95 lines) | stat: -rw-r--r-- 3,148 bytes parent folder | download | duplicates (2)
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
/*****************************************************************************
 *  Based on
 *  xdbx - X Window System interface to the dbx debugger
 *
 *  Copyright 1989 The University of Texas at Austin
 *  Copyright 1990 Microelectronics and Computer Technology Corporation
 *
 *  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 name of The University of Texas
 *  and Microelectronics and Computer Technology Corporation (MCC) not be 
 *  used in advertising or publicity pertaining to distribution of
 *  the software without specific, written prior permission.  The
 *  University of Texas and MCC makes no representations about the 
 *  suitability of this software for any purpose.  It is provided "as is" 
 *  without express or implied warranty.
 *
 *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
 *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
 *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC 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.
 *
 *  Author:  	Po Cheung
 *  Created:   	March 10, 1989
 *
 *****************************************************************************/

/*  utils.c
 *
 *    Contain common routines used by other functions.
 *
 *    TextGetLastPos():		Get the last insertion position of text.
 *    TextPositionToLine(): 	Return text position give a line number.
 *    LineToStopNo():		Return the stop number given a line number.
 *    DisableWindowResize():	Fix the size of a window inside vpane.
 *    bell():			Ring the bell.
 *    concat():			Concatenate two strings together
 */

#include "jpc_global.h"
#include <string.h> /* in case of dmalloc */ 

#ifdef __STDC__
#include <stdlib.h>
#else
#include <malloc.h>
#endif

void DisableWindowResize(w)
Widget w;
{
    Arg args[MAXARGS];
    Cardinal n;
    Dimension height;

    n = 0;
    XtSetArg(args[n], XtNheight, &height);                       n++;
    XtGetValues(w, args, n);
    XawPanedSetMinMax(w,(int) height, (int) height);
    XawPanedAllowResize(w, False);
}


void bell(volume)
int volume;
{
    XBell(XtDisplay(toplevel), volume);
}

/* append string s2 to end of string s1 and return the result */

char *concat(s1, s2)
char *s1, *s2;
{
    if (s2) {
        if (s1 == NULL) {
            s1 = XtMalloc((Cardinal) (strlen(s2)+1)*sizeof(char));
            strcpy(s1, s2);
        }
        else {
            s1 = XtRealloc(s1, (Cardinal) strlen(s1)+strlen(s2)+2);
            strcat(s1, s2);
        }
    }
#if 0	/*(PW)4DEC90 : bug ! if s2 is null, there is no reason to set s1 to 0 */
    else
        s1 = NULL;
#endif
    return (s1);
}