1 /*
2  *  The Regina Rexx Interpreter
3  *  Copyright (C) 1992-1994  Anders Christensen <anders@pvv.unit.no>
4  *
5  *  This library is free software; you can redistribute it and/or
6  *  modify it under the terms of the GNU Library General Public
7  *  License as published by the Free Software Foundation; either
8  *  version 2 of the License, or (at your option) any later version.
9  *
10  *  This library is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  *  Library General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Library General Public
16  *  License along with this library; if not, write to the Free
17  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 #ifndef _STRINGS_ALREADY_DEFINED_
20 #define _STRINGS_ALREADY_DEFINED_
21 
22 typedef struct strengtype {
23    int len, max ;
24 #ifdef CHECK_MEMORY                     /* FGC: Test                         */
25    char *value;
26 #else
27    char value[4] ;
28 #endif
29 } streng ;
30 
31 /*
32  * Some strange define's to allow constant strengs to be defined. They will
33  * be accessible as pointers.
34  */
35 #ifdef CHECK_MEMORY
36 #  define conststreng(name,value) const streng __regina__##name = { sizeof( value ) - 1, \
37                                                         sizeof( value ) - 1,             \
38                                                         value };                         \
39                                   const streng *name = (const streng *) &__regina__##name
40 #  define staticstreng(name,value) static streng x_##name = { sizeof( value ) - 1,       \
41                                                                 sizeof( value ) - 1,     \
42                                                                 value };                 \
43                                    const static streng *name = (const streng *) &x_##name
44 #else
45 #  define conststreng(name,value) const struct {                               \
46                                      int len, max;                             \
47                                      char content[sizeof( value )];            \
48                                   } x__regina__##name = { sizeof( value ) - 1, \
49                                                 sizeof( value ) - 1,           \
50                                                 value };                       \
51                                   const streng *name = (streng *) &x__regina__##name
52 #  define staticstreng(name,value) static struct {                     \
53                                       int len, max;                    \
54                                       char content[sizeof( value )];   \
55                                    } x_##name = { sizeof( value ) - 1, \
56                                                  sizeof( value ) - 1,  \
57                                                  value };              \
58                                    static const streng *name = (const streng *) &x_##name
59 #endif
60 #define STRENG_TYPEDEFED 1
61 
62 #define Str_len(a) ((a)->len)
63 #define Str_max(a) ((a)->max)
64 #define Str_val(a) ((a)->value)
65 #define Str_in(a,b) (Str_len(a)>(b))
66 #define Str_end(a) ((a)->value+Str_len(a))
67 #define Str_zero(a) ((Str_len(a)<Str_max(a)) && ((a)->value[(a)->len]==0x00))
68 
69 
70 #define STRHEAD (1+(sizeof(int)<<1))
71 
72 
73 typedef struct num_descr_type
74 {
75    char *num ;      /* pointer to matissa of precision + 1 */
76    int negative ;   /* boolean, true if negative number */
77    int exp ;        /* value of exponent */
78    int size ;       /* how much of num is actually used */
79    int max ;        /* how much can num actually take */
80 
81    /*
82     * The number has an absolute value of
83     *   *********************
84     *   * "0."<num>"E"<exp> *
85     *   *********************
86     * Only size byte of num are used.
87     *
88     * The number of used digits depends on its usage. In general, it's a good
89     * idea to use the standard value. used_digits shall be reset after each
90     * computation and may or may not be respected. It shall be respected, and
91     * this is the intention, by str_norm and all other function which make
92     * a string from the number accidently. Functions like string_add may
93     * or may not use this value.
94     * fixes bug 675395
95     */
96    int used_digits;
97 } num_descr ;
98 
99 
100 #endif /* _STRINGS_ALREADY_INCLUDED_ */
101