1 /* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */
2 /* From input file "cht-1.7.pp" */
3 
4 
5 #ifdef HAVE_CONFIG_H
6 #include <config.h>
7 #endif
8 
9 #ifndef P2C_H
10 #define P2C_H
11 
12 
13 /* Header file for code generated by "p2c", the Pascal-to-C translator */
14 
15 /* "p2c"  Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation.
16  * By Dave Gillespie, daveg@synaptics.com.  Version 1.21alpha-07.Dec.93.
17  * This file may be copied, modified, etc. in any way.  It is not restricted
18  * by the licence agreement accompanying p2c itself.
19  */
20 
21 
22 #include <stdio.h>
23 #include <unistd.h>
24 #define DOUBLE double
25 
26 
27 
28 /* If the following heuristic fails, compile -DBSD=0 for non-BSD systems,
29    or -DBSD=1 for BSD systems. */
30 
31 #ifdef M_XENIX
32 # define BSD 0
33 #endif
34 
35 #ifdef vms
36 # define BSD 0
37 # ifndef __STDC__
38 #  define __STDC__ 1
39 # endif
40 #endif
41 
42 #ifdef __TURBOC__
43 # define MSDOS 1
44 #endif
45 
46 #ifdef MSDOS
47 # define BSD 0
48 #endif
49 
50 #ifdef FILE       /* a #define in BSD, a typedef in SYSV (hp-ux, at least) */
51 # ifndef BSD	  /*  (a convenient, but horrible kludge!) */
52 #  define BSD 1
53 # endif
54 #endif
55 
56 #ifdef BSD
57 # if !BSD
58 #  undef BSD
59 # endif
60 #endif
61 
62 
63 #if (defined(__STDC__) && !defined(M_XENIX)) || defined(__TURBOC__)
64 # include <stdlib.h>
65 # include <stddef.h>
66 # define HAS_STDLIB
67 # if defined(vms) || defined(__TURBOC__)
68 #  define NON_ANSI_CAT
69 # endif
70 #else
71 # ifndef BSD
72 #  ifndef __TURBOC__
73 #   include <memory.h>
74 #  endif
75 # endif
76 # ifdef hpux
77 #  ifdef _INCLUDE__STDC__
78 #   include <stddef.h>
79 #   include <stdlib.h>
80 #   define HAS_STDLIB
81 #  endif
82 # endif
83 # include <sys/types.h>
84 # if !defined(MSDOS) || defined(__TURBOC__)
85 #  define NON_ANSI_CAT
86 # endif
87 #endif
88 
89 #if defined(NON_ANSI_CAT) && !defined(ANSI_CAT)
90 # ifdef NON_ANSI_CAT_ALTERNATE
91 #  define __CAT__(a,b)a/**/b
92 # else
93 #  define __ID__(a)a
94 #  define __CAT__(a,b)__ID__(a)b
95 # endif
96 #else
97 # define __CAT__(a,b)a##b
98 #endif
99 
100 
101 #ifdef BSD
102 # include <strings.h>
103 # define memcpy(a,b,n) (bcopy(b,a,n),a)
104 # define memcmp(a,b,n) bcmp(a,b,n)
105 # define strchr(s,c) index(s,c)
106 # define strrchr(s,c) rindex(s,c)
107 #else
108 # include <string.h>
109 #endif
110 
111 #include <ctype.h>
112 #include <math.h>
113 #include <setjmp.h>
114 #include <assert.h>
115 
116 
117 #ifndef NO_LACK
118 #ifdef vms
119 
120 #define LACK_LABS
121 #define LACK_MEMMOVE
122 #define LACK_MEMCPY
123 
124 #else
125 
126 #define LACK_LABS       /* Undefine these if your library has these */
127 #define LACK_MEMMOVE
128 
129 #endif
130 #endif
131 
132 
133 typedef struct __p2c_jmp_buf {
134     struct __p2c_jmp_buf *next;
135     jmp_buf jbuf;
136 } __p2c_jmp_buf;
137 
138 
139 /* Warning: The following will not work if setjmp is used simultaneously.
140    This also violates the ANSI restriction about using vars after longjmp,
141    but a typical implementation of longjmp will get it right anyway. */
142 
143 #ifndef FAKE_TRY
144 # define TRY(x)         do { __p2c_jmp_buf __try_jb;  \
145 			     __try_jb.next = __top_jb;  \
146 			     if (!setjmp((__top_jb = &__try_jb)->jbuf)) {
147 # define RECOVER(x)	__top_jb = __try_jb.next; } else {
148 # define RECOVER2(x,L)  __top_jb = __try_jb.next; } else {  \
149 			     if (0) { L: __top_jb = __try_jb.next; }
150 # define ENDTRY(x)      } } while (0)
151 #else
152 # define TRY(x)         if (1) {
153 # define RECOVER(x)     } else do {
154 # define RECOVER2(x,L)  } else do { L: ;
155 # define ENDTRY(x)      } while (0)
156 #endif
157 
158 
159 
160 #ifdef M_XENIX  /* avoid compiler bug */
161 # define SHORT_MAX  (32767)
162 # define SHORT_MIN  (-32768)
163 #endif
164 
165 
166 /* The following definitions work only on twos-complement machines */
167 #ifndef SHORT_MAX
168 # define SHORT_MAX  ((short)(((unsigned short) -1) >> 1))
169 # define SHORT_MIN  (~SHORT_MAX)
170 #endif
171 
172 #ifndef INT_MAX
173 # define INT_MAX    ((int)(((unsigned int) -1) >> 1))
174 # define INT_MIN    (~INT_MAX)
175 #endif
176 
177 #ifndef LONG_MAX
178 # define LONG_MAX   ((long)(((unsigned long) -1) >> 1))
179 # define LONG_MIN   (~LONG_MAX)
180 #endif
181 
182 #ifndef SEEK_SET
183 # define SEEK_SET   0
184 # define SEEK_CUR   1
185 # define SEEK_END   2
186 #endif
187 
188 #ifndef EXIT_SUCCESS
189 # ifdef vms
190 #  define EXIT_SUCCESS  1
191 #  define EXIT_FAILURE  (02000000000L)
192 # else
193 #  define EXIT_SUCCESS  0
194 #  define EXIT_FAILURE  1
195 # endif
196 #endif
197 
198 
199 #define SETBITS  32
200 
201 
202 #if defined(__STDC__) || defined(__TURBOC__)
203 # if !defined(vms) && !defined(M_LINT)
204 #  define Signed    signed
205 # else
206 #  define Signed
207 # endif
208 # define Void       void      /* Void f() = procedure */
209 # ifndef Const
210 #  define Const     const
211 # endif
212 # ifndef Volatile
213 # define Volatile   volatile
214 # endif
215 # ifdef M_LINT
216 #  define PP(x)     ()
217 #  define PV()	    ()
218 typedef char *Anyptr;
219 # else
220 #  define PP(x)     x         /* function prototype */
221 #  define PV()      (void)    /* null function prototype */
222 typedef void *Anyptr;
223 # endif
224 #else
225 # define Signed
226 # define Void       void
227 # ifndef Const
228 #  define Const
229 # endif
230 # ifndef Volatile
231 #  define Volatile
232 # endif
233 # define PP(x)      ()
234 # define PV()       ()
235 typedef char *Anyptr;
236 #endif
237 
238 #ifdef __GNUC__
239 # define Inline     inline
240 #else
241 # define Inline
242 #endif
243 
244 #define Register    register  /* Register variables */
245 #define Char        char      /* Characters (not bytes) */
246 
247 #ifndef Static
248 # define Static     static    /* Private global funcs and vars */
249 #endif
250 
251 #ifndef Local
252 # define Local      static    /* Nested functions */
253 #endif
254 
255 typedef Signed   char schar;
256 typedef unsigned char uchar;
257 typedef unsigned char boolean;
258 
259 #ifndef NO_DECLARE_ALFA
260 typedef Char alfa[10];
261 #endif
262 
263 #ifndef true
264 # define true    1
265 # define false   0
266 #endif
267 
268 #ifndef TRUE
269 # define TRUE    1
270 # define FALSE   0
271 #endif
272 
273 
274 typedef struct {
275     Anyptr proc, link;
276 } _PROCEDURE;
277 
278 #ifndef _FNSIZE
279 # define _FNSIZE  120
280 #endif
281 
282 
283 extern Void    PASCAL_MAIN  PP( (int, Char **) );
284 extern Char    **P_argv;
285 extern int     P_argc;
286 extern short   P_escapecode;
287 extern int     P_ioresult;
288 extern __p2c_jmp_buf *__top_jb;
289 
290 
291 #ifdef P2C_H_PROTO   /* if you have Ansi C but non-prototyped header files */
292 extern Char    *strcat      PP( (Char *, Const Char *) );
293 extern Char    *strchr      PP( (Const Char *, int) );
294 extern int      strcmp      PP( (Const Char *, Const Char *) );
295 extern Char    *strcpy      PP( (Char *, Const Char *) );
296 extern size_t   strlen      PP( (Const Char *) );
297 extern Char    *strncat     PP( (Char *, Const Char *, size_t) );
298 extern int      strncmp     PP( (Const Char *, Const Char *, size_t) );
299 extern Char    *strncpy     PP( (Char *, Const Char *, size_t) );
300 extern Char    *strrchr     PP( (Const Char *, int) );
301 
302 extern Anyptr   memchr      PP( (Const Anyptr, int, size_t) );
303 extern Anyptr   memmove     PP( (Anyptr, Const Anyptr, size_t) );
304 extern Anyptr   memset      PP( (Anyptr, int, size_t) );
305 #ifndef memcpy
306 extern Anyptr   memcpy      PP( (Anyptr, Const Anyptr, size_t) );
307 extern int      memcmp      PP( (Const Anyptr, Const Anyptr, size_t) );
308 #endif
309 
310 extern int      atoi        PP( (Const Char *) );
311 extern double   atof        PP( (Const Char *) );
312 extern long     atol        PP( (Const Char *) );
313 extern double   strtod      PP( (Const Char *, Char **) );
314 extern long     strtol      PP( (Const Char *, Char **, int) );
315 #endif /*P2C_H_PROTO*/
316 
317 #ifndef HAS_STDLIB
318 #ifndef NO_DECLARE_MALLOC
319 extern Anyptr   malloc      PP( (size_t) );
320 extern Void     free        PP( (Anyptr) );
321 #endif
322 #endif
323 
324 extern int      _OutMem     PV();
325 extern int      _CaseCheck  PV();
326 extern int      _NilCheck   PV();
327 extern int	_Escape     PP( (int) );
328 extern int	_EscIO      PP( (int) );
329 extern int	_EscIO2     PP( (int, Char *) );
330 
331 extern long     ipow        PP( (long, long) );
332 extern long     P_imax      PP( (long, long) );
333 extern long     P_imin      PP( (long, long) );
334 extern double   P_rmax      PP( (double, double) );
335 extern double   P_rmin      PP( (double, double) );
336 extern Char    *strsub      PP( (Char *, Char *, int, int) );
337 extern Char    *strltrim    PP( (Char *) );
338 extern Char    *strrtrim    PP( (Char *) );
339 extern Char    *strrpt      PP( (Char *, Char *, int) );
340 extern Char    *strpad      PP( (Char *, Char *, int, int) );
341 extern int      strpos2     PP( (Char *, Char *, int) );
342 extern long     memavail    PV();
343 extern int      P_peek      PP( (FILE *) );
344 extern int      P_eof       PP( (FILE *) );
345 extern int      P_eoln      PP( (FILE *) );
346 extern Void     P_readpaoc  PP( (FILE *, Char *, int) );
347 extern Void     P_readlnpaoc PP( (FILE *, Char *, int) );
348 extern long     P_maxpos    PP( (FILE *) );
349 extern Char    *P_trimname  PP( (Char *, int) );
350 extern long    *P_setunion  PP( (long *, long *, long *) );
351 extern long    *P_setint    PP( (long *, long *, long *) );
352 extern long    *P_setdiff   PP( (long *, long *, long *) );
353 extern long    *P_setxor    PP( (long *, long *, long *) );
354 extern int      P_inset     PP( (unsigned, long *) );
355 extern int      P_setequal  PP( (long *, long *) );
356 extern int      P_subset    PP( (long *, long *) );
357 extern long    *P_addset    PP( (long *, unsigned) );
358 extern long    *P_addsetr   PP( (long *, unsigned, unsigned) );
359 extern long    *P_remset    PP( (long *, unsigned) );
360 extern long    *P_setcpy    PP( (long *, long *) );
361 extern long    *P_expset    PP( (long *, long) );
362 extern long     P_packset   PP( (long *) );
363 extern FILE    *_skipspaces PP( (FILE *) );
364 extern FILE    *_skipnlspaces PP( (FILE *) );
365 
366 
367 /* I/O error handling */
368 #define _CHKIO(cond,ior,val,def)  ((cond) ? P_ioresult=0,(val)  \
369 					  : P_ioresult=(ior),(def))
370 #define _SETIO(cond,ior)          (P_ioresult = (cond) ? 0 : (ior))
371 
372 /* Following defines are suitable for the HP Pascal operating system */
373 #define FileNotFound     10
374 #define FileNotOpen      13
375 #define FileWriteError   38
376 #define BadInputFormat   14
377 #define EndOfFile        30
378 
379 #define FILENOTFOUND     10
380 #define FILENOTOPEN      13
381 #define FILEWRITEERROR   38
382 #define BADINPUTFORMAT   14
383 #define ENDOFFILE        30
384 
385 /* Creating temporary files */
386 #if (defined(BSD) || defined(NO_TMPFILE)) && !defined(HAVE_TMPFILE)
387 # define tmpfile()  (fopen(tmpnam(NULL), "w+"))
388 #endif
389 
390 /* File buffers */
391 #define FILEBUF(f,sc,type) sc int __CAT__(f,_BFLAGS);   \
392 			   sc type __CAT__(f,_BUFFER)
393 #define FILEBUFNC(f,type)  int __CAT__(f,_BFLAGS);   \
394 			   type __CAT__(f,_BUFFER)
395 
396 #define RESETBUF(f,type)   (__CAT__(f,_BFLAGS) = 1)
397 #define SETUPBUF(f,type)   (__CAT__(f,_BFLAGS) = 0)
398 
399 #define GETFBUF(f,type)    (*((__CAT__(f,_BFLAGS) == 1 &&   \
400 			       ((__CAT__(f,_BFLAGS) = 2),   \
401 				fread(&__CAT__(f,_BUFFER),  \
402 				      sizeof(type),1,(f)))),\
403 			      &__CAT__(f,_BUFFER)))
404 #define AGETFBUF(f,type)   ((__CAT__(f,_BFLAGS) == 1 &&   \
405 			     ((__CAT__(f,_BFLAGS) = 2),   \
406 			      fread(__CAT__(f,_BUFFER),  \
407 				    sizeof(type),1,(f)))),\
408 			    __CAT__(f,_BUFFER))
409 
410 #define PUTFBUF(f,type,v)  (GETFBUF(f,type) = (v))
411 #define CPUTFBUF(f,v)      (PUTFBUF(f,char,v))
412 #define APUTFBUF(f,type,v) (memcpy(AGETFBUF(f,type), (v),  \
413 				   sizeof(__CAT__(f,_BUFFER))))
414 
415 #define GET(f,type)        (__CAT__(f,_BFLAGS) == 1 ?   \
416 			    fread(&__CAT__(f,_BUFFER),sizeof(type),1,(f)) :  \
417 			    (__CAT__(f,_BFLAGS) = 1))
418 
419 #define PUT(f,type)        (fwrite(&__CAT__(f,_BUFFER),sizeof(type),1,(f)),  \
420 			    (__CAT__(f,_BFLAGS) = 0))
421 #define CPUT(f)            (PUT(f,char))
422 
423 #define BUFEOF(f)	   (__CAT__(f,_BFLAGS) != 2 && P_eof(f))
424 #define BUFFPOS(f)	   (ftell(f) - (__CAT__(f,_BFLAGS) == 2))
425 
426 typedef struct {
427     FILE *f;
428     int f_BFLAGS;    /* FILEBUFNC(f,Char); */
429     Char f_BUFFER;
430     Char name[_FNSIZE];
431 } _TEXT;
432 
433 /* Memory allocation */
434 #ifdef __GCC__
435 # define Malloc(n)  (malloc(n) ?: (Anyptr)_OutMem())
436 #else
437 extern Anyptr __MallocTemp__;
438 # define Malloc(n)  ((__MallocTemp__ = malloc(n)) ? __MallocTemp__ : (Anyptr)_OutMem())
439 #endif
440 #define FreeR(p)    (free((Anyptr)(p)))    /* used if arg is an rvalue */
441 #define Free(p)     (free((Anyptr)(p)), (p)=NULL)
442 
443 /* sign extension */
444 #define SEXT(x,n)   ((x) | -(((x) & (1L<<((n)-1))) << 1))
445 
446 /* packed arrays */   /* BEWARE: these are untested! */
447 #define P_getbits_UB(a,i,n,L)   ((int)((a)[(i)>>(L)-(n)] >>   \
448 				       (((~(i))&((1<<(L)-(n))-1)) << (n)) &  \
449 				       (1<<(1<<(n)))-1))
450 
451 #define P_getbits_SB(a,i,n,L)   ((int)((a)[(i)>>(L)-(n)] <<   \
452 				       (16 - ((((~(i))&((1<<(L)-(n))-1))+1) <<\
453 					      (n)) >> (16-(1<<(n))))))
454 
455 #define P_putbits_UB(a,i,x,n,L) ((a)[(i)>>(L)-(n)] |=   \
456 				 (x) << (((~(i))&((1<<(L)-(n))-1)) << (n)))
457 
458 #define P_putbits_SB(a,i,x,n,L) ((a)[(i)>>(L)-(n)] |=   \
459 				 ((x) & (1<<(1<<(n)))-1) <<   \
460 				 (((~(i))&((1<<(L)-(n))-1)) << (n)))
461 
462 #define P_clrbits_B(a,i,n,L)    ((a)[(i)>>(L)-(n)] &=   \
463 				 ~( ((1<<(1<<(n)))-1) <<   \
464 				   (((~(i))&((1<<(L)-(n))-1)) << (n))) )
465 
466 /* small packed arrays */
467 #define P_getbits_US(v,i,n)     ((int)((v) >> ((i)<<(n)) & (1<<(1<<(n)))-1))
468 #define P_getbits_SS(v,i,n)     ((int)((long)(v) << (SETBITS - (((i)+1) << (n))) >> (SETBITS-(1<<(n)))))
469 #define P_putbits_US(v,i,x,n)   ((v) |= (x) << ((i) << (n)))
470 #define P_putbits_SS(v,i,x,n)   ((v) |= ((x) & (1<<(1<<(n)))-1) << ((i)<<(n)))
471 #define P_clrbits_S(v,i,n)      ((v) &= ~( ((1<<(1<<(n)))-1) << ((i)<<(n)) ))
472 
473 #define P_max(a,b)   ((a) > (b) ? (a) : (b))
474 #define P_min(a,b)   ((a) < (b) ? (a) : (b))
475 
476 
477 /* Fix ANSI-isms */
478 
479 #ifdef LACK_LABS
480 # ifndef labs
481 #  define labs  my_labs
482    extern long my_labs PP( (long) );
483 # endif
484 #endif
485 
486 #ifdef LACK_MEMMOVE
487 # ifndef memmove
488 #  define memmove  my_memmove
489    extern Anyptr my_memmove PP( (Anyptr, Const Anyptr, size_t) );
490 # endif
491 #endif
492 
493 #ifdef LACK_MEMCPY
494 # ifndef memcpy
495 #  define memcpy  my_memcpy
496    extern Anyptr my_memcpy PP( (Anyptr, Const Anyptr, size_t) );
497 # endif
498 # ifndef memcmp
499 #  define memcmp  my_memcmp
500    extern int my_memcmp PP( (Const Anyptr, Const Anyptr, size_t) );
501 # endif
502 # ifndef memset
503 #  define memset  my_memset
504    extern Anyptr my_memset PP( (Anyptr, int, size_t) );
505 # endif
506 #endif
507 
508 /* Fix toupper/tolower on Suns and other stupid BSD systems */
509 #ifdef toupper
510 # undef toupper
511 # undef tolower
512 # define toupper(c)   my_toupper(c)
513 # define tolower(c)   my_tolower(c)
514 #endif
515 
516 #ifndef _toupper
517 # if 'A' == 65 && 'a' == 97
518 #  define _toupper(c)  ((c)-'a'+'A')
519 #  define _tolower(c)  ((c)-'A'+'a')
520 # else
521 #  ifdef toupper
522 #   undef toupper   /* hope these are shadowing real functions, */
523 #   undef tolower   /* because my_toupper calls _toupper! */
524 #  endif
525 #  define _toupper(c)  toupper(c)
526 #  define _tolower(c)  tolower(c)
527 # endif
528 #endif
529 
530 
531 #endif    /* P2C_H */
532 
533 
534 
535 /* End. */
536 
537 
538 
539 
540 /* Run-time library for use with "p2c", the Pascal to C translator */
541 
542 /* "p2c"  Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation.
543  * By Dave Gillespie, daveg@synaptics.com.  Version --VERSION--.
544  * This file may be copied, modified, etc. in any way.  It is not restricted
545  * by the licence agreement accompanying p2c itself.
546  */
547 
548 
549 
550 
551 
552 #ifndef NO_TIME
553 # include <time.h>
554 #endif
555 
556 
557 #define Isspace(c)  isspace(c)      /* or "((c) == ' ')" if preferred */
558 
559 
560 
561 
562 int P_argc;
563 char **P_argv;
564 
565 short P_escapecode;
566 int P_ioresult;
567 
568 long EXCP_LINE;    /* Used by Pascal workstation system */
569 
570 Anyptr __MallocTemp__;
571 
572 __p2c_jmp_buf *__top_jb;
573 
574 
575 
576 
PASCAL_MAIN(argc,argv)577 void PASCAL_MAIN(argc, argv)
578 int argc;
579 char **argv;
580 {
581     P_argc = argc;
582     P_argv = argv;
583     __top_jb = NULL;
584 
585 #ifdef LOCAL_INIT
586     LOCAL_INIT();
587 #endif
588 }
589 
590 
591 
592 
593 
594 /* In case your system lacks these... */
595 
my_labs(x)596 long my_labs(x)
597 long x;
598 {
599     return((x > 0) ? x : -x);
600 }
601 
602 
603 #ifdef __STDC__
my_memmove(Anyptr d,Const Anyptr s,size_t n)604 Anyptr my_memmove(Anyptr d, Const Anyptr s, size_t n)
605 #else
606 Anyptr my_memmove(d, s, n)
607 Anyptr d, s;
608 register int n;
609 #endif
610 {
611     register char *dd = (char *)d, *ss = (char *)s;
612     if (dd < ss || dd - ss >= n) {
613 #if defined(bcopy) && defined(memcpy)
614         my_memcpy(dd, ss, n);
615 #else
616 	memcpy(dd, ss, n);
617 #endif
618     } else if (n > 0) {
619 	dd += n;
620 	ss += n;
621 	while (n-- > 0)
622 	    *--dd = *--ss;
623     }
624     return d;
625 }
626 
627 
628 #ifdef __STDC__
my_memcpy(Anyptr d,Const Anyptr s,size_t n)629 Anyptr my_memcpy(Anyptr d, Const Anyptr s, size_t n)
630 #else
631 Anyptr my_memcpy(d, s, n)
632 Anyptr d, s;
633 register int n;
634 #endif
635 {
636     register char *ss = (char *)s, *dd = (char *)d;
637     while (n-- > 0)
638 	*dd++ = *ss++;
639     return d;
640 }
641 
642 #ifdef __STDC__
my_memcmp(Const Anyptr s1,Const Anyptr s2,size_t n)643 int my_memcmp(Const Anyptr s1, Const Anyptr s2, size_t n)
644 #else
645 int my_memcmp(s1, s2, n)
646 Anyptr s1, s2;
647 register int n;
648 #endif
649 {
650     register char *a = (char *)s1, *b = (char *)s2;
651     register int i;
652     while (n-- > 0)
653 	if ((i = (*a++) - (*b++)) != 0)
654 	    return i;
655     return 0;
656 }
657 
658 #ifdef __STDC__
my_memset(Anyptr d,int c,size_t n)659 Anyptr my_memset(Anyptr d, int c, size_t n)
660 #else
661 Anyptr my_memset(d, c, n)
662 Anyptr d;
663 register int c;
664 register int n;
665 #endif
666 {
667     register char *dd = (char *)d;
668     while (n-- > 0)
669 	*dd++ = c;
670     return d;
671 }
672 
673 
my_toupper(c)674 int my_toupper(c)
675 int c;
676 {
677     if (islower(c))
678 	return _toupper(c);
679     else
680 	return c;
681 }
682 
683 
my_tolower(c)684 int my_tolower(c)
685 int c;
686 {
687     if (isupper(c))
688 	return _tolower(c);
689     else
690 	return c;
691 }
692 
693 
694 
695 
ipow(a,b)696 long ipow(a, b)
697 long a, b;
698 {
699     long v;
700 
701     if (a == 0 || a == 1)
702 	return a;
703     if (a == -1)
704 	return (b & 1) ? -1 : 1;
705     if (b < 0)
706 	return 0;
707     if (a == 2)
708 	return 1L << b;
709     v = (b & 1) ? a : 1;
710     while ((b >>= 1) > 0) {
711 	a *= a;
712 	if (b & 1)
713 	    v *= a;
714     }
715     return v;
716 }
717 
718 
P_imax(a,b)719 long P_imax(a, b)
720 long a, b;
721 {
722     if (a > b)
723 	return a;
724     else
725 	return b;
726 }
727 
P_imin(a,b)728 long P_imin(a, b)
729 long a, b;
730 {
731     if (a < b)
732 	return a;
733     else
734 	return b;
735 }
736 
737 
P_rmax(a,b)738 double P_rmax(a, b)
739 double a, b;
740 {
741     if (a > b)
742 	return a;
743     else
744 	return b;
745 }
746 
P_rmin(a,b)747 double P_rmin(a, b)
748 double a, b;
749 {
750     if (a < b)
751 	return a;
752     else
753 	return b;
754 }
755 
756 
757 
758 
759 /* Common string functions: */
760 
761 /* Store in "ret" the substring of length "len" starting from "pos" (1-based).
762    Store a shorter or null string if out-of-range.  Return "ret". */
763 
strsub(ret,s,pos,len)764 char *strsub(ret, s, pos, len)
765 register char *ret, *s;
766 register int pos, len;
767 {
768     register char *s2;
769 
770     if (--pos < 0 || len <= 0) {
771         *ret = 0;
772         return ret;
773     }
774     while (pos > 0) {
775         if (!*s++) {
776             *ret = 0;
777             return ret;
778         }
779         pos--;
780     }
781     s2 = ret;
782     while (--len >= 0) {
783         if (!(*s2++ = *s++))
784             return ret;
785     }
786     *s2 = 0;
787     return ret;
788 }
789 
790 
791 /* Return the index of the first occurrence of "pat" as a substring of "s",
792    starting at index "pos" (1-based).  Result is 1-based, 0 if not found. */
793 
strpos2(s,pat,pos)794 int strpos2(s, pat, pos)
795 char *s;
796 register char *pat;
797 register int pos;
798 {
799     register char *cp, ch;
800     register int slen;
801 
802     if (--pos < 0)
803         return 0;
804     slen = strlen(s) - pos;
805     cp = s + pos;
806     if (!(ch = *pat++))
807         return 0;
808     pos = strlen(pat);
809     slen -= pos;
810     while (--slen >= 0) {
811         if (*cp++ == ch && !strncmp(cp, pat, pos))
812             return cp - s;
813     }
814     return 0;
815 }
816 
817 
818 /* Case-insensitive version of strcmp. */
819 
strcicmp(s1,s2)820 int strcicmp(s1, s2)
821 register char *s1, *s2;
822 {
823     register unsigned char c1, c2;
824 
825     while (*s1) {
826 	if (*s1++ != *s2++) {
827 	    if (!s2[-1])
828 		return 1;
829 	    c1 = toupper(s1[-1]);
830 	    c2 = toupper(s2[-1]);
831 	    if (c1 != c2)
832 		return c1 - c2;
833 	}
834     }
835     if (*s2)
836 	return -1;
837     return 0;
838 }
839 
840 
841 
842 
843 /* HP and Turbo Pascal string functions: */
844 
845 /* Trim blanks at left end of string. */
846 
strltrim(s)847 char *strltrim(s)
848 register char *s;
849 {
850     while (Isspace(*s++)) ;
851     return s - 1;
852 }
853 
854 
855 /* Trim blanks at right end of string. */
856 
strrtrim(s)857 char *strrtrim(s)
858 register char *s;
859 {
860     register char *s2 = s;
861 
862     if (!*s)
863 	return s;
864     while (*++s2) ;
865     while (s2 > s && Isspace(*--s2))
866         *s2 = 0;
867     return s;
868 }
869 
870 
871 /* Store in "ret" "num" copies of string "s".  Return "ret". */
872 
strrpt(ret,s,num)873 char *strrpt(ret, s, num)
874 char *ret;
875 register char *s;
876 register int num;
877 {
878     register char *s2 = ret;
879     register char *s1;
880 
881     while (--num >= 0) {
882         s1 = s;
883         while ((*s2++ = *s1++)) ;
884         s2--;
885     }
886     return ret;
887 }
888 
889 
890 /* Store in "ret" string "s" with enough pad chars added to reach "size". */
891 
strpad(ret,s,padchar,num)892 char *strpad(ret, s, padchar, num)
893 char *ret;
894 register char *s;
895 register int padchar, num;
896 {
897     register char *d = ret;
898 
899     if (s == d) {
900 	while (*d++) ;
901     } else {
902 	while ((*d++ = *s++)) ;
903     }
904     num -= (--d - ret);
905     while (--num >= 0)
906 	*d++ = padchar;
907     *d = 0;
908     return ret;
909 }
910 
911 
912 /* Copy the substring of length "len" from index "spos" of "s" (1-based)
913    to index "dpos" of "d", lengthening "d" if necessary.  Length and
914    indices must be in-range. */
915 
strmove(len,s,spos,d,dpos)916 void strmove(len, s, spos, d, dpos)
917 register char *s, *d;
918 register int len, spos, dpos;
919 {
920     s += spos - 1;
921     d += dpos - 1;
922     while (*d && --len >= 0)
923 	*d++ = *s++;
924     if (len > 0) {
925 	while (--len >= 0)
926 	    *d++ = *s++;
927 	*d = 0;
928     }
929 }
930 
931 
932 /* Delete the substring of length "len" at index "pos" from "s".
933    Delete less if out-of-range. */
934 
strdelete(s,pos,len)935 void strdelete(s, pos, len)
936 register char *s;
937 register int pos, len;
938 {
939     register int slen;
940 
941     if (--pos < 0)
942         return;
943     slen = strlen(s) - pos;
944     if (slen <= 0)
945         return;
946     s += pos;
947     if (slen <= len) {
948         *s = 0;
949         return;
950     }
951     while ((*s = s[len])) s++;
952 }
953 
954 
955 /* Insert string "src" at index "pos" of "dst". */
956 
strinsert(src,dst,pos)957 void strinsert(src, dst, pos)
958 register char *src, *dst;
959 register int pos;
960 {
961     register int slen, dlen;
962 
963     if (--pos < 0)
964         return;
965     dlen = strlen(dst);
966     dst += dlen;
967     dlen -= pos;
968     if (dlen <= 0) {
969         strcpy(dst, src);
970         return;
971     }
972     slen = strlen(src);
973     do {
974         dst[slen] = *dst;
975         --dst;
976     } while (--dlen >= 0);
977     dst++;
978     while (--slen >= 0)
979         *dst++ = *src++;
980 }
981 
982 
983 
984 
985 /* File functions */
986 
987 /* Peek at next character of input stream; return EOF at end-of-file. */
988 
P_peek(f)989 int P_peek(f)
990 FILE *f;
991 {
992     int ch;
993 
994     ch = getc(f);
995     if (ch == EOF)
996 	return EOF;
997     ungetc(ch, f);
998     return (ch == '\n') ? ' ' : ch;
999 }
1000 
1001 
1002 /* Check if at end of file, using Pascal "eof" semantics.  End-of-file for
1003    stdin is broken; remove the special case for it to be broken in a
1004    different way. */
1005 
P_eof(f)1006 int P_eof(f)
1007 FILE *f;
1008 {
1009     register int ch;
1010 
1011     if (feof(f))
1012 	return 1;
1013 #ifdef HAVE_ISATTY
1014     if (isatty(fileno(f)))
1015 #else
1016     if (f == stdin)
1017 #endif
1018 	return 0;    /* not safe to look-ahead on the keyboard! */
1019     ch = getc(f);
1020     if (ch == EOF)
1021 	return 1;
1022     ungetc(ch, f);
1023     return 0;
1024 }
1025 
1026 
1027 /* Check if at end of line (or end of entire file). */
1028 
P_eoln(f)1029 int P_eoln(f)
1030 FILE *f;
1031 {
1032     register int ch;
1033 
1034     ch = getc(f);
1035     if (ch == EOF)
1036         return 1;
1037     ungetc(ch, f);
1038     return (ch == '\n');
1039 }
1040 
1041 
1042 /* Skip whitespace (including newlines) in a file. */
1043 
_skipnlspaces(f)1044 FILE *_skipnlspaces(f)
1045 FILE *f;
1046 {
1047   register int ch;
1048 
1049   do {
1050     ch = getc(f);
1051   } while (ch == ' ' || ch == '\t' || ch == '\n');
1052   if (ch != EOF)
1053     ungetc(ch, f);
1054   return f;
1055 }
1056 
1057 
1058 /* Skip whitespace (not including newlines) in a file. */
1059 
_skipspaces(f)1060 FILE *_skipspaces(f)
1061 FILE *f;
1062 {
1063   register int ch;
1064 
1065   do {
1066     ch = getc(f);
1067   } while (ch == ' ' || ch == '\t');
1068   if (ch != EOF)
1069     ungetc(ch, f);
1070   return f;
1071 }
1072 
1073 
1074 /* Read a packed array of characters from a file. */
1075 
P_readpaoc(f,s,len)1076 Void P_readpaoc(f, s, len)
1077 FILE *f;
1078 char *s;
1079 int len;
1080 {
1081     int ch;
1082 
1083     for (;;) {
1084 	if (len <= 0)
1085 	    return;
1086 	ch = getc(f);
1087 	if (ch == EOF || ch == '\n')
1088 	    break;
1089 	*s++ = ch;
1090 	--len;
1091     }
1092     while (--len >= 0)
1093 	*s++ = ' ';
1094     if (ch != EOF)
1095 	ungetc(ch, f);
1096 }
1097 
P_readlnpaoc(f,s,len)1098 Void P_readlnpaoc(f, s, len)
1099 FILE *f;
1100 char *s;
1101 int len;
1102 {
1103     int ch;
1104 
1105     for (;;) {
1106 	ch = getc(f);
1107 	if (ch == EOF || ch == '\n')
1108 	    break;
1109 	if (len > 0) {
1110 	    *s++ = ch;
1111 	    --len;
1112 	}
1113     }
1114     while (--len >= 0)
1115 	*s++ = ' ';
1116 }
1117 
1118 
1119 /* Compute maximum legal "seek" index in file (0-based). */
1120 
P_maxpos(f)1121 long P_maxpos(f)
1122 FILE *f;
1123 {
1124     long savepos = ftell(f);
1125     long val;
1126 
1127     if (fseek(f, 0L, SEEK_END))
1128         return -1;
1129     val = ftell(f);
1130     if (fseek(f, savepos, SEEK_SET))
1131         return -1;
1132     return val;
1133 }
1134 
1135 
1136 /* Use packed array of char for a file name. */
1137 
P_trimname(fn,len)1138 Char *P_trimname(fn, len)
1139 register Char *fn;
1140 register int len;
1141 {
1142     static Char fnbuf[256];
1143     register Char *cp = fnbuf;
1144 
1145     while (--len >= 0 && *fn && !isspace(*fn))
1146 	*cp++ = *fn++;
1147     *cp = 0;
1148     return fnbuf;
1149 }
1150 
1151 
1152 
1153 
1154 /* Pascal's "memavail" doesn't make much sense in Unix with virtual memory.
1155    We fix memory size as 10Meg as a reasonable compromise. */
1156 
memavail()1157 long memavail()
1158 {
1159     return 10000000;            /* worry about this later! */
1160 }
1161 
maxavail()1162 long maxavail()
1163 {
1164     return memavail();
1165 }
1166 
1167 
1168 
1169 
1170 /* Sets are stored as an array of longs.  S[0] is the size of the set;
1171    S[N] is the N'th 32-bit chunk of the set.  S[0] equals the maximum
1172    I such that S[I] is nonzero.  S[0] is zero for an empty set.  Within
1173    each long, bits are packed from lsb to msb.  The first bit of the
1174    set is the element with ordinal value 0.  (Thus, for a "set of 5..99",
1175    the lowest five bits of the first long are unused and always zero.) */
1176 
1177 /* (Sets with 32 or fewer elements are normally stored as plain longs.) */
1178 
P_setunion(d,s1,s2)1179 long *P_setunion(d, s1, s2)         /* d := s1 + s2 */
1180 register long *d, *s1, *s2;
1181 {
1182     long *dbase = d++;
1183     register int sz1 = *s1++, sz2 = *s2++;
1184     while (sz1 > 0 && sz2 > 0) {
1185         *d++ = *s1++ | *s2++;
1186 	sz1--, sz2--;
1187     }
1188     while (--sz1 >= 0)
1189 	*d++ = *s1++;
1190     while (--sz2 >= 0)
1191 	*d++ = *s2++;
1192     *dbase = d - dbase - 1;
1193     return dbase;
1194 }
1195 
1196 
P_setint(d,s1,s2)1197 long *P_setint(d, s1, s2)           /* d := s1 * s2 */
1198 register long *d, *s1, *s2;
1199 {
1200     long *dbase = d++;
1201     register int sz1 = *s1++, sz2 = *s2++;
1202     while (--sz1 >= 0 && --sz2 >= 0)
1203         *d++ = *s1++ & *s2++;
1204     while (--d > dbase && !*d) ;
1205     *dbase = d - dbase;
1206     return dbase;
1207 }
1208 
1209 
P_setdiff(d,s1,s2)1210 long *P_setdiff(d, s1, s2)          /* d := s1 - s2 */
1211 register long *d, *s1, *s2;
1212 {
1213     long *dbase = d++;
1214     register int sz1 = *s1++, sz2 = *s2++;
1215     while (--sz1 >= 0 && --sz2 >= 0)
1216         *d++ = *s1++ & ~*s2++;
1217     if (sz1 >= 0) {
1218         while (sz1-- >= 0)
1219             *d++ = *s1++;
1220     }
1221     while (--d > dbase && !*d) ;
1222     *dbase = d - dbase;
1223     return dbase;
1224 }
1225 
1226 
P_setxor(d,s1,s2)1227 long *P_setxor(d, s1, s2)         /* d := s1 / s2 */
1228 register long *d, *s1, *s2;
1229 {
1230     long *dbase = d++;
1231     register int sz1 = *s1++, sz2 = *s2++;
1232     while (sz1 > 0 && sz2 > 0) {
1233         *d++ = *s1++ ^ *s2++;
1234 	sz1--, sz2--;
1235     }
1236     while (--sz1 >= 0)
1237 	*d++ = *s1++;
1238     while (--sz2 >= 0)
1239 	*d++ = *s2++;
1240     while (--d > dbase && !*d) ;
1241     *dbase = d - dbase;
1242     return dbase;
1243 }
1244 
1245 
P_inset(val,s)1246 int P_inset(val, s)                 /* val IN s */
1247 register unsigned val;
1248 register long *s;
1249 {
1250     register int bit;
1251     bit = val % SETBITS;
1252     val /= SETBITS;
1253     if (val < *s++ && ((1L<<bit) & s[val]))
1254 	return 1;
1255     return 0;
1256 }
1257 
1258 
P_addset(s,val)1259 long *P_addset(s, val)              /* s := s + [val] */
1260 register long *s;
1261 register unsigned val;
1262 {
1263     register long *sbase = s;
1264     register int bit, size;
1265     bit = val % SETBITS;
1266     val /= SETBITS;
1267     size = *s;
1268     if (++val > size) {
1269         s += size;
1270         while (val > size)
1271             *++s = 0, size++;
1272         *sbase = size;
1273     } else
1274         s += val;
1275     *s |= 1L<<bit;
1276     return sbase;
1277 }
1278 
1279 
P_addsetr(s,v1,v2)1280 long *P_addsetr(s, v1, v2)              /* s := s + [v1..v2] */
1281 register long *s;
1282 register unsigned v1, v2;
1283 {
1284     register long *sbase = s;
1285     register int b1, b2, size;
1286     if ((int)v1 > (int)v2)
1287 	return sbase;
1288     b1 = v1 % SETBITS;
1289     v1 /= SETBITS;
1290     b2 = v2 % SETBITS;
1291     v2 /= SETBITS;
1292     size = *s;
1293     v1++;
1294     if (++v2 > size) {
1295         while (v2 > size)
1296             s[++size] = 0;
1297         s[v2] = 0;
1298         *s = v2;
1299     }
1300     s += v1;
1301     if (v1 == v2) {
1302         *s |= (~((-2L)<<(b2-b1))) << b1;
1303     } else {
1304         *s++ |= (-1L) << b1;
1305         while (++v1 < v2)
1306             *s++ = -1;
1307         *s |= ~((-2L) << b2);
1308     }
1309     return sbase;
1310 }
1311 
1312 
P_remset(s,val)1313 long *P_remset(s, val)              /* s := s - [val] */
1314 register long *s;
1315 register unsigned val;
1316 {
1317     register int bit;
1318     bit = val % SETBITS;
1319     val /= SETBITS;
1320     if (++val <= *s) {
1321 	if (!(s[val] &= ~(1L<<bit)))
1322 	    while (*s && !s[*s])
1323 		(*s)--;
1324     }
1325     return s;
1326 }
1327 
1328 
P_setequal(s1,s2)1329 int P_setequal(s1, s2)              /* s1 = s2 */
1330 register long *s1, *s2;
1331 {
1332     register int size = *s1++;
1333     if (*s2++ != size)
1334         return 0;
1335     while (--size >= 0) {
1336         if (*s1++ != *s2++)
1337             return 0;
1338     }
1339     return 1;
1340 }
1341 
1342 
P_subset(s1,s2)1343 int P_subset(s1, s2)                /* s1 <= s2 */
1344 register long *s1, *s2;
1345 {
1346     register int sz1 = *s1++, sz2 = *s2++;
1347     if (sz1 > sz2)
1348         return 0;
1349     while (--sz1 >= 0) {
1350         if (*s1++ & ~*s2++)
1351             return 0;
1352     }
1353     return 1;
1354 }
1355 
1356 
P_setcpy(d,s)1357 long *P_setcpy(d, s)                /* d := s */
1358 register long *d, *s;
1359 {
1360     register long *save_d = d;
1361 
1362 #ifdef SETCPY_MEMCPY
1363     memcpy(d, s, (*s + 1) * sizeof(long));
1364 #else
1365     register int i = *s + 1;
1366     while (--i >= 0)
1367         *d++ = *s++;
1368 #endif
1369     return save_d;
1370 }
1371 
1372 
1373 /* s is a "smallset", i.e., a 32-bit or less set stored
1374    directly in a long. */
1375 
P_expset(d,s)1376 long *P_expset(d, s)                /* d := s */
1377 register long *d;
1378 register long s;
1379 {
1380     if (s) {
1381 	d[1] = s;
1382 	*d = 1;
1383     } else
1384         *d = 0;
1385     return d;
1386 }
1387 
1388 
P_packset(s)1389 long P_packset(s)                   /* convert s to a small-set */
1390 register long *s;
1391 {
1392     if (*s++)
1393         return *s;
1394     else
1395         return 0;
1396 }
1397 
1398 
1399 
1400 
1401 
1402 
1403 
_OutMem()1404 int _OutMem()
1405 {
1406     return _Escape(-2);
1407 }
1408 
_CaseCheck()1409 int _CaseCheck()
1410 {
1411     return _Escape(-9);
1412 }
1413 
_NilCheck()1414 int _NilCheck()
1415 {
1416     return _Escape(-3);
1417 }
1418 
1419 
1420 
1421 
1422 
1423 /* The following is suitable for the HP Pascal operating system.
1424    It might want to be revised when emulating another system. */
1425 
_ShowEscape(buf,code,ior,prefix)1426 char *_ShowEscape(buf, code, ior, prefix)
1427 char *buf, *prefix;
1428 int code, ior;
1429 {
1430     char *bufp;
1431 
1432     if (prefix && *prefix) {
1433         strcpy(buf, prefix);
1434 	strcat(buf, ": ");
1435         bufp = buf + strlen(buf);
1436     } else {
1437         bufp = buf;
1438     }
1439     if (code == -10) {
1440         sprintf(bufp, "Pascal system I/O error %d", ior);
1441         switch (ior) {
1442             case 3:
1443                 strcat(buf, " (illegal I/O request)");
1444                 break;
1445             case 7:
1446                 strcat(buf, " (bad file name)");
1447                 break;
1448             case FileNotFound:   /*10*/
1449                 strcat(buf, " (file not found)");
1450                 break;
1451             case FileNotOpen:    /*13*/
1452                 strcat(buf, " (file not open)");
1453                 break;
1454             case BadInputFormat: /*14*/
1455                 strcat(buf, " (bad input format)");
1456                 break;
1457             case 24:
1458                 strcat(buf, " (not open for reading)");
1459                 break;
1460             case 25:
1461                 strcat(buf, " (not open for writing)");
1462                 break;
1463             case 26:
1464                 strcat(buf, " (not open for direct access)");
1465                 break;
1466             case 28:
1467                 strcat(buf, " (string subscript out of range)");
1468                 break;
1469             case EndOfFile:      /*30*/
1470                 strcat(buf, " (end-of-file)");
1471                 break;
1472             case FileWriteError: /*38*/
1473 		strcat(buf, " (file write error)");
1474 		break;
1475         }
1476     } else {
1477         sprintf(bufp, "Pascal system error %d", code);
1478         switch (code) {
1479             case -2:
1480                 strcat(buf, " (out of memory)");
1481                 break;
1482             case -3:
1483                 strcat(buf, " (reference to NIL pointer)");
1484                 break;
1485             case -4:
1486                 strcat(buf, " (integer overflow)");
1487                 break;
1488             case -5:
1489                 strcat(buf, " (divide by zero)");
1490                 break;
1491             case -6:
1492                 strcat(buf, " (real math overflow)");
1493                 break;
1494             case -8:
1495                 strcat(buf, " (value range error)");
1496                 break;
1497             case -9:
1498                 strcat(buf, " (CASE value range error)");
1499                 break;
1500             case -12:
1501                 strcat(buf, " (bus error)");
1502                 break;
1503             case -20:
1504                 strcat(buf, " (stopped by user)");
1505                 break;
1506         }
1507     }
1508     return buf;
1509 }
1510 
1511 
_Escape(code)1512 int _Escape(code)
1513 int code;
1514 {
1515     char buf[100];
1516 
1517     P_escapecode = code;
1518     if (__top_jb) {
1519 	__p2c_jmp_buf *jb = __top_jb;
1520 	__top_jb = jb->next;
1521 	longjmp(jb->jbuf, 1);
1522     }
1523     if (code == 0)
1524         exit(EXIT_SUCCESS);
1525     if (code == -1)
1526         exit(EXIT_FAILURE);
1527     fprintf(stderr, "%s\n", _ShowEscape(buf, P_escapecode, P_ioresult, ""));
1528     exit(EXIT_FAILURE);
1529 }
1530 
_EscIO(code)1531 int _EscIO(code)
1532 int code;
1533 {
1534     P_ioresult = code;
1535     return _Escape(-10);
1536 }
1537 
_EscIO2(code,name)1538 int _EscIO2(code, name)
1539 int code;
1540 char *name;
1541 {
1542     P_ioresult = code;
1543     if (!__top_jb && name && *name) {
1544 	char buf[100];
1545 	fprintf(stderr, "%s: %s\n",
1546 		name, _ShowEscape(buf, P_escapecode, P_ioresult, ""));
1547 	exit(EXIT_FAILURE);
1548     }
1549     return _Escape(-10);
1550 }
1551 
1552 /* End. */
1553 
1554 
1555 typedef struct TPoint {
1556   long X, Y, C, H, N, O, P, S, Si, B, Br, Cl, F, I, Al, As, Ba, Be, Bi, Ca, Cd,
1557        Co, Cr, Cs, Cu, Fe, Ga, Ge, In, Li, Mg, Mn, Na, Ni, K, Pb, Rb, Sb, Sc, Se, Sn,
1558        Sr, Te, Ti, Tl, V, Zn, RecCount;
1559   struct TPoint *Last;
1560 } TPoint;
1561 
1562 typedef struct TBond {
1563   long X1, Y1, X2, Y2, RecCount;
1564   struct TBond *Last;
1565 } TBond;
1566 
1567 
1568 Static long C, H, N, O, P, S, Si, B, Br, Cl, F, I, Al, As, Ba, Be, Bi, Ca, Cd,
1569             Co, Cr, Cs, Cu, Fe, Ga, Ge, In, Li, Mg, Mn, Na, Ni, K, Pb, Rb, Sb, Sc, Se,
1570             Sn, Sr, Te, Ti, Tl, V, Zn, X1, X2, Y1, Y2, T, D;
1571 Static FILE *IFile;
1572 Static TPoint *Point, *Last, *Current;
1573 Static TBond *Bond, *LastB, *CurrentB;
1574 Static Char sss[256], A[256], subs[256], Alert[256];
1575 Static Char sssb[7];
1576 Static double M, Me;
1577 Static Char separator;
1578 Static long Count, code, atoms, rep, range, bonds;
1579 Static boolean Abandon, debug, verbose, fa, nobonds;
1580 Static long Sensi = 5;   /*bonds and labels joint precision sensitivity*/
1581 Static Char IFile_NAME[_FNSIZE];
1582 
1583 
doBonds()1584 Static Void doBonds()
1585 {
1586   do {
1587     fgets(sss,256,IFile);
1588     sscanf(sss, "%ld%ld%ld%ld%ld%ld%*[^\n]", &X1, &Y1, &X2, &Y2, &T, &D);
1589     /*getc(IFile);*/
1590     bonds--;
1591     if (debug)
1592       printf("%ld; %ld; %ld; %ld; %ld; %ld\n", X1, Y1, X2, Y2, T, D);
1593     if (D == 1 || T == 8){
1594 	if (debug) printf("skipped\n");
1595 	 continue;
1596 	}
1597 	if (debug) printf("parsed\n");
1598     if (T == 11)
1599       range = ((X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2)) * 4;
1600 
1601     LastB = Bond;
1602     Bond = (TBond *)Malloc(sizeof(TBond));
1603     Bond->X1 = X1;
1604     Bond->X2 = X2;
1605     Bond->Y1 = Y1;
1606     Bond->Y2 = Y2;
1607     Bond->Last = LastB;
1608     CurrentB = Bond;
1609     Bond = Bond->Last;
1610     while (Bond->Last != NULL) {
1611       if ((labs(Bond->X1 - X1) < Sensi && labs(Bond->Y1 - Y1) < Sensi &&
1612 	   labs(Bond->X2 - X2) < Sensi && labs(Bond->Y2 - Y2) < Sensi) ||
1613 	  (labs(Bond->X2 - X1) < Sensi && labs(Bond->Y2 - Y1) < Sensi &&
1614 	   labs(Bond->X1 - X2) < Sensi && labs(Bond->Y1 - Y2) < Sensi)) {
1615 	if (debug)
1616 	  printf("  ! Bond overlap\n");
1617 	strcat(Alert, "!");
1618       }
1619       Bond = Bond->Last;
1620     }
1621     Bond = CurrentB;
1622 
1623     Abandon = false;
1624     Current = Point;
1625     while (Point->Last != NULL) {
1626       if (T == 11) {
1627 	Abandon = true;
1628 	if ((Point->X - X1) * (Point->X - X1) +
1629 	    (Point->Y - Y1) * (Point->Y - Y1) < range) {
1630 	  if (Point->H > 0)
1631 	    Point->H--;
1632 	  if (debug)
1633 	    printf("Ring --> stripped one H from %ld %ld\n",
1634 		   Point->X, Point->Y);
1635 	}
1636       } else {
1637 	if (labs(Point->X - X1) < Sensi && labs(Point->Y - Y1) < Sensi) {
1638 	  if (debug)
1639 	    printf("  %ld --> Joined at %ld %ld\n", Point->RecCount, X1, Y1);
1640 	  if (T == 0 || T == 5 || T == 6 || T == 7 || T == 10 || T == 12 ||
1641 	      T == 13)
1642 	    Point->H--;
1643 	  if (T == 1 || T == 2 || T == 4 || T == 14 || T == 15 )
1644 	    Point->H -= 2;
1645 	  if (T == 3)
1646 	    Point->H -= 3;
1647 	  if (Point->H < 0) {
1648 	  	if (debug) printf("Point^.X=%ld, Point^.Y=%ld has H count <0 !\n",Point->X,Point->Y);
1649 	  	Point->H = 0;
1650 	  	}
1651 	  Abandon = true;
1652 	}
1653       }
1654       Point = Point->Last;
1655     }
1656     Point = Current;
1657 
1658     if (!Abandon) {
1659       Count++;
1660       Last = Point;
1661       Point = (TPoint *)Malloc(sizeof(TPoint));
1662       Point->X = X1;
1663       if (debug)
1664 	printf("  Point^.X=%ld", Point->X);
1665       Point->Y = Y1;
1666       if (debug)
1667 	printf("  Point^.Y=%ld", Point->Y);
1668       if (T != 11 && T != 9)
1669 	Point->C = 1;
1670       else
1671 	Point->C = 0;
1672       if (debug)
1673 	printf("  Point^.C=%ld", Point->C);
1674       if (T == 0 || T == 5 || T == 6 || T == 7 || T == 10 || T == 12 ||
1675 	  T == 13)
1676 	Point->H = 3;
1677       if (T == 1 || T == 2 || T == 4 || T == 14 || T == 15)
1678 	Point->H = 2;
1679       if (T == 3)
1680 	Point->H = 1;
1681       if (debug)
1682 	printf("  Point^.H=%ld", Point->H);
1683       Point->N = 0;
1684       Point->O = 0;
1685       Point->P = 0;
1686       Point->S = 0;
1687       Point->Si = 0;
1688       Point->B = 0;
1689       Point->Br = 0;
1690       Point->Cl = 0;
1691       Point->F = 0;
1692       Point->I = 0;
1693       Point->Al = 0;
1694       Point->As = 0;
1695       Point->Ba = 0;
1696       Point->Be = 0;
1697       Point->Bi = 0;
1698       Point->Ca = 0;
1699       Point->Cd = 0;
1700       Point->Co = 0;
1701       Point->Cr = 0;
1702       Point->Cs = 0;
1703       Point->Cu = 0;
1704       Point->Fe = 0;
1705       Point->Ga = 0;
1706       Point->Ge = 0;
1707       Point->In = 0;
1708       Point->Li = 0;
1709       Point->Na = 0;
1710       Point->Ni = 0;
1711       Point->Mg = 0;
1712       Point->Mn = 0;
1713       Point->K = 0;
1714       Point->Pb = 0;
1715       Point->Rb = 0;
1716       Point->Sb = 0;
1717       Point->Sc = 0;
1718       Point->Se = 0;
1719       Point->Sn = 0;
1720       Point->Sr = 0;
1721       Point->Te = 0;
1722       Point->Ti = 0;
1723       Point->Tl = 0;
1724       Point->V = 0;
1725       Point->Zn = 0;
1726       Point->RecCount = Count;
1727       if (debug)
1728 	printf("  Point^.RecCount=%ld\n", Point->RecCount);
1729       Point->Last = Last;
1730     }
1731 
1732     if (T != 11) {
1733       Abandon = false;
1734       Current = Point;
1735       while (Point->Last != NULL) {
1736 	if (labs(Point->X - X2) < Sensi && labs(Point->Y - Y2) < Sensi) {
1737 	  if (debug)
1738 	    printf("  %ld --> Joined at %ld %ld\n", Point->RecCount, X2, Y2);
1739 	  if (T == 0 || T == 5 || T == 6 || T == 7 || T == 10 || T == 12 ||
1740 	      T == 13)
1741 	    Point->H--;
1742 	  if (T == 1 || T == 2 || T == 4 || T == 14 || T == 15)
1743 	    Point->H -= 2;
1744 	  if (T == 3)
1745 	    Point->H -= 3;
1746 	  if (Point->H < 0) {
1747 	  	  	  if (debug) printf("Point^.X=%ld, Point^.Y=%ld has H count <0 !\n",Point->X,Point->Y);
1748 			  Point->H = 0;
1749 			  }
1750 	  Abandon = true;
1751 	}
1752 	Point = Point->Last;
1753       }
1754       Point = Current;
1755 
1756       if (!Abandon) {
1757 	Count++;
1758 	Last = Point;
1759 	Point = (TPoint *)Malloc(sizeof(TPoint));
1760 	Point->X = X2;
1761 	if (debug)
1762 	  printf("  Point^.X=%ld", Point->X);
1763 	Point->Y = Y2;
1764 	if (debug)
1765 	  printf("  Point^.Y=%ld", Point->Y);
1766 	if (T != 11 && T != 9)
1767 	  Point->C = 1;
1768 	else
1769 	  Point->C = 0;
1770 	if (debug)
1771 	  printf("  Point^.C=%ld", Point->C);
1772 	if (T == 0 || T == 5 || T == 6 || T == 7 || T == 10 || T == 12 ||
1773 	    T == 13)
1774 	  Point->H = 3;
1775 	if (T == 1 || T == 2 || T == 4 || T == 14 || T == 15 )
1776 	  Point->H = 2;
1777 	if (T == 3)
1778 	  Point->H = 1;
1779 	if (debug)
1780 	  printf("  Point^.H=%ld", Point->H);
1781 	Point->N = 0;
1782 	Point->O = 0;
1783 	Point->P = 0;
1784 	Point->S = 0;
1785 	Point->Si = 0;
1786 	Point->B = 0;
1787 	Point->Br = 0;
1788 	Point->Cl = 0;
1789 	Point->F = 0;
1790 	Point->I = 0;
1791 	Point->Al = 0;
1792 	Point->As = 0;
1793 	Point->Ba = 0;
1794 	Point->Be = 0;
1795         Point->Bi = 0;
1796 	Point->Ca = 0;
1797 	Point->Cd = 0;
1798 	Point->Co = 0;
1799 	Point->Cr = 0;
1800 	Point->Cs = 0;
1801 	Point->Cu = 0;
1802 	Point->Fe = 0;
1803         Point->Ga = 0;
1804         Point->Ge = 0;
1805         Point->In = 0;
1806 	Point->Li = 0;
1807 	Point->Mg = 0;
1808 	Point->Mn = 0;
1809 	Point->Na = 0;
1810 	Point->Ni = 0;
1811 	Point->K = 0;
1812       Point->Pb = 0;
1813       Point->Rb = 0;
1814       Point->Sb = 0;
1815       Point->Sc = 0;
1816       Point->Se = 0;
1817       Point->Sn = 0;
1818       Point->Sr = 0;
1819       Point->Te = 0;
1820       Point->Ti = 0;
1821       Point->Tl = 0;
1822       Point->V = 0;
1823       Point->Zn = 0;
1824 	Point->RecCount = Count;
1825 	if (debug)
1826 	  printf("  Point^.RecCount=%ld\n", Point->RecCount);
1827 	Point->Last = Last;
1828       }
1829     }
1830   } while (bonds != 0);
1831 }
1832 
1833 
doLabels()1834 Static Void doLabels()
1835 {
1836   long mul, gmul, gmpos, ggmul, ggmpos;
1837   boolean stripped;
1838   Char STR2[256];
1839   long FORLIM;
1840   Char *TEMP;
1841 
1842   if (debug)
1843     printf("---- and now parse the labels ---------\n");
1844   if (verbose)
1845     printf("HeteroAtoms: %ld\n", atoms);
1846   FORLIM = atoms;
1847   for (rep = 1; rep <= FORLIM; rep++) {
1848     fscanf(IFile, "%ld%ld%c", &X1, &Y1, &separator);
1849     fgets(sss, 256, IFile);
1850     TEMP = strchr(sss, '\n');
1851     if (TEMP != NULL)
1852       *TEMP = 0;
1853     sprintf(A, "%.*s", strpos2(sss, "\t", 1) - 1, sss);
1854 
1855     if (debug)
1856       printf("Atom %s X=%ld Y=%ld sss: %s\n", A, X1, Y1, sss);
1857     if (nobonds)
1858     {   /*initialize the Point structure if no bonds, only labels, defined*/
1859       Count++;
1860       Last = Point;
1861       Point = (TPoint *)Malloc(sizeof(TPoint));
1862       Point->X = X1;
1863       Point->Y = Y1;
1864       Point->C = 0;
1865       Point->H = 0;
1866       Point->N = 0;
1867       Point->O = 0;
1868       Point->P = 0;
1869       Point->S = 0;
1870       Point->Si = 0;
1871       Point->B = 0;
1872       Point->Br = 0;
1873       Point->Cl = 0;
1874       Point->F = 0;
1875       Point->I = 0;
1876       Point->Al = 0;
1877       Point->As = 0;
1878       Point->Ba = 0;
1879       Point->Be = 0;
1880       Point->Bi = 0;
1881       Point->Ca = 0;
1882       Point->Cd = 0;
1883       Point->Co = 0;
1884       Point->Cr = 0;
1885       Point->Cs = 0;
1886       Point->Cu = 0;
1887       Point->Fe = 0;
1888       Point->Ga = 0;
1889       Point->Ge = 0;
1890       Point->In = 0;
1891       Point->Li = 0;
1892       Point->Mg = 0;
1893       Point->Mn = 0;
1894       Point->Na = 0;
1895       Point->Ni = 0;
1896       Point->K = 0;
1897       Point->Pb = 0;
1898       Point->Rb = 0;
1899       Point->Sb = 0;
1900       Point->Sc = 0;
1901       Point->Se = 0;
1902       Point->Sn = 0;
1903       Point->Sr = 0;
1904       Point->Te = 0;
1905       Point->Ti = 0;
1906       Point->Tl = 0;
1907       Point->V = 0;
1908       Point->Zn = 0;
1909       Point->RecCount = Count;
1910       Point->Last = Last;
1911     }
1912     Current = Point;
1913     while (Point->Last != NULL) {
1914       if (labs(Point->X - X1) < Sensi && labs(Point->Y - Y1) < Sensi) {
1915 	if (debug)
1916 	  printf("  [%ld]\n", Point->RecCount);
1917 	Point->C = 0;   /*we substitute -CH_x(-) by -R(-)*/
1918 	Point->H = 0;
1919 	Point->N = 0;
1920 	Point->O = 0;
1921 	Point->P = 0;
1922 	Point->S = 0;
1923 	Point->Si = 0;
1924 	Point->B = 0;
1925 	Point->Br = 0;
1926 	Point->Cl = 0;
1927 	Point->F = 0;
1928 	Point->I = 0;
1929 	Point->Al = 0;
1930 	Point->As = 0;
1931 	Point->Ba = 0;
1932         Point->Be = 0;
1933         Point->Bi = 0;
1934 	Point->Ca = 0;
1935 	Point->Cd = 0;
1936 	Point->Co = 0;
1937 	Point->Cr = 0;
1938 	Point->Cs = 0;
1939 	Point->Cu = 0;
1940 	Point->Fe = 0;
1941         Point->Ga = 0;
1942         Point->Ge = 0;
1943         Point->In = 0;
1944 	Point->Li = 0;
1945 	Point->Mg = 0;
1946 	Point->Mn = 0;
1947 	Point->Na = 0;
1948 	Point->Ni = 0;
1949 	Point->K = 0;
1950       Point->Pb = 0;
1951       Point->Rb = 0;
1952       Point->Sb = 0;
1953       Point->Sc = 0;
1954       Point->Se = 0;
1955       Point->Sn = 0;
1956       Point->Sr = 0;
1957       Point->Te = 0;
1958       Point->Ti = 0;
1959       Point->Tl = 0;
1960       Point->V = 0;
1961       Point->Zn = 0;
1962 	mul = 1;
1963 	gmul = 1;
1964 	ggmul = 1;
1965 	while (*A != '\0') {
1966 	  stripped = false;
1967 	  if (strlen(A) >= 5) {
1968 	    sprintf(subs, "%.5s", A);
1969 	    if (strlen(A) > 6) {
1970 	      if (A[5] == '_') {
1971 	       if (A[6]!= '{') {
1972 		sprintf(STR2, "%c", A[6]);
1973 	        if (A[7]=='_') sprintf(STR2, "%c%c", A[6],A[8]);
1974 		code = (sscanf(STR2, "%ld", &mul) == 0);
1975 		}else{
1976 		mul=7;
1977 		while(A[mul]!='}'){STR2[mul-7]=A[mul]; mul++ ; }
1978 		STR2[mul-6]='\0';
1979 		code = (sscanf(STR2, "%ld", &mul) == 0);
1980 		}
1981 	      } else
1982 		mul = 1;
1983 	    }
1984 	    mul *= gmul * ggmul;
1985 	    if (!strcmp(subs, "TBDMS")) {  /*Tert-butyldimethylsilyl*/
1986 	      if (debug)
1987 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
1988 	      Point->C += mul * 6;
1989 	      Point->H += mul * 15;
1990 	      Point->Si += mul;
1991 	      strcpy(A, strsub(STR2, A, 6, (int)(strlen(A) - 5)));
1992 	      stripped = true;
1993 	    }
1994 	    if (!strcmp(subs, "TBDPS")) {  /*Tert-butyldiphenylsilyl*/
1995 	      if (debug)
1996 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
1997 	      Point->C += mul * 16;
1998 	      Point->H += mul * 19;
1999 	      Point->Si += mul;
2000 	      strcpy(A, strsub(STR2, A, 6, (int)(strlen(A) - 5)));
2001 	      stripped = true;
2002 	    }
2003 	    if (A[0] == '[') {
2004 	      ggmpos = strpos2(A, "]", 1);
2005 	      if (ggmpos != 0) {
2006 		if (A[ggmpos] == '_') {
2007 	       if (A[ggmpos+1]!= '{') {
2008 		sprintf(STR2, "%c", A[ggmpos+1]);
2009 	        if (A[ggmpos+2]=='_') sprintf(STR2, "%c%c", A[ggmpos+1],A[ggmpos+3]);
2010 		code = (sscanf(STR2, "%ld", &ggmul) == 0);
2011 		}else{
2012 		ggmul=ggmpos+2;
2013 		while(A[ggmul]!='}'){STR2[ggmul-ggmpos-2]=A[ggmul]; ggmul++ ; }
2014 		STR2[ggmul-ggmpos-1]='\0';
2015 		code = (sscanf(STR2, "%ld", &ggmul) == 0);
2016 		}
2017 		} else
2018 		  ggmul = 1;
2019 	      }
2020 	    }
2021 	    if (A[0] == '(') {
2022 	      gmpos = strpos2(A, ")", 1);
2023 	      if (gmpos != 0) {
2024 		if (A[gmpos] == '_') {
2025 	       if (A[gmpos+1]!= '{') {
2026 		sprintf(STR2, "%c", A[gmpos+1]);
2027 	        if (A[gmpos+2]=='_') sprintf(STR2, "%c%c", A[gmpos+1],A[gmpos+3]);
2028 		code = (sscanf(STR2, "%ld", &gmul) == 0);
2029 		}else{
2030 		gmul=gmpos+2;
2031 		while(A[gmul]!='}'){STR2[gmul-gmpos-2]=A[gmul]; gmul++ ; }
2032 		STR2[gmul-gmpos-1]='\0';
2033 		code = (sscanf(STR2, "%ld", &gmul) == 0);
2034 		}
2035 		} else
2036 		  gmul = 1;
2037 	      }
2038 	    }
2039 	  }
2040 	  if (strlen(A) >= 4 && !stripped) {
2041 	    sprintf(subs, "%.4s", A);
2042 	    if (strlen(A) > 5) {
2043 	      if (A[4] == '_') {
2044 	       if (A[5]!= '{') {
2045 		sprintf(STR2, "%c", A[5]);
2046 	        if (A[6]=='_') sprintf(STR2, "%c%c", A[5],A[7]);
2047 		code = (sscanf(STR2, "%ld", &mul) == 0);
2048 		}else{
2049 		mul=6;
2050 		while(A[mul]!='}'){STR2[mul-6]=A[mul]; mul++ ; }
2051 		STR2[mul-5]='\0';
2052 		code = (sscanf(STR2, "%ld", &mul) == 0);
2053 		}
2054 	      } else
2055 		mul = 1;
2056 	    }
2057 	    mul *= gmul * ggmul;
2058 	    if (!strcmp(subs, "DBAM"))
2059 	    {  /*dibutylaminomethylene; =R, used as the N prot.*/
2060 	      if (debug)
2061 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2062 	      Point->C += mul * 9;
2063 	      Point->H += mul * 19;
2064 	      Point->N += mul;
2065 	      strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
2066 	      stripped = true;
2067 	    }
2068 	    if (!strcmp(subs, "DMAM"))
2069 	    {  /*dimethylaminomethylene; =R, used as the N prot.*/
2070 	      if (debug)
2071 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2072 	      Point->C += mul * 3;
2073 	      Point->H += mul * 7;
2074 	      Point->N += mul;
2075 	      strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
2076 	      stripped = true;
2077 	    }
2078 	    if (!strcmp(subs, "DMTr")) {  /*dimethoxytrityl*/
2079 	      if (debug)
2080 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2081 	      Point->C += mul * 21;
2082 	      Point->H += mul * 19;
2083 	      Point->O += mul * 2;
2084 	      strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
2085 	      stripped = true;
2086 	    }
2087 	    if (!strcmp(subs, "MMTr")) {  /*monomethoxytrityl*/
2088 	      if (debug)
2089 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2090 	      Point->C += mul * 20;
2091 	      Point->H += mul * 16;
2092 	      Point->O += mul;
2093 	      strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
2094 	      stripped = true;
2095 	    }
2096 	    if (!strcmp(subs, "TMTr")) {  /*trimethoxytrityl*/
2097 	      if (debug)
2098 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2099 	      Point->C += mul * 22;
2100 	      Point->H += mul * 22;
2101 	      Point->O += mul * 3;
2102 	      strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
2103 	      stripped = true;
2104 	    }
2105 	  }
2106 	  if (strlen(A) >= 3 && !stripped) {
2107 	    sprintf(subs, "%.3s", A);
2108 	    if (strlen(A) > 4) {
2109 	      if (A[3] == '_') {
2110 	       if (A[4]!= '{') {
2111 		sprintf(STR2, "%c", A[4]);
2112 	        if (A[5]=='_') sprintf(STR2, "%c%c", A[4],A[6]);
2113 		code = (sscanf(STR2, "%ld", &mul) == 0);
2114 		}else{
2115 		mul=5;
2116 		while(A[mul]!='}'){STR2[mul-5]=A[mul]; mul++ ; }
2117 		STR2[mul-4]='\0';
2118 		code = (sscanf(STR2, "%ld", &mul) == 0);
2119 		}
2120 	      } else
2121 		mul = 1;
2122 	    }
2123 	    mul *= gmul * ggmul;
2124 	    if (!strcmp(subs, "Ade")) {  /*Adeninyl*/
2125 	      if (debug)
2126 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2127 	      Point->C += mul * 5;
2128 	      Point->H += mul * 4;
2129 	      Point->N += mul * 5;
2130 	      strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2131 	      stripped = true;
2132 	    }
2133 	    if (!strcmp(subs, "BOC")) {  /*Butyloxycarbonyl*/
2134 	      if (debug)
2135 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2136 	      Point->C += mul * 5;
2137 	      Point->H += mul * 9;
2138 	      Point->O += mul * 2;
2139 	      strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2140 	      stripped = true;
2141 	    }
2142 	    if (!strcmp(subs, "Cyt")) {  /*Cytosinyl*/
2143 	      if (debug)
2144 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2145 	      Point->C += mul * 4;
2146 	      Point->H += mul * 4;
2147 	      Point->N += mul * 3;
2148 	      Point->O += mul;
2149 	      strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2150 	      stripped = true;
2151 	    }
2152 	    if (!strcmp(subs, "Gua")) {  /*Guaninyl*/
2153 	      if (debug)
2154 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2155 	      Point->C += mul * 5;
2156 	      Point->H += mul * 4;
2157 	      Point->N += mul * 5;
2158 	      Point->O += mul;
2159 	      strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2160 	      stripped = true;
2161 	    }
2162 	    if (!strcmp(subs, "iBu")) {  /*iso-Butyl*/
2163 	      if (debug)
2164 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2165 	      Point->C += mul * 4;
2166 	      Point->H += mul * 9;
2167 	      strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2168 	      stripped = true;
2169 	    }
2170 	    if (!strcmp(subs, "iPr")) {  /*2-Propyl*/
2171 	      if (debug)
2172 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2173 	      Point->C += mul * 3;
2174 	      Point->H += mul * 7;
2175 	      strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2176 	      stripped = true;
2177 	    }
2178 	    if (!strcmp(subs, "MOC")) {  /*Methoxycarbonyl*/
2179 	      if (debug)
2180 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2181 	      Point->C += mul * 2;
2182 	      Point->H += mul * 3;
2183 	      Point->O += mul * 2;
2184 	      strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2185 	      stripped = true;
2186 	    }
2187 	    if (!strcmp(subs, "MOM")) {  /*Methoxymethyl*/
2188 	      if (debug)
2189 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2190 	      Point->C += mul * 2;
2191 	      Point->H += mul * 5;
2192 	      Point->O += mul;
2193 	      strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2194 	      stripped = true;
2195 	    }
2196 	    if (!strcmp(subs, "tBu")) {  /*t-Butyl*/
2197 	      if (debug)
2198 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2199 	      Point->C += mul * 4;
2200 	      Point->H += mul * 9;
2201 	      strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2202 	      stripped = true;
2203 	    }
2204 	    if (!strcmp(subs, "Thy")) {  /*Thyminyl*/
2205 	      if (debug)
2206 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2207 	      Point->C += mul * 5;
2208 	      Point->H += mul * 5;
2209 	      Point->N += mul * 2;
2210 	      Point->O += mul * 2;
2211 	      strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2212 	      stripped = true;
2213 	    }
2214 	    if (!strcmp(subs, "TMS")) {  /*Trimethylsilyl*/
2215 	      if (debug)
2216 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2217 	      Point->C += mul * 3;
2218 	      Point->H += mul * 9;
2219 	      Point->Si += mul;
2220 	      strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2221 	      stripped = true;
2222 	    }
2223 	    if (!strcmp(subs, "Tol")) {  /*tolyl*/
2224 	      if (debug)
2225 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2226 	      Point->C += mul * 8;
2227 	      Point->H += mul * 7;
2228 	      Point->O += mul;
2229 	      strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2230 	      stripped = true;
2231 	    }
2232 	    if (!strcmp(subs, "Ura")) {  /*Uracilyl*/
2233 	      if (debug)
2234 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2235 	      Point->C += mul * 4;
2236 	      Point->H += mul * 3;
2237 	      Point->N += mul * 2;
2238 	      Point->O += mul * 2;
2239 	      strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2240 	      stripped = true;
2241 	    }
2242 	  }
2243 	  if (strlen(A) >= 2 && !stripped) {
2244 	    sprintf(subs, "%.2s", A);
2245 	    if (strlen(A) > 3) {
2246 	      if (A[2] == '_') {
2247 	       if (A[3]!= '{') {
2248 		sprintf(STR2, "%c", A[3]);
2249 	        if (A[4]=='_') sprintf(STR2, "%c%c", A[3],A[5]);
2250 		code = (sscanf(STR2, "%ld", &mul) == 0);
2251 		}else{
2252 		mul=4;
2253 		while(A[mul]!='}'){STR2[mul-4]=A[mul]; mul++ ; }
2254 		STR2[mul-3]='\0';
2255 		code = (sscanf(STR2, "%ld", &mul) == 0);
2256 		}
2257 	      } else
2258 		mul = 1;
2259 	    }
2260 	    mul *= gmul * ggmul;
2261 	    if (!strcmp(subs, "Ac")) {  /*acetyl*/
2262 	      if (debug)
2263 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2264 	      Point->C += mul * 2;
2265 	      Point->H += mul * 3;
2266 	      Point->O += mul;
2267 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2268 	      stripped = true;
2269 	    }
2270 	    if (!strcmp(subs, "Al")) {  /*alumin(i)um*/
2271 	      if (debug)
2272 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2273 	      Point->Al += mul ;
2274 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2275 	      stripped = true;
2276 	    }
2277 	    if (!strcmp(subs, "As")) {  /*arsenic*/
2278 	      if (debug)
2279 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2280 	      Point->As += mul ;
2281 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2282 	      stripped = true;
2283 	    }
2284 	    if (!strcmp(subs, "Ba")) {  /*barium*/
2285 	      if (debug)
2286 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2287 	      Point->Ba += mul ;
2288 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2289 	      stripped = true;
2290 	    }
2291 	    if (!strcmp(subs, "Be")) {  /*beryllium*/
2292 	      if (debug)
2293 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2294 	      Point->Be += mul ;
2295 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2296 	      stripped = true;
2297 	    }
2298 	    if (!strcmp(subs, "Bi")) {  /*bismuth*/
2299 	      if (debug)
2300 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2301 	      Point->Bi += mul ;
2302 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2303 	      stripped = true;
2304 	    }
2305 	    if (!strcmp(subs, "Bn")) {  /*benzyl*/
2306 	      if (debug)
2307 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2308 	      Point->C += mul * 7;
2309 	      Point->H += mul * 7;
2310 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2311 	      stripped = true;
2312 	    }
2313 	    if (!strcmp(subs, "Br")) {  /*bromine*/
2314 	      if (debug)
2315 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2316 	      Point->Br += mul;
2317 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2318 	      stripped = true;
2319 	    }
2320 	    if (!strcmp(subs, "Bu")) {  /*butyl*/
2321 	      if (debug)
2322 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2323 	      Point->C += mul * 4;
2324 	      Point->H += mul * 9;
2325 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2326 	      stripped = true;
2327 	    }
2328 	    if (!strcmp(subs, "Bz")) {  /*benzoyl*/
2329 	      if (debug)
2330 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2331 	      Point->C += mul * 7;
2332 	      Point->H += mul * 5;
2333 	      Point->O += mul;
2334 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2335 	      stripped = true;
2336 	    }
2337 	    if (!strcmp(subs, "CE")) {  /*cyanoethyl*/
2338 	      if (debug)
2339 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2340 	      Point->C += mul * 3;
2341 	      Point->H += mul * 4;
2342 	      Point->N += mul;
2343 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2344 	      stripped = true;
2345 	    }
2346 	    if (!strcmp(subs, "Cl")) {  /*chlorine*/
2347 	      if (debug)
2348 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2349 	      Point->Cl += mul;
2350 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2351 	      stripped = true;
2352 	    }
2353 	    if (!strcmp(subs, "Ca")) {  /*calcium*/
2354 	      if (debug)
2355 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2356 	      Point->Ca += mul;
2357 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2358 	      stripped = true;
2359 	    }
2360 	    if (!strcmp(subs, "Cd")) {  /*cadmium*/
2361 	      if (debug)
2362 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2363 	      Point->Cd += mul;
2364 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2365 	      stripped = true;
2366 	    }
2367 	    if (!strcmp(subs, "Co")) {  /*cobalt*/
2368 	      if (debug)
2369 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2370 	      Point->Co += mul;
2371 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2372 	      stripped = true;
2373 	    }
2374 	    if (!strcmp(subs, "Cr")) {  /*chromium*/
2375 	      if (debug)
2376 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2377 	      Point->Cr += mul;
2378 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2379 	      stripped = true;
2380 	    }
2381 	    if (!strcmp(subs, "Cs")) {  /*cesium*/
2382 	      if (debug)
2383 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2384 	      Point->Cs += mul;
2385 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2386 	      stripped = true;
2387 	    }
2388 	    if (!strcmp(subs, "Cu")) {  /*copper*/
2389 	      if (debug)
2390 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2391 	      Point->Cu += mul;
2392 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2393 	      stripped = true;
2394 	    }
2395 	    if (!strcmp(subs, "Et")) {  /*ethyl*/
2396 	      if (debug)
2397 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2398 	      Point->C += mul * 2;
2399 	      Point->H += mul * 5;
2400 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2401 	      stripped = true;
2402 	    }
2403 	    if (!strcmp(subs, "Fe")) {  /*iron*/
2404 	      if (debug)
2405 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2406 	      Point->Fe += mul;
2407 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2408 	      stripped = true;
2409 	    }
2410 	    if (!strcmp(subs, "Ga")) {  /*gallium*/
2411 	      if (debug)
2412 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2413 	      Point->Ga += mul;
2414 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2415 	      stripped = true;
2416 	    }
2417 	    if (!strcmp(subs, "Ge")) {  /*germanium*/
2418 	      if (debug)
2419 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2420 	      Point->Ge += mul;
2421 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2422 	      stripped = true;
2423 	    }
2424 	    if (!strcmp(subs, "In")) {  /*indium*/
2425 	      if (debug)
2426 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2427 	      Point->In += mul;
2428 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2429 	      stripped = true;
2430 	    }
2431 	    if (!strcmp(subs, "Li")) {  /*lithium*/
2432 	      if (debug)
2433 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2434 	      Point->Li += mul;
2435 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2436 	      stripped = true;
2437 	    }
2438 	    if (!strcmp(subs, "Me")) {  /*methyl*/
2439 	      if (debug)
2440 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2441 	      Point->C += mul;
2442 	      Point->H += mul * 3;
2443 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2444 	      stripped = true;
2445 	    }
2446 	    if (!strcmp(subs, "Ms")) {  /*methanesulfonyl, mesyl*/
2447 	      if (debug)
2448 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2449 	      Point->C += mul;
2450 	      Point->H += mul * 3;
2451 	      Point->O += mul * 2;
2452 	      Point->S += mul;
2453 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2454 	      stripped = true;
2455 	    }
2456 	    if (!strcmp(subs, "Mg")) {  /*magnesium*/
2457 	      if (debug)
2458 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2459 	      Point->Mg += mul;
2460 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2461 	      stripped = true;
2462 	    }
2463 	    if (!strcmp(subs, "Mn")) {  /*manganese*/
2464 	      if (debug)
2465 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2466 	      Point->Mn += mul;
2467 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2468 	      stripped = true;
2469 	    }
2470 	    if (!strcmp(subs, "Na")) {  /*sodium*/
2471 	      if (debug)
2472 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2473 	      Point->Na += mul;
2474 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2475 	      stripped = true;
2476 	    }
2477 	    if (!strcmp(subs, "Ni")) {  /*nickel*/
2478 	      if (debug)
2479 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2480 	      Point->Ni += mul;
2481 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2482 	      stripped = true;
2483 	    }
2484 	    if (!strcmp(subs, "Pb")) {  /*lead*/
2485 	      if (debug)
2486 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2487 	      Point->Pb += mul;
2488 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2489 	      stripped = true;
2490 	    }
2491 	    if (!strcmp(subs, "Ph")|| !strcmp(subs,"@F")) {  /*phenyl*/
2492 	      if (debug)
2493 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2494 	      Point->C += mul * 6;
2495 	      Point->H += mul * 5;
2496 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2497 	      stripped = true;
2498 	    }
2499 	    if (!strcmp(subs, "Pr")) {  /*propyl*/
2500 	      if (debug)
2501 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2502 	      Point->C += mul * 3;
2503 	      Point->H += mul * 7;
2504 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2505 	      stripped = true;
2506 	    }
2507 	    if (!strcmp(subs, "Rb")) {  /*rubidium*/
2508 	      if (debug)
2509 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2510 	      Point->Rb += mul;
2511 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2512 	      stripped = true;
2513 	    }
2514 	    if (!strcmp(subs, "Sb")) {  /*antimony*/
2515 	      if (debug)
2516 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2517 	      Point->Sb += mul;
2518 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2519 	      stripped = true;
2520 	    }
2521 	    if (!strcmp(subs, "Sc")) {  /*scandium*/
2522 	      if (debug)
2523 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2524 	      Point->Sc += mul;
2525 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2526 	      stripped = true;
2527 	    }
2528 	    if (!strcmp(subs, "Se")) {  /*selenium*/
2529 	      if (debug)
2530 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2531 	      Point->Se += mul;
2532 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2533 	      stripped = true;
2534 	    }
2535 	    if (!strcmp(subs, "Sn")) {  /*tin*/
2536 	      if (debug)
2537 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2538 	      Point->Sn += mul;
2539 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2540 	      stripped = true;
2541 	    }
2542 	    if (!strcmp(subs, "Sr")) {  /*strontium*/
2543 	      if (debug)
2544 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2545 	      Point->Sr += mul;
2546 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2547 	      stripped = true;
2548 	    }
2549 	    if (!strcmp(subs, "Te")) {  /*tellurium*/
2550 	      if (debug)
2551 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2552 	      Point->Te += mul;
2553 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2554 	      stripped = true;
2555 	    }
2556 	    if (!strcmp(subs, "Ti")) {  /*titanium*/
2557 	      if (debug)
2558 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2559 	      Point->Ti += mul;
2560 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2561 	      stripped = true;
2562 	    }
2563 	    if (!strcmp(subs, "Tf")) {  /*trifluoromethanesulfonyl, triflyl*/
2564 	      if (debug)
2565 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2566 	      Point->C += mul;
2567 	      Point->F += mul * 3;
2568 	      Point->O += mul * 2;
2569 	      Point->S += mul;
2570 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2571 	      stripped = true;
2572 	    }
2573 	    if (!strcmp(subs, "Tl")) {  /*thallium*/
2574 	      if (debug)
2575 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2576 	      Point->Tl += mul;
2577 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2578 	      stripped = true;
2579 	    }
2580 	    if (!strcmp(subs, "Tr")) {  /*trityl, triphenylmethyl*/
2581 	      if (debug)
2582 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2583 	      Point->C += mul * 19;
2584 	      Point->H += mul * 15;
2585 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2586 	      stripped = true;
2587 	    }
2588 	    if (!strcmp(subs, "Ts")) {  /*toluenesulfonyl, tosyl*/
2589 	      if (debug)
2590 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2591 	      Point->C += mul * 7;
2592 	      Point->H += mul * 7;
2593 	      Point->O += mul * 2;
2594 	      Point->S += mul;
2595 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2596 	      stripped = true;
2597 	    }
2598 	    if (!strcmp(subs, "Si")) {  /*silicon*/
2599 	      if (debug)
2600 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2601 	      Point->Si += mul;
2602 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2603 	      stripped = true;
2604 	    }
2605 	    if (!strcmp(subs, "Zn")) {  /*zinc*/
2606 	      if (debug)
2607 		printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2608 	      Point->Zn += mul;
2609 	      strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2610 	      stripped = true;
2611 	    }
2612 	  }
2613 	  if (strlen(A) < 1 || stripped)
2614 	    continue;
2615 	  sprintf(subs, "%.1s", A);
2616 	  if (strlen(A) > 2) {
2617 	    if (A[1] == '_') {
2618 	       if (A[2]!= '{') {
2619 		sprintf(STR2, "%c", A[2]);
2620 	        if (A[3]=='_') sprintf(STR2, "%c%c", A[2],A[4]);
2621 		code = (sscanf(STR2, "%ld", &mul) == 0);
2622 		}else{
2623 		mul=3;
2624 		while(A[mul]!='}'){STR2[mul-3]=A[mul]; mul++ ; }
2625 		STR2[mul-2]='\0';
2626 		code = (sscanf(STR2, "%ld", &mul) == 0);
2627 		}
2628 	    } else
2629 	      mul = 1;
2630 	  }
2631 	  mul *= gmul * ggmul;
2632 	  if (!strcmp(subs, "B")) {  /*boron*/
2633 	    if (debug)
2634 	      printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2635 	    Point->B += mul;
2636 	  }
2637 	  if (!strcmp(subs, "C")) {  /*carbon*/
2638 	    if (debug)
2639 	      printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2640 	    Point->C += mul;
2641 	  }
2642 	  if (!strcmp(subs, "F")) {  /*fluorine*/
2643 	    if (debug)
2644 	      printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2645 	    Point->F += mul;
2646 	  }
2647 	  if (!strcmp(subs, "H")) {  /*hydrogen*/
2648 	    if (debug)
2649 	      printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2650 	    Point->H += mul;
2651 	  }
2652 	  if (!strcmp(subs, "I")) {  /*iodine*/
2653 	    if (debug)
2654 	      printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2655 	    Point->I += mul;
2656 	  }
2657 	  if (!strcmp(subs, "K")) {  /*potassium*/
2658 	    if (debug)
2659 	      printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2660 	    Point->K += mul;
2661 	  }
2662 	  if (!strcmp(subs, "N")) {  /*nitrogen*/
2663 	    if (debug)
2664 	      printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2665 	    Point->N += mul;
2666 	  }
2667 	  if (!strcmp(subs, "O")) {  /*oxygen*/
2668 	    if (debug)
2669 	      printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2670 	    Point->O += mul;
2671 	  }
2672 	  if (!strcmp(subs, "P")) {  /*phosphorus*/
2673 	    if (debug)
2674 	      printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2675 	    Point->P += mul;
2676 	  }
2677 	  if (!strcmp(subs, "S")) {  /*sulfur*/
2678 	    if (debug)
2679 	      printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2680 	    Point->S += mul;
2681 	  }
2682 	  if (!strcmp(subs, "V")) {  /*vanadium*/
2683 	    if (debug)
2684 	      printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2685 	    Point->V += mul;
2686 	  }
2687 	  if (!strcmp(subs, "Z")) {  /*"Z", Benzyloxycarbonyl*/
2688 	    if (debug)
2689 	      printf("  %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2690 	    Point->C += mul * 8;
2691 	    Point->H += mul * 7;
2692 	    Point->O += mul * 2;
2693 	  }
2694 	  if (!strcmp(subs, ")"))  /*reset gmul*/
2695 	    gmul = 1;
2696 	  if (!strcmp(subs, "]")) {  /*reset gmul,ggmul*/
2697 	    gmul = 1;
2698 	    ggmul = 1;
2699 	  }
2700 	  if (true)
2701 	    strcpy(A, strsub(STR2, A, 2, (int)(strlen(A) - 1)));
2702 	}
2703       }
2704       Point = Point->Last;
2705     }
2706     Point = Current;
2707   }
2708 }
2709 
2710 
main(argc,argv)2711 main(argc, argv)
2712 int argc;
2713 Char *argv[];
2714 {
2715   Char STR1[256], STR2[256];
2716   Char *TEMP;
2717   boolean interactive=false;
2718 
2719   PASCAL_MAIN(argc, argv);
2720   IFile = NULL;
2721   if (P_argc == 1) {
2722     printf("enter \"cht -h\" for help\n");
2723     _Escape(0);
2724   }
2725   C = 0;
2726   H = 0;
2727   N = 0;
2728   O = 0;
2729   P = 0;
2730   S = 0;
2731   Si = 0;
2732   B = 0;
2733   Br = 0;
2734   I = 0;
2735   Cl = 0;
2736   F = 0;
2737   Al = 0;
2738   As = 0;
2739   Ba = 0;
2740   Be = 0;
2741   Bi = 0;
2742   Ca = 0;
2743   Cd = 0;
2744   Co = 0;
2745   Cr = 0;
2746   Cs = 0;
2747   Cu = 0;
2748   Fe = 0;
2749   Ga = 0;
2750   Ge = 0;
2751   In = 0;
2752   Li = 0;
2753   Mg = 0;
2754   Mn = 0;
2755   Na = 0;
2756   Ni = 0;
2757   K = 0;
2758   Pb = 0;
2759   Rb = 0;
2760   Sb = 0;
2761   Sc = 0;
2762   Se = 0;
2763   Sn = 0;
2764   Sr = 0;
2765   Te = 0;
2766   Ti = 0;
2767   Tl = 0;
2768   V = 0;
2769   Zn = 0;
2770   verbose = false;
2771   debug = false;
2772   fa = false;   /*no file assigned*/
2773   Count = 0;
2774   *Alert = '\0';
2775   for (rep = 1; rep < P_argc; rep++) {
2776     if (!strcmp(strcpy(STR2, P_argv[rep]), "-v") ||
2777 	!strcmp(strcpy(STR1, P_argv[rep]), "--verbose"))
2778       verbose = true;
2779     if (!strcmp(strcpy(STR2, P_argv[rep]), "-d") ||
2780 	!strcmp(strcpy(STR1, P_argv[rep]), "--debug"))
2781       debug = true;
2782     if (!strcmp(strcpy(STR2, P_argv[rep]), "-i") ||
2783 	!strcmp(strcpy(STR1, P_argv[rep]), "--interpret"))
2784       interactive = true;
2785     if (!strcmp(strcpy(STR2, P_argv[rep]), "-h") ||
2786 	!strcmp(strcpy(STR1, P_argv[rep]), "--help")) {
2787       printf("The Chemtool drawings analyzer 1.7\n");
2788       printf("***   Gizmo Head Software   ***\n");
2789       printf("    Radek Liboska (c) 2001\n\n");
2790       printf("syntax: cht [-options] <filename.cht>\n\n");
2791       printf("Recognizes C,H,O,N,P,S,Si,B,Br,I,Cl,F,Al,As,Ba,Be,Bi,Ca,Cd,Co,Cr,Cs,Cu,\nFe,Ga,Ge,In,Li,Mg,Mn,Na,Ni,K,Pb,Rb,Sb,Sc,Se,Sn,Sr,\nTe,Ti,Tl,V,Zn\n");
2792       printf(
2793 	"        Ac,Ade,Bn,Bu,Bz,BOC,Cyt,CE,DBAM,DMAM,DMTr,Et,Gua,iBu,iPr,Me,Ms,MOC,\n");
2794       printf(
2795 	"        MOM,MMTr,Ph,Pr,tBu,Tf,Thy,Tol,Tr,Ts,TBDMS,TBDPS,TMS,TMTr,Ura,Z\n");
2796       printf("Can handle two levels of parentheses; e.g. P[OCH(CH_3)_2]_3\n\n");
2797       printf("options:\n");
2798       printf("        -h or --help : this help\n");
2799       printf("        -v or --verbose : be verbose\n");
2800       printf("        -d or --debug : be more verbose\n\n");
2801       _Escape(0);
2802     }
2803     if (strcpy(STR2, P_argv[rep])[0] != '-') {
2804       strcpy(STR1, P_argv[rep]);
2805       strcpy(IFile_NAME, STR1);
2806       fa = true;
2807     }
2808   }
2809   if (!fa && !interactive) {
2810     printf("No file defined, enter \"cht -h\" for help\n");
2811     _Escape(1);
2812   }
2813   if (!interactive){
2814   if (IFile != NULL)
2815     IFile = freopen(IFile_NAME, "r", IFile);
2816   else
2817     IFile = fopen(IFile_NAME, "r");
2818   if (IFile == NULL)
2819     _EscIO2(FileNotFound, IFile_NAME);
2820   }else {
2821   if (IFile)fclose(IFile);
2822   IFile=tmpfile();
2823   fprintf(IFile,"Chemtool Version 1.0\ngeometry 100 100\n\bonds 0\natoms 1\n0	 0	%s 	0\n",IFile_NAME);
2824   rewind(IFile);
2825   }
2826   Point = (TPoint *)Malloc(sizeof(TPoint));
2827   Point->X = 0;
2828   Point->Y = 0;
2829   Point->C = 0;
2830   Point->H = 0;
2831   Point->N = 0;
2832   Point->O = 0;
2833   Point->P = 0;
2834   Point->S = 0;
2835   Point->Si = 0;
2836   Point->B = 0;
2837   Point->Br = 0;
2838   Point->Cl = 0;
2839   Point->F = 0;
2840   Point->I = 0;
2841   Point->Al = 0;
2842   Point->As = 0;
2843   Point->Ba = 0;
2844   Point->Be = 0;
2845   Point->Bi = 0;
2846   Point->Ca = 0;
2847   Point->Cd = 0;
2848   Point->Co = 0;
2849   Point->Cr = 0;
2850   Point->Cs = 0;
2851   Point->Cu = 0;
2852   Point->Fe = 0;
2853   Point->Ga = 0;
2854   Point->Ge = 0;
2855   Point->In = 0;
2856   Point->Li = 0;
2857   Point->Mg = 0;
2858   Point->Mn = 0;
2859   Point->Na = 0;
2860   Point->Ni = 0;
2861   Point->K = 0;
2862   Point->Pb = 0;
2863   Point->Rb = 0;
2864   Point->Sb = 0;
2865   Point->Sc = 0;
2866   Point->Se = 0;
2867   Point->Sn = 0;
2868   Point->Sr = 0;
2869   Point->Te = 0;
2870   Point->Ti = 0;
2871   Point->Tl = 0;
2872   Point->V = 0;
2873   Point->Zn = 0;
2874   Point->RecCount = Count;
2875   Point->Last = NULL;
2876   Bond = (TBond *)Malloc(sizeof(TBond));
2877   Bond->X1 = 0;
2878   Bond->Y1 = 0;
2879   Bond->X2 = 0;
2880   Bond->Y2 = 0;
2881   Bond->RecCount = Count;
2882   Bond->Last = NULL;
2883   fgets(sss, 256, IFile);
2884   TEMP = strchr(sss, '\n');
2885   if (TEMP != NULL)
2886     *TEMP = 0;
2887   sprintf(sss, "%.18s", strcpy(STR1, sss));
2888   if (strcmp(sss, "Chemtool Version 1")) {
2889     printf("Not a chemtool 1.x file, enter \"cht -h\" for help\n");
2890     printf("file starts: %s\n",sss);
2891     _Escape(2);
2892   }
2893   fscanf(IFile, "%*[^\n]");
2894   getc(IFile);
2895   fgets(sssb, 7, IFile);
2896   TEMP = strchr(sssb, '\n');
2897   if (TEMP != NULL) {
2898     *TEMP = 0;
2899     ungetc('\n', IFile);
2900   }
2901   fscanf(IFile, "%ld%*[^\n]", &bonds);
2902   getc(IFile);
2903   if (bonds == 0)
2904     nobonds = true;
2905   if (!strcmp(sssb, "bonds ")) {
2906     if (bonds > 0)
2907       doBonds();
2908   }
2909   fgets(sssb, 7, IFile);
2910   TEMP = strchr(sssb, '\n');
2911   if (TEMP != NULL) {
2912     *TEMP = 0;
2913     ungetc('\n', IFile);
2914   }
2915   fscanf(IFile, "%ld%*[^\n]", &atoms);
2916   getc(IFile);
2917   if (!strcmp(sssb, "atoms ")) {
2918     if (atoms > 0)
2919       doLabels();
2920   }
2921   if (IFile != NULL)
2922     fclose(IFile);
2923   IFile = NULL;
2924   if (verbose)
2925     printf("---------------------- Summary -------------------------\n");
2926   while (Point->Last != NULL) {
2927     if (verbose)
2928       printf(
2929 	"RecCount: %ld X=%ld Y=%ld C%ld H%ld N%ld O%ld P%ld S%ld Si%ld B%ld\nBr%ld Cl%ld F%ld I%ld Al%ld As%ld Ba%ld Be%ld Bi%ld Ca%ld Cd%ld Co%ld\nCr%ld Cs%ld Cu%ld Fe%ld Ga%ld Ge%ld In%ld Li%ld Mg%ld Mn%ld\nNa%ld Ni%ld K%ld Pb %ld Rb%ld Sb%ld Sc%ld Se%ld Sn%ld Sr%ld Te%ld Ti%ld Tl%ld V%ld Zn%ld\n",
2930 	Point->RecCount, Point->X, Point->Y, Point->C, Point->H, Point->N,
2931 	Point->O, Point->P, Point->S, Point->Si, Point->B, Point->Br,
2932 	Point->Cl, Point->F, Point->I, Point->Al, Point->As, Point->Ba,
2933 	Point->Be,Point->Bi, Point->Ca, Point->Cd, Point->Co,
2934 	Point->Cr, Point->Cs,Point->Cu,Point->Fe,Point->Ga,Point->Ge,
2935 	Point->In,Point->Li,Point->Mg, Point->Mn, Point->Na, Point->Ni,
2936 	Point->K,Point->Pb,Point->Rb, Point->Sb,Point->Sc,Point->Se,Point->Sn,Point->Sr,
2937 	Point->Te,Point->Ti,Point->Tl,Point->V,Point->Zn);
2938     C += Point->C;
2939     H += Point->H;
2940     N += Point->N;
2941     O += Point->O;
2942     P += Point->P;
2943     S += Point->S;
2944     Si += Point->Si;
2945     B += Point->B;
2946     Br += Point->Br;
2947     Cl += Point->Cl;
2948     F += Point->F;
2949     I += Point->I;
2950     Al += Point->Al;
2951     As += Point->As;
2952     Ba += Point->Ba;
2953     Be += Point->Be;
2954     Bi += Point->Bi;
2955     Ca += Point->Ca;
2956     Cd += Point->Cd;
2957     Co += Point->Co;
2958     Cr += Point->Cr;
2959     Cs += Point->Cs;
2960     Cu += Point->Cu;
2961     Fe += Point->Fe;
2962     Ga += Point->Ga;
2963     Ge += Point->Ge;
2964     In += Point->In;
2965     Li += Point->Li;
2966     Mg += Point->Mg;
2967     Mn += Point->Mn;
2968     Na += Point->Na;
2969     Ni += Point->Ni;
2970     K += Point->K;
2971     Pb +=  Point->Pb;
2972     Rb +=  Point->Rb;
2973     Sb +=  Point->Sb;
2974     Sc +=  Point->Sc;
2975     Se +=  Point->Se;
2976     Sn +=  Point->Sn;
2977     Sr +=  Point->Sr;
2978     Te +=  Point->Te;
2979     Ti +=  Point->Ti;
2980     Tl +=  Point->Tl;
2981     V += Point->V;
2982     Zn += Point->Zn;
2983     Point = Point->Last;
2984   }
2985 
2986   if (H < 0)   /*overlapped bonds*/
2987     H = 0;
2988 
2989   M = C * 12.011 + H * 1.0079 + N * 14.0067 + O * 15.9994 + P * 30.97376 +
2990       S * 32.064 + Si * 28.086 + B * 10.81 + Br * 79.904 + Cl * 35.453 +
2991       F * 18.9984 + I * 126.9045 + Mg * 24.305 + Na * 22.98977 + K * 39.098 +
2992       Ca * 40.08 + Cd * 112.41 + Co * 58.933 + Cr * 51.996 + Cu * 63.546 +
2993       Fe * 55.847 + Li * 6.941 + Mn * 54.938 + Ni * 58.69 + Al * 26.981539 +
2994       Ba * 137.327 + Cs * 132.90543 + As * 74.92159 + Be *9.012182 +
2995       Ga * 69.723 + Ge * 72.61 + Sb * 121.75 + Sc * 44.95591 + Se * 78.96 +
2996       Sn * 118.710 + Sr * 87.62 + Rb * 85.4678 + Te * 127.60 + Ti * 47.88 +
2997       V * 50.9415 + Zn * 65.39 + In * 114.82 + Bi * 208.98037 + Pb *207.2 +
2998       Tl * 204.3833;
2999 
3000   Me = C * 12 + H * 1.007825037 + N * 14.003074008 + O * 15.99491464 +
3001        P * 30.9737634 + S * 31.9720718 + Si * 27.9769284 + B * 11.0093053 +
3002        Br * 78.9183361 + Cl * 34.968852729 + F * 18.99840325 +
3003        I * 126.904477 + Mg * 23.9850450 + Na * 22.9897697 + K * 38.9637079 +
3004       Ca * 39.9626 + Cd * 113.9034 + Co * 58.9332 + Cr * 51.9405 + Cu * 62.9296 +
3005       Fe * 55.9349 +Li * 7.0160 + Mn * 54.93805 + Ni * 57.9353 + Al * 26.981539 +
3006       Ba * 137.9052 + Cs * 132.90543 + As * 74.92159 + Be * 9.012182 +
3007       Ga * 68.9256 + Ge * 73.9212 + Sb * 120.9038 + Sc * 44.95591 +
3008       Se *79.9165 + Sn * 119.9022 + Sr * 87.9056 + Rb * 84.9118 +
3009       Te * 129.9062 + Ti * 47.9479 + V * 50.9440 + Zn * 63.9291 +
3010       In * 114.9039 + Bi * 208.98037 + Pb * 207.9766 + Tl * 204.9744;
3011 
3012   if (Me > 0 && *Alert == '\0') {
3013     if (C > 1)
3014       printf("C%ld", C);
3015     if (C == 1)
3016       putchar('C');
3017     if (H > 1)
3018       printf("H%ld", H);
3019     if (H == 1)
3020       putchar('H');
3021     if (N > 1)
3022       printf("N%ld", N);
3023     if (N == 1)
3024       putchar('N');
3025     if (O > 1)
3026       printf("O%ld", O);
3027     if (O == 1)
3028       putchar('O');
3029     if (P > 1)
3030       printf("P%ld", P);
3031     if (P == 1)
3032       putchar('P');
3033     if (S > 1)
3034       printf("S%ld", S);
3035     if (S == 1)
3036       putchar('S');
3037     if (Si > 1)
3038       printf("Si%ld", Si);
3039     if (Si == 1)
3040       printf("Si");
3041     if (B > 1)
3042       printf("B%ld", B);
3043     if (B == 1)
3044       putchar('B');
3045     if (Br > 1)
3046       printf("Br%ld", Br);
3047     if (Br == 1)
3048       printf("Br");
3049     if (Cl > 1)
3050       printf("Cl%ld", Cl);
3051     if (Cl == 1)
3052       printf("Cl");
3053     if (F > 1)
3054       printf("F%ld", F);
3055     if (F == 1)
3056       putchar('F');
3057     if (I > 1)
3058       printf("I%ld", I);
3059     if (I == 1)
3060       putchar('I');
3061     if (Al > 1)
3062       printf("Al%ld", Al);
3063     if (Al == 1)
3064       printf("Al");
3065     if (As > 1)
3066       printf("As%ld", As);
3067     if (As == 1)
3068       printf("As");
3069     if (Ba > 1)
3070       printf("Ba%ld", Ba);
3071     if (Ba == 1)
3072       printf("Ba");
3073     if (Be > 1)
3074       printf("Be%ld", Be);
3075     if (Be == 1)
3076       printf("Be");
3077     if (Bi > 1)
3078       printf("Bi%ld", Bi);
3079     if (Bi == 1)
3080       printf("Bi");
3081     if (Ca > 1)
3082       printf("Ca%ld", Ca);
3083     if (Ca == 1)
3084       printf("Ca");
3085     if (Cd > 1)
3086       printf("Cd%ld", Cd);
3087     if (Cd == 1)
3088       printf("Cd");
3089     if (Co > 1)
3090       printf("Co%ld", Co);
3091     if (Co == 1)
3092       printf("Co");
3093     if (Cr > 1)
3094       printf("Cr%ld", Cr);
3095     if (Cr == 1)
3096       printf("Cr");
3097     if (Cs > 1)
3098       printf("Cs%ld", Cs);
3099     if (Cs == 1)
3100       printf("Cs");
3101     if (Cu > 1)
3102       printf("Cu%ld", Cu);
3103     if (Cu == 1)
3104       printf("Cu");
3105     if (Fe > 1)
3106       printf("Fe%ld", Fe);
3107     if (Fe == 1)
3108       printf("Fe");
3109     if (Ga > 1)
3110       printf("Ga%ld", Ga);
3111     if (Ga == 1)
3112       printf("Ga");
3113     if (Ge > 1)
3114       printf("Ge%ld", Ge);
3115     if (Ge == 1)
3116       printf("Ge");
3117     if (In > 1)
3118       printf("In%ld", In);
3119     if (In == 1)
3120       printf("In");
3121     if (Li > 1)
3122       printf("Li%ld", Li);
3123     if (Li == 1)
3124       printf("Li");
3125     if (Mg > 1)
3126       printf("Mg%ld", Mg);
3127     if (Mg == 1)
3128       printf("Mg");
3129     if (Mn > 1)
3130       printf("Mn%ld", Mn);
3131     if (Mn == 1)
3132       printf("Mn");
3133     if (Na > 1)
3134       printf("Na%ld", Na);
3135     if (Na == 1)
3136       printf("Na");
3137     if (Ni > 1)
3138       printf("Ni%ld", Ni);
3139     if (Ni == 1)
3140       printf("Ni");
3141     if (Pb > 1)
3142       printf("Pb%ld", Pb);
3143     if (Pb == 1)
3144       printf("Pb");
3145     if (Rb > 1)
3146       printf("Rb%ld", Rb);
3147     if (Rb == 1)
3148       printf("Rb");
3149     if (Sb > 1)
3150       printf("Sb%ld", Sb);
3151     if (Sb == 1)
3152       printf("Sb");
3153     if (Sc > 1)
3154       printf("Sc%ld", Sc);
3155     if (Sc == 1)
3156       printf("Sc");
3157     if (Se > 1)
3158       printf("Se%ld", Se);
3159     if (Se == 1)
3160       printf("Se");
3161     if (Sn > 1)
3162       printf("Sn%ld", Sn);
3163     if (Sn == 1)
3164       printf("Sn");
3165     if (Sr > 1)
3166       printf("Sr%ld", Sr);
3167     if (Sr == 1)
3168       printf("Sr");
3169     if (Te > 1)
3170       printf("Te%ld", Te);
3171     if (Te == 1)
3172       printf("Te");
3173     if (Ti > 1)
3174       printf("Ti%ld", Ti);
3175     if (Ti == 1)
3176       printf("Ti");
3177     if (Tl > 1)
3178       printf("Tl%ld", Tl);
3179     if (Tl == 1)
3180       printf("Tl");
3181     if (V > 1)
3182       printf("V%ld", V);
3183     if (V == 1)
3184       printf("V");
3185     if (Zn > 1)
3186       printf("Zn%ld", Zn);
3187     if (Zn == 1)
3188       printf("Zn");
3189     if (K > 1)
3190       printf("K%ld", K);
3191     if (K == 1)
3192       putchar('K');
3193 
3194     printf(" [%2.3f]", M);
3195     printf(" Me=%2.10f ", Me);
3196 
3197     if (C > 0)
3198       printf("%4.2f%%C;", C * 12.011 * 100 / M);
3199     if (H > 0)
3200       printf("%4.2f%%H;", H * 1.0079 * 100 / M);
3201     if (B > 0)
3202       printf("%4.2f%%B;", B * 10.81 * 100 / M);
3203     if (N > 0)
3204       printf("%4.2f%%N;", N * 14.0067 * 100 / M);
3205     if (O > 0)
3206       printf("%4.2f%%O;", O * 15.9994 * 100 / M);
3207     if (P > 0)
3208       printf("%4.2f%%P;", P * 30.97376 * 100 / M);
3209     if (S > 0)
3210       printf("%4.2f%%S;", S * 32.0640 * 100 / M);
3211     if (K > 0)
3212       printf("%4.2f%%K;", K * 39.098 * 100 / M);
3213     if (Mg > 0)
3214       printf("%4.2f%%Mg;", Mg * 24.305 * 100 / M);
3215     if (Na > 0)
3216       printf("%4.2f%%Na;", Na * 22.98977 * 100 / M);
3217     if (Si > 0)
3218       printf("%4.2f%%Si;", Si * 28.086 * 100 / M);
3219     if (Br > 0)
3220       printf("%4.2f%%Br;", Br * 79.904 * 100 / M);
3221     if (Cl > 0)
3222       printf("%4.2f%%Cl;", Cl * 35.453 * 100 / M);
3223     if (F > 0)
3224       printf("%4.2f%%F;", F * 18.9984 * 100 / M);
3225     if (I > 0)
3226       printf("%4.2f%%I;", I * 126.9045 * 100 / M);
3227     if (Al >0)
3228       printf("%4.2f%%Al;", Al * 26.981539 * 100 / M);
3229     if (As >0)
3230       printf("%4.2f%%As;", As * 74.92159 * 100 / M);
3231     if (Ba >0)
3232       printf("%4.2f%%Ba;", Ba * 137.327 * 100 / M);
3233     if (Be >0)
3234       printf("%4.2f%%Be;", Be * 9.012182 * 100 / M);
3235     if (Bi >0)
3236       printf("%4.2f%%Bi;", Bi * 208.98037 * 100 / M);
3237     if (Ca >0)
3238       printf("%4.2f%%Ca;", Ca * 40.08 * 100 / M);
3239     if (Cd >0)
3240       printf("%4.2f%%Cd;", Cd * 112.41 * 100 / M);
3241     if (Co >0)
3242       printf("%4.2f%%Co;", Co * 58.993 * 100 / M);
3243     if (Cr >0)
3244       printf("%4.2f%%Cr;", Cr * 51.996 * 100 / M);
3245     if (Cs >0)
3246       printf("%4.2f%%Cs;", Cs * 132.90543 * 100 / M);
3247     if (Cu >0)
3248       printf("%4.2f%%Cu;", Cu * 63.546 * 100 / M);
3249     if (Fe >0)
3250       printf("%4.2f%%Fe;", Fe * 55.847 * 100 / M);
3251     if (Ga >0)
3252       printf("%4.2f%%Ga;", Ga * 69.723 * 100 / M);
3253     if (Ge >0)
3254       printf("%4.2f%%Ge;", Ge * 72.61 * 100 / M);
3255     if (In >0)
3256       printf("%4.2f%%In;", In * 114.82 * 100 / M);
3257     if (Li >0)
3258       printf("%4.2f%%Li;", Li * 6.941 * 100 / M);
3259     if (Mn >0)
3260       printf("%4.2f%%Mn;", Mn * 54.938 * 100 / M);
3261     if (Ni >0)
3262       printf("%4.2f%%Ni;", Ni * 58.69  *100 / M);
3263     if (Pb >0)
3264       printf("%4.2f%%Pb;", Pb * 207.2  *100 / M);
3265     if (Rb >0)
3266       printf("%4.2f%%Rb;", Rb * 85.4678  *100 / M);
3267     if (Sb >0)
3268       printf("%4.2f%%Sb;", Sb * 121.75  *100 / M);
3269     if (Sc >0)
3270       printf("%4.2f%%Sc;", Sc * 44.95591  *100 / M);
3271     if (Se >0)
3272       printf("%4.2f%%Se;", Se * 78.96  *100 / M);
3273     if (Sn >0)
3274       printf("%4.2f%%Sn;", Sn * 118.71  *100 / M);
3275     if (Sr >0)
3276       printf("%4.2f%%Sr;", Sr * 87.62  *100 / M);
3277     if (Te >0)
3278       printf("%4.2f%%Te;", Te * 127.60  *100 / M);
3279     if (Ti >0)
3280       printf("%4.2f%%Ti;", Ti * 47.88  *100 / M);
3281     if (Tl >0)
3282       printf("%4.2f%%Tl;", Tl * 204.3833 *100 / M);
3283     if (V >0)
3284       printf("%4.2f%%V;", V * 50.9415  *100 / M);
3285     if (Zn >0)
3286       printf("%4.2f%%Zn;", Zn * 65.39  *100 / M);
3287   } else {
3288     if (*Alert != '\0')
3289       printf("%s overlapped bonds !", Alert);
3290     else
3291       printf("C0H0 [0.00] Me=0.0000000000 0.00%%C;0.00%%H");
3292   }
3293   putchar('\n');
3294   exit(EXIT_SUCCESS);
3295 }
3296 
3297 
3298 
3299 /* End. */
3300