PageRenderTime 58ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

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

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

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