PageRenderTime 61ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

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

#
C | 2702 lines | 2287 code | 338 blank | 77 comment | 634 complexity | 2b7d03e71db41155f3b3fd247882f8f1 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. #ifndef P2C_H
  4. #define P2C_H
  5. /* Header file for code generated by "p2c", the Pascal-to-C translator */
  6. /* "p2c" Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation.
  7. * By Dave Gillespie, daveg@synaptics.com. Version 1.21alpha-07.Dec.93.
  8. * This file may be copied, modified, etc. in any way. It is not restricted
  9. * by the licence agreement accompanying p2c itself.
  10. */
  11. #include <stdio.h>
  12. #define DOUBLE double
  13. /* If the following heuristic fails, compile -DBSD=0 for non-BSD systems,
  14. or -DBSD=1 for BSD systems. */
  15. #ifdef M_XENIX
  16. # define BSD 0
  17. #endif
  18. #ifdef vms
  19. # define BSD 0
  20. # ifndef __STDC__
  21. # define __STDC__ 1
  22. # endif
  23. #endif
  24. #ifdef __TURBOC__
  25. # define MSDOS 1
  26. #endif
  27. #ifdef MSDOS
  28. # define BSD 0
  29. #endif
  30. #ifdef FILE /* a #define in BSD, a typedef in SYSV (hp-ux, at least) */
  31. # ifndef BSD /* (a convenient, but horrible kludge!) */
  32. # define BSD 1
  33. # endif
  34. #endif
  35. #ifdef BSD
  36. # if !BSD
  37. # undef BSD
  38. # endif
  39. #endif
  40. #if (defined(__STDC__) && !defined(M_XENIX)) || defined(__TURBOC__)
  41. # include <stdlib.h>
  42. # include <stddef.h>
  43. # define HAS_STDLIB
  44. # if defined(vms) || defined(__TURBOC__)
  45. # define NON_ANSI_CAT
  46. # endif
  47. #else
  48. # ifndef BSD
  49. # ifndef __TURBOC__
  50. # include <memory.h>
  51. # endif
  52. # endif
  53. # ifdef hpux
  54. # ifdef _INCLUDE__STDC__
  55. # include <stddef.h>
  56. # include <stdlib.h>
  57. # define HAS_STDLIB
  58. # endif
  59. # endif
  60. # include <sys/types.h>
  61. # if !defined(MSDOS) || defined(__TURBOC__)
  62. # define NON_ANSI_CAT
  63. # endif
  64. #endif
  65. #if defined(NON_ANSI_CAT) && !defined(ANSI_CAT)
  66. # ifdef NON_ANSI_CAT_ALTERNATE
  67. # define __CAT__(a,b)a/**/b
  68. # else
  69. # define __ID__(a)a
  70. # define __CAT__(a,b)__ID__(a)b
  71. # endif
  72. #else
  73. # define __CAT__(a,b)a##b
  74. #endif
  75. #ifdef BSD
  76. # include <strings.h>
  77. # define memcpy(a,b,n) (bcopy(b,a,n),a)
  78. # define memcmp(a,b,n) bcmp(a,b,n)
  79. # define strchr(s,c) index(s,c)
  80. # define strrchr(s,c) rindex(s,c)
  81. #else
  82. # include <string.h>
  83. #endif
  84. #include <ctype.h>
  85. #include <math.h>
  86. #include <setjmp.h>
  87. #include <assert.h>
  88. #ifndef NO_LACK
  89. #ifdef vms
  90. #define LACK_LABS
  91. #define LACK_MEMMOVE
  92. #define LACK_MEMCPY
  93. #else
  94. #define LACK_LABS /* Undefine these if your library has these */
  95. #define LACK_MEMMOVE
  96. #endif
  97. #endif
  98. typedef struct __p2c_jmp_buf {
  99. struct __p2c_jmp_buf *next;
  100. jmp_buf jbuf;
  101. } __p2c_jmp_buf;
  102. /* Warning: The following will not work if setjmp is used simultaneously.
  103. This also violates the ANSI restriction about using vars after longjmp,
  104. but a typical implementation of longjmp will get it right anyway. */
  105. #ifndef FAKE_TRY
  106. # define TRY(x) do { __p2c_jmp_buf __try_jb; \
  107. __try_jb.next = __top_jb; \
  108. if (!setjmp((__top_jb = &__try_jb)->jbuf)) {
  109. # define RECOVER(x) __top_jb = __try_jb.next; } else {
  110. # define RECOVER2(x,L) __top_jb = __try_jb.next; } else { \
  111. if (0) { L: __top_jb = __try_jb.next; }
  112. # define ENDTRY(x) } } while (0)
  113. #else
  114. # define TRY(x) if (1) {
  115. # define RECOVER(x) } else do {
  116. # define RECOVER2(x,L) } else do { L: ;
  117. # define ENDTRY(x) } while (0)
  118. #endif
  119. #ifdef M_XENIX /* avoid compiler bug */
  120. # define SHORT_MAX (32767)
  121. # define SHORT_MIN (-32768)
  122. #endif
  123. /* The following definitions work only on twos-complement machines */
  124. #ifndef SHORT_MAX
  125. # define SHORT_MAX ((short)(((unsigned short) -1) >> 1))
  126. # define SHORT_MIN (~SHORT_MAX)
  127. #endif
  128. #ifndef INT_MAX
  129. # define INT_MAX ((int)(((unsigned int) -1) >> 1))
  130. # define INT_MIN (~INT_MAX)
  131. #endif
  132. #ifndef LONG_MAX
  133. # define LONG_MAX ((long)(((unsigned long) -1) >> 1))
  134. # define LONG_MIN (~LONG_MAX)
  135. #endif
  136. #ifndef SEEK_SET
  137. # define SEEK_SET 0
  138. # define SEEK_CUR 1
  139. # define SEEK_END 2
  140. #endif
  141. #ifndef EXIT_SUCCESS
  142. # ifdef vms
  143. # define EXIT_SUCCESS 1
  144. # define EXIT_FAILURE (02000000000L)
  145. # else
  146. # define EXIT_SUCCESS 0
  147. # define EXIT_FAILURE 1
  148. # endif
  149. #endif
  150. #define SETBITS 32
  151. #if defined(__STDC__) || defined(__TURBOC__)
  152. # if !defined(vms) && !defined(M_LINT)
  153. # define Signed signed
  154. # else
  155. # define Signed
  156. # endif
  157. # define Void void /* Void f() = procedure */
  158. # ifndef Const
  159. # define Const const
  160. # endif
  161. # ifndef Volatile
  162. # define Volatile volatile
  163. # endif
  164. # ifdef M_LINT
  165. # define PP(x) ()
  166. # define PV() ()
  167. typedef char *Anyptr;
  168. # else
  169. # define PP(x) x /* function prototype */
  170. # define PV() (void) /* null function prototype */
  171. typedef void *Anyptr;
  172. # endif
  173. #else
  174. # define Signed
  175. # define Void void
  176. # ifndef Const
  177. # define Const
  178. # endif
  179. # ifndef Volatile
  180. # define Volatile
  181. # endif
  182. # define PP(x) ()
  183. # define PV() ()
  184. typedef char *Anyptr;
  185. #endif
  186. #ifdef __GNUC__
  187. # define Inline inline
  188. #else
  189. # define Inline
  190. #endif
  191. #define Register register /* Register variables */
  192. #define Char char /* Characters (not bytes) */
  193. #ifndef Static
  194. # define Static static /* Private global funcs and vars */
  195. #endif
  196. #ifndef Local
  197. # define Local static /* Nested functions */
  198. #endif
  199. typedef Signed char schar;
  200. typedef unsigned char uchar;
  201. typedef unsigned char boolean;
  202. #ifndef NO_DECLARE_ALFA
  203. typedef Char alfa[10];
  204. #endif
  205. #ifndef true
  206. # define true 1
  207. # define false 0
  208. #endif
  209. #ifndef TRUE
  210. # define TRUE 1
  211. # define FALSE 0
  212. #endif
  213. typedef struct {
  214. Anyptr proc, link;
  215. } _PROCEDURE;
  216. #ifndef _FNSIZE
  217. # define _FNSIZE 120
  218. #endif
  219. extern Void PASCAL_MAIN PP( (int, Char **) );
  220. extern Char **P_argv;
  221. extern int P_argc;
  222. extern short P_escapecode;
  223. extern int P_ioresult;
  224. extern __p2c_jmp_buf *__top_jb;
  225. #ifdef P2C_H_PROTO /* if you have Ansi C but non-prototyped header files */
  226. extern Char *strcat PP( (Char *, Const Char *) );
  227. extern Char *strchr PP( (Const Char *, int) );
  228. extern int strcmp PP( (Const Char *, Const Char *) );
  229. extern Char *strcpy PP( (Char *, Const Char *) );
  230. extern size_t strlen PP( (Const Char *) );
  231. extern Char *strncat PP( (Char *, Const Char *, size_t) );
  232. extern int strncmp PP( (Const Char *, Const Char *, size_t) );
  233. extern Char *strncpy PP( (Char *, Const Char *, size_t) );
  234. extern Char *strrchr PP( (Const Char *, int) );
  235. extern Anyptr memchr PP( (Const Anyptr, int, size_t) );
  236. extern Anyptr memmove PP( (Anyptr, Const Anyptr, size_t) );
  237. extern Anyptr memset PP( (Anyptr, int, size_t) );
  238. #ifndef memcpy
  239. extern Anyptr memcpy PP( (Anyptr, Const Anyptr, size_t) );
  240. extern int memcmp PP( (Const Anyptr, Const Anyptr, size_t) );
  241. #endif
  242. extern int atoi PP( (Const Char *) );
  243. extern double atof PP( (Const Char *) );
  244. extern long atol PP( (Const Char *) );
  245. extern double strtod PP( (Const Char *, Char **) );
  246. extern long strtol PP( (Const Char *, Char **, int) );
  247. #endif /*P2C_H_PROTO*/
  248. #ifndef HAS_STDLIB
  249. #ifndef NO_DECLARE_MALLOC
  250. extern Anyptr malloc PP( (size_t) );
  251. extern Void free PP( (Anyptr) );
  252. #endif
  253. #endif
  254. extern int _OutMem PV();
  255. extern int _CaseCheck PV();
  256. extern int _NilCheck PV();
  257. extern int _Escape PP( (int) );
  258. extern int _EscIO PP( (int) );
  259. extern int _EscIO2 PP( (int, Char *) );
  260. extern long ipow PP( (long, long) );
  261. extern long P_imax PP( (long, long) );
  262. extern long P_imin PP( (long, long) );
  263. extern double P_rmax PP( (double, double) );
  264. extern double P_rmin PP( (double, double) );
  265. extern Char *strsub PP( (Char *, Char *, int, int) );
  266. extern Char *strltrim PP( (Char *) );
  267. extern Char *strrtrim PP( (Char *) );
  268. extern Char *strrpt PP( (Char *, Char *, int) );
  269. extern Char *strpad PP( (Char *, Char *, int, int) );
  270. extern int strpos2 PP( (Char *, Char *, int) );
  271. extern long memavail PV();
  272. extern int P_peek PP( (FILE *) );
  273. extern int P_eof PP( (FILE *) );
  274. extern int P_eoln PP( (FILE *) );
  275. extern Void P_readpaoc PP( (FILE *, Char *, int) );
  276. extern Void P_readlnpaoc PP( (FILE *, Char *, int) );
  277. extern long P_maxpos PP( (FILE *) );
  278. extern Char *P_trimname PP( (Char *, int) );
  279. extern long *P_setunion PP( (long *, long *, long *) );
  280. extern long *P_setint PP( (long *, long *, long *) );
  281. extern long *P_setdiff PP( (long *, long *, long *) );
  282. extern long *P_setxor PP( (long *, long *, long *) );
  283. extern int P_inset PP( (unsigned, long *) );
  284. extern int P_setequal PP( (long *, long *) );
  285. extern int P_subset PP( (long *, long *) );
  286. extern long *P_addset PP( (long *, unsigned) );
  287. extern long *P_addsetr PP( (long *, unsigned, unsigned) );
  288. extern long *P_remset PP( (long *, unsigned) );
  289. extern long *P_setcpy PP( (long *, long *) );
  290. extern long *P_expset PP( (long *, long) );
  291. extern long P_packset PP( (long *) );
  292. extern int P_getcmdline PP( (int, int, Char *) );
  293. extern Void TimeStamp PP( (int *, int *, int *,
  294. int *, int *, int *) );
  295. extern Void P_sun_argv PP( (char *, int, int) );
  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 >= n) {
  479. #if defined(bcopy) && defined(memcpy)
  480. my_memcpy(dd, ss, n);
  481. #else
  482. memcpy(dd, ss, 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 = strlen(s) - pos;
  641. cp = s + pos;
  642. if (!(ch = *pat++))
  643. return 0;
  644. pos = strlen(pat);
  645. slen -= pos;
  646. while (--slen >= 0) {
  647. if (*cp++ == ch && !strncmp(cp, pat, 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 = toupper(s1[-1]);
  662. c2 = 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 = 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 = strlen(dst);
  769. dst += dlen;
  770. dlen -= pos;
  771. if (dlen <= 0) {
  772. strcpy(dst, src);
  773. return;
  774. }
  775. slen = 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 = val % SETBITS;
  998. val /= SETBITS;
  999. if (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 = val % SETBITS;
  1010. val /= SETBITS;
  1011. size = *s;
  1012. if (++val > size) {
  1013. s += size;
  1014. while (val > 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 = v1 % SETBITS;
  1031. v1 /= SETBITS;
  1032. b2 = v2 % SETBITS;
  1033. v2 /= SETBITS;
  1034. size = *s;
  1035. v1++;
  1036. if (++v2 > size) {
  1037. while (v2 > size)
  1038. s[++size] = 0;
  1039. s[v2] = 0;
  1040. *s = 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 = val % SETBITS;
  1059. val /= SETBITS;
  1060. if (++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. /* Oregon Software Pascal extensions, courtesy of William Bader */
  1126. int P_getcmdline(l, h, line)
  1127. int l, h;
  1128. Char *line;
  1129. {
  1130. int i, len;
  1131. char *s;
  1132. h = h - l + 1;
  1133. len = 0;
  1134. for(i = 1; i < P_argc; i++) {
  1135. s = P_argv[i];
  1136. while (*s) {
  1137. if (len >= h) return len;
  1138. line[len++] = *s++;
  1139. }
  1140. if (len >= h) return len;
  1141. line[len++] = ' ';
  1142. }
  1143. return len;
  1144. }
  1145. Void TimeStamp(Day, Month, Year, Hour, Min, Sec)
  1146. int *Day, *Month, *Year, *Hour, *Min, *Sec;
  1147. {
  1148. #ifndef NO_TIME
  1149. struct tm *tm;
  1150. long clock;
  1151. time(&clock);
  1152. tm = localtime(&clock);
  1153. *Day = tm->tm_mday;
  1154. *Month = tm->tm_mon + 1; /* Jan = 0 */
  1155. *Year = tm->tm_year;
  1156. if (*Year < 1900)
  1157. *Year += 1900; /* year since 1900 */
  1158. *Hour = tm->tm_hour;
  1159. *Min = tm->tm_min;
  1160. *Sec = tm->tm_sec;
  1161. #endif
  1162. }
  1163. Void VAXdate(s)
  1164. char *s;
  1165. {
  1166. long clock;
  1167. char *c;
  1168. int i;
  1169. static int where[] = {8, 9, 0, 4, 5, 6, 0, 20, 21, 22, 23};
  1170. time(&clock);
  1171. c = ctime(&clock);
  1172. for (i = 0; i < 11; i++)
  1173. s[i] = my_toupper(c[where[i]]);
  1174. s[2] = '-';
  1175. s[6] = '-';
  1176. }
  1177. Void VAXtime(s)
  1178. char *s;
  1179. {
  1180. long clock;
  1181. char *c;
  1182. int i;
  1183. time(&clock);
  1184. c = ctime(&clock);
  1185. for (i = 0; i < 8; i++)
  1186. s[i] = c[i+11];
  1187. s[8] = '.';
  1188. s[9] = '0';
  1189. s[10] = '0';
  1190. }
  1191. /* SUN Berkeley Pascal extensions */
  1192. Void P_sun_argv(s, len, n)
  1193. register char *s;
  1194. register int len, n;
  1195. {
  1196. register char *cp;
  1197. if ((unsigned)n < P_argc)
  1198. cp = P_argv[n];
  1199. else
  1200. cp = "";
  1201. while (*cp && --len >= 0)
  1202. *s++ = *cp++;
  1203. while (--len >= 0)
  1204. *s++ = ' ';
  1205. }
  1206. int _OutMem()
  1207. {
  1208. return _Escape(-2);
  1209. }
  1210. int _CaseCheck()
  1211. {
  1212. return _Escape(-9);
  1213. }
  1214. int _NilCheck()
  1215. {
  1216. return _Escape(-3);
  1217. }
  1218. /* The following is suitable for the HP Pascal operating system.
  1219. It might want to be revised when emulating another system. */
  1220. char *_ShowEscape(buf, code, ior, prefix)
  1221. char *buf, *prefix;
  1222. int code, ior;
  1223. {
  1224. char *bufp;
  1225. if (prefix && *prefix) {
  1226. strcpy(buf, prefix);
  1227. strcat(buf, ": ");
  1228. bufp = buf + strlen(buf);
  1229. } else {
  1230. bufp = buf;
  1231. }
  1232. if (code == -10) {
  1233. sprintf(bufp, "Pascal system I/O error %d", ior);
  1234. switch (ior) {
  1235. case 3:
  1236. strcat(buf, " (illegal I/O request)");
  1237. break;
  1238. case 7:
  1239. strcat(buf, " (bad file name)");
  1240. break;
  1241. case FileNotFound: /*10*/
  1242. strcat(buf, " (file not found)");
  1243. break;
  1244. case FileNotOpen: /*13*/
  1245. strcat(buf, " (file not open)");
  1246. break;
  1247. case BadInputFormat: /*14*/
  1248. strcat(buf, " (bad input format)");
  1249. break;
  1250. case 24:
  1251. strcat(buf, " (not open for reading)");
  1252. break;
  1253. case 25:
  1254. strcat(buf, " (not open for writing)");
  1255. break;
  1256. case 26:
  1257. strcat(buf, " (not open for direct access)");
  1258. break;
  1259. case 28:
  1260. strcat(buf, " (string subscript out of range)");
  1261. break;
  1262. case EndOfFile: /*30*/
  1263. strcat(buf, " (end-of-file)");
  1264. break;
  1265. case FileWriteError: /*38*/
  1266. strcat(buf, " (file write error)");
  1267. break;
  1268. }
  1269. } else {
  1270. sprintf(bufp, "Pascal system error %d", code);
  1271. switch (code) {
  1272. case -2:
  1273. strcat(buf, " (out of memory)");
  1274. break;
  1275. case -3:
  1276. strcat(buf, " (reference to NIL pointer)");
  1277. break;
  1278. case -4:
  1279. strcat(buf, " (integer overflow)");
  1280. break;
  1281. case -5:
  1282. strcat(buf, " (divide by zero)");
  1283. break;
  1284. case -6:
  1285. strcat(buf, " (real math overflow)");
  1286. break;
  1287. case -8:
  1288. strcat(buf, " (value range error)");
  1289. break;
  1290. case -9:
  1291. strcat(buf, " (CASE value range error)");
  1292. break;
  1293. case -12:
  1294. strcat(buf, " (bus error)");
  1295. break;
  1296. case -20:
  1297. strcat(buf, " (stopped by user)");
  1298. break;
  1299. }
  1300. }
  1301. return buf;
  1302. }
  1303. int _Escape(code)
  1304. int code;
  1305. {
  1306. char buf[100];
  1307. P_escapecode = code;
  1308. if (__top_jb) {
  1309. __p2c_jmp_buf *jb = __top_jb;
  1310. __top_jb = jb->next;
  1311. longjmp(jb->jbuf, 1);
  1312. }
  1313. if (code == 0)
  1314. exit(EXIT_SUCCESS);
  1315. if (code == -1)
  1316. exit(EXIT_FAILURE);
  1317. fprintf(stderr, "%s\n", _ShowEscape(buf, P_escapecode, P_ioresult, ""));
  1318. exit(EXIT_FAILURE);
  1319. }
  1320. int _EscIO(code)
  1321. int code;
  1322. {
  1323. P_ioresult = code;
  1324. return _Escape(-10);
  1325. }
  1326. int _EscIO2(code, name)
  1327. int code;
  1328. char *name;
  1329. {
  1330. P_ioresult = code;
  1331. if (!__top_jb && name && *name) {
  1332. char buf[100];
  1333. fprintf(stderr, "%s: %s\n",
  1334. name, _ShowEscape(buf, P_escapecode, P_ioresult, ""));
  1335. exit(EXIT_FAILURE);
  1336. }
  1337. return _Escape(-10);
  1338. }
  1339. /* End. */
  1340. typedef struct TPoint {
  1341. long X, Y, C, H, N, O, P, S, Si, B, Br, Cl, F, I, Mg, Na, K, RecCount;
  1342. struct TPoint *Last;
  1343. } TPoint;
  1344. typedef struct TBond {
  1345. long X1, Y1, X2, Y2, RecCount;
  1346. struct TBond *Last;
  1347. } TBond;
  1348. Static long C, H, N, O, P, S, Si, B, Br, Cl, F, I, Mg, Na, K, X1, X2, Y1, Y2,
  1349. T;
  1350. Static FILE *IFile;
  1351. Static TPoint *Point, *Last, *Current;
  1352. Static TBond *Bond, *LastB, *CurrentB;
  1353. Static Char sss[256], A[256], subs[256], Alert[256];
  1354. Static Char sssb[7];
  1355. Static double M, Me;
  1356. Static Char separator;
  1357. Static long Count, code, atoms, rep, range, bonds;
  1358. Static boolean Abandon, debug, verbose, fa, nobonds;
  1359. Static long Sensi = 5; /*bonds and labels joint precision sensitivity*/
  1360. Static Char IFile_NAME[_FNSIZE];
  1361. Static Void doBonds()
  1362. {
  1363. do {
  1364. fscanf(IFile, "%ld%ld%ld%ld%ld%*[^\n]", &X1, &Y1, &X2, &Y2, &T);
  1365. getc(IFile);
  1366. bonds--;
  1367. if (debug)
  1368. printf("%ld; %ld; %ld; %ld; %ld\n", X1, Y1, X2, Y2, T);
  1369. if (T == 11)
  1370. range = ((X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2)) * 4;
  1371. LastB = Bond;
  1372. Bond = (TBond *)Malloc(sizeof(TBond));
  1373. Bond->X1 = X1;
  1374. Bond->X2 = X2;
  1375. Bond->Y1 = Y1;
  1376. Bond->Y2 = Y2;
  1377. Bond->Last = LastB;
  1378. CurrentB = Bond;
  1379. Bond = Bond->Last;
  1380. while (Bond->Last != NULL) {
  1381. if ((labs(Bond->X1 - X1) < Sensi && labs(Bond->Y1 - Y1) < Sensi &&
  1382. labs(Bond->X2 - X2) < Sensi && labs(Bond->Y2 - Y2) < Sensi) ||
  1383. (labs(Bond->X2 - X1) < Sensi && labs(Bond->Y2 - Y1) < Sensi &&
  1384. labs(Bond->X1 - X2) < Sensi && labs(Bond->Y1 - Y2) < Sensi)) {
  1385. if (debug)
  1386. printf(" ! Bond overlap\n");
  1387. strcat(Alert, "!");
  1388. }
  1389. Bond = Bond->Last;
  1390. }
  1391. Bond = CurrentB;
  1392. Abandon = false;
  1393. Current = Point;
  1394. while (Point->Last != NULL) {
  1395. if (T == 11) {
  1396. Abandon = true;
  1397. if ((Point->X - X1) * (Point->X - X1) +
  1398. (Point->Y - Y1) * (Point->Y - Y1) < range) {
  1399. if (Point->H > 0)
  1400. Point->H--;
  1401. if (debug)
  1402. printf("Ring --> stripped one H from %ld %ld\n",
  1403. Point->X, Point->Y);
  1404. }
  1405. } else {
  1406. if (labs(Point->X - X1) < Sensi && labs(Point->Y - Y1) < Sensi) {
  1407. if (debug)
  1408. printf(" %ld --> Joined at %ld %ld\n", Point->RecCount, X1, Y1);
  1409. if (T == 0 || T == 5 || T == 6 || T == 7 || T == 10 || T == 12 ||
  1410. T == 13)
  1411. Point->H--;
  1412. if (T == 1 || T == 2 || T == 4 || T == 14 || T == 15 )
  1413. Point->H -= 2;
  1414. if (T == 3)
  1415. Point->H -= 3;
  1416. if (Point->H < 0) {
  1417. if (debug) printf("Point^.X=%ld, Point^.Y=%ld has H count <0 !\n",Point->X,Point->Y);
  1418. Point->H = 0;
  1419. }
  1420. Abandon = true;
  1421. }
  1422. }
  1423. Point = Point->Last;
  1424. }
  1425. Point = Current;
  1426. if (!Abandon) {
  1427. Count++;
  1428. Last = Point;
  1429. Point = (TPoint *)Malloc(sizeof(TPoint));
  1430. Point->X = X1;
  1431. if (debug)
  1432. printf(" Point^.X=%ld", Point->X);
  1433. Point->Y = Y1;
  1434. if (debug)
  1435. printf(" Point^.Y=%ld", Point->Y);
  1436. if (T != 11)
  1437. Point->C = 1;
  1438. else
  1439. Point->C = 0;
  1440. if (debug)
  1441. printf(" Point^.C=%ld", Point->C);
  1442. if (T == 0 || T == 5 || T == 6 || T == 7 || T == 10 || T == 12 ||
  1443. T == 13)
  1444. Point->H = 3;
  1445. if (T == 1 || T == 2 || T == 4 || T == 14 || T == 15)
  1446. Point->H = 2;
  1447. if (T == 3)
  1448. Point->H = 1;
  1449. if (debug)
  1450. printf(" Point^.H=%ld", Point->H);
  1451. Point->N = 0;
  1452. Point->O = 0;
  1453. Point->P = 0;
  1454. Point->S = 0;
  1455. Point->Si = 0;
  1456. Point->B = 0;
  1457. Point->Br = 0;
  1458. Point->Cl = 0;
  1459. Point->F = 0;
  1460. Point->I = 0;
  1461. Point->Na = 0;
  1462. Point->Mg = 0;
  1463. Point->K = 0;
  1464. Point->RecCount = Count;
  1465. if (debug)
  1466. printf(" Point^.RecCount=%ld\n", Point->RecCount);
  1467. Point->Last = Last;
  1468. }
  1469. if (T != 11) {
  1470. Abandon = false;
  1471. Current = Point;
  1472. while (Point->Last != NULL) {
  1473. if (labs(Point->X - X2) < Sensi && labs(Point->Y - Y2) < Sensi) {
  1474. if (debug)
  1475. printf(" %ld --> Joined at %ld %ld\n", Point->RecCount, X2, Y2);
  1476. if (T == 0 || T == 5 || T == 6 || T == 7 || T == 10 || T == 12 ||
  1477. T == 13)
  1478. Point->H--;
  1479. if (T == 1 || T == 2 || T == 4 || T == 14 || T == 15)
  1480. Point->H -= 2;
  1481. if (T == 3)
  1482. Point->H -= 3;
  1483. if (Point->H < 0) {
  1484. if (debug) printf("Point^.X=%ld, Point^.Y=%ld has H count <0 !\n",Point->X,Point->Y);
  1485. Point->H = 0;
  1486. }
  1487. Abandon = true;
  1488. }
  1489. Point = Point->Last;
  1490. }
  1491. Point = Current;
  1492. if (!Abandon) {
  1493. Count++;
  1494. Last = Point;
  1495. Point = (TPoint *)Malloc(sizeof(TPoint));
  1496. Point->X = X2;
  1497. if (debug)
  1498. printf(" Point^.X=%ld", Point->X);
  1499. Point->Y = Y2;
  1500. if (debug)
  1501. printf(" Point^.Y=%ld", Point->Y);
  1502. if (T != 11)
  1503. Point->C = 1;
  1504. else
  1505. Point->C = 0;
  1506. if (debug)
  1507. printf(" Point^.C=%ld", Point->C);
  1508. if (T == 0 || T == 5 || T == 6 || T == 7 || T == 10 || T == 12 ||
  1509. T == 13)
  1510. Point->H = 3;
  1511. if (T == 1 || T == 2 || T == 4 || T == 14 || T == 15 )
  1512. Point->H = 2;
  1513. if (T == 3)
  1514. Point->H = 1;
  1515. if (debug)
  1516. printf(" Point^.H=%ld", Point->H);
  1517. Point->N = 0;
  1518. Point->O = 0;
  1519. Point->P = 0;
  1520. Point->S = 0;
  1521. Point->Si = 0;
  1522. Point->B = 0;
  1523. Point->Br = 0;
  1524. Point->Cl = 0;
  1525. Point->F = 0;
  1526. Point->I = 0;
  1527. Point->Mg = 0;
  1528. Point->Na = 0;
  1529. Point->K = 0;
  1530. Point->RecCount = Count;
  1531. if (debug)
  1532. printf(" Point^.RecCount=%ld\n", Point->RecCount);
  1533. Point->Last = Last;
  1534. }
  1535. }
  1536. } while (bonds != 0);
  1537. }
  1538. Static Void doLabels()
  1539. {
  1540. long mul, gmul, gmpos, ggmul, ggmpos;
  1541. boolean stripped;
  1542. Char STR2[256];
  1543. long FORLIM;
  1544. Char *TEMP;
  1545. if (debug)
  1546. printf("---- and now parse the labels ---------\n");
  1547. if (verbose)
  1548. printf("HeteroAtoms: %ld\n", atoms);
  1549. FORLIM = atoms;
  1550. for (rep = 1; rep <= FORLIM; rep++) {
  1551. fscanf(IFile, "%ld%ld%c", &X1, &Y1, &separator);
  1552. fgets(sss, 256, IFile);
  1553. TEMP = strchr(sss, '\n');
  1554. if (TEMP != NULL)
  1555. *TEMP = 0;
  1556. sprintf(A, "%.*s", strpos2(sss, "\t", 1) - 1, sss);
  1557. if (debug)
  1558. printf("Atom %s X=%ld Y=%ld sss: %s\n", A, X1, Y1, sss);
  1559. if (nobonds)
  1560. { /*initialize the Point structure if no bonds, only labels, defined*/
  1561. Count++;
  1562. Last = Point;
  1563. Point = (TPoint *)Malloc(sizeof(TPoint));
  1564. Point->X = X1;
  1565. Point->Y = Y1;
  1566. Point->C = 0;
  1567. Point->H = 0;
  1568. Point->N = 0;
  1569. Point->O = 0;
  1570. Point->P = 0;
  1571. Point->S = 0;
  1572. Point->Si = 0;
  1573. Point->B = 0;
  1574. Point->Br = 0;
  1575. Point->Cl = 0;
  1576. Point->F = 0;
  1577. Point->I = 0;
  1578. Point->Mg = 0;
  1579. Point->Na = 0;
  1580. Point->K = 0;
  1581. Point->RecCount = Count;
  1582. Point->Last = Last;
  1583. }
  1584. Current = Point;
  1585. while (Point->Last != NULL) {
  1586. if (labs(Point->X - X1) < Sensi && labs(Point->Y - Y1) < Sensi) {
  1587. if (debug)
  1588. printf(" [%ld]\n", Point->RecCount);
  1589. Point->C = 0; /*we substitute -CH_x(-) by -R(-)*/
  1590. Point->H = 0;
  1591. Point->N = 0;
  1592. Point->O = 0;
  1593. Point->P = 0;
  1594. Point->S = 0;
  1595. Point->Si = 0;
  1596. Point->B = 0;
  1597. Point->Br = 0;
  1598. Point->Cl = 0;
  1599. Point->F = 0;
  1600. Point->I = 0;
  1601. Point->Mg = 0;
  1602. Point->Na = 0;
  1603. Point->K = 0;
  1604. mul = 1;
  1605. gmul = 1;
  1606. ggmul = 1;
  1607. while (*A != '\0') {
  1608. stripped = false;
  1609. if (strlen(A) >= 5) {
  1610. sprintf(subs, "%.5s", A);
  1611. if (strlen(A) > 6) {
  1612. if (A[5] == '_') {
  1613. sprintf(STR2, "%c", A[6]);
  1614. code = (sscanf(STR2, "%ld", &mul) == 0);
  1615. } else
  1616. mul = 1;
  1617. }
  1618. mul *= gmul * ggmul;
  1619. if (!strcmp(subs, "TBDMS")) { /*Tert-butyldimethylsilyl*/
  1620. if (debug)
  1621. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1622. Point->C += mul * 6;
  1623. Point->H += mul * 15;
  1624. Point->Si += mul;
  1625. strcpy(A, strsub(STR2, A, 6, (int)(strlen(A) - 5)));
  1626. stripped = true;
  1627. }
  1628. if (!strcmp(subs, "TBDPS")) { /*Tert-butyldiphenylsilyl*/
  1629. if (debug)
  1630. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1631. Point->C += mul * 16;
  1632. Point->H += mul * 19;
  1633. Point->Si += mul;
  1634. strcpy(A, strsub(STR2, A, 6, (int)(strlen(A) - 5)));
  1635. stripped = true;
  1636. }
  1637. if (A[0] == '[') {
  1638. ggmpos = strpos2(A, "]", 1);
  1639. if (ggmpos != 0) {
  1640. if (A[ggmpos] == '_') {
  1641. sprintf(STR2, "%c", A[ggmpos+1]);
  1642. code = (sscanf(STR2, "%ld", &ggmul) == 0);
  1643. } else
  1644. ggmul = 1;
  1645. }
  1646. }
  1647. if (A[0] == '(') {
  1648. gmpos = strpos2(A, ")", 1);
  1649. if (gmpos != 0) {
  1650. if (A[gmpos] == '_') {
  1651. sprintf(STR2, "%c", A[gmpos+1]);
  1652. code = (sscanf(STR2, "%ld", &gmul) == 0);
  1653. } else
  1654. gmul = 1;
  1655. }
  1656. }
  1657. }
  1658. if (strlen(A) >= 4 && !stripped) {
  1659. sprintf(subs, "%.4s", A);
  1660. if (strlen(A) > 5) {
  1661. if (A[4] == '_') {
  1662. sprintf(STR2, "%c", A[5]);
  1663. code = (sscanf(STR2, "%ld", &mul) == 0);
  1664. } else
  1665. mul = 1;
  1666. }
  1667. mul *= gmul * ggmul;
  1668. if (!strcmp(subs, "DBAM"))
  1669. { /*dibutylaminomethylene; =R, used as the N prot.*/
  1670. if (debug)
  1671. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1672. Point->C += mul * 9;
  1673. Point->H += mul * 19;
  1674. Point->N += mul;
  1675. strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
  1676. stripped = true;
  1677. }
  1678. if (!strcmp(subs, "DMAM"))
  1679. { /*dimethylaminomethylene; =R, used as the N prot.*/
  1680. if (debug)
  1681. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1682. Point->C += mul * 3;
  1683. Point->H += mul * 7;
  1684. Point->N += mul;
  1685. strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
  1686. stripped = true;
  1687. }
  1688. if (!strcmp(subs, "DMTr")) { /*dimethoxytrityl*/
  1689. if (debug)
  1690. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1691. Point->C += mul * 21;
  1692. Point->H += mul * 19;
  1693. Point->O += mul * 2;
  1694. strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
  1695. stripped = true;
  1696. }
  1697. if (!strcmp(subs, "MMTr")) { /*monomethoxytrityl*/
  1698. if (debug)
  1699. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1700. Point->C += mul * 20;
  1701. Point->H += mul * 16;
  1702. Point->O += mul;
  1703. strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
  1704. stripped = true;
  1705. }
  1706. if (!strcmp(subs, "TMTr")) { /*trimethoxytrityl*/
  1707. if (debug)
  1708. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1709. Point->C += mul * 22;
  1710. Point->H += mul * 22;
  1711. Point->O += mul * 3;
  1712. strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
  1713. stripped = true;
  1714. }
  1715. }
  1716. if (strlen(A) >= 3 && !stripped) {
  1717. sprintf(subs, "%.3s", A);
  1718. if (strlen(A) > 4) {
  1719. if (A[3] == '_') {
  1720. sprintf(STR2, "%c", A[4]);
  1721. code = (sscanf(STR2, "%ld", &mul) == 0);
  1722. } else
  1723. mul = 1;
  1724. }
  1725. mul *= gmul * ggmul;
  1726. if (!strcmp(subs, "Ade")) { /*Adeninyl*/
  1727. if (debug)
  1728. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1729. Point->C += mul * 5;
  1730. Point->H += mul * 4;
  1731. Point->N += mul * 5;
  1732. strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
  1733. stripped = true;
  1734. }
  1735. if (!strcmp(subs, "BOC")) { /*Butyloxycarbonyl*/
  1736. if (debug)
  1737. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1738. Point->C += mul * 5;
  1739. Point->H += mul * 9;
  1740. Point->O += mul * 2;
  1741. strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
  1742. stripped = true;
  1743. }
  1744. if (!strcmp(subs, "Cyt")) { /*Cytosinyl*/
  1745. if (debug)
  1746. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1747. Point->C += mul * 4;
  1748. Point->H += mul * 4;
  1749. Point->N += mul * 3;
  1750. Point->O += mul;
  1751. strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
  1752. stripped = true;
  1753. }
  1754. if (!strcmp(subs, "Gua")) { /*Guaninyl*/
  1755. if (debug)
  1756. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1757. Point->C += mul * 5;
  1758. Point->H += mul * 4;
  1759. Point->N += mul * 5;
  1760. Point->O += mul;
  1761. strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
  1762. stripped = true;
  1763. }
  1764. if (!strcmp(subs, "iBu")) { /*iso-Butyl*/
  1765. if (debug)
  1766. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1767. Point->C += mul * 4;
  1768. Point->H += mul * 9;
  1769. strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
  1770. stripped = true;
  1771. }
  1772. if (!strcmp(subs, "iPr")) { /*2-Propyl*/
  1773. if (debug)
  1774. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1775. Point->C += mul * 3;
  1776. Point->H += mul * 7;
  1777. strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
  1778. stripped = true;
  1779. }
  1780. if (!strcmp(subs, "MOC")) { /*Methoxycarbonyl*/
  1781. if (debug)
  1782. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1783. Point->C += mul * 2;
  1784. Point->H += mul * 3;
  1785. Point->O += mul * 2;
  1786. strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
  1787. stripped = true;
  1788. }
  1789. if (!strcmp(subs, "MOM")) { /*Methoxymethyl*/
  1790. if (debug)
  1791. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1792. Point->C += mul * 2;
  1793. Point->H += mul * 5;
  1794. Point->O += mul;
  1795. strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
  1796. stripped = true;
  1797. }
  1798. if (!strcmp(subs, "tBu")) { /*t-Butyl*/
  1799. if (debug)
  1800. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1801. Point->C += mul * 4;
  1802. Point->H += mul * 9;
  1803. strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
  1804. stripped = true;
  1805. }
  1806. if (!strcmp(subs, "Thy")) { /*Thyminyl*/
  1807. if (debug)
  1808. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1809. Point->C += mul * 5;
  1810. Point->H += mul * 5;
  1811. Point->N += mul * 2;
  1812. Point->O += mul * 2;
  1813. strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
  1814. stripped = true;
  1815. }
  1816. if (!strcmp(subs, "TMS")) { /*Trimethylsilyl*/
  1817. if (debug)
  1818. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1819. Point->C += mul * 3;
  1820. Point->H += mul * 9;
  1821. Point->Si += mul;
  1822. strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
  1823. stripped = true;
  1824. }
  1825. if (!strcmp(subs, "Tol")) { /*tolyl*/
  1826. if (debug)
  1827. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1828. Point->C += mul * 8;
  1829. Point->H += mul * 7;
  1830. Point->O += mul;
  1831. strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
  1832. stripped = true;
  1833. }
  1834. if (!strcmp(subs, "Ura")) { /*Uracilyl*/
  1835. if (debug)
  1836. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1837. Point->C += mul * 4;
  1838. Point->H += mul * 3;
  1839. Point->N += mul * 2;
  1840. Point->O += mul * 2;
  1841. strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
  1842. stripped = true;
  1843. }
  1844. }
  1845. if (strlen(A) >= 2 && !stripped) {
  1846. sprintf(subs, "%.2s", A);
  1847. if (strlen(A) > 3) {
  1848. if (A[2] == '_') {
  1849. sprintf(STR2, "%c", A[3]);
  1850. code = (sscanf(STR2, "%ld", &mul) == 0);
  1851. } else
  1852. mul = 1;
  1853. }
  1854. mul *= gmul * ggmul;
  1855. if (!strcmp(subs, "Ac")) { /*acetyl*/
  1856. if (debug)
  1857. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1858. Point->C += mul * 2;
  1859. Point->H += mul * 3;
  1860. Point->O += mul;
  1861. strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
  1862. stripped = true;
  1863. }
  1864. if (!strcmp(subs, "Bn")) { /*benzyl*/
  1865. if (debug)
  1866. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1867. Point->C += mul * 7;
  1868. Point->H += mul * 7;
  1869. strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
  1870. stripped = true;
  1871. }
  1872. if (!strcmp(subs, "Br")) { /*bromine*/
  1873. if (debug)
  1874. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1875. Point->Br += mul;
  1876. strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
  1877. stripped = true;
  1878. }
  1879. if (!strcmp(subs, "Bu")) { /*butyl*/
  1880. if (debug)
  1881. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1882. Point->C += mul * 4;
  1883. Point->H += mul * 9;
  1884. strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
  1885. stripped = true;
  1886. }
  1887. if (!strcmp(subs, "Bz")) { /*benzoyl*/
  1888. if (debug)
  1889. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1890. Point->C += mul * 7;
  1891. Point->H += mul * 5;
  1892. Point->O += mul;
  1893. strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
  1894. stripped = true;
  1895. }
  1896. if (!strcmp(subs, "CE")) { /*cyanoethyl*/
  1897. if (debug)
  1898. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
  1899. Point->C += mul * 3;
  1900. Point->H += mul * 4;
  1901. Point->N += mul;
  1902. strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
  1903. stripped = true;
  1904. }
  1905. if (!strcmp(subs, "Cl")) { /*chlorine*/
  1906. if (debug)
  1907. printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, g

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