PageRenderTime 54ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/chemtool-1.6.13/src-cht/cht-2.5.c.compile

#
Unknown | 3688 lines | 3366 code | 322 blank | 0 comment | 0 complexity | d1b802b5d5ac8f1bc81891946c00e4ee MD5 | raw file
Possible License(s): GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. /* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */
  2. /* From input file "cht-1.7.pp" */
  3. #ifdef HAVE_CONFIG_H
  4. #include <config.h>
  5. #endif
  6. #ifndef P2C_H
  7. #define P2C_H
  8. /* Header file for code generated by "p2c", the Pascal-to-C translator */
  9. /* "p2c" Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation.
  10. * By Dave Gillespie, daveg@synaptics.com. Version 1.21alpha-07.Dec.93.
  11. * This file may be copied, modified, etc. in any way. It is not restricted
  12. * by the licence agreement accompanying p2c itself.
  13. */
  14. #include <stdio.h>
  15. #include <unistd.h>
  16. #define DOUBLE double
  17. /* If the following heuristic fails, compile -DBSD=0 for non-BSD systems,
  18. or -DBSD=1 for BSD systems. */
  19. #ifdef M_XENIX
  20. # define BSD 0
  21. #endif
  22. #ifdef vms
  23. # define BSD 0
  24. # ifndef __STDC__
  25. # define __STDC__ 1
  26. # endif
  27. #endif
  28. #ifdef __TURBOC__
  29. # define MSDOS 1
  30. #endif
  31. #ifdef MSDOS
  32. # define BSD 0
  33. #endif
  34. #ifdef FILE /* a #define in BSD, a typedef in SYSV (hp-ux, at least) */
  35. # ifndef BSD /* (a convenient, but horrible kludge!) */
  36. # define BSD 1
  37. # endif
  38. #endif
  39. #ifdef BSD
  40. # if !BSD
  41. # undef BSD
  42. # endif
  43. #endif
  44. #if (defined(__STDC__) && !defined(M_XENIX)) || defined(__TURBOC__)
  45. # include <stdlib.h>
  46. # include <stddef.h>
  47. # define HAS_STDLIB
  48. # if defined(vms) || defined(__TURBOC__)
  49. # define NON_ANSI_CAT
  50. # endif
  51. #else
  52. # ifndef BSD
  53. # ifndef __TURBOC__
  54. # include <memory.h>
  55. # endif
  56. # endif
  57. # ifdef hpux
  58. # ifdef _INCLUDE__STDC__
  59. # include <stddef.h>
  60. # include <stdlib.h>
  61. # define HAS_STDLIB
  62. # endif
  63. # endif
  64. # include <sys/types.h>
  65. # if !defined(MSDOS) || defined(__TURBOC__)
  66. # define NON_ANSI_CAT
  67. # endif
  68. #endif
  69. #if defined(NON_ANSI_CAT) && !defined(ANSI_CAT)
  70. # ifdef NON_ANSI_CAT_ALTERNATE
  71. # define __CAT__(a,b)a/**/b
  72. # else
  73. # define __ID__(a)a
  74. # define __CAT__(a,b)__ID__(a)b
  75. # endif
  76. #else
  77. # define __CAT__(a,b)a##b
  78. #endif
  79. #ifdef BSD
  80. # include <strings.h>
  81. # define memcpy(a,b,n) (bcopy(b,a,n),a)
  82. # define memcmp(a,b,n) bcmp(a,b,n)
  83. # define strchr(s,c) index(s,c)
  84. # define strrchr(s,c) rindex(s,c)
  85. #else
  86. # include <string.h>
  87. #endif
  88. #include <ctype.h>
  89. #include <math.h>
  90. #include <setjmp.h>
  91. #include <assert.h>
  92. #ifndef NO_LACK
  93. #ifdef vms
  94. #define LACK_LABS
  95. #define LACK_MEMMOVE
  96. #define LACK_MEMCPY
  97. #else
  98. #define LACK_LABS /* Undefine these if your library has these */
  99. #define LACK_MEMMOVE
  100. #endif
  101. #endif
  102. typedef struct __p2c_jmp_buf {
  103. struct __p2c_jmp_buf *next;
  104. jmp_buf jbuf;
  105. } __p2c_jmp_buf;
  106. /* Warning: The following will not work if setjmp is used simultaneously.
  107. This also violates the ANSI restriction about using vars after longjmp,
  108. but a typical implementation of longjmp will get it right anyway. */
  109. #ifndef FAKE_TRY
  110. # define TRY(x) do { __p2c_jmp_buf __try_jb; \
  111. __try_jb.next = __top_jb; \
  112. if (!setjmp((__top_jb = &__try_jb)->jbuf)) {
  113. # define RECOVER(x) __top_jb = __try_jb.next; } else {
  114. # define RECOVER2(x,L) __top_jb = __try_jb.next; } else { \
  115. if (0) { L: __top_jb = __try_jb.next; }
  116. # define ENDTRY(x) } } while (0)
  117. #else
  118. # define TRY(x) if (1) {
  119. # define RECOVER(x) } else do {
  120. # define RECOVER2(x,L) } else do { L: ;
  121. # define ENDTRY(x) } while (0)
  122. #endif
  123. #ifdef M_XENIX /* avoid compiler bug */
  124. # define SHORT_MAX (32767)
  125. # define SHORT_MIN (-32768)
  126. #endif
  127. /* The following definitions work only on twos-complement machines */
  128. #ifndef SHORT_MAX
  129. # define SHORT_MAX ((short)(((unsigned short) -1) >> 1))
  130. # define SHORT_MIN (~SHORT_MAX)
  131. #endif
  132. #ifndef INT_MAX
  133. # define INT_MAX ((int)(((unsigned int) -1) >> 1))
  134. # define INT_MIN (~INT_MAX)
  135. #endif
  136. #ifndef LONG_MAX
  137. # define LONG_MAX ((long)(((unsigned long) -1) >> 1))
  138. # define LONG_MIN (~LONG_MAX)
  139. #endif
  140. #ifndef SEEK_SET
  141. # define SEEK_SET 0
  142. # define SEEK_CUR 1
  143. # define SEEK_END 2
  144. #endif
  145. #ifndef EXIT_SUCCESS
  146. # ifdef vms
  147. # define EXIT_SUCCESS 1
  148. # define EXIT_FAILURE (02000000000L)
  149. # else
  150. # define EXIT_SUCCESS 0
  151. # define EXIT_FAILURE 1
  152. # endif
  153. #endif
  154. #define SETBITS 32
  155. #if defined(__STDC__) || defined(__TURBOC__)
  156. # if !defined(vms) && !defined(M_LINT)
  157. # define Signed signed
  158. # else
  159. # define Signed
  160. # endif
  161. # define Void void /* Void f() = procedure */
  162. # ifndef Const
  163. # define Const const
  164. # endif
  165. # ifndef Volatile
  166. # define Volatile volatile
  167. # endif
  168. # ifdef M_LINT
  169. # define PP(x) ()
  170. # define PV() ()
  171. typedef char *Anyptr;
  172. # else
  173. # define PP(x) x /* function prototype */
  174. # define PV() (void) /* null function prototype */
  175. typedef void *Anyptr;
  176. # endif
  177. #else
  178. # define Signed
  179. # define Void void
  180. # ifndef Const
  181. # define Const
  182. # endif
  183. # ifndef Volatile
  184. # define Volatile
  185. # endif
  186. # define PP(x) ()
  187. # define PV() ()
  188. typedef char *Anyptr;
  189. #endif
  190. #ifdef __GNUC__
  191. # define Inline inline
  192. #else
  193. # define Inline
  194. #endif
  195. #define Register register /* Register variables */
  196. #define Char char /* Characters (not bytes) */
  197. #ifndef Static
  198. # define Static static /* Private global funcs and vars */
  199. #endif
  200. #ifndef Local
  201. # define Local static /* Nested functions */
  202. #endif
  203. typedef Signed char schar;
  204. typedef unsigned char uchar;
  205. typedef unsigned char boolean;
  206. #ifndef NO_DECLARE_ALFA
  207. typedef Char alfa[10];
  208. #endif
  209. #ifndef true
  210. # define true 1
  211. # define false 0
  212. #endif
  213. #ifndef TRUE
  214. # define TRUE 1
  215. # define FALSE 0
  216. #endif
  217. typedef struct {
  218. Anyptr proc, link;
  219. } _PROCEDURE;
  220. #ifndef _FNSIZE
  221. # define _FNSIZE 120
  222. #endif
  223. extern Void PASCAL_MAIN PP( (int, Char **) );
  224. extern Char **P_argv;
  225. extern int P_argc;
  226. extern short P_escapecode;
  227. extern int P_ioresult;
  228. extern __p2c_jmp_buf *__top_jb;
  229. #ifdef P2C_H_PROTO /* if you have Ansi C but non-prototyped header files */
  230. extern Char *strcat PP( (Char *, Const Char *) );
  231. extern Char *strchr PP( (Const Char *, int) );
  232. extern int strcmp PP( (Const Char *, Const Char *) );
  233. extern Char *strcpy PP( (Char *, Const Char *) );
  234. extern size_t strlen PP( (Const Char *) );
  235. extern Char *strncat PP( (Char *, Const Char *, size_t) );
  236. extern int strncmp PP( (Const Char *, Const Char *, size_t) );
  237. extern Char *strncpy PP( (Char *, Const Char *, size_t) );
  238. extern Char *strrchr PP( (Const Char *, int) );
  239. extern Anyptr memchr PP( (Const Anyptr, int, size_t) );
  240. extern Anyptr memmove PP( (Anyptr, Const Anyptr, size_t) );
  241. extern Anyptr memset PP( (Anyptr, int, size_t) );
  242. #ifndef memcpy
  243. extern Anyptr memcpy PP( (Anyptr, Const Anyptr, size_t) );
  244. extern int memcmp PP( (Const Anyptr, Const Anyptr, size_t) );
  245. #endif
  246. extern int atoi PP( (Const Char *) );
  247. extern double atof PP( (Const Char *) );
  248. extern long atol PP( (Const Char *) );
  249. extern double strtod PP( (Const Char *, Char **) );
  250. extern long strtol PP( (Const Char *, Char **, int) );
  251. #endif /*P2C_H_PROTO*/
  252. #ifndef HAS_STDLIB
  253. #ifndef NO_DECLARE_MALLOC
  254. extern Anyptr malloc PP( (size_t) );
  255. extern Void free PP( (Anyptr) );
  256. #endif
  257. #endif
  258. extern int _OutMem PV();
  259. extern int _CaseCheck PV();
  260. extern int _NilCheck PV();
  261. extern int _Escape PP( (int) );
  262. extern int _EscIO PP( (int) );
  263. extern int _EscIO2 PP( (int, Char *) );
  264. extern long ipow PP( (long, long) );
  265. extern long P_imax PP( (long, long) );
  266. extern long P_imin PP( (long, long) );
  267. extern double P_rmax PP( (double, double) );
  268. extern double P_rmin PP( (double, double) );
  269. extern Char *strsub PP( (Char *, Char *, int, int) );
  270. extern Char *strltrim PP( (Char *) );
  271. extern Char *strrtrim PP( (Char *) );
  272. extern Char *strrpt PP( (Char *, Char *, int) );
  273. extern Char *strpad PP( (Char *, Char *, int, int) );
  274. extern int strpos2 PP( (Char *, Char *, int) );
  275. extern long memavail PV();
  276. extern int P_peek PP( (FILE *) );
  277. extern int P_eof PP( (FILE *) );
  278. extern int P_eoln PP( (FILE *) );
  279. extern Void P_readpaoc PP( (FILE *, Char *, int) );
  280. extern Void P_readlnpaoc PP( (FILE *, Char *, int) );
  281. extern long P_maxpos PP( (FILE *) );
  282. extern Char *P_trimname PP( (Char *, int) );
  283. extern long *P_setunion PP( (long *, long *, long *) );
  284. extern long *P_setint PP( (long *, long *, long *) );
  285. extern long *P_setdiff PP( (long *, long *, long *) );
  286. extern long *P_setxor PP( (long *, long *, long *) );
  287. extern int P_inset PP( (unsigned, long *) );
  288. extern int P_setequal PP( (long *, long *) );
  289. extern int P_subset PP( (long *, long *) );
  290. extern long *P_addset PP( (long *, unsigned) );
  291. extern long *P_addsetr PP( (long *, unsigned, unsigned) );
  292. extern long *P_remset PP( (long *, unsigned) );
  293. extern long *P_setcpy PP( (long *, long *) );
  294. extern long *P_expset PP( (long *, long) );
  295. extern long P_packset PP( (long *) );
  296. extern FILE *_skipspaces PP( (FILE *) );
  297. extern FILE *_skipnlspaces PP( (FILE *) );
  298. /* I/O error handling */
  299. #define _CHKIO(cond,ior,val,def) ((cond) ? P_ioresult=0,(val) \
  300. : P_ioresult=(ior),(def))
  301. #define _SETIO(cond,ior) (P_ioresult = (cond) ? 0 : (ior))
  302. /* Following defines are suitable for the HP Pascal operating system */
  303. #define FileNotFound 10
  304. #define FileNotOpen 13
  305. #define FileWriteError 38
  306. #define BadInputFormat 14
  307. #define EndOfFile 30
  308. #define FILENOTFOUND 10
  309. #define FILENOTOPEN 13
  310. #define FILEWRITEERROR 38
  311. #define BADINPUTFORMAT 14
  312. #define ENDOFFILE 30
  313. /* Creating temporary files */
  314. #if (defined(BSD) || defined(NO_TMPFILE)) && !defined(HAVE_TMPFILE)
  315. # define tmpfile() (fopen(tmpnam(NULL), "w+"))
  316. #endif
  317. /* File buffers */
  318. #define FILEBUF(f,sc,type) sc int __CAT__(f,_BFLAGS); \
  319. sc type __CAT__(f,_BUFFER)
  320. #define FILEBUFNC(f,type) int __CAT__(f,_BFLAGS); \
  321. type __CAT__(f,_BUFFER)
  322. #define RESETBUF(f,type) (__CAT__(f,_BFLAGS) = 1)
  323. #define SETUPBUF(f,type) (__CAT__(f,_BFLAGS) = 0)
  324. #define GETFBUF(f,type) (*((__CAT__(f,_BFLAGS) == 1 && \
  325. ((__CAT__(f,_BFLAGS) = 2), \
  326. fread(&__CAT__(f,_BUFFER), \
  327. sizeof(type),1,(f)))),\
  328. &__CAT__(f,_BUFFER)))
  329. #define AGETFBUF(f,type) ((__CAT__(f,_BFLAGS) == 1 && \
  330. ((__CAT__(f,_BFLAGS) = 2), \
  331. fread(__CAT__(f,_BUFFER), \
  332. sizeof(type),1,(f)))),\
  333. __CAT__(f,_BUFFER))
  334. #define PUTFBUF(f,type,v) (GETFBUF(f,type) = (v))
  335. #define CPUTFBUF(f,v) (PUTFBUF(f,char,v))
  336. #define APUTFBUF(f,type,v) (memcpy(AGETFBUF(f,type), (v), \
  337. sizeof(__CAT__(f,_BUFFER))))
  338. #define GET(f,type) (__CAT__(f,_BFLAGS) == 1 ? \
  339. fread(&__CAT__(f,_BUFFER),sizeof(type),1,(f)) : \
  340. (__CAT__(f,_BFLAGS) = 1))
  341. #define PUT(f,type) (fwrite(&__CAT__(f,_BUFFER),sizeof(type),1,(f)), \
  342. (__CAT__(f,_BFLAGS) = 0))
  343. #define CPUT(f) (PUT(f,char))
  344. #define BUFEOF(f) (__CAT__(f,_BFLAGS) != 2 && P_eof(f))
  345. #define BUFFPOS(f) (ftell(f) - (__CAT__(f,_BFLAGS) == 2))
  346. typedef struct {
  347. FILE *f;
  348. int f_BFLAGS; /* FILEBUFNC(f,Char); */
  349. Char f_BUFFER;
  350. Char name[_FNSIZE];
  351. } _TEXT;
  352. /* Memory allocation */
  353. #ifdef __GCC__
  354. # define Malloc(n) (malloc(n) ?: (Anyptr)_OutMem())
  355. #else
  356. extern Anyptr __MallocTemp__;
  357. # define Malloc(n) ((__MallocTemp__ = malloc(n)) ? __MallocTemp__ : (Anyptr)_OutMem())
  358. #endif
  359. #define FreeR(p) (free((Anyptr)(p))) /* used if arg is an rvalue */
  360. #define Free(p) (free((Anyptr)(p)), (p)=NULL)
  361. /* sign extension */
  362. #define SEXT(x,n) ((x) | -(((x) & (1L<<((n)-1))) << 1))
  363. /* packed arrays */ /* BEWARE: these are untested! */
  364. #define P_getbits_UB(a,i,n,L) ((int)((a)[(i)>>(L)-(n)] >> \
  365. (((~(i))&((1<<(L)-(n))-1)) << (n)) & \
  366. (1<<(1<<(n)))-1))
  367. #define P_getbits_SB(a,i,n,L) ((int)((a)[(i)>>(L)-(n)] << \
  368. (16 - ((((~(i))&((1<<(L)-(n))-1))+1) <<\
  369. (n)) >> (16-(1<<(n))))))
  370. #define P_putbits_UB(a,i,x,n,L) ((a)[(i)>>(L)-(n)] |= \
  371. (x) << (((~(i))&((1<<(L)-(n))-1)) << (n)))
  372. #define P_putbits_SB(a,i,x,n,L) ((a)[(i)>>(L)-(n)] |= \
  373. ((x) & (1<<(1<<(n)))-1) << \
  374. (((~(i))&((1<<(L)-(n))-1)) << (n)))
  375. #define P_clrbits_B(a,i,n,L) ((a)[(i)>>(L)-(n)] &= \
  376. ~( ((1<<(1<<(n)))-1) << \
  377. (((~(i))&((1<<(L)-(n))-1)) << (n))) )
  378. /* small packed arrays */
  379. #define P_getbits_US(v,i,n) ((int)((v) >> ((i)<<(n)) & (1<<(1<<(n)))-1))
  380. #define P_getbits_SS(v,i,n) ((int)((long)(v) << (SETBITS - (((i)+1) << (n))) >> (SETBITS-(1<<(n)))))
  381. #define P_putbits_US(v,i,x,n) ((v) |= (x) << ((i) << (n)))
  382. #define P_putbits_SS(v,i,x,n) ((v) |= ((x) & (1<<(1<<(n)))-1) << ((i)<<(n)))
  383. #define P_clrbits_S(v,i,n) ((v) &= ~( ((1<<(1<<(n)))-1) << ((i)<<(n)) ))
  384. #define P_max(a,b) ((a) > (b) ? (a) : (b))
  385. #define P_min(a,b) ((a) < (b) ? (a) : (b))
  386. /* Fix ANSI-isms */
  387. #ifdef LACK_LABS
  388. # ifndef labs
  389. # define labs my_labs
  390. extern long my_labs PP( (long) );
  391. # endif
  392. #endif
  393. #ifdef LACK_MEMMOVE
  394. # ifndef memmove
  395. # define memmove my_memmove
  396. extern Anyptr my_memmove PP( (Anyptr, Const Anyptr, size_t) );
  397. # endif
  398. #endif
  399. #ifdef LACK_MEMCPY
  400. # ifndef memcpy
  401. # define memcpy my_memcpy
  402. extern Anyptr my_memcpy PP( (Anyptr, Const Anyptr, size_t) );
  403. # endif
  404. # ifndef memcmp
  405. # define memcmp my_memcmp
  406. extern int my_memcmp PP( (Const Anyptr, Const Anyptr, size_t) );
  407. # endif
  408. # ifndef memset
  409. # define memset my_memset
  410. extern Anyptr my_memset PP( (Anyptr, int, size_t) );
  411. # endif
  412. #endif
  413. /* Fix toupper/tolower on Suns and other stupid BSD systems */
  414. #ifdef toupper
  415. # undef toupper
  416. # undef tolower
  417. # define toupper(c) my_toupper(c)
  418. # define tolower(c) my_tolower(c)
  419. #endif
  420. #ifndef _toupper
  421. # if 'A' == 65 && 'a' == 97
  422. # define _toupper(c) ((c)-'a'+'A')
  423. # define _tolower(c) ((c)-'A'+'a')
  424. # else
  425. # ifdef toupper
  426. # undef toupper /* hope these are shadowing real functions, */
  427. # undef tolower /* because my_toupper calls _toupper! */
  428. # endif
  429. # define _toupper(c) toupper(c)
  430. # define _tolower(c) tolower(c)
  431. # endif
  432. #endif
  433. #endif /* P2C_H */
  434. /* End. */
  435. /* Run-time library for use with "p2c", the Pascal to C translator */
  436. /* "p2c" Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation.
  437. * By Dave Gillespie, daveg@synaptics.com. Version --VERSION--.
  438. * This file may be copied, modified, etc. in any way. It is not restricted
  439. * by the licence agreement accompanying p2c itself.
  440. */
  441. #ifndef NO_TIME
  442. # include <time.h>
  443. #endif
  444. #define Isspace(c) isspace(c) /* or "((c) == ' ')" if preferred */
  445. int P_argc;
  446. char **P_argv;
  447. short P_escapecode;
  448. int P_ioresult;
  449. long EXCP_LINE; /* Used by Pascal workstation system */
  450. Anyptr __MallocTemp__;
  451. __p2c_jmp_buf *__top_jb;
  452. void PASCAL_MAIN(argc, argv)
  453. int argc;
  454. char **argv;
  455. {
  456. P_argc = argc;
  457. P_argv = argv;
  458. __top_jb = NULL;
  459. #ifdef LOCAL_INIT
  460. LOCAL_INIT();
  461. #endif
  462. }
  463. /* In case your system lacks these... */
  464. long my_labs(x)
  465. long x;
  466. {
  467. return((x > 0) ? x : -x);
  468. }
  469. #ifdef __STDC__
  470. Anyptr my_memmove(Anyptr d, Const Anyptr s, size_t n)
  471. #else
  472. Anyptr my_memmove(d, s, n)
  473. Anyptr d, s;
  474. register int n;
  475. #endif
  476. {
  477. register char *dd = (char *)d, *ss = (char *)s;
  478. if (dd < ss || dd - ss >= (int)n) {
  479. #if defined(bcopy) && defined(memcpy)
  480. my_memcpy(dd, ss, n);
  481. #else
  482. memcpy(dd, ss, (size_t)n);
  483. #endif
  484. } else if (n > 0) {
  485. dd += n;
  486. ss += n;
  487. while (n-- > 0)
  488. *--dd = *--ss;
  489. }
  490. return d;
  491. }
  492. #ifdef __STDC__
  493. Anyptr my_memcpy(Anyptr d, Const Anyptr s, size_t n)
  494. #else
  495. Anyptr my_memcpy(d, s, n)
  496. Anyptr d, s;
  497. register int n;
  498. #endif
  499. {
  500. register char *ss = (char *)s, *dd = (char *)d;
  501. while (n-- > 0)
  502. *dd++ = *ss++;
  503. return d;
  504. }
  505. #ifdef __STDC__
  506. int my_memcmp(Const Anyptr s1, Const Anyptr s2, size_t n)
  507. #else
  508. int my_memcmp(s1, s2, n)
  509. Anyptr s1, s2;
  510. register int n;
  511. #endif
  512. {
  513. register char *a = (char *)s1, *b = (char *)s2;
  514. register int i;
  515. while (n-- > 0)
  516. if ((i = (*a++) - (*b++)) != 0)
  517. return i;
  518. return 0;
  519. }
  520. #ifdef __STDC__
  521. Anyptr my_memset(Anyptr d, int c, size_t n)
  522. #else
  523. Anyptr my_memset(d, c, n)
  524. Anyptr d;
  525. register int c;
  526. register int n;
  527. #endif
  528. {
  529. register char *dd = (char *)d;
  530. while (n-- > 0)
  531. *dd++ = c;
  532. return d;
  533. }
  534. int my_toupper(c)
  535. int c;
  536. {
  537. if (islower(c))
  538. return _toupper(c);
  539. else
  540. return c;
  541. }
  542. int my_tolower(c)
  543. int c;
  544. {
  545. if (isupper(c))
  546. return _tolower(c);
  547. else
  548. return c;
  549. }
  550. long ipow(a, b)
  551. long a, b;
  552. {
  553. long v;
  554. if (a == 0 || a == 1)
  555. return a;
  556. if (a == -1)
  557. return (b & 1) ? -1 : 1;
  558. if (b < 0)
  559. return 0;
  560. if (a == 2)
  561. return 1L << b;
  562. v = (b & 1) ? a : 1;
  563. while ((b >>= 1) > 0) {
  564. a *= a;
  565. if (b & 1)
  566. v *= a;
  567. }
  568. return v;
  569. }
  570. long P_imax(a, b)
  571. long a, b;
  572. {
  573. if (a > b)
  574. return a;
  575. else
  576. return b;
  577. }
  578. long P_imin(a, b)
  579. long a, b;
  580. {
  581. if (a < b)
  582. return a;
  583. else
  584. return b;
  585. }
  586. double P_rmax(a, b)
  587. double a, b;
  588. {
  589. if (a > b)
  590. return a;
  591. else
  592. return b;
  593. }
  594. double P_rmin(a, b)
  595. double a, b;
  596. {
  597. if (a < b)
  598. return a;
  599. else
  600. return b;
  601. }
  602. /* Common string functions: */
  603. /* Store in "ret" the substring of length "len" starting from "pos" (1-based).
  604. Store a shorter or null string if out-of-range. Return "ret". */
  605. char *strsub(ret, s, pos, len)
  606. register char *ret, *s;
  607. register int pos, len;
  608. {
  609. register char *s2;
  610. if (--pos < 0 || len <= 0) {
  611. *ret = 0;
  612. return ret;
  613. }
  614. while (pos > 0) {
  615. if (!*s++) {
  616. *ret = 0;
  617. return ret;
  618. }
  619. pos--;
  620. }
  621. s2 = ret;
  622. while (--len >= 0) {
  623. if (!(*s2++ = *s++))
  624. return ret;
  625. }
  626. *s2 = 0;
  627. return ret;
  628. }
  629. /* Return the index of the first occurrence of "pat" as a substring of "s",
  630. starting at index "pos" (1-based). Result is 1-based, 0 if not found. */
  631. int strpos2(s, pat, pos)
  632. char *s;
  633. register char *pat;
  634. register int pos;
  635. {
  636. register char *cp, ch;
  637. register int slen;
  638. if (--pos < 0)
  639. return 0;
  640. slen = (int)strlen(s) - pos;
  641. cp = s + pos;
  642. if (!(ch = *pat++))
  643. return 0;
  644. pos = (int)strlen(pat);
  645. slen -= pos;
  646. while (--slen >= 0) {
  647. if (*cp++ == ch && !strncmp(cp, pat, (size_t)pos))
  648. return cp - s;
  649. }
  650. return 0;
  651. }
  652. /* Case-insensitive version of strcmp. */
  653. int strcicmp(s1, s2)
  654. register char *s1, *s2;
  655. {
  656. register unsigned char c1, c2;
  657. while (*s1) {
  658. if (*s1++ != *s2++) {
  659. if (!s2[-1])
  660. return 1;
  661. c1 = (unsigned char)toupper(s1[-1]);
  662. c2 = (unsigned char)toupper(s2[-1]);
  663. if (c1 != c2)
  664. return c1 - c2;
  665. }
  666. }
  667. if (*s2)
  668. return -1;
  669. return 0;
  670. }
  671. /* HP and Turbo Pascal string functions: */
  672. /* Trim blanks at left end of string. */
  673. char *strltrim(s)
  674. register char *s;
  675. {
  676. while (Isspace(*s++)) ;
  677. return s - 1;
  678. }
  679. /* Trim blanks at right end of string. */
  680. char *strrtrim(s)
  681. register char *s;
  682. {
  683. register char *s2 = s;
  684. if (!*s)
  685. return s;
  686. while (*++s2) ;
  687. while (s2 > s && Isspace(*--s2))
  688. *s2 = 0;
  689. return s;
  690. }
  691. /* Store in "ret" "num" copies of string "s". Return "ret". */
  692. char *strrpt(ret, s, num)
  693. char *ret;
  694. register char *s;
  695. register int num;
  696. {
  697. register char *s2 = ret;
  698. register char *s1;
  699. while (--num >= 0) {
  700. s1 = s;
  701. while ((*s2++ = *s1++)) ;
  702. s2--;
  703. }
  704. return ret;
  705. }
  706. /* Store in "ret" string "s" with enough pad chars added to reach "size". */
  707. char *strpad(ret, s, padchar, num)
  708. char *ret;
  709. register char *s;
  710. register int padchar, num;
  711. {
  712. register char *d = ret;
  713. if (s == d) {
  714. while (*d++) ;
  715. } else {
  716. while ((*d++ = *s++)) ;
  717. }
  718. num -= (--d - ret);
  719. while (--num >= 0)
  720. *d++ = padchar;
  721. *d = 0;
  722. return ret;
  723. }
  724. /* Copy the substring of length "len" from index "spos" of "s" (1-based)
  725. to index "dpos" of "d", lengthening "d" if necessary. Length and
  726. indices must be in-range. */
  727. void strmove(len, s, spos, d, dpos)
  728. register char *s, *d;
  729. register int len, spos, dpos;
  730. {
  731. s += spos - 1;
  732. d += dpos - 1;
  733. while (*d && --len >= 0)
  734. *d++ = *s++;
  735. if (len > 0) {
  736. while (--len >= 0)
  737. *d++ = *s++;
  738. *d = 0;
  739. }
  740. }
  741. /* Delete the substring of length "len" at index "pos" from "s".
  742. Delete less if out-of-range. */
  743. void strdelete(s, pos, len)
  744. register char *s;
  745. register int pos, len;
  746. {
  747. register int slen;
  748. if (--pos < 0)
  749. return;
  750. slen = (int)strlen(s) - pos;
  751. if (slen <= 0)
  752. return;
  753. s += pos;
  754. if (slen <= len) {
  755. *s = 0;
  756. return;
  757. }
  758. while ((*s = s[len])) s++;
  759. }
  760. /* Insert string "src" at index "pos" of "dst". */
  761. void strinsert(src, dst, pos)
  762. register char *src, *dst;
  763. register int pos;
  764. {
  765. register int slen, dlen;
  766. if (--pos < 0)
  767. return;
  768. dlen = (int)strlen(dst);
  769. dst += dlen;
  770. dlen -= pos;
  771. if (dlen <= 0) {
  772. strcpy(dst, src);
  773. return;
  774. }
  775. slen = (int)strlen(src);
  776. do {
  777. dst[slen] = *dst;
  778. --dst;
  779. } while (--dlen >= 0);
  780. dst++;
  781. while (--slen >= 0)
  782. *dst++ = *src++;
  783. }
  784. /* File functions */
  785. /* Peek at next character of input stream; return EOF at end-of-file. */
  786. int P_peek(f)
  787. FILE *f;
  788. {
  789. int ch;
  790. ch = getc(f);
  791. if (ch == EOF)
  792. return EOF;
  793. ungetc(ch, f);
  794. return (ch == '\n') ? ' ' : ch;
  795. }
  796. /* Check if at end of file, using Pascal "eof" semantics. End-of-file for
  797. stdin is broken; remove the special case for it to be broken in a
  798. different way. */
  799. int P_eof(f)
  800. FILE *f;
  801. {
  802. register int ch;
  803. if (feof(f))
  804. return 1;
  805. #ifdef HAVE_ISATTY
  806. if (isatty(fileno(f)))
  807. #else
  808. if (f == stdin)
  809. #endif
  810. return 0; /* not safe to look-ahead on the keyboard! */
  811. ch = getc(f);
  812. if (ch == EOF)
  813. return 1;
  814. ungetc(ch, f);
  815. return 0;
  816. }
  817. /* Check if at end of line (or end of entire file). */
  818. int P_eoln(f)
  819. FILE *f;
  820. {
  821. register int ch;
  822. ch = getc(f);
  823. if (ch == EOF)
  824. return 1;
  825. ungetc(ch, f);
  826. return (ch == '\n');
  827. }
  828. /* Skip whitespace (including newlines) in a file. */
  829. FILE *_skipnlspaces(f)
  830. FILE *f;
  831. {
  832. register int ch;
  833. do {
  834. ch = getc(f);
  835. } while (ch == ' ' || ch == '\t' || ch == '\n');
  836. if (ch != EOF)
  837. ungetc(ch, f);
  838. return f;
  839. }
  840. /* Skip whitespace (not including newlines) in a file. */
  841. FILE *_skipspaces(f)
  842. FILE *f;
  843. {
  844. register int ch;
  845. do {
  846. ch = getc(f);
  847. } while (ch == ' ' || ch == '\t');
  848. if (ch != EOF)
  849. ungetc(ch, f);
  850. return f;
  851. }
  852. /* Read a packed array of characters from a file. */
  853. Void P_readpaoc(f, s, len)
  854. FILE *f;
  855. char *s;
  856. int len;
  857. {
  858. int ch;
  859. for (;;) {
  860. if (len <= 0)
  861. return;
  862. ch = getc(f);
  863. if (ch == EOF || ch == '\n')
  864. break;
  865. *s++ = ch;
  866. --len;
  867. }
  868. while (--len >= 0)
  869. *s++ = ' ';
  870. if (ch != EOF)
  871. ungetc(ch, f);
  872. }
  873. Void P_readlnpaoc(f, s, len)
  874. FILE *f;
  875. char *s;
  876. int len;
  877. {
  878. int ch;
  879. for (;;) {
  880. ch = getc(f);
  881. if (ch == EOF || ch == '\n')
  882. break;
  883. if (len > 0) {
  884. *s++ = ch;
  885. --len;
  886. }
  887. }
  888. while (--len >= 0)
  889. *s++ = ' ';
  890. }
  891. /* Compute maximum legal "seek" index in file (0-based). */
  892. long P_maxpos(f)
  893. FILE *f;
  894. {
  895. long savepos = ftell(f);
  896. long val;
  897. if (fseek(f, 0L, SEEK_END))
  898. return -1;
  899. val = ftell(f);
  900. if (fseek(f, savepos, SEEK_SET))
  901. return -1;
  902. return val;
  903. }
  904. /* Use packed array of char for a file name. */
  905. Char *P_trimname(fn, len)
  906. register Char *fn;
  907. register int len;
  908. {
  909. static Char fnbuf[256];
  910. register Char *cp = fnbuf;
  911. while (--len >= 0 && *fn && !isspace(*fn))
  912. *cp++ = *fn++;
  913. *cp = 0;
  914. return fnbuf;
  915. }
  916. /* Pascal's "memavail" doesn't make much sense in Unix with virtual memory.
  917. We fix memory size as 10Meg as a reasonable compromise. */
  918. long memavail()
  919. {
  920. return 10000000; /* worry about this later! */
  921. }
  922. long maxavail()
  923. {
  924. return memavail();
  925. }
  926. /* Sets are stored as an array of longs. S[0] is the size of the set;
  927. S[N] is the N'th 32-bit chunk of the set. S[0] equals the maximum
  928. I such that S[I] is nonzero. S[0] is zero for an empty set. Within
  929. each long, bits are packed from lsb to msb. The first bit of the
  930. set is the element with ordinal value 0. (Thus, for a "set of 5..99",
  931. the lowest five bits of the first long are unused and always zero.) */
  932. /* (Sets with 32 or fewer elements are normally stored as plain longs.) */
  933. long *P_setunion(d, s1, s2) /* d := s1 + s2 */
  934. register long *d, *s1, *s2;
  935. {
  936. long *dbase = d++;
  937. register int sz1 = *s1++, sz2 = *s2++;
  938. while (sz1 > 0 && sz2 > 0) {
  939. *d++ = *s1++ | *s2++;
  940. sz1--, sz2--;
  941. }
  942. while (--sz1 >= 0)
  943. *d++ = *s1++;
  944. while (--sz2 >= 0)
  945. *d++ = *s2++;
  946. *dbase = d - dbase - 1;
  947. return dbase;
  948. }
  949. long *P_setint(d, s1, s2) /* d := s1 * s2 */
  950. register long *d, *s1, *s2;
  951. {
  952. long *dbase = d++;
  953. register int sz1 = *s1++, sz2 = *s2++;
  954. while (--sz1 >= 0 && --sz2 >= 0)
  955. *d++ = *s1++ & *s2++;
  956. while (--d > dbase && !*d) ;
  957. *dbase = d - dbase;
  958. return dbase;
  959. }
  960. long *P_setdiff(d, s1, s2) /* d := s1 - s2 */
  961. register long *d, *s1, *s2;
  962. {
  963. long *dbase = d++;
  964. register int sz1 = *s1++, sz2 = *s2++;
  965. while (--sz1 >= 0 && --sz2 >= 0)
  966. *d++ = *s1++ & ~*s2++;
  967. if (sz1 >= 0) {
  968. while (sz1-- >= 0)
  969. *d++ = *s1++;
  970. }
  971. while (--d > dbase && !*d) ;
  972. *dbase = d - dbase;
  973. return dbase;
  974. }
  975. long *P_setxor(d, s1, s2) /* d := s1 / s2 */
  976. register long *d, *s1, *s2;
  977. {
  978. long *dbase = d++;
  979. register int sz1 = *s1++, sz2 = *s2++;
  980. while (sz1 > 0 && sz2 > 0) {
  981. *d++ = *s1++ ^ *s2++;
  982. sz1--, sz2--;
  983. }
  984. while (--sz1 >= 0)
  985. *d++ = *s1++;
  986. while (--sz2 >= 0)
  987. *d++ = *s2++;
  988. while (--d > dbase && !*d) ;
  989. *dbase = d - dbase;
  990. return dbase;
  991. }
  992. int P_inset(val, s) /* val IN s */
  993. register unsigned val;
  994. register long *s;
  995. {
  996. register int bit;
  997. bit = (int) (val % SETBITS);
  998. val /= SETBITS;
  999. if ((long)val < *s++ && ((1L<<bit) & s[val]))
  1000. return 1;
  1001. return 0;
  1002. }
  1003. long *P_addset(s, val) /* s := s + [val] */
  1004. register long *s;
  1005. register unsigned val;
  1006. {
  1007. register long *sbase = s;
  1008. register int bit, size;
  1009. bit = (int) (val % SETBITS);
  1010. val /= SETBITS;
  1011. size = (int)*s;
  1012. if (++val >(unsigned) size) {
  1013. s += size;
  1014. while (val > (unsigned)size)
  1015. *++s = 0, size++;
  1016. *sbase = size;
  1017. } else
  1018. s += val;
  1019. *s |= 1L<<bit;
  1020. return sbase;
  1021. }
  1022. long *P_addsetr(s, v1, v2) /* s := s + [v1..v2] */
  1023. register long *s;
  1024. register unsigned v1, v2;
  1025. {
  1026. register long *sbase = s;
  1027. register int b1, b2, size;
  1028. if ((int)v1 > (int)v2)
  1029. return sbase;
  1030. b1 = (int) (v1 % SETBITS);
  1031. v1 /= SETBITS;
  1032. b2 = (int) (v2 % SETBITS);
  1033. v2 /= SETBITS;
  1034. size = *s;
  1035. v1++;
  1036. if (++v2 > (unsigned)size) {
  1037. while (v2 > (unsigned)size)
  1038. s[++size] = 0;
  1039. s[v2] = 0;
  1040. *s = (long)v2;
  1041. }
  1042. s += v1;
  1043. if (v1 == v2) {
  1044. *s |= (~((-2L)<<(b2-b1))) << b1;
  1045. } else {
  1046. *s++ |= (-1L) << b1;
  1047. while (++v1 < v2)
  1048. *s++ = -1;
  1049. *s |= ~((-2L) << b2);
  1050. }
  1051. return sbase;
  1052. }
  1053. long *P_remset(s, val) /* s := s - [val] */
  1054. register long *s;
  1055. register unsigned val;
  1056. {
  1057. register int bit;
  1058. bit = (int) (val % SETBITS);
  1059. val /= SETBITS;
  1060. if ((long)++val <= *s) {
  1061. if (!(s[val] &= ~(1L<<bit)))
  1062. while (*s && !s[*s])
  1063. (*s)--;
  1064. }
  1065. return s;
  1066. }
  1067. int P_setequal(s1, s2) /* s1 = s2 */
  1068. register long *s1, *s2;
  1069. {
  1070. register int size = *s1++;
  1071. if (*s2++ != size)
  1072. return 0;
  1073. while (--size >= 0) {
  1074. if (*s1++ != *s2++)
  1075. return 0;
  1076. }
  1077. return 1;
  1078. }
  1079. int P_subset(s1, s2) /* s1 <= s2 */
  1080. register long *s1, *s2;
  1081. {
  1082. register int sz1 = *s1++, sz2 = *s2++;
  1083. if (sz1 > sz2)
  1084. return 0;
  1085. while (--sz1 >= 0) {
  1086. if (*s1++ & ~*s2++)
  1087. return 0;
  1088. }
  1089. return 1;
  1090. }
  1091. long *P_setcpy(d, s) /* d := s */
  1092. register long *d, *s;
  1093. {
  1094. register long *save_d = d;
  1095. #ifdef SETCPY_MEMCPY
  1096. memcpy(d, s, (*s + 1) * sizeof(long));
  1097. #else
  1098. register int i = *s + 1;
  1099. while (--i >= 0)
  1100. *d++ = *s++;
  1101. #endif
  1102. return save_d;
  1103. }
  1104. /* s is a "smallset", i.e., a 32-bit or less set stored
  1105. directly in a long. */
  1106. long *P_expset(d, s) /* d := s */
  1107. register long *d;
  1108. register long s;
  1109. {
  1110. if (s) {
  1111. d[1] = s;
  1112. *d = 1;
  1113. } else
  1114. *d = 0;
  1115. return d;
  1116. }
  1117. long P_packset(s) /* convert s to a small-set */
  1118. register long *s;
  1119. {
  1120. if (*s++)
  1121. return *s;
  1122. else
  1123. return 0;
  1124. }
  1125. int _OutMem()
  1126. {
  1127. return _Escape(-2);
  1128. }
  1129. int _CaseCheck()
  1130. {
  1131. return _Escape(-9);
  1132. }
  1133. int _NilCheck()
  1134. {
  1135. return _Escape(-3);
  1136. }
  1137. /* The following is suitable for the HP Pascal operating system.
  1138. It might want to be revised when emulating another system. */
  1139. char *_ShowEscape(buf, code, ior, prefix)
  1140. char *buf, *prefix;
  1141. int code, ior;
  1142. {
  1143. char *bufp;
  1144. if (prefix && *prefix) {
  1145. strcpy(buf, prefix);
  1146. strcat(buf, ": ");
  1147. bufp = buf + strlen(buf);
  1148. } else {
  1149. bufp = buf;
  1150. }
  1151. if (code == -10) {
  1152. snprintf(bufp,80, "Pascal system I/O error %d", ior);
  1153. switch (ior) {
  1154. case 3:
  1155. strcat(buf, " (illegal I/O request)");
  1156. break;
  1157. case 7:
  1158. strcat(buf, " (bad file name)");
  1159. break;
  1160. case FileNotFound: /*10*/
  1161. strcat(buf, " (file not found)");
  1162. break;
  1163. case FileNotOpen: /*13*/
  1164. strcat(buf, " (file not open)");
  1165. break;
  1166. case BadInputFormat: /*14*/
  1167. strcat(buf, " (bad input format)");
  1168. break;
  1169. case 24:
  1170. strcat(buf, " (not open for reading)");
  1171. break;
  1172. case 25:
  1173. strcat(buf, " (not open for writing)");
  1174. break;
  1175. case 26:
  1176. strcat(buf, " (not open for direct access)");
  1177. break;
  1178. case 28:
  1179. strcat(buf, " (string subscript out of range)");
  1180. break;
  1181. case EndOfFile: /*30*/
  1182. strcat(buf, " (end-of-file)");
  1183. break;
  1184. case FileWriteError: /*38*/
  1185. strcat(buf, " (file write error)");
  1186. break;
  1187. }
  1188. } else {
  1189. snprintf(bufp,80, "Pascal system error %d", code);
  1190. switch (code) {
  1191. case -2:
  1192. strcat(buf, " (out of memory)");
  1193. break;
  1194. case -3:
  1195. strcat(buf, " (reference to NIL pointer)");
  1196. break;
  1197. case -4:
  1198. strcat(buf, " (integer overflow)");
  1199. break;
  1200. case -5:
  1201. strcat(buf, " (divide by zero)");
  1202. break;
  1203. case -6:
  1204. strcat(buf, " (real math overflow)");
  1205. break;
  1206. case -8:
  1207. strcat(buf, " (value range error)");
  1208. break;
  1209. case -9:
  1210. strcat(buf, " (CASE value range error)");
  1211. break;
  1212. case -12:
  1213. strcat(buf, " (bus error)");
  1214. break;
  1215. case -20:
  1216. strcat(buf, " (stopped by user)");
  1217. break;
  1218. }
  1219. }
  1220. return buf;
  1221. }
  1222. int _Escape(code)
  1223. int code;
  1224. {
  1225. char buf[100];
  1226. P_escapecode = code;
  1227. if (__top_jb) {
  1228. __p2c_jmp_buf *jb = __top_jb;
  1229. __top_jb = jb->next;
  1230. longjmp(jb->jbuf, 1);
  1231. }
  1232. if (code == 0)
  1233. exit(EXIT_SUCCESS);
  1234. if (code == -1)
  1235. exit(EXIT_FAILURE);
  1236. fprintf(stderr, "%s\n", _ShowEscape(buf, P_escapecode, P_ioresult, ""));
  1237. exit(EXIT_FAILURE);
  1238. }
  1239. int _EscIO(code)
  1240. int code;
  1241. {
  1242. P_ioresult = code;
  1243. return _Escape(-10);
  1244. }
  1245. int _EscIO2(code, name)
  1246. int code;
  1247. char *name;
  1248. {
  1249. P_ioresult = code;
  1250. if (!__top_jb && name && *name) {
  1251. char buf[100];
  1252. fprintf(stderr, "%s: %s\n",
  1253. name, _ShowEscape(buf, P_escapecode, P_ioresult, ""));
  1254. exit(EXIT_FAILURE);
  1255. }
  1256. return _Escape(-10);
  1257. }
  1258. /* End. */
  1259. typedef struct TPoint {
  1260. long X, Y, C, H, N, O, P, S, Si, B, Br, Cl, F, I, Al, Ag, As,Au, Ba, Be, Bi, Ca, Cd,
  1261. Co, Cr, Cs, Cu, Fe, Ga, Ge, Hf, Hg, In, Ir, Li, Lu, Mg, Mn, Mo, Na, Nb, Ni, Os, K, Pb, Pd, Pt, Rb,
  1262. Re, Rh, Ru, Sb, Sc, Se, Sn, Sr, Ta, Te, Ti, Tl, V, W, Ytt, Zn, Zr, RecCount;
  1263. struct TPoint *Last;
  1264. } TPoint;
  1265. typedef struct TBond {
  1266. long X1, Y1, X2, Y2, RecCount;
  1267. struct TBond *Last;
  1268. } TBond;
  1269. Static long C, H, N, O, P, S, Si, B, Br, Cl, F, I, Al, Ag, As, Au, Ba, Be, Bi, Ca, Cd,
  1270. Co, Cr, Cs, Cu, Fe, Ga, Ge, Hf, Hg, In, Ir, Li, Lu, Mg, Mn, Mo, Na, Nb, Ni, Os, K, Pb,
  1271. Pd, Pt, Rb, Re, Rh, Ru, Sb, Sc, Se, Sn, Sr, Ta, Te, Ti, Tl, V, W, Ytt, Zn, Zr, X1, X2, Y1, Y2, T, D;
  1272. Static FILE *IFile;
  1273. Static TPoint *Point, *Last, *Current;
  1274. Static TBond *Bond, *LastB, *CurrentB;
  1275. Static Char sss[256], A[256], subs[256], Alert[256];
  1276. Static Char sssb[7];
  1277. Static double M, Me;
  1278. Static Char separator;
  1279. Static long Count, code, atoms, rep, range, bonds;
  1280. Static boolean Abandon, debug, verbose, fa, nobonds;
  1281. Static long Sensi = 5; /*bonds and labels joint precision sensitivity*/
  1282. Static Char IFile_NAME[_FNSIZE];
  1283. Static Void doBonds()
  1284. {
  1285. do {
  1286. (void)fgets(sss,256,IFile);
  1287. sscanf(sss, "%ld%ld%ld%ld%ld%ld%*[^\n]", &X1, &Y1, &X2, &Y2, &T, &D);
  1288. /*getc(IFile);*/
  1289. bonds--;
  1290. if (debug)
  1291. printf("%ld; %ld; %ld; %ld; %ld; %ld\n", X1, Y1, X2, Y2, T, D);
  1292. if (D == 1 || T == 8){
  1293. if (debug) printf("skipped\n");
  1294. continue;
  1295. }
  1296. if (debug) printf("parsed\n");
  1297. if (T == 11)
  1298. range = ((X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2)) * 4;
  1299. LastB = Bond;
  1300. Bond = (TBond *)malloc(sizeof(TBond));
  1301. if (Bond == NULL) {
  1302. fprintf(stderr,"Could not allocate memory\n");
  1303. exit(1);
  1304. }
  1305. Bond->X1 = X1;
  1306. Bond->X2 = X2;
  1307. Bond->Y1 = Y1;
  1308. Bond->Y2 = Y2;
  1309. Bond->Last = LastB;
  1310. CurrentB = Bond;
  1311. Bond = Bond->Last;
  1312. while (Bond->Last != NULL) {
  1313. if ((labs(Bond->X1 - X1) < Sensi && labs(Bond->Y1 - Y1) < Sensi &&
  1314. labs(Bond->X2 - X2) < Sensi && labs(Bond->Y2 - Y2) < Sensi) ||
  1315. (labs(Bond->X2 - X1) < Sensi && labs(Bond->Y2 - Y1) < Sensi &&
  1316. labs(Bond->X1 - X2) < Sensi && labs(Bond->Y1 - Y2) < Sensi)) {
  1317. if (debug)
  1318. printf(" ! Bond overlap\n");
  1319. strcat(Alert, "!");
  1320. }
  1321. Bond = Bond->Last;
  1322. }
  1323. Bond = CurrentB;
  1324. Abandon = false;
  1325. Current = Point;
  1326. while (Point->Last != NULL) {
  1327. if (T == 11) {
  1328. Abandon = true;
  1329. if ((Point->X - X1) * (Point->X - X1) +
  1330. (Point->Y - Y1) * (Point->Y - Y1) < range) {
  1331. if (Point->H > 0)
  1332. Point->H--;
  1333. if (debug)
  1334. printf("Ring --> stripped one H from %ld %ld\n",
  1335. Point->X, Point->Y);
  1336. }
  1337. } else {
  1338. if (labs(Point->X - X1) < Sensi && labs(Point->Y - Y1) < Sensi) {
  1339. if (debug)
  1340. printf(" %ld --> Joined at %ld %ld\n", Point->RecCount, X1, Y1);
  1341. if (T == 0 || T == 5 || T == 6 || T == 7 || T == 10 || T == 12 ||
  1342. T == 13)
  1343. Point->H--;
  1344. if (T == 1 || T == 2 || T == 4 || T == 14 || T == 15 )
  1345. Point->H -= 2;
  1346. if (T == 3)
  1347. Point->H -= 3;
  1348. if (Point->H < 0) {
  1349. if (debug) printf("Point^.X=%ld, Point^.Y=%ld has H count <0 !\n",Point->X,Point->Y);
  1350. Point->H = 0;
  1351. }
  1352. Abandon = true;
  1353. }
  1354. }
  1355. Point = Point->Last;
  1356. }
  1357. Point = Current;
  1358. if (!Abandon) {
  1359. Count++;
  1360. Last = Point;
  1361. Point = (TPoint *)malloc(sizeof(TPoint));
  1362. if (Point == NULL) {
  1363. fprintf(stderr,"Could not allocate memory\n");
  1364. exit(1);
  1365. }
  1366. Point->X = X1;
  1367. if (debug)
  1368. printf(" Point^.X=%ld", Point->X);
  1369. Point->Y = Y1;
  1370. if (debug)
  1371. printf(" Point^.Y=%ld", Point->Y);
  1372. if (T != 11 && T != 9)
  1373. Point->C = 1;
  1374. else
  1375. Point->C = 0;
  1376. if (debug)
  1377. printf(" Point^.C=%ld", Point->C);
  1378. if (T == 0 || T == 5 || T == 6 || T == 7 || T == 10 || T == 12 ||
  1379. T == 13)
  1380. Point->H = 3;
  1381. if (T == 1 || T == 2 || T == 4 || T == 14 || T == 15)
  1382. Point->H = 2;
  1383. if (T == 3)
  1384. Point->H = 1;
  1385. if (debug)
  1386. printf(" Point^.H=%ld", Point->H);
  1387. Point->N = 0;
  1388. Point->O = 0;
  1389. Point->P = 0;
  1390. Point->S = 0;
  1391. Point->Si = 0;
  1392. Point->B = 0;
  1393. Point->Br = 0;
  1394. Point->Cl = 0;
  1395. Point->F = 0;
  1396. Point->I = 0;
  1397. Point->Al = 0;
  1398. Point->Ag = 0;
  1399. Point->As = 0;
  1400. Point->Au = 0;
  1401. Point->Ba = 0;
  1402. Point->Be = 0;
  1403. Point->Bi = 0;
  1404. Point->Ca = 0;
  1405. Point->Cd = 0;
  1406. Point->Co = 0;
  1407. Point->Cr = 0;
  1408. Point->Cs = 0;
  1409. Point->Cu = 0;
  1410. Point->Fe = 0;
  1411. Point->Ga = 0;
  1412. Point->Ge = 0;
  1413. Point->Hf = 0;
  1414. Point->Hg = 0;
  1415. Point->In = 0;
  1416. Point->Ir = 0;
  1417. Point->Li = 0;
  1418. Point->Lu = 0;
  1419. Point->Na = 0;
  1420. Point->Nb = 0;
  1421. Point->Ni = 0;
  1422. Point->Os = 0;
  1423. Point->Mg = 0;
  1424. Point->Mn = 0;
  1425. Point->Mo = 0;
  1426. Point->K = 0;
  1427. Point->Pb = 0;
  1428. Point->Pd = 0;
  1429. Point->Pt = 0;
  1430. Point->Rb = 0;
  1431. Point->Re = 0;
  1432. Point->Rh = 0;
  1433. Point->Ru = 0;
  1434. Point->Sb = 0;
  1435. Point->Sc = 0;
  1436. Point->Se = 0;
  1437. Point->Sn = 0;
  1438. Point->Sr = 0;
  1439. Point->Ta = 0;
  1440. Point->Te = 0;
  1441. Point->Ti = 0;
  1442. Point->Tl = 0;
  1443. Point->V = 0;
  1444. Point->W = 0;
  1445. Point->Ytt = 0;
  1446. Point->Zn = 0;
  1447. Point->Zr = 0;
  1448. Point->RecCount = Count;
  1449. if (debug)
  1450. printf(" Point^.RecCount=%ld\n", Point->RecCount);
  1451. Point->Last = Last;
  1452. }
  1453. if (T != 11) {
  1454. Abandon = false;
  1455. Current = Point;
  1456. while (Point->Last != NULL) {
  1457. if (labs(Point->X - X2) < Sensi && labs(Point->Y - Y2) < Sensi) {
  1458. if (debug)
  1459. printf(" %ld --> Joined at %ld %ld\n", Point->RecCount, X2, Y2);
  1460. if (T == 0 || T == 5 || T == 6 || T == 7 || T == 10 || T == 12 ||
  1461. T == 13)
  1462. Point->H--;
  1463. if (T == 1 || T == 2 || T == 4 || T == 14 || T == 15)
  1464. Point->H -= 2;
  1465. if (T == 3)
  1466. Point->H -= 3;
  1467. if (Point->H < 0) {
  1468. if (debug) printf("Point^.X=%ld, Point^.Y=%ld has H count <0 !\n",Point->X,Point->Y);
  1469. Point->H = 0;
  1470. }
  1471. Abandon = true;
  1472. }
  1473. Point = Point->Last;
  1474. }
  1475. Point = Current;
  1476. if (!Abandon) {
  1477. Count++;
  1478. Last = Point;
  1479. Point = (TPoint *)malloc(sizeof(TPoint));
  1480. if (Point == NULL) {
  1481. fprintf(stderr,"Could not allocate memory\n");
  1482. exit(1);
  1483. }
  1484. Point->X = X2;
  1485. if (debug)
  1486. printf(" Point^.X=%ld", Point->X);
  1487. Point->Y = Y2;
  1488. if (debug)
  1489. printf(" Point^.Y=%ld", Point->Y);
  1490. if (T != 11 && T != 9)
  1491. Point->C = 1;
  1492. else
  1493. Point->C = 0;
  1494. if (debug)
  1495. printf(" Point^.C=%ld", Point->C);
  1496. if (T == 0 || T == 5 || T == 6 || T == 7 || T == 10 || T == 12 ||
  1497. T == 13)
  1498. Point->H = 3;
  1499. if (T == 1 || T == 2 || T == 4 || T == 14 || T == 15 )
  1500. Point->H = 2;
  1501. if (T == 3)
  1502. Point->H = 1;
  1503. if (debug)
  1504. printf(" Point^.H=%ld", Point->H);
  1505. Point->N = 0;
  1506. Point->O = 0;
  1507. Point->P = 0;
  1508. Point->S = 0;
  1509. Point->Si = 0;
  1510. Point->B = 0;
  1511. Point->Br = 0;
  1512. Point->Cl = 0;
  1513. Point->F = 0;
  1514. Point->I = 0;
  1515. Point->Al = 0;
  1516. Point->Ag = 0;
  1517. Point->As = 0;
  1518. Point->Au = 0;
  1519. Point->Ba = 0;
  1520. Point->Be = 0;
  1521. Point->Bi = 0;
  1522. Point->Ca = 0;
  1523. Point->Cd = 0;
  1524. Point->Co = 0;
  1525. Point->Cr = 0;
  1526. Point->Cs = 0;
  1527. Point->Cu = 0;
  1528. Point->Fe = 0;
  1529. Point->Ga = 0;
  1530. Point->Ge = 0;
  1531. Point->Hf = 0;
  1532. Point->Hg = 0;
  1533. Point->In = 0;
  1534. Point->Ir = 0;
  1535. Point->Li = 0;
  1536. Point->Lu = 0;
  1537. Point->Mg = 0;
  1538. Point->Mn = 0;
  1539. Point->Mo = 0;
  1540. Point->Na = 0;
  1541. Point->Nb = 0;
  1542. Point->Ni = 0;
  1543. Point->Os = 0;
  1544. Point->K = 0;
  1545. Point->Pb = 0;
  1546. Point->Pd = 0;
  1547. Point->Pt = 0;
  1548. Point->Rb = 0;
  1549. Point->Re = 0;
  1550. Point->Rh = 0;
  1551. Point->Ru = 0;
  1552. Point->Sb = 0;
  1553. Point->Sc = 0;
  1554. Point->Se = 0;
  1555. Point->Sn = 0;
  1556. Point->Sr = 0;
  1557. Point->Ta = 0;
  1558. Point->Te = 0;
  1559. Point->Ti = 0;
  1560. Point->Tl = 0;
  1561. Point->V = 0;
  1562. Point->W = 0;
  1563. Point->Ytt = 0;
  1564. Point->Zn = 0;
  1565. Point->Zr = 0;
  1566. Point->RecCount = Count;
  1567. if (debug)
  1568. printf(" Point^.RecCount=%ld\n", Point->RecCount);
  1569. Point->Last = Last;
  1570. }
  1571. }
  1572. } while (bonds != 0);
  1573. }
  1574. Static Void doLabels()
  1575. {
  1576. long mul, gmul, gmpos, ggmul, ggmpos;
  1577. boolean stripped;
  1578. Char STR2[256];
  1579. long FORLIM;
  1580. Char *TEMP;
  1581. if (debug)
  1582. printf("---- and now parse the labels ---------\n");
  1583. if (verbose)
  1584. printf("HeteroAtoms: %ld\n", atoms);
  1585. FORLIM = atoms;
  1586. for (rep = 1; rep <= FORLIM; rep++) {
  1587. fscanf(IFile, "%ld%ld%c", &X1, &Y1, &separator);
  1588. (void)fgets(sss, 256, IFile);
  1589. TEMP = strchr(sss, '\n');
  1590. if (TEMP != NULL)
  1591. *TEMP = 0;
  1592. snprintf(A,256, "%.*s", strpos2(sss, "\t", 1) - 1, sss);
  1593. if (debug)
  1594. printf("Atom %s X=%ld Y=%ld sss: %s\n", A, X1, Y1, sss);
  1595. if (nobonds)
  1596. { /*initialize the Point structure if no bonds, only labels, defined*/
  1597. Count++;
  1598. Last = Point;
  1599. Point = (TPoint *)malloc(sizeof(TPoint));
  1600. if (Point == NULL) {
  1601. fprintf(stderr,"Could not allocate memory\n");
  1602. exit(1);
  1603. }
  1604. Point->X = X1;
  1605. Point->Y = Y1;
  1606. Point->C = 0;
  1607. Point->H = 0;
  1608. Point->N = 0;
  1609. Point->O = 0;
  1610. Point->P = 0;
  1611. Point->S = 0;
  1612. Point->Si = 0;
  1613. Point->B = 0;
  1614. Point->Br = 0;
  1615. Point->Cl = 0;
  1616. Point->F = 0;
  1617. Point->I = 0;
  1618. Point->Al = 0;
  1619. Point->Ag = 0;
  1620. Point->As = 0;
  1621. Point->Au = 0;
  1622. Point->Ba = 0;
  1623. Point->Be = 0;
  1624. Point->Bi = 0;
  1625. Point->Ca = 0;
  1626. Point->Cd = 0;
  1627. Point->Co = 0;
  1628. Point->Cr = 0;
  1629. Point->Cs = 0;
  1630. Point->Cu = 0;
  1631. Point->Fe = 0;
  1632. Point->Ga = 0;
  1633. Point->Ge = 0;
  1634. Point->Hf = 0;
  1635. Point->Hg = 0;
  1636. Point->In = 0;
  1637. Point->Ir = 0;
  1638. Point->Li = 0;
  1639. Point->Lu = 0;
  1640. Point->Mg = 0;
  1641. Point->Mn = 0;
  1642. Point->Mo = 0;
  1643. Point->Na = 0;
  1644. Point->Nb = 0;
  1645. Point->Ni = 0;
  1646. Point->Os = 0;
  1647. Point->K = 0;
  1648. Point->Pb = 0;
  1649. Point->Pd = 0;
  1650. Point->Pt = 0;
  1651. Point->Rb = 0;
  1652. Point->Re = 0;
  1653. Point->Rh = 0;
  1654. Point->Ru = 0;
  1655. Point->Sb = 0;
  1656. Point->Sc = 0;
  1657. Point->Se = 0;
  1658. Point->Sn = 0;
  1659. Point->Sr = 0;
  1660. Point->Ta = 0;
  1661. Point->Te = 0;
  1662. Point->Ti = 0;
  1663. Point->Tl = 0;
  1664. Point->V = 0;
  1665. Point->W = 0;
  1666. Point->Ytt = 0;
  1667. Point->Zn = 0;
  1668. Point->Zr = 0;
  1669. Point->RecCount = Count;
  1670. Point->Last = Last;
  1671. }
  1672. Current = Point;
  1673. while (Point->Last != NULL) {
  1674. if (labs(Point->X - X1) < Sensi && labs(Point->Y - Y1) < Sensi) {
  1675. if (debug)
  1676. printf(" [%ld]\n", Point->RecCount);
  1677. Point->C = 0; /*we substitute -CH_x(-) by -R(-)*/
  1678. Point->H = 0;
  1679. Point->N = 0;
  1680. Point->O = 0;
  1681. Point->P = 0;
  1682. Point->S = 0;
  1683. Point->Si = 0;
  1684. Point->B = 0;
  1685. Point->Br = 0;
  1686. Point->Cl = 0;
  1687. Point->F = 0;
  1688. Point->I = 0;
  1689. Point->Al = 0;
  1690. Point->Ag = 0;
  1691. Point->As = 0;
  1692. Point->Au = 0;
  1693. Point->Ba = 0;
  1694. Point->Be = 0;
  1695. Point->Bi = 0;
  1696. Point->Ca = 0;
  1697. Point->Cd = 0;
  1698. Point->Co = 0;
  1699. Point->Cr = 0;
  1700. Point->Cs = 0;
  1701. Point->Cu = 0;
  1702. Point->Fe = 0;
  1703. Point->Ga = 0;
  1704. Point->Ge = 0;
  1705. Point->Hf = 0;
  1706. Point->Hg = 0;
  1707. Point->In = 0;
  1708. Point->Ir = 0;
  1709. Point->Li = 0;
  1710. Point->Lu = 0;
  1711. Point->Mg = 0;
  1712. Point->Mn = 0;
  1713. Point->Mo = 0;
  1714. Point->Na = 0;
  1715. Point->Nb = 0;
  1716. Point->Ni = 0;
  1717. Point->Os = 0;
  1718. Point->K = 0;
  1719. Point->Pb = 0;
  1720. Point->Pd = 0;
  1721. Point->Pt = 0;
  1722. Point->Rb = 0;
  1723. Point->Re = 0;
  1724. Point->Rh = 0;
  1725. Point->Ru = 0;
  1726. Point->Sb = 0;
  1727. Point->Sc = 0;
  1728. Point->Se = 0;
  1729. Point->Sn = 0;
  1730. Point->Sr = 0;
  1731. Point->Ta = 0;
  1732. Point->Te = 0;
  1733. Point->Ti = 0;
  1734. Point->Tl = 0;
  1735. Point->V = 0;
  1736. Point->W = 0;
  1737. Point->Ytt = 0;
  1738. Point->Zn = 0;
  1739. Point->Zr = 0;
  1740. mul = 1;
  1741. gmul = 1;
  1742. ggmul = 1;
  1743. while (*A != '\0') {
  1744. stripped = false;
  1745. if ((int)strlen(A) >= 5) {
  1746. snprintf(subs,256, "%.5s", A);
  1747. if ((int)strlen(A) > 6) {
  1748. if (A[5] == '_') {
  1749. if (A[6]!= '{') {
  1750. snprintf(STR2,256, "%c", A[6]);
  1751. if (A[7]=='_') snprintf(STR2,256, "%c%c", A[6],A[8]);
  1752. code = (sscanf(STR2, "%ld", &mul) == 0);
  1753. }else{
  1754. mul=7;
  1755. while(A[mul]!='}'){STR2[mul-7]=A[mul]; mul++ ; }
  1756. STR2[mul-6]='\0';
  1757. code = (sscanf(STR2, "%ld", &mul) == 0);
  1758. }
  1759. } else
  1760. mul = 1;
  1761. }
  1762. mul *= gmul * ggmul;
  1763. if (!strcmp(subs, "TBDMS")) { /*Tert-butyldimethylsilyl*/
  1764. if (debug)
  1765. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1766. Point->C += mul * 6;
  1767. Point->H += mul * 15;
  1768. Point->Si += mul;
  1769. strcpy(A, strsub(STR2, A, 6, (int)(strlen(A) - 5)));
  1770. stripped = true;
  1771. }
  1772. if (!strcmp(subs, "TBDPS")) { /*Tert-butyldiphenylsilyl*/
  1773. if (debug)
  1774. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1775. Point->C += mul * 16;
  1776. Point->H += mul * 19;
  1777. Point->Si += mul;
  1778. strcpy(A, strsub(STR2, A, 6, (int)(strlen(A) - 5)));
  1779. stripped = true;
  1780. }
  1781. if (A[0] == '[') {
  1782. ggmpos = strpos2(A, "]", 1);
  1783. if (ggmpos != 0) {
  1784. if (A[ggmpos] == '_') {
  1785. if (A[ggmpos+1]!= '{') {
  1786. snprintf(STR2,256, "%c", A[ggmpos+1]);
  1787. if (A[ggmpos+2]=='_') snprintf(STR2,256, "%c%c", A[ggmpos+1],A[ggmpos+3]);
  1788. code = (sscanf(STR2, "%ld", &ggmul) == 0);
  1789. }else{
  1790. ggmul=ggmpos+2;
  1791. while(A[ggmul]!='}'){STR2[ggmul-ggmpos-2]=A[ggmul]; ggmul++ ; }
  1792. STR2[ggmul-ggmpos-1]='\0';
  1793. code = (sscanf(STR2, "%ld", &ggmul) == 0);
  1794. }
  1795. } else
  1796. ggmul = 1;
  1797. }
  1798. }
  1799. if (A[0] == '(') {
  1800. gmpos = strpos2(A, ")", 1);
  1801. if (gmpos != 0) {
  1802. if (A[gmpos] == '_') {
  1803. if (A[gmpos+1]!= '{') {
  1804. snprintf(STR2,256, "%c", A[gmpos+1]);
  1805. if (A[gmpos+2]=='_') snprintf(STR2,256, "%c%c", A[gmpos+1],A[gmpos+3]);
  1806. code = (sscanf(STR2, "%ld", &gmul) == 0);
  1807. }else{
  1808. gmul=gmpos+2;
  1809. while(A[gmul]!='}'){STR2[gmul-gmpos-2]=A[gmul]; gmul++ ; }
  1810. STR2[gmul-gmpos-1]='\0';
  1811. code = (sscanf(STR2, "%ld", &gmul) == 0);
  1812. }
  1813. } else
  1814. gmul = 1;
  1815. }
  1816. }
  1817. }
  1818. if ((int)strlen(A) >= 4 && !stripped) {
  1819. snprintf(subs,256, "%.4s", A);
  1820. if ((int)strlen(A) > 5) {
  1821. if (A[4] == '_') {
  1822. if (A[5]!= '{') {
  1823. snprintf(STR2,256, "%c", A[5]);
  1824. if (A[6]=='_') snprintf(STR2,256, "%c%c", A[5],A[7]);
  1825. code = (sscanf(STR2, "%ld", &mul) == 0);
  1826. }else{
  1827. mul=6;
  1828. while(A[mul]!='}'){STR2[mul-6]=A[mul]; mul++ ; }
  1829. STR2[mul-5]='\0';
  1830. code = (sscanf(STR2, "%ld", &mul) == 0);
  1831. }
  1832. } else
  1833. mul = 1;
  1834. }
  1835. mul *= gmul * ggmul;
  1836. if (!strcmp(subs, "DBAM"))
  1837. { /*dibutylaminomethylene; =R, used as the N prot.*/
  1838. if (debug)
  1839. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1840. Point->C += mul * 9;
  1841. Point->H += mul * 19;
  1842. Point->N += mul;
  1843. strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
  1844. stripped = true;
  1845. }
  1846. if (!strcmp(subs, "DMAM"))
  1847. { /*dimethylaminomethylene; =R, used as the N prot.*/
  1848. if (debug)
  1849. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1850. Point->C += mul * 3;
  1851. Point->H += mul * 7;
  1852. Point->N += mul;
  1853. strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
  1854. stripped = true;
  1855. }
  1856. if (!strcmp(subs, "DMTr")) { /*dimethoxytrityl*/
  1857. if (debug)
  1858. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1859. Point->C += mul * 21;
  1860. Point->H += mul * 19;
  1861. Point->O += mul * 2;
  1862. strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
  1863. stripped = true;
  1864. }
  1865. if (!strcmp(subs, "MMTr")) { /*monomethoxytrityl*/
  1866. if (debug)
  1867. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1868. Point->C += mul * 20;
  1869. Point->H += mul * 16;
  1870. Point->O += mul;
  1871. strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
  1872. stripped = true;
  1873. }
  1874. if (!strcmp(subs, "TMTr")) { /*trimethoxytrityl*/
  1875. if (debug)
  1876. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1877. Point->C += mul * 22;
  1878. Point->H += mul * 22;
  1879. Point->O += mul * 3;
  1880. strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
  1881. stripped = true;
  1882. }
  1883. }
  1884. if ((int)strlen(A) >= 3 && !stripped) {
  1885. snprintf(subs,256, "%.3s", A);
  1886. if ((int)strlen(A) > 4) {
  1887. if (A[3] == '_') {
  1888. if (A[4]!= '{') {
  1889. snprintf(STR2,256, "%c", A[4]);
  1890. if (A[5]=='_') snprintf(STR2,256, "%c%c", A[4],A[6]);
  1891. code = (sscanf(STR2, "%ld", &mul) == 0);
  1892. }else{
  1893. mul=5;
  1894. while(A[mul]!='}'){STR2[mul-5]=A[mul]; mul++ ; }
  1895. STR2[mul-4]='\0';
  1896. code = (sscanf(STR2, "%ld", &mul) == 0);
  1897. }
  1898. } else
  1899. mul = 1;
  1900. }
  1901. mul *= gmul * ggmul;
  1902. if (!strcmp(subs, "Ade")) { /*Adeninyl*/
  1903. if (debug)
  1904. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1905. Point->C += mul * 5;
  1906. Point->H += mul * 4;
  1907. Point->N += mul * 5;
  1908. strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
  1909. stripped = true;
  1910. }
  1911. if (!strcmp(subs, "BOC")) { /*Butyloxycarbonyl*/
  1912. if (debug)
  1913. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1914. Point->C += mul * 5;
  1915. Point->H += mul * 9;
  1916. Point->O += mul * 2;
  1917. strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
  1918. stripped = true;
  1919. }
  1920. if (!strcmp(subs, "Cyt")) { /*Cytosinyl*/
  1921. if (debug)
  1922. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1923. Point->C += mul * 4;
  1924. Point->H += mul * 4;
  1925. Point->N += mul * 3;
  1926. Point->O += mul;
  1927. strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
  1928. stripped = true;
  1929. }
  1930. if (!strcmp(subs, "Gua")) { /*Guaninyl*/
  1931. if (debug)
  1932. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1933. Point->C += mul * 5;
  1934. Point->H += mul * 4;
  1935. Point->N += mul * 5;
  1936. Point->O += mul;
  1937. strcpy(A, strsub(STR2, A, 4, (int)(st

Large files files are truncated, but you can click here to view the full file