diff --git a/.gitattributes b/.gitattributes index ba363689..54fdd865 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,10 +1,20 @@ # This file configures how Git treats line endings. # This is important because we're working on both Windows and Unix machines. -# For details see https://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/. +# For details see https://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/ +# and https://www.aleksandrhovhannisyan.com/blog/crlf-vs-lf-normalizing-line-endings-in-git/. # Git runs CRLF to LF replacement on files marked as `text` # every time they are written to the object database # and the reverse replacement when writing to the working directory. + +# When spurious diffs due to EOL changes occur (e.g., after pulling remote), do the following: +# * Inspect EOL with `git ls-files --eol`. +# * Stage the diffs. +# * Run `git rm --cached -r . && git reset --hard`. +# * Run `git add --renormalize .`. +# * Inspect EOL with `git lf-files --eol` again to verify that conversion worked. +# * Commit the change containing the EOL conversions. + *.c text *.h text *.py text @@ -16,6 +26,15 @@ *.yml text *.yaml text *.sdf text +*.props text +*.ruleset text +*.sln text +*.vcxproj text +*.def text +*.map text +*.user text +makefile text +makefile32 text *.sqlite binary *.png binary @@ -24,4 +43,6 @@ *.zip binary *.dll binary *.docx binary -*.pdf binary \ No newline at end of file +*.pdf binary +*.jpg binary +*.lib binary \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d4e7a0c2..3da30593 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,20 +9,14 @@ on: jobs: test_glibc_gcc: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 container: gcc:14 steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - name: Install test dependencies - run: | - python -m pip install --upgrade pip - python -m pip install -e INCHI-1-TEST[invariance-tests] + run: cd INCHI-1-TEST && ./install.sh - uses: ./.github/actions/compile_inchi_exe id: compile_exe @@ -51,12 +45,8 @@ jobs: test_musl_gcc: - runs-on: ubuntu-latest - # We need Python 3.12. That's why we're using alpine:edge. - # Currently (May 2024) edge is the only Alpine version with Python 3.12. - # Once edge advances, the Alpine Python version will be bumped and `python -m pip install -e INCHI-1-TEST` will break. - # TODO: Find more sustainable solution. - container: alpine:edge + runs-on: ubuntu-24.04 + container: alpine:latest steps: - name: Install build and test environment diff --git a/INCHI-1-BIN/linux/32bit/inchi-1 b/INCHI-1-BIN/linux/32bit/inchi-1 index 8f3f3c55..bc035d8a 100644 Binary files a/INCHI-1-BIN/linux/32bit/inchi-1 and b/INCHI-1-BIN/linux/32bit/inchi-1 differ diff --git a/INCHI-1-BIN/linux/32bit/inchi-1.gz b/INCHI-1-BIN/linux/32bit/inchi-1.gz index 85fb8278..b52541b8 100644 Binary files a/INCHI-1-BIN/linux/32bit/inchi-1.gz and b/INCHI-1-BIN/linux/32bit/inchi-1.gz differ diff --git a/INCHI-1-BIN/linux/32bit/so/inchi_main b/INCHI-1-BIN/linux/32bit/so/inchi_main index 19531d6c..3bd049fb 100644 Binary files a/INCHI-1-BIN/linux/32bit/so/inchi_main and b/INCHI-1-BIN/linux/32bit/so/inchi_main differ diff --git a/INCHI-1-BIN/linux/32bit/so/inchi_main.gz b/INCHI-1-BIN/linux/32bit/so/inchi_main.gz index 2bfe67d9..5733a3bb 100644 Binary files a/INCHI-1-BIN/linux/32bit/so/inchi_main.gz and b/INCHI-1-BIN/linux/32bit/so/inchi_main.gz differ diff --git a/INCHI-1-BIN/linux/32bit/so/libinchi.so.1.07 b/INCHI-1-BIN/linux/32bit/so/libinchi.so.1.07 index eeef9079..7c850f7a 100644 Binary files a/INCHI-1-BIN/linux/32bit/so/libinchi.so.1.07 and b/INCHI-1-BIN/linux/32bit/so/libinchi.so.1.07 differ diff --git a/INCHI-1-BIN/linux/32bit/so/libinchi.so.1.07.gz b/INCHI-1-BIN/linux/32bit/so/libinchi.so.1.07.gz index 29825c9e..01497176 100644 Binary files a/INCHI-1-BIN/linux/32bit/so/libinchi.so.1.07.gz and b/INCHI-1-BIN/linux/32bit/so/libinchi.so.1.07.gz differ diff --git a/INCHI-1-BIN/linux/64bit/inchi-1 b/INCHI-1-BIN/linux/64bit/inchi-1 index 94ff6d6b..d6ad037e 100644 Binary files a/INCHI-1-BIN/linux/64bit/inchi-1 and b/INCHI-1-BIN/linux/64bit/inchi-1 differ diff --git a/INCHI-1-BIN/linux/64bit/inchi-1.gz b/INCHI-1-BIN/linux/64bit/inchi-1.gz index 08190a83..d4968b2a 100644 Binary files a/INCHI-1-BIN/linux/64bit/inchi-1.gz and b/INCHI-1-BIN/linux/64bit/inchi-1.gz differ diff --git a/INCHI-1-BIN/linux/64bit/so/inchi_main b/INCHI-1-BIN/linux/64bit/so/inchi_main index 53069888..0ea80f3a 100644 Binary files a/INCHI-1-BIN/linux/64bit/so/inchi_main and b/INCHI-1-BIN/linux/64bit/so/inchi_main differ diff --git a/INCHI-1-BIN/linux/64bit/so/inchi_main.gz b/INCHI-1-BIN/linux/64bit/so/inchi_main.gz index 2406f84b..3afc1fcf 100644 Binary files a/INCHI-1-BIN/linux/64bit/so/inchi_main.gz and b/INCHI-1-BIN/linux/64bit/so/inchi_main.gz differ diff --git a/INCHI-1-BIN/linux/64bit/so/libinchi.so.1.07 b/INCHI-1-BIN/linux/64bit/so/libinchi.so.1.07 index aedd12ee..bcd47f82 100644 Binary files a/INCHI-1-BIN/linux/64bit/so/libinchi.so.1.07 and b/INCHI-1-BIN/linux/64bit/so/libinchi.so.1.07 differ diff --git a/INCHI-1-BIN/linux/64bit/so/libinchi.so.1.07.gz b/INCHI-1-BIN/linux/64bit/so/libinchi.so.1.07.gz index e45704e0..21b823ce 100644 Binary files a/INCHI-1-BIN/linux/64bit/so/libinchi.so.1.07.gz and b/INCHI-1-BIN/linux/64bit/so/libinchi.so.1.07.gz differ diff --git a/INCHI-1-BIN/windows/32bit/dll/inchi_main.exe b/INCHI-1-BIN/windows/32bit/dll/inchi_main.exe index 156be295..f5d1249a 100644 Binary files a/INCHI-1-BIN/windows/32bit/dll/inchi_main.exe and b/INCHI-1-BIN/windows/32bit/dll/inchi_main.exe differ diff --git a/INCHI-1-BIN/windows/32bit/dll/inchi_main.zip b/INCHI-1-BIN/windows/32bit/dll/inchi_main.zip index 7e2fccb3..90bf27c8 100644 Binary files a/INCHI-1-BIN/windows/32bit/dll/inchi_main.zip and b/INCHI-1-BIN/windows/32bit/dll/inchi_main.zip differ diff --git a/INCHI-1-BIN/windows/32bit/dll/libgcc_s_dw2-1.dll b/INCHI-1-BIN/windows/32bit/dll/libgcc_s_dw2-1.dll new file mode 100644 index 00000000..b2c6a7e9 Binary files /dev/null and b/INCHI-1-BIN/windows/32bit/dll/libgcc_s_dw2-1.dll differ diff --git a/INCHI-1-BIN/windows/32bit/dll/libinchi.dll b/INCHI-1-BIN/windows/32bit/dll/libinchi.dll index 0b8cf1f9..12c23dc1 100644 Binary files a/INCHI-1-BIN/windows/32bit/dll/libinchi.dll and b/INCHI-1-BIN/windows/32bit/dll/libinchi.dll differ diff --git a/INCHI-1-BIN/windows/32bit/dll/libinchi.zip b/INCHI-1-BIN/windows/32bit/dll/libinchi.zip index 51817a64..d9dccf2f 100644 Binary files a/INCHI-1-BIN/windows/32bit/dll/libinchi.zip and b/INCHI-1-BIN/windows/32bit/dll/libinchi.zip differ diff --git a/INCHI-1-BIN/windows/32bit/inchi-1.exe b/INCHI-1-BIN/windows/32bit/inchi-1.exe index fd818047..c13ce5a0 100644 Binary files a/INCHI-1-BIN/windows/32bit/inchi-1.exe and b/INCHI-1-BIN/windows/32bit/inchi-1.exe differ diff --git a/INCHI-1-BIN/windows/32bit/inchi-1.zip b/INCHI-1-BIN/windows/32bit/inchi-1.zip index d6095c92..6a5b3106 100644 Binary files a/INCHI-1-BIN/windows/32bit/inchi-1.zip and b/INCHI-1-BIN/windows/32bit/inchi-1.zip differ diff --git a/INCHI-1-BIN/windows/32bit/libgcc_s_dw2-1.dll b/INCHI-1-BIN/windows/32bit/libgcc_s_dw2-1.dll new file mode 100644 index 00000000..b2c6a7e9 Binary files /dev/null and b/INCHI-1-BIN/windows/32bit/libgcc_s_dw2-1.dll differ diff --git a/INCHI-1-BIN/windows/64bit/dll/inchi_main.exe b/INCHI-1-BIN/windows/64bit/dll/inchi_main.exe index e4fc3567..23d29cb1 100644 Binary files a/INCHI-1-BIN/windows/64bit/dll/inchi_main.exe and b/INCHI-1-BIN/windows/64bit/dll/inchi_main.exe differ diff --git a/INCHI-1-BIN/windows/64bit/dll/inchi_main.zip b/INCHI-1-BIN/windows/64bit/dll/inchi_main.zip index e24c16e4..3b7e4acc 100644 Binary files a/INCHI-1-BIN/windows/64bit/dll/inchi_main.zip and b/INCHI-1-BIN/windows/64bit/dll/inchi_main.zip differ diff --git a/INCHI-1-BIN/windows/64bit/dll/libinchi.dll b/INCHI-1-BIN/windows/64bit/dll/libinchi.dll index 94b62ef6..0d32fcc2 100644 Binary files a/INCHI-1-BIN/windows/64bit/dll/libinchi.dll and b/INCHI-1-BIN/windows/64bit/dll/libinchi.dll differ diff --git a/INCHI-1-BIN/windows/64bit/dll/libinchi.zip b/INCHI-1-BIN/windows/64bit/dll/libinchi.zip index 2b618fdf..abc585be 100644 Binary files a/INCHI-1-BIN/windows/64bit/dll/libinchi.zip and b/INCHI-1-BIN/windows/64bit/dll/libinchi.zip differ diff --git a/INCHI-1-BIN/windows/64bit/inchi-1.exe b/INCHI-1-BIN/windows/64bit/inchi-1.exe index 6629118e..8cfe627c 100644 Binary files a/INCHI-1-BIN/windows/64bit/inchi-1.exe and b/INCHI-1-BIN/windows/64bit/inchi-1.exe differ diff --git a/INCHI-1-BIN/windows/64bit/inchi-1.zip b/INCHI-1-BIN/windows/64bit/inchi-1.zip index 13826a1c..295b7824 100644 Binary files a/INCHI-1-BIN/windows/64bit/inchi-1.zip and b/INCHI-1-BIN/windows/64bit/inchi-1.zip differ diff --git a/INCHI-1-BIN/windows/winchi-1.exe b/INCHI-1-BIN/windows/winchi-1.exe deleted file mode 100644 index 27b82200..00000000 Binary files a/INCHI-1-BIN/windows/winchi-1.exe and /dev/null differ diff --git a/INCHI-1-SRC/INCHI_API/demos/inchi_main/gcc/makefile b/INCHI-1-SRC/INCHI_API/demos/inchi_main/gcc/makefile index 33e24393..b8f48614 100644 --- a/INCHI-1-SRC/INCHI_API/demos/inchi_main/gcc/makefile +++ b/INCHI-1-SRC/INCHI_API/demos/inchi_main/gcc/makefile @@ -41,11 +41,15 @@ endif ifndef C_COMPILER ifeq ($(CCN),2) C_COMPILER = clang -$(info Both GCC and Clang/LLVM detected. Compiling with Clang -- please edit makefile to compile with GCC.) +$(info Both GCC and Clang/LLVM detected. Compiling with Clang(++) -- please edit makefile to compile with GCC.) $(info ) else +ifeq ($(OS_ID),0) +C_COMPILER = gcc -static +else C_COMPILER = gcc -$(info Both GCC and Clang/LLVM detected. Compiling with GCC (default) -- please edit makefile to compile with Clang/LLVM.) +endif +$(info Both GCC and Clang/LLVM detected. Compiling with GCC/G++ (default) -- please edit makefile to compile with Clang/LLVM.) $(info ) endif endif @@ -116,9 +120,9 @@ endif # === C Compiler Options ======= ifndef C_OPTIONS ifndef CALLER_IS_MOL2INCHI - C_OPTIONS = -std=c11 -ansi -O2 -c -fno-strict-aliasing + C_OPTIONS = -std=c11 -ansi -O1 -c -fno-strict-aliasing else - C_OPTIONS = -std=c11 -O2 -c -fno-strict-aliasing + C_OPTIONS = -std=c11 -O1 -c -fno-strict-aliasing endif ifneq ($(OS_ID),0) ifndef C_SO_OPTIONS @@ -176,7 +180,7 @@ else ifeq ($(OS_ID),2) # jwm: linking to .dylib on OS X $(API_CALLER_PATHNAME) : $(API_CALLER_OBJS) $(INCHI_LIB_PATHNAME).so$(VERSION) $(LINKER) -o $(API_CALLER_PATHNAME) $(API_CALLER_OBJS) \ -$(INCHI_LIB_PATHNAME).dylib$(VERSION) -lm +$(INCHI_LIB_PATHNAME)$(VERSION).dylib -lm else # djb-rwth: linking to .so on Linux $(API_CALLER_PATHNAME) : $(API_CALLER_OBJS) $(INCHI_LIB_PATHNAME).so$(VERSION) @@ -255,9 +259,9 @@ $(INCHI_LIB_PATHNAME).dll$(VERSION): $(INCHI_LIB_OBJS) $(INCHI_LIB_OBJS) -Wl$(LINUX_MAP),-soname,$(INCHI_LIB_NAME).dll$(VERSION) -Wl,--subsystem,windows -lm else ifeq ($(OS_ID), 2) # jwm: creating .dylib on OS X -$(INCHI_LIB_PATHNAME).dylib$(VERSION): $(INCHI_LIB_OBJS) - $(SHARED_LINK) $(SHARED_LINK_PARM) -o $(INCHI_LIB_PATHNAME).dylib$(VERSION) \ -$(INCHI_LIB_OBJS) -Wl$(LINUX_MAP)$(LINUX_Z_RELRO) -install_name $(INCHI_LIB_NAME).dylib$(VERSION) -lm +$(INCHI_LIB_PATHNAME)$(VERSION).dylib: $(INCHI_LIB_OBJS) + $(SHARED_LINK) $(SHARED_LINK_PARM) -o $(INCHI_LIB_PATHNAME)$(VERSION).dylib \ +$(INCHI_LIB_OBJS) -Wl$(LINUX_MAP)$(LINUX_Z_RELRO) -install_name $(INCHI_LIB_NAME)$(VERSION).dylib -lm else # djb-rwth: creating .so on Linux $(INCHI_LIB_PATHNAME).so$(VERSION): $(INCHI_LIB_OBJS) diff --git a/INCHI-1-SRC/INCHI_API/demos/inchi_main/gcc/makefile32 b/INCHI-1-SRC/INCHI_API/demos/inchi_main/gcc/makefile32 index 10fbbe3c..ac8651f9 100644 --- a/INCHI-1-SRC/INCHI_API/demos/inchi_main/gcc/makefile32 +++ b/INCHI-1-SRC/INCHI_API/demos/inchi_main/gcc/makefile32 @@ -37,18 +37,26 @@ ifeq ($(CCN),$(filter $(CCN),1 2)) ifeq ($(GCC_DETECTED),1) ifeq ($(CLANG_DETECTED),1) # djb-rwth: Choose C compiler if both GCC and Clang are detected -- CCN = 1 for GCC, CCN = 2 for Clang/LLVM -CCN = 1 +CCN = 2 endif endif # === C Compiler =============== ifndef C_COMPILER ifeq ($(CCN),2) +ifeq ($(OS_ID),0) +C_COMPILER = clang -static +else C_COMPILER = clang -$(info Both GCC and Clang/LLVM detected. Compiling with Clang -- please edit makefile to compile with GCC.) +endif +$(info Both GCC and Clang/LLVM detected. Compiling with Clang(++) -- please edit makefile to compile with GCC.) $(info ) else +ifeq ($(OS_ID),0) +C_COMPILER = gcc -static +else C_COMPILER = gcc -$(info Both GCC and Clang/LLVM detected. Compiling with GCC (default) -- please edit makefile to compile with Clang/LLVM.) +endif +$(info Both GCC and Clang/LLVM detected. Compiling with GCC/G++ (default) -- please edit makefile to compile with Clang/LLVM.) $(info ) endif endif @@ -116,9 +124,9 @@ endif # === C Compiler Options ======= ifndef C_OPTIONS ifndef CALLER_IS_MOL2INCHI - C_OPTIONS = -std=c11 -m32 -ansi -O2 -c -fno-strict-aliasing + C_OPTIONS = -std=c11 -m32 -ansi -O1 -c -fno-strict-aliasing else - C_OPTIONS = -std=c11 -m32 -O2 -c -fno-strict-aliasing + C_OPTIONS = -std=c11 -m32 -O1 -c -fno-strict-aliasing endif ifneq ($(OS_ID),0) ifndef C_SO_OPTIONS diff --git a/INCHI-1-SRC/INCHI_API/demos/inchi_main/src/e_0dstereo.c b/INCHI-1-SRC/INCHI_API/demos/inchi_main/src/e_0dstereo.c index f3c133fe..9576b55a 100644 --- a/INCHI-1-SRC/INCHI_API/demos/inchi_main/src/e_0dstereo.c +++ b/INCHI-1-SRC/INCHI_API/demos/inchi_main/src/e_0dstereo.c @@ -48,7 +48,6 @@ #include #include #include -#include #include "e_mode.h" @@ -329,11 +328,17 @@ int e_GetElType( inchi_Atom *at, int cur_atom ) S_CHAR num_bonds[MAX_BOND_TYPE]; int i; int nRadicalValence = 0; - bool cndt1, cndt2; + int cndt1 = 0, cndt2 = 0; /* djb-rwth: avoiding non-zero constant warning */ - cndt1 = sizeof(at->num_iso_H) != sizeof(num_iso_H); - cndt2 = sizeof(at->num_iso_H[0]) != sizeof(num_iso_H[0]); + if (sizeof(at->num_iso_H) != sizeof(num_iso_H)) + { + cndt1 = 1; + } + if (sizeof(at->num_iso_H[0]) != sizeof(num_iso_H[0])) + { + cndt2 = 1; + } if ( cndt1 || cndt2 ) { diff --git a/INCHI-1-SRC/INCHI_API/demos/inchi_main/src/e_ichi_parms.c b/INCHI-1-SRC/INCHI_API/demos/inchi_main/src/e_ichi_parms.c index 1c8be799..e3d947c6 100644 --- a/INCHI-1-SRC/INCHI_API/demos/inchi_main/src/e_ichi_parms.c +++ b/INCHI-1-SRC/INCHI_API/demos/inchi_main/src/e_ichi_parms.c @@ -2724,15 +2724,15 @@ void HelpCommandLineParms(INCHI_IOSTREAM* f) inchi_ios_print_nodisplay(f, " SLUUD Make labels for unknown and undefined stereo different\n"); inchi_ios_print_nodisplay(f, " RecMet Include reconnected metals results\n"); inchi_ios_print_nodisplay(f, " FixedH Include Fixed H layer\n"); - inchi_ios_print_nodisplay(f, " KET Account for keto-enol tautomerism (experimental)\n"); - inchi_ios_print_nodisplay(f, " 15T Account for 1,5-tautomerism (experimental)\n"); - - inchi_ios_print_nodisplay(f, " PT_22_00 Account for PT_22_00 tautomerism (experimental)\n"); - inchi_ios_print_nodisplay(f, " PT_16_00 Account for PT_16_00 tautomerism (experimental)\n"); - inchi_ios_print_nodisplay(f, " PT_06_00 Account for PT_06_00 tautomerism (experimental)\n"); - inchi_ios_print_nodisplay(f, " PT_39_00 Account for PT_39_00 tautomerism (experimental)\n"); - inchi_ios_print_nodisplay(f, " PT_13_00 Account for PT_13_00 tautomerism (experimental)\n"); - inchi_ios_print_nodisplay(f, " PT_18_00 Account for PT_18_00 tautomerism (experimental)\n"); + + inchi_ios_print_nodisplay(f, " KET Consider keto-enol tautomerism (experimental)\n"); + inchi_ios_print_nodisplay(f, " 15T Consider 1,5-tautomerism (experimental)\n"); + inchi_ios_print_nodisplay(f, " PT_06_00 Consider 1,3 heteroatom shift (experimental)\n"); + inchi_ios_print_nodisplay(f, " PT_13_00 Consider keten-ynol exchange (experimental)\n"); + inchi_ios_print_nodisplay(f, " PT_16_00 Consider nitroso-oxime tautomerism (experimental)\n"); + inchi_ios_print_nodisplay(f, " PT_18_00 Consider cyanic/iso-cyanic acids (experimental)\n"); + inchi_ios_print_nodisplay(f, " PT_22_00 Consider imine/imine tautomerism (experimental)\n"); + inchi_ios_print_nodisplay(f, " PT_39_00 Consider nitrone/azoxy or Behrend rearrangement (experimental)\n"); inchi_ios_print_nodisplay(f, "Generation\n"); diff --git a/INCHI-1-SRC/INCHI_API/demos/inchi_main/src/e_mode.h b/INCHI-1-SRC/INCHI_API/demos/inchi_main/src/e_mode.h index 3e81e08a..2ef5cf90 100644 --- a/INCHI-1-SRC/INCHI_API/demos/inchi_main/src/e_mode.h +++ b/INCHI-1-SRC/INCHI_API/demos/inchi_main/src/e_mode.h @@ -43,6 +43,7 @@ #define __MODE_H__ #include +#include "../../../../INCHI_BASE/src/bcf_s.h" @@ -189,9 +190,10 @@ MS VC compiler pragmas #undef APP_DESCRIPTION #endif #ifndef CREATE_INCHI_STEP_BY_STEP -#define APP_DESCRIPTION "InChI version 1, Software v. 1.07 (Library call example, classic API)" +/* djb-rwth: adding full version number in the output -- GH issue #61 */ +#define APP_DESCRIPTION "InChI version 1, Software " CURRENT_VER " (Library call example, classic API)" #else -#define APP_DESCRIPTION "InChI version 1, Software v. 1.07 (Library call example, modularized API)" +#define APP_DESCRIPTION "InChI version 1, Software " CURRENT_VER " (Library call example, modularized API)" #endif diff --git a/INCHI-1-SRC/INCHI_API/demos/inchi_main/vc14/inchi_main.vcxproj b/INCHI-1-SRC/INCHI_API/demos/inchi_main/vc14/inchi_main.vcxproj index 1018138c..edc7c72a 100644 --- a/INCHI-1-SRC/INCHI_API/demos/inchi_main/vc14/inchi_main.vcxproj +++ b/INCHI-1-SRC/INCHI_API/demos/inchi_main/vc14/inchi_main.vcxproj @@ -1,243 +1,243 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {815C9385-15A4-48B4-A3DF-4671619245C1} - inchi_main - Win32Proj - 10.0 - - - - Application - v143 - NotSet - true - - - Application - v143 - NotSet - true - - - Application - v143 - NotSet - true - - - Application - v143 - NotSet - true - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>14.0.25431.1 - - - ../../../bin2/Windows/$(Platform)/$(Configuration)\ - ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ - false - - - ../../../bin2/Windows/$(Platform)/$(Configuration)\ - ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ - false - - - ../../../bin2/Windows/$(Platform)/$(Configuration)\ - ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ - false - - - ../../../bin2/Windows/$(Platform)/$(Configuration)\ - ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ - false - - - - MaxSpeed - _CONSOLE;_MBCS;BUILD_LINK_AS_DLL; TARGET_EXE_USING_API=1;%(PreprocessorDefinitions) - false - Default - MultiThreadedDebug - - Level3 - ProgramDatabase - Default - true - - true - - - ../../../bin2/Windows/$(Platform)/$(Configuration)/inchi_main.exe - true - Console - 16000000 - MachineX86 - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;"..\..\..\bin2\windows\win32\debug\libinchi.lib";%(AdditionalDependencies) - - - true - true - - - - - X64 - - - MaxSpeed - _CONSOLE;_MBCS;BUILD_LINK_AS_DLL; TARGET_EXE_USING_API=1;%(PreprocessorDefinitions) - false - Default - MultiThreadedDebug - - Level3 - ProgramDatabase - true - true - - - ../../../bin2/Windows/$(Platform)/$(Configuration)/inchi_main.exe - true - Console - 16000000 - MachineX64 - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;"..\..\..\bin2\windows\x64\debug\libinchi.lib";%(AdditionalDependencies) - - - true - true - - - - - MaxSpeed - true - _CONSOLE;_MBCS;BUILD_LINK_AS_DLL; TARGET_EXE_USING_API=1;%(PreprocessorDefinitions) - MultiThreaded - true - - Level3 - ProgramDatabase - - - - ../../../bin2/Windows/$(Platform)/$(Configuration)/inchi_main.exe - true - Console - 16000000 - true - true - MachineX86 - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;"..\..\..\bin2\windows\win32\release\libinchi.lib";%(AdditionalDependencies) - - - - - - - X64 - - - MaxSpeed - true - _CONSOLE;_MBCS;BUILD_LINK_AS_DLL; TARGET_EXE_USING_API=1;%(PreprocessorDefinitions) - MultiThreaded - true - - Level3 - ProgramDatabase - Default - - - ../../../bin2/Windows/$(Platform)/$(Configuration)/inchi_main.exe - true - Console - 16000000 - true - true - MachineX64 - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;"..\..\..\bin2\windows\x64\release\libinchi.lib";%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {815C9385-15A4-48B4-A3DF-4671619245C1} + inchi_main + Win32Proj + 10.0 + + + + Application + v143 + NotSet + true + + + Application + v143 + NotSet + true + + + Application + v143 + NotSet + true + + + Application + v143 + NotSet + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>14.0.25431.1 + + + ../../../bin2/Windows/$(Platform)/$(Configuration)\ + ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ + false + + + ../../../bin2/Windows/$(Platform)/$(Configuration)\ + ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ + false + + + ../../../bin2/Windows/$(Platform)/$(Configuration)\ + ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ + false + + + ../../../bin2/Windows/$(Platform)/$(Configuration)\ + ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ + false + + + + MaxSpeed + _CONSOLE;_MBCS;BUILD_LINK_AS_DLL; TARGET_EXE_USING_API=1;%(PreprocessorDefinitions) + false + Default + MultiThreadedDebug + + Level3 + ProgramDatabase + Default + true + + true + + + ../../../bin2/Windows/$(Platform)/$(Configuration)/inchi_main.exe + true + Console + 16000000 + MachineX86 + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;"..\..\..\bin2\windows\win32\debug\libinchi.lib";%(AdditionalDependencies) + + + true + true + + + + + X64 + + + MaxSpeed + _CONSOLE;_MBCS;BUILD_LINK_AS_DLL; TARGET_EXE_USING_API=1;%(PreprocessorDefinitions) + false + Default + MultiThreadedDebug + + Level3 + ProgramDatabase + true + true + + + ../../../bin2/Windows/$(Platform)/$(Configuration)/inchi_main.exe + true + Console + 16000000 + MachineX64 + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;"..\..\..\bin2\windows\x64\debug\libinchi.lib";%(AdditionalDependencies) + + + true + true + + + + + MaxSpeed + true + _CONSOLE;_MBCS;BUILD_LINK_AS_DLL; TARGET_EXE_USING_API=1;%(PreprocessorDefinitions) + MultiThreaded + true + + Level3 + ProgramDatabase + + + + ../../../bin2/Windows/$(Platform)/$(Configuration)/inchi_main.exe + true + Console + 16000000 + true + true + MachineX86 + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;"..\..\..\bin2\windows\win32\release\libinchi.lib";%(AdditionalDependencies) + + + + + + + X64 + + + MaxSpeed + true + _CONSOLE;_MBCS;BUILD_LINK_AS_DLL; TARGET_EXE_USING_API=1;%(PreprocessorDefinitions) + MultiThreaded + true + + Level3 + ProgramDatabase + Default + + + ../../../bin2/Windows/$(Platform)/$(Configuration)/inchi_main.exe + true + Console + 16000000 + true + true + MachineX64 + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;"..\..\..\bin2\windows\x64\release\libinchi.lib";%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/INCHI-1-SRC/INCHI_API/demos/inchi_main/vc14/inchi_main.vcxproj.user b/INCHI-1-SRC/INCHI_API/demos/inchi_main/vc14/inchi_main.vcxproj.user index 0f14913f..88a55094 100644 --- a/INCHI-1-SRC/INCHI_API/demos/inchi_main/vc14/inchi_main.vcxproj.user +++ b/INCHI-1-SRC/INCHI_API/demos/inchi_main/vc14/inchi_main.vcxproj.user @@ -1,4 +1,4 @@ - - - + + + \ No newline at end of file diff --git a/INCHI-1-SRC/INCHI_API/demos/test_ixa/src/moreitil.h b/INCHI-1-SRC/INCHI_API/demos/test_ixa/src/moreitil.h index bf563b84..428a0bd6 100644 --- a/INCHI-1-SRC/INCHI_API/demos/test_ixa/src/moreitil.h +++ b/INCHI-1-SRC/INCHI_API/demos/test_ixa/src/moreitil.h @@ -25,8 +25,8 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. - * - * The InChI library and programs are free software developed under the +* +* The InChI library and programs are free software developed under the * auspices of the International Union of Pure and Applied Chemistry (IUPAC). * Originally developed at NIST. * Modifications and additions by IUPAC and the InChI Trust. @@ -36,7 +36,8 @@ * * info@inchi-trust.org * - */ +*/ + #ifndef _MOREUTIL_H_ #define _MOREUTIL_H_ diff --git a/INCHI-1-SRC/INCHI_API/demos/test_ixa/src/moreutil.c b/INCHI-1-SRC/INCHI_API/demos/test_ixa/src/moreutil.c index 34414c91..ded7d948 100644 --- a/INCHI-1-SRC/INCHI_API/demos/test_ixa/src/moreutil.c +++ b/INCHI-1-SRC/INCHI_API/demos/test_ixa/src/moreutil.c @@ -25,8 +25,8 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. - * - * The InChI library and programs are free software developed under the +* +* The InChI library and programs are free software developed under the * auspices of the International Union of Pure and Applied Chemistry (IUPAC). * Originally developed at NIST. * Modifications and additions by IUPAC and the InChI Trust. @@ -36,7 +36,8 @@ * * info@inchi-trust.org * - */ +*/ + #pragma warning( disable : 4996 ) diff --git a/INCHI-1-SRC/INCHI_API/demos/test_ixa/src/test_ixa.c b/INCHI-1-SRC/INCHI_API/demos/test_ixa/src/test_ixa.c index bc1152b3..474c63cc 100644 --- a/INCHI-1-SRC/INCHI_API/demos/test_ixa/src/test_ixa.c +++ b/INCHI-1-SRC/INCHI_API/demos/test_ixa/src/test_ixa.c @@ -25,8 +25,8 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. - * - * The InChI library and programs are free software developed under the +* +* The InChI library and programs are free software developed under the * auspices of the International Union of Pure and Applied Chemistry (IUPAC). * Originally developed at NIST. * Modifications and additions by IUPAC and the InChI Trust. @@ -36,7 +36,8 @@ * * info@inchi-trust.org * - */ +*/ + #include #include @@ -452,7 +453,7 @@ void main( int argc, const char *argv[] ) #if ( defined(_WIN32) && defined(_MSC_VER) ) #if WINVER >= 0x0501 /* XP or newer */ /* 0x0600 Vista or newer */ - tick_ixa_start = GetTickCount( ); + tick_ixa_start = GetTickCount64( ); #endif #else time( &time_t_ixa_start ); @@ -738,7 +739,7 @@ void main( int argc, const char *argv[] ) #if ( defined(_WIN32) && defined(_MSC_VER) ) #if WINVER >= 0x0501 /* XP or newer */ /* 0x0600 Vista or newer */ - tick_ixa_stop = GetTickCount( ); + tick_ixa_stop = GetTickCount64( ); fprintf( stderr, "\nElapsed time: %d msec.\n", tick_ixa_stop - tick_ixa_start ); #endif #else diff --git a/INCHI-1-SRC/INCHI_API/demos/test_ixa/src/test_ixa.h b/INCHI-1-SRC/INCHI_API/demos/test_ixa/src/test_ixa.h index d92e2835..0ac2971d 100644 --- a/INCHI-1-SRC/INCHI_API/demos/test_ixa/src/test_ixa.h +++ b/INCHI-1-SRC/INCHI_API/demos/test_ixa/src/test_ixa.h @@ -25,8 +25,8 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. - * - * The InChI library and programs are free software developed under the +* +* The InChI library and programs are free software developed under the * auspices of the International Union of Pure and Applied Chemistry (IUPAC). * Originally developed at NIST. * Modifications and additions by IUPAC and the InChI Trust. @@ -36,7 +36,9 @@ * * info@inchi-trust.org * - */ +*/ + +#include "../../../../INCHI_BASE/src/bcf_s.h" #ifndef _TEST_IXA_H_ #define _TEST_IXA_H_ @@ -67,7 +69,7 @@ #ifdef APP_DESCRIPTION #undef APP_DESCRIPTION #endif -#define APP_DESCRIPTION "InChI version 1, Software v. 1.061 (test_ixa - Library call example, IXA API v. 1.061)" +#define APP_DESCRIPTION "InChI version 1, Software v. " CURRENT_VER " (test_ixa - Library call example, IXA API v. " CURRENT_VER /*#define RELEASE_IS_FINAL 0*/ /* 1=> pre-release version; comment out to disable */ #ifndef RELEASE_IS_FINAL diff --git a/INCHI-1-SRC/INCHI_API/libinchi/gcc/makefile b/INCHI-1-SRC/INCHI_API/libinchi/gcc/makefile index 6d5a7226..283a7b2b 100644 --- a/INCHI-1-SRC/INCHI_API/libinchi/gcc/makefile +++ b/INCHI-1-SRC/INCHI_API/libinchi/gcc/makefile @@ -1,278 +1,282 @@ -# Comment out the next line to create so/dll only -#CREATE_MAIN = 1 -# Comment out the next line to create mol2inchi executable (otherwise, inchi_maiin is created) -#CALLER_IS_MOL2INCHI = 1 -# djb-rwth: detecting the OS in Makefile -- no need to specify ISLINUX externally; OS can also be defined in command line: e.g. make OS_ID=1 -ifeq ($(OS),Windows_NT) - OS_ID := 0 -else - UNAME_S := $(shell uname -s) - ifeq ($(UNAME_S),Linux) - OS_ID := 1 - endif - ifeq ($(UNAME_S),Darwin) - OS_ID := 2 - endif - ifeq ($(UNAME_S),FreeBSD) - OS_ID := 3 - endif -# djb-rwth: other OSs should be numbered accordingly -endif -# djb-rwth: checking the presence on GCC and Clang/LLVM -GCC_CHECK := $(shell gcc --version) -CLANG_CHECK := $(shell clang --version) -ifneq ($(GCC_CHECK),) - GCC_DETECTED := 1 - CCN = 1 -endif -ifneq ($(CLANG_CHECK),) - CLANG_DETECTED := 1 - CCN = 2 -endif -ifeq ($(CCN),$(filter $(CCN),1 2)) -# djb-rwth: Choosing the compiler if both GCC and Clang/LLVM are detected -ifeq ($(GCC_DETECTED),1) -ifeq ($(CLANG_DETECTED),1) -# djb-rwth: Choose C compiler if both GCC and Clang are detected -- CCN = 1 for GCC, CCN = 2 for Clang/LLVM -CCN = 1 -endif -endif -# === C Compiler =============== -ifndef C_COMPILER -ifeq ($(CCN),2) -C_COMPILER = clang -$(info Both GCC and Clang/LLVM detected. Compiling with Clang -- please edit makefile to compile with GCC.) -$(info ) -else -C_COMPILER = gcc -$(info Both GCC and Clang/LLVM detected. Compiling with GCC (default) -- please edit makefile to compile with Clang/LLVM.) -$(info ) -endif -endif -# Linux fpic option: replace -fPIC with -fpic if the latter works -# Comment out "LINUX_Z_RELRO =" if -z relro is not supported -# These options are needed to avoid the following SELinux message: -# "Error: cannot restore segment prot after reloc: Permission denied" -# In addition, inchi.map restricts set of expoorted from .so -# functions to those which belong to InChI API -ifneq ($(OS_ID),2) - LINUX_MAP = ,--version-script=libinchi.map - LINUX_Z_RELRO = ,-z,relro -endif -ifneq ($(OS_ID),0) - LINUX_FPIC = -fPIC -# === version === - MAIN_VERSION = .1 - VERSION = $(MAIN_VERSION).07 -endif -# === executable & library directory === -ifndef LIB_DIR - LIB_DIR = ../../bin/Linux -endif -# === InChI Library name === -ifndef INCHI_LIB_NAME - INCHI_LIB_NAME = libinchi -endif -INCHI_LIB_PATHNAME = $(LIB_DIR)/$(INCHI_LIB_NAME) -# === Main program name ==== -ifndef API_CALLER_NAME - ifndef CALLER_IS_MOL2INCHI - API_CALLER_NAME = inchi_main - else - API_CALLER_NAME = mol2inchi - endif -endif -API_CALLER_PATHNAME = $(LIB_DIR)/$(API_CALLER_NAME) -# === Linker to create (Shared) InChI library ==== -ifndef SHARED_LINK - SHARED_LINK = $(C_COMPILER) -shared -endif -# === Linker to create Main program ===== -ifndef LINKER - ifdef OS_ID -# or: ifeq ($(OS_ID),$(filter $(OS_ID),0 1 2 3)) -# djb-rwth: avoiding the use of LD_LIBRARY_PATH by adding LIB_DIR to runtime library search path - LINKER_CWD_PATH = -Wl,-R,"",-rpath=$(LIB_DIR) - endif - LINKER = $(C_COMPILER) -s $(LINKER_CWD_PATH) -endif -# djb-rwth: space for shared link parameters SHARED_LINK_PARMS -ifndef P_LIBR - P_LIBR = ../../libinchi/src/ -endif -ifndef P_LIBR_IXA - P_LIBR_IXA = ../../libinchi/src/ixa/ -endif -ifndef P_BASE - P_BASE = ../../../INCHI_BASE/src/ -endif -ifndef P_MAIN - ifndef CALLER_IS_MOL2INCHI - P_MAIN = ../src/ - else - P_MAIN = ../src/ - endif -endif -# === C Compiler Options ======= -ifndef C_OPTIONS - ifndef CALLER_IS_MOL2INCHI - C_OPTIONS = -std=c11 -ansi -O2 -c -fno-strict-aliasing - else - C_OPTIONS = -std=c11 -O2 -c -fno-strict-aliasing - endif - ifneq ($(OS_ID),0) - ifndef C_SO_OPTIONS - C_SO_OPTIONS = $(LINUX_FPIC) -DTARGET_API_LIB -DCOMPILE_ANSI_ONLY - endif - else - ifndef C_SO_OPTIONS - C_SO_OPTIONS = -DBUILD_LINK_AS_DLL -DTARGET_API_LIB - endif - endif - ifndef C_MAIN_OPTIONS - C_MAIN_OPTIONS = -DBUILD_LINK_AS_DLL -DTARGET_EXE_USING_API - endif -endif -ifdef CREATE_MAIN -ifndef CALLER_IS_MOL2INCHI -API_CALLER_SRCS = $(P_MAIN)e_0dstereo.c \ -$(P_MAIN)e_ichimain.c \ -$(P_MAIN)e_ichi_io.c \ -$(P_MAIN)e_ichi_parms.c \ -$(P_MAIN)e_inchi_atom.c \ -$(P_MAIN)e_mol2atom.c \ -$(P_MAIN)e_readinch.c \ -$(P_MAIN)e_readmol.c \ -$(P_MAIN)e_readstru.c \ -$(P_MAIN)e_util.c \ -$(P_MAIN)e_ichimain_a.c -API_CALLER_OBJS = e_0dstereo.o \ -e_ichimain.o \ -e_ichi_io.o \ -e_ichi_parms.o \ -e_inchi_atom.o \ -e_mol2atom.o \ -e_readinch.o \ -e_readmol.o \ -e_readstru.o \ -e_util.o \ -e_ichimain_a.o -else -API_CALLER_SRCS = $(P_MAIN)mol2inchi.c \ -$(P_MAIN)getcputime.c \ -$(P_MAIN)moreutil.c -API_CALLER_OBJS = mol2inchi.o \ -getcputime.o \ -moreutil.o -endif -# === InChI Main Link rule ================ -ifeq ($(OS_ID),0) -# djb-rwth: linking to .dll on Windows -$(API_CALLER_PATHNAME) : $(API_CALLER_OBJS) $(INCHI_LIB_PATHNAME).dll$(VERSION) - $(LINKER) -o $(API_CALLER_PATHNAME) $(API_CALLER_OBJS) \ -$(INCHI_LIB_PATHNAME).dll$(VERSION) -lm -else ifeq ($(OS_ID),2) -# jwm: linking to .dylib on OS X -$(API_CALLER_PATHNAME) : $(API_CALLER_OBJS) $(INCHI_LIB_PATHNAME).so$(VERSION) - $(LINKER) -o $(API_CALLER_PATHNAME) $(API_CALLER_OBJS) \ -$(INCHI_LIB_PATHNAME).dylib$(VERSION) -lm -else -# djb-rwth: linking to .so on Linux -$(API_CALLER_PATHNAME) : $(API_CALLER_OBJS) $(INCHI_LIB_PATHNAME).so$(VERSION) - $(LINKER) -o $(API_CALLER_PATHNAME) $(API_CALLER_OBJS) \ -$(INCHI_LIB_PATHNAME).so$(VERSION) -lm -endif -# === InChI Main compile rule ============ -%.o: $(P_MAIN)%.c - $(C_COMPILER) $(C_MAIN_OPTIONS) $(C_OPTIONS) $< -endif -# === InChI Library Object files ============ -INCHI_LIB_OBJS = ichican2.o \ -ichicano.o \ -ichi_io.o \ -ichierr.o \ -ichicans.o \ -ichiisot.o \ -ichilnct.o \ -ichimak2.o \ -ichimake.o \ -ichimap1.o \ -ichimap2.o \ -ichimap4.o \ -ichinorm.o \ -ichiparm.o \ -ichiprt1.o \ -ichiprt2.o \ -ichiprt3.o \ -ichiqueu.o \ -ichiring.o \ -ichisort.o \ -ichister.o \ -ichitaut.o \ -ichi_bns.o \ -inchi_dll.o \ -ichiread.o \ -ichirvr1.o \ -ichirvr2.o \ -ichirvr3.o \ -ichirvr4.o \ -ichirvr5.o \ -ichirvr6.o \ -ichirvr7.o \ -ikey_dll.o \ -ikey_base26.o \ -inchi_dll_main.o \ -inchi_dll_a.o \ -inchi_dll_a2.o \ -inchi_dll_b.o \ -ixa_inchikey_builder.o \ -ixa_read_mol.o \ -ixa_status.o \ -ixa_builder.o \ -ixa_mol.o \ -ixa_read_inchi.o \ -mol_fmt1.o \ -mol_fmt2.o \ -mol_fmt3.o \ -mol2atom.o \ -mol_fmt4.o \ -readinch.o \ -runichi.o \ -runichi2.o \ -runichi3.o \ -runichi4.o \ -sha2.o \ -strutil.o \ -util.o \ -bcf_s.o -# === InChI Library link rule ========= -ifeq ($(OS_ID),0) -# djb-rwth: creating .dll on Windows -$(INCHI_LIB_PATHNAME).dll$(VERSION): $(INCHI_LIB_OBJS) - $(SHARED_LINK) $(SHARED_LINK_PARM) -o $(INCHI_LIB_PATHNAME).dll$(VERSION) \ -$(INCHI_LIB_OBJS) -Wl$(LINUX_MAP),-soname,$(INCHI_LIB_NAME).dll$(VERSION) -Wl,--subsystem,windows -lm -else ifeq ($(OS_ID), 2) -# jwm: creating .dylib on OS X -$(INCHI_LIB_PATHNAME).dylib$(VERSION): $(INCHI_LIB_OBJS) - $(SHARED_LINK) $(SHARED_LINK_PARM) -o $(INCHI_LIB_PATHNAME).dylib$(VERSION) \ -$(INCHI_LIB_OBJS) -Wl$(LINUX_MAP)$(LINUX_Z_RELRO) -install_name $(INCHI_LIB_NAME).dylib$(VERSION) -lm -else -# djb-rwth: creating .so on Linux -$(INCHI_LIB_PATHNAME).so$(VERSION): $(INCHI_LIB_OBJS) - $(SHARED_LINK) $(SHARED_LINK_PARM) -o $(INCHI_LIB_PATHNAME).so$(VERSION) \ -$(INCHI_LIB_OBJS) -Wl$(LINUX_MAP)$(LINUX_Z_RELRO),-soname,$(INCHI_LIB_NAME).so$(VERSION) -lm -endif -# djb-rwth: no forceful linking is required if .so version extensions are the same -# ln -fs $(INCHI_LIB_NAME).so$(VERSION) \ -$(INCHI_LIB_PATHNAME).so$(MAIN_VERSION) -# === InChI Library compile rule ========= -%.o: $(P_LIBR)%.c - $(C_COMPILER) $(C_SO_OPTIONS) $(C_OPTIONS) $< -%.o: $(P_LIBR_IXA)%.c - $(C_COMPILER) $(C_SO_OPTIONS) $(C_OPTIONS) $< -%.o: $(P_BASE)%.c - $(C_COMPILER) $(C_SO_OPTIONS) $(C_OPTIONS) $< -else -$(info GCC or Clang not detected. Please edit makefile in order to include available C compiler. Terminating.) -$(info ) +# Comment out the next line to create so/dll only +#CREATE_MAIN = 1 +# Comment out the next line to create mol2inchi executable (otherwise, inchi_maiin is created) +#CALLER_IS_MOL2INCHI = 1 +# djb-rwth: detecting the OS in Makefile -- no need to specify ISLINUX externally; OS can also be defined in command line: e.g. make OS_ID=1 +ifeq ($(OS),Windows_NT) + OS_ID := 0 +else + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S),Linux) + OS_ID := 1 + endif + ifeq ($(UNAME_S),Darwin) + OS_ID := 2 + endif + ifeq ($(UNAME_S),FreeBSD) + OS_ID := 3 + endif +# djb-rwth: other OSs should be numbered accordingly +endif +# djb-rwth: checking the presence on GCC and Clang/LLVM +GCC_CHECK := $(shell gcc --version) +CLANG_CHECK := $(shell clang --version) +ifneq ($(GCC_CHECK),) + GCC_DETECTED := 1 + CCN = 1 +endif +ifneq ($(CLANG_CHECK),) + CLANG_DETECTED := 1 + CCN = 2 +endif +ifeq ($(CCN),$(filter $(CCN),1 2)) +# djb-rwth: Choosing the compiler if both GCC and Clang/LLVM are detected +ifeq ($(GCC_DETECTED),1) +ifeq ($(CLANG_DETECTED),1) +# djb-rwth: Choose C compiler if both GCC and Clang are detected -- CCN = 1 for GCC, CCN = 2 for Clang/LLVM +CCN = 1 +endif +endif +# === C Compiler =============== +ifndef C_COMPILER +ifeq ($(CCN),2) +C_COMPILER = clang +$(info Both GCC and Clang/LLVM detected. Compiling with Clang(++) -- please edit makefile to compile with GCC.) +$(info ) +else +ifeq ($(OS_ID),0) +C_COMPILER = gcc -static +else +C_COMPILER = gcc +endif +$(info Both GCC and Clang/LLVM detected. Compiling with GCC/G++ (default) -- please edit makefile to compile with Clang/LLVM.) +$(info ) +endif +endif +# Linux fpic option: replace -fPIC with -fpic if the latter works +# Comment out "LINUX_Z_RELRO =" if -z relro is not supported +# These options are needed to avoid the following SELinux message: +# "Error: cannot restore segment prot after reloc: Permission denied" +# In addition, inchi.map restricts set of expoorted from .so +# functions to those which belong to InChI API +ifneq ($(OS_ID),2) + LINUX_MAP = ,--version-script=libinchi.map + LINUX_Z_RELRO = ,-z,relro +endif +ifneq ($(OS_ID),0) + LINUX_FPIC = -fPIC +# === version === + MAIN_VERSION = .1 + VERSION = $(MAIN_VERSION).07 +endif +# === executable & library directory === +ifndef LIB_DIR + LIB_DIR = ../../bin/Linux +endif +# === InChI Library name === +ifndef INCHI_LIB_NAME + INCHI_LIB_NAME = libinchi +endif +INCHI_LIB_PATHNAME = $(LIB_DIR)/$(INCHI_LIB_NAME) +# === Main program name ==== +ifndef API_CALLER_NAME + ifndef CALLER_IS_MOL2INCHI + API_CALLER_NAME = inchi_main + else + API_CALLER_NAME = mol2inchi + endif +endif +API_CALLER_PATHNAME = $(LIB_DIR)/$(API_CALLER_NAME) +# === Linker to create (Shared) InChI library ==== +ifndef SHARED_LINK + SHARED_LINK = $(C_COMPILER) -shared +endif +# === Linker to create Main program ===== +ifndef LINKER + ifdef OS_ID +# or: ifeq ($(OS_ID),$(filter $(OS_ID),0 1 2 3)) +# djb-rwth: avoiding the use of LD_LIBRARY_PATH by adding LIB_DIR to runtime library search path + LINKER_CWD_PATH = -Wl,-R,"",-rpath=$(LIB_DIR) + endif + LINKER = $(C_COMPILER) -s $(LINKER_CWD_PATH) +endif +# djb-rwth: space for shared link parameters SHARED_LINK_PARMS +ifndef P_LIBR + P_LIBR = ../../libinchi/src/ +endif +ifndef P_LIBR_IXA + P_LIBR_IXA = ../../libinchi/src/ixa/ +endif +ifndef P_BASE + P_BASE = ../../../INCHI_BASE/src/ +endif +ifndef P_MAIN + ifndef CALLER_IS_MOL2INCHI + P_MAIN = ../src/ + else + P_MAIN = ../src/ + endif +endif +# === C Compiler Options ======= +ifndef C_OPTIONS + ifndef CALLER_IS_MOL2INCHI + C_OPTIONS = -std=c11 -ansi -O1 -c -fno-strict-aliasing + else + C_OPTIONS = -std=c11 -O1 -c -fno-strict-aliasing + endif + ifneq ($(OS_ID),0) + ifndef C_SO_OPTIONS + C_SO_OPTIONS = $(LINUX_FPIC) -DTARGET_API_LIB -DCOMPILE_ANSI_ONLY + endif + else + ifndef C_SO_OPTIONS + C_SO_OPTIONS = -DBUILD_LINK_AS_DLL -DTARGET_API_LIB + endif + endif + ifndef C_MAIN_OPTIONS + C_MAIN_OPTIONS = -DBUILD_LINK_AS_DLL -DTARGET_EXE_USING_API + endif +endif +ifdef CREATE_MAIN +ifndef CALLER_IS_MOL2INCHI +API_CALLER_SRCS = $(P_MAIN)e_0dstereo.c \ +$(P_MAIN)e_ichimain.c \ +$(P_MAIN)e_ichi_io.c \ +$(P_MAIN)e_ichi_parms.c \ +$(P_MAIN)e_inchi_atom.c \ +$(P_MAIN)e_mol2atom.c \ +$(P_MAIN)e_readinch.c \ +$(P_MAIN)e_readmol.c \ +$(P_MAIN)e_readstru.c \ +$(P_MAIN)e_util.c \ +$(P_MAIN)e_ichimain_a.c +API_CALLER_OBJS = e_0dstereo.o \ +e_ichimain.o \ +e_ichi_io.o \ +e_ichi_parms.o \ +e_inchi_atom.o \ +e_mol2atom.o \ +e_readinch.o \ +e_readmol.o \ +e_readstru.o \ +e_util.o \ +e_ichimain_a.o +else +API_CALLER_SRCS = $(P_MAIN)mol2inchi.c \ +$(P_MAIN)getcputime.c \ +$(P_MAIN)moreutil.c +API_CALLER_OBJS = mol2inchi.o \ +getcputime.o \ +moreutil.o +endif +# === InChI Main Link rule ================ +ifeq ($(OS_ID),0) +# djb-rwth: linking to .dll on Windows +$(API_CALLER_PATHNAME) : $(API_CALLER_OBJS) $(INCHI_LIB_PATHNAME).dll$(VERSION) + $(LINKER) -o $(API_CALLER_PATHNAME) $(API_CALLER_OBJS) \ +$(INCHI_LIB_PATHNAME).dll$(VERSION) -lm +else ifeq ($(OS_ID),2) +# jwm: linking to .dylib on OS X +$(API_CALLER_PATHNAME) : $(API_CALLER_OBJS) $(INCHI_LIB_PATHNAME).so$(VERSION) + $(LINKER) -o $(API_CALLER_PATHNAME) $(API_CALLER_OBJS) \ +$(INCHI_LIB_PATHNAME)$(VERSION).dylib -lm +else +# djb-rwth: linking to .so on Linux +$(API_CALLER_PATHNAME) : $(API_CALLER_OBJS) $(INCHI_LIB_PATHNAME).so$(VERSION) + $(LINKER) -o $(API_CALLER_PATHNAME) $(API_CALLER_OBJS) \ +$(INCHI_LIB_PATHNAME).so$(VERSION) -lm +endif +# === InChI Main compile rule ============ +%.o: $(P_MAIN)%.c + $(C_COMPILER) $(C_MAIN_OPTIONS) $(C_OPTIONS) $< +endif +# === InChI Library Object files ============ +INCHI_LIB_OBJS = ichican2.o \ +ichicano.o \ +ichi_io.o \ +ichierr.o \ +ichicans.o \ +ichiisot.o \ +ichilnct.o \ +ichimak2.o \ +ichimake.o \ +ichimap1.o \ +ichimap2.o \ +ichimap4.o \ +ichinorm.o \ +ichiparm.o \ +ichiprt1.o \ +ichiprt2.o \ +ichiprt3.o \ +ichiqueu.o \ +ichiring.o \ +ichisort.o \ +ichister.o \ +ichitaut.o \ +ichi_bns.o \ +inchi_dll.o \ +ichiread.o \ +ichirvr1.o \ +ichirvr2.o \ +ichirvr3.o \ +ichirvr4.o \ +ichirvr5.o \ +ichirvr6.o \ +ichirvr7.o \ +ikey_dll.o \ +ikey_base26.o \ +inchi_dll_main.o \ +inchi_dll_a.o \ +inchi_dll_a2.o \ +inchi_dll_b.o \ +ixa_inchikey_builder.o \ +ixa_read_mol.o \ +ixa_status.o \ +ixa_builder.o \ +ixa_mol.o \ +ixa_read_inchi.o \ +mol_fmt1.o \ +mol_fmt2.o \ +mol_fmt3.o \ +mol2atom.o \ +mol_fmt4.o \ +readinch.o \ +runichi.o \ +runichi2.o \ +runichi3.o \ +runichi4.o \ +sha2.o \ +strutil.o \ +util.o \ +bcf_s.o +# === InChI Library link rule ========= +ifeq ($(OS_ID),0) +# djb-rwth: creating .dll on Windows +$(INCHI_LIB_PATHNAME).dll$(VERSION): $(INCHI_LIB_OBJS) + $(SHARED_LINK) $(SHARED_LINK_PARM) -o $(INCHI_LIB_PATHNAME).dll$(VERSION) \ +$(INCHI_LIB_OBJS) -Wl$(LINUX_MAP),-soname,$(INCHI_LIB_NAME).dll$(VERSION) -Wl,--subsystem,windows -lm +else ifeq ($(OS_ID), 2) +# jwm: creating .dylib on OS X +$(INCHI_LIB_PATHNAME)$(VERSION).dylib: $(INCHI_LIB_OBJS) + $(SHARED_LINK) $(SHARED_LINK_PARM) -o $(INCHI_LIB_PATHNAME)$(VERSION).dylib \ +$(INCHI_LIB_OBJS) -Wl$(LINUX_MAP)$(LINUX_Z_RELRO) -install_name $(INCHI_LIB_NAME)$(VERSION).dylib -lm +else +# djb-rwth: creating .so on Linux +$(INCHI_LIB_PATHNAME).so$(VERSION): $(INCHI_LIB_OBJS) + $(SHARED_LINK) $(SHARED_LINK_PARM) -o $(INCHI_LIB_PATHNAME).so$(VERSION) \ +$(INCHI_LIB_OBJS) -Wl$(LINUX_MAP)$(LINUX_Z_RELRO),-soname,$(INCHI_LIB_NAME).so$(VERSION) -lm +endif +# djb-rwth: no forceful linking is required if .so version extensions are the same +# ln -fs $(INCHI_LIB_NAME).so$(VERSION) \ +$(INCHI_LIB_PATHNAME).so$(MAIN_VERSION) +# === InChI Library compile rule ========= +%.o: $(P_LIBR)%.c + $(C_COMPILER) $(C_SO_OPTIONS) $(C_OPTIONS) $< +%.o: $(P_LIBR_IXA)%.c + $(C_COMPILER) $(C_SO_OPTIONS) $(C_OPTIONS) $< +%.o: $(P_BASE)%.c + $(C_COMPILER) $(C_SO_OPTIONS) $(C_OPTIONS) $< +else +$(info GCC or Clang not detected. Please edit makefile in order to include available C compiler. Terminating.) +$(info ) endif \ No newline at end of file diff --git a/INCHI-1-SRC/INCHI_API/libinchi/gcc/makefile32 b/INCHI-1-SRC/INCHI_API/libinchi/gcc/makefile32 index 864f8798..2d33da8a 100644 --- a/INCHI-1-SRC/INCHI_API/libinchi/gcc/makefile32 +++ b/INCHI-1-SRC/INCHI_API/libinchi/gcc/makefile32 @@ -37,18 +37,26 @@ ifeq ($(CCN),$(filter $(CCN),1 2)) ifeq ($(GCC_DETECTED),1) ifeq ($(CLANG_DETECTED),1) # djb-rwth: Choose C compiler if both GCC and Clang are detected -- CCN = 1 for GCC, CCN = 2 for Clang/LLVM -CCN = 1 +CCN = 2 endif endif # === C Compiler =============== ifndef C_COMPILER ifeq ($(CCN),2) +ifeq ($(OS_ID),0) +C_COMPILER = clang -static +else C_COMPILER = clang -$(info Both GCC and Clang/LLVM detected. Compiling with Clang -- please edit makefile to compile with GCC.) +endif +$(info Both GCC and Clang/LLVM detected. Compiling with Clang(++) -- please edit makefile to compile with GCC.) $(info ) else +ifeq ($(OS_ID),0) +C_COMPILER = gcc -static +else C_COMPILER = gcc -$(info Both GCC and Clang/LLVM detected. Compiling with GCC (default) -- please edit makefile to compile with Clang/LLVM.) +endif +$(info Both GCC and Clang/LLVM detected. Compiling with GCC/G++ (default) -- please edit makefile to compile with Clang/LLVM.) $(info ) endif endif @@ -116,9 +124,9 @@ endif # === C Compiler Options ======= ifndef C_OPTIONS ifndef CALLER_IS_MOL2INCHI - C_OPTIONS = -std=c11 -m32 -ansi -O2 -c -fno-strict-aliasing + C_OPTIONS = -std=c11 -m32 -ansi -O1 -c -fno-strict-aliasing else - C_OPTIONS = -std=c11 -m32 -O2 -c -fno-strict-aliasing + C_OPTIONS = -std=c11 -m32 -O1 -c -fno-strict-aliasing endif ifneq ($(OS_ID),0) ifndef C_SO_OPTIONS diff --git a/INCHI-1-SRC/INCHI_API/libinchi/src/inchi_dll.c b/INCHI-1-SRC/INCHI_API/libinchi/src/inchi_dll.c index df3fad9f..bdb2a675 100644 --- a/INCHI-1-SRC/INCHI_API/libinchi/src/inchi_dll.c +++ b/INCHI-1-SRC/INCHI_API/libinchi/src/inchi_dll.c @@ -2698,7 +2698,7 @@ int INCHI_DECL GetStructFromINCHIEx( inchi_InputINCHI *inpInChI, outStruct->szMessage, MAX_MSG_LEN, outStruct->WarningFlags ); - if (nRet >= 0 && polymer && at && ((num_at > 0) && (num_at < at_size_check1))) /* djb-rwth: fixing oss-fuzz issue #68329, #68286 */ + if (nRet >= 0 && polymer && at && (num_at > 0)) /* djb-rwth: fixing oss-fuzz issue #68329, #68286 */ { OAD_Polymer_SmartReopenCyclizedUnits( polymer, at, num_at, &num_bonds ); diff --git a/INCHI-1-SRC/INCHI_API/libinchi/vc14/djb-rwth.ruleset b/INCHI-1-SRC/INCHI_API/libinchi/vc14/djb-rwth.ruleset index 6aa4748c..a56d9ae2 100644 --- a/INCHI-1-SRC/INCHI_API/libinchi/vc14/djb-rwth.ruleset +++ b/INCHI-1-SRC/INCHI_API/libinchi/vc14/djb-rwth.ruleset @@ -1,10 +1,10 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/INCHI-1-SRC/INCHI_API/libinchi/vc14/libinchi.vcxproj b/INCHI-1-SRC/INCHI_API/libinchi/vc14/libinchi.vcxproj index 8c94437a..772b6ca0 100644 --- a/INCHI-1-SRC/INCHI_API/libinchi/vc14/libinchi.vcxproj +++ b/INCHI-1-SRC/INCHI_API/libinchi/vc14/libinchi.vcxproj @@ -1,327 +1,327 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {5DAB1696-1795-49AA-BDE6-1771FBE25445} - inchi_dll - Win32Proj - 10.0 - - - - DynamicLibrary - v143 - Unicode - true - - - DynamicLibrary - v143 - NotSet - true - - - DynamicLibrary - v143 - NotSet - true - - - DynamicLibrary - v143 - NotSet - true - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>14.0.25431.1 - - - ../../bin2/Windows/$(Platform)/$(Configuration)/ - ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ - false - $(VC_IncludePath);$(WindowsSDK_IncludePath); - $(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86) - - - ../../bin2/Windows/$(Platform)/$(Configuration)/ - ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ - false - $(VC_IncludePath);$(WindowsSDK_IncludePath); - $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64) - NativeRecommendedRules.ruleset - - - ../../bin2/Windows/$(Platform)/$(Configuration)/ - ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ - false - $(IncludePath) - $(LibraryPath) - - - ../../bin2/Windows/$(Platform)/$(Configuration)/ - ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ - false - $(VC_IncludePath);$(WindowsSDK_IncludePath); - $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64) - - - - MaxSpeed - _WINDOWS;_MBCS;_USRDLL;BUILD_LINK_AS_DLL;TARGET_API_LIB=1;%(PreprocessorDefinitions) - false - Default - MultiThreadedDebugDLL - - Level3 - ProgramDatabase - Default - - true - true - - - ../../bin2/Windows/$(Platform)/$(Configuration)/libinchi.dll - - - true - Windows - 16000000 - MachineX86 - - - true - true - - - - - X64 - - - MaxSpeed - _WINDOWS;_MBCS;_USRDLL;BUILD_LINK_AS_DLL;TARGET_API_LIB=1; COMPILE_ADD_NON_ANSI_FUNCTIONS;%(PreprocessorDefinitions) - false - Default - MultiThreadedDebugDLL - - Level3 - ProgramDatabase - true - - - true - true - - - ../../bin2/Windows/$(Platform)/$(Configuration)/libinchi.dll - - - true - Windows - 16000000 - MachineX64 - - - true - true - - - - - MaxSpeed - true - _WINDOWS;_MBCS;_USRDLL;BUILD_LINK_AS_DLL;TARGET_API_LIB=1; COMPILE_ADD_NON_ANSI_FUNCTIONS;%(PreprocessorDefinitions) - MultiThreaded - true - - Level3 - ProgramDatabase - Default - - - - ../../bin2/Windows/$(Platform)/$(Configuration)/libinchi.dll - - - true - Windows - 16000000 - true - true - MachineX86 - - - - - - - X64 - - - MaxSpeed - true - _WINDOWS;_MBCS;_USRDLL;BUILD_LINK_AS_DLL;TARGET_API_LIB=1; COMPILE_ADD_NON_ANSI_FUNCTIONS;%(PreprocessorDefinitions) - MultiThreaded - true - - Level3 - ProgramDatabase - - - ../../bin2/Windows/$(Platform)/$(Configuration)/libinchi.dll - - - true - Windows - 16000000 - true - true - MachineX64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {5DAB1696-1795-49AA-BDE6-1771FBE25445} + inchi_dll + Win32Proj + 10.0 + + + + DynamicLibrary + v143 + Unicode + true + + + DynamicLibrary + v143 + NotSet + true + + + DynamicLibrary + v143 + NotSet + true + + + DynamicLibrary + v143 + NotSet + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>14.0.25431.1 + + + ../../bin2/Windows/$(Platform)/$(Configuration)/ + ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ + false + $(VC_IncludePath);$(WindowsSDK_IncludePath); + $(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86) + + + ../../bin2/Windows/$(Platform)/$(Configuration)/ + ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ + false + $(VC_IncludePath);$(WindowsSDK_IncludePath); + $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64) + NativeRecommendedRules.ruleset + + + ../../bin2/Windows/$(Platform)/$(Configuration)/ + ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ + false + $(IncludePath) + $(LibraryPath) + + + ../../bin2/Windows/$(Platform)/$(Configuration)/ + ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ + false + $(VC_IncludePath);$(WindowsSDK_IncludePath); + $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64) + + + + MaxSpeed + _WINDOWS;_MBCS;_USRDLL;BUILD_LINK_AS_DLL;TARGET_API_LIB=1;%(PreprocessorDefinitions) + false + Default + MultiThreadedDebugDLL + + Level3 + ProgramDatabase + Default + + true + true + + + ../../bin2/Windows/$(Platform)/$(Configuration)/libinchi.dll + + + true + Windows + 16000000 + MachineX86 + + + true + true + + + + + X64 + + + MaxSpeed + _WINDOWS;_MBCS;_USRDLL;BUILD_LINK_AS_DLL;TARGET_API_LIB=1; COMPILE_ADD_NON_ANSI_FUNCTIONS;%(PreprocessorDefinitions) + false + Default + MultiThreadedDebugDLL + + Level3 + ProgramDatabase + true + + + true + true + + + ../../bin2/Windows/$(Platform)/$(Configuration)/libinchi.dll + + + true + Windows + 16000000 + MachineX64 + + + true + true + + + + + MaxSpeed + true + _WINDOWS;_MBCS;_USRDLL;BUILD_LINK_AS_DLL;TARGET_API_LIB=1; COMPILE_ADD_NON_ANSI_FUNCTIONS;%(PreprocessorDefinitions) + MultiThreaded + true + + Level3 + ProgramDatabase + Default + + + + ../../bin2/Windows/$(Platform)/$(Configuration)/libinchi.dll + + + true + Windows + 16000000 + true + true + MachineX86 + + + + + + + X64 + + + MaxSpeed + true + _WINDOWS;_MBCS;_USRDLL;BUILD_LINK_AS_DLL;TARGET_API_LIB=1; COMPILE_ADD_NON_ANSI_FUNCTIONS;%(PreprocessorDefinitions) + MultiThreaded + true + + Level3 + ProgramDatabase + + + ../../bin2/Windows/$(Platform)/$(Configuration)/libinchi.dll + + + true + Windows + 16000000 + true + true + MachineX64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/INCHI-1-SRC/INCHI_API/libinchi/vc14/libinchi.vcxproj.user b/INCHI-1-SRC/INCHI_API/libinchi/vc14/libinchi.vcxproj.user index 0f14913f..88a55094 100644 --- a/INCHI-1-SRC/INCHI_API/libinchi/vc14/libinchi.vcxproj.user +++ b/INCHI-1-SRC/INCHI_API/libinchi/vc14/libinchi.vcxproj.user @@ -1,4 +1,4 @@ - - - + + + \ No newline at end of file diff --git a/INCHI-1-SRC/INCHI_BASE/src/bcf_s.h b/INCHI-1-SRC/INCHI_BASE/src/bcf_s.h index 0a14c85b..f52d5458 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/bcf_s.h +++ b/INCHI-1-SRC/INCHI_BASE/src/bcf_s.h @@ -49,6 +49,8 @@ #include #include +#define CURRENT_VER "1.07.2" /* djb-rwth: full version number in the output, required for fixing GHI #61 */ + #ifdef __STDC_LIB_EXT1__ #if (__STDC_LIB_EXT1__ >= 201112L) #define USE_BCF_GCC 1 /* djb-rwth: use bounds-checking functions / C11 Annex K */ @@ -66,17 +68,10 @@ #endif /* djb-rwth: control macros */ -/* #define GCC_DEBUG 0 djb-rwth: required for GCC 12+ vs GCC 11- debugging */ #define RINCHI_TEST 0 /* djb-rwrh: RInChI testing */ /* djb-rwth: custom functions */ int max_3(int a, int b, int c); int memcpy_custom(char** dst, char* src, unsigned long long len); -/* djb-rwth: external variables required for oss-fuzz fixes */ -extern int at_size_check1; /* djb-rwth: required for fixing oss-fuzz issue #68329 */ -extern int sminor_size; /* djb-rwth: required for fixing oss-fuzz issue #66746 */ -extern int na_global; /* djb-rwth: required for fixing oss-fuzz issues #69965, #69315 */ -extern int sp_at_size; /* djb-rwth: required for fixing oss-fuzz issue #69656 */ - #endif \ No newline at end of file diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichi_bns.c b/INCHI-1-SRC/INCHI_BASE/src/ichi_bns.c index 8a344cb9..12fc1ab3 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichi_bns.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichi_bns.c @@ -5269,6 +5269,7 @@ int mark_alt_bonds_and_taut_groups( struct tagINCHI_CLOCK *ic, #ifdef FIX_AROM_RADICAL /* Added 2011-05-09 IPl */ int i, n_arom_radicals = 0, *stored_radicals = NULL; #endif + int at_prot; /* moved from below 2024-09-01 DT */ nChanges = 0; bError = 0; @@ -5278,7 +5279,6 @@ int mark_alt_bonds_and_taut_groups( struct tagINCHI_CLOCK *ic, memset( pAATG, 0, sizeof( *pAATG ) ); /* djb-rwth: memset_s C11/Annex K variant? */ /*(@nnuk : Nauman Ullah Khan) :: Variable for checking (De)protonation status */ - int at_prot; LOG_NO_ARGS("\n############# Initial state before (De)Protonation (L5373:ichi_bns.c) ###############\n"); for (at_prot = 0; at_prot < num_atoms; at_prot++) { diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichi_io.c b/INCHI-1-SRC/INCHI_BASE/src/ichi_io.c index a34623e5..506c8cfa 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichi_io.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichi_io.c @@ -58,20 +58,20 @@ #endif #ifdef TARGET_LIB_FOR_WINCHI -extern void( *FWPRINT ) ( const char * format, va_list argptr ); -extern void( *FWPUSH ) ( const char *s ); +extern void(*FWPRINT) (const char* format, va_list argptr); +extern void(*FWPUSH) (const char* s); #endif /* Internal functions */ -int inchi_ios_str_getc( INCHI_IOSTREAM *ios ); -char *inchi_ios_str_gets( char *szLine, int len, INCHI_IOSTREAM *ios ); -char *inchi_ios_str_getsTab( char *szLine, int len, INCHI_IOSTREAM *ios ); -int GetMaxPrintfLength( const char *lpszFormat, va_list argList ); -char *inchi_fgetsTab( char *szLine, int len, FILE *f ); -int inchi_vfprintf( FILE* f, const char* lpszFormat, va_list argList ); +int inchi_ios_str_getc(INCHI_IOSTREAM* ios); +char* inchi_ios_str_gets(char* szLine, int len, INCHI_IOSTREAM* ios); +char* inchi_ios_str_getsTab(char* szLine, int len, INCHI_IOSTREAM* ios); +int GetMaxPrintfLength(const char* lpszFormat, va_list argList); +char* inchi_fgetsTab(char* szLine, int len, FILE* f); +int inchi_vfprintf(FILE* f, const char* lpszFormat, va_list argList); /* @@ -82,18 +82,18 @@ int inchi_vfprintf( FILE* f, const char* lpszFormat, va_list argList ); /**************************************************************************** Init INCHI_IOSTREAM ****************************************************************************/ -void inchi_ios_init( INCHI_IOSTREAM* ios, int io_type, FILE *f ) +void inchi_ios_init(INCHI_IOSTREAM* ios, int io_type, FILE* f) { - memset( ios, 0, sizeof( *ios ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(ios, 0, sizeof(*ios)); /* djb-rwth: memset_s C11/Annex K variant? */ switch (io_type) { - case INCHI_IOS_TYPE_FILE: - ios->type = INCHI_IOS_TYPE_FILE; - break; - case INCHI_IOS_TYPE_STRING: - default: - ios->type = INCHI_IOS_TYPE_STRING; - break; + case INCHI_IOS_TYPE_FILE: + ios->type = INCHI_IOS_TYPE_FILE; + break; + case INCHI_IOS_TYPE_STRING: + default: + ios->type = INCHI_IOS_TYPE_STRING; + break; } ios->f = f; return; @@ -103,11 +103,11 @@ void inchi_ios_init( INCHI_IOSTREAM* ios, int io_type, FILE *f ) /**************************************************************************** Make a copy of INCHI_IOSTREAM ****************************************************************************/ -int inchi_ios_create_copy( INCHI_IOSTREAM* ios, INCHI_IOSTREAM* ios0 ) +int inchi_ios_create_copy(INCHI_IOSTREAM* ios, INCHI_IOSTREAM* ios0) { if (ios) /* djb-rwth: fixing a NULL pointer dereference */ { - memset( ios, 0, sizeof( *ios ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(ios, 0, sizeof(*ios)); /* djb-rwth: memset_s C11/Annex K variant? */ ios->type = ios0->type; if (ios->type == INCHI_IOS_TYPE_STRING) @@ -129,7 +129,7 @@ int inchi_ios_create_copy( INCHI_IOSTREAM* ios, INCHI_IOSTREAM* ios0 ) } ios->f = ios0->f; } - + return 0; } @@ -141,7 +141,7 @@ int inchi_ios_create_copy( INCHI_IOSTREAM* ios, INCHI_IOSTREAM* ios0 ) If INCHI_IOSTREAM type is INCHI_IOS_TYPE_FILE, just flush the file. ****************************************************************************/ -void inchi_ios_flush( INCHI_IOSTREAM* ios ) +void inchi_ios_flush(INCHI_IOSTREAM* ios) { if (ios->type == INCHI_IOS_TYPE_STRING) @@ -152,10 +152,10 @@ void inchi_ios_flush( INCHI_IOSTREAM* ios ) { if (ios->f) { - fprintf( ios->f, "%-s", ios->s.pStr ); - fflush( ios->f ); + fprintf(ios->f, "%-s", ios->s.pStr); + fflush(ios->f); } - inchi_free( ios->s.pStr ); + inchi_free(ios->s.pStr); ios->s.pStr = NULL; ios->s.nUsedLength = ios->s.nAllocatedLength = ios->s.nPtr = 0; } @@ -165,7 +165,7 @@ void inchi_ios_flush( INCHI_IOSTREAM* ios ) else if (ios->type == INCHI_IOS_TYPE_FILE) { /* output to plain file: just flush it. */ - fflush( ios->f ); + fflush(ios->f); } return; @@ -180,7 +180,7 @@ void inchi_ios_flush( INCHI_IOSTREAM* ios ) If INCHI_IOSTREAM type is INCHI_IOS_TYPE_FILE, just flush the both files. ****************************************************************************/ -void inchi_ios_flush2( INCHI_IOSTREAM* ios, FILE *f2 ) +void inchi_ios_flush2(INCHI_IOSTREAM* ios, FILE* f2) { if (ios->type == INCHI_IOS_TYPE_STRING) @@ -191,15 +191,15 @@ void inchi_ios_flush2( INCHI_IOSTREAM* ios, FILE *f2 ) { if (ios->f) { - fprintf( ios->f, "%-s", ios->s.pStr ); - fflush( ios->f ); + fprintf(ios->f, "%-s", ios->s.pStr); + fflush(ios->f); } if (f2 != ios->f) { - fprintf( f2, "%-s", ios->s.pStr ); + fprintf(f2, "%-s", ios->s.pStr); } - inchi_free( ios->s.pStr ); + inchi_free(ios->s.pStr); ios->s.pStr = NULL; ios->s.nUsedLength = ios->s.nAllocatedLength = ios->s.nPtr = 0; } @@ -209,13 +209,13 @@ void inchi_ios_flush2( INCHI_IOSTREAM* ios, FILE *f2 ) else if (ios->type == INCHI_IOS_TYPE_FILE) { /* Output to plain file: just flush it. */ - if (( ios->f ) && ( ios->f != stderr ) && ( ios->f != stdout )) + if ((ios->f) && (ios->f != stderr) && (ios->f != stdout)) { - fflush( ios->f ); + fflush(ios->f); } if (f2 && f2 != stderr && f2 != stdout) { - fflush( f2 ); + fflush(f2); } } @@ -226,7 +226,7 @@ void inchi_ios_flush2( INCHI_IOSTREAM* ios, FILE *f2 ) /**************************************************************************** Close INCHI_IOSTREAM: free string buffer and close associated file. ****************************************************************************/ -void inchi_ios_close( INCHI_IOSTREAM* ios ) +void inchi_ios_close(INCHI_IOSTREAM* ios) { if (NULL == ios) { @@ -234,14 +234,14 @@ void inchi_ios_close( INCHI_IOSTREAM* ios ) } if (ios->s.pStr) { - inchi_free( ios->s.pStr ); + inchi_free(ios->s.pStr); } ios->s.pStr = NULL; ios->s.nUsedLength = ios->s.nAllocatedLength = ios->s.nPtr = 0; if (NULL != ios->f && stdout != ios->f && stderr != ios->f && stdin != ios->f) { - fclose( ios->f ); + fclose(ios->f); } return; @@ -252,13 +252,13 @@ void inchi_ios_close( INCHI_IOSTREAM* ios ) Reset INCHI_IOSTREAM: set string buffer ptr to NULL (but do _not_ free memory)and close associated file. ****************************************************************************/ -void inchi_ios_reset( INCHI_IOSTREAM* ios ) +void inchi_ios_reset(INCHI_IOSTREAM* ios) { ios->s.pStr = NULL; ios->s.nUsedLength = ios->s.nAllocatedLength = ios->s.nPtr = 0; if (NULL != ios->f && stdout != ios->f && stderr != ios->f && stdin != ios->f) { - fclose( ios->f ); + fclose(ios->f); } return; @@ -269,7 +269,7 @@ void inchi_ios_reset( INCHI_IOSTREAM* ios ) Reset INCHI_IOSTREAM: set string buffer ptr to NULL (after freeing memory) but do not close associated file. ****************************************************************************/ -void inchi_ios_free_str( INCHI_IOSTREAM *ios ) +void inchi_ios_free_str(INCHI_IOSTREAM* ios) { if (NULL == ios) { @@ -291,22 +291,22 @@ void inchi_ios_free_str( INCHI_IOSTREAM *ios ) /**************************************************************************** [str] getc() ****************************************************************************/ -int inchi_ios_str_getc( INCHI_IOSTREAM *ios ) +int inchi_ios_str_getc(INCHI_IOSTREAM* ios) { int c; if (ios->type == INCHI_IOS_TYPE_STRING) { if (ios->s.nPtr < ios->s.nUsedLength) { - return (int) ios->s.pStr[ios->s.nPtr++]; + return (int)ios->s.pStr[ios->s.nPtr++]; } return EOF; } else if (ios->type == INCHI_IOS_TYPE_FILE) { - c = fgetc( ios->f ); - if (ferror( ios->f )) + c = fgetc(ios->f); + if (ferror(ios->f)) { c = EOF; } @@ -321,16 +321,16 @@ int inchi_ios_str_getc( INCHI_IOSTREAM *ios ) /**************************************************************************** [str] gets() ****************************************************************************/ -char *inchi_ios_str_gets( char *szLine, int len, INCHI_IOSTREAM *f ) +char* inchi_ios_str_gets(char* szLine, int len, INCHI_IOSTREAM* f) { int length = 0, c = 0; if (--len < 0) { return NULL; } - while (length < len && EOF != ( c = inchi_ios_str_getc( f ) )) + while (length < len && EOF != (c = inchi_ios_str_getc(f))) { - szLine[length++] = (char) c; + szLine[length++] = (char)c; if (c == '\n') { break; @@ -351,20 +351,20 @@ char *inchi_ios_str_gets( char *szLine, int len, INCHI_IOSTREAM *f ) remove leading and trailing white spaces; keep zero termination ****************************************************************************/ -char *inchi_ios_str_getsTab( char *szLine, int len, INCHI_IOSTREAM *f ) +char* inchi_ios_str_getsTab(char* szLine, int len, INCHI_IOSTREAM* f) { int length = 0, c = 0; if (--len < 0) { return NULL; } - while (length < len && EOF != ( c = inchi_ios_str_getc( f ) )) + while (length < len && EOF != (c = inchi_ios_str_getc(f))) { if (c == '\t') { c = '\n'; } - szLine[length++] = (char) c; + szLine[length++] = (char)c; if (c == '\n') { break; @@ -383,16 +383,16 @@ char *inchi_ios_str_getsTab( char *szLine, int len, INCHI_IOSTREAM *f ) /**************************************************************************** gets() ****************************************************************************/ -int inchi_ios_gets( char *szLine, - int len, - INCHI_IOSTREAM *f, - int *bTooLongLine ) +int inchi_ios_gets(char* szLine, + int len, + INCHI_IOSTREAM* f, + int* bTooLongLine) { int length; - char *p; + char* p; do { - p = inchi_ios_str_gets( szLine, len - 1, f ); + p = inchi_ios_str_gets(szLine, len - 1, f); if (!p) { *bTooLongLine = 0; @@ -402,11 +402,10 @@ int inchi_ios_gets( char *szLine, /* *bTooLongLine = !strchr( szLine, '\n' ); */ - p = strchr( szLine, '\n' ); - *bTooLongLine = ( !p && ( (int) strlen( szLine ) ) == len - 2 ); - lrtrim( szLine, &length ); - } - while (!length); + p = strchr(szLine, '\n'); + *bTooLongLine = (!p && ((int)strlen(szLine)) == len - 2); + lrtrim(szLine, &length); + } while (!length); return length; } @@ -418,17 +417,17 @@ int inchi_ios_gets( char *szLine, remove leading and trailing white spaces; keep zero termination ****************************************************************************/ -int inchi_ios_getsTab( char *szLine, - int len, - INCHI_IOSTREAM *f, - int *bTooLongLine ) +int inchi_ios_getsTab(char* szLine, + int len, + INCHI_IOSTREAM* f, + int* bTooLongLine) { int length; - char *p; + char* p; do { - p = inchi_ios_str_getsTab( szLine, len - 1, f ); + p = inchi_ios_str_getsTab(szLine, len - 1, f); if (!p) { *bTooLongLine = 0; @@ -438,9 +437,9 @@ int inchi_ios_getsTab( char *szLine, /* *bTooLongLine = !strchr( szLine, '\n' ); */ - p = strchr( szLine, '\n' ); - *bTooLongLine = ( !p && ( (int) strlen( szLine ) ) == len - 2 ); - lrtrim( szLine, &length ); + p = strchr(szLine, '\n'); + *bTooLongLine = (!p && ((int)strlen(szLine)) == len - 2); + lrtrim(szLine, &length); } while (!length); @@ -449,24 +448,24 @@ int inchi_ios_getsTab( char *szLine, /****************************************************************************/ -int inchi_ios_getsTab1( char *szLine, - int len, - INCHI_IOSTREAM *f, - int *bTooLongLine ) +int inchi_ios_getsTab1(char* szLine, + int len, + INCHI_IOSTREAM* f, + int* bTooLongLine) { int length; - char *p; + char* p; - p = inchi_ios_str_getsTab( szLine, len - 1, f ); + p = inchi_ios_str_getsTab(szLine, len - 1, f); if (!p) { *bTooLongLine = 0; return -1; /* end of file or cannot read */ } szLine[len - 1] = '\0'; - p = strchr( szLine, '\n' ); - *bTooLongLine = ( !p && ( (int) strlen( szLine ) ) == len - 2 ); - lrtrim( szLine, &length ); + p = strchr(szLine, '\n'); + *bTooLongLine = (!p && ((int)strlen(szLine)) == len - 2); + lrtrim(szLine, &length); return length; } @@ -475,7 +474,7 @@ int inchi_ios_getsTab1( char *szLine, /**************************************************************************** General procedure for printing to INCHI_IOSTREAM ****************************************************************************/ -int inchi_ios_print( INCHI_IOSTREAM * ios, const char* lpszFormat, ... ) +int inchi_ios_print(INCHI_IOSTREAM* ios, const char* lpszFormat, ...) { int ret = 0, ret2 = 0; va_list argList; @@ -489,9 +488,9 @@ int inchi_ios_print( INCHI_IOSTREAM * ios, const char* lpszFormat, ... ) { /* output to string buffer */ int max_len; - my_va_start( argList, lpszFormat ); - max_len = GetMaxPrintfLength( lpszFormat, argList ); - va_end( argList ); + my_va_start(argList, lpszFormat); + max_len = GetMaxPrintfLength(lpszFormat, argList); + va_end(argList); if (max_len >= 0) { /* djb-rwth: fixing oss-fuzz issue #30152 */ @@ -509,7 +508,7 @@ int inchi_ios_print( INCHI_IOSTREAM * ios, const char* lpszFormat, ... ) { memcpy(new_str, ios->s.pStr, sizeof(new_str[0]) * ios->s.nUsedLength); } - inchi_free( ios->s.pStr ); + inchi_free(ios->s.pStr); } ios->s.pStr = new_str; ios->s.nAllocatedLength += nAddLength; @@ -520,12 +519,9 @@ int inchi_ios_print( INCHI_IOSTREAM * ios, const char* lpszFormat, ... ) } } /* output */ - if (ios->s.nUsedLength <= new_str_len) - { - my_va_start(argList, lpszFormat); - ret = vsnprintf(ios->s.pStr + ios->s.nUsedLength, new_str_len - (long long)ios->s.nUsedLength, lpszFormat, argList); - va_end(argList); - } + my_va_start(argList, lpszFormat); + ret = vsprintf(ios->s.pStr + ios->s.nUsedLength, lpszFormat, argList); /* djb-rwth: not using vsnprintf due to variable length argument */ + va_end(argList); if (ret >= 0) { ios->s.nUsedLength += ret; @@ -534,9 +530,9 @@ int inchi_ios_print( INCHI_IOSTREAM * ios, const char* lpszFormat, ... ) #if 0 if (FWPRINT) { - my_va_start( argList, lpszFormat ); - FWPRINT( lpszFormat, argList ); - va_end( argList ); + my_va_start(argList, lpszFormat); + FWPRINT(lpszFormat, argList); + va_end(argList); } #endif #endif @@ -550,22 +546,22 @@ int inchi_ios_print( INCHI_IOSTREAM * ios, const char* lpszFormat, ... ) /* output to file */ if (ios->f) { - my_va_start( argList, lpszFormat ); - ret = vfprintf( ios->f, lpszFormat, argList ); - va_end( argList ); + my_va_start(argList, lpszFormat); + ret = vfprintf(ios->f, lpszFormat, argList); + va_end(argList); } else { - my_va_start( argList, lpszFormat ); - ret2 = vfprintf( stdout, lpszFormat, argList ); - va_end( argList ); + my_va_start(argList, lpszFormat); + ret2 = vfprintf(stdout, lpszFormat, argList); + va_end(argList); } #ifdef TARGET_LIB_FOR_WINCHI if (FWPRINT) { - my_va_start( argList, lpszFormat ); - FWPRINT( lpszFormat, argList ); - va_end( argList ); + my_va_start(argList, lpszFormat); + FWPRINT(lpszFormat, argList); + va_end(argList); } #endif return ret ? ret : ret2; @@ -577,8 +573,8 @@ int inchi_ios_print( INCHI_IOSTREAM * ios, const char* lpszFormat, ... ) /****************************************************************************/ -int push_to_winchi_text_window( INCHI_IOSTREAM * ios ) - /*, const char* lpszFormat, ... ) */ +int push_to_winchi_text_window(INCHI_IOSTREAM* ios) +/*, const char* lpszFormat, ... ) */ { #ifndef TARGET_LIB_FOR_WINCHI return -1; @@ -596,7 +592,7 @@ int push_to_winchi_text_window( INCHI_IOSTREAM * ios ) return -1; } - FWPUSH( ios->s.pStr ); + FWPUSH(ios->s.pStr); return 0; #endif @@ -631,14 +627,14 @@ int inchi_ios_print_nodisplay( INCHI_IOSTREAM * ios, if (ios->s.nAllocatedLength - ios->s.nUsedLength <= max_len) { /* enlarge output string */ - char *new_str = (char *) inchi_calloc( new_str_len, sizeof( new_str[0] ) ); /* djb-rwth: cast operators added */ + char* new_str = (char*)inchi_calloc(new_str_len, sizeof(new_str[0])); /* djb-rwth: cast operators added */ if (new_str) { if (ios->s.pStr) { if (ios->s.nUsedLength > 0) { - memcpy(new_str, ios->s.pStr, sizeof(new_str[0]) * ios->s.nUsedLength); + memcpy( new_str, ios->s.pStr, sizeof( new_str[0] )*ios->s.nUsedLength ); } inchi_free( ios->s.pStr ); } @@ -652,12 +648,9 @@ int inchi_ios_print_nodisplay( INCHI_IOSTREAM * ios, } /* output */ /* djb-rwth: fixing oss-fuzz issue #67676 */ - if (ios->s.nUsedLength <= new_str_len) - { - my_va_start(argList, lpszFormat); - ret = vsnprintf(ios->s.pStr + ios->s.nUsedLength, new_str_len - (long long)ios->s.nUsedLength, lpszFormat, argList); - va_end(argList); - } + my_va_start(argList, lpszFormat); + ret = vsprintf(ios->s.pStr + ios->s.nUsedLength, lpszFormat, argList); /* djb-rwth: not using vsnprintf due to variable length argument; fixing GHI #71 */ + va_end(argList); if (ret >= 0) { ios->s.nUsedLength += ret; @@ -683,9 +676,9 @@ int inchi_ios_print_nodisplay( INCHI_IOSTREAM * ios, This function's flushes previously hidden output and resets string stream returns n chars on success, otherwise -1 ****************************************************************************/ -int inchi_ios_flush_not_displayed( INCHI_IOSTREAM * ios ) +int inchi_ios_flush_not_displayed(INCHI_IOSTREAM* ios) { - char *obuf = NULL; + char* obuf = NULL; int ret; if (!ios) @@ -693,7 +686,7 @@ int inchi_ios_flush_not_displayed( INCHI_IOSTREAM * ios ) return -1; } - obuf = (char *) inchi_calloc( (long long)ios->s.nUsedLength + 1, sizeof( char ) ); /* djb-rwth: cast operator added */ + obuf = (char*)inchi_calloc((long long)ios->s.nUsedLength + 1, sizeof(char)); /* djb-rwth: cast operator added */ if (!obuf) { @@ -702,8 +695,8 @@ int inchi_ios_flush_not_displayed( INCHI_IOSTREAM * ios ) strcpy(obuf, ios->s.pStr); ios->s.nUsedLength = 0; - ret = inchi_ios_print( ios, "%s", obuf ); - inchi_free( obuf ); + ret = inchi_ios_print(ios, "%s", obuf); + inchi_free(obuf); return ret; } @@ -712,7 +705,7 @@ int inchi_ios_flush_not_displayed( INCHI_IOSTREAM * ios ) /**************************************************************************** Print to string buffer or to file+stderr ****************************************************************************/ -int inchi_ios_eprint( INCHI_IOSTREAM * ios, const char* lpszFormat, ... ) +int inchi_ios_eprint(INCHI_IOSTREAM* ios, const char* lpszFormat, ...) { int ret = 0, ret2 = 0; va_list argList; @@ -727,19 +720,19 @@ int inchi_ios_eprint( INCHI_IOSTREAM * ios, const char* lpszFormat, ... ) { /* output to string buffer */ int max_len, nAddLength = 0; - char *new_str = NULL; + char* new_str = NULL; - my_va_start( argList, lpszFormat ); - max_len = GetMaxPrintfLength( lpszFormat, argList ); - va_end( argList ); + my_va_start(argList, lpszFormat); + max_len = GetMaxPrintfLength(lpszFormat, argList); + va_end(argList); if (max_len >= 0) { if (ios->s.nAllocatedLength - ios->s.nUsedLength <= max_len) { /* enlarge output string */ - nAddLength = inchi_max( INCHI_ADD_STR_LEN, max_len ); - new_str = (char *) inchi_calloc( (long long)ios->s.nAllocatedLength + (long long)nAddLength, sizeof( new_str[0] ) ); /* djb-rwth: cast operators added */ + nAddLength = inchi_max(INCHI_ADD_STR_LEN, max_len); + new_str = (char*)inchi_calloc((long long)ios->s.nAllocatedLength + (long long)nAddLength, sizeof(new_str[0])); /* djb-rwth: cast operators added */ if (new_str) { if (ios->s.pStr) @@ -748,7 +741,7 @@ int inchi_ios_eprint( INCHI_IOSTREAM * ios, const char* lpszFormat, ... ) { memcpy(new_str, ios->s.pStr, sizeof(new_str[0]) * ios->s.nUsedLength); } - inchi_free( ios->s.pStr ); + inchi_free(ios->s.pStr); } ios->s.pStr = new_str; ios->s.nAllocatedLength += nAddLength; @@ -760,9 +753,9 @@ int inchi_ios_eprint( INCHI_IOSTREAM * ios, const char* lpszFormat, ... ) } /* output */ - my_va_start( argList, lpszFormat ); + my_va_start(argList, lpszFormat); ret = vsprintf(ios->s.pStr + ios->s.nUsedLength, lpszFormat, argList); - va_end( argList ); + va_end(argList); if (ret >= 0) { ios->s.nUsedLength += ret; @@ -777,16 +770,16 @@ int inchi_ios_eprint( INCHI_IOSTREAM * ios, const char* lpszFormat, ... ) if (ios->f) { /* output to plain file */ - my_va_start( argList, lpszFormat ); - ret = inchi_vfprintf( ios->f, lpszFormat, argList ); - va_end( argList ); + my_va_start(argList, lpszFormat); + ret = inchi_vfprintf(ios->f, lpszFormat, argList); + va_end(argList); /* No output to stderr from within dll or GUI program */ #if ( !defined(TARGET_API_LIB) && !defined(TARGET_LIB_FOR_WINCHI) ) if (ios->f != stderr) { - my_va_start( argList, lpszFormat ); - ret2 = vfprintf( stderr, lpszFormat, argList ); - va_end( argList ); + my_va_start(argList, lpszFormat); + ret2 = vfprintf(stderr, lpszFormat, argList); + va_end(argList); } #endif return ret ? ret : ret2; @@ -804,22 +797,22 @@ int inchi_ios_eprint( INCHI_IOSTREAM * ios, const char* lpszFormat, ... ) /**************************************************************************** Print to file, echoing to stderr ****************************************************************************/ -int inchi_fprintf( FILE* f, const char* lpszFormat, ... ) +int inchi_fprintf(FILE* f, const char* lpszFormat, ...) { int ret = 0, ret2 = 0; va_list argList; if (f) { - my_va_start( argList, lpszFormat ); - ret = inchi_vfprintf( f, lpszFormat, argList ); - va_end( argList ); + my_va_start(argList, lpszFormat); + ret = inchi_vfprintf(f, lpszFormat, argList); + va_end(argList); /* No output to stderr from within dll or GUI program */ #if ( !defined(TARGET_API_LIB) && !defined(TARGET_LIB_FOR_WINCHI) ) if (f != stderr) { - my_va_start( argList, lpszFormat ); - ret2 = vfprintf( stderr, lpszFormat, argList ); - va_end( argList ); + my_va_start(argList, lpszFormat); + ret2 = vfprintf(stderr, lpszFormat, argList); + va_end(argList); } #endif return ret ? ret : ret2; @@ -832,7 +825,7 @@ int inchi_fprintf( FILE* f, const char* lpszFormat, ... ) /**************************************************************************** Print to file ****************************************************************************/ -int inchi_vfprintf( FILE* f, const char* lpszFormat, va_list argList ) +int inchi_vfprintf(FILE* f, const char* lpszFormat, va_list argList) { int ret = 0; if (lpszFormat && lpszFormat[0]) /* djb-rwth: condition added as lpszFormat == 0 may lead to undefined ret value */ @@ -871,7 +864,7 @@ int inchi_vfprintf( FILE* f, const char* lpszFormat, va_list argList ) /**************************************************************************** This function's output should not be displayed in the output pane ****************************************************************************/ -int inchi_print_nodisplay( FILE* f, const char* lpszFormat, ... ) +int inchi_print_nodisplay(FILE* f, const char* lpszFormat, ...) { int ret = 0; va_list argList; @@ -886,7 +879,7 @@ int inchi_print_nodisplay( FILE* f, const char* lpszFormat, ... ) fi = stdout; } - my_va_start( argList, lpszFormat ); + my_va_start(argList, lpszFormat); ret = vfprintf(fi, lpszFormat, argList); return ret; } @@ -896,28 +889,27 @@ int inchi_print_nodisplay( FILE* f, const char* lpszFormat, ... ) /****************************************************************************/ -int inchi_fgetsLfTab( char *szLine, int len, FILE *f ) +int inchi_fgetsLfTab(char* szLine, int len, FILE* f) { int length; - char *p; + char* p; char szSkip[256]; int bTooLongLine = 0; do { - p = inchi_fgetsTab( szLine, len, f ); + p = inchi_fgetsTab(szLine, len, f); if (!p) { return -1; /* end of file or cannot read */ } - bTooLongLine = ( (int) strlen( szLine ) == len - 1 && szLine[len - 2] != '\n' ); - lrtrim( szLine, &length ); - } - while (!length); + bTooLongLine = ((int)strlen(szLine) == len - 1 && szLine[len - 2] != '\n'); + lrtrim(szLine, &length); + } while (!length); if (bTooLongLine) { - while ((p = inchi_fgetsTab( szSkip, sizeof( szSkip ) - 1, f ))) /* djb-rwth: ignoring LLVM warning: function returning value */ + while ((p = inchi_fgetsTab(szSkip, sizeof(szSkip) - 1, f))) /* djb-rwth: ignoring LLVM warning: function returning value */ { - if (strchr( szSkip, '\n' )) + if (strchr(szSkip, '\n')) break; } } @@ -930,15 +922,15 @@ int inchi_fgetsLfTab( char *szLine, int len, FILE *f ) /****************************************************************************/ -int inchi_fgetsLfTab( char *szLine, int len, FILE *f ) +int inchi_fgetsLfTab(char* szLine, int len, FILE* f) { int length; - char *p; + char* p; char szSkip[256]; int bTooLongLine = 0; do { - p = inchi_fgetsTab( szLine, len - 1, f ); + p = inchi_fgetsTab(szLine, len - 1, f); if (!p) { return -1; /* end of file or cannot read */ @@ -947,16 +939,15 @@ int inchi_fgetsLfTab( char *szLine, int len, FILE *f ) /* bTooLongLine = !strchr( szLine, '\n' ); */ - bTooLongLine = ( !p && ( (int) strlen( szLine ) ) == len - 2 ); - lrtrim( szLine, &length ); - } - while (!length); + bTooLongLine = (!p && ((int)strlen(szLine)) == len - 2); + lrtrim(szLine, &length); + } while (!length); if (bTooLongLine) { - while (p = inchi_fgetsTab( szSkip, sizeof( szSkip ) - 1, f )) + while (p = inchi_fgetsTab(szSkip, sizeof(szSkip) - 1, f)) { - szSkip[sizeof( szSkip ) - 1] = '\0'; - if (strchr( szSkip, '\n' )) + szSkip[sizeof(szSkip) - 1] = '\0'; + if (strchr(szSkip, '\n')) break; } } @@ -971,17 +962,17 @@ int inchi_fgetsLfTab( char *szLine, int len, FILE *f ) remove leading and trailing white spaces; keep zero termination ****************************************************************************/ -char *inchi_fgetsTab( char *szLine, int len, FILE *f ) +char* inchi_fgetsTab(char* szLine, int len, FILE* f) { int length = 0, c = 0; len--; - while (length < len && EOF != ( c = fgetc( f ) )) + while (length < len && EOF != (c = fgetc(f))) { if (c == '\t') { c = '\n'; } - szLine[length++] = (char) c; + szLine[length++] = (char)c; if (c == '\n') { break; @@ -1001,22 +992,22 @@ char *inchi_fgetsTab( char *szLine, int len, FILE *f ) Read up to LF but not more than line_len bytes; if input line is too long, quietly ignore the rest of the line ****************************************************************************/ -char* inchi_fgetsLf( char* line, int line_len, INCHI_IOSTREAM* inp_stream ) +char* inchi_fgetsLf(char* line, int line_len, INCHI_IOSTREAM* inp_stream) { - char *p = NULL, *q; + char* p = NULL, * q; FILE* finp = NULL; if (inp_stream->type == INCHI_IOS_TYPE_FILE) { /* Read from file */ finp = inp_stream->f; - memset( line, 0, line_len ); /* djb-rwth: memset_s C11/Annex K variant? */ - if (NULL != ( p = fgets( line, line_len, finp ) ) && - NULL == strchr( p, '\n' )) + memset(line, 0, line_len); /* djb-rwth: memset_s C11/Annex K variant? */ + if (NULL != (p = fgets(line, line_len, finp)) && + NULL == strchr(p, '\n')) { char temp[64]; /* bypass up to '\n' or up to end of file whichever comes first */ - while (NULL != fgets( temp, sizeof( temp ), finp ) && NULL == strchr( temp, '\n' )) + while (NULL != fgets(temp, sizeof(temp), finp) && NULL == strchr(temp, '\n')) { ; } @@ -1025,13 +1016,13 @@ char* inchi_fgetsLf( char* line, int line_len, INCHI_IOSTREAM* inp_stream ) else if (inp_stream->type == INCHI_IOS_TYPE_STRING) { /* Read from supplied string representing Molfile */ - memset( line, 0, line_len ); /* djb-rwth: memset_s C11/Annex K variant? */ - if (NULL != ( p = inchi_sgets( line, line_len, inp_stream ) ) && - NULL == strchr( p, '\n' )) + memset(line, 0, line_len); /* djb-rwth: memset_s C11/Annex K variant? */ + if (NULL != (p = inchi_sgets(line, line_len, inp_stream)) && + NULL == strchr(p, '\n')) { char temp[64]; /* bypass up to '\n' or up to end of file whichever comes first */ - while (NULL != inchi_sgets( temp, sizeof( temp ), inp_stream ) && NULL == strchr( temp, '\n' )) + while (NULL != inchi_sgets(temp, sizeof(temp), inp_stream) && NULL == strchr(temp, '\n')) { ; } @@ -1044,7 +1035,7 @@ char* inchi_fgetsLf( char* line, int line_len, INCHI_IOSTREAM* inp_stream ) if (p) { - if ((q = strchr( line, '\r' ))) /* djb-rwth: addressing LLVM warning */ + if ((q = strchr(line, '\r'))) /* djb-rwth: addressing LLVM warning */ { /* fix CR CR LF line terminator. */ q[0] = '\n'; @@ -1070,18 +1061,25 @@ char* inchi_fgetsLf( char* line, int line_len, INCHI_IOSTREAM* inp_stream ) /**************************************************************************** Formatting (using wsprintf style formatting) ****************************************************************************/ -int GetMaxPrintfLength( const char *lpszFormat, va_list argList ) +int GetMaxPrintfLength(const char* lpszFormat, va_list argList) { - /*ASSERT(AfxIsValidString(lpszFormat, FALSE));*/ - const char * lpsz; + /*ASSERT(AfxIsValidString(lpszFormat, FALSE));*/ + const char* lpsz; int nMaxLen, nWidth, nPrecision, nModifier, nItemLen; nMaxLen = 0; /* make a guess at the maximum length of the resulting string */ for (lpsz = lpszFormat; *lpsz; lpsz++) { - /* handle '%' character, but watch out for '%%' */ - if (*lpsz != '%' || *( ++lpsz ) == '%') + /* moved from below for C syntax reason - 2024-09-01 DT */ + /* djb-rwth: return values needed for va_arg; djb-rwth: ignoring LLVM warnings: function returning value */ + int ivarg; + double dvarg; + void* ivvarg; + int* ipvarg; + + /* handle '%' character, but watch out for '%%' */ + if (*lpsz != '%' || *(++lpsz) == '%') { nMaxLen += 1; continue; @@ -1093,17 +1091,17 @@ int GetMaxPrintfLength( const char *lpszFormat, va_list argList ) nWidth = 0; for (; *lpsz; lpsz++) { - /* check for valid flags */ + /* check for valid flags */ if (*lpsz == '#') { nMaxLen += 2; /* for '0x' */ } else if (*lpsz == '*') { - nWidth = va_arg( argList, int ); + nWidth = va_arg(argList, int); } else if (*lpsz == '-' || *lpsz == '+' || *lpsz == '0' - || *lpsz == ' ') + || *lpsz == ' ') { ; } @@ -1115,9 +1113,9 @@ int GetMaxPrintfLength( const char *lpszFormat, va_list argList ) /* get width and skip it */ if (nWidth == 0) { - /* width indicated by */ - nWidth = atoi( lpsz ); - for (; *lpsz && isdigit( *lpsz ); lpsz++) + /* width indicated by */ + nWidth = atoi(lpsz); + for (; *lpsz && isdigit(*lpsz); lpsz++) { ; } @@ -1131,19 +1129,19 @@ int GetMaxPrintfLength( const char *lpszFormat, va_list argList ) nPrecision = 0; if (*lpsz == '.') { - /* skip past '.' separator (width.precision)*/ + /* skip past '.' separator (width.precision)*/ lpsz++; /* get precision and skip it*/ if (*lpsz == '*') { - nPrecision = va_arg( argList, int ); + nPrecision = va_arg(argList, int); lpsz++; } else { - nPrecision = atoi( lpsz ); - for (; *lpsz && isdigit( *lpsz ); lpsz++) + nPrecision = atoi(lpsz); + for (; *lpsz && isdigit(*lpsz); lpsz++) { ; } @@ -1158,157 +1156,151 @@ int GetMaxPrintfLength( const char *lpszFormat, va_list argList ) nModifier = 0; switch (*lpsz) { - /* modifiers that affect size */ - case 'h': - switch (lpsz[1]) - { - case 'd': - case 'i': - case 'o': - case 'x': - case 'X': - case 'u': - /* short unsigned, short double, etc. -- added to the original MS example */ - /* ignore the fact that these modifiers do affect size */ - lpsz++; - break; - default: - nModifier = FORCE_ANSI; - lpsz++; - break; - } + /* modifiers that affect size */ + case 'h': + switch (lpsz[1]) + { + case 'd': + case 'i': + case 'o': + case 'x': + case 'X': + case 'u': + /* short unsigned, short double, etc. -- added to the original MS example */ + /* ignore the fact that these modifiers do affect size */ + lpsz++; break; - case 'l': - switch (lpsz[1]) - { - case 'd': - case 'i': - case 'o': - case 'x': - case 'X': - case 'u': - case 'f': /* long float -- post ANSI C */ - /* long unsigned, long double, etc. -- added to the original MS example */ - /* ignore the fact that these modifiers do affect size */ - lpsz++; - break; - default: - /* - nModifier = FORCE_UNICODE; - lpsz ++; - break; - */ - goto exit_error; /* no UNICODE, please */ - } + default: + nModifier = FORCE_ANSI; + lpsz++; break; - /* modifiers that do not affect size */ - case 'F': - case 'N': - case 'L': + } + break; + case 'l': + switch (lpsz[1]) + { + case 'd': + case 'i': + case 'o': + case 'x': + case 'X': + case 'u': + case 'f': /* long float -- post ANSI C */ + /* long unsigned, long double, etc. -- added to the original MS example */ + /* ignore the fact that these modifiers do affect size */ lpsz++; break; + default: + /* + nModifier = FORCE_UNICODE; + lpsz ++; + break; + */ + goto exit_error; /* no UNICODE, please */ + } + break; + /* modifiers that do not affect size */ + case 'F': + case 'N': + case 'L': + lpsz++; + break; } /* now should be on specifier */ - - /* djb-rwth: return values needed for va_arg; djb-rwth: ignoring LLVM warnings: function returning value */ - int ivarg; - double dvarg; - void* ivvarg; - int* ipvarg; - + switch (*lpsz | nModifier) { - /* single characters*/ - case 'c': - case 'C': - nItemLen = 2; - ivarg = va_arg( argList, int ); /* djb-rwth: int return value; ignoring LLVM warning */ - break; - case 'c' | FORCE_ANSI: - case 'C' | FORCE_ANSI: - nItemLen = 2; - ivarg = va_arg( argList, int ); /* djb-rwth: int return value; ignoring LLVM warning */ - break; - case 'c' | FORCE_UNICODE: - case 'C' | FORCE_UNICODE: - goto exit_error; /* no UNICODE, please */ - /* - nItemLen = 2; - va_arg(argList, wchar_t); - break; - */ + /* single characters*/ + case 'c': + case 'C': + nItemLen = 2; + ivarg = va_arg(argList, int); /* djb-rwth: int return value; ignoring LLVM warning */ + break; + case 'c' | FORCE_ANSI: + case 'C' | FORCE_ANSI: + nItemLen = 2; + ivarg = va_arg(argList, int); /* djb-rwth: int return value; ignoring LLVM warning */ + break; + case 'c' | FORCE_UNICODE: + case 'C' | FORCE_UNICODE: + goto exit_error; /* no UNICODE, please */ + /* + nItemLen = 2; + va_arg(argList, wchar_t); + break; + */ - /* strings*/ - case 's': - case 'S': - nItemLen = (int) strlen( va_arg( argList, char* ) ); - nItemLen = inchi_max( 1, nItemLen ); - break; - case 's' | FORCE_ANSI: - case 'S' | FORCE_ANSI: - nItemLen = (int) strlen( va_arg( argList, char* ) ); - nItemLen = inchi_max( 1, nItemLen ); - break; + /* strings*/ + case 's': + case 'S': + nItemLen = (int)strlen(va_arg(argList, char*)); + nItemLen = inchi_max(1, nItemLen); + break; + case 's' | FORCE_ANSI: + case 'S' | FORCE_ANSI: + nItemLen = (int)strlen(va_arg(argList, char*)); + nItemLen = inchi_max(1, nItemLen); + break; - case 's' | FORCE_UNICODE: - case 'S' | FORCE_UNICODE: - goto exit_error; /* no UNICODE, please */ - /* - nItemLen = wcslen(va_arg(argList, wchar_t*)); - nItemLen = inchi_max(1, nItemLen); - break; - */ + case 's' | FORCE_UNICODE: + case 'S' | FORCE_UNICODE: + goto exit_error; /* no UNICODE, please */ + /* + nItemLen = wcslen(va_arg(argList, wchar_t*)); + nItemLen = inchi_max(1, nItemLen); + break; + */ } /* adjust nItemLen for strings */ if (nItemLen != 0) { - nItemLen = inchi_max( nItemLen, nWidth ); + nItemLen = inchi_max(nItemLen, nWidth); if (nPrecision != 0) { - nItemLen = inchi_min( nItemLen, nPrecision ); + nItemLen = inchi_min(nItemLen, nPrecision); } } else { switch (*lpsz) { - /* integers */ - case 'd': - case 'i': - case 'u': - case 'x': - case 'X': - case 'o': - ivarg = va_arg( argList, int ); /* djb-rwth: int return value; ignoring LLVM warning */ - nItemLen = 32; - nItemLen = inchi_max( nItemLen, nWidth + nPrecision ); - break; - - case 'e': - case 'f': - case 'g': - case 'G': - dvarg = va_arg( argList, double ); /* djb-rwth: double return value; ignoring LLVM warning */ - nItemLen = 32; - nItemLen = inchi_max( nItemLen, nWidth + nPrecision ); - break; - - case 'p': - ivvarg = va_arg( argList, void* ); /* djb-rwth: void* return value; ignoring LLVM warning */ - nItemLen = 32; - nItemLen = inchi_max( nItemLen, nWidth + nPrecision ); - break; - - /* no output */ - case 'n': - ipvarg = va_arg( argList, int* ); /* djb-rwth: int* return value; ignoring LLVM warning */ - break; - - default: - /*ASSERT(FALSE);*/ /* unknown formatting option*/ - goto exit_error; /* instead of exception */ + /* integers */ + case 'd': + case 'i': + case 'u': + case 'x': + case 'X': + case 'o': + ivarg = va_arg(argList, int); /* djb-rwth: int return value; ignoring LLVM warning */ + nItemLen = 32; + nItemLen = inchi_max(nItemLen, nWidth + nPrecision); + break; + + case 'e': + case 'f': + case 'g': + case 'G': + dvarg = va_arg(argList, double); /* djb-rwth: double return value; ignoring LLVM warning */ + nItemLen = 32; + nItemLen = inchi_max(nItemLen, nWidth + nPrecision); + break; + + case 'p': + ivvarg = va_arg(argList, void*); /* djb-rwth: void* return value; ignoring LLVM warning */ + nItemLen = 32; + nItemLen = inchi_max(nItemLen, nWidth + nPrecision); + break; + + /* no output */ + case 'n': + ipvarg = va_arg(argList, int*); /* djb-rwth: int* return value; ignoring LLVM warning */ + break; + + default: + /*ASSERT(FALSE);*/ /* unknown formatting option*/ + goto exit_error; /* instead of exception */ } } @@ -1326,11 +1318,11 @@ int GetMaxPrintfLength( const char *lpszFormat, va_list argList ) Get at most n-1 chars, plus a null, then advance input's start. Return emulates fgets() ****************************************************************************/ -char *inchi_sgets( char *s, int n, INCHI_IOSTREAM* ios ) +char* inchi_sgets(char* s, int n, INCHI_IOSTREAM* ios) { int c = 0; - char *p; - char *inp; + char* p; + char* inp; inp = ios->s.pStr + ios->s.nPtr; @@ -1353,10 +1345,10 @@ char *inchi_sgets( char *s, int n, INCHI_IOSTREAM* ios ) else */ - while (--n > 0 && ( c = *inp++ )) + while (--n > 0 && (c = *inp++)) { ios->s.nPtr++; - if (( *p++ = c ) == '\n') + if ((*p++ = c) == '\n') { break; } @@ -1365,7 +1357,7 @@ char *inchi_sgets( char *s, int n, INCHI_IOSTREAM* ios ) /* printf("\n*** {%-s}",s); */ - return ( c == '\0' && p == s ) + return (c == '\0' && p == s) ? NULL /* like EOF reached */ : s; } @@ -1374,10 +1366,10 @@ char *inchi_sgets( char *s, int n, INCHI_IOSTREAM* ios ) /**************************************************************************** Init expandable buffer of type INCHI_IOS_STRING ****************************************************************************/ -int inchi_strbuf_init( INCHI_IOS_STRING *buf, int start_size, int incr_size ) +int inchi_strbuf_init(INCHI_IOS_STRING* buf, int start_size, int incr_size) { - char *new_str = NULL; - memset( buf, 0, sizeof( *buf ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + char* new_str = NULL; + memset(buf, 0, sizeof(*buf)); /* djb-rwth: memset_s C11/Annex K variant? */ if (start_size <= 0) { @@ -1388,7 +1380,7 @@ int inchi_strbuf_init( INCHI_IOS_STRING *buf, int start_size, int incr_size ) incr_size = INCHI_STRBUF_SIZE_INCREMENT; } - new_str = (char *) inchi_calloc( start_size, sizeof( char ) ); + new_str = (char*)inchi_calloc(start_size, sizeof(char)); if (!new_str) { @@ -1407,7 +1399,7 @@ int inchi_strbuf_init( INCHI_IOS_STRING *buf, int start_size, int incr_size ) Reset INCHI_IOS_STRING object holding an expandable buffer string (place '\0' at the start and do _not_ free memory). ****************************************************************************/ -void inchi_strbuf_reset( INCHI_IOS_STRING *buf ) +void inchi_strbuf_reset(INCHI_IOS_STRING* buf) { if (!buf) { @@ -1426,7 +1418,7 @@ void inchi_strbuf_reset( INCHI_IOS_STRING *buf ) Close INCHI_IOS_STRING object holding an expandable buffer string, free previously allocated sring memory ****************************************************************************/ -void inchi_strbuf_close( INCHI_IOS_STRING *buf ) +void inchi_strbuf_close(INCHI_IOS_STRING* buf) { if (!buf) { @@ -1434,19 +1426,19 @@ void inchi_strbuf_close( INCHI_IOS_STRING *buf ) } if (buf->pStr) { - inchi_free( buf->pStr ); + inchi_free(buf->pStr); } - memset( buf, 0, sizeof( *buf ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(buf, 0, sizeof(*buf)); /* djb-rwth: memset_s C11/Annex K variant? */ } /****************************************************************************/ -int inchi_strbuf_create_copy( INCHI_IOS_STRING *buf2, INCHI_IOS_STRING *buf ) +int inchi_strbuf_create_copy(INCHI_IOS_STRING* buf2, INCHI_IOS_STRING* buf) { - char *new_str = NULL; + char* new_str = NULL; - new_str = (char *) inchi_calloc( buf->nAllocatedLength, sizeof( char ) ); + new_str = (char*)inchi_calloc(buf->nAllocatedLength, sizeof(char)); buf2->pStr = new_str; if (!new_str) { @@ -1463,7 +1455,7 @@ int inchi_strbuf_create_copy( INCHI_IOS_STRING *buf2, INCHI_IOS_STRING *buf ) /**************************************************************************** Check size and if necessary expand string buffer in INCHI_IOS_STRING ****************************************************************************/ -int inchi_strbuf_update( INCHI_IOS_STRING *buf, int new_addition_size ) +int inchi_strbuf_update(INCHI_IOS_STRING* buf, int new_addition_size) { int requsted_len; @@ -1482,11 +1474,11 @@ int inchi_strbuf_update( INCHI_IOS_STRING *buf, int new_addition_size ) if (requsted_len >= buf->nAllocatedLength) { /* Expand */ - int nAddLength = inchi_max( buf->nPtr, new_addition_size ); - /* buf->nPtr stores size increment for this buffer */ - char *new_str = - (char *) inchi_calloc( (long long)buf->nAllocatedLength + (long long)nAddLength, - sizeof( new_str[0] ) ); /* djb-rwth: cast operators added */ + int nAddLength = inchi_max(buf->nPtr, new_addition_size); + /* buf->nPtr stores size increment for this buffer */ + char* new_str = + (char*)inchi_calloc((long long)buf->nAllocatedLength + (long long)nAddLength, + sizeof(new_str[0])); /* djb-rwth: cast operators added */ if (!new_str) { return -1; /* failed */ @@ -1497,7 +1489,7 @@ int inchi_strbuf_update( INCHI_IOS_STRING *buf, int new_addition_size ) { memcpy(new_str, buf->pStr, sizeof(new_str[0]) * buf->nUsedLength); } - inchi_free( buf->pStr ); + inchi_free(buf->pStr); } buf->pStr = new_str; buf->nAllocatedLength += nAddLength; @@ -1511,7 +1503,7 @@ int inchi_strbuf_update( INCHI_IOS_STRING *buf, int new_addition_size ) Add to the end of string in INCHI_IOS_STRING object, expanding buffer if necessary ****************************************************************************/ -int inchi_strbuf_printf( INCHI_IOS_STRING *buf, const char* lpszFormat, ... ) +int inchi_strbuf_printf(INCHI_IOS_STRING* buf, const char* lpszFormat, ...) { int ret = 0, max_len; va_list argList; @@ -1521,19 +1513,19 @@ int inchi_strbuf_printf( INCHI_IOS_STRING *buf, const char* lpszFormat, ... ) return -1; } - my_va_start( argList, lpszFormat ); - max_len = GetMaxPrintfLength( lpszFormat, argList ); - va_end( argList ); + my_va_start(argList, lpszFormat); + max_len = GetMaxPrintfLength(lpszFormat, argList); + va_end(argList); if (max_len < 0) { return 0; } - inchi_strbuf_update( buf, max_len ); + inchi_strbuf_update(buf, max_len); - my_va_start( argList, lpszFormat ); + my_va_start(argList, lpszFormat); ret = vsprintf(buf->pStr + buf->nUsedLength, lpszFormat, argList); - va_end( argList ); + va_end(argList); if (ret >= 0) { buf->nUsedLength += ret; @@ -1548,9 +1540,9 @@ int inchi_strbuf_printf( INCHI_IOS_STRING *buf, const char* lpszFormat, ... ) from specified position 'npos', expanding buffer if necessary. NB: be careful, intentionally no checks on where is 'npos'! ****************************************************************************/ -int inchi_strbuf_printf_from( INCHI_IOS_STRING *buf, - int npos, - const char* lpszFormat, ... ) +int inchi_strbuf_printf_from(INCHI_IOS_STRING* buf, + int npos, + const char* lpszFormat, ...) { int ret = 0, max_len; va_list argList; @@ -1560,9 +1552,9 @@ int inchi_strbuf_printf_from( INCHI_IOS_STRING *buf, return -1; } - my_va_start( argList, lpszFormat ); - max_len = GetMaxPrintfLength( lpszFormat, argList ); - va_end( argList ); + my_va_start(argList, lpszFormat); + max_len = GetMaxPrintfLength(lpszFormat, argList); + va_end(argList); if (max_len < 0) { return 0; @@ -1570,11 +1562,11 @@ int inchi_strbuf_printf_from( INCHI_IOS_STRING *buf, max_len += npos; - inchi_strbuf_update( buf, max_len ); + inchi_strbuf_update(buf, max_len); - my_va_start( argList, lpszFormat ); + my_va_start(argList, lpszFormat); ret = vsprintf(buf->pStr + npos, lpszFormat, argList); - va_end( argList ); + va_end(argList); if (ret >= 0) { buf->nUsedLength = npos + ret; @@ -1588,18 +1580,18 @@ int inchi_strbuf_printf_from( INCHI_IOS_STRING *buf, Reads the next line to growing str buf. Returns n of read chars, -1 at end of file or at error. *****************************************************************************/ -int inchi_strbuf_getline( INCHI_IOS_STRING *buf, - FILE *f, - int crlf2lf, - int preserve_lf ) +int inchi_strbuf_getline(INCHI_IOS_STRING* buf, + FILE* f, + int crlf2lf, + int preserve_lf) { int c; - inchi_strbuf_reset( buf ); + inchi_strbuf_reset(buf); while (1) { - c = fgetc( f ); - if (ferror( f )) + c = fgetc(f); + if (ferror(f)) { return -1; } @@ -1607,7 +1599,7 @@ int inchi_strbuf_getline( INCHI_IOS_STRING *buf, { return -1; } - inchi_strbuf_printf( buf, "%c", c ); + inchi_strbuf_printf(buf, "%c", c); if (c == '\n') { break; @@ -1639,21 +1631,21 @@ int inchi_strbuf_getline( INCHI_IOS_STRING *buf, Adds the next line to growing str buf (does not reset buf before adding). Returns n of read chars, -1 at end of file or at error. ****************************************************************************/ -int inchi_strbuf_addline( INCHI_IOS_STRING *buf, - INCHI_IOSTREAM *inp_stream, - int crlf2lf, - int preserve_lf ) +int inchi_strbuf_addline(INCHI_IOS_STRING* buf, + INCHI_IOSTREAM* inp_stream, + int crlf2lf, + int preserve_lf) { int c; while (1) { - c = inchi_ios_str_getc( inp_stream ); + c = inchi_ios_str_getc(inp_stream); if (c == EOF) { return -1; } - inchi_strbuf_printf( buf, "%c", c ); + inchi_strbuf_printf(buf, "%c", c); if (c == '\n') { break; @@ -1685,7 +1677,7 @@ int inchi_strbuf_addline( INCHI_IOS_STRING *buf, /****************************************************************************/ /* djb-rwth: placed as a global variable to avoid function buffer issues */ -char it_buffer[32767]; +char it_buffer[32767]; int _inchi_trace(char* format, ...) { /* @@ -1694,16 +1686,16 @@ int _inchi_trace(char* format, ...) */ int ret; - va_list argptr; - va_start(argptr, format); - /*wvsprintf(buffer, format, argptr);*/ - ret = vsprintf(it_buffer, format, argptr); - va_end(argptr); - OutputDebugString(it_buffer); - return 1; + va_list argptr; + va_start(argptr, format); + /*wvsprintf(buffer, format, argptr);*/ + ret = vsprintf(it_buffer, format, argptr); + va_end(argptr); + OutputDebugString(it_buffer); + return 1; } #else -int _inchi_trace( char *format, ... ) +int _inchi_trace(char* format, ...) { return 1; } @@ -1713,14 +1705,14 @@ int _inchi_trace( char *format, ... ) /**************************************************************************** Output structure (compound) header for current record ****************************************************************************/ -int Output_RecordInfo(INCHI_IOSTREAM *out_file, +int Output_RecordInfo(INCHI_IOSTREAM* out_file, int num_input_struct, int bNoStructLabels, - const char *szSdfLabel, - const char *szSdfValue, + const char* szSdfLabel, + const char* szSdfValue, unsigned long lSdfId, - char *pLF, - char *pTAB) + char* pLF, + char* pTAB) { if (bNoStructLabels) { diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichican2.c b/INCHI-1-SRC/INCHI_BASE/src/ichican2.c index 645849cd..b75bb235 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichican2.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichican2.c @@ -54,7 +54,6 @@ #include "ichitime.h" #include "bcf_s.h" -int na_global; /* djb-rwth: required for fixing oss-fuzz issue #69315 */ #define MAX_CELLS 32766 #define MAX_NODES 32766 @@ -1884,7 +1883,7 @@ void CtPartFill( Graph *G, /******* Well-defined (by fixed ranks) part of the connection table ************/ /* djb-rwth: fixing oss-fuzz issue #69612 */ - if ((startAtOrd < 0) || (startAtOrd >= na_global)) + if (startAtOrd < 0) { return; } @@ -4674,7 +4673,7 @@ int SetInitialRanks2( int num_atoms, /* djb-rwth: fixing oss-fuzz issue #69315 */ nNumDiffRanks = 1; - if ((num_atoms > 0) && (num_atoms <= na_global)) + if (num_atoms > 0) { nCurrentRank = (AT_RANK)num_atoms; nNewRank[nAtomNumber[num_atoms - 1]] = nCurrentRank; @@ -5299,7 +5298,6 @@ int GetBaseCanonRanking( INCHI_CLOCK *ic, nRank = (AT_RANK *) inchi_calloc( num_max, sizeof( nRank[0] ) ); nAtomNumber = (AT_NUMB *) inchi_calloc( num_max, sizeof( nAtomNumber[0] ) ); nTempRank = (AT_RANK *) inchi_calloc( num_max, sizeof( nTempRank[0] ) ); - na_global = num_max; /* djb-rwth: required for fixing oss-fuzz issue #69315 */ if (!pAtomInvariant || !nSymmRankNoH || !nCanonRankNoH || !nAtomNumberCanonNoH || diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichicano.c b/INCHI-1-SRC/INCHI_BASE/src/ichicano.c index 04957395..a4c4981b 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichicano.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichicano.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "mode.h" #include "ichicano.h" @@ -129,7 +130,7 @@ static void FillMaxMinClock( INCHI_CLOCK *ic ) if (!ic->m_MaxPositiveClock) { clock_t valPos = 0, val1 = 1; - while (0 < ( ( val1 <<= 1 ), ( val1 |= 1 ) )) + while (0 < ( ( val1 <<= 1 ), ( val1 |= 1 ) )) /* djb-rwth: ignoring GH issue #59.3 -- LLONG_MIN/LLONG_MAX not found in on Linux */ { valPos = val1; } @@ -1070,7 +1071,6 @@ int UpdateFullLinearCT( int num_atoms, int nCTLen = 0, nCTLenAtOnly = 0; - num_neigh = 0; /* djb-rwth: num_neigh initialisation added */ AT_NUMB r_neigh; AT_NUMB *LinearCT = pCS->LinearCT; @@ -1085,6 +1085,8 @@ int UpdateFullLinearCT( int num_atoms, AT_NUMB r0_at_type; #endif + num_neigh = 0; /* Moved from above 2024-09-01 DT; djb-rwth: num_neigh initialisation added */ + bCompare = bFirstTime ? 0 : 1; if (num_at_tg > num_atoms) diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichicans.c b/INCHI-1-SRC/INCHI_BASE/src/ichicans.c index accf6498..a8144387 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichicans.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichicans.c @@ -331,7 +331,7 @@ int UnmarkNonStereo( CANON_GLOBALS *pCG, AT_RANK nNeighborNumber[MAX_NUM_STEREO_ATOM_NEIGH]; AT_RANK nPrevAtomRank, nPrevNeighRank; #ifdef FIX_OLEAN_SPIRO_CHIRALITY_DETECTION_BUG - int num_in_same_ring_system = 1, nRingSystem, num_with_eq_neigh_in_same_ring_system = 0; /* djb-rwth: although unlikely to ever occur, uninitialised num_in_same_ring_system variable can lead to garbage value in line 449, including 0 which leads to various errors and inconsistency with 1.06 outputs -- function rewriting and discussion required */ + int num_in_same_ring_system = 1, nRingSystem, num_with_eq_neigh_in_same_ring_system = 0; /* djb-rwth: although unlikely to ever occur, uninitialised num_in_same_ring_system variable can lead to garbage value, including 0 which leads to various errors and inconsistency with 1.06 outputs -- function rewriting and discussion required */ #endif diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichimak2.c b/INCHI-1-SRC/INCHI_BASE/src/ichimak2.c index 07d14a8d..c50f1070 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichimak2.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichimak2.c @@ -1059,15 +1059,7 @@ int FillOutINChI( INChI *pINChI, } /* Total charge */ - /* djb-rwth: required for fixing oss-fuzz issue #69656 */ - if (num_atoms + num_removed_H > sp_at_size) - { - nErrorCode = 0; - ret = CT_OVERFLOW; - pINChI->nErrorCode = pINChI_Aux->nErrorCode = CT_OVERFLOW; - goto exit_function; - } - + /* djb-rwth: fixing oss-fuzz issue #69656 */ for (i = 0, n = 0; i < num_atoms + num_removed_H; i++) { n += at[i].charge; diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichimake.c b/INCHI-1-SRC/INCHI_BASE/src/ichimake.c index 5992b3f0..d0aa5f95 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichimake.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichimake.c @@ -52,7 +52,6 @@ #include "ichi_bns.h" #include "bcf_s.h" -int sp_at_size; /* djb-rwth: required for fixing oss-fuzz issue #69656 */ /* Local functions @@ -3743,8 +3742,6 @@ int Create_INChI( CANON_GLOBALS *pCG, int bMayHaveStereo = 0; int num_taut_at = 0; - sp_at_size = 0; /* djb-rwth: required for fixing oss-fuzz issue #69656 */ - inp_ATOM *out_at = NULL; /*, *norm_at_fixed_bonds[TAUT_NUM]; */ /* = {out_norm_nontaut_at, out_norm_taut_at} ; */ INChI *pINChI = NULL; /* added initialization 2006-03 */ INChI_Aux *pINChI_Aux = NULL; /* added initialization 2006-03 */ @@ -3836,10 +3833,6 @@ int Create_INChI( CANON_GLOBALS *pCG, { ret = -1; } - else - { - sp_at_size = num_inp_at; /* djb-rwth: required for fixing oss-fuzz issue #69656 */\ - } } else { diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichimap2.c b/INCHI-1-SRC/INCHI_BASE/src/ichimap2.c index 68de5072..7405f2f9 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichimap2.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichimap2.c @@ -159,7 +159,7 @@ int SortedEquInfoToRanks( const AT_RANK* nSymmRank, AT_RANK* nRank, const AT_RAN i_init = num_atoms - 1; /* djb-rwth: fixing oss-fuzz issue #69965 */ - if ((i_init >= 0) && (i_init < na_global)) + if (i_init >= 0) { j = (int)nAtomNumber[i_init]; rOld = nSymmRank[j]; @@ -406,7 +406,7 @@ int SetNewRanksFromNeighLists( CANON_GLOBALS *pCG, /* djb-rwth: fixing oss-fuzz issue #69315 */ nNumDiffRanks = 1; - if ((num_atoms > 0) && (num_atoms <= na_global)) + if (num_atoms > 0) { nCurrentRank = (AT_RANK)num_atoms; j = num_atoms - 1; diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichinorm.c b/INCHI-1-SRC/INCHI_BASE/src/ichinorm.c index b5446172..c9a1974d 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichinorm.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichinorm.c @@ -3338,10 +3338,10 @@ int mark_atoms_deriv( inp_ATOM *at, { int i, nFound = 0, ret, j; DERIV_AT da1; + int ret2; /* moved from below 2024-09-01 DT */ + DERIV_AT da2; /* moved from below 2024-09-01 DT */ da1.other_atom = 0; /* djb-rwth: initialisation needed for if conditons */ #if( defined(DERIV_RING_DMOX_DEOX_N) && defined(DERIV_RING_DMOX_DEOX_O) ) - int ret2; - DERIV_AT da2; /* djb-rwth: initialisation needed to avoid garbage values in add_to_da function call */ for (j = 0; j < DERIV_AT_LEN; j++) { diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichiparm.c b/INCHI-1-SRC/INCHI_BASE/src/ichiparm.c index 0a6c7c13..c3623ae2 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichiparm.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichiparm.c @@ -2782,15 +2782,15 @@ void HelpCommandLineParms(INCHI_IOSTREAM* f) inchi_ios_print_nodisplay(f, " SLUUD Make labels for unknown and undefined stereo different\n"); inchi_ios_print_nodisplay(f, " RecMet Include reconnected metals results\n"); inchi_ios_print_nodisplay(f, " FixedH Include Fixed H layer\n"); - inchi_ios_print_nodisplay(f, " KET Account for keto-enol tautomerism (experimental)\n"); - inchi_ios_print_nodisplay(f, " 15T Account for 1,5-tautomerism (experimental)\n"); - - inchi_ios_print_nodisplay(f, " PT_22_00 Account for PT_22_00 tautomerism (experimental)\n"); - inchi_ios_print_nodisplay(f, " PT_16_00 Account for PT_16_00 tautomerism (experimental)\n"); - inchi_ios_print_nodisplay(f, " PT_06_00 Account for PT_06_00 tautomerism (experimental)\n"); - inchi_ios_print_nodisplay(f, " PT_39_00 Account for PT_39_00 tautomerism (experimental)\n"); - inchi_ios_print_nodisplay(f, " PT_13_00 Account for PT_13_00 tautomerism (experimental)\n"); - inchi_ios_print_nodisplay(f, " PT_18_00 Account for PT_18_00 tautomerism (experimental)\n"); + + inchi_ios_print_nodisplay(f, " KET Consider keto-enol tautomerism (experimental)\n"); + inchi_ios_print_nodisplay(f, " 15T Consider 1,5-tautomerism (experimental)\n"); + inchi_ios_print_nodisplay(f, " PT_06_00 Consider 1,3 heteroatom shift (experimental)\n"); + inchi_ios_print_nodisplay(f, " PT_13_00 Consider keten-ynol exchange (experimental)\n"); + inchi_ios_print_nodisplay(f, " PT_16_00 Consider nitroso-oxime tautomerism (experimental)\n"); + inchi_ios_print_nodisplay(f, " PT_18_00 Consider cyanic/iso-cyanic acids (experimental)\n"); + inchi_ios_print_nodisplay(f, " PT_22_00 Consider imine/imine tautomerism (experimental)\n"); + inchi_ios_print_nodisplay(f, " PT_39_00 Consider nitrone/azoxy or Behrend rearrangement (experimental)\n"); inchi_ios_print_nodisplay(f, "Generation\n"); diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichiprt1.c b/INCHI-1-SRC/INCHI_BASE/src/ichiprt1.c index 73ab2c75..9ffc4ee7 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichiprt1.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichiprt1.c @@ -2773,7 +2773,7 @@ int WriteOrigBonds( CANON_GLOBALS *pCG, { /* both atoms belong to a stereo bond */ int kc; - int p1=0, p2, p1NM=0, p2NM, neigh, neigh1, neigh2, bHasMetal, bWellDef; /* djb-rwth: initialising p1 and p1NM */ + int p1 = 0, p2, p1NM = 0, p2NM, neigh, neigh1, neigh2, bHasMetal, bWellDef; /* djb-rwth: initialising p1 and p1NM */ int bNeighSwitched1, bNeighSwitched2; /* djb-rwth: avoiding buffer overrun as picur_sb_parity_ord == -1 is possible */ diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichiprt3.c b/INCHI-1-SRC/INCHI_BASE/src/ichiprt3.c index 42a28ab5..1d6ceb0a 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichiprt3.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichiprt3.c @@ -4106,40 +4106,42 @@ int bin_AuxTautTrans( INCHI_SORT *pINChISort, is20 = pINChISort2; /* djb-rwth: rewritten to avoid memory leaks */ - nTrans_n = (AT_NUMB*)inchi_calloc((long long)num_components + 1, sizeof(nTrans_n[0])); - nTrans_s = (AT_NUMB*)inchi_calloc((long long)num_components + 1, sizeof(nTrans_s[0])); /* Pass 1: save new non-taut numbering */ - /* For each connected component... */ for (i = 0; i < num_components; i++) { is = is0 + i; is2 = is20 + i; - pINChI = ( 0 <= ( ii = GET_II( bOutType, is ) ) ) ? is->pINChI[ii] : NULL; - pINChI_Taut = ( 0 <= ( ii2 = GET_II( OUT_T1, is2 ) ) ) ? is2->pINChI[ii2] : NULL; - if (pINChI && pINChI->nNumberOfAtoms > 0 && + pINChI = (0 <= (ii = GET_II(bOutType, is))) ? is->pINChI[ii] : NULL; + pINChI_Taut = (0 <= (ii2 = GET_II(OUT_T1, is2))) ? is2->pINChI[ii2] : NULL; + if (pINChI && pINChI->nNumberOfAtoms > 0 && pINChI_Taut && pINChI_Taut->nNumberOfAtoms > 0 && /* different components save equal new ord. numbers: */ is->ord_number != is2->ord_number) { - if ( nTrans_n && nTrans_s ) /* djb-rwth: rewritten to avoid memory leaks */ + if (!nTrans_n || !nTrans_s) + { + nTrans_n = (AT_NUMB*)inchi_calloc(num_components + 1, sizeof(nTrans_n[0])); + nTrans_s = (AT_NUMB*)inchi_calloc(num_components + 1, sizeof(nTrans_s[0])); + } + if (nTrans_n && nTrans_s) { /* new ordering number for original non-tautomeric component number is->ord_number */ - nTrans_n[is->ord_number] = /*nTrans_t[is2->ord_number] =*/ i + 1; + nTrans_n[is->ord_number] = i + 1; /*nTrans_t[is2->ord_number] =*/ } } } if (nTrans_n && nTrans_s) { - /* pass 2: get new taut numbering, retrieve new non-taut and save the transposition */ + /* Pass 2: get new taut numbering, retrieve new non-taut and save the transposition */ for (i = 0; i < num_components; i++) { is = is0 + i; is2 = is20 + i; - pINChI = ( 0 <= ( ii = GET_II( bOutType, is ) ) ) ? is->pINChI[ii] : NULL; - pINChI_Taut = ( 0 <= ( ii2 = GET_II( OUT_T1, is2 ) ) ) ? is2->pINChI[ii2] : NULL; - if (pINChI && pINChI->nNumberOfAtoms > 0 && + pINChI = (0 <= (ii = GET_II(bOutType, is))) ? is->pINChI[ii] : NULL; + pINChI_Taut = (0 <= (ii2 = GET_II(OUT_T1, is2))) ? is2->pINChI[ii2] : NULL; + if (pINChI && pINChI->nNumberOfAtoms > 0 && pINChI_Taut && pINChI_Taut->nNumberOfAtoms > 0 && is->ord_number != is2->ord_number && nTrans_n[is2->ord_number]) @@ -4158,16 +4160,20 @@ int bin_AuxTautTrans( INCHI_SORT *pINChISort, *pTrans_s = nTrans_s; ret = 1; } - /* djb-rwth: rewritten to avoid memory leaks */ else { - ret = -1; + if (nTrans_n) + { + inchi_free(nTrans_n); + ret = -1; + } + if (nTrans_s) + { + inchi_free(nTrans_s); + ret = -1; + } } - /* djb-rwth: rewritten to avoid memory leaks */ - inchi_free( nTrans_n ); - inchi_free( nTrans_s ); - return ret; } diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichiread.c b/INCHI-1-SRC/INCHI_BASE/src/ichiread.c index 03ee1b08..e4cf09b6 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichiread.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichiread.c @@ -40,7 +40,7 @@ #include #include -#include /* djb-rwth: needed for boolean variables */ +#include /* #define CHECK_WIN32_VC_HEAP */ @@ -80,15 +80,9 @@ /* */ #include "bcf_s.h" -static int pi_nnc1; /* djb-rwth: required for fixing oss-fuzz issue #69489 */ -static int pi_nnc2; /* djb-rwth: required for fixing oss-fuzz issue #69699 */ -static int pi_nnc3; /* djb-rwth: required for fixing GH issues #27/#28 */ #define SEGM_LINE_ADD 128 -bool if_cnd = true; /* djb-rwth: needed for some if condition restructuring */ -static int nnumcomp_limit; /* djb-rwth: required for fixing oss-fuzz issue #26540 */ - typedef struct tagOneLinkedBond { AT_NUMB neigh; /* canonical number of a neighbor */ @@ -3858,6 +3852,7 @@ int ParseAuxSegmentNumbers(const char* str, /* AuxInfo string int val, ret, k, mpy_component, num; AT_NUMB* pNumb; int base = 10; + int if_cnd = 1; /* djb-rwth: needed for some if condition restructuring */ switch (state) { @@ -3942,10 +3937,10 @@ int ParseAuxSegmentNumbers(const char* str, /* AuxInfo string { val = 1; q = pStart; - if_cnd = true; + if_cnd = 1; } - if (if_cnd && (t = strchr((char*)mult_type, *q)) && q + 1 == pEnd) /* djb-rwth: bool if_cnd applied; ignoring LLVM warning: variable used to store function return value */ + if (if_cnd && (t = strchr((char*)mult_type, *q)) && q + 1 == pEnd) /* djb-rwth: if_cnd applied; ignoring LLVM warning: variable used to store function return value */ { /* Process the abbreviation */ pInChI_From = NULL; @@ -5756,7 +5751,7 @@ int ParseSegmentPerm(const char* str, goto exit_function; } iComponent1 = (int)inchi_strtol(p, &q, 10); - if ((iComponent1 < 1) || (iComponent1 > nNumComponents) || (iComponent1 >= sminor_size)) /* djb-rwth: fixing oss-fuzz issue #66746 */ + if ((iComponent1 < 1) || (iComponent1 > nNumComponents)) /* djb-rwth: fixing oss-fuzz issue #66746 */ { ret = RI_ERR_SYNTAX; /* syntax error */ goto exit_function; @@ -5815,6 +5810,7 @@ int ParseSegmentIsoAtoms(const char* str, const char parity_type[] = "-+TDH"; int bIsoFrom, nCpyType = CPY_ISO_AT; int base = 10; + int if_cnd = 1; /* djb-rwth: needed for some if condition restructuring */ if (str[0] != 'i') { @@ -5872,10 +5868,10 @@ int ParseSegmentIsoAtoms(const char* str, { val = 1; q = pStart; - if_cnd = true; + if_cnd = 1; } - if (if_cnd && (t = strchr((char*)mult_type, *q)) && q + 1 == pEnd) /* djb-rwth: bool if_cnd applied; ignoring LLVM warning: variable used to store function return value */ + if (if_cnd && (t = strchr((char*)mult_type, *q)) && q + 1 == pEnd) /* djb-rwth: if_cnd applied; ignoring LLVM warning: variable used to store function return value */ { /* process the abbreviation */ ret = 0; @@ -6532,7 +6528,7 @@ int ParseSegmentSp3m(const char* str, ret = RI_ERR_ALLOC; /* memory allocation failed */ goto exit_function; } - } +} ret = nNumComponents + 1; } else @@ -6608,6 +6604,7 @@ int ParseSegmentSp3(const char* str, /* input; string of segment starting with int bIso = (state == IST_MOBILE_H_ISO_SP3 || state == IST_FIXED_H_ISO_SP3); INChI* pInChI = pInpInChI[bMobileH]; INChI_Stereo** pStereo = NULL; + int if_cnd = 1; /* djb-rwth: needed for some if condition restructuring */ if (!bIso && state != IST_MOBILE_H_SP3 && state != IST_FIXED_H_SP3) { @@ -6648,7 +6645,7 @@ int ParseSegmentSp3(const char* str, /* input; string of segment starting with { val = 1; q = pStart; - if_cnd = true; + if_cnd = 1; } /* Abbreviation? */ @@ -6879,6 +6876,7 @@ int ParseSegmentSp2(const char* str, int bIsoTo, bIsoFrom, nCpyType = CPY_SP2; int bIso = (state == IST_MOBILE_H_ISO_SP2 || state == IST_FIXED_H_ISO_SP2); int base = 10; + int if_cnd = 1; /* djb-rwth: needed for some if condition restructuring */ if (!bIso && state != IST_MOBILE_H_SP2 && state != IST_FIXED_H_SP2) { @@ -6937,18 +6935,27 @@ int ParseSegmentSp2(const char* str, { val = 1; q = pStart; - if_cnd = true; + if_cnd = 1; } - if (if_cnd && (t = strchr((char*)mult_type, *q)) && q + 1 == pEnd) /* djb-rwth: bool if_cnd applied; ignoring LLVM warning: variable used to store function return value */ + if (if_cnd && (t = strchr((char*)mult_type, *q)) && q + 1 == pEnd) /* djb-rwth: if_cnd applied; ignoring LLVM warning: variable used to store function return value */ { /* process the abbreviation */ ret = 0; #if (FIX_DALKE_BUGS == 1) - if (iComponent + val > nNumComponents) + /* djb-rwth: fixing GH issue #59.2 */ + if ((iComponent + val >= INT_MIN) && (iComponent + val <= INT_MAX)) { - ret = RI_ERR_SYNTAX; /* syntax error */ + if ((iComponent + val > nNumComponents)) + { + ret = RI_ERR_SYNTAX; /* syntax error */ + goto exit_function; + } + } + else + { + ret = BNS_PROGRAM_ERR; goto exit_function; } #endif @@ -6983,7 +6990,7 @@ int ParseSegmentSp2(const char* str, default: ret = RI_ERR_SYNTAX; break; - } + } break; case TAUT_NON: switch (state) @@ -7058,7 +7065,7 @@ int ParseSegmentSp2(const char* str, default: ret = RI_ERR_SYNTAX; break; - } + } if (ret < 0) { goto exit_function; @@ -7096,7 +7103,7 @@ int ParseSegmentSp2(const char* str, } mpy_component = val; goto end_main_cycle; - } + } else /* regular multiplier */ if ((p = strchr(pStart, '*')) && p < pEnd) @@ -7376,7 +7383,7 @@ int ParseSegmentSp2(const char* str, { break; } - } +} if (nNumComponents != iComponent) { ret = RI_ERR_SYNTAX; /* syntax error */ @@ -8001,6 +8008,7 @@ int ParseSegmentCharge(const char* str, int ret; INChI* pInChI = pInpInChI[bMobileH]; const char mult_type[] = "mnMNe"; + int if_cnd = 1; /* djb-rwth: needed for some if condition restructuring */ if (str[0] != 'q') { @@ -8039,11 +8047,11 @@ int ParseSegmentCharge(const char* str, { val = 1; q = pStart; - if_cnd = true; + if_cnd = 1; } - if (if_cnd && (t = strchr((char*)mult_type, *q)) && q + 1 == pEnd) /* djb-rwth: bool if_cnd applied; ignoring LLVM warning: variable used to store function return value */ + if (if_cnd && (t = strchr((char*)mult_type, *q)) && q + 1 == pEnd) /* djb-rwth: if_cnd applied; ignoring LLVM warning: variable used to store function return value */ { /* process the abbreviation */ @@ -8186,11 +8194,11 @@ int ParseSegmentCharge(const char* str, /**************************************************************************** Parse "/h" InChI layer ****************************************************************************/ -int ParseSegmentMobileH( const char *str, - int bMobileH, - INChI *pInpInChI[], - int pnNumComponents[], - int *pbAbc ) +int ParseSegmentMobileH(const char* str, + int bMobileH, + INChI* pInpInChI[], + int pnNumComponents[], + int* pbAbc) { #define nNum_H( ICOMPONENT ) ((bMobileH==TAUT_YES)? pInChI[ICOMPONENT].nNum_H : pInChI[ICOMPONENT].nNum_H_fixed) @@ -8202,15 +8210,15 @@ int ParseSegmentMobileH( const char *str, const char* p, * q, * h, * t, * p1, * pTaut, * pStart, * pEnd; AT_NUMB curAtom, nxtAtom; int state, ret, nAltMobileH = ALT_TAUT(bMobileH); /* djb-rwth: removing redundant variables */ - INChI *pInChI = pInpInChI[bMobileH]; - INChI *pAltInChI = pInpInChI[nAltMobileH]; + INChI* pInChI = pInpInChI[bMobileH]; + INChI* pAltInChI = pInpInChI[nAltMobileH]; int base = 10; num_H = -999; /* impossible value */ num_Minus = -999; /* impossible value */ tg_pos_Tautomer = -999; /* impossible value */ - /* number of immobile H is always allocated; immobile H are present in M layer only */ + /* number of immobile H is always allocated; immobile H are present in M layer only */ nNumComponents = pnNumComponents[bMobileH]; /* djb-rwth: fixing oss-fuzz issues #66985, #66718, #43512, #43456, #43420, #42774, #34772, #30156 */ @@ -8225,7 +8233,7 @@ int ParseSegmentMobileH( const char *str, len = pAltInChI[i].nNumberOfAtoms; if (pInChI[i].nNum_H) { - inchi_free( pInChI[i].nNum_H ); + inchi_free(pInChI[i].nNum_H); pInChI[i].nNum_H = NULL; } } @@ -8241,7 +8249,6 @@ int ParseSegmentMobileH( const char *str, } pInChI[i].nNum_H = pi_nnh2; /* pi_nnh2_init = true; */ - pi_nnc2 = len; } /* copy immobile H from Mobile-H layer to Fixed-H layer */ if (bMobileH == TAUT_NON && i < pnNumComponents[nAltMobileH]) @@ -8249,11 +8256,12 @@ int ParseSegmentMobileH( const char *str, S_CHAR* pai_nnh = (S_CHAR*)realloc(pAltInChI[i].nNum_H, len * sizeof(pAltInChI[0].nNum_H[0])); if (pai_nnh) { + S_CHAR* pi_nnh1 = NULL; /* copied from below to satisfy C syntax 2024-09-01 DT */ pAltInChI[i].nNum_H = pai_nnh; /*if (!pi_nnh2_init) { */ - S_CHAR* pi_nnh1 = (S_CHAR*)inchi_calloc(len, sizeof(pInChI[0].nNum_H[0])); + pi_nnh1 = (S_CHAR*)inchi_calloc(len, sizeof(pInChI[0].nNum_H[0])); if (!pi_nnh1) { ret = RI_ERR_ALLOC; /* allocation error */ @@ -8299,30 +8307,30 @@ int ParseSegmentMobileH( const char *str, } /* Read Hydrogen info in 1 pass */ - - pStart = (char *) str + 1; + + pStart = (char*)str + 1; iComponent = 0; nNumComponents = pnNumComponents[bMobileH]; while (1) { /* cycle over components */ - if (!( pEnd = strchr( pStart, ';' ) )) + if (!(pEnd = strchr(pStart, ';'))) { - pEnd = pStart + strlen( pStart ); + pEnd = pStart + strlen(pStart); } - if (( p = strchr( pStart, '*' ) ) && p < pEnd) + if ((p = strchr(pStart, '*')) && p < pEnd) { - mpy_component = (int) inchi_strtol( pStart, &q, 10 ); + mpy_component = (int)inchi_strtol(pStart, &q, 10); #if ( CHECK_STRTOL_ATNUMB==1 ) - if (mpy_component>MAX_ATOMS || mpy_component<0) + if (mpy_component > MAX_ATOMS || mpy_component < 0) { ret = RI_ERR_SYNTAX; goto exit_function; - } + } #endif #if ( FIX_DALKE_BUGS == 1 ) - if (p != q || !isdigit( UCINT *pStart )) /* prevent non-positive multipliers */ + if (p != q || !isdigit(UCINT* pStart)) /* prevent non-positive multipliers */ #else if (p != q) #endif @@ -8352,12 +8360,12 @@ int ParseSegmentMobileH( const char *str, if (p < pEnd && *pbAbc == -1) { /* check if compressed InChI */ - *pbAbc = ( *p == ',' || isupper( UCINT *p ) ) ? 1 : 0; + *pbAbc = (*p == ',' || isupper(UCINT* p)) ? 1 : 0; } - base = ( *pbAbc == 1 ) ? ALPHA_BASE : 10; + base = (*pbAbc == 1) ? ALPHA_BASE : 10; /* immobile H */ - t = pTaut = ( *pbAbc == 1 ) ? strchr( p, ',' ) : strchr( p, '(' ); /* locate the first tautomer group character */ + t = pTaut = (*pbAbc == 1) ? strchr(p, ',') : strchr(p, '('); /* locate the first tautomer group character */ if (t && bMobileH == TAUT_NON) { @@ -8382,14 +8390,13 @@ int ParseSegmentMobileH( const char *str, } if (iComponent + i < pnNumComponents[nAltMobileH]) { - len = inchi_max( pInChI[iComponent + i].nNumberOfAtoms, pAltInChI[iComponent + i].nNumberOfAtoms ) + 1; + len = inchi_max(pInChI[iComponent + i].nNumberOfAtoms, pAltInChI[iComponent + i].nNumberOfAtoms) + 1; } else { len = pInChI[iComponent + i].nNumberOfAtoms + 1; } - pInChI[iComponent + i].nNum_H_fixed = (S_CHAR *) inchi_calloc( len, sizeof( pInChI[0].nNum_H_fixed[0] ) ); - pi_nnc3 = len; + pInChI[iComponent + i].nNum_H_fixed = (S_CHAR*)inchi_calloc(len, sizeof(pInChI[0].nNum_H_fixed[0])); if (!pInChI[iComponent + i].nNum_H_fixed) { ret = RI_ERR_ALLOC; /* allocation error */ @@ -8398,11 +8405,11 @@ int ParseSegmentMobileH( const char *str, /* compare nAtom */ if (iComponent + i < pnNumComponents[nAltMobileH]) { - len2 = inchi_min( pInChI[iComponent + i].nNumberOfAtoms, pAltInChI[iComponent + i].nNumberOfAtoms ); + len2 = inchi_min(pInChI[iComponent + i].nNumberOfAtoms, pAltInChI[iComponent + i].nNumberOfAtoms); if (pInChI[iComponent + i].nAtom && len2) { /* check */ - if (memcmp( pInChI[iComponent + i].nAtom, pAltInChI[iComponent + i].nAtom, len2 * sizeof( pInChI[0].nAtom[0] ) )) + if (memcmp(pInChI[iComponent + i].nAtom, pAltInChI[iComponent + i].nAtom, len2 * sizeof(pInChI[0].nAtom[0]))) { ret = RI_ERR_SYNTAX; /* syntax error */ goto exit_function; @@ -8412,8 +8419,8 @@ int ParseSegmentMobileH( const char *str, if (pInChI[iComponent + i].nNumberOfAtoms < pAltInChI[iComponent + i].nNumberOfAtoms) { if (pInChI[iComponent + i].nAtom) - inchi_free( pInChI[iComponent + i].nAtom ); - if (!( pInChI[iComponent + i].nAtom = (U_CHAR *) inchi_calloc( len, sizeof( pInChI[0].nAtom[0] ) ) )) + inchi_free(pInChI[iComponent + i].nAtom); + if (!(pInChI[iComponent + i].nAtom = (U_CHAR*)inchi_calloc(len, sizeof(pInChI[0].nAtom[0])))) { ret = RI_ERR_ALLOC; /* allocation error */ goto exit_function; @@ -8438,7 +8445,7 @@ int ParseSegmentMobileH( const char *str, while (p < pTaut) { /* syntax check: atom number */ - if (!*p || !isupper( UCINT *p )) + if (!*p || !isupper(UCINT* p)) { ret = RI_ERR_SYNTAX; /* syntax error */ goto exit_function; @@ -8446,11 +8453,11 @@ int ParseSegmentMobileH( const char *str, if ((curAtom = nxtAtom = (int)inchi_strtol(p, &q, base))) /* djb-rwth: addressing LLVM warning */ { p = q; - if (isupper( UCINT *p )) + if (isupper(UCINT* p)) { - nxtAtom = (int) inchi_strtol( p, &q, base ); + nxtAtom = (int)inchi_strtol(p, &q, base); #if ( CHECK_STRTOL_ATNUMB==1 ) - if (nxtAtom>MAX_ATOMS || nxtAtom<0) + if (nxtAtom > MAX_ATOMS || nxtAtom < 0) { ret = RI_ERR_SYNTAX; goto exit_function; @@ -8465,7 +8472,7 @@ int ParseSegmentMobileH( const char *str, goto exit_function; } /* number of H, may be negative */ - if (!( num_H = (int) inchi_strtol( p, &q, 10 ) ) || q > pTaut) + if (!(num_H = (int)inchi_strtol(p, &q, 10)) || q > pTaut) { ret = RI_ERR_SYNTAX; /* syntax error */ goto exit_function; @@ -8497,7 +8504,7 @@ int ParseSegmentMobileH( const char *str, #if ( FIX_GAF_2019_1==1 ) { char invalid; - const char *str1 = str + 1; + const char* str1 = str + 1; if (bMobileH == TAUT_NON) /* FixedH layer "/h"*/ { invalid = str1[strspn(str1, "0123456789hDHT-,;()*")]; @@ -8516,13 +8523,13 @@ int ParseSegmentMobileH( const char *str, while (p < pTaut) { /* syntax check: atom number */ - if (!*p || !isdigit( UCINT *p )) + if (!*p || !isdigit(UCINT* p)) { ret = RI_ERR_SYNTAX; /* syntax error */ goto exit_function; } /* number of H */ - h = p + strcspn( p, "Hh" ); + h = p + strcspn(p, "Hh"); /*h = strchr( p, 'H' );*/ if (!*h || h >= pTaut) { @@ -8533,15 +8540,15 @@ int ParseSegmentMobileH( const char *str, h = NULL; break; */ /* no more H found */ } - num_H = ( *h == 'H' ) ? 1 : ( *h == 'h' ) ? -1 : 0; + num_H = (*h == 'H') ? 1 : (*h == 'h') ? -1 : 0; if (!num_H) { ret = RI_ERR_SYNTAX; /* syntax error */ goto exit_function; } - if (h[1] && isdigit( UCINT h[1] )) + if (h[1] && isdigit(UCINT h[1])) { - num_H *= (int) inchi_strtol( h + 1, &p1, 10 ); + num_H *= (int)inchi_strtol(h + 1, &p1, 10); } else { @@ -8554,17 +8561,17 @@ int ParseSegmentMobileH( const char *str, /* list of atoms that have num_H */ while (p < h) { - if (!*p || !isdigit( UCINT *p )) + if (!*p || !isdigit(UCINT* p)) { ret = RI_ERR_SYNTAX; /* syntax error */ goto exit_function; } - nxtAtom = curAtom = (int) inchi_strtol( p, &q, 10 ); + nxtAtom = curAtom = (int)inchi_strtol(p, &q, 10); if (*q == '-') { - nxtAtom = (int) inchi_strtol( q + 1, &q, 10 ); + nxtAtom = (int)inchi_strtol(q + 1, &q, 10); #if ( CHECK_STRTOL_ATNUMB==1 ) - if (nxtAtom>MAX_ATOMS || nxtAtom<0) + if (nxtAtom > MAX_ATOMS || nxtAtom < 0) { ret = RI_ERR_SYNTAX; goto exit_function; @@ -8573,7 +8580,7 @@ int ParseSegmentMobileH( const char *str, } /* consitency check */ if (!curAtom || curAtom > numCtAtoms || - nxtAtom < curAtom || nxtAtom > numCtAtoms) + nxtAtom < curAtom || nxtAtom > numCtAtoms) { ret = RI_ERR_SYNTAX; /* syntax error */ goto exit_function; @@ -8641,7 +8648,7 @@ int ParseSegmentMobileH( const char *str, while (p < pEnd) { /* start t-group */ - if (!isdigit( UCINT *p ) || !( num_H = (int) inchi_strtol( p, &q, 10 ) ) || q > pEnd) + if (!isdigit(UCINT* p) || !(num_H = (int)inchi_strtol(p, &q, 10)) || q > pEnd) { ret = RI_ERR_SYNTAX; /* syntax error */ goto exit_function; @@ -8651,9 +8658,9 @@ int ParseSegmentMobileH( const char *str, if (*p == '-') { p++; - if (isdigit( UCINT *p )) + if (isdigit(UCINT* p)) { - num_Minus = (int) inchi_strtol( p, &q, 10 ); + num_Minus = (int)inchi_strtol(p, &q, 10); p = q; } else @@ -8690,7 +8697,7 @@ int ParseSegmentMobileH( const char *str, This does not include zero termination! */ - tg_alloc_len = ( ( 3 + INCHI_T_NUM_MOVABLE )*pInChI[iComponent].nNumberOfAtoms ) / 2 + 1; + tg_alloc_len = ((3 + INCHI_T_NUM_MOVABLE) * pInChI[iComponent].nNumberOfAtoms) / 2 + 1; for (i = 0; i < mpy_component; i++) { pInChI[iComponent + i].nTautomer = (AT_NUMB*)inchi_calloc((long long)tg_alloc_len + 1, sizeof(pInChI->nTautomer[0])); /* djb-rwth: cast operator added */ @@ -8718,10 +8725,10 @@ int ParseSegmentMobileH( const char *str, lenTautomer = tg_pos_Tautomer + 3; /* first atom number position */ num_taut_H_component += num_H; - while (p < pEnd && isupper( UCINT *p )) + while (p < pEnd && isupper(UCINT* p)) { /* read list of tautomeric atoms */ - val = (int) inchi_strtol( p, &q, base ); + val = (int)inchi_strtol(p, &q, base); if (lenTautomer >= tg_alloc_len || val > numCtAtoms) { ret = RI_ERR_PROGR; /* wrong tautomer array length */ @@ -8761,180 +8768,181 @@ int ParseSegmentMobileH( const char *str, /* t-group */ switch (*p) { - case '(': /* start t-group */ - switch (state) + case '(': /* start t-group */ + switch (state) + { + case ')': + state = *p++; + num_H = 0; + num_Minus = 0; + continue; + default: + ret = RI_ERR_SYNTAX; /* syntax error */ + goto exit_function; + } + case ')': /* end t-group */ + switch (state) + { + case 'A': /* previuos was atom number */ + if (!tg_alloc_len) { - case ')': - state = *p++; - num_H = 0; - num_Minus = 0; - continue; - default: - ret = RI_ERR_SYNTAX; /* syntax error */ - goto exit_function; + ret = RI_ERR_SYNTAX; /* syntax error */ + goto exit_function; } - case ')': /* end t-group */ - switch (state) + iTGroup++; + state = *p++; + pInChI[iComponent].nTautomer[tg_pos_Tautomer] = lenTautomer - tg_pos_Tautomer - 1; /* length of the rest of the t-group */ + pInChI[iComponent].lenTautomer = lenTautomer; + continue; + default: + ret = RI_ERR_SYNTAX; /* syntax error */ + goto exit_function; + } + case 'H': /* number of H */ + switch (state) + { + case '(': + state = *p++; + num_H = 1; + continue; + default: + ret = RI_ERR_SYNTAX; /* syntax error */ + goto exit_function; + } + case '-': /* number of (-) */ + switch (state) + { + case 'N': /* previous was number of H */ + case 'H': /* previous was H */ + state = *p++; + num_Minus = 1; + continue; + default: + ret = RI_ERR_SYNTAX; /* syntax error */ + goto exit_function; + } + case ',': + switch (state) + { + case 'N': /* previous was number of H */ + case 'H': /* previous was H */ + case '-': /* previuos was - */ + case 'M': /* previous was number of (-) */ + /* the next must be the first tautomeric atom number; save num_H & num_Minus */ + if (num_H <= 0 && num_Minus <= 0) + { + ret = RI_ERR_SYNTAX; /* syntax error */ + goto exit_function; + } + if (!tg_alloc_len) { - case 'A': /* previuos was atom number */ - if (!tg_alloc_len) + /* + --- header --- + [num_t_groups] + --- one t-group: --- + [len=group length no including this value] + [num_H] + [num_(-)] + [Endpoint(1),...,Endpoint(len-2)] + --- next t-group --- + ... + + Max. size = 1 + 3*max_num_t_groups + max_num_endpoints + + max_num_t_groups = num_at/2 + max_num_endpoints = num_at + + Max. size = 1 + 3*(num_at/2) + num_at = 1 + (5*num_at)/2 + 5 = 3 + INCHI_T_NUM_MOVABLE = 3 + num_types_of_attachments + + This does not include zero termination! + + */ + tg_alloc_len = ((3 + INCHI_T_NUM_MOVABLE) * pInChI[iComponent].nNumberOfAtoms) / 2 + 1; + for (i = 0; i < mpy_component; i++) + { + /* djb-rwth: fixing oss-fuzz issue #68314 */ + AT_NUMB* pinchi_icint = (AT_NUMB*)inchi_calloc((long long)tg_alloc_len + 1, sizeof(pInChI->nTautomer[0])); /* djb-rwth: cast operator added */ + if (!pinchi_icint) { - ret = RI_ERR_SYNTAX; /* syntax error */ + ret = RI_ERR_ALLOC; /* allocation error */ goto exit_function; } - iTGroup++; - state = *p++; - pInChI[iComponent].nTautomer[tg_pos_Tautomer] = lenTautomer - tg_pos_Tautomer - 1; /* length of the rest of the t-group */ - pInChI[iComponent].lenTautomer = lenTautomer; - continue; - default: - ret = RI_ERR_SYNTAX; /* syntax error */ - goto exit_function; + pInChI[iComponent + i].nTautomer = pinchi_icint; + pInChI[iComponent + i].lenTautomer = 0; + } + tg_pos_Tautomer = 1; /* number atoms (NumAt+2) position */ } - case 'H': /* number of H */ - switch (state) + else { - case '(': - state = *p++; - num_H = 1; - continue; - default: - ret = RI_ERR_SYNTAX; /* syntax error */ - goto exit_function; + /* next t-group */ + tg_pos_Tautomer = lenTautomer; } - case '-': /* number of (-) */ - switch (state) + if (tg_pos_Tautomer + 3 >= tg_alloc_len) { - case 'N': /* previous was number of H */ - case 'H': /* previous was H */ - state = *p++; - num_Minus = 1; - continue; - default: - ret = RI_ERR_SYNTAX; /* syntax error */ - goto exit_function; + ret = RI_ERR_PROGR; /* wrong tautomer array length */ + goto exit_function; } - case ',': - switch (state) + pInChI[iComponent].nTautomer[tg_pos_Tautomer + 1] = num_H; + pInChI[iComponent].nTautomer[tg_pos_Tautomer + 2] = num_Minus; + lenTautomer = tg_pos_Tautomer + 3; /* first atom number position */ + /* djb-rwth: fixing GH issue #59.1 */ + if (num_H >= INT_MIN && num_H <= INT_MAX) { - case 'N': /* previous was number of H */ - case 'H': /* previous was H */ - case '-': /* previuos was - */ - case 'M': /* previous was number of (-) */ - /* the next must be the first tautomeric atom number; save num_H & num_Minus */ - if (num_H <= 0 && num_Minus <= 0) - { - ret = RI_ERR_SYNTAX; /* syntax error */ - goto exit_function; - } - if (!tg_alloc_len) - { - /* - --- header --- - [num_t_groups] - --- one t-group: --- - [len=group length no including this value] - [num_H] - [num_(-)] - [Endpoint(1),...,Endpoint(len-2)] - --- next t-group --- - ... - - Max. size = 1 + 3*max_num_t_groups + max_num_endpoints - - max_num_t_groups = num_at/2 - max_num_endpoints = num_at - - Max. size = 1 + 3*(num_at/2) + num_at = 1 + (5*num_at)/2 - 5 = 3 + INCHI_T_NUM_MOVABLE = 3 + num_types_of_attachments - - This does not include zero termination! - - */ - tg_alloc_len = ( ( 3 + INCHI_T_NUM_MOVABLE )*pInChI[iComponent].nNumberOfAtoms ) / 2 + 1; - for (i = 0; i < mpy_component; i++) - { - /* djb-rwth: fixing oss-fuzz issue #68314 */ - if (iComponent + i < nnumcomp_limit) - { - AT_NUMB* pinchi_icint = (AT_NUMB*)inchi_calloc((long long)tg_alloc_len + 1, sizeof(pInChI->nTautomer[0])); /* djb-rwth: cast operator added */ - if (!pinchi_icint) - { - ret = RI_ERR_ALLOC; /* allocation error */ - goto exit_function; - } - pInChI[iComponent + i].nTautomer = pinchi_icint; - pInChI[iComponent + i].lenTautomer = 0; - } - else - { - ret = RI_ERR_ALLOC; /* allocation error */ - goto exit_function; - } - } - tg_pos_Tautomer = 1; /* number atoms (NumAt+2) position */ - } - else - { - /* next t-group */ - tg_pos_Tautomer = lenTautomer; - } - if (tg_pos_Tautomer + 3 >= tg_alloc_len) - { - ret = RI_ERR_PROGR; /* wrong tautomer array length */ - goto exit_function; - } - pInChI[iComponent].nTautomer[tg_pos_Tautomer + 1] = num_H; - pInChI[iComponent].nTautomer[tg_pos_Tautomer + 2] = num_Minus; - lenTautomer = tg_pos_Tautomer + 3; /* first atom number position */ - num_taut_H_component += num_H; - state = *p++; - continue; - case 'A': - /* previuos was atom number */ - state = *p++; - continue; - default: - ret = RI_ERR_SYNTAX; /* syntax error */ - goto exit_function; + num_taut_H_component += num_H; } + else + { + ret = BNS_PROGRAM_ERR; + goto exit_function; + } + state = *p++; + continue; + case 'A': + /* previuos was atom number */ + state = *p++; + continue; default: - if (isdigit( UCINT *p )) + ret = RI_ERR_SYNTAX; /* syntax error */ + goto exit_function; + } + default: + if (isdigit(UCINT* p)) + { + val = (int)inchi_strtol(p, &q, 10); + if (val <= 0) { - val = (int) inchi_strtol( p, &q, 10 ); - if (val <= 0) + ret = RI_ERR_SYNTAX; /* syntax error */ + goto exit_function; + } + p = q; + switch (state) + { + case 'H': + num_H = val; + state = 'N'; + continue; + case '-': + num_Minus = val; + state = 'M'; + continue; + case ',': + if (lenTautomer >= tg_alloc_len || val > numCtAtoms) { - ret = RI_ERR_SYNTAX; /* syntax error */ + ret = RI_ERR_PROGR; /* wrong tautomer array length */ goto exit_function; } - p = q; - switch (state) - { - case 'H': - num_H = val; - state = 'N'; - continue; - case '-': - num_Minus = val; - state = 'M'; - continue; - case ',': - if (lenTautomer >= tg_alloc_len || val > numCtAtoms) - { - ret = RI_ERR_PROGR; /* wrong tautomer array length */ - goto exit_function; - } - num_Atoms++; - pInChI[iComponent].nTautomer[lenTautomer++] = val; - state = 'A'; - continue; - default: - ret = RI_ERR_SYNTAX; /* syntax error */ - goto exit_function; - } + num_Atoms++; + pInChI[iComponent].nTautomer[lenTautomer++] = val; + state = 'A'; + continue; + default: + ret = RI_ERR_SYNTAX; /* syntax error */ + goto exit_function; } - ret = RI_ERR_SYNTAX; /* syntax error */ - goto exit_function; + } + ret = RI_ERR_SYNTAX; /* syntax error */ + goto exit_function; } } if (!iTGroup || state != ')') @@ -8946,13 +8954,13 @@ int ParseSegmentMobileH( const char *str, } } /* check num_H in components; for bMobileH=TAUT_NON, pInChI->nNum_H_fixed[] has not been added to pInChI->nNum_H[] yet */ - if (0 > ( ret2 = GetInChIFormulaNumH( pInChI + iComponent, &num_H_formula ) ) || - 0 > ( ret2 = GetInChINumH( pInChI + iComponent, &num_H_InChI ) )) + if (0 > (ret2 = GetInChIFormulaNumH(pInChI + iComponent, &num_H_formula)) || + 0 > (ret2 = GetInChINumH(pInChI + iComponent, &num_H_InChI))) { ret = ret2; goto exit_function; } - if (num_H_formula != num_H_InChI + ( bMobileH == TAUT_NON ? num_H_component : 0 )) + if (num_H_formula != num_H_InChI + (bMobileH == TAUT_NON ? num_H_component : 0)) { ret = RI_ERR_SYNTAX; /* syntax error */ goto exit_function; @@ -8962,7 +8970,7 @@ int ParseSegmentMobileH( const char *str, for (i = 1; i < mpy_component; i++) { #if ( FIX_GAF_2019_2==1 ) - if ((iComponent + i > nNumComponents - 1) || (iComponent + i < 0)) + if ((iComponent + i > nNumComponents - 1) || (iComponent + i < 0)) { ret = RI_ERR_SYNTAX; /* syntax error */ goto exit_function; @@ -8975,11 +8983,6 @@ int ParseSegmentMobileH( const char *str, } #endif /* djb-rwth: fixing oss-fuzz issue #69699 */ - if ((iComponent < 0) || (iComponent > pi_nnc2)) - { - ret = RI_ERR_SYNTAX; /* syntax error */ - goto exit_function; - } if (nNum_H(iComponent)) /* djb-rwth: fixing GH issues #27/#28 */ { memcpy(nNum_H(iComponent + i), nNum_H(iComponent), pInChI[iComponent + i].nNumberOfAtoms * sizeof(nNum_H(0)[0])); @@ -8995,13 +8998,13 @@ int ParseSegmentMobileH( const char *str, pInChI[iComponent + i].lenTautomer = pInChI[iComponent].lenTautomer; } /* check num_H in components */ - if (0 > ( ret2 = GetInChIFormulaNumH( pInChI + iComponent + i, &num_H_formula ) ) || - 0 > ( ret2 = GetInChINumH( pInChI + iComponent + i, &num_H_InChI ) )) + if (0 > (ret2 = GetInChIFormulaNumH(pInChI + iComponent + i, &num_H_formula)) || + 0 > (ret2 = GetInChINumH(pInChI + iComponent + i, &num_H_InChI))) { ret = ret2; goto exit_function; } - if (num_H_formula != num_H_InChI + ( bMobileH == TAUT_NON ? num_H_component : 0 )) + if (num_H_formula != num_H_InChI + (bMobileH == TAUT_NON ? num_H_component : 0)) { ret = RI_ERR_SYNTAX; /* syntax error */ goto exit_function; @@ -9883,7 +9886,6 @@ int ParseSegmentFormula(const char* str, { /* allocate InChI */ pInChI = (INChI*)inchi_calloc(nNumComponents, sizeof(INChI)); - pi_nnc1 = nNumComponents; if (!(pInChI)) { return RI_ERR_ALLOC; /* alloc failure */ @@ -9895,6 +9897,8 @@ int ParseSegmentFormula(const char* str, char** piibmi_shf = (char**)inchi_malloc(nNumComponents * sizeof(char*)); */ for (i = 0; i < nNumComponents; i++) { + U_CHAR* piibmi_na = NULL; /* copied from below to obey C syntax - 2024-09-01 DT */ + char* piibmi_shf = NULL; /* copied from below to obey C syntax - 2024-09-01 DT */ /* copy number of atoms */ len = pInpInChI[bMobileH][i].nNumberOfAtoms = pInpInChI[nAltMobileH][i].nNumberOfAtoms; /* copy atoms */ @@ -9903,7 +9907,7 @@ int ParseSegmentFormula(const char* str, { inchi_free(pInpInChI[bMobileH][i].nAtom); } - U_CHAR* piibmi_na = (U_CHAR*)inchi_malloc(((long long)len + 1) * sizeof(pInpInChI[0][0].nAtom[0])); + piibmi_na = (U_CHAR*)inchi_malloc(((long long)len + 1) * sizeof(pInpInChI[0][0].nAtom[0])); if (piibmi_na) /* djb-rwth: cast operator added; addressing LLVM warning */ { memcpy(piibmi_na, pInpInChI[nAltMobileH][i].nAtom, len); @@ -9920,7 +9924,7 @@ int ParseSegmentFormula(const char* str, { inchi_free(pInpInChI[bMobileH][i].szHillFormula); } - char* piibmi_shf = (char*)inchi_malloc((inchi_max(len, 2)) * sizeof(char)); + piibmi_shf = (char*)inchi_malloc((inchi_max(len, 2)) * sizeof(char)); if (piibmi_shf) /* djb-rwth: addressing LLVM warning */ { memcpy(piibmi_shf, pInpInChI[nAltMobileH][i].szHillFormula, len); @@ -9964,12 +9968,11 @@ int ParseSegmentFormula(const char* str, } /* allocate InChI */ - if (!(pInpInChI[bMobileH] = (INChI*)inchi_calloc(nNumComponents, sizeof(INChI)))) + if (!((sizeof(INChI) > 0) && (pInpInChI[bMobileH] = (INChI*)inchi_calloc(nNumComponents, sizeof(INChI))))) /* djb-rwth: fixing GH issue #58 */ { return RI_ERR_ALLOC; /* alloc failure */ } pInChI = pInpInChI[bMobileH]; - nnumcomp_limit = nNumComponents; /* Pass 2. Count elements, save formulas and elements */ pStart = (char*)str; @@ -10151,12 +10154,13 @@ int ParseSegmentFormula(const char* str, } else { + U_CHAR* pci1 = NULL; /* copied from below to obey C syntax - 2024-09-01 DT */ /* Copy duplicated formula */ strcpy(pInChI[iComponent + i].szHillFormula, pInChI[iComponent].szHillFormula); /* Copy atoms in the duplicated formula */ pInChI[iComponent + i].nNumberOfAtoms = nNumAtoms; /* djb-rwth: fixing oss-fuzz issue #43420, #34772 */ - U_CHAR* pci1 = (U_CHAR*)inchi_malloc((long long)nNumAtoms + 1); /* djb-rwth: cast operator added */ + pci1 = (U_CHAR*)inchi_malloc((long long)nNumAtoms + 1); /* djb-rwth: cast operator added */ if (!pci1) { return RI_ERR_ALLOC; /* failed allocation */ @@ -10251,6 +10255,9 @@ int CopySegment(INChI* pInChITo, stereoFrom->nBondAtom1 && stereoFrom->nBondAtom2)) /* djb-rwth: addressing LLVM warning */ { + S_CHAR* pst0_bp = NULL; /* copied from below to obey C syntax - 2024-09-01 DT */ + AT_NUMB* pst0_nba1 = NULL; /* copied from below to obey C syntax - 2024-09-01 DT */ + AT_NUMB* pst0_nba2 = NULL; /* copied from below to obey C syntax - 2024-09-01 DT */ len = (bIsotopicFrom < 0) ? 0 : stereoFrom->nNumberOfStereoBonds; pstereoTo = bIsotopicTo ? &pInChITo->StereoIsotopic : &pInChITo->Stereo; @@ -10273,9 +10280,9 @@ int CopySegment(INChI* pInChITo, /* allocate sp2 stereo */ /* djb-rwth: fixing oss-fuzz issue #66985 */ /* djb-rwth: cast operators added */ - S_CHAR* pst0_bp = (S_CHAR*)inchi_calloc((long long)len + 1, sizeof(pstereoTo[0]->b_parity[0])); - AT_NUMB* pst0_nba1 = (AT_NUMB*)inchi_calloc((long long)len + 1, sizeof(pstereoTo[0]->nBondAtom1[0])); - AT_NUMB* pst0_nba2 = (AT_NUMB*)inchi_calloc((long long)len + 1, sizeof(pstereoTo[0]->nBondAtom2[0])); + pst0_bp = (S_CHAR*)inchi_calloc((long long)len + 1, sizeof(pstereoTo[0]->b_parity[0])); + pst0_nba1 = (AT_NUMB*)inchi_calloc((long long)len + 1, sizeof(pstereoTo[0]->nBondAtom1[0])); + pst0_nba2 = (AT_NUMB*)inchi_calloc((long long)len + 1, sizeof(pstereoTo[0]->nBondAtom2[0])); pstereoTo[0]->b_parity = pst0_bp; pstereoTo[0]->nBondAtom1 = pst0_nba1; pstereoTo[0]->nBondAtom2 = pst0_nba2; @@ -12320,29 +12327,22 @@ static int SegmentSp3ProcessAbbreviation(int* mpy_component, for (i = 0; i < val; i++) { /* djb-rwth: fixing oss-fuzz issue #26540 */ - if (iComponent + i <= nnumcomp_limit) + ret = CopySegment(pInChI + iComponent + i, pInChIFrom + iComponent + i, nCpyType, bIsoTo, bIsoFrom); + if (!ret) { - ret = CopySegment(pInChI + iComponent + i, pInChIFrom + iComponent + i, nCpyType, bIsoTo, bIsoFrom); - if (!ret) - { - ret = RI_ERR_SYNTAX; /* syntax error */ - } - if (ret < 0) - { - return ret; - } - if (bIsoFrom >= 0) - { - INChI_Stereo* pStereoTo = bIsoTo ? pInChI[iComponent + i].StereoIsotopic : pInChI[iComponent + i].Stereo; - if (pStereoTo) - { - pStereoTo->nCompInv2Abs = NO_VALUE_INT; /* in case there in no /m segment after this */ - } - } + ret = RI_ERR_SYNTAX; /* syntax error */ } - else + if (ret < 0) { - ret = RI_ERR_ALLOC; + return ret; + } + if (bIsoFrom >= 0) + { + INChI_Stereo* pStereoTo = bIsoTo ? pInChI[iComponent + i].StereoIsotopic : pInChI[iComponent + i].Stereo; + if (pStereoTo) + { + pStereoTo->nCompInv2Abs = NO_VALUE_INT; /* in case there in no /m segment after this */ + } } } diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichirvr1.c b/INCHI-1-SRC/INCHI_BASE/src/ichirvr1.c index 29e66749..4156c8fb 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichirvr1.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichirvr1.c @@ -749,13 +749,13 @@ int cmp_charge_val( const void *a1, const void *a2, void *p ) int bMayBeACationInMobileHLayer( inp_ATOM *at, VAL_AT *pVA, int iat, int bMobileH ) { int j, neigh; + U_CHAR cVal; /* moved from below 2024-09-01 DT */ if (!bMobileH || !at[iat].num_H) { return 1; } /* cVal, cation valence */ - U_CHAR cVal; switch ( at[iat].el_number ) { case EL_NUMBER_N: /* fallthrough */ case EL_NUMBER_P: @@ -5277,6 +5277,7 @@ int MakeOneInChIOutOfStrFromINChI( struct tagCANON_GLOBALS *pCG, /* djb-rwth: introducing variables for correct nAllocMode expression */ int nAM1 = 0, nAM2 = 0; + int nAllocMode = 0; /* copied from below 2024-09-01 DT */ if (k == TAUT_YES) nAM1 = REQ_MODE_TAUT; @@ -5284,7 +5285,7 @@ int MakeOneInChIOutOfStrFromINChI( struct tagCANON_GLOBALS *pCG, if (bTautFlagsDone & (TG_FLAG_FOUND_ISOTOPIC_H_DONE | TG_FLAG_FOUND_ISOTOPIC_ATOM_DONE)) nAM2 = ip->nMode & REQ_MODE_ISO; - int nAllocMode = nAM1 | nAM2; /* djb-rwth: original sequence of bit-wise operations had to be rewritten */ + nAllocMode = nAM1 | nAM2; /* djb-rwth: original sequence of bit-wise operations had to be rewritten */ if ((k == TAUT_NON && ( ip->nMode & REQ_MODE_BASIC )) || (k == TAUT_YES && ( ip->nMode & REQ_MODE_TAUT ))) /* djb-rwth: addressing LLVM warnings */ diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichirvr2.c b/INCHI-1-SRC/INCHI_BASE/src/ichirvr2.c index cbdbf1af..fd6ef0ec 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichirvr2.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichirvr2.c @@ -115,6 +115,7 @@ int RestoreAtomConnectionsSetStereo( StrFromINChI *pStruct, int num_stereo_bonds2, num_stereo_centers2; /* djb-rwth: removing redundant variables */ INChI_Stereo *pStereo = NULL, *pStereo2 = NULL; AT_NUMB nCumulene[MAX_CUMULENE_LEN + 2]; + inp_ATOM* at = NULL; /* copied from below 2024-09-01 DT */ num_atoms = pInChI->nNumberOfAtoms; if (num_atoms <= 0) @@ -125,7 +126,7 @@ int RestoreAtomConnectionsSetStereo( StrFromINChI *pStruct, INCHI_HEAPCHK /* atoms */ - inp_ATOM* at = (inp_ATOM*)inchi_calloc(num_atoms, sizeof(pStruct->at[0])); + at = (inp_ATOM*)inchi_calloc(num_atoms, sizeof(pStruct->at[0])); if (!at) { ret = RI_ERR_ALLOC; diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichirvr4.c b/INCHI-1-SRC/INCHI_BASE/src/ichirvr4.c index 4a9ec9b4..93c5f38f 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichirvr4.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichirvr4.c @@ -54,15 +54,15 @@ #include "bcf_s.h" /****************************************************************************/ -int ForbidCarbonChargeEdges( BN_STRUCT *pBNS, - ALL_TC_GROUPS *pTCGroups, - EDGE_LIST *pCarbonChargeEdges, - int forbidden_edge_mask ) +int ForbidCarbonChargeEdges(BN_STRUCT* pBNS, + ALL_TC_GROUPS* pTCGroups, + EDGE_LIST* pCarbonChargeEdges, + int forbidden_edge_mask) { #define MAX_NUM_CARBON_CHARGE_EDGES 2 int nType, i, k, ret; - BNS_EDGE *pEdge; - if ((ret = AllocEdgeList( pCarbonChargeEdges, MAX_NUM_CARBON_CHARGE_EDGES) )) /* djb-rwth: addressing LLVM warning */ + BNS_EDGE* pEdge; + if ((ret = AllocEdgeList(pCarbonChargeEdges, MAX_NUM_CARBON_CHARGE_EDGES))) /* djb-rwth: addressing LLVM warning */ { goto exit_function; } @@ -71,26 +71,26 @@ int ForbidCarbonChargeEdges( BN_STRUCT *pBNS, { switch (i) { - case 0: - nType = TCG_Plus_C0; - break; - case 1: - nType = TCG_Minus_C0; - break; - default: - ret = RI_ERR_PROGR; - goto exit_function; + case 0: + nType = TCG_Plus_C0; + break; + case 1: + nType = TCG_Minus_C0; + break; + default: + ret = RI_ERR_PROGR; + goto exit_function; } - if (( k = pTCGroups->nGroup[nType] ) >= 0) + if ((k = pTCGroups->nGroup[nType]) >= 0) { k = pTCGroups->pTCG[k].nForwardEdge; if (k > 0) { pEdge = pBNS->edge + k; - if (!( pEdge->forbidden & forbidden_edge_mask )) + if (!(pEdge->forbidden & forbidden_edge_mask)) { pEdge->forbidden |= forbidden_edge_mask; - if ((ret = AddToEdgeList( pCarbonChargeEdges, k, 0 ))) /* djb-rwth: addressing LLVM warning */ + if ((ret = AddToEdgeList(pCarbonChargeEdges, k, 0))) /* djb-rwth: addressing LLVM warning */ { goto exit_function; } @@ -113,36 +113,36 @@ int ForbidCarbonChargeEdges( BN_STRUCT *pBNS, /****************************************************************************/ -int ForbidNintrogenPlus2BondsInSmallRings( BN_STRUCT *pBNS, - inp_ATOM *at, - int num_at, - VAL_AT *pVA, - int min_ring_size, - ALL_TC_GROUPS *pTCGroups, - EDGE_LIST *pNplus2BondsEdges, - int forbidden_edge_mask ) +int ForbidNintrogenPlus2BondsInSmallRings(BN_STRUCT* pBNS, + inp_ATOM* at, + int num_at, + VAL_AT* pVA, + int min_ring_size, + ALL_TC_GROUPS* pTCGroups, + EDGE_LIST* pNplus2BondsEdges, + int forbidden_edge_mask) { int i, j, ret; - BNS_EDGE *e; + BNS_EDGE* e; /* djb-rwth: removing redundant code */ /* --- forbid edges that allow to make =N(+)= or #N(+)- in small ring */ for (i = 0; i < num_at; i++) { if (at[i].valence == 2 && - !at[i].num_H && !at[i].endpoint && - pVA[i].cNumValenceElectrons == 5 && - pVA[i].cPeriodicRowNumber == 1 && - !pVA[i].cMaxFlowToMetal && pVA[i].nCPlusGroupEdge > 0 && - pVA[i].cnListIndex > 0 && cnList[pVA[i].cnListIndex - 1].bits == cn_bits_MNP && - pVA[i].cMinRingSize && pVA[i].cMinRingSize <= min_ring_size) + !at[i].num_H && !at[i].endpoint && + pVA[i].cNumValenceElectrons == 5 && + pVA[i].cPeriodicRowNumber == 1 && + !pVA[i].cMaxFlowToMetal && pVA[i].nCPlusGroupEdge > 0 && + pVA[i].cnListIndex > 0 && cnList[pVA[i].cnListIndex - 1].bits == cn_bits_MNP && + pVA[i].cMinRingSize && pVA[i].cMinRingSize <= min_ring_size) { - e = pBNS->edge + ( j = pVA[i].nCPlusGroupEdge - 1 ); - if (!( e->forbidden & forbidden_edge_mask )) + e = pBNS->edge + (j = pVA[i].nCPlusGroupEdge - 1); + if (!(e->forbidden & forbidden_edge_mask)) { e->forbidden |= forbidden_edge_mask; - if ((ret = AddToEdgeList( pNplus2BondsEdges, j, 128 ))) /* djb-rwth: addressing LLVM warning */ + if ((ret = AddToEdgeList(pNplus2BondsEdges, j, 128))) /* djb-rwth: addressing LLVM warning */ { goto exit_function; } @@ -174,16 +174,16 @@ less H than in the input InChI (charge from onium cannot be moved to remove H+) ****************************************************************************/ -int FixLessHydrogenInFormula( BN_STRUCT *pBNS, - BN_DATA *pBD, - StrFromINChI *pStruct, - inp_ATOM *at, - inp_ATOM *at2, - inp_ATOM *atf, - VAL_AT *pVA, - ALL_TC_GROUPS *pTCGroups, - int *pnNumRunBNS, - int *pnTotalDelta, int forbidden_edge_mask ) +int FixLessHydrogenInFormula(BN_STRUCT* pBNS, + BN_DATA* pBD, + StrFromINChI* pStruct, + inp_ATOM* at, + inp_ATOM* at2, + inp_ATOM* atf, + VAL_AT* pVA, + ALL_TC_GROUPS* pTCGroups, + int* pnNumRunBNS, + int* pnTotalDelta, int forbidden_edge_mask) { int iBPlus = NO_VERTEX, iNV = NO_VERTEX, iNH = NO_VERTEX, neigh; EDGE_LIST NewlyFixedEdges; @@ -194,24 +194,24 @@ int FixLessHydrogenInFormula( BN_STRUCT *pBNS, Vertex vPathStart, vPathEnd; int nPathLen, nDeltaH, nDeltaCharge, nNumVisitedAtoms; - AllocEdgeList( &NewlyFixedEdges, EDGE_LIST_CLEAR ); - if ((ret = AllocEdgeList( &NewlyFixedEdges, 2 * num_at ))) /* djb-rwth: addressing LLVM warning */ + AllocEdgeList(&NewlyFixedEdges, EDGE_LIST_CLEAR); + if ((ret = AllocEdgeList(&NewlyFixedEdges, 2 * num_at))) /* djb-rwth: addressing LLVM warning */ { goto exit_function; } for (i = 0; i < num_at; i++) { - if (( j = pVA[i].nCMinusGroupEdge - 1 ) >= 0) + if ((j = pVA[i].nCMinusGroupEdge - 1) >= 0) { - if ((ret = AddToEdgeList( &NewlyFixedEdges, j, 0 ))) /* djb-rwth: addressing LLVM warning */ + if ((ret = AddToEdgeList(&NewlyFixedEdges, j, 0))) /* djb-rwth: addressing LLVM warning */ { goto exit_function; } pBNS->edge[j].forbidden |= forbidden_edge_mask; } - if (( j = pVA[i].nCPlusGroupEdge - 1 ) >= 0) + if ((j = pVA[i].nCPlusGroupEdge - 1) >= 0) { - if ((ret = AddToEdgeList( &NewlyFixedEdges, j, 0 ))) /* djb-rwth: addressing LLVM warning */ + if ((ret = AddToEdgeList(&NewlyFixedEdges, j, 0))) /* djb-rwth: addressing LLVM warning */ { goto exit_function; } @@ -222,8 +222,8 @@ int FixLessHydrogenInFormula( BN_STRUCT *pBNS, for (i = 0; i < num_at; i++) { if (!at2[i].endpoint && !pVA[i].cMetal && - pVA[i].cNumValenceElectrons == 5 && pVA[i].cPeriodicRowNumber == 1 && - at2[i].num_H == atf[i].num_H + 1) + pVA[i].cNumValenceElectrons == 5 && pVA[i].cPeriodicRowNumber == 1 && + at2[i].num_H == atf[i].num_H + 1) { /* H was removed from N */ iNH = i; @@ -242,7 +242,7 @@ int FixLessHydrogenInFormula( BN_STRUCT *pBNS, if (at2[neigh].valence == 4) { if (at2[neigh].charge == -1 && at2[neigh].chem_bonds_valence == 4 && - !at2[neigh].radical && !at[neigh].num_H) + !at2[neigh].radical && !at[neigh].num_H) { iBPlus = neigh; } @@ -268,9 +268,9 @@ int FixLessHydrogenInFormula( BN_STRUCT *pBNS, bond_type_at2 = at2[i].bond_type[j] & BOND_TYPE_MASK; /* restored bond */ bond_type_atf = atf[i].bond_type[j] & BOND_TYPE_MASK; /* normalized bond */ nxt_is_NPlus = 0; - if (( bond_type_atf - bond_type_at2 == delta || bond_type_atf == BOND_ALT12NS ) && - BOND_TYPE_SINGLE <= bond_type_at2 + delta && bond_type_at2 + delta <= BOND_TYPE_TRIPLE && - !at2[(int) at2[i].neighbor[j]].cFlags) + if ((bond_type_atf - bond_type_at2 == delta || bond_type_atf == BOND_ALT12NS) && + BOND_TYPE_SINGLE <= bond_type_at2 + delta && bond_type_at2 + delta <= BOND_TYPE_TRIPLE && + !at2[(int)at2[i].neighbor[j]].cFlags) { prv = i; nxt = at2[i].neighbor[j]; @@ -279,20 +279,20 @@ int FixLessHydrogenInFormula( BN_STRUCT *pBNS, at2[i].cFlags |= 1; /* avoid cycling */ /* djb-rwth: removing redundant code */ if (delta == -1 && at2[prv].valence == 4 && at2[prv].chem_bonds_valence == 5 && - !at2[prv].charge && !at2[prv].radical && pVA[prv].cNumValenceElectrons == 5 && - pVA[prv].nCPlusGroupEdge > 0) + !at2[prv].charge && !at2[prv].radical && pVA[prv].cNumValenceElectrons == 5 && + pVA[prv].nCPlusGroupEdge > 0) { iNV = prv; } if (at2[nxt].charge != atf[nxt].charge) { - if (( at2[nxt].charge == 1 || atf[nxt].charge == 1 ) && - pVA[nxt].nCPlusGroupEdge > 0) + if ((at2[nxt].charge == 1 || atf[nxt].charge == 1) && + pVA[nxt].nCPlusGroupEdge > 0) { pBNS->edge[pVA[nxt].nCPlusGroupEdge - 1].forbidden &= inv_forbidden_edge_mask; } - if (( at2[nxt].charge == -1 || atf[nxt].charge == -1 ) && - pVA[nxt].nCMinusGroupEdge > 0) + if ((at2[nxt].charge == -1 || atf[nxt].charge == -1) && + pVA[nxt].nCMinusGroupEdge > 0) { pBNS->edge[pVA[nxt].nCMinusGroupEdge - 1].forbidden &= inv_forbidden_edge_mask; } @@ -300,8 +300,7 @@ int FixLessHydrogenInFormula( BN_STRUCT *pBNS, break; /* found */ } } - } - while (nxt >= 0 && !( nxt_is_NPlus && delta == -1 )); + } while (nxt >= 0 && !(nxt_is_NPlus && delta == -1)); for (i = 0; i < num_at; i++) { at2[i].cFlags = 0; @@ -312,26 +311,26 @@ int FixLessHydrogenInFormula( BN_STRUCT *pBNS, if (iBPlus || iNV) { /* move (+) charge from N(+) to iNV or, if iBPlus, then to iNH */ - if ((iNV >= 0 && ( j = pVA[iNV].nCPlusGroupEdge - 1 ) > 0 && pBNS->edge[j].flow > 0) || - (iNH >= 0 && ( j = pVA[iNH].nCPlusGroupEdge - 1 ) > 0 && pBNS->edge[j].flow > 0)) /* djb-rwth: addressing LLVM warnings */ + if ((iNV >= 0 && (j = pVA[iNV].nCPlusGroupEdge - 1) > 0 && pBNS->edge[j].flow > 0) || + (iNH >= 0 && (j = pVA[iNH].nCPlusGroupEdge - 1) > 0 && pBNS->edge[j].flow > 0)) /* djb-rwth: addressing LLVM warnings */ { int ieFlower; - BNS_EDGE *pe = pBNS->edge + j, *peFlower = NULL; + BNS_EDGE* pe = pBNS->edge + j, * peFlower = NULL; Vertex v1 = pe->neighbor1; Vertex v2 = v1 ^ pe->neighbor12; - BNS_VERTEX *pv1 = pBNS->vert + v1; - BNS_VERTEX *pv2 = pBNS->vert + v2; + BNS_VERTEX* pv1 = pBNS->vert + v1; + BNS_VERTEX* pv2 = pBNS->vert + v2; delta = 1; /* prevent conversion of >N(+)= into N(V) neutral */ - ieFlower = GetChargeFlowerUpperEdge( pBNS, pVA, pVA[nxt].nCPlusGroupEdge - 1 ); + ieFlower = GetChargeFlowerUpperEdge(pBNS, pVA, pVA[nxt].nCPlusGroupEdge - 1); if (ieFlower >= 0) { peFlower = pBNS->edge + ieFlower; if (peFlower->flow == delta) { peFlower->forbidden |= forbidden_edge_mask; - if ((ret = AddToEdgeList( &NewlyFixedEdges, ieFlower, 0 ))) /* djb-rwth: addressing LLVM warning */ + if ((ret = AddToEdgeList(&NewlyFixedEdges, ieFlower, 0))) /* djb-rwth: addressing LLVM warning */ { goto exit_function; } @@ -342,18 +341,18 @@ int FixLessHydrogenInFormula( BN_STRUCT *pBNS, pv1->st_edge.flow -= delta; pv2->st_edge.flow -= delta; pBNS->tot_st_flow -= 2 * delta; - ret = RunBnsTestOnce( pBNS, pBD, pVA, &vPathStart, &vPathEnd, &nPathLen, - &nDeltaH, &nDeltaCharge, &nNumVisitedAtoms ); + ret = RunBnsTestOnce(pBNS, pBD, pVA, &vPathStart, &vPathEnd, &nPathLen, + &nDeltaH, &nDeltaCharge, &nNumVisitedAtoms); if (ret < 0) { goto exit_function; } - if (ret == 1 && ( (vPathEnd == v1 && vPathStart == v2) || - (vPathEnd == v2 && vPathStart == v1) ) && - nDeltaCharge <= 0 /* charge moving to this atom disappers*/) /* djb-rwth: addressing LLVM warnings */ + if (ret == 1 && ((vPathEnd == v1 && vPathStart == v2) || + (vPathEnd == v2 && vPathStart == v1)) && + nDeltaCharge <= 0 /* charge moving to this atom disappers*/) /* djb-rwth: addressing LLVM warnings */ { - ret = RunBnsRestoreOnce( pBNS, pBD, pVA, pTCGroups ); - ( *pnNumRunBNS )++; + ret = RunBnsRestoreOnce(pBNS, pBD, pVA, pTCGroups); + (*pnNumRunBNS)++; if (ret < 0) { goto exit_function; @@ -384,8 +383,8 @@ int FixLessHydrogenInFormula( BN_STRUCT *pBNS, exit_function: /* remove bond fixation */ - RemoveForbiddenEdgeMask( pBNS, &NewlyFixedEdges, forbidden_edge_mask ); - AllocEdgeList( &NewlyFixedEdges, EDGE_LIST_FREE ); + RemoveForbiddenEdgeMask(pBNS, &NewlyFixedEdges, forbidden_edge_mask); + AllocEdgeList(&NewlyFixedEdges, EDGE_LIST_FREE); return ret; } @@ -396,17 +395,17 @@ int FixLessHydrogenInFormula( BN_STRUCT *pBNS, X=Y-O(-) => X(-)-Y=O ****************************************************************************/ -int FixMoreHydrogenInFormula( BN_STRUCT *pBNS, - BN_DATA *pBD, - StrFromINChI *pStruct, - inp_ATOM *at, - inp_ATOM *at2, - inp_ATOM *atf, - VAL_AT *pVA, - ALL_TC_GROUPS *pTCGroups, - int *pnNumRunBNS, - int *pnTotalDelta, - int forbidden_edge_mask ) +int FixMoreHydrogenInFormula(BN_STRUCT* pBNS, + BN_DATA* pBD, + StrFromINChI* pStruct, + inp_ATOM* at, + inp_ATOM* at2, + inp_ATOM* atf, + VAL_AT* pVA, + ALL_TC_GROUPS* pTCGroups, + int* pnNumRunBNS, + int* pnTotalDelta, + int forbidden_edge_mask) { int iNH = NO_VERTEX, neigh, neigh2; EDGE_LIST NewlyFixedEdges; @@ -417,27 +416,27 @@ int FixMoreHydrogenInFormula( BN_STRUCT *pBNS, /* for RunBnsTestOnce */ Vertex vPathStart, vPathEnd; int nPathLen, nDeltaH, nDeltaCharge, nNumVisitedAtoms; - BNS_EDGE *pe, *pe2; + BNS_EDGE* pe, * pe2; - AllocEdgeList( &NewlyFixedEdges, EDGE_LIST_CLEAR ); - if ((ret = AllocEdgeList( &NewlyFixedEdges, 2 * num_at ))) /* djb-rwth: addressing LLVM warning */ + AllocEdgeList(&NewlyFixedEdges, EDGE_LIST_CLEAR); + if ((ret = AllocEdgeList(&NewlyFixedEdges, 2 * num_at))) /* djb-rwth: addressing LLVM warning */ { goto exit_function; } /* fix all charges */ for (i = 0; i < num_at; i++) { - if (( j = pVA[i].nCMinusGroupEdge - 1 ) >= 0) + if ((j = pVA[i].nCMinusGroupEdge - 1) >= 0) { - if ((ret = AddToEdgeList( &NewlyFixedEdges, j, 0 ))) /* djb-rwth: addressing LLVM warning */ + if ((ret = AddToEdgeList(&NewlyFixedEdges, j, 0))) /* djb-rwth: addressing LLVM warning */ { goto exit_function; } pBNS->edge[j].forbidden |= forbidden_edge_mask; } - if (( j = pVA[i].nCPlusGroupEdge - 1 ) >= 0) + if ((j = pVA[i].nCPlusGroupEdge - 1) >= 0) { - if ((ret = AddToEdgeList( &NewlyFixedEdges, j, 0 ))) /* djb-rwth: addressing LLVM warning */ + if ((ret = AddToEdgeList(&NewlyFixedEdges, j, 0))) /* djb-rwth: addressing LLVM warning */ { goto exit_function; } @@ -449,15 +448,15 @@ int FixMoreHydrogenInFormula( BN_STRUCT *pBNS, for (i = 0; i < num_at; i++) { neigh = at2[i].neighbor[0]; /* djb-rwth: avoiding unsequenced modification and access to neigh */ - if (!( pStruct->bMobileH ? at2[i].endpoint : pStruct->endpoint[i] ) && !pVA[i].cMetal && - at2[i].num_H + 1 == atf[i].num_H && /* normalization added H ??? What would happen in Fixed-H case?*/ - ( k = pVA[i].nCMinusGroupEdge - 1 ) >= 0 && - pBNS->edge[k].flow == 1 && /* atom had (-) charge before preprocessing */ - at2[i].charge == -1 && atf[i].charge == 0 && /* and has no charge after preprocessing */ - at2[i].valence == 1 && at2[i].chem_bonds_valence == 1 && /* connected by a single bond */ - pVA[i].cNumValenceElectrons == 6 && /* atom is O, S, Se, Te */ - at2[neigh].chem_bonds_valence > at2[neigh].valence - /* atom's single neighbor has multiple bond(s)*/ + if (!(pStruct->bMobileH ? at2[i].endpoint : pStruct->endpoint[i]) && !pVA[i].cMetal && + at2[i].num_H + 1 == atf[i].num_H && /* normalization added H ??? What would happen in Fixed-H case?*/ + (k = pVA[i].nCMinusGroupEdge - 1) >= 0 && + pBNS->edge[k].flow == 1 && /* atom had (-) charge before preprocessing */ + at2[i].charge == -1 && atf[i].charge == 0 && /* and has no charge after preprocessing */ + at2[i].valence == 1 && at2[i].chem_bonds_valence == 1 && /* connected by a single bond */ + pVA[i].cNumValenceElectrons == 6 && /* atom is O, S, Se, Te */ + at2[neigh].chem_bonds_valence > at2[neigh].valence + /* atom's single neighbor has multiple bond(s)*/ ) { /* H(+) was added to O in Y=X-O(-), where X is the only neighbor of O, X=neigh, Y=neigh2 */ @@ -466,11 +465,11 @@ int FixMoreHydrogenInFormula( BN_STRUCT *pBNS, { neigh2 = at2[neigh].neighbor[j]; if (neigh2 != iNH && !at2[neigh2].endpoint && - !pBNS->edge[(int) pBNS->vert[neigh].iedge[j]].forbidden && - 4 <= pVA[neigh2].cNumValenceElectrons && - pVA[neigh2].cNumValenceElectrons <= 5 && /* neig2 is C or N */ - ( k2 = pVA[neigh2].nCMinusGroupEdge - 1 ) >= 0 && - !pBNS->edge[k2].flow /* negative charge may be moved to neigh2 */) + !pBNS->edge[(int)pBNS->vert[neigh].iedge[j]].forbidden && + 4 <= pVA[neigh2].cNumValenceElectrons && + pVA[neigh2].cNumValenceElectrons <= 5 && /* neig2 is C or N */ + (k2 = pVA[neigh2].nCMinusGroupEdge - 1) >= 0 && + !pBNS->edge[k2].flow /* negative charge may be moved to neigh2 */) { break; } @@ -488,18 +487,18 @@ int FixMoreHydrogenInFormula( BN_STRUCT *pBNS, pBNS->tot_st_flow -= 2 * delta; pe2->forbidden &= inv_forbidden_edge_mask; /* allow the charge to move */ - ret = RunBnsTestOnce( pBNS, pBD, pVA, &vPathStart, &vPathEnd, &nPathLen, - &nDeltaH, &nDeltaCharge, &nNumVisitedAtoms ); + ret = RunBnsTestOnce(pBNS, pBD, pVA, &vPathStart, &vPathEnd, &nPathLen, + &nDeltaH, &nDeltaCharge, &nNumVisitedAtoms); if (ret < 0) { goto exit_function; } - if (ret == 1 && ( (vPathEnd == v1 && vPathStart == v2) || - (vPathEnd == v2 && vPathStart == v1) ) && - nDeltaCharge <= 1) /* djb-rwth: addressing LLVM warnings */ + if (ret == 1 && ((vPathEnd == v1 && vPathStart == v2) || + (vPathEnd == v2 && vPathStart == v1)) && + nDeltaCharge <= 1) /* djb-rwth: addressing LLVM warnings */ { - ret = RunBnsRestoreOnce( pBNS, pBD, pVA, pTCGroups ); - ( *pnNumRunBNS )++; + ret = RunBnsRestoreOnce(pBNS, pBD, pVA, pTCGroups); + (*pnNumRunBNS)++; if (ret < 0) { goto exit_function; @@ -517,7 +516,7 @@ int FixMoreHydrogenInFormula( BN_STRUCT *pBNS, } else { - /* the attempt has failed; restore the flow */ + /* the attempt has failed; restore the flow */ ret = 0; pe->flow += delta; pBNS->vert[v1].st_edge.flow += delta; @@ -530,8 +529,8 @@ int FixMoreHydrogenInFormula( BN_STRUCT *pBNS, exit_function: /* remove bond fixation */ - RemoveForbiddenEdgeMask( pBNS, &NewlyFixedEdges, forbidden_edge_mask ); - AllocEdgeList( &NewlyFixedEdges, EDGE_LIST_FREE ); + RemoveForbiddenEdgeMask(pBNS, &NewlyFixedEdges, forbidden_edge_mask); + AllocEdgeList(&NewlyFixedEdges, EDGE_LIST_FREE); return ret; } @@ -539,18 +538,18 @@ int FixMoreHydrogenInFormula( BN_STRUCT *pBNS, #if ( FIX_ADD_PROTON_FOR_ADP == 1 ) /****************************************************************************/ -int FixAddProtonForADP( BN_STRUCT *pBNS, - BN_DATA *pBD, - StrFromINChI *pStruct, - inp_ATOM *at, - inp_ATOM *at2, - inp_ATOM *atf, - VAL_AT *pVA, - ALL_TC_GROUPS *pTCGroups, - ICR *picr, - int *pnNumRunBNS, - int *pnTotalDelta, - int forbidden_edge_mask ) +int FixAddProtonForADP(BN_STRUCT* pBNS, + BN_DATA* pBD, + StrFromINChI* pStruct, + inp_ATOM* at, + inp_ATOM* at2, + inp_ATOM* atf, + VAL_AT* pVA, + ALL_TC_GROUPS* pTCGroups, + ICR* picr, + int* pnNumRunBNS, + int* pnTotalDelta, + int forbidden_edge_mask) { int iBPlus = NO_VERTEX, iNV = NO_VERTEX, iNH = NO_VERTEX, neigh, neigh2; EDGE_LIST NewlyFixedEdges; @@ -561,7 +560,7 @@ int FixAddProtonForADP( BN_STRUCT *pBNS, /* for RunBnsTestOnce */ Vertex vPathStart, vPathEnd; int nPathLen, nDeltaH, nDeltaCharge, nNumVisitedAtoms; - BNS_EDGE *pe, *pe2; + BNS_EDGE* pe, * pe2; ret = 0; /* @@ -587,18 +586,18 @@ int FixAddProtonForADP( BN_STRUCT *pBNS, \\ \ S(IV) or N(V) or P(V) may be a centerpoint O O(-) ****************************************************************************/ -int FixRemoveExtraTautEndpoints( BN_STRUCT *pBNS, - BN_DATA *pBD, - StrFromINChI *pStruct, - inp_ATOM *at, - inp_ATOM *at2, - inp_ATOM *atf, - inp_ATOM *atn, - VAL_AT *pVA, - ALL_TC_GROUPS *pTCGroups, ICR *picr, - int *pnNumRunBNS, - int *pnTotalDelta, - int forbidden_edge_mask ) +int FixRemoveExtraTautEndpoints(BN_STRUCT* pBNS, + BN_DATA* pBD, + StrFromINChI* pStruct, + inp_ATOM* at, + inp_ATOM* at2, + inp_ATOM* atf, + inp_ATOM* atn, + VAL_AT* pVA, + ALL_TC_GROUPS* pTCGroups, ICR* picr, + int* pnNumRunBNS, + int* pnTotalDelta, + int forbidden_edge_mask) { EDGE_LIST NewlyFixedEdges; int ret, i, j, k, delta, centerpoint, endpoint1, endpoint2; @@ -608,29 +607,29 @@ int FixRemoveExtraTautEndpoints( BN_STRUCT *pBNS, /* for RunBnsTestOnce */ Vertex vPathStart, vPathEnd; int nPathLen, nDeltaH, nDeltaCharge, nNumVisitedAtoms; - BNS_EDGE *pe, *pe2; + BNS_EDGE* pe, * pe2; ret = 0; /* djb-rwth: ignoring LLVM warning: value might be returned */ - AllocEdgeList( &NewlyFixedEdges, EDGE_LIST_CLEAR ); - if ((ret = AllocEdgeList( &NewlyFixedEdges, 2 * num_at ))) /* djb-rwth: addressing LLVM warning */ + AllocEdgeList(&NewlyFixedEdges, EDGE_LIST_CLEAR); + if ((ret = AllocEdgeList(&NewlyFixedEdges, 2 * num_at))) /* djb-rwth: addressing LLVM warning */ { goto exit_function; } /* fix all charges */ for (i = 0; i < num_at; i++) { - if (( j = pVA[i].nCMinusGroupEdge - 1 ) >= 0) + if ((j = pVA[i].nCMinusGroupEdge - 1) >= 0) { - if ((ret = AddToEdgeList( &NewlyFixedEdges, j, 0 ))) /* djb-rwth: addressing LLVM warning */ + if ((ret = AddToEdgeList(&NewlyFixedEdges, j, 0))) /* djb-rwth: addressing LLVM warning */ { goto exit_function; } pBNS->edge[j].forbidden |= forbidden_edge_mask; } - if (( j = pVA[i].nCPlusGroupEdge - 1 ) >= 0) + if ((j = pVA[i].nCPlusGroupEdge - 1) >= 0) { - if ((ret = AddToEdgeList( &NewlyFixedEdges, j, 0 ))) /* djb-rwth: addressing LLVM warning */ + if ((ret = AddToEdgeList(&NewlyFixedEdges, j, 0))) /* djb-rwth: addressing LLVM warning */ { goto exit_function; } @@ -642,18 +641,18 @@ int FixRemoveExtraTautEndpoints( BN_STRUCT *pBNS, { endpoint1 = picr->endp_in1_only[i] - 1; if (at2[endpoint1].valence == at2[endpoint1].chem_bonds_valence || - pVA[endpoint1].nCMinusGroupEdge <= 0) + pVA[endpoint1].nCMinusGroupEdge <= 0) { continue; } /* find centerpoint */ for (j = 0; j < at2[endpoint1].valence; j++) { - if (BOND_TYPE_DOUBLE == ( BOND_TYPE_MASK & at2[endpoint1].bond_type[j] )) + if (BOND_TYPE_DOUBLE == (BOND_TYPE_MASK & at2[endpoint1].bond_type[j])) { centerpoint = at2[endpoint1].neighbor[j]; if (at2[centerpoint].charge || pVA[centerpoint].nCPlusGroupEdge <= 0 || - !is_centerpoint_elem( at2[centerpoint].el_number )) + !is_centerpoint_elem(at2[centerpoint].el_number)) { continue; } @@ -666,7 +665,7 @@ int FixRemoveExtraTautEndpoints( BN_STRUCT *pBNS, /* find 2nd endpoint */ for (k = 0; k < at2[centerpoint].valence; k++) { - if (BOND_TYPE_SINGLE != ( BOND_TYPE_MASK & at2[centerpoint].bond_type[k] )) + if (BOND_TYPE_SINGLE != (BOND_TYPE_MASK & at2[centerpoint].bond_type[k])) { continue; } @@ -700,18 +699,18 @@ int FixRemoveExtraTautEndpoints( BN_STRUCT *pBNS, pBNS->tot_st_flow -= 2 * delta; pe2->forbidden &= inv_forbidden_edge_mask; /* allow the charge to move */ - ret = RunBnsTestOnce( pBNS, pBD, pVA, &vPathStart, &vPathEnd, &nPathLen, - &nDeltaH, &nDeltaCharge, &nNumVisitedAtoms ); + ret = RunBnsTestOnce(pBNS, pBD, pVA, &vPathStart, &vPathEnd, &nPathLen, + &nDeltaH, &nDeltaCharge, &nNumVisitedAtoms); if (ret < 0) { goto exit_function; } - if (ret == 1 && ( (vPathEnd == v1 && vPathStart == v2) || - (vPathEnd == v2 && vPathStart == v1) ) && - nDeltaCharge <= 1) /* djb-rwth: addressing LLVM warnings */ + if (ret == 1 && ((vPathEnd == v1 && vPathStart == v2) || + (vPathEnd == v2 && vPathStart == v1)) && + nDeltaCharge <= 1) /* djb-rwth: addressing LLVM warnings */ { - ret = RunBnsRestoreOnce( pBNS, pBD, pVA, pTCGroups ); - ( *pnNumRunBNS )++; + ret = RunBnsRestoreOnce(pBNS, pBD, pVA, pTCGroups); + (*pnNumRunBNS)++; if (ret < 0) { goto exit_function; @@ -744,27 +743,27 @@ int FixRemoveExtraTautEndpoints( BN_STRUCT *pBNS, exit_function: /* remove bond fixation */ - RemoveForbiddenEdgeMask( pBNS, &NewlyFixedEdges, forbidden_edge_mask ); - AllocEdgeList( &NewlyFixedEdges, EDGE_LIST_FREE ); + RemoveForbiddenEdgeMask(pBNS, &NewlyFixedEdges, forbidden_edge_mask); + AllocEdgeList(&NewlyFixedEdges, EDGE_LIST_FREE); return ret; } /****************************************************************************/ -int FillOutExtraFixedHDataRestr( StrFromINChI *pStruct ) +int FillOutExtraFixedHDataRestr(StrFromINChI* pStruct) { int i, j, k, len, ret = 0; - AT_NUMB *pNum; + AT_NUMB* pNum; for (i = 0; i < TAUT_NUM; i++) { if (pStruct->pOneINChI_Aux[i]) { - pNum = ( pStruct->pOneINChI_Aux[i]->nIsotopicOrigAtNosInCanonOrd && - pStruct->pOneINChI_Aux[i]->nIsotopicOrigAtNosInCanonOrd[0] ) ? + pNum = (pStruct->pOneINChI_Aux[i]->nIsotopicOrigAtNosInCanonOrd && + pStruct->pOneINChI_Aux[i]->nIsotopicOrigAtNosInCanonOrd[0]) ? pStruct->pOneINChI_Aux[i]->nIsotopicOrigAtNosInCanonOrd : - ( pStruct->pOneINChI_Aux[i]->nOrigAtNosInCanonOrd && - pStruct->pOneINChI_Aux[i]->nOrigAtNosInCanonOrd[0] ) ? + (pStruct->pOneINChI_Aux[i]->nOrigAtNosInCanonOrd && + pStruct->pOneINChI_Aux[i]->nOrigAtNosInCanonOrd[0]) ? pStruct->pOneINChI_Aux[i]->nOrigAtNosInCanonOrd : NULL; } else @@ -773,11 +772,11 @@ int FillOutExtraFixedHDataRestr( StrFromINChI *pStruct ) } if (pNum) { - len = pStruct->num_atoms * sizeof( pStruct->nCanon2Atno[0][0] ); + len = pStruct->num_atoms * sizeof(pStruct->nCanon2Atno[0][0]); if ((!pStruct->nCanon2Atno[i] && - !( pStruct->nCanon2Atno[i] = (AT_NUMB *) inchi_malloc( len ) )) || - (!pStruct->nAtno2Canon[i] && - !( pStruct->nAtno2Canon[i] = (AT_NUMB *) inchi_malloc( len )) )) /* djb-rwth: addressing LLVM warnings */ + !(pStruct->nCanon2Atno[i] = (AT_NUMB*)inchi_malloc(len))) || + (!pStruct->nAtno2Canon[i] && + !(pStruct->nAtno2Canon[i] = (AT_NUMB*)inchi_malloc(len)))) /* djb-rwth: addressing LLVM warnings */ { ret = RI_ERR_ALLOC; goto exit_function; @@ -789,13 +788,13 @@ int FillOutExtraFixedHDataRestr( StrFromINChI *pStruct ) INCHI_HEAPCHK - for (j = 0; j < pStruct->num_atoms; j++) - { - k = pNum[j] - 1; /* atom number */ - pStruct->nCanon2Atno[i][j] = (AT_NUMB) k; - pStruct->nAtno2Canon[i][k] = (AT_NUMB) j; - INCHI_HEAPCHK - } + for (j = 0; j < pStruct->num_atoms; j++) + { + k = pNum[j] - 1; /* atom number */ + pStruct->nCanon2Atno[i][j] = (AT_NUMB)k; + pStruct->nAtno2Canon[i][k] = (AT_NUMB)j; + INCHI_HEAPCHK + } } else { @@ -808,15 +807,15 @@ int FillOutExtraFixedHDataRestr( StrFromINChI *pStruct ) { if (pStruct->nCanon2Atno[i]) { - inchi_free( pStruct->nCanon2Atno[i] ); + inchi_free(pStruct->nCanon2Atno[i]); pStruct->nCanon2Atno[i] = NULL; } INCHI_HEAPCHK - if (pStruct->nAtno2Canon[i]) - { - inchi_free( pStruct->nAtno2Canon[i] ); - pStruct->nAtno2Canon[i] = NULL; - } + if (pStruct->nAtno2Canon[i]) + { + inchi_free(pStruct->nAtno2Canon[i]); + pStruct->nAtno2Canon[i] = NULL; + } INCHI_HEAPCHK } } @@ -829,21 +828,21 @@ int FillOutExtraFixedHDataRestr( StrFromINChI *pStruct ) /****************************************************************************/ -int FillOutExtraFixedHDataInChI( StrFromINChI *pStruct, INChI *pInChI[] ) +int FillOutExtraFixedHDataInChI(StrFromINChI* pStruct, INChI* pInChI[]) { int ret = 0; /*--- allocate memory for Mobile/Fixed-H data from the input InChI ---*/ if (NULL == pStruct->endpoint) { - pStruct->endpoint = (AT_NUMB *) inchi_calloc( pStruct->num_atoms, sizeof( pStruct->endpoint[0] ) ); + pStruct->endpoint = (AT_NUMB*)inchi_calloc(pStruct->num_atoms, sizeof(pStruct->endpoint[0])); } else { - memset( pStruct->endpoint, 0, pStruct->num_atoms * sizeof( pStruct->endpoint[0] ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(pStruct->endpoint, 0, pStruct->num_atoms * sizeof(pStruct->endpoint[0])); /* djb-rwth: memset_s C11/Annex K variant? */ } if (NULL == pStruct->fixed_H) { - pStruct->fixed_H = (S_CHAR *) inchi_malloc( pStruct->num_atoms * sizeof( pStruct->fixed_H[0] ) ); + pStruct->fixed_H = (S_CHAR*)inchi_malloc(pStruct->num_atoms * sizeof(pStruct->fixed_H[0])); } if (!pStruct->endpoint || !pStruct->fixed_H) { @@ -851,14 +850,14 @@ int FillOutExtraFixedHDataInChI( StrFromINChI *pStruct, INChI *pInChI[] ) goto exit_function; } /*--- fill out Mobile/Fixed-H data from the input InChI ---*/ - GetTgroupInfoFromInChI( &pStruct->ti, NULL, pStruct->endpoint, pInChI[1] ); + GetTgroupInfoFromInChI(&pStruct->ti, NULL, pStruct->endpoint, pInChI[1]); if (pInChI[0]->nNum_H_fixed) { memcpy(pStruct->fixed_H, pInChI[0]->nNum_H_fixed, pStruct->num_atoms * sizeof(pStruct->fixed_H[0])); } else { - memset( pStruct->fixed_H, 0, pStruct->num_atoms * sizeof( pStruct->fixed_H[0] ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(pStruct->fixed_H, 0, pStruct->num_atoms * sizeof(pStruct->fixed_H[0])); /* djb-rwth: memset_s C11/Annex K variant? */ } exit_function: @@ -868,28 +867,28 @@ int FillOutExtraFixedHDataInChI( StrFromINChI *pStruct, INChI *pInChI[] ) /****************************************************************************/ -int FillOutCMP2FHINCHI( StrFromINChI *pStruct, - inp_ATOM *at2, - VAL_AT *pVA, - INChI *pInChI[], - CMP2FHINCHI *pc2i ) +int FillOutCMP2FHINCHI(StrFromINChI* pStruct, + inp_ATOM* at2, + VAL_AT* pVA, + INChI* pInChI[], + CMP2FHINCHI* pc2i) { int ret = 0, i, j; int bFixHRevrsExists = pInChI[1] && pInChI[1]->nNumberOfAtoms > 0 && !pInChI[1]->bDeleted; - inp_ATOM *at_Mobile_H_Revrs = ( pStruct->pOne_norm_data[1] && - pStruct->pOne_norm_data[1]->at ) ? pStruct->pOne_norm_data[1]->at : NULL; - S_CHAR *num_Fixed_H_Revrs = pStruct->pOneINChI[0]->nNum_H_fixed ? pStruct->pOneINChI[0]->nNum_H_fixed : NULL; + inp_ATOM* at_Mobile_H_Revrs = (pStruct->pOne_norm_data[1] && + pStruct->pOne_norm_data[1]->at) ? pStruct->pOne_norm_data[1]->at : NULL; + S_CHAR* num_Fixed_H_Revrs = pStruct->pOneINChI[0]->nNum_H_fixed ? pStruct->pOneINChI[0]->nNum_H_fixed : NULL; /* atom number in structure that produced original InChI is atom number in all inp_ATOM *atoms */ /* atom number in structure that produced restored InChI is in nAtomRevrs[]: */ - AT_NUMB *nAtno2CanonRevrs = pStruct->nAtno2Canon[0]; - S_CHAR *pnMobHInChI = ( pInChI[1] && pInChI[1]->nNum_H ) ? pInChI[1]->nNum_H : - ( pInChI[0] && pInChI[0]->nNum_H ) ? pInChI[0]->nNum_H : NULL; - S_CHAR *pnMobHRevrs = ( pStruct->pOneINChI[1] && pStruct->pOneINChI[1]->nNum_H ) ? + AT_NUMB* nAtno2CanonRevrs = pStruct->nAtno2Canon[0]; + S_CHAR* pnMobHInChI = (pInChI[1] && pInChI[1]->nNum_H) ? pInChI[1]->nNum_H : + (pInChI[0] && pInChI[0]->nNum_H) ? pInChI[0]->nNum_H : NULL; + S_CHAR* pnMobHRevrs = (pStruct->pOneINChI[1] && pStruct->pOneINChI[1]->nNum_H) ? pStruct->pOneINChI[1]->nNum_H : - ( pStruct->pOneINChI[0] && pStruct->pOneINChI[0]->nNum_H ) ? + (pStruct->pOneINChI[0] && pStruct->pOneINChI[0]->nNum_H) ? pStruct->pOneINChI[0]->nNum_H : NULL; int nNumTgHInChI, nNumTgMInChI, nNumTgHRevrs, nNumTgMRevrs; - memset( pc2i, 0, sizeof( *pc2i ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(pc2i, 0, sizeof(*pc2i)); /* djb-rwth: memset_s C11/Annex K variant? */ pc2i->nNumTgInChI = pStruct->ti.num_t_groups; pc2i->nNumTgRevrs = pStruct->One_ti.num_t_groups; pc2i->bHasDifference |= pc2i->nNumTgInChI != pc2i->nNumTgRevrs; @@ -912,7 +911,7 @@ int FillOutCMP2FHINCHI( StrFromINChI *pStruct, pc2i->bHasDifference |= nNumTgMInChI != nNumTgMRevrs; if (pStruct->ti.t_group[i].nNumEndpoints == - pStruct->One_ti.t_group[i].nNumEndpoints) + pStruct->One_ti.t_group[i].nNumEndpoints) { if (nNumTgHInChI != nNumTgHRevrs) @@ -959,8 +958,8 @@ int FillOutCMP2FHINCHI( StrFromINChI *pStruct, int nFixHRevrs = num_Fixed_H_Revrs ? num_Fixed_H_Revrs[iCanonRevrs] : 0; int nMobHInChI = pnMobHInChI ? pnMobHInChI[i] : 0; int nMobHRevrs = pnMobHRevrs ? pnMobHRevrs[iCanonRevrs] : 0; - if ( /*(!endptInChI || !endptRevrs) &&*/ ( nFixHInChI != nFixHRevrs ) || - ( !endptInChI != !endptRevrs ) || nMobHInChI != nMobHRevrs) + if ( /*(!endptInChI || !endptRevrs) &&*/ (nFixHInChI != nFixHRevrs) || + (!endptInChI != !endptRevrs) || nMobHInChI != nMobHRevrs) { /* in InChI or reversed InChI atom[i] is not tautomeric */ /* and number of fixed-H on the atom[i] differs */ @@ -980,18 +979,18 @@ int FillOutCMP2FHINCHI( StrFromINChI *pStruct, pc2i->bHasDifference |= nFixHInChI != nFixHRevrs; pc2i->c2at[j].nMobHInChI = pInChI[1] && pInChI[1]->nNum_H ? pInChI[1]->nNum_H[i] : pInChI[0] && pInChI[0]->nNum_H ? pInChI[0]->nNum_H[i] : 0; - pc2i->c2at[j].nMobHRevrs = ( pStruct->pOneINChI[1] && pStruct->pOneINChI[1]->nNum_H ) ? + pc2i->c2at[j].nMobHRevrs = (pStruct->pOneINChI[1] && pStruct->pOneINChI[1]->nNum_H) ? pStruct->pOneINChI[1]->nNum_H[iCanonRevrs] : - ( pStruct->pOneINChI[0] && pStruct->pOneINChI[0]->nNum_H ) ? + (pStruct->pOneINChI[0] && pStruct->pOneINChI[0]->nNum_H) ? pStruct->pOneINChI[0]->nNum_H[iCanonRevrs] : 0; - pc2i->nNumDiffMobH += ( nMobHInChI != nMobHRevrs && !endptRevrs && !endptInChI ); + pc2i->nNumDiffMobH += (nMobHInChI != nMobHRevrs && !endptRevrs && !endptInChI); pc2i->bHasDifference |= nMobHInChI != nMobHRevrs; pc2i->c2at[j].nNumHRevrs = at2[i].num_H; pc2i->c2at[j].nAtChargeRevrs = at2[i].charge; j++; } - pc2i->nNumEndpInChI += ( endptInChI != 0 ); - pc2i->nNumEndpRevrs += ( endptRevrs != 0 ); + pc2i->nNumEndpInChI += (endptInChI != 0); + pc2i->nNumEndpRevrs += (endptRevrs != 0); if (!pVA[i].cMetal) { @@ -1019,26 +1018,26 @@ int FillOutCMP2FHINCHI( StrFromINChI *pStruct, /****************************************************************************/ -int FillOutCMP2MHINCHI( StrFromINChI *pStruct, - ALL_TC_GROUPS *pTCGroups, - inp_ATOM *at2, - VAL_AT *pVA, - INChI *pInChI[], - CMP2MHINCHI *pc2i ) +int FillOutCMP2MHINCHI(StrFromINChI* pStruct, + ALL_TC_GROUPS* pTCGroups, + inp_ATOM* at2, + VAL_AT* pVA, + INChI* pInChI[], + CMP2MHINCHI* pc2i) { int ret = 0, i, j, iat; int bFixHRevrsExists = pInChI[1] && pInChI[1]->nNumberOfAtoms > 0 && !pInChI[1]->bDeleted; - inp_ATOM *at_Mobile_H_Revrs = ( pStruct->pOne_norm_data[0] && - pStruct->pOne_norm_data[0]->at ) ? pStruct->pOne_norm_data[0]->at : NULL; + inp_ATOM* at_Mobile_H_Revrs = (pStruct->pOne_norm_data[0] && + pStruct->pOne_norm_data[0]->at) ? pStruct->pOne_norm_data[0]->at : NULL; /* atom number in structure that produced original InChI is atom number in all inp_ATOM *atoms */ /* atom number in structure that produced restored InChI is in nAtomRevrs[]: */ - AT_NUMB *nCanon2AtnoRevrs = pStruct->nCanon2Atno[0]; - AT_NUMB *nAtno2CanonRevrs = pStruct->nAtno2Canon[0]; - S_CHAR *pnMobHInChI = ( pInChI[0] && pInChI[0]->nNum_H ) ? pInChI[0]->nNum_H : NULL; - S_CHAR *pnMobHRevrs = ( pStruct->pOneINChI[0] && pStruct->pOneINChI[0]->nNum_H ) ? + AT_NUMB* nCanon2AtnoRevrs = pStruct->nCanon2Atno[0]; + AT_NUMB* nAtno2CanonRevrs = pStruct->nAtno2Canon[0]; + S_CHAR* pnMobHInChI = (pInChI[0] && pInChI[0]->nNum_H) ? pInChI[0]->nNum_H : NULL; + S_CHAR* pnMobHRevrs = (pStruct->pOneINChI[0] && pStruct->pOneINChI[0]->nNum_H) ? pStruct->pOneINChI[0]->nNum_H : NULL; int nNumTgHInChI, nNumTgMInChI, nNumTgHRevrs, nNumTgMRevrs; - memset( pc2i, 0, sizeof( *pc2i ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(pc2i, 0, sizeof(*pc2i)); /* djb-rwth: memset_s C11/Annex K variant? */ pc2i->nNumTgInChI = pStruct->ti.num_t_groups; pc2i->nNumTgRevrs = pStruct->One_ti.num_t_groups; pc2i->bHasDifference |= pc2i->nNumTgInChI != pc2i->nNumTgRevrs; @@ -1079,7 +1078,7 @@ int FillOutCMP2MHINCHI( StrFromINChI *pStruct, } else { - /* O, S, Se, Te */ + /* O, S, Se, Te */ pc2i->nNumTgOHInChI += at2[iat].charge == 0 && at2[iat].num_H == 1; pc2i->nNumTgOMinusInChI += at2[iat].charge == -1 && at2[iat].num_H == 0; } @@ -1112,7 +1111,7 @@ int FillOutCMP2MHINCHI( StrFromINChI *pStruct, int is_N, is_O; for (j = 0; j < jNum; j++) { - iat = nCanon2AtnoRevrs[(int) pStruct->One_ti.nEndpointAtomNumber[jFst + j]]; + iat = nCanon2AtnoRevrs[(int)pStruct->One_ti.nEndpointAtomNumber[jFst + j]]; is_N = pVA[iat].cNumValenceElectrons == 5 && pVA[iat].cPeriodicRowNumber == 1; is_O = pVA[iat].cNumValenceElectrons == 6; if (is_N + is_O != 1) @@ -1172,7 +1171,7 @@ int FillOutCMP2MHINCHI( StrFromINChI *pStruct, pc2i->bHasDifference |= nNumTgMInChI != nNumTgMRevrs; if (pStruct->ti.t_group[i].nNumEndpoints == - pStruct->One_ti.t_group[i].nNumEndpoints) + pStruct->One_ti.t_group[i].nNumEndpoints) { if (nNumTgHInChI != nNumTgHRevrs) @@ -1217,7 +1216,7 @@ int FillOutCMP2MHINCHI( StrFromINChI *pStruct, int endptRevrs = at_Mobile_H_Revrs ? at_Mobile_H_Revrs[i].endpoint : 0; int nMobHInChI = pnMobHInChI ? pnMobHInChI[i] : 0; int nMobHRevrs = pnMobHRevrs ? pnMobHRevrs[iCanonRevrs] : 0; - if (( !endptInChI != !endptRevrs ) || nMobHInChI != nMobHRevrs) + if ((!endptInChI != !endptRevrs) || nMobHInChI != nMobHRevrs) { /* in InChI or reversed InChI atom[i] is not tautomeric */ /* and number of fixed-H on the atom[i] differs */ @@ -1234,23 +1233,23 @@ int FillOutCMP2MHINCHI( StrFromINChI *pStruct, pc2i->c2at[j].nPeriodNum = pVA[i].cPeriodicRowNumber; pc2i->c2at[j].nMobHInChI = pInChI[1] && pInChI[1]->nNum_H ? pInChI[1]->nNum_H[i] : pInChI[0] && pInChI[0]->nNum_H ? pInChI[0]->nNum_H[i] : 0; - pc2i->c2at[j].nMobHRevrs = ( pStruct->pOneINChI[1] && pStruct->pOneINChI[1]->nNum_H ) ? + pc2i->c2at[j].nMobHRevrs = (pStruct->pOneINChI[1] && pStruct->pOneINChI[1]->nNum_H) ? pStruct->pOneINChI[1]->nNum_H[iCanonRevrs] : - ( pStruct->pOneINChI[0] && pStruct->pOneINChI[0]->nNum_H ) ? + (pStruct->pOneINChI[0] && pStruct->pOneINChI[0]->nNum_H) ? pStruct->pOneINChI[0]->nNum_H[iCanonRevrs] : 0; - pc2i->nNumDiffMobH += ( nMobHInChI != nMobHRevrs && !endptRevrs && !endptInChI ); - pc2i->bHasDifference |= ( nMobHInChI != nMobHRevrs ); + pc2i->nNumDiffMobH += (nMobHInChI != nMobHRevrs && !endptRevrs && !endptInChI); + pc2i->bHasDifference |= (nMobHInChI != nMobHRevrs); pc2i->c2at[j].nNumHRevrs = at2[i].num_H; pc2i->c2at[j].nAtChargeRevrs = at2[i].charge; j++; } - pc2i->nNumEndpInChI += ( endptInChI != 0 ); - pc2i->nNumEndpRevrs += ( endptRevrs != 0 ); + pc2i->nNumEndpInChI += (endptInChI != 0); + pc2i->nNumEndpRevrs += (endptRevrs != 0); if (!pVA[i].cMetal) { - pc2i->nChargeMobHRevrsNonMetal += ( at_Mobile_H_Revrs && !at_Mobile_H_Revrs[i].endpoint ) ? at_Mobile_H_Revrs[i].charge : 0; + pc2i->nChargeMobHRevrsNonMetal += (at_Mobile_H_Revrs && !at_Mobile_H_Revrs[i].endpoint) ? at_Mobile_H_Revrs[i].charge : 0; } @@ -1272,25 +1271,25 @@ int FillOutCMP2MHINCHI( StrFromINChI *pStruct, /****************************************************************************/ -int NormalizeAndCompare( CANON_GLOBALS *pCG, - INCHI_CLOCK *ic, - ICHICONST INPUT_PARMS *ip, - STRUCT_DATA *sd, - BN_STRUCT *pBNS, - BN_DATA *pBD, - StrFromINChI *pStruct, - inp_ATOM *at, - inp_ATOM *at2, - inp_ATOM *at3, - VAL_AT *pVA, - ALL_TC_GROUPS *pTCGroups, - INChI *pInChI[], - long num_inp, - int bHasSomeFixedH, - int *pnNumRunBNS, - int *pnTotalDelta, - int forbidden_edge_mask, - int forbidden_stereo_edge_mask ) +int NormalizeAndCompare(CANON_GLOBALS* pCG, + INCHI_CLOCK* ic, + ICHICONST INPUT_PARMS* ip, + STRUCT_DATA* sd, + BN_STRUCT* pBNS, + BN_DATA* pBD, + StrFromINChI* pStruct, + inp_ATOM* at, + inp_ATOM* at2, + inp_ATOM* at3, + VAL_AT* pVA, + ALL_TC_GROUPS* pTCGroups, + INChI* pInChI[], + long num_inp, + int bHasSomeFixedH, + int* pnNumRunBNS, + int* pnTotalDelta, + int forbidden_edge_mask, + int forbidden_stereo_edge_mask) { int i; int err; @@ -1298,13 +1297,13 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, int num_norm_endpoints, num_endpoints, num_norm_t_groups, ret = 0; /* djb-rwth: ignoring LLVM warning: variables used; removing redundant variables */ #if ( bRELEASE_VERSION == 0 ) #ifndef TARGET_API_LIB - const char *szCurHdr = ( ip->pSdfValue && ip->pSdfValue[0] ) ? ip->pSdfValue : "???"; + const char* szCurHdr = (ip->pSdfValue && ip->pSdfValue[0]) ? ip->pSdfValue : "???"; int iComponent = pTCGroups->iComponent; #endif #endif - T_GROUP_INFO *t_group_info = NULL; - inp_ATOM *at_norm = NULL; /* normalized */ - inp_ATOM *at_prep = NULL; /* preprocessed */ + T_GROUP_INFO* t_group_info = NULL; + inp_ATOM* at_norm = NULL; /* normalized */ + inp_ATOM* at_prep = NULL; /* preprocessed */ INCHI_MODE cmpInChI, cmpInChI2; int nDeltaPrev, nDeltaCur; int iOrigInChI, iRevrInChI; @@ -1313,47 +1312,47 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, /***********************************************************/ /* normalize and create one component InChI */ /***********************************************************/ - ret = MakeOneInChIOutOfStrFromINChI2( pCG, ic, ip, sd, pBNS, pStruct, at, at2, at3, pVA, pTCGroups, - &t_group_info, &at_norm, &at_prep ); + ret = MakeOneInChIOutOfStrFromINChI2(pCG, ic, ip, sd, pBNS, pStruct, at, at2, at3, pVA, pTCGroups, + &t_group_info, &at_norm, &at_prep); if (ret < 0) { #if ( bRELEASE_VERSION == 0 ) #ifndef TARGET_API_LIB - fprintf( stdout, "\nERROR in MakeOneInchi-1: %ld %s Comp:%d %c%c Err:%d\n", num_inp, - szCurHdr ? szCurHdr : "???", iComponent, pStruct->iInchiRec ? 'R' : 'D', pStruct->iMobileH ? 'M' : 'F', ret ); + fprintf(stdout, "\nERROR in MakeOneInchi-1: %ld %s Comp:%d %c%c Err:%d\n", num_inp, + szCurHdr ? szCurHdr : "???", iComponent, pStruct->iInchiRec ? 'R' : 'D', pStruct->iMobileH ? 'M' : 'F', ret); #endif #endif goto exit_function; } if (pStruct->bMobileH == TAUT_NON) { -/* these indexes are used to compare Mobile-H InChI */ - iOrigInChI = ( pInChI[1] && pInChI[1]->nNumberOfAtoms && !pInChI[1]->bDeleted ) ? 1 : 0; - iRevrInChI = ( pStruct->pOneINChI[1] && pStruct->pOneINChI[1]->nNumberOfAtoms && !pStruct->pOneINChI[1]->bDeleted ) ? 1 : 0; + /* these indexes are used to compare Mobile-H InChI */ + iOrigInChI = (pInChI[1] && pInChI[1]->nNumberOfAtoms && !pInChI[1]->bDeleted) ? 1 : 0; + iRevrInChI = (pStruct->pOneINChI[1] && pStruct->pOneINChI[1]->nNumberOfAtoms && !pStruct->pOneINChI[1]->bDeleted) ? 1 : 0; } else { iOrigInChI = 0; iRevrInChI = 0; } - + /* Intercept and correct non-polymer Zz to Zy if applicable */ if (pStruct->n_zy && pStruct->n_pzz) { if (pStruct->pOneINChI[iRevrInChI]->szHillFormula) { INCHI_IOS_STRING temp_string_container; - INCHI_IOS_STRING *strbuf = &temp_string_container; + INCHI_IOS_STRING* strbuf = &temp_string_container; int len0 = strlen(pStruct->pOneINChI[iRevrInChI]->szHillFormula); - if (inchi_strbuf_init(strbuf, len0+1, len0+1) > 0) + if (inchi_strbuf_init(strbuf, len0 + 1, len0 + 1) > 0) { inchi_strbuf_printf(strbuf, "%-s", pStruct->pOneINChI[iRevrInChI]->szHillFormula); } MergeZzInHillFormula(strbuf); - if (strbuf->nUsedLength>len0+1) + if (strbuf->nUsedLength > len0 + 1) { char* ctmp; /* djb-rwth: supplementary variable */ - ctmp = (char *) realloc(pStruct->pOneINChI[iRevrInChI]->szHillFormula, (long long)strbuf->nUsedLength+1); /* djb-rwth: cast operator added */ + ctmp = (char*)realloc(pStruct->pOneINChI[iRevrInChI]->szHillFormula, (long long)strbuf->nUsedLength + 1); /* djb-rwth: cast operator added */ if (ctmp != NULL) /* djb-rwth: NULL pointer must not be assigned to pStruct->pOneINChI[iRevrInChI]->szHillFormula */ pStruct->pOneINChI[iRevrInChI]->szHillFormula = ctmp; } @@ -1366,11 +1365,11 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, /************************************************************/ /* compare */ /************************************************************/ - if (pStruct->iMobileH == TAUT_NON && ( ret = FillOutExtraFixedHDataRestr( pStruct ) )) + if (pStruct->iMobileH == TAUT_NON && (ret = FillOutExtraFixedHDataRestr(pStruct))) { goto exit_function; } - cmpInChI = CompareReversedINChI2( pStruct->pOneINChI[iRevrInChI], pInChI[iOrigInChI], pStruct->pOneINChI_Aux[iRevrInChI], NULL /*INChI_Aux *a2*/, &icr, &err ); + cmpInChI = CompareReversedINChI2(pStruct->pOneINChI[iRevrInChI], pInChI[iOrigInChI], pStruct->pOneINChI_Aux[iRevrInChI], NULL /*INChI_Aux *a2*/, &icr, &err); if (cmpInChI & IDIF_PROBLEM) { ret = RI_ERR_PROGR; /* severe restore problem */ @@ -1382,12 +1381,12 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, goto exit_function; } /********** InChI from restored structure has LESS hydrogen atoms ******************************/ - if (( cmpInChI & IDIF_LESS_H ) && at_prep && 0 < ( nDeltaCur = icr.tot_num_H2 - icr.tot_num_H1 )) + if ((cmpInChI & IDIF_LESS_H) && at_prep && 0 < (nDeltaCur = icr.tot_num_H2 - icr.tot_num_H1)) { do { - ret = FixLessHydrogenInFormula( pBNS, pBD, pStruct, at, at2, at_prep, pVA, pTCGroups, - pnNumRunBNS, pnTotalDelta, forbidden_edge_mask ); + ret = FixLessHydrogenInFormula(pBNS, pBD, pStruct, at, at2, at_prep, pVA, pTCGroups, + pnNumRunBNS, pnTotalDelta, forbidden_edge_mask); if (ret < 0) { goto exit_function; @@ -1395,14 +1394,14 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, if (ret) { /* Probably success. The changes are in pBNS. Create new InChI out of the new restored structure */ - ret = MakeOneInChIOutOfStrFromINChI2( pCG, ic, ip, sd, pBNS, pStruct, at, at2, at3, pVA, pTCGroups, - &t_group_info, &at_norm, &at_prep ); + ret = MakeOneInChIOutOfStrFromINChI2(pCG, ic, ip, sd, pBNS, pStruct, at, at2, at3, pVA, pTCGroups, + &t_group_info, &at_norm, &at_prep); if (ret < 0) { #if ( bRELEASE_VERSION == 0 ) #ifndef TARGET_API_LIB - fprintf( stdout, "\nERROR in MakeOneInchi-2: %ld %s Comp:%d %c%c Err:%d\n", num_inp, - szCurHdr ? szCurHdr : "???", iComponent, pStruct->iInchiRec ? 'R' : 'D', pStruct->iMobileH ? 'M' : 'F', ret ); + fprintf(stdout, "\nERROR in MakeOneInchi-2: %ld %s Comp:%d %c%c Err:%d\n", num_inp, + szCurHdr ? szCurHdr : "???", iComponent, pStruct->iInchiRec ? 'R' : 'D', pStruct->iMobileH ? 'M' : 'F', ret); #endif #endif goto exit_function; @@ -1410,17 +1409,17 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, /* compare new InChI to the original InChI */ if (pStruct->bMobileH == TAUT_NON) { - iRevrInChI = ( pStruct->pOneINChI[1] && pStruct->pOneINChI[1]->nNumberOfAtoms && !pStruct->pOneINChI[1]->bDeleted ) ? 1 : 0; + iRevrInChI = (pStruct->pOneINChI[1] && pStruct->pOneINChI[1]->nNumberOfAtoms && !pStruct->pOneINChI[1]->bDeleted) ? 1 : 0; } else { iRevrInChI = 0; } - if (pStruct->iMobileH == TAUT_NON && ( ret = FillOutExtraFixedHDataRestr( pStruct ) )) + if (pStruct->iMobileH == TAUT_NON && (ret = FillOutExtraFixedHDataRestr(pStruct))) { goto exit_function; } - cmpInChI = CompareReversedINChI2( pStruct->pOneINChI[iRevrInChI], pInChI[iOrigInChI], pStruct->pOneINChI_Aux[iRevrInChI], NULL, &icr, &err ); + cmpInChI = CompareReversedINChI2(pStruct->pOneINChI[iRevrInChI], pInChI[iOrigInChI], pStruct->pOneINChI_Aux[iRevrInChI], NULL, &icr, &err); nDeltaPrev = nDeltaCur; nDeltaCur = icr.tot_num_H2 - icr.tot_num_H1; } @@ -1428,16 +1427,15 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, { break; } - } - while (( cmpInChI & IDIF_LESS_H ) && at_prep && nDeltaCur && nDeltaCur < nDeltaPrev); + } while ((cmpInChI & IDIF_LESS_H) && at_prep && nDeltaCur && nDeltaCur < nDeltaPrev); } /********** InChI from restored structure has MORE hydrogen atoms ******************************/ - if (( cmpInChI & IDIF_MORE_H ) && at_prep && 0 < ( nDeltaCur = icr.tot_num_H1 - icr.tot_num_H2 )) + if ((cmpInChI & IDIF_MORE_H) && at_prep && 0 < (nDeltaCur = icr.tot_num_H1 - icr.tot_num_H2)) { do { - ret = FixMoreHydrogenInFormula( pBNS, pBD, pStruct, at, at2, at_prep, pVA, pTCGroups, - pnNumRunBNS, pnTotalDelta, forbidden_edge_mask ); + ret = FixMoreHydrogenInFormula(pBNS, pBD, pStruct, at, at2, at_prep, pVA, pTCGroups, + pnNumRunBNS, pnTotalDelta, forbidden_edge_mask); if (ret < 0) { goto exit_function; @@ -1445,14 +1443,14 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, if (ret) { /* Probably success. The changes are in pBNS. Create new InChI out of the new restored structure */ - ret = MakeOneInChIOutOfStrFromINChI2( pCG, ic, ip, sd, pBNS, pStruct, at, at2, at3, pVA, pTCGroups, - &t_group_info, &at_norm, &at_prep ); + ret = MakeOneInChIOutOfStrFromINChI2(pCG, ic, ip, sd, pBNS, pStruct, at, at2, at3, pVA, pTCGroups, + &t_group_info, &at_norm, &at_prep); if (ret < 0) { #if ( bRELEASE_VERSION == 0 ) #ifndef TARGET_API_LIB - fprintf( stdout, "\nERROR in MakeOneInchi-3: %ld %s Comp:%d %c%c Err:%d\n", num_inp, - szCurHdr ? szCurHdr : "???", iComponent, pStruct->iInchiRec ? 'R' : 'D', pStruct->iMobileH ? 'M' : 'F', ret ); + fprintf(stdout, "\nERROR in MakeOneInchi-3: %ld %s Comp:%d %c%c Err:%d\n", num_inp, + szCurHdr ? szCurHdr : "???", iComponent, pStruct->iInchiRec ? 'R' : 'D', pStruct->iMobileH ? 'M' : 'F', ret); #endif #endif goto exit_function; @@ -1460,17 +1458,17 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, /* compare new InChI to the original InChI */ if (pStruct->bMobileH == TAUT_NON) { - iRevrInChI = ( pStruct->pOneINChI[1] && pStruct->pOneINChI[1]->nNumberOfAtoms && !pStruct->pOneINChI[1]->bDeleted ) ? 1 : 0; + iRevrInChI = (pStruct->pOneINChI[1] && pStruct->pOneINChI[1]->nNumberOfAtoms && !pStruct->pOneINChI[1]->bDeleted) ? 1 : 0; } else { iRevrInChI = 0; } - if (pStruct->iMobileH == TAUT_NON && ( ret = FillOutExtraFixedHDataRestr( pStruct ) )) + if (pStruct->iMobileH == TAUT_NON && (ret = FillOutExtraFixedHDataRestr(pStruct))) { goto exit_function; } - cmpInChI = CompareReversedINChI2( pStruct->pOneINChI[iRevrInChI], pInChI[iOrigInChI], pStruct->pOneINChI_Aux[iRevrInChI], NULL, &icr, &err ); + cmpInChI = CompareReversedINChI2(pStruct->pOneINChI[iRevrInChI], pInChI[iOrigInChI], pStruct->pOneINChI_Aux[iRevrInChI], NULL, &icr, &err); nDeltaPrev = nDeltaCur; nDeltaCur = icr.tot_num_H1 - icr.tot_num_H2; } @@ -1478,16 +1476,15 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, { break; } - } - while (( cmpInChI & IDIF_MORE_H ) && at_prep && nDeltaCur && nDeltaCur < nDeltaPrev); + } while ((cmpInChI & IDIF_MORE_H) && at_prep && nDeltaCur && nDeltaCur < nDeltaPrev); } /***************** Fix non-taut atoms normalized to tautomeric endpoints ***********************/ - if (( cmpInChI & IDIF_EXTRA_TG_ENDP ) && at_norm && 0 < ( nDeltaCur = icr.num_endp_in1_only )) + if ((cmpInChI & IDIF_EXTRA_TG_ENDP) && at_norm && 0 < (nDeltaCur = icr.num_endp_in1_only)) { do { - ret = FixRemoveExtraTautEndpoints( pBNS, pBD, pStruct, at, at2, at_prep, at_norm, pVA, pTCGroups, &icr, - pnNumRunBNS, pnTotalDelta, forbidden_edge_mask ); + ret = FixRemoveExtraTautEndpoints(pBNS, pBD, pStruct, at, at2, at_prep, at_norm, pVA, pTCGroups, &icr, + pnNumRunBNS, pnTotalDelta, forbidden_edge_mask); if (ret < 0) { goto exit_function; @@ -1495,14 +1492,14 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, if (ret) { /* Probably success. The changes are in pBNS. Create new InChI out of the new restored structure */ - ret = MakeOneInChIOutOfStrFromINChI2( pCG, ic, ip, sd, pBNS, pStruct, at, at2, at3, pVA, pTCGroups, - &t_group_info, &at_norm, &at_prep ); + ret = MakeOneInChIOutOfStrFromINChI2(pCG, ic, ip, sd, pBNS, pStruct, at, at2, at3, pVA, pTCGroups, + &t_group_info, &at_norm, &at_prep); if (ret < 0) { #if ( bRELEASE_VERSION == 0 ) #ifndef TARGET_API_LIB - fprintf( stdout, "\nERROR in MakeOneInchi-4: %ld %s Comp:%d %c%c Err:%d\n", num_inp, - szCurHdr ? szCurHdr : "???", iComponent, pStruct->iInchiRec ? 'R' : 'D', pStruct->iMobileH ? 'M' : 'F', ret ); + fprintf(stdout, "\nERROR in MakeOneInchi-4: %ld %s Comp:%d %c%c Err:%d\n", num_inp, + szCurHdr ? szCurHdr : "???", iComponent, pStruct->iInchiRec ? 'R' : 'D', pStruct->iMobileH ? 'M' : 'F', ret); #endif #endif goto exit_function; @@ -1510,17 +1507,17 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, /* compare new InChI to the original InChI */ if (pStruct->bMobileH == TAUT_NON) { - iRevrInChI = ( pStruct->pOneINChI[1] && pStruct->pOneINChI[1]->nNumberOfAtoms && !pStruct->pOneINChI[1]->bDeleted ) ? 1 : 0; + iRevrInChI = (pStruct->pOneINChI[1] && pStruct->pOneINChI[1]->nNumberOfAtoms && !pStruct->pOneINChI[1]->bDeleted) ? 1 : 0; } else { iRevrInChI = 0; } - if (pStruct->iMobileH == TAUT_NON && ( ret = FillOutExtraFixedHDataRestr( pStruct ) )) + if (pStruct->iMobileH == TAUT_NON && (ret = FillOutExtraFixedHDataRestr(pStruct))) { goto exit_function; } - cmpInChI = CompareReversedINChI2( pStruct->pOneINChI[iRevrInChI], pInChI[iOrigInChI], pStruct->pOneINChI_Aux[iRevrInChI], NULL, &icr, &err ); + cmpInChI = CompareReversedINChI2(pStruct->pOneINChI[iRevrInChI], pInChI[iOrigInChI], pStruct->pOneINChI_Aux[iRevrInChI], NULL, &icr, &err); nDeltaPrev = nDeltaCur; nDeltaCur = icr.num_endp_in1_only; } @@ -1528,8 +1525,7 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, { break; } - } - while (( cmpInChI & IDIF_EXTRA_TG_ENDP ) && at_norm && nDeltaCur && nDeltaCur < nDeltaPrev); + } while ((cmpInChI & IDIF_EXTRA_TG_ENDP) && at_norm && nDeltaCur && nDeltaCur < nDeltaPrev); } /************************ case of Fixed-H ******************************************************/ @@ -1538,30 +1534,29 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, int num_tries = 0; do { - if (0 > ( ret = FixFixedHRestoredStructure( pCG, ic, ip, sd, pBNS, pBD, pStruct, at, at2, at3, pVA, pTCGroups, + if (0 > (ret = FixFixedHRestoredStructure(pCG, ic, ip, sd, pBNS, pBD, pStruct, at, at2, at3, pVA, pTCGroups, &t_group_info, &at_norm, &at_prep, pInChI, num_inp, bHasSomeFixedH, pnNumRunBNS, pnTotalDelta, forbidden_edge_mask, - forbidden_stereo_edge_mask ) )) + forbidden_stereo_edge_mask))) { goto exit_function; } - } - while (num_tries++ < 2 && ret > 0); + } while (num_tries++ < 2 && ret > 0); } /************************ case of Fixed-H ******************************************************/ if (pStruct->bMobileH == TAUT_YES) { - if (0 > ( ret = FixMobileHRestoredStructure( pCG, ic, ip, sd, pBNS, pBD, pStruct, at, at2, at3, pVA, pTCGroups, + if (0 > (ret = FixMobileHRestoredStructure(pCG, ic, ip, sd, pBNS, pBD, pStruct, at, at2, at3, pVA, pTCGroups, &t_group_info, &at_norm, &at_prep, pInChI, num_inp, bHasSomeFixedH, pnNumRunBNS, pnTotalDelta, forbidden_edge_mask, - forbidden_stereo_edge_mask ) )) + forbidden_stereo_edge_mask))) { goto exit_function; } } /**********************************************************************************************/ /* stereo */ - cmpInChI = CompareReversedINChI2( pStruct->pOneINChI[0], pInChI[0], pStruct->pOneINChI_Aux[0], NULL /*INChI_Aux *a2*/, &icr, &err ); + cmpInChI = CompareReversedINChI2(pStruct->pOneINChI[0], pInChI[0], pStruct->pOneINChI_Aux[0], NULL /*INChI_Aux *a2*/, &icr, &err); if (cmpInChI & IDIF_PROBLEM) { ret = RI_ERR_PROGR; /* severe restore problem */ @@ -1573,11 +1568,11 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, goto exit_function; } cmpInChI2 = 0; - memset( &icr2, 0, sizeof( icr2 ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(&icr2, 0, sizeof(icr2)); /* djb-rwth: memset_s C11/Annex K variant? */ if (iRevrInChI || iOrigInChI) { /* additional mobile-H compare in case of Fixed-H */ - cmpInChI2 = CompareReversedINChI2( pStruct->pOneINChI[iRevrInChI], pInChI[iOrigInChI], pStruct->pOneINChI_Aux[iRevrInChI], NULL /*INChI_Aux *a2*/, &icr2, &err ); + cmpInChI2 = CompareReversedINChI2(pStruct->pOneINChI[iRevrInChI], pInChI[iOrigInChI], pStruct->pOneINChI_Aux[iRevrInChI], NULL /*INChI_Aux *a2*/, &icr2, &err); if (cmpInChI & IDIF_PROBLEM) { ret = RI_ERR_PROGR; /* severe restore problem */ @@ -1589,12 +1584,12 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, goto exit_function; } } - ret = FixRestoredStructureStereo( pCG, ic, - cmpInChI, &icr, cmpInChI2, &icr2, - ip, sd, pBNS, pBD, pStruct, at, at2, at3, pVA, pTCGroups, - &t_group_info, &at_norm, &at_prep, pInChI, - num_inp, pnNumRunBNS, pnTotalDelta, forbidden_edge_mask, - forbidden_stereo_edge_mask ); + ret = FixRestoredStructureStereo(pCG, ic, + cmpInChI, &icr, cmpInChI2, &icr2, + ip, sd, pBNS, pBD, pStruct, at, at2, at3, pVA, pTCGroups, + &t_group_info, &at_norm, &at_prep, pInChI, + num_inp, pnNumRunBNS, pnTotalDelta, forbidden_edge_mask, + forbidden_stereo_edge_mask); if (ret < 0) { @@ -1604,17 +1599,17 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, /************************ check and fix ADP by adding a proton (dummy) *************************/ if (cmpInChI && pTCGroups->num_tgroups && pBNS->tot_st_cap > pBNS->tot_st_flow) { - ret = FixAddProtonForADP( pBNS, pBD, pStruct, at, at2, at_prep, pVA, pTCGroups, &icr, - pnNumRunBNS, pnTotalDelta, forbidden_edge_mask ); + ret = FixAddProtonForADP(pBNS, pBD, pStruct, at, at2, at_prep, pVA, pTCGroups, &icr, + pnNumRunBNS, pnTotalDelta, forbidden_edge_mask); if (ret < 0) { goto exit_function; } } #endif - /* moved to MakeOneInChIOutOfStrFromINChI(): - pStruct->nNumRemovedProtons = (pStruct->iMobileH == TAUT_YES)? pStruct->One_ti.tni.nNumRemovedProtons : 0; - */ + /* moved to MakeOneInChIOutOfStrFromINChI(): + pStruct->nNumRemovedProtons = (pStruct->iMobileH == TAUT_YES)? pStruct->One_ti.tni.nNumRemovedProtons : 0; + */ /* count endpoints */ num_endpoints = 0; @@ -1646,13 +1641,13 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, #ifndef TARGET_API_LIB if (num_norm_t_groups != pTCGroups->num_tgroups || num_norm_endpoints != num_endpoints) { -/* need aggressive (de)protonation */ -/* pStruct->bExtract |= EXTRACT_STRUCT_NUMBER; */ - fprintf( stdout, "NORMCOMP: %s comp=%d %c%c: InChI/NormRvrs NumTg=%d/%d NumEndp=%d/%d\n", - ( *ip ).pSdfValue, ( *pTCGroups ).iComponent, - pStruct->iInchiRec ? 'R' : 'D', pStruct->iMobileH ? 'M' : 'F', - pTCGroups->num_tgroups, num_norm_t_groups, - num_endpoints, num_norm_endpoints ); + /* need aggressive (de)protonation */ + /* pStruct->bExtract |= EXTRACT_STRUCT_NUMBER; */ + fprintf(stdout, "NORMCOMP: %s comp=%d %c%c: InChI/NormRvrs NumTg=%d/%d NumEndp=%d/%d\n", + (*ip).pSdfValue, (*pTCGroups).iComponent, + pStruct->iInchiRec ? 'R' : 'D', pStruct->iMobileH ? 'M' : 'F', + pTCGroups->num_tgroups, num_norm_t_groups, + num_endpoints, num_norm_endpoints); } #endif #endif @@ -1661,17 +1656,17 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, for (i = 0; i < TAUT_NUM; i++) { - Free_INChI( &pStruct->pOneINChI[i] ); - Free_INChI_Aux( &pStruct->pOneINChI_Aux[i] ); - FreeInpAtomData( pStruct->pOne_norm_data[i] ); + Free_INChI(&pStruct->pOneINChI[i]); + Free_INChI_Aux(&pStruct->pOneINChI_Aux[i]); + FreeInpAtomData(pStruct->pOne_norm_data[i]); if (pStruct->pOne_norm_data[i]) { - inchi_free( pStruct->pOne_norm_data[i] ); + inchi_free(pStruct->pOne_norm_data[i]); pStruct->pOne_norm_data[i] = NULL; } } - free_t_group_info( &pStruct->One_ti ); + free_t_group_info(&pStruct->One_ti); return ret; } @@ -1680,9 +1675,9 @@ int NormalizeAndCompare( CANON_GLOBALS *pCG, /**************************************************************************** Find A=X< where all bonds to X except A=X are marked as stereogenic; temporary allow stereobonds change and make A=X bonds single */ -int CheckAndRefixStereobonds( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStruct, - inp_ATOM *at, inp_ATOM *at2, VAL_AT *pVA, ALL_TC_GROUPS *pTCGroups, - int *pnNumRunBNS, int *pnTotalDelta, int forbidden_edge_mask ) +int CheckAndRefixStereobonds(BN_STRUCT* pBNS, BN_DATA* pBD, StrFromINChI* pStruct, + inp_ATOM* at, inp_ATOM* at2, VAL_AT* pVA, ALL_TC_GROUPS* pTCGroups, + int* pnNumRunBNS, int* pnTotalDelta, int forbidden_edge_mask) { int forbidden_edge_stereo = BNS_EDGE_FORBIDDEN_MASK; int inv_forbidden_edge_stereo = ~forbidden_edge_stereo; @@ -1694,16 +1689,16 @@ int CheckAndRefixStereobonds( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStru int len_at = num_at + num_deleted_H; EDGE_LIST FixedEdges, WrongEdges, CarbonChargeEdges; - BNS_EDGE *pEdge; + BNS_EDGE* pEdge; Vertex v1, v2; - BNS_VERTEX *pv1, *pv2; + BNS_VERTEX* pv1, * pv2; ret = 0; /* to simplify, prepare new at[] from pBNS */ memcpy(at2, at, len_at * sizeof(at2[0])); pStruct->at = at2; - ret2 = CopyBnsToAtom( pStruct, pBNS, pVA, pTCGroups, 1 ); + ret2 = CopyBnsToAtom(pStruct, pBNS, pVA, pTCGroups, 1); pStruct->at = at; if (ret2 < 0) { @@ -1715,11 +1710,11 @@ int CheckAndRefixStereobonds( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStru for (i = 0; i < num_at; i++) { if (at2[i].valence == 3 && - at2[i].chem_bonds_valence - at2[i].valence == 1 && - at2[i].sb_parity[0] && at2[i].sb_parity[1] && !at2[i].sb_parity[2] && - ( at2[i].bond_type[j1 = (int) at2[i].sb_ord[0]] & BOND_TYPE_MASK ) == BOND_TYPE_SINGLE && - ( at2[i].bond_type[j2 = (int) at2[i].sb_ord[1]] & BOND_TYPE_MASK ) == BOND_TYPE_SINGLE && - j1 != j2) + at2[i].chem_bonds_valence - at2[i].valence == 1 && + at2[i].sb_parity[0] && at2[i].sb_parity[1] && !at2[i].sb_parity[2] && + (at2[i].bond_type[j1 = (int)at2[i].sb_ord[0]] & BOND_TYPE_MASK) == BOND_TYPE_SINGLE && + (at2[i].bond_type[j2 = (int)at2[i].sb_ord[1]] & BOND_TYPE_MASK) == BOND_TYPE_SINGLE && + j1 != j2) { num_wrong++; @@ -1740,18 +1735,18 @@ int CheckAndRefixStereobonds( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStru } /* there may be no fixed stereo bonds at all, see #87607 */ - AllocEdgeList( &CarbonChargeEdges, EDGE_LIST_CLEAR ); - AllocEdgeList( &FixedEdges, EDGE_LIST_CLEAR ); - AllocEdgeList( &WrongEdges, EDGE_LIST_CLEAR ); + AllocEdgeList(&CarbonChargeEdges, EDGE_LIST_CLEAR); + AllocEdgeList(&FixedEdges, EDGE_LIST_CLEAR); + AllocEdgeList(&WrongEdges, EDGE_LIST_CLEAR); /* do not goto exit_function before reaching this point: EdgeLists have not been initiated */ - if (0 > ( ret = ForbidCarbonChargeEdges( pBNS, pTCGroups, &CarbonChargeEdges, forbidden_edge_mask ) )) + if (0 > (ret = ForbidCarbonChargeEdges(pBNS, pTCGroups, &CarbonChargeEdges, forbidden_edge_mask))) { goto exit_function; } - if (( ret = AllocEdgeList( &FixedEdges, num_fixed ) ) || - ( ret = AllocEdgeList( &WrongEdges, num_wrong ) )) + if ((ret = AllocEdgeList(&FixedEdges, num_fixed)) || + (ret = AllocEdgeList(&WrongEdges, num_wrong))) { goto exit_function; } @@ -1759,26 +1754,26 @@ int CheckAndRefixStereobonds( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStru for (i = 0; i < num_at && WrongEdges.num_edges < num_wrong; i++) { if (at2[i].valence == 3 && - at2[i].chem_bonds_valence - at2[i].valence == 1 && - at2[i].sb_parity[0] && at2[i].sb_parity[1] && !at2[i].sb_parity[2] && - ( at2[i].bond_type[j1 = (int) at2[i].sb_ord[0]] & BOND_TYPE_MASK ) == BOND_TYPE_SINGLE && - ( at2[i].bond_type[j2 = (int) at2[i].sb_ord[1]] & BOND_TYPE_MASK ) == BOND_TYPE_SINGLE && - j1 != j2) + at2[i].chem_bonds_valence - at2[i].valence == 1 && + at2[i].sb_parity[0] && at2[i].sb_parity[1] && !at2[i].sb_parity[2] && + (at2[i].bond_type[j1 = (int)at2[i].sb_ord[0]] & BOND_TYPE_MASK) == BOND_TYPE_SINGLE && + (at2[i].bond_type[j2 = (int)at2[i].sb_ord[1]] & BOND_TYPE_MASK) == BOND_TYPE_SINGLE && + j1 != j2) { switch (j1 + j2) { - case 1: /* 0, 1 */ - k = 2; - break; - case 2: /* 0, 2 */ - k = 1; - break; - case 3: /* 1, 2 */ - k = 0; - break; - default: - ret = RI_ERR_PROGR; - goto exit_function; + case 1: /* 0, 1 */ + k = 2; + break; + case 2: /* 0, 2 */ + k = 1; + break; + case 3: /* 1, 2 */ + k = 0; + break; + default: + ret = RI_ERR_PROGR; + goto exit_function; } ne = pBNS->vert[i].iedge[k]; pEdge = pBNS->edge + ne; @@ -1797,7 +1792,7 @@ int CheckAndRefixStereobonds( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStru pv1->st_edge.flow--; pv2->st_edge.flow--; pBNS->tot_st_flow -= 2; - if ((ret = AddToEdgeList( &WrongEdges, ne, 0 ))) /* djb-rwth: addressing LLVM warning */ + if ((ret = AddToEdgeList(&WrongEdges, ne, 0))) /* djb-rwth: addressing LLVM warning */ { goto exit_function; } @@ -1814,8 +1809,8 @@ int CheckAndRefixStereobonds( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStru } } /* Run BNS to move charges and rearrange bond orders */ - retBNS = RunBnsRestoreOnce( pBNS, pBD, pVA, pTCGroups ); - ( *pnNumRunBNS )++; + retBNS = RunBnsRestoreOnce(pBNS, pBD, pVA, pTCGroups); + (*pnNumRunBNS)++; if (retBNS < 0) { goto exit_function; @@ -1828,14 +1823,14 @@ int CheckAndRefixStereobonds( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStru } } /* remove forbidden_edge_mask and set forbidden_edge_stereo */ - RemoveForbiddenEdgeMask( pBNS, &WrongEdges, forbidden_edge_mask ); + RemoveForbiddenEdgeMask(pBNS, &WrongEdges, forbidden_edge_mask); /* allow carbon charges to change */ - RemoveForbiddenEdgeMask( pBNS, &CarbonChargeEdges, forbidden_edge_mask ); + RemoveForbiddenEdgeMask(pBNS, &CarbonChargeEdges, forbidden_edge_mask); /* fix previously unfixed stereo bonds */ - SetForbiddenEdgeMask( pBNS, &FixedEdges, forbidden_edge_stereo ); + SetForbiddenEdgeMask(pBNS, &FixedEdges, forbidden_edge_stereo); /* Run BNS again in case not all edge flows are maximal */ - ret2 = RunBnsRestoreOnce( pBNS, pBD, pVA, pTCGroups ); - ( *pnNumRunBNS )++; + ret2 = RunBnsRestoreOnce(pBNS, pBD, pVA, pTCGroups); + (*pnNumRunBNS)++; if (ret2 < 0) { goto exit_function; @@ -1851,9 +1846,9 @@ int CheckAndRefixStereobonds( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStru exit_function: - AllocEdgeList( &CarbonChargeEdges, EDGE_LIST_FREE ); - AllocEdgeList( &FixedEdges, EDGE_LIST_FREE ); - AllocEdgeList( &WrongEdges, EDGE_LIST_FREE ); + AllocEdgeList(&CarbonChargeEdges, EDGE_LIST_FREE); + AllocEdgeList(&FixedEdges, EDGE_LIST_FREE); + AllocEdgeList(&WrongEdges, EDGE_LIST_FREE); return ret; } @@ -1862,16 +1857,16 @@ int CheckAndRefixStereobonds( BN_STRUCT *pBNS, BN_DATA *pBD, StrFromINChI *pStru /**************************************************************************** Find and eliminate false Mobile-H groups: Cl(=O)3(-O(-)) => Cl(-)(=O)4 ****************************************************************************/ -int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, - BN_DATA *pBD, - StrFromINChI *pStruct, - inp_ATOM *at, - inp_ATOM *at2, - VAL_AT *pVA, - ALL_TC_GROUPS *pTCGroups, - int *pnNumRunBNS, - int *pnTotalDelta, - int forbidden_edge_mask ) +int MoveChargeToRemoveCenerpoints(BN_STRUCT* pBNS, + BN_DATA* pBD, + StrFromINChI* pStruct, + inp_ATOM* at, + inp_ATOM* at2, + VAL_AT* pVA, + ALL_TC_GROUPS* pTCGroups, + int* pnNumRunBNS, + int* pnTotalDelta, + int forbidden_edge_mask) { int i, j, neigh, num_success; /* djb-rwth: removing redundant variables */ int num_donors, num_acceptors, bond_type, num_donors_O, num_acceptors_O, is_centerpoint_N, num_known_endpoints, num_wrong_neigh; @@ -1880,15 +1875,15 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, int num_deleted_H = pStruct->num_deleted_H; int len_at = num_at + num_deleted_H; int forbidden_edge_test = BNS_EDGE_FORBIDDEN_TEST; - int bPossiblyIgnore = pStruct->charge >= 0 && ( !pTCGroups->num_tgroups || (pStruct->iMobileH == TAUT_NON && pStruct->ti.num_t_groups) ); /* djb-rwth: addressing LLVM warning */ + int bPossiblyIgnore = pStruct->charge >= 0 && (!pTCGroups->num_tgroups || (pStruct->iMobileH == TAUT_NON && pStruct->ti.num_t_groups)); /* djb-rwth: addressing LLVM warning */ S_CHAR MobileChargeNeigh[MAXVAL], DoubleBondAcceptors[MAXVAL], DoubleBondNotONeigh[MAXVAL]; int numMobileChargeNeigh, numDoubleBondAcceptors, numDoubleBondNotONeigh; /* djb-rwth: removing redundant variables */ EDGE_LIST ChargeListAllExcept_DB_O; - BNS_EDGE *pEdgeMinus, *pe; + BNS_EDGE* pEdgeMinus, * pe; Vertex v1m, v2m; - BNS_VERTEX *pv1m, *pv2m; + BNS_VERTEX* pv1m, * pv2m; /* djb-rwth: removing redundant code */ num_success = 0; @@ -1899,7 +1894,7 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, goto exit_function; } */ - if ((ret = AllocEdgeList( &ChargeListAllExcept_DB_O, EDGE_LIST_CLEAR ))) /* djb-rwth: addressing LLVM warning */ + if ((ret = AllocEdgeList(&ChargeListAllExcept_DB_O, EDGE_LIST_CLEAR))) /* djb-rwth: addressing LLVM warning */ { goto exit_function; } @@ -1908,7 +1903,7 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, /* to simplify, prepare new at[] from pBNS */ memcpy(at2, at, len_at * sizeof(at2[0])); pStruct->at = at2; - ret2 = CopyBnsToAtom( pStruct, pBNS, pVA, pTCGroups, 1 ); + ret2 = CopyBnsToAtom(pStruct, pBNS, pVA, pTCGroups, 1); pStruct->at = at; if (ret2 < 0) { @@ -1916,7 +1911,7 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, goto exit_function; } #if ( FIND_RING_SYSTEMS == 1 ) - ret2 = MarkRingSystemsInp( at2, num_at, 0 ); + ret2 = MarkRingSystemsInp(at2, num_at, 0); if (ret2 < 0) { ret = ret2; @@ -1924,7 +1919,7 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, } #endif /* mark bonds that cannot be tautomeric; do not forget to remove the marks later */ - ret_forbid_edges = SetForbiddenEdges( pBNS, at2, num_at, forbidden_edge_test, 0, NULL ); + ret_forbid_edges = SetForbiddenEdges(pBNS, at2, num_at, forbidden_edge_test, 0, NULL); if (ret_forbid_edges < 0) { ret = ret_forbid_edges; @@ -1934,13 +1929,13 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, for (i = 0; i < num_at; i++) { if (pVA[i].cNumValenceElectrons != 4 && /* not C, Si, Ge */ - !( pVA[i].nTautGroupEdge || (pStruct->iMobileH == TAUT_NON && pStruct->endpoint && pStruct->endpoint[i]) ) && - !at2[i].num_H && !at2[i].charge && at2[i].valence >= 2 && - at2[i].valence < at2[i].chem_bonds_valence && - is_centerpoint_elem( at2[i].el_number )) /* djb-rwth: addressing LLVM warning */ + !(pVA[i].nTautGroupEdge || (pStruct->iMobileH == TAUT_NON && pStruct->endpoint && pStruct->endpoint[i])) && + !at2[i].num_H && !at2[i].charge && at2[i].valence >= 2 && + at2[i].valence < at2[i].chem_bonds_valence && + is_centerpoint_elem(at2[i].el_number)) /* djb-rwth: addressing LLVM warning */ { - is_centerpoint_N = ( pVA[i].cNumValenceElectrons == 5 && ( pVA[i].cPeriodicRowNumber == 1 || pVA[i].cMetal ) ); + is_centerpoint_N = (pVA[i].cNumValenceElectrons == 5 && (pVA[i].cPeriodicRowNumber == 1 || pVA[i].cMetal)); /* look at the neighbors */ numMobileChargeNeigh = numDoubleBondAcceptors = numDoubleBondNotONeigh = num_donors = num_acceptors = 0; num_donors_O = num_acceptors_O = 0; @@ -1948,7 +1943,7 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, for (j = 0; j < at2[i].valence; j++) /* djb-rwth: removing redundant code */ { neigh = at2[i].neighbor[j]; - if (( at2[neigh].endpoint || (pStruct->iMobileH == TAUT_NON && pStruct->endpoint && pStruct->endpoint[neigh]) ) || at2[neigh].charge > 0) /* djb-rwth: addressing LLVM warning */ + if ((at2[neigh].endpoint || (pStruct->iMobileH == TAUT_NON && pStruct->endpoint && pStruct->endpoint[neigh])) || at2[neigh].charge > 0) /* djb-rwth: addressing LLVM warning */ { num_known_endpoints++; continue; @@ -1968,7 +1963,7 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, break; /* not this case */ } if (at2[neigh].chem_bonds_valence - at2[neigh].charge - != get_endpoint_valence( at2[neigh].el_number )) + != get_endpoint_valence(at2[neigh].el_number)) { if (bond_type == BOND_TYPE_DOUBLE && pVA[neigh].cNumValenceElectrons != 6) { @@ -1977,31 +1972,31 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, continue; } if (at2[neigh].charge == -1 && bond_type == BOND_TYPE_SINGLE && - ( pVA[neigh].nCMinusGroupEdge < 1 || pBNS->edge[pVA[neigh].nCMinusGroupEdge - 1].flow != 1 )) + (pVA[neigh].nCMinusGroupEdge < 1 || pBNS->edge[pVA[neigh].nCMinusGroupEdge - 1].flow != 1)) { break; } switch (bond_type) { - case BOND_TYPE_SINGLE: - if (at2[neigh].charge != -1 || pVA[neigh].nCMinusGroupEdge <= 0) - { - num_wrong_neigh++; - continue; - } - num_donors++; - num_donors_O += ( pVA[neigh].cNumValenceElectrons == 6 && pVA[neigh].cPeriodicRowNumber <= 4 ); - MobileChargeNeigh[numMobileChargeNeigh++] = j; - break; - case BOND_TYPE_DOUBLE: - if (at2[neigh].charge) - { - num_wrong_neigh++; - continue; - } - DoubleBondAcceptors[numDoubleBondAcceptors++] = j; - num_acceptors++; - num_acceptors_O += ( pVA[neigh].cNumValenceElectrons == 6 && pVA[neigh].cPeriodicRowNumber <= 4 ); + case BOND_TYPE_SINGLE: + if (at2[neigh].charge != -1 || pVA[neigh].nCMinusGroupEdge <= 0) + { + num_wrong_neigh++; + continue; + } + num_donors++; + num_donors_O += (pVA[neigh].cNumValenceElectrons == 6 && pVA[neigh].cPeriodicRowNumber <= 4); + MobileChargeNeigh[numMobileChargeNeigh++] = j; + break; + case BOND_TYPE_DOUBLE: + if (at2[neigh].charge) + { + num_wrong_neigh++; + continue; + } + DoubleBondAcceptors[numDoubleBondAcceptors++] = j; + num_acceptors++; + num_acceptors_O += (pVA[neigh].cNumValenceElectrons == 6 && pVA[neigh].cPeriodicRowNumber <= 4); } } if (j != at2[i].valence || !num_donors || !num_acceptors) @@ -2009,7 +2004,7 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, continue; } /* special case NOn(-) */ - if (is_centerpoint_N && ( num_donors == num_donors_O ) && ( num_acceptors == num_acceptors_O )) + if (is_centerpoint_N && (num_donors == num_donors_O) && (num_acceptors == num_acceptors_O)) { continue; } @@ -2026,23 +2021,23 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, for (k = 0; k < num_at; k++) { if (!((1 == at2[k].valence && pBNS->edge[pBNS->vert[k].iedge[0]].flow && - !pBNS->edge[pBNS->vert[k].iedge[0]].forbidden && - !( ( e = pVA[k].nCMinusGroupEdge - 1 ) >= 0 && pBNS->edge[e].flow ) && - !( ( e = pVA[k].nCPlusGroupEdge - 1 ) >= 0 && !pBNS->edge[e].flow ) && - /* 0 == at2[k].charge && */ - pVA[k].cNumValenceElectrons == 6 && !pVA[k].cMetal && - (pStruct->endpoint && pStruct->endpoint[k])) || - (pStruct->fixed_H && pStruct->fixed_H[k]))) /* djb-rwth: addressing LLVM warnings */ + !pBNS->edge[pBNS->vert[k].iedge[0]].forbidden && + !((e = pVA[k].nCMinusGroupEdge - 1) >= 0 && pBNS->edge[e].flow) && + !((e = pVA[k].nCPlusGroupEdge - 1) >= 0 && !pBNS->edge[e].flow) && + /* 0 == at2[k].charge && */ + pVA[k].cNumValenceElectrons == 6 && !pVA[k].cMetal && + (pStruct->endpoint && pStruct->endpoint[k])) || + (pStruct->fixed_H && pStruct->fixed_H[k]))) /* djb-rwth: addressing LLVM warnings */ /* djb-rwth: removing redundant code */ - if (( e = pVA[k].nCMinusGroupEdge - 1 ) >= 0 && !pBNS->edge[e].flow && - !pBNS->edge[e].forbidden && - ( ret = AddToEdgeList( &ChargeListAllExcept_DB_O, e, 64 ) )) + if ((e = pVA[k].nCMinusGroupEdge - 1) >= 0 && !pBNS->edge[e].flow && + !pBNS->edge[e].forbidden && + (ret = AddToEdgeList(&ChargeListAllExcept_DB_O, e, 64))) { goto exit_function; } - if (( e = pVA[k].nCPlusGroupEdge - 1 ) >= 0 && - !pBNS->edge[e].forbidden && - ( ret = AddToEdgeList( &ChargeListAllExcept_DB_O, e, 64 ) )) + if ((e = pVA[k].nCPlusGroupEdge - 1) >= 0 && + !pBNS->edge[e].forbidden && + (ret = AddToEdgeList(&ChargeListAllExcept_DB_O, e, 64))) { goto exit_function; } @@ -2052,39 +2047,39 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, we will try to make these bons single */ for (k = 0; k < numDoubleBondNotONeigh; k++) { - e = pBNS->vert[i].iedge[(int) DoubleBondNotONeigh[k]]; + e = pBNS->vert[i].iedge[(int)DoubleBondNotONeigh[k]]; if (!pBNS->edge[e].forbidden && - ( ret = AddToEdgeList( &ChargeListAllExcept_DB_O, e, 64 ) )) + (ret = AddToEdgeList(&ChargeListAllExcept_DB_O, e, 64))) { goto exit_function; } } /* attempt to make DoubleBondNotONeigh[] single */ - SetForbiddenEdgeMask( pBNS, &ChargeListAllExcept_DB_O, forbidden_edge_mask ); + SetForbiddenEdgeMask(pBNS, &ChargeListAllExcept_DB_O, forbidden_edge_mask); for (k = 0; k < numDoubleBondNotONeigh && num_MovedCharges < numMobileChargeNeigh; k++) { - pe = pBNS->edge + pBNS->vert[i].iedge[(int) DoubleBondNotONeigh[k]]; + pe = pBNS->edge + pBNS->vert[i].iedge[(int)DoubleBondNotONeigh[k]]; delta = 1; if (pe->flow != delta) continue; - pv1m = pBNS->vert + ( v1m = pe->neighbor1 ); - pv2m = pBNS->vert + ( v2m = pe->neighbor12 ^ v1m ); + pv1m = pBNS->vert + (v1m = pe->neighbor1); + pv2m = pBNS->vert + (v2m = pe->neighbor12 ^ v1m); pv1m->st_edge.flow -= delta; pv2m->st_edge.flow -= delta; pe->flow -= delta; pBNS->tot_st_flow -= 2 * delta; - ret = RunBnsTestOnce( pBNS, pBD, pVA, &vPathStart, &vPathEnd, &nPathLen, - &nDeltaH, &nDeltaCharge, &nNumVisitedAtoms ); + ret = RunBnsTestOnce(pBNS, pBD, pVA, &vPathStart, &vPathEnd, &nPathLen, + &nDeltaH, &nDeltaCharge, &nNumVisitedAtoms); if (ret < 0) { goto exit_function; } - if (ret == 1 && ( (vPathEnd == v1m && vPathStart == v2m) || - (vPathEnd == v2m && vPathStart == v1m) ) && - nDeltaCharge == 0 /* (-) moving from one to another atom*/) /* djb-rwth: addressing LLVM warnings */ + if (ret == 1 && ((vPathEnd == v1m && vPathStart == v2m) || + (vPathEnd == v2m && vPathStart == v1m)) && + nDeltaCharge == 0 /* (-) moving from one to another atom*/) /* djb-rwth: addressing LLVM warnings */ { - ret = RunBnsRestoreOnce( pBNS, pBD, pVA, pTCGroups ); - ( *pnNumRunBNS )++; + ret = RunBnsRestoreOnce(pBNS, pBD, pVA, pTCGroups); + (*pnNumRunBNS)++; if (ret < 0) { goto exit_function; @@ -2112,7 +2107,7 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, pBNS->tot_st_flow += 2 * delta; } } - RemoveForbiddenEdgeMask( pBNS, &ChargeListAllExcept_DB_O, forbidden_edge_mask ); + RemoveForbiddenEdgeMask(pBNS, &ChargeListAllExcept_DB_O, forbidden_edge_mask); } else { @@ -2124,8 +2119,8 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, pVA[i].cInitCharge -= num_donors; /* work no matter what are known charge/valence */ for (j = 0; j < numMobileChargeNeigh; j++) { - neigh = at2[i].neighbor[(int) MobileChargeNeigh[j]]; - pEdgeMinus = pBNS->edge + ( (long long)pVA[neigh].nCMinusGroupEdge - 1 ); /* djb-rwth: cast operator added */ + neigh = at2[i].neighbor[(int)MobileChargeNeigh[j]]; + pEdgeMinus = pBNS->edge + ((long long)pVA[neigh].nCMinusGroupEdge - 1); /* djb-rwth: cast operator added */ v1m = pEdgeMinus->neighbor1; v2m = pEdgeMinus->neighbor12 ^ v1m; pv1m = pBNS->vert + v1m; @@ -2133,14 +2128,14 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, delta = pEdgeMinus->flow; pv1m->st_edge.flow -= delta; pv2m->st_edge.flow -= delta; - if (IS_BNS_VT_C_GR( pv1m->type )) + if (IS_BNS_VT_C_GR(pv1m->type)) { /* irreversible change to ChargeStruct */ pv1m->st_edge.cap -= delta; } else { - if (IS_BNS_VT_C_GR( pv2m->type )) + if (IS_BNS_VT_C_GR(pv2m->type)) { /* irreversible change to ChargeStruct */ pv2m->st_edge.cap -= delta; @@ -2155,8 +2150,8 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, pBNS->tot_st_flow -= 2 * delta; pEdgeMinus->flow -= delta; } - ret = RunBnsRestoreOnce( pBNS, pBD, pVA, pTCGroups ); - ( *pnNumRunBNS )++; + ret = RunBnsRestoreOnce(pBNS, pBD, pVA, pTCGroups); + (*pnNumRunBNS)++; if (ret < 0) { goto exit_function; @@ -2180,13 +2175,13 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, if (ret_forbid_edges) { /* remove the marks */ - RemoveForbiddenBondFlowBits( pBNS, forbidden_edge_test ); + RemoveForbiddenBondFlowBits(pBNS, forbidden_edge_test); } ret = num_success; exit_function: - AllocEdgeList( &ChargeListAllExcept_DB_O, EDGE_LIST_FREE ); + AllocEdgeList(&ChargeListAllExcept_DB_O, EDGE_LIST_FREE); return ret; } @@ -2196,16 +2191,16 @@ int MoveChargeToRemoveCenerpoints( BN_STRUCT *pBNS, Find and eliminate cases when Mobile H endpoint has radical on it (typical for wrong P(VI)(=O)3OH ****************************************************************************/ -int MakeSingleBondsMetal2ChargedHeteroat( BN_STRUCT *pBNS, - BN_DATA *pBD, - StrFromINChI *pStruct, - inp_ATOM *at, - inp_ATOM *at2, - VAL_AT *pVA, - ALL_TC_GROUPS *pTCGroups, - int *pnNumRunBNS, - int *pnTotalDelta, - int forbidden_edge_mask ) +int MakeSingleBondsMetal2ChargedHeteroat(BN_STRUCT* pBNS, + BN_DATA* pBD, + StrFromINChI* pStruct, + inp_ATOM* at, + inp_ATOM* at2, + VAL_AT* pVA, + ALL_TC_GROUPS* pTCGroups, + int* pnNumRunBNS, + int* pnTotalDelta, + int forbidden_edge_mask) { int i; @@ -2217,10 +2212,10 @@ int MakeSingleBondsMetal2ChargedHeteroat( BN_STRUCT *pBNS, int j, k; int cur_num_edges; - BNS_EDGE *e; + BNS_EDGE* e; Vertex v1, v2; - EdgeIndex *pFixedEdges; + EdgeIndex* pFixedEdges; int nNumEdgesToFix; ret = 0; @@ -2228,7 +2223,7 @@ int MakeSingleBondsMetal2ChargedHeteroat( BN_STRUCT *pBNS, /* to simplify, prepare new at[] from pBNS */ memcpy(at2, at, len_at * sizeof(at2[0])); pStruct->at = at2; - ret2 = CopyBnsToAtom( pStruct, pBNS, pVA, pTCGroups, 1 ); + ret2 = CopyBnsToAtom(pStruct, pBNS, pVA, pTCGroups, 1); pStruct->at = at; if (ret2 < 0) { @@ -2249,7 +2244,7 @@ int MakeSingleBondsMetal2ChargedHeteroat( BN_STRUCT *pBNS, { break; /* nothing to do */ } - pFixedEdges = (EdgeIndex *) inchi_malloc( nNumEdgesToFix * sizeof( pFixedEdges[0] ) ); + pFixedEdges = (EdgeIndex*)inchi_malloc(nNumEdgesToFix * sizeof(pFixedEdges[0])); if (!pFixedEdges) { ret = RI_ERR_ALLOC; @@ -2265,20 +2260,20 @@ int MakeSingleBondsMetal2ChargedHeteroat( BN_STRUCT *pBNS, { neigh = at2[i].neighbor[j]; if (pVA[neigh].cNumValenceElectrons == 4 && - pVA[neigh].cPeriodicRowNumber == 1) + pVA[neigh].cPeriodicRowNumber == 1) { continue; /* ignore carbon */ } if (at2[i].bond_type[j] > BOND_TYPE_SINGLE && at2[neigh].charge && - !pVA[neigh].cMetal && pVA[neigh].cnListIndex > 0) + !pVA[neigh].cMetal && pVA[neigh].cnListIndex > 0) { - int cnBits = at2[neigh].charge > 0 ? MAKE_CN_BITS( cn_bits_N, cn_bits_P, 0, 0 ) : - MAKE_CN_BITS( cn_bits_N, cn_bits_M, 0, 0 ); + int cnBits = at2[neigh].charge > 0 ? MAKE_CN_BITS(cn_bits_N, cn_bits_P, 0, 0) : + MAKE_CN_BITS(cn_bits_N, cn_bits_M, 0, 0); int atBits = cnList[pVA[neigh].cnListIndex - 1].bits; for (k = 0; k < MAX_NUM_CN_BITS - 1; k++, atBits >>= cn_bits_shift) { /* ??? */ - if (( atBits & cnBits ) == cnBits) + if ((atBits & cnBits) == cnBits) { break; } @@ -2322,18 +2317,18 @@ int MakeSingleBondsMetal2ChargedHeteroat( BN_STRUCT *pBNS, pBNS->vert[v1].st_edge.flow--; pBNS->vert[v2].st_edge.flow--; pBNS->tot_st_flow -= 2; - ( *pnTotalDelta ) -= 2; + (*pnTotalDelta) -= 2; } /* Run BNS allowing to change any charges */ - ret = RunBnsRestoreOnce( pBNS, pBD, pVA, pTCGroups ); - ( *pnNumRunBNS )++; + ret = RunBnsRestoreOnce(pBNS, pBD, pVA, pTCGroups); + (*pnNumRunBNS)++; if (ret < 0) { goto exit_function; } else { - ( *pnTotalDelta ) += ret; + (*pnTotalDelta) += ret; } /* unfix the edges */ for (i = 0; i < nNumEdgesToFix; i++) @@ -2344,21 +2339,21 @@ int MakeSingleBondsMetal2ChargedHeteroat( BN_STRUCT *pBNS, if (ret < 2 * nNumEdgesToFix) { /* not all fixes succeeded */ - ret = RunBnsRestoreOnce( pBNS, pBD, pVA, pTCGroups ); - ( *pnNumRunBNS )++; + ret = RunBnsRestoreOnce(pBNS, pBD, pVA, pTCGroups); + (*pnNumRunBNS)++; if (ret < 0) { goto exit_function; } else { - ( *pnTotalDelta ) += ret; + (*pnTotalDelta) += ret; } } } if (pFixedEdges) { - inchi_free( pFixedEdges ); + inchi_free(pFixedEdges); pFixedEdges = NULL; } @@ -2374,16 +2369,16 @@ int MakeSingleBondsMetal2ChargedHeteroat( BN_STRUCT *pBNS, /* for example, M-O-C= -> M(+)-O(-)-C= */ /* Defect: instead of NH2-C=O(+)-M it will restore NH2(+)=C-O(-)-M(+) */ /* However, in this release metal-organic compounds do not get much care */ -int SaltBondsToCoordBonds( BN_STRUCT *pBNS, - BN_DATA *pBD, - StrFromINChI *pStruct, - inp_ATOM *at, - inp_ATOM *at2, - VAL_AT *pVA, - ALL_TC_GROUPS *pTCGroups, - int *pnNumRunBNS, - int *pnTotalDelta, - int forbidden_edge_mask ) +int SaltBondsToCoordBonds(BN_STRUCT* pBNS, + BN_DATA* pBD, + StrFromINChI* pStruct, + inp_ATOM* at, + inp_ATOM* at2, + VAL_AT* pVA, + ALL_TC_GROUPS* pTCGroups, + int* pnNumRunBNS, + int* pnTotalDelta, + int forbidden_edge_mask) { int i; @@ -2396,8 +2391,8 @@ int SaltBondsToCoordBonds( BN_STRUCT *pBNS, EDGE_LIST AllChargeEdges; int j, k, n; - BNS_EDGE *pe, *pePlusMetal, *peMinusO; - BNS_VERTEX *pv1, *pv2, *pvO, *pvM; + BNS_EDGE* pe, * pePlusMetal, * peMinusO; + BNS_VERTEX* pv1, * pv2, * pvO, * pvM; Vertex v1, v2, vPlusMinus; EdgeIndex ie, iePlusMetal, ieMinusO; @@ -2407,7 +2402,7 @@ int SaltBondsToCoordBonds( BN_STRUCT *pBNS, ret = 0; cur_success = 0; - AllocEdgeList( &AllChargeEdges, EDGE_LIST_CLEAR ); + AllocEdgeList(&AllChargeEdges, EDGE_LIST_CLEAR); if (pStruct->iInchiRec == INCHI_BAS || !pStruct->pSrm->bMetalAddFlower || pStruct->pSrm->nMetalMinBondOrder) { @@ -2417,7 +2412,7 @@ int SaltBondsToCoordBonds( BN_STRUCT *pBNS, /* to simplify, prepare new at[] from pBNS */ memcpy(at2, at, len_at * sizeof(at2[0])); pStruct->at = at2; - ret2 = CopyBnsToAtom( pStruct, pBNS, pVA, pTCGroups, 1 ); + ret2 = CopyBnsToAtom(pStruct, pBNS, pVA, pTCGroups, 1); pStruct->at = at; if (ret2 < 0) { @@ -2426,7 +2421,7 @@ int SaltBondsToCoordBonds( BN_STRUCT *pBNS, } for (i = 0; i < num_at; i++) { - if (bIsMetalSalt( at2, i )) + if (bIsMetalSalt(at2, i)) { if (!AllChargeEdges.num_edges) { @@ -2438,19 +2433,19 @@ int SaltBondsToCoordBonds( BN_STRUCT *pBNS, { n = at2[j].neighbor[k]; if (n < j && !pBNS->edge[ie = pBNS->vert[j].iedge[k]].forbidden && - ( ret = AddToEdgeList( &AllChargeEdges, ie, num_edges ) )) + (ret = AddToEdgeList(&AllChargeEdges, ie, num_edges))) { goto exit_function; } } /* charge edges */ - if (( ie = pVA[j].nCMinusGroupEdge - 1 ) >= 0 && !pBNS->edge[ie].forbidden && - ( ret = AddToEdgeList( &AllChargeEdges, ie, num_edges ) )) + if ((ie = pVA[j].nCMinusGroupEdge - 1) >= 0 && !pBNS->edge[ie].forbidden && + (ret = AddToEdgeList(&AllChargeEdges, ie, num_edges))) { goto exit_function; } - if (( ie = pVA[j].nCPlusGroupEdge - 1 ) >= 0 && !pBNS->edge[ie].forbidden && - ( ret = AddToEdgeList( &AllChargeEdges, ie, num_edges ) )) + if ((ie = pVA[j].nCPlusGroupEdge - 1) >= 0 && !pBNS->edge[ie].forbidden && + (ret = AddToEdgeList(&AllChargeEdges, ie, num_edges))) { goto exit_function; } @@ -2458,13 +2453,13 @@ int SaltBondsToCoordBonds( BN_STRUCT *pBNS, /* taut group edges */ for (j = 0; j < pTCGroups->num_tgroups; j++) { - pv1 = pBNS->vert + ( v1 = pTCGroups->pTCG[j].nVertexNumber ); /* t-group vertex */ /* djb-rwth: ignoring LLVM warning: see comment below */ + pv1 = pBNS->vert + (v1 = pTCGroups->pTCG[j].nVertexNumber); /* t-group vertex */ /* djb-rwth: ignoring LLVM warning: see comment below */ for (k = 0; k < pv1->num_adj_edges; k++) { /* ie, pe - tautomeric atom edge; pv2 - endpoint vertex */ /* Note: pe, pv2, v1 are not used here; they are to show how to traverse t-group */ - pv2 = pBNS->vert + ( pe = pBNS->edge + ( ie = pv1->iedge[k] ) )->neighbor1; /* djb-rwth: ignoring LLVM warning: see comment above */ - if ((ret = AddToEdgeList( &AllChargeEdges, ie, num_edges ))) /* djb-rwth: addressing LLVM warning */ + pv2 = pBNS->vert + (pe = pBNS->edge + (ie = pv1->iedge[k]))->neighbor1; /* djb-rwth: ignoring LLVM warning: see comment above */ + if ((ret = AddToEdgeList(&AllChargeEdges, ie, num_edges))) /* djb-rwth: addressing LLVM warning */ { goto exit_function; } @@ -2506,29 +2501,29 @@ int SaltBondsToCoordBonds( BN_STRUCT *pBNS, /* decrement bond order to 0 */ delta = 1; - pv1 = pBNS->vert + ( v1 = pe->neighbor1 ); - pv2 = pBNS->vert + ( v2 = pe->neighbor12 ^ v1 ); + pv1 = pBNS->vert + (v1 = pe->neighbor1); + pv2 = pBNS->vert + (v2 = pe->neighbor12 ^ v1); pe->flow -= delta; pv1->st_edge.flow -= delta; pv2->st_edge.flow -= delta; pBNS->tot_st_flow -= 2 * delta; - SetForbiddenEdgeMask( pBNS, &AllChargeEdges, forbidden_edge_mask ); + SetForbiddenEdgeMask(pBNS, &AllChargeEdges, forbidden_edge_mask); pePlusMetal->forbidden &= inv_forbidden_edge_mask; peMinusO->forbidden &= inv_forbidden_edge_mask; - ret = RunBnsTestOnce( pBNS, pBD, pVA, &vPathStart, &vPathEnd, &nPathLen, - &nDeltaH, &nDeltaCharge, &nNumVisitedAtoms ); + ret = RunBnsTestOnce(pBNS, pBD, pVA, &vPathStart, &vPathEnd, &nPathLen, + &nDeltaH, &nDeltaCharge, &nNumVisitedAtoms); - if (ret == 1 && ( (vPathEnd == v1 && vPathStart == v2) || - (vPathEnd == v2 && vPathStart == v1) ) /*&& nDeltaCharge > 0*/) /* djb-rwth: addressing LLVM warnings */ + if (ret == 1 && ((vPathEnd == v1 && vPathStart == v2) || + (vPathEnd == v2 && vPathStart == v1)) /*&& nDeltaCharge > 0*/) /* djb-rwth: addressing LLVM warnings */ { /* (+)charge was just moved, no change in number of charges */ - ret = RunBnsRestoreOnce( pBNS, pBD, pVA, pTCGroups ); + ret = RunBnsRestoreOnce(pBNS, pBD, pVA, pTCGroups); if (ret > 0) { - ( *pnNumRunBNS )++; + (*pnNumRunBNS)++; cur_success++; /* 01 */ } } @@ -2539,11 +2534,11 @@ int SaltBondsToCoordBonds( BN_STRUCT *pBNS, pv2->st_edge.flow += delta; pBNS->tot_st_flow += 2 * delta; } - RemoveForbiddenEdgeMask( pBNS, &AllChargeEdges, forbidden_edge_mask ); + RemoveForbiddenEdgeMask(pBNS, &AllChargeEdges, forbidden_edge_mask); } else { - if (NO_VERTEX != ( vPlusMinus = GetPlusMinusVertex( pBNS, pTCGroups, 1, 1 ) )) + if (NO_VERTEX != (vPlusMinus = GetPlusMinusVertex(pBNS, pTCGroups, 1, 1))) { /* manually add (-) charge to O and (+) charge to metal */ /* decrement bond order to 0 */ @@ -2591,22 +2586,22 @@ int SaltBondsToCoordBonds( BN_STRUCT *pBNS, pBNS->edge[pBNS->vert[j1].iedge[k1]].cap += delta; } } - SetForbiddenEdgeMask( pBNS, &AllChargeEdges, forbidden_edge_mask ); + SetForbiddenEdgeMask(pBNS, &AllChargeEdges, forbidden_edge_mask); pePlusMetal->forbidden &= inv_forbidden_edge_mask; pe->forbidden &= inv_forbidden_edge_mask; - ret = RunBnsTestOnce( pBNS, pBD, pVA, &vPathStart, &vPathEnd, &nPathLen, - &nDeltaH, &nDeltaCharge, &nNumVisitedAtoms ); + ret = RunBnsTestOnce(pBNS, pBD, pVA, &vPathStart, &vPathEnd, &nPathLen, + &nDeltaH, &nDeltaCharge, &nNumVisitedAtoms); cur_success = 0; - if (ret == 1 && ( (vPathEnd == v1 && vPathStart == v2) || - (vPathEnd == v2 && vPathStart == v1) ) /*&& nDeltaCharge == 1*/) /* djb-rwth: addressing LLVM warnings */ + if (ret == 1 && ((vPathEnd == v1 && vPathStart == v2) || + (vPathEnd == v2 && vPathStart == v1)) /*&& nDeltaCharge == 1*/) /* djb-rwth: addressing LLVM warnings */ { /* Added (+)charge to -N< => nDeltaCharge == 1 */ /* Flow change on pe (-)charge edge (atom B-O(-)) is not known to RunBnsTestOnce()) */ - ret = RunBnsRestoreOnce( pBNS, pBD, pVA, pTCGroups ); + ret = RunBnsRestoreOnce(pBNS, pBD, pVA, pTCGroups); if (ret > 0) { - ( *pnNumRunBNS )++; + (*pnNumRunBNS)++; cur_success++; /* 01 */ } } @@ -2648,7 +2643,7 @@ int SaltBondsToCoordBonds( BN_STRUCT *pBNS, } } } - RemoveForbiddenEdgeMask( pBNS, &AllChargeEdges, forbidden_edge_mask ); + RemoveForbiddenEdgeMask(pBNS, &AllChargeEdges, forbidden_edge_mask); } } } @@ -2657,7 +2652,7 @@ int SaltBondsToCoordBonds( BN_STRUCT *pBNS, exit_function: - AllocEdgeList( &AllChargeEdges, EDGE_LIST_FREE ); + AllocEdgeList(&AllChargeEdges, EDGE_LIST_FREE); return ret; } @@ -2667,18 +2662,18 @@ int SaltBondsToCoordBonds( BN_STRUCT *pBNS, /****************************************************************************/ -int ForbidMetalCarbonEdges( BN_STRUCT *pBNS, - inp_ATOM *at, - int num_at, - VAL_AT *pVA, - ALL_TC_GROUPS *pTCGroups, - EDGE_LIST *pMetalCarbonEdges, - int forbidden_edge_mask ) +int ForbidMetalCarbonEdges(BN_STRUCT* pBNS, + inp_ATOM* at, + int num_at, + VAL_AT* pVA, + ALL_TC_GROUPS* pTCGroups, + EDGE_LIST* pMetalCarbonEdges, + int forbidden_edge_mask) { int i, j, neigh, nNumEdgeMetalCarbon = 0, pass = 0, ret = 0; - BNS_VERTEX *pVert, *pNeigh; - BNS_EDGE *pEdge; + BNS_VERTEX* pVert, * pNeigh; + BNS_EDGE* pEdge; /* count carbon-metal edges */ @@ -2695,16 +2690,16 @@ int ForbidMetalCarbonEdges( BN_STRUCT *pBNS, pEdge = pBNS->edge + pVert->iedge[j]; neigh = pEdge->neighbor12 ^ i; pNeigh = pBNS->vert + neigh; - if (!IS_BNS_VT_ATOM( pNeigh->type )) + if (!IS_BNS_VT_ATOM(pNeigh->type)) continue; if (at[neigh].endpoint) continue; if (pVA[neigh].cNumValenceElectrons == 4 && pVA[neigh].cPeriodicRowNumber == 1 && - pNeigh->st_edge.cap >= at[neigh].valence + 1) + pNeigh->st_edge.cap >= at[neigh].valence + 1) { if (pass) { - if (ret = AddToEdgeList( pMetalCarbonEdges, pVert->iedge[j], 0 )) + if (ret = AddToEdgeList(pMetalCarbonEdges, pVert->iedge[j], 0)) { goto exit_function; } @@ -2720,7 +2715,7 @@ int ForbidMetalCarbonEdges( BN_STRUCT *pBNS, } if (!pass && nNumEdgeMetalCarbon) { - if (ret = AllocEdgeList( pMetalCarbonEdges, nNumEdgeMetalCarbon )) + if (ret = AllocEdgeList(pMetalCarbonEdges, nNumEdgeMetalCarbon)) { goto exit_function; } @@ -2739,29 +2734,29 @@ int ForbidMetalCarbonEdges( BN_STRUCT *pBNS, /**************************************************************************** - Restore bonds & charges + Restore bonds & charges *****************************************************************************/ -int RunBnsRestore1( CANON_GLOBALS *pCG, - INCHI_CLOCK *ic, - ICHICONST INPUT_PARMS *ip, - STRUCT_DATA *sd, - BN_STRUCT *pBNS, - BN_DATA *pBD, - StrFromINChI *pStruct, - VAL_AT *pVA, - ALL_TC_GROUPS *pTCGroups, - INChI *pInChI[], - long num_inp, - int bHasSomeFixedH ) +int RunBnsRestore1(CANON_GLOBALS* pCG, + INCHI_CLOCK* ic, + ICHICONST INPUT_PARMS* ip, + STRUCT_DATA* sd, + BN_STRUCT* pBNS, + BN_DATA* pBD, + StrFromINChI* pStruct, + VAL_AT* pVA, + ALL_TC_GROUPS* pTCGroups, + INChI* pInChI[], + long num_inp, + int bHasSomeFixedH) { int nNumRunBNS = 0; EDGE_LIST CarbonChargeEdges, MetalCarbonEdges, Nplus2BondsEdges; int nTotalDelta = 0, ret = 0; /* djb-rwth: removing redundant variables */ - inp_ATOM *at = pStruct->at; - inp_ATOM *at2 = NULL; /* restored structure */ - inp_ATOM *at3 = NULL; /* structure for calculating one InChI */ + inp_ATOM* at = pStruct->at; + inp_ATOM* at2 = NULL; /* restored structure */ + inp_ATOM* at3 = NULL; /* structure for calculating one InChI */ int num_at = pStruct->num_atoms; int num_deleted_H = pStruct->num_deleted_H; #ifdef _DEBUG @@ -2769,43 +2764,43 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, #endif #if ( KEEP_METAL_EDGE_FLOW == 1 ) - BNS_VERTEX *pVert, *pNeigh; + BNS_VERTEX* pVert, * pNeigh; int j, neigh; #endif /* Edge lists initialization */ - AllocEdgeList( &CarbonChargeEdges, EDGE_LIST_CLEAR ); - AllocEdgeList( &MetalCarbonEdges, EDGE_LIST_CLEAR ); - AllocEdgeList( &Nplus2BondsEdges, EDGE_LIST_CLEAR ); + AllocEdgeList(&CarbonChargeEdges, EDGE_LIST_CLEAR); + AllocEdgeList(&MetalCarbonEdges, EDGE_LIST_CLEAR); + AllocEdgeList(&Nplus2BondsEdges, EDGE_LIST_CLEAR); if (pStruct->iMobileH == TAUT_NON && - ( ret = FillOutExtraFixedHDataInChI( pStruct, pInChI ) )) + (ret = FillOutExtraFixedHDataInChI(pStruct, pInChI))) { goto exit_function; } - if ((!at2 && !( at2 = (inp_ATOM *) inchi_malloc( ( (long long)num_at + (long long)num_deleted_H ) * sizeof( at2[0] ) ) )) || - (!at3 && !( at3 = (inp_ATOM *) inchi_malloc( ( (long long)num_at + (long long)num_deleted_H ) * sizeof( at3[0] ) ) ))) /* djb-rwth: cast operators added; addressing LLVM warning */ + if ((!at2 && !(at2 = (inp_ATOM*)inchi_malloc(((long long)num_at + (long long)num_deleted_H) * sizeof(at2[0])))) || + (!at3 && !(at3 = (inp_ATOM*)inchi_malloc(((long long)num_at + (long long)num_deleted_H) * sizeof(at3[0]))))) /* djb-rwth: cast operators added; addressing LLVM warning */ { inchi_free(at2); inchi_free(at3); return RI_ERR_ALLOC; } - if (0 > ( ret = ForbidCarbonChargeEdges( pBNS, pTCGroups, &CarbonChargeEdges, BNS_EDGE_FORBIDDEN_TEMP ) )) + if (0 > (ret = ForbidCarbonChargeEdges(pBNS, pTCGroups, &CarbonChargeEdges, BNS_EDGE_FORBIDDEN_TEMP))) { goto exit_function; } #if ( KEEP_METAL_EDGE_FLOW == 1 ) /* count edges of -C(IV)< carbons connected to metals */ - if (0 > ( ret = ForbidMetalCarbonEdges( pBNS, at, num_at, pVA, pTCGroups, &MetalCarbonEdges, BNS_EDGE_FORBIDDEN_TEMP ) )) + if (0 > (ret = ForbidMetalCarbonEdges(pBNS, at, num_at, pVA, pTCGroups, &MetalCarbonEdges, BNS_EDGE_FORBIDDEN_TEMP))) { goto exit_function; } #endif - if (0 > ( ret = ForbidNintrogenPlus2BondsInSmallRings( pBNS, at, num_at, pVA, 6, - pTCGroups, &Nplus2BondsEdges, BNS_EDGE_FORBIDDEN_TEMP ) )) + if (0 > (ret = ForbidNintrogenPlus2BondsInSmallRings(pBNS, at, num_at, pVA, 6, + pTCGroups, &Nplus2BondsEdges, BNS_EDGE_FORBIDDEN_TEMP))) { goto exit_function; } @@ -2814,7 +2809,7 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, if (Nplus2BondsEdges.num_edges) { /* Run BNS leaving carbon charges unchanged */ - ret = RunBnsRestoreOnce( pBNS, pBD, pVA, pTCGroups ); + ret = RunBnsRestoreOnce(pBNS, pBD, pVA, pTCGroups); nNumRunBNS++; if (ret < 0) { @@ -2824,26 +2819,26 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, { nTotalDelta += ret; } - RemoveForbiddenEdgeMask( pBNS, &Nplus2BondsEdges, BNS_EDGE_FORBIDDEN_TEMP ); - AllocEdgeList( &Nplus2BondsEdges, EDGE_LIST_FREE ); + RemoveForbiddenEdgeMask(pBNS, &Nplus2BondsEdges, BNS_EDGE_FORBIDDEN_TEMP); + AllocEdgeList(&Nplus2BondsEdges, EDGE_LIST_FREE); } #ifdef _DEBUG /* debug only */ - memcpy( at2, at, ( (long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H ) * sizeof( at2[0] ) ); /* djb-rwth: cast operators added */ + memcpy(at2, at, ((long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H) * sizeof(at2[0])); /* djb-rwth: cast operators added */ pStruct->at = at2; - ret2 = CopyBnsToAtom( pStruct, pBNS, pVA, pTCGroups, 1 ); + ret2 = CopyBnsToAtom(pStruct, pBNS, pVA, pTCGroups, 1); pStruct->at = at; #endif /*************************** extend min ring size to 8 ****************************/ - if (0 > ( ret = ForbidNintrogenPlus2BondsInSmallRings( pBNS, at, num_at, pVA, 8, - pTCGroups, &Nplus2BondsEdges, BNS_EDGE_FORBIDDEN_TEMP ) )) + if (0 > (ret = ForbidNintrogenPlus2BondsInSmallRings(pBNS, at, num_at, pVA, 8, + pTCGroups, &Nplus2BondsEdges, BNS_EDGE_FORBIDDEN_TEMP))) { goto exit_function; } if (Nplus2BondsEdges.num_edges) { /* Run BNS leaving carbon charges unchanged */ - ret = RunBnsRestoreOnce( pBNS, pBD, pVA, pTCGroups ); + ret = RunBnsRestoreOnce(pBNS, pBD, pVA, pTCGroups); nNumRunBNS++; if (ret < 0) { @@ -2853,21 +2848,21 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, { nTotalDelta += ret; } - RemoveForbiddenEdgeMask( pBNS, &Nplus2BondsEdges, BNS_EDGE_FORBIDDEN_TEMP ); - AllocEdgeList( &Nplus2BondsEdges, EDGE_LIST_FREE ); + RemoveForbiddenEdgeMask(pBNS, &Nplus2BondsEdges, BNS_EDGE_FORBIDDEN_TEMP); + AllocEdgeList(&Nplus2BondsEdges, EDGE_LIST_FREE); } #ifdef _DEBUG /* debug only */ - memcpy( at2, at, ( (long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H ) * sizeof( at2[0] ) ); /* djb-rwth: cast operators added */ + memcpy(at2, at, ((long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H) * sizeof(at2[0])); /* djb-rwth: cast operators added */ pStruct->at = at2; - ret2 = CopyBnsToAtom( pStruct, pBNS, pVA, pTCGroups, 1 ); + ret2 = CopyBnsToAtom(pStruct, pBNS, pVA, pTCGroups, 1); pStruct->at = at; #endif /*******************************************************************/ if (CarbonChargeEdges.num_edges > 0) { /* Run BNS leaving carbon charges unchanged */ - ret = RunBnsRestoreOnce( pBNS, pBD, pVA, pTCGroups ); + ret = RunBnsRestoreOnce(pBNS, pBD, pVA, pTCGroups); nNumRunBNS++; if (ret < 0) { @@ -2877,21 +2872,21 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, { nTotalDelta += ret; } - RemoveForbiddenEdgeMask( pBNS, &CarbonChargeEdges, BNS_EDGE_FORBIDDEN_TEMP ); - AllocEdgeList( &CarbonChargeEdges, EDGE_LIST_FREE ); + RemoveForbiddenEdgeMask(pBNS, &CarbonChargeEdges, BNS_EDGE_FORBIDDEN_TEMP); + AllocEdgeList(&CarbonChargeEdges, EDGE_LIST_FREE); } #ifdef _DEBUG /* debug only */ - memcpy( at2, at, ( (long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H ) * sizeof( at2[0] ) ); /* djb-rwth: cast operators added */ + memcpy(at2, at, ((long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H) * sizeof(at2[0])); /* djb-rwth: cast operators added */ pStruct->at = at2; - ret2 = CopyBnsToAtom( pStruct, pBNS, pVA, pTCGroups, 1 ); + ret2 = CopyBnsToAtom(pStruct, pBNS, pVA, pTCGroups, 1); pStruct->at = at; #endif /*******************************************************************/ if (MetalCarbonEdges.num_edges > 0) { /* Run BNS leaving carbon charges unchanged */ - ret = RunBnsRestoreOnce( pBNS, pBD, pVA, pTCGroups ); + ret = RunBnsRestoreOnce(pBNS, pBD, pVA, pTCGroups); nNumRunBNS++; if (ret < 0) { @@ -2901,12 +2896,12 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, { nTotalDelta += ret; } - RemoveForbiddenEdgeMask( pBNS, &MetalCarbonEdges, BNS_EDGE_FORBIDDEN_TEMP ); - AllocEdgeList( &MetalCarbonEdges, EDGE_LIST_FREE ); + RemoveForbiddenEdgeMask(pBNS, &MetalCarbonEdges, BNS_EDGE_FORBIDDEN_TEMP); + AllocEdgeList(&MetalCarbonEdges, EDGE_LIST_FREE); } /*******************************************************************/ /* Run BNS allowing to change any charges */ - ret = RunBnsRestoreOnce( pBNS, pBD, pVA, pTCGroups ); + ret = RunBnsRestoreOnce(pBNS, pBD, pVA, pTCGroups); nNumRunBNS++; if (ret < 0) { @@ -2918,9 +2913,9 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, } #ifdef _DEBUG /* debug only */ - memcpy( at2, at, ( (long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H ) * sizeof( at2[0] ) ); /* djb-rwth: cast operators added */ + memcpy(at2, at, ((long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H) * sizeof(at2[0])); /* djb-rwth: cast operators added */ pStruct->at = at2; - ret2 = CopyBnsToAtom( pStruct, pBNS, pVA, pTCGroups, 1 ); + ret2 = CopyBnsToAtom(pStruct, pBNS, pVA, pTCGroups, 1); pStruct->at = at; #endif @@ -2928,7 +2923,7 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /****************************************************************************/ /* move unfulfilled 'radicals' from ChargeStruct to atoms */ /* and set change charges of affected atoms to fit total charge */ - ret = MoveRadToAtomsAddCharges( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, BNS_EDGE_FORBIDDEN_TEMP ); + ret = MoveRadToAtomsAddCharges(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; @@ -2941,14 +2936,14 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /**************************************************************/ #ifdef _DEBUG /* debug only */ - memcpy( at2, at, ( (long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H ) * sizeof( at2[0] ) ); /* djb-rwth: cast operators added */ + memcpy(at2, at, ((long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H) * sizeof(at2[0])); /* djb-rwth: cast operators added */ pStruct->at = at2; - ret2 = CopyBnsToAtom( pStruct, pBNS, pVA, pTCGroups, 1 ); + ret2 = CopyBnsToAtom(pStruct, pBNS, pVA, pTCGroups, 1); pStruct->at = at; #endif /* rearrange (+) and (-) edges flow so that there is no (+)flow=0 and (-)flow=1 */ - ret = RearrangePlusMinusEdgesFlow( pBNS, pBD, pVA, pTCGroups, BNS_EDGE_FORBIDDEN_TEMP ); + ret = RearrangePlusMinusEdgesFlow(pBNS, pBD, pVA, pTCGroups, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; @@ -2957,8 +2952,8 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /*****************************************************************/ /* Increment zero order metal bonds to heteroatoms */ /*****************************************************************/ - ret = IncrementZeroOrderBondsToHeteroat( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = IncrementZeroOrderBondsToHeteroat(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; @@ -2966,9 +2961,9 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, #ifdef _DEBUG /* debug only */ - memcpy( at2, at, ( (long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H ) * sizeof( at2[0] ) ); /* djb-rwth: cast operators added */ + memcpy(at2, at, ((long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H) * sizeof(at2[0])); /* djb-rwth: cast operators added */ pStruct->at = at2; - ret2 = CopyBnsToAtom( pStruct, pBNS, pVA, pTCGroups, 1 ); + ret2 = CopyBnsToAtom(pStruct, pBNS, pVA, pTCGroups, 1); pStruct->at = at; #endif @@ -2976,8 +2971,8 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /*****************************************************************/ /* move charges from heteroatoms to metal atoms */ /*****************************************************************/ - ret = MoveChargeFromHeteroatomsToMetals( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = MoveChargeFromHeteroatomsToMetals(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; @@ -2990,8 +2985,8 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, / / NH2 NH2 ************************************************************************/ - ret = MovePlusFromS2DiaminoCarbon( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = MovePlusFromS2DiaminoCarbon(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; @@ -2999,8 +2994,8 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /*****************************************************************/ /* Avoid charge separation on heteroatoms */ /*****************************************************************/ - ret = EliminateChargeSeparationOnHeteroatoms( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP, 0 ); + ret = EliminateChargeSeparationOnHeteroatoms(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP, 0); if (ret < 0) { goto exit_function; @@ -3008,9 +3003,9 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, if (ret) { /*charge separation remains; allow changes of stereobonds in a ring and try again */ - ret = EliminateChargeSeparationOnHeteroatoms( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP, - BNS_EDGE_FORBIDDEN_MASK ); + ret = EliminateChargeSeparationOnHeteroatoms(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP, + BNS_EDGE_FORBIDDEN_MASK); if (ret < 0) { goto exit_function; @@ -3019,8 +3014,8 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /*****************************************************************/ /* convert N#N(+)-N= into N(-)=N(+)=N- */ /*****************************************************************/ - ret = RestoreNNNgroup( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = RestoreNNNgroup(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; @@ -3028,8 +3023,8 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /*****************************************************************/ /* convert Metal(q)-N(-)-O(-) Metal(q-2)-N=O (local change) */ /*****************************************************************/ - ret = FixMetal_Nminus_Ominus( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = FixMetal_Nminus_Ominus(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; @@ -3037,8 +3032,8 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /*****************************************************************/ /* convert N(-)=C= into N#C- - */ /*****************************************************************/ - ret = RestoreCyanoGroup( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = RestoreCyanoGroup(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; @@ -3046,8 +3041,8 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /*****************************************************************/ /* convert C(+)#N(+)- into C(-)#N(+)- */ /*****************************************************************/ - ret = RestoreIsoCyanoGroup( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = RestoreIsoCyanoGroup(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; @@ -3056,8 +3051,8 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /* eliminate =N(V)= if possible */ /* | */ /*****************************************************************/ - ret = EliminateNitrogen5Val3Bonds( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = EliminateNitrogen5Val3Bonds(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; @@ -3068,8 +3063,8 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /* convert -S- to =S= if possible */ /* | | */ /*****************************************************************/ - ret = Convert_SIV_to_SVI( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = Convert_SIV_to_SVI(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; @@ -3080,8 +3075,8 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /* convert => if possible */ /* Metal(q) Metal(q+2) */ /*****************************************************************/ - ret = PlusFromDB_N_DB_O_to_Metal( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = PlusFromDB_N_DB_O_to_Metal(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; @@ -3093,8 +3088,8 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /* because an edge may not become forbidden */ /* note: removes this 'forbidden_edge' bit from ALL edges */ /*****************************************************************/ - ret = MoveMobileHToAvoidFixedBonds( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = MoveMobileHToAvoidFixedBonds(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { @@ -3105,13 +3100,13 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /* djb-rwth: removing redundant code */ if (pStruct->iMobileH == TAUT_NON) { - ret = RemoveRadFromMobileHEndpointFixH( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = RemoveRadFromMobileHEndpointFixH(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); } else { - ret = RemoveRadFromMobileHEndpoint( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = RemoveRadFromMobileHEndpoint(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); } if (ret < 0) { @@ -3120,16 +3115,16 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /* djb-rwth: removing redundant code */ /**************************************************************/ /* make bonds between a charged heteroatom and a metal single */ - ret = MakeSingleBondsMetal2ChargedHeteroat( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = MakeSingleBondsMetal2ChargedHeteroat(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; } /**************************************************************/ /* move (+) charges to >N- and other centerpoints */ - ret = MoveChargeToMakeCenerpoints( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = MoveChargeToMakeCenerpoints(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; @@ -3137,8 +3132,8 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /**************************************************************************/ /* Find and eliminate false Mobile-H groups: Cl(=O)3(-O(-)) => Cl(-)(=O)4 */ - ret = MoveChargeToRemoveCenerpoints( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = MoveChargeToRemoveCenerpoints(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; @@ -3146,8 +3141,8 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /**************************************************************************/ /* Find A=X< where all bonds to X except A=X are marked as stereogenic */ /* make bonds A=X single */ - ret = CheckAndRefixStereobonds( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = CheckAndRefixStereobonds(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; @@ -3157,16 +3152,16 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /* for example, M-O-C= -> M(+)-O(-)-C= */ /* Defect: instead of NH2-C=O(+)-M it will restore NH2(+)=C-O(-)-M(+) */ /* However, in this release metal-organic compounds do not get much care */ - ret = SaltBondsToCoordBonds( pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP ); + ret = SaltBondsToCoordBonds(pBNS, pBD, pStruct, at, at2, pVA, pTCGroups, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP); if (ret < 0) { goto exit_function; } /**************************************************************************/ /* Normalize the structure and compare t-groups and stereobonds */ - ret = NormalizeAndCompare( pCG, ic, ip, sd, pBNS, pBD, pStruct, at, at2, at3, pVA, pTCGroups, pInChI, num_inp, bHasSomeFixedH, - &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP, BNS_EDGE_FORBIDDEN_MASK ); + ret = NormalizeAndCompare(pCG, ic, ip, sd, pBNS, pBD, pStruct, at, at2, at3, pVA, pTCGroups, pInChI, num_inp, bHasSomeFixedH, + &nNumRunBNS, &nTotalDelta, BNS_EDGE_FORBIDDEN_TEMP, BNS_EDGE_FORBIDDEN_MASK); if (ret < 0) { goto exit_function; @@ -3182,16 +3177,16 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, pStruct->at = at; pStruct->at2 = at2; at2 = NULL; - AllocEdgeList( &CarbonChargeEdges, EDGE_LIST_FREE ); - AllocEdgeList( &MetalCarbonEdges, EDGE_LIST_FREE ); - AllocEdgeList( &Nplus2BondsEdges, EDGE_LIST_FREE ); + AllocEdgeList(&CarbonChargeEdges, EDGE_LIST_FREE); + AllocEdgeList(&MetalCarbonEdges, EDGE_LIST_FREE); + AllocEdgeList(&Nplus2BondsEdges, EDGE_LIST_FREE); if (at2) { - inchi_free( at2 ); + inchi_free(at2); } if (at3) { - inchi_free( at3 ); + inchi_free(at3); } return ret; @@ -3199,38 +3194,37 @@ int RunBnsRestore1( CANON_GLOBALS *pCG, /****************************************************************************/ -int RestoreAtomMakeBNS( INCHI_CLOCK *ic, CANON_GLOBALS *pCG, - ICHICONST INPUT_PARMS *ip, - STRUCT_DATA *sd, - StrFromINChI *pStruct, - int iComponent, - int iAtNoOffset, - INChI *pInChI[], - const char *szCurHdr, - long num_inp, - int bHasSomeFixedH ) +int RestoreAtomMakeBNS(INCHI_CLOCK* ic, CANON_GLOBALS* pCG, + ICHICONST INPUT_PARMS* ip, + STRUCT_DATA* sd, + StrFromINChI* pStruct, + int iComponent, + int iAtNoOffset, + INChI* pInChI[], + const char* szCurHdr, + long num_inp, + int bHasSomeFixedH) { int i, j, ret = 0, ret2; /*int nDelta, nTotalDelta;*/ - VAL_AT *pVA = NULL; + VAL_AT* pVA = NULL; VAL_AT va1; int num_at = pStruct->num_atoms; - inp_ATOM *at = pStruct->at; + inp_ATOM* at = pStruct->at; ALL_TC_GROUPS TCGroups; - ALL_TC_GROUPS *pTCGroups = &TCGroups; + ALL_TC_GROUPS* pTCGroups = &TCGroups; int nAddEdges2eachAtom = 2, nAddVertices = 0; - /* T_GROUP_INFO* tgi_tmp_oti = &(pStruct->One_ti); djb-rwth: required for fixing oss-fuzz issue #69602 */ BFS_Q bfsq; /* BNS creation */ - BN_STRUCT *pBNS = NULL; - BN_DATA *pBD = NULL; + BN_STRUCT* pBNS = NULL; + BN_DATA* pBD = NULL; int nNum_changed_bonds = 0; int bTreatMoreAtomsAsMetals = 0, bSecondPassNewMetals = 0; int nMaxAddAtoms = 2, nMaxAddEdges = 2, max_altp = BN_MAX_ALTP; - memset( pTCGroups, 0, sizeof( pTCGroups[0] ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(pTCGroups, 0, sizeof(pTCGroups[0])); /* djb-rwth: memset_s C11/Annex K variant? */ for (i = 0; i < NUM_TCGROUP_TYPES; i++) { pTCGroups->nGroup[i] = TCG_None; /* unassigned */ @@ -3241,8 +3235,8 @@ int RestoreAtomMakeBNS( INCHI_CLOCK *ic, CANON_GLOBALS *pCG, if (num_at == 1) { /* single atom -- no bonds to restore */ - inp_ATOM *at2 = (inp_ATOM *) inchi_malloc( sizeof( at2[0] )*( (long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H ) ); /* djb-rwth: cast operators added */ - inp_ATOM *at3 = (inp_ATOM *) inchi_malloc( sizeof( at3[0] )*( (long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H ) ); /* djb-rwth: cast operators added */ + inp_ATOM* at2 = (inp_ATOM*)inchi_malloc(sizeof(at2[0]) * ((long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H)); /* djb-rwth: cast operators added */ + inp_ATOM* at3 = (inp_ATOM*)inchi_malloc(sizeof(at3[0]) * ((long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H)); /* djb-rwth: cast operators added */ pStruct->at2 = at2; at[0].charge = pInChI[0]->nTotalCharge; if (at2) @@ -3251,46 +3245,46 @@ int RestoreAtomMakeBNS( INCHI_CLOCK *ic, CANON_GLOBALS *pCG, } if (!at2 || !at3) { - if (at3) inchi_free( at3 ); + if (at3) inchi_free(at3); return RI_ERR_ALLOC; } - ret = MakeOneInChIOutOfStrFromINChI( pCG, ic, ip, sd, pStruct, pStruct->at2, at3, pTCGroups ); + ret = MakeOneInChIOutOfStrFromINChI(pCG, ic, ip, sd, pStruct, pStruct->at2, at3, pTCGroups); /* clean up */ for (i = 0; i < TAUT_NUM; i++) { - Free_INChI( &pStruct->pOneINChI[i] ); - Free_INChI_Aux( &pStruct->pOneINChI_Aux[i] ); - FreeInpAtomData( pStruct->pOne_norm_data[i] ); + Free_INChI(&pStruct->pOneINChI[i]); + Free_INChI_Aux(&pStruct->pOneINChI_Aux[i]); + FreeInpAtomData(pStruct->pOne_norm_data[i]); if (pStruct->pOne_norm_data[i]) { - inchi_free( pStruct->pOne_norm_data[i] ); + inchi_free(pStruct->pOne_norm_data[i]); pStruct->pOne_norm_data[i] = NULL; } } /* djb-rwth: fixing oss-fuzz issue #69602 */ /* free_t_group_info(&pStruct->One_ti); */ - inchi_free( at3 ); + inchi_free(at3); return ret; } - AllocBfsQueue( &bfsq, BFS_Q_CLEAR, 0 ); - if (!( pVA = (VAL_AT *) inchi_calloc( num_at, sizeof( pVA[0] ) ) )) + AllocBfsQueue(&bfsq, BFS_Q_CLEAR, 0); + if (!(pVA = (VAL_AT*)inchi_calloc(num_at, sizeof(pVA[0])))) { ret = RI_ERR_ALLOC; goto exit_function; } pStruct->pVA = pVA; - memset( &va1, 0, sizeof( va1 ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(&va1, 0, sizeof(va1)); /* djb-rwth: memset_s C11/Annex K variant? */ pTCGroups->total_charge = pInChI[0]->nTotalCharge; - if (0 > ( ret = AllocBfsQueue( &bfsq, num_at, 0 /* min ring size undefined */ ) )) + if (0 > (ret = AllocBfsQueue(&bfsq, num_at, 0 /* min ring size undefined */))) { goto exit_function; } pStruct->pbfsq = &bfsq; if (pStruct->iMobileH == TAUT_NON && pInChI[1] && pInChI[1]->nNumberOfAtoms > 1 && - ( ret = FillOutpStructEndpointFromInChI( pInChI[1], &pStruct->endpoint ) )) + (ret = FillOutpStructEndpointFromInChI(pInChI[1], &pStruct->endpoint))) { goto exit_function; } @@ -3298,17 +3292,17 @@ int RestoreAtomMakeBNS( INCHI_CLOCK *ic, CANON_GLOBALS *pCG, /* mark metal atoms; find min ring sizes for atoms that have 2 bonds */ for (i = 0; i < num_at; i++) { - pVA[i].cNumValenceElectrons = get_sp_element_type( at[i].el_number, &j ); + pVA[i].cNumValenceElectrons = get_sp_element_type(at[i].el_number, &j); pVA[i].cPeriodicRowNumber = j; pVA[i].cPeriodicNumber = at[i].el_number; pVA[i].cNumValenceElectrons--; /* = -1 d- and f- metals, 0 for H, 1 for Na, 2 for Mg,.. = (ATYPE_Xx-1) */ - if (is_el_a_metal( at[i].el_number )) + if (is_el_a_metal(at[i].el_number)) { if (pStruct->pSrm->bStereoRemovesMetalFlag) { /* treat metal as non-metal if it is stereogenic or has a stereobond */ - pVA[i].cMetal = !( at[i].p_parity || at[i].sb_parity[0] ); + pVA[i].cMetal = !(at[i].p_parity || at[i].sb_parity[0]); } else { @@ -3317,8 +3311,8 @@ int RestoreAtomMakeBNS( INCHI_CLOCK *ic, CANON_GLOBALS *pCG, } if (at[i].valence == 2 && !at[i].num_H) { - pVA[i].cMinRingSize = is_bond_in_Nmax_memb_ring( at, i, 0, bfsq.q, bfsq.nAtomLevel, - bfsq.cSource, 99 /* max ring size */ ); + pVA[i].cMinRingSize = is_bond_in_Nmax_memb_ring(at, i, 0, bfsq.q, bfsq.nAtomLevel, + bfsq.cSource, 99 /* max ring size */); } else { @@ -3334,7 +3328,7 @@ int RestoreAtomMakeBNS( INCHI_CLOCK *ic, CANON_GLOBALS *pCG, /* get additional fictitious atoms information */ pVA[i].cInitFreeValences = 0; - ret = GetAtomRestoreInfo( pCG, at, i, pVA, pStruct->pSrm, pStruct->bMobileH, pStruct->endpoint ); + ret = GetAtomRestoreInfo(pCG, at, i, pVA, pStruct->pSrm, pStruct->bMobileH, pStruct->endpoint); if (ret < 0) { @@ -3345,7 +3339,7 @@ int RestoreAtomMakeBNS( INCHI_CLOCK *ic, CANON_GLOBALS *pCG, if (pStruct->pSrm->bStereoRemovesMetalFlag) { /* treat metal as non-metal if it is stereogenic or has a stereobond */ - pVA[i].cMetal = !( at[i].p_parity || at[i].sb_parity[0] ); + pVA[i].cMetal = !(at[i].p_parity || at[i].sb_parity[0]); } else { @@ -3376,37 +3370,37 @@ int RestoreAtomMakeBNS( INCHI_CLOCK *ic, CANON_GLOBALS *pCG, } /* count atoms, bonds, additional edges and vertices in ChargeValence structures and t-groups */ - ret = nCountBnsSizes( at, num_at, nAddEdges2eachAtom, nAddVertices, &pStruct->ti, - pVA, pStruct->pSrm, pTCGroups ); + ret = nCountBnsSizes(at, num_at, nAddEdges2eachAtom, nAddVertices, &pStruct->ti, + pVA, pStruct->pSrm, pTCGroups); if (ret < 0) { goto exit_function; } /* find and count groups; add counts of all other vertices to be created */ - ret = nAddSuperCGroups( pTCGroups ); + ret = nAddSuperCGroups(pTCGroups); if (ret < 0) { goto exit_function; } /* create the BNS and fill it with all real atoms */ - pBNS = AllocateAndInitTCGBnStruct( pStruct, pVA, pTCGroups, - nMaxAddAtoms, nMaxAddEdges, max_altp, &nNum_changed_bonds ); + pBNS = AllocateAndInitTCGBnStruct(pStruct, pVA, pTCGroups, + nMaxAddAtoms, nMaxAddEdges, max_altp, &nNum_changed_bonds); if (!pBNS) { ret = BNS_OUT_OF_RAM; goto exit_function; } /* add t-groups to the BNS */ - ret = AddTGroups2TCGBnStruct( pBNS, pStruct, pVA, pTCGroups, nMaxAddEdges ); + ret = AddTGroups2TCGBnStruct(pBNS, pStruct, pVA, pTCGroups, nMaxAddEdges); if (ret < 0) { goto exit_function; } /* add c-groups to the BNS; adjust charges */ - ret = AddCGroups2TCGBnStruct( pBNS, pStruct, pVA, pTCGroups, nMaxAddEdges ); + ret = AddCGroups2TCGBnStruct(pBNS, pStruct, pVA, pTCGroups, nMaxAddEdges); if (ret < 0) { goto exit_function; @@ -3416,44 +3410,44 @@ int RestoreAtomMakeBNS( INCHI_CLOCK *ic, CANON_GLOBALS *pCG, pBNS->ic = ic; /* v. 1.05 */ /* allocate BNData */ - pBD = AllocateAndInitBnData( pBNS->max_vertices + pBNS->max_vertices / 2 ); + pBD = AllocateAndInitBnData(pBNS->max_vertices + pBNS->max_vertices / 2); if (!pBD) { ret = BNS_OUT_OF_RAM; goto exit_function; } - CheckBnsConsistency( pStruct, pBNS, pVA, pTCGroups, 0 ); + CheckBnsConsistency(pStruct, pBNS, pVA, pTCGroups, 0); /* restore bonds & charges */ - ret = RunBnsRestore1( pCG, ic, ip, sd, pBNS, pBD, pStruct, pVA, pTCGroups, pInChI, num_inp, bHasSomeFixedH ); + ret = RunBnsRestore1(pCG, ic, ip, sd, pBNS, pBD, pStruct, pVA, pTCGroups, pInChI, num_inp, bHasSomeFixedH); if (ret < 0) { goto exit_function; } - ret = CheckBnsConsistency( pStruct, pBNS, pVA, pTCGroups, 1 ); + ret = CheckBnsConsistency(pStruct, pBNS, pVA, pTCGroups, 1); #if ( bRELEASE_VERSION == 0 ) #ifndef TARGET_API_LIB if (ret) { - fprintf( stdout, "Msg for: %ld %s comp=%d %c%c\n", num_inp, ( szCurHdr && szCurHdr[0] ) ? szCurHdr : "", iComponent, pStruct->iInchiRec ? 'R' : 'D', pStruct->iMobileH ? 'M' : 'F' ); + fprintf(stdout, "Msg for: %ld %s comp=%d %c%c\n", num_inp, (szCurHdr && szCurHdr[0]) ? szCurHdr : "", iComponent, pStruct->iInchiRec ? 'R' : 'D', pStruct->iMobileH ? 'M' : 'F'); } if (pStruct->iMobileH == TAUT_YES && pStruct->nNumRemovedProtons) { - fprintf( stdout, "REMOVED_PROTONS%+d %ld %s\n", pStruct->nNumRemovedProtons, num_inp, ( szCurHdr && szCurHdr[0] ) ? szCurHdr : "" ); + fprintf(stdout, "REMOVED_PROTONS%+d %ld %s\n", pStruct->nNumRemovedProtons, num_inp, (szCurHdr && szCurHdr[0]) ? szCurHdr : ""); /*pStruct->bExtract |= EXTRACT_STRUCT_NUMBER;*/ } if (pStruct->bExtract & EXTRACT_STRUCT_NUMBER) { - fprintf( stdout, "EXTRACT: %ld: %s\n", num_inp, ( szCurHdr && szCurHdr[0] ) ? szCurHdr : "" ); + fprintf(stdout, "EXTRACT: %ld: %s\n", num_inp, (szCurHdr && szCurHdr[0]) ? szCurHdr : ""); } #endif #endif { /* create the final structure in pStruct->at2 */ - inp_ATOM *at_tmp = pStruct->at; + inp_ATOM* at_tmp = pStruct->at; pStruct->at = pStruct->at2; - memcpy(pStruct->at, at_tmp, sizeof(pStruct->at[0])* ((long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H)); /* djb-rwth: cast operators added */ - ret2 = CopyBnsToAtom( pStruct, pBNS, pVA, pTCGroups, 1 ); + memcpy(pStruct->at, at_tmp, sizeof(pStruct->at[0]) * ((long long)pStruct->num_atoms + (long long)pStruct->num_deleted_H)); /* djb-rwth: cast operators added */ + ret2 = CopyBnsToAtom(pStruct, pBNS, pVA, pTCGroups, 1); pStruct->at2 = pStruct->at; pStruct->at = at_tmp; if (ret2 < 0) @@ -3465,66 +3459,66 @@ int RestoreAtomMakeBNS( INCHI_CLOCK *ic, CANON_GLOBALS *pCG, exit_function: pStruct->pbfsq = NULL; - AllocBfsQueue( &bfsq, BFS_Q_FREE, 0 ); + AllocBfsQueue(&bfsq, BFS_Q_FREE, 0); - pBD = DeAllocateBnData( pBD ); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ - pBNS = DeAllocateBnStruct( pBNS ); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + pBD = DeAllocateBnData(pBD); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + pBNS = DeAllocateBnStruct(pBNS); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ /* if ( pVA ) inchi_free( pVA ); */ - if (pTCGroups->pTCG) inchi_free( pTCGroups->pTCG ); + if (pTCGroups->pTCG) inchi_free(pTCGroups->pTCG); return ret; } /****************************************************************************/ -int OneInChI2Atom( INCHI_CLOCK *ic, - CANON_GLOBALS *pCG, - ICHICONST INPUT_PARMS *ip_inp, - STRUCT_DATA *sd, - const char *szCurHdr, - long num_inp, - StrFromINChI *pStruct, - int iComponent, - int iAtNoOffset, - int bHasSomeFixedH, - INChI *pInChI[] ) +int OneInChI2Atom(INCHI_CLOCK* ic, + CANON_GLOBALS* pCG, + ICHICONST INPUT_PARMS* ip_inp, + STRUCT_DATA* sd, + const char* szCurHdr, + long num_inp, + StrFromINChI* pStruct, + int iComponent, + int iAtNoOffset, + int bHasSomeFixedH, + INChI* pInChI[]) { int ret; - INPUT_PARMS *ip, ip_loc; + INPUT_PARMS* ip, ip_loc; ip_loc = *ip_inp; ip = &ip_loc; sd->pStrErrStruct[0] = '\0'; - ret = RestoreAtomConnectionsSetStereo( pStruct, iComponent, iAtNoOffset, pInChI[0], pInChI[1] ); + ret = RestoreAtomConnectionsSetStereo(pStruct, iComponent, iAtNoOffset, pInChI[0], pInChI[1]); if (ret < 0) { goto exit_function; } - ret = SetStereoBondTypesFrom0DStereo( pStruct, pInChI[0] ); + ret = SetStereoBondTypesFrom0DStereo(pStruct, pInChI[0]); if (ret < 0) { goto exit_function; } - ret = ReconcileAllCmlBondParities( pStruct->at, pStruct->num_atoms, 0 ); + ret = ReconcileAllCmlBondParities(pStruct->at, pStruct->num_atoms, 0); if (ret < 0) { goto exit_function; } /* main InChI restore function */ - ret = RestoreAtomMakeBNS( ic, pCG, ip, sd, pStruct, iComponent, iAtNoOffset, pInChI, szCurHdr, num_inp, bHasSomeFixedH ); + ret = RestoreAtomMakeBNS(ic, pCG, ip, sd, pStruct, iComponent, iAtNoOffset, pInChI, szCurHdr, num_inp, bHasSomeFixedH); #ifndef COMPILE_ANSI_ONLY - if (( pStruct->num_inp_actual > 0 ? pStruct->num_inp_actual : num_inp ) >= ip->first_struct_number && - ( (/*ret > 0 &&*/ ip->bDisplayIfRestoreWarnings ) && pStruct->pXYZ )) + if ((pStruct->num_inp_actual > 0 ? pStruct->num_inp_actual : num_inp) >= ip->first_struct_number && + ((/*ret > 0 &&*/ ip->bDisplayIfRestoreWarnings) && pStruct->pXYZ)) { inchiTime ulTStart; - InchiTimeGet( &ulTStart ); - DisplayRestoredComponent( pCG, pStruct, iComponent, iAtNoOffset, pInChI[0], szCurHdr ); - sd->ulStructTime -= InchiTimeElapsed( ic, &ulTStart ); /* subtract display time */ + InchiTimeGet(&ulTStart); + DisplayRestoredComponent(pCG, pStruct, iComponent, iAtNoOffset, pInChI[0], szCurHdr); + sd->ulStructTime -= InchiTimeElapsed(ic, &ulTStart); /* subtract display time */ } #endif @@ -3532,27 +3526,27 @@ int OneInChI2Atom( INCHI_CLOCK *ic, { goto exit_function; } - if (( pStruct->num_inp_actual ? pStruct->num_inp_actual : num_inp ) >= ip->first_struct_number && ret >= 0) + if ((pStruct->num_inp_actual ? pStruct->num_inp_actual : num_inp) >= ip->first_struct_number && ret >= 0) { /* remove t-group markings and increment zero-order bonds, otherwise MakeInChIOutOfStrFromINChI2() woild fail */ - /* --- moved to MakeInChIOutOfStrFromINChI2 --- - IncrZeroBondsAndClearEndpts(pStruct->at2, pStruct->num_atoms, iComponent+1); - CopySt2At( pStruct->at2, pStruct->st, pStruct->num_atoms ); - */ - /* include all restored structure features in pStruct->at2 */ - /* make full InChI out of pStruct->at2, pStruct->num_atoms */ - /***************************************************************************************/ - /* !!! pStruct->One_InChI etc. were removed at the exit from NormalizeAndCompare() !!! */ - /***************************************************************************************/ + /* --- moved to MakeInChIOutOfStrFromINChI2 --- + IncrZeroBondsAndClearEndpts(pStruct->at2, pStruct->num_atoms, iComponent+1); + CopySt2At( pStruct->at2, pStruct->st, pStruct->num_atoms ); + */ + /* include all restored structure features in pStruct->at2 */ + /* make full InChI out of pStruct->at2, pStruct->num_atoms */ + /***************************************************************************************/ + /* !!! pStruct->One_InChI etc. were removed at the exit from NormalizeAndCompare() !!! */ + /***************************************************************************************/ if (bHasSomeFixedH && pStruct->iInchiRec == INCHI_REC && pStruct->iMobileH == TAUT_YES && - !pStruct->bFixedHExists && !( ip->nMode & REQ_MODE_BASIC )) + !pStruct->bFixedHExists && !(ip->nMode & REQ_MODE_BASIC)) { /* reconnected components without Fixed-H layer may produce 'tautomeric' fragments like Cl(-) */ ip->nMode |= REQ_MODE_BASIC; } - ret = MakeInChIOutOfStrFromINChI2( ic, pCG, ip, sd, pStruct, iComponent, iAtNoOffset, num_inp ); + ret = MakeInChIOutOfStrFromINChI2(ic, pCG, ip, sd, pStruct, iComponent, iAtNoOffset, num_inp); if (ret >= 0) { @@ -3562,8 +3556,8 @@ int OneInChI2Atom( INCHI_CLOCK *ic, #ifndef TARGET_API_LIB else { - fprintf( stdout, "\nERROR in MakeInChI-1: %ld %s Comp:%d %c%c Err:%d\n", num_inp, - szCurHdr ? szCurHdr : "???", iComponent, pStruct->iInchiRec ? 'R' : 'D', pStruct->iMobileH ? 'M' : 'F', ret ); + fprintf(stdout, "\nERROR in MakeInChI-1: %ld %s Comp:%d %c%c Err:%d\n", num_inp, + szCurHdr ? szCurHdr : "???", iComponent, pStruct->iInchiRec ? 'R' : 'D', pStruct->iMobileH ? 'M' : 'F', ret); } #endif #endif @@ -3576,9 +3570,9 @@ int OneInChI2Atom( INCHI_CLOCK *ic, /****************************************************************************/ -int MakeProtonComponent( StrFromINChI *pStruct, int iComponent, int num_prot ) +int MakeProtonComponent(StrFromINChI* pStruct, int iComponent, int num_prot) { - inp_ATOM *at = NULL; + inp_ATOM* at = NULL; int i; if (num_prot <= 0) @@ -3586,8 +3580,8 @@ int MakeProtonComponent( StrFromINChI *pStruct, int iComponent, int num_prot ) return 0; } /* allocate */ - pStruct->at = (inp_ATOM *) inchi_calloc( num_prot, sizeof( pStruct->at[0] ) ); - pStruct->at2 = (inp_ATOM *) inchi_calloc( num_prot, sizeof( pStruct->at2[0] ) ); + pStruct->at = (inp_ATOM*)inchi_calloc(num_prot, sizeof(pStruct->at[0])); + pStruct->at2 = (inp_ATOM*)inchi_calloc(num_prot, sizeof(pStruct->at2[0])); if (!pStruct->at || !pStruct->at2) { return 0; @@ -3597,7 +3591,7 @@ int MakeProtonComponent( StrFromINChI *pStruct, int iComponent, int num_prot ) /* fill out proton atom info */ for (i = 0; i < num_prot; i++) { - strcpy( at[i].elname, "H" ); + strcpy(at[i].elname, "H"); at[i].el_number = EL_NUMBER_H; at[i].orig_at_number = i + 1; /* @@ -3617,26 +3611,26 @@ int MakeProtonComponent( StrFromINChI *pStruct, int iComponent, int num_prot ) /****************************************************************************/ -int AddRemProtonsInRestrStruct( INCHI_CLOCK *ic, - CANON_GLOBALS *pCG, - ICHICONST INPUT_PARMS *ip_inp, - STRUCT_DATA *sd, long num_inp, - int bHasSomeFixedH, - StrFromINChI *pStruct, - int num_components, - StrFromINChI *pStructR, - int num_componentsR, - NUM_H *nProtonsToBeRemovedByNormFromRevrs, - int *recmet_change_balance ) +int AddRemProtonsInRestrStruct(INCHI_CLOCK* ic, + CANON_GLOBALS* pCG, + ICHICONST INPUT_PARMS* ip_inp, + STRUCT_DATA* sd, long num_inp, + int bHasSomeFixedH, + StrFromINChI* pStruct, + int num_components, + StrFromINChI* pStructR, + int num_componentsR, + NUM_H* nProtonsToBeRemovedByNormFromRevrs, + int* recmet_change_balance) { /* on entry and exit, all at[i].num_H do not include isotopic H and explicit terminal H are connected */ int iComp, q, ret = 0; - int num_atoms, num_deleted_H = 0, num_tg, num_changed, num_deleted_components; /* djb-rwth: removing redundant variables */ - inp_ATOM *at; - INPUT_PARMS *ip, ip_loc; + int num_atoms, num_deleted_H, num_tg, num_changed, num_deleted_components; /* djb-rwth: removing redundant variables */ + inp_ATOM* at; + INPUT_PARMS* ip, ip_loc; int num_prot = *nProtonsToBeRemovedByNormFromRevrs; int delta_recmet_prot, num_prot_prev, bAccumulateChanges = 0, nNumProtAddedByRevrs; - INChI_Aux *pINChI_Aux; + INChI_Aux* pINChI_Aux; INCHI_MODE bNormalizationFlags; int nChargeRevrs, nChargeInChI; @@ -3672,8 +3666,8 @@ int AddRemProtonsInRestrStruct( INCHI_CLOCK *ic, if (pStruct[iComp].nLink < 0 && num_componentsR > 0) { /* check */ - q = -( pStruct[iComp].nLink + 1 ); - if (!pStructR || !num_componentsR || q >= num_componentsR || pStructR[q].nLink != ( iComp + 1 )) + q = -(pStruct[iComp].nLink + 1); + if (!pStructR || !num_componentsR || q >= num_componentsR || pStructR[q].nLink != (iComp + 1)) { ret = RI_ERR_PROGR; goto exit_function; @@ -3683,17 +3677,17 @@ int AddRemProtonsInRestrStruct( INCHI_CLOCK *ic, at = pStruct[iComp].at2; num_atoms = pStruct[iComp].num_atoms; - /* djb-rwth: removing redundant code */ - bAccumulateChanges = ( pStruct[iComp].nLink > 0 && !num_componentsR ); + num_deleted_H = pStruct[iComp].num_deleted_H; /* djb-rwth: removing redundant code */ + bAccumulateChanges = (pStruct[iComp].nLink > 0 && !num_componentsR); nChargeRevrs = pStruct[iComp].nChargeRevrs; nChargeInChI = pStruct[iComp].nChargeInChI; - num_deleted_components += ( 0 != pStruct[iComp].bDeleted ); + num_deleted_components += (0 != pStruct[iComp].bDeleted); if (!at || !num_atoms) { continue; } /* find whether it is a reconnected structure */ - q = bRevInchiComponentExists( pStruct + iComp, INCHI_REC, TAUT_YES, 0 ) ? INCHI_REC : INCHI_BAS; + q = bRevInchiComponentExists(pStruct + iComp, INCHI_REC, TAUT_YES, 0) ? INCHI_REC : INCHI_BAS; /* q = pStruct[iComp].RevInChI.pINChI_Aux[INCHI_REC] && pStruct[iComp].RevInChI.pINChI_Aux[INCHI_REC][0][TAUT_YES] && @@ -3707,16 +3701,16 @@ int AddRemProtonsInRestrStruct( INCHI_CLOCK *ic, /* disconnect all explicit H and add the number of implicit iso H and all explicit terminal H to the number of implicit H */ - if (0 > ( ret = DisconnectedConnectedH( at, num_atoms, num_deleted_H ) )) + if (0 > (ret = DisconnectedConnectedH(at, num_atoms, num_deleted_H))) { goto exit_function; } num_prot_prev = num_prot; - ret = AddRemoveProtonsRestr( at, num_atoms, &num_prot, nNumProtAddedByRevrs, - bNormalizationFlags, num_tg, nChargeRevrs, nChargeInChI ); + ret = AddRemoveProtonsRestr(at, num_atoms, &num_prot, nNumProtAddedByRevrs, + bNormalizationFlags, num_tg, nChargeRevrs, nChargeInChI); pStruct[iComp].bPostProcessed = ret; - num_changed += ( ret > 0 ); + num_changed += (ret > 0); if (ret < 0) { goto exit_function; @@ -3724,21 +3718,21 @@ int AddRemProtonsInRestrStruct( INCHI_CLOCK *ic, if (ret > 0) { /* recalculate InChI; it will reconnect at */ - StrFromINChI *pStruct1 = pStruct + iComp; + StrFromINChI* pStruct1 = pStruct + iComp; INCHI_MODE nMode = ip->nMode; - FreeAllINChIArrays( pStruct1->RevInChI.pINChI, - pStruct1->RevInChI.pINChI_Aux, - pStruct1->RevInChI.num_components ); + FreeAllINChIArrays(pStruct1->RevInChI.pINChI, + pStruct1->RevInChI.pINChI_Aux, + pStruct1->RevInChI.num_components); if (bHasSomeFixedH && pStruct1->iInchiRec == INCHI_REC && pStruct1->iMobileH == TAUT_YES && - !pStruct1->bFixedHExists && !( ip->nMode & REQ_MODE_BASIC )) + !pStruct1->bFixedHExists && !(ip->nMode & REQ_MODE_BASIC)) { /* reconnected components without Fixed-H layer may produce 'tautomeric' fragments like Cl(-) */ ip->nMode |= REQ_MODE_BASIC; } /* calls ConnectDisconnectedH(...): subtracts number of implicit iso H from implicit H */ - ret = MakeInChIOutOfStrFromINChI2( ic, pCG, ip, sd, pStruct1, 0, 0, num_inp ); + ret = MakeInChIOutOfStrFromINChI2(ic, pCG, ip, sd, pStruct1, 0, 0, num_inp); ip->nMode = nMode; if (ret < 0) @@ -3748,8 +3742,8 @@ int AddRemProtonsInRestrStruct( INCHI_CLOCK *ic, } else { - /* reconnect disconnected terminal H and subtracts number of implicit iso H from implicit H */ - if (0 > ( ret = ConnectDisconnectedH( at, num_atoms, num_deleted_H ) )) + /* reconnect disconnected terminal H and subtracts number of implicit iso H from implicit H */ + if (0 > (ret = ConnectDisconnectedH(at, num_atoms, num_deleted_H))) { goto exit_function; } @@ -3766,23 +3760,23 @@ int AddRemProtonsInRestrStruct( INCHI_CLOCK *ic, { /* add bare protons to the deleted Mobile-H component; undelete the component */ num_prot_prev = num_prot; - if (!MakeProtonComponent( pStruct + iComp, iComp, num_prot )) + if (!MakeProtonComponent(pStruct + iComp, iComp, num_prot)) { goto exit_function; } else { - /* recalculate InChI; it will reconnect at */ - StrFromINChI *pStruct1 = pStruct + iComp; + /* recalculate InChI; it will reconnect at */ + StrFromINChI* pStruct1 = pStruct + iComp; INCHI_MODE nMode = ip->nMode; num_changed++; num_prot = 0; - FreeAllINChIArrays( pStruct1->RevInChI.pINChI, - pStruct1->RevInChI.pINChI_Aux, - pStruct1->RevInChI.num_components ); + FreeAllINChIArrays(pStruct1->RevInChI.pINChI, + pStruct1->RevInChI.pINChI_Aux, + pStruct1->RevInChI.num_components); if (bHasSomeFixedH && pStruct1->iInchiRec == INCHI_REC && pStruct1->iMobileH == TAUT_YES && - !pStruct1->bFixedHExists && !( ip->nMode & REQ_MODE_BASIC )) + !pStruct1->bFixedHExists && !(ip->nMode & REQ_MODE_BASIC)) { /* reconnected components without Fixed-H layer may produce 'tautomeric' fragments like Cl(-) */ ip->nMode |= REQ_MODE_BASIC; @@ -3791,7 +3785,7 @@ int AddRemProtonsInRestrStruct( INCHI_CLOCK *ic, /* to subtracts number of implicit iso H from implicit H */ /* this CANNOT have any effect on the deleted H component */ - ret = MakeInChIOutOfStrFromINChI2( ic, pCG, ip, sd, pStruct1, 0, 0, num_inp ); + ret = MakeInChIOutOfStrFromINChI2(ic, pCG, ip, sd, pStruct1, 0, 0, num_inp); ip->nMode = nMode; if (ret < 0) @@ -3818,28 +3812,28 @@ int AddRemProtonsInRestrStruct( INCHI_CLOCK *ic, /****************************************************************************/ -int AddRemIsoProtonsInRestrStruct( INCHI_CLOCK *ic, - CANON_GLOBALS *pCG, - ICHICONST INPUT_PARMS *ip_inp, - STRUCT_DATA *sd, - long num_inp, - int bHasSomeFixedH, - StrFromINChI *pStruct, - int num_components, - StrFromINChI *pStructR, - int num_componentsR, - NUM_H pProtonBalance[], - NUM_H recmet_change_balance[] ) +int AddRemIsoProtonsInRestrStruct(INCHI_CLOCK* ic, + CANON_GLOBALS* pCG, + ICHICONST INPUT_PARMS* ip_inp, + STRUCT_DATA* sd, + long num_inp, + int bHasSomeFixedH, + StrFromINChI* pStruct, + int num_components, + StrFromINChI* pStructR, + int num_componentsR, + NUM_H pProtonBalance[], + NUM_H recmet_change_balance[]) { /* on entry and exit, all at[i].num_H do not include isotopic H and explicit terminal H are connected */ int iComp, q, k, ret = 0, bNotEmpty; - int num_atoms, num_deleted_H = 0, num_tg, num_changed; /* djb-rwth: removing redundant variables; initialisation of num_deleted_H */ - inp_ATOM *at; + int num_atoms, num_deleted_H, num_tg, num_changed; /* djb-rwth: removing redundant variables */ + inp_ATOM* at; NUM_H num_prot[NUM_H_ISOTOPES], delta_recmet_prot[NUM_H_ISOTOPES], num_prot_prev[NUM_H_ISOTOPES]; int bAccumulateChanges; - INChI_Aux *pINChI_Aux; + INChI_Aux* pINChI_Aux; /* djb-rwth: removing redundant variables */ - INPUT_PARMS *ip, ip_loc; + INPUT_PARMS* ip, ip_loc; ip_loc = *ip_inp; ip = &ip_loc; @@ -3853,7 +3847,7 @@ int AddRemIsoProtonsInRestrStruct( INCHI_CLOCK *ic, { return 0; } - memset( delta_recmet_prot, 0, sizeof( delta_recmet_prot ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(delta_recmet_prot, 0, sizeof(delta_recmet_prot)); /* djb-rwth: memset_s C11/Annex K variant? */ num_changed = 0; /*---------------------------------------------------------------------------------- nLink < 0 && num_componentsR > 0 => This is a Disconnected structure component; it is @@ -3872,14 +3866,14 @@ int AddRemIsoProtonsInRestrStruct( INCHI_CLOCK *ic, Process and save charge delta. -----------------------------------------------------------------------------------*/ - for (iComp = 0; iComp < num_components; iComp++) /* djb-rwth: removing redundant code */ + for (iComp = 0; iComp < num_components && num_prot; iComp++) /* djb-rwth: the condition will always evaluate to true only if pProtonBalance is not NULL */ { /* djb-rwth: removing redundant code */ if (pStruct[iComp].nLink < 0 && num_componentsR > 0) { /* check */ - q = -( pStruct[iComp].nLink + 1 ); - if (!pStructR || !num_componentsR || q >= num_componentsR || pStructR[q].nLink != ( iComp + 1 )) + q = -(pStruct[iComp].nLink + 1); + if (!pStructR || !num_componentsR || q >= num_componentsR || pStructR[q].nLink != (iComp + 1)) { ret = RI_ERR_PROGR; goto exit_function; @@ -3889,8 +3883,8 @@ int AddRemIsoProtonsInRestrStruct( INCHI_CLOCK *ic, at = pStruct[iComp].at2; num_atoms = pStruct[iComp].num_atoms; - /* djb-rwth: removing redundant code */ - bAccumulateChanges = ( pStruct[iComp].nLink > 0 && !num_componentsR ); + num_deleted_H = pStruct[iComp].num_deleted_H; /* djb-rwth: removing redundant code */ + bAccumulateChanges = (pStruct[iComp].nLink > 0 && !num_componentsR); if (!at || !num_atoms) { @@ -3907,35 +3901,35 @@ int AddRemIsoProtonsInRestrStruct( INCHI_CLOCK *ic, memcpy(num_prot_prev, num_prot, sizeof(num_prot_prev)); /* pass CONNECTED explicit H to AddRemoveIsoProtonsRestr() for isotopic H addition */ - ret = AddRemoveIsoProtonsRestr( at, num_atoms, num_prot, num_tg ); + ret = AddRemoveIsoProtonsRestr(at, num_atoms, num_prot, num_tg); pStruct[iComp].bPostProcessed |= ret; - num_changed += ( ret > 0 ); + num_changed += (ret > 0); if (ret < 0) { goto exit_function; } if (ret > 0) { - StrFromINChI *pStruct1 = pStruct + iComp; + StrFromINChI* pStruct1 = pStruct + iComp; INCHI_MODE nMode = ip->nMode; /* recalculate InChI; MakeInChIOutOfStrFromINChI2() will reconnect explicit H */ /* disconnect all explicit H and add the number of implicit iso H and all explicit terminal H to the number of implicit H */ - if (0 > ( ret = DisconnectedConnectedH( at, num_atoms, num_deleted_H ) )) + if (0 > (ret = DisconnectedConnectedH(at, num_atoms, num_deleted_H))) { goto exit_function; } - FreeAllINChIArrays( pStruct1->RevInChI.pINChI, - pStruct1->RevInChI.pINChI_Aux, - pStruct1->RevInChI.num_components ); + FreeAllINChIArrays(pStruct1->RevInChI.pINChI, + pStruct1->RevInChI.pINChI_Aux, + pStruct1->RevInChI.num_components); if (bHasSomeFixedH && pStruct1->iInchiRec == INCHI_REC && pStruct1->iMobileH == TAUT_YES && - !pStruct1->bFixedHExists && !( ip->nMode & REQ_MODE_BASIC )) + !pStruct1->bFixedHExists && !(ip->nMode & REQ_MODE_BASIC)) { /* reconnected components without Fixed-H layer may produce 'tautomeric' fragments like Cl(-) */ ip->nMode |= REQ_MODE_BASIC; } /* input: disconnected explicit H, output: connected explicit H */ - ret = MakeInChIOutOfStrFromINChI2( ic, pCG, ip, sd, pStruct1, 0, 0, num_inp ); + ret = MakeInChIOutOfStrFromINChI2(ic, pCG, ip, sd, pStruct1, 0, 0, num_inp); ip->nMode = nMode; if (ret < 0) { diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichirvr7.c b/INCHI-1-SRC/INCHI_BASE/src/ichirvr7.c index 8f3c835b..9923def3 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichirvr7.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichirvr7.c @@ -62,7 +62,6 @@ #include "inchi_gui.h" #include "bcf_s.h" -int at_size_check1; /* djb-rwth: required for fixing oss-fuzz issue #68329 */ #if 0 #ifndef COMPILE_ANSI_ONLY @@ -76,22 +75,22 @@ int at_size_check1; /* djb-rwth: required for fixing oss-fuzz issue #68329 */ #ifdef TARGET_LIB_FOR_WINCHI /* dummies */ /****************************************************************************/ -int DisplayStructure( struct tagCANON_GLOBALS *pCG, - inp_ATOM *at, - int num_at, - OAD_Polymer *polymer, - int num_removed_H, - int bAdd_DT_to_num_H, - int nNumRemovedProtons, - NUM_H *nNumRemovedProtonsIsotopic, - int bIsotopic, - int j /*bTautomeric*/, - INChI **cur_INChI, - INChI_Aux **cur_INChI_Aux, - int bAbcNumbers, - DRAW_PARMS *dp, - INCHI_MODE nMode, - char *szTitle ) +int DisplayStructure(struct tagCANON_GLOBALS* pCG, + inp_ATOM* at, + int num_at, + OAD_Polymer* polymer, + int num_removed_H, + int bAdd_DT_to_num_H, + int nNumRemovedProtons, + NUM_H* nNumRemovedProtonsIsotopic, + int bIsotopic, + int j /*bTautomeric*/, + INChI** cur_INChI, + INChI_Aux** cur_INChI_Aux, + int bAbcNumbers, + DRAW_PARMS* dp, + INCHI_MODE nMode, + char* szTitle) { return 0; } @@ -99,29 +98,29 @@ int DisplayStructure( struct tagCANON_GLOBALS *pCG, /****************************************************************************/ -int InChI2Atom( INCHI_CLOCK *ic, - CANON_GLOBALS *pCG, - ICHICONST INPUT_PARMS *ip, - STRUCT_DATA *sd, - const char *szCurHdr, - long num_inp, - StrFromINChI *pStruct, - int iComponent, - int iAtNoOffset, - int bI2A_Flag, - int bHasSomeFixedH, - InpInChI *OneInput ) +int InChI2Atom(INCHI_CLOCK* ic, + CANON_GLOBALS* pCG, + ICHICONST INPUT_PARMS* ip, + STRUCT_DATA* sd, + const char* szCurHdr, + long num_inp, + StrFromINChI* pStruct, + int iComponent, + int iAtNoOffset, + int bI2A_Flag, + int bHasSomeFixedH, + InpInChI* OneInput) { int ret = 0; - int iINChI = ( bI2A_Flag & I2A_FLAG_RECMET ) ? INCHI_REC : INCHI_BAS; - int bMobileH = ( bI2A_Flag & I2A_FLAG_FIXEDH ) ? TAUT_NON : TAUT_YES; + int iINChI = (bI2A_Flag & I2A_FLAG_RECMET) ? INCHI_REC : INCHI_BAS; + int bMobileH = (bI2A_Flag & I2A_FLAG_FIXEDH) ? TAUT_NON : TAUT_YES; - INChI *pInChI[TAUT_NUM]; + INChI* pInChI[TAUT_NUM]; - memset( pInChI, 0, sizeof( pInChI ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(pInChI, 0, sizeof(pInChI)); /* djb-rwth: memset_s C11/Annex K variant? */ /* disconnected or reconnected */ @@ -171,20 +170,20 @@ int InChI2Atom( INCHI_CLOCK *ic, } if (bMobileH == TAUT_NON || - (bMobileH == TAUT_YES && - OneInput->pInpInChI[iINChI][TAUT_NON] && - OneInput->pInpInChI[iINChI][TAUT_NON][iComponent].nNumberOfAtoms > 0 && - !OneInput->pInpInChI[iINChI][TAUT_NON][iComponent].bDeleted) /* djb-rwth: addressing LLVM warning */ + (bMobileH == TAUT_YES && + OneInput->pInpInChI[iINChI][TAUT_NON] && + OneInput->pInpInChI[iINChI][TAUT_NON][iComponent].nNumberOfAtoms > 0 && + !OneInput->pInpInChI[iINChI][TAUT_NON][iComponent].bDeleted) /* djb-rwth: addressing LLVM warning */ ) { pStruct->bFixedHExists = 1; } if (bMobileH == TAUT_NON && - iComponent < OneInput->nNumComponents[iINChI][TAUT_YES] && - OneInput->pInpInChI[iINChI][TAUT_YES] && - OneInput->pInpInChI[iINChI][TAUT_YES][iComponent].nNumberOfAtoms > 0 && - !OneInput->pInpInChI[iINChI][TAUT_YES][iComponent].bDeleted + iComponent < OneInput->nNumComponents[iINChI][TAUT_YES] && + OneInput->pInpInChI[iINChI][TAUT_YES] && + OneInput->pInpInChI[iINChI][TAUT_YES][iComponent].nNumberOfAtoms > 0 && + !OneInput->pInpInChI[iINChI][TAUT_YES][iComponent].bDeleted ) { /* pointer to the Mobile-H InChI if we are reversing Fixed-H InChI */ @@ -194,10 +193,10 @@ int InChI2Atom( INCHI_CLOCK *ic, pStruct->num_inp_actual = OneInput->num_inp; /* Intercept and correct non-polymer Zz to Zy if applicable */ - if ( OneInput->polymer ) + if (OneInput->polymer) { int a, k, new_num; - OAD_Polymer *p = OneInput->polymer; + OAD_Polymer* p = OneInput->polymer; pStruct->n_pzz = 0; pStruct->n_zy = 0; for (a = 0; a < pInChI[0]->nNumberOfAtoms; a++) @@ -208,7 +207,7 @@ int InChI2Atom( INCHI_CLOCK *ic, new_num = EL_NUMBER_ZY; /* Zy */ for (k = 0; k < p->n; k++) { - if ( (aglob == p->units[k]->cap1) || (aglob == p->units[k]->cap2) ) + if ((aglob == p->units[k]->cap1) || (aglob == p->units[k]->cap2)) { new_num = EL_NUMBER_ZZ; break; @@ -216,8 +215,8 @@ int InChI2Atom( INCHI_CLOCK *ic, } pInChI[0]->nAtom[a] = new_num; if (new_num == EL_NUMBER_ZY) - { - pStruct->n_zy++; + { + pStruct->n_zy++; } else if (new_num == EL_NUMBER_ZZ) { @@ -227,8 +226,8 @@ int InChI2Atom( INCHI_CLOCK *ic, } } - ret = OneInChI2Atom( ic, pCG, ip, sd, szCurHdr, num_inp, pStruct, - iComponent, 0 /* iAtNoOffset*/, bHasSomeFixedH, pInChI ); + ret = OneInChI2Atom(ic, pCG, ip, sd, szCurHdr, num_inp, pStruct, + iComponent, 0 /* iAtNoOffset*/, bHasSomeFixedH, pInChI); /* djb-rwth: fixing oss-fuzz issue #66758, #30283 */ if (pStruct->at && pStruct->at2) @@ -253,23 +252,23 @@ int InChI2Atom( INCHI_CLOCK *ic, } - /****************************************************************************/ -void RemoveFixHInChIIdentical2MobH( InpInChI *pOneInput ) +/****************************************************************************/ +void RemoveFixHInChIIdentical2MobH(InpInChI* pOneInput) { int iInchiRec, cur_num_comp, k; /* eliminate Fixed-H InChI that are exactly same as the corresponding Mobile-H structures */ for (iInchiRec = 0; iInchiRec < INCHI_NUM; iInchiRec++) { - cur_num_comp = inchi_min( pOneInput->nNumComponents[iInchiRec][TAUT_YES], - pOneInput->nNumComponents[iInchiRec][TAUT_NON] ); + cur_num_comp = inchi_min(pOneInput->nNumComponents[iInchiRec][TAUT_YES], + pOneInput->nNumComponents[iInchiRec][TAUT_NON]); for (k = 0; k < cur_num_comp; k++) { - if (!CompareReversedINChI( pOneInput->pInpInChI[iInchiRec][TAUT_YES] + k, - pOneInput->pInpInChI[iInchiRec][TAUT_NON] + k, NULL, NULL )) + if (!CompareReversedINChI(pOneInput->pInpInChI[iInchiRec][TAUT_YES] + k, + pOneInput->pInpInChI[iInchiRec][TAUT_NON] + k, NULL, NULL)) { - Free_INChI_Members( pOneInput->pInpInChI[iInchiRec][TAUT_NON] + k ); - memset( pOneInput->pInpInChI[iInchiRec][TAUT_NON] + k, 0, sizeof( pOneInput->pInpInChI[0][0][0] ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + Free_INChI_Members(pOneInput->pInpInChI[iInchiRec][TAUT_NON] + k); + memset(pOneInput->pInpInChI[iInchiRec][TAUT_NON] + k, 0, sizeof(pOneInput->pInpInChI[0][0][0])); /* djb-rwth: memset_s C11/Annex K variant? */ } } } @@ -281,16 +280,16 @@ void RemoveFixHInChIIdentical2MobH( InpInChI *pOneInput ) Disconnected will have a negative number of the reconnected component Reconnected will have a positive number of the disconnected component ****************************************************************************/ -int MarkDisconectedIdenticalToReconnected( InpInChI *pOneInput ) +int MarkDisconectedIdenticalToReconnected(InpInChI* pOneInput) { int k1, k2, num_marked = 0; - int k1max = inchi_max( pOneInput->nNumComponents[INCHI_BAS][TAUT_YES], - pOneInput->nNumComponents[INCHI_BAS][TAUT_NON] ); + int k1max = inchi_max(pOneInput->nNumComponents[INCHI_BAS][TAUT_YES], + pOneInput->nNumComponents[INCHI_BAS][TAUT_NON]); for (k1 = 0; k1 < k1max; k1++) { - int k2max = inchi_max( pOneInput->nNumComponents[INCHI_REC][TAUT_YES], - pOneInput->nNumComponents[INCHI_REC][TAUT_NON] ); + int k2max = inchi_max(pOneInput->nNumComponents[INCHI_REC][TAUT_YES], + pOneInput->nNumComponents[INCHI_REC][TAUT_NON]); for (k2 = 0; k2 < k2max; k2++) { @@ -309,9 +308,9 @@ int MarkDisconectedIdenticalToReconnected( InpInChI *pOneInput ) && !pOneInput->pInpInChI[INCHI_REC][TAUT_YES][k2].bDeleted && - !CompareReversedINChI( pOneInput->pInpInChI[INCHI_REC][TAUT_YES] + k2, - pOneInput->pInpInChI[INCHI_BAS][TAUT_YES] + k1, - NULL, NULL ); + !CompareReversedINChI(pOneInput->pInpInChI[INCHI_REC][TAUT_YES] + k2, + pOneInput->pInpInChI[INCHI_BAS][TAUT_YES] + k1, + NULL, NULL); int isF1 = k1 < pOneInput->nNumComponents[INCHI_BAS][TAUT_NON] && @@ -336,19 +335,19 @@ int MarkDisconectedIdenticalToReconnected( InpInChI *pOneInput ) pOneInput->pInpInChI[INCHI_BAS][TAUT_NON][k1].nNumberOfAtoms == pOneInput->pInpInChI[INCHI_REC][TAUT_NON][k2].nNumberOfAtoms && - !CompareReversedINChI( pOneInput->pInpInChI[INCHI_REC][TAUT_NON] + k2, - pOneInput->pInpInChI[INCHI_BAS][TAUT_NON] + k1, - NULL, NULL ) + !CompareReversedINChI(pOneInput->pInpInChI[INCHI_REC][TAUT_NON] + k2, + pOneInput->pInpInChI[INCHI_BAS][TAUT_NON] + k1, + NULL, NULL) ; - if (eqM && ( (!isF1 && !isF2) || eqF )) /* djb-rwth: addressing LLVM warning */ + if (eqM && ((!isF1 && !isF2) || eqF)) /* djb-rwth: addressing LLVM warning */ { - pOneInput->pInpInChI[INCHI_BAS][TAUT_YES][k1].nLink = -( k2 + 1 ); - pOneInput->pInpInChI[INCHI_REC][TAUT_YES][k2].nLink = ( k1 + 1 ); + pOneInput->pInpInChI[INCHI_BAS][TAUT_YES][k1].nLink = -(k2 + 1); + pOneInput->pInpInChI[INCHI_REC][TAUT_YES][k2].nLink = (k1 + 1); if (eqF) { - pOneInput->pInpInChI[INCHI_BAS][TAUT_NON][k1].nLink = -( k2 + 1 ); - pOneInput->pInpInChI[INCHI_REC][TAUT_NON][k2].nLink = ( k1 + 1 ); + pOneInput->pInpInChI[INCHI_BAS][TAUT_NON][k1].nLink = -(k2 + 1); + pOneInput->pInpInChI[INCHI_REC][TAUT_NON][k2].nLink = (k1 + 1); } num_marked++; break; @@ -362,10 +361,10 @@ int MarkDisconectedIdenticalToReconnected( InpInChI *pOneInput ) /****************************************************************************/ -void SetUpSrm( SRM *pSrm ) +void SetUpSrm(SRM* pSrm) { /* structure restore parms !!!!! */ - memset( pSrm, 0, sizeof( pSrm[0] ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(pSrm, 0, sizeof(pSrm[0])); /* djb-rwth: memset_s C11/Annex K variant? */ pSrm->bFixStereoBonds = FIX_STEREO_BOND_ORDER; pSrm->nMetal2EndpointMinBondOrder = 1; pSrm->nMetal2EndpointInitEdgeFlow = 0; @@ -404,20 +403,20 @@ void SetUpSrm( SRM *pSrm ) /****************************************************************************/ -int MergeStructureComponents( ICHICONST INPUT_PARMS *ip, - STRUCT_DATA *sd, - long num_inp, - char *szCurHdr, - ICHICONST SRM *pSrm, - int bReqNonTaut, - StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], - InpInChI *pOneInput ) +int MergeStructureComponents(ICHICONST INPUT_PARMS* ip, + STRUCT_DATA* sd, + long num_inp, + char* szCurHdr, + ICHICONST SRM* pSrm, + int bReqNonTaut, + StrFromINChI* pStruct[INCHI_NUM][TAUT_NUM], + InpInChI* pOneInput) { int iInchiRec, iMobileH, iAlternH, num_components, tot_just_atoms, tot_atoms, cur_nA, cur_nH; /* djb-rwth: removing redundant variables */ int k, i, j, ret, iCurAtomOffs, iNxtAtomOffs, iCurDelHOffs, iNxtDelHOffs, len, len2, iShiftH, icomp; - int *nAtomOffs = NULL, *nDelHOffs = NULL; - StrFromINChI *pStruct1; - inp_ATOM *at = NULL, *a; + int* nAtomOffs = NULL, * nDelHOffs = NULL; + StrFromINChI* pStruct1; + inp_ATOM* at = NULL, * a; ret = 0; pOneInput->num_atoms = 0; @@ -456,8 +455,8 @@ int MergeStructureComponents( ICHICONST INPUT_PARMS *ip, } } - nAtomOffs = (int*) inchi_malloc( ( (long long)num_components + 1 ) * sizeof( nAtomOffs[0] ) ); /* djb-rwth: cast operator added */ - nDelHOffs = (int*) inchi_malloc( ( (long long)num_components + 1 ) * sizeof( nDelHOffs[0] ) ); /* djb-rwth: cast operator added */ + nAtomOffs = (int*)inchi_malloc(((long long)num_components + 1) * sizeof(nAtomOffs[0])); /* djb-rwth: cast operator added */ + nDelHOffs = (int*)inchi_malloc(((long long)num_components + 1) * sizeof(nDelHOffs[0])); /* djb-rwth: cast operator added */ if (!nAtomOffs || !nDelHOffs) { ret = RI_ERR_ALLOC; @@ -465,7 +464,7 @@ int MergeStructureComponents( ICHICONST INPUT_PARMS *ip, } /* count number of atoms and removed H */ /* djb-rwth: removing redundant code */ - iAlternH = ( iMobileH == TAUT_NON && pOneInput->nNumComponents[iInchiRec][TAUT_YES] ) ? TAUT_YES : -1; + iAlternH = (iMobileH == TAUT_NON && pOneInput->nNumComponents[iInchiRec][TAUT_YES]) ? TAUT_YES : -1; nAtomOffs[0] = nDelHOffs[0] = 0; for (k = 0; k < num_components; k++) { @@ -494,7 +493,6 @@ int MergeStructureComponents( ICHICONST INPUT_PARMS *ip, /* merge atoms together: 1. Allocate */ at = (inp_ATOM*)inchi_malloc(((long long)tot_atoms + 1) * sizeof(at[0])); /* djb-rwth: cast operator added */ - at_size_check1 = tot_atoms + 1; if (NULL == at) { ret = RI_ERR_ALLOC; @@ -606,9 +604,9 @@ int MergeStructureComponents( ICHICONST INPUT_PARMS *ip, at = NULL; exit_function: - if (at) inchi_free( at ); /* in case of failure */ - if (nAtomOffs) inchi_free( nAtomOffs ); - if (nDelHOffs) inchi_free( nDelHOffs ); + if (at) inchi_free(at); /* in case of failure */ + if (nAtomOffs) inchi_free(nAtomOffs); + if (nDelHOffs) inchi_free(nDelHOffs); return ret; } @@ -620,10 +618,10 @@ static PER_DRAW_PARMS pdp; /****************************************************************************/ -int DisplayAllRestoredComponents( struct tagCANON_GLOBALS *pCG, - inp_ATOM *at, - int num_at, - const char *szCurHdr ) +int DisplayAllRestoredComponents(struct tagCANON_GLOBALS* pCG, + inp_ATOM* at, + int num_at, + const char* szCurHdr) { int ret; /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ char szTitle[512]; @@ -633,46 +631,46 @@ int DisplayAllRestoredComponents( struct tagCANON_GLOBALS *pCG, { return 0; } - memset( &dp, 0, sizeof( dp ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( &tdp, 0, sizeof( tdp ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(&dp, 0, sizeof(dp)); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(&tdp, 0, sizeof(tdp)); /* djb-rwth: memset_s C11/Annex K variant? */ /*memset( &pdp, 0, sizeof(pdp) );*/ dp.sdp.tdp = &tdp; dp.pdp = &pdp; dp.sdp.nFontSize = -9; sprintf(szTitle, "All Components of Restored %s Structure", szCurHdr ? szCurHdr : "(No structure name)"); - ret = DisplayStructure( pCG, at, num_at, - NULL, /* OAD_Polymer *polymer, */ - 0 /* nNumDeletedH*/, 0 /*bAdd_DT_to_num_H*/, - 0 /*nNumRemovedProtons*/, NULL /*NUM_H *nNumRemovedProtonsIsotopic*/, - 1 /*int bIsotopic*/, 0 /*bTautomeric*/, - NULL /* pINChI */, NULL /* INChI_Aux **cur_INChI_Aux*/, - 0 /*bAbcNumbers*/, &dp, 0 /*INCHI_MODE nMode*/, szTitle ); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + ret = DisplayStructure(pCG, at, num_at, + NULL, /* OAD_Polymer *polymer, */ + 0 /* nNumDeletedH*/, 0 /*bAdd_DT_to_num_H*/, + 0 /*nNumRemovedProtons*/, NULL /*NUM_H *nNumRemovedProtonsIsotopic*/, + 1 /*int bIsotopic*/, 0 /*bTautomeric*/, + NULL /* pINChI */, NULL /* INChI_Aux **cur_INChI_Aux*/, + 0 /*bAbcNumbers*/, &dp, 0 /*INCHI_MODE nMode*/, szTitle); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ return 0; } /****************************************************************************/ -int DisplayOneRestoredComponent( struct tagCANON_GLOBALS *pCG, - StrFromINChI *pStruct, - inp_ATOM *at, - int iComponent, - int nNumComponents, - int bMobileH, - const char *szCurHdr ) +int DisplayOneRestoredComponent(struct tagCANON_GLOBALS* pCG, + StrFromINChI* pStruct, + inp_ATOM* at, + int iComponent, + int nNumComponents, + int bMobileH, + const char* szCurHdr) { int ret, k; /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ int num_at = pStruct->num_atoms; - XYZ_COORD *pxyz = pStruct->pXYZ; + XYZ_COORD* pxyz = pStruct->pXYZ; char szTitle[512]; DRAW_PARMS dp; TBL_DRAW_PARMS tdp; int iInchiRec = pStruct->iInchiRec; int iMobileH = pStruct->iMobileH; - INChI **pInChI = NULL; - INChI_Aux **pAux = NULL; + INChI** pInChI = NULL; + INChI_Aux** pAux = NULL; int nNumRemovedProtons = pAux ? pAux[iMobileH]->nNumRemovedProtons : 0; - NUM_H *nNumRemovedProtonsIsotopic = pAux ? pAux[iMobileH]->nNumRemovedIsotopicH : NULL; + NUM_H* nNumRemovedProtonsIsotopic = pAux ? pAux[iMobileH]->nNumRemovedIsotopicH : NULL; if (num_at <= 0 || !pxyz) @@ -684,16 +682,16 @@ int DisplayOneRestoredComponent( struct tagCANON_GLOBALS *pCG, iInchiRec = 0; } k = iMobileH; - if (!bRevInchiComponentExists( pStruct, iInchiRec, k, 0 )) + if (!bRevInchiComponentExists(pStruct, iInchiRec, k, 0)) { - k = ALT_TAUT( k ); + k = ALT_TAUT(k); } pInChI = pStruct->RevInChI.pINChI[iInchiRec][0]; pAux = pStruct->RevInChI.pINChI_Aux[iInchiRec][0]; - memset( &dp, 0, sizeof( dp ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( &tdp, 0, sizeof( tdp ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(&dp, 0, sizeof(dp)); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(&tdp, 0, sizeof(tdp)); /* djb-rwth: memset_s C11/Annex K variant? */ /*memset( &pdp, 0, sizeof(pdp) );*/ dp.sdp.tdp = &tdp; dp.pdp = &pdp; @@ -701,32 +699,32 @@ int DisplayOneRestoredComponent( struct tagCANON_GLOBALS *pCG, sprintf(szTitle, "Restored %s Component %d of %d %c%c", szCurHdr ? szCurHdr : "(No structure name)", iComponent + 1, nNumComponents, pStruct->iInchiRec ? 'R' : 'D', pStruct->iMobileH ? 'M' : 'F'); - ret = DisplayStructure( pCG, at, num_at, - NULL, /* OAD_Polymer *polymer, */ - 0 /* nNumDeletedH*/, 0 /*bAdd_DT_to_num_H*/, - nNumRemovedProtons, /*NULL*/ nNumRemovedProtonsIsotopic, - 1 /*int bIsotopic*/, k, - pInChI, pAux, - 0 /*bAbcNumbers*/, &dp, 0 /*INCHI_MODE nMode*/, szTitle ); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + ret = DisplayStructure(pCG, at, num_at, + NULL, /* OAD_Polymer *polymer, */ + 0 /* nNumDeletedH*/, 0 /*bAdd_DT_to_num_H*/, + nNumRemovedProtons, /*NULL*/ nNumRemovedProtonsIsotopic, + 1 /*int bIsotopic*/, k, + pInChI, pAux, + 0 /*bAbcNumbers*/, &dp, 0 /*INCHI_MODE nMode*/, szTitle); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ return 0; } /****************************************************************************/ -int DisplayRestoredComponent( struct tagCANON_GLOBALS *pCG, - StrFromINChI *pStruct, - int iComponent, - int iAtNoOffset, - INChI *pInChI, - const char *szCurHdr ) +int DisplayRestoredComponent(struct tagCANON_GLOBALS* pCG, + StrFromINChI* pStruct, + int iComponent, + int iAtNoOffset, + INChI* pInChI, + const char* szCurHdr) { int i, ret; /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ int num_at = pStruct->num_atoms; int num_deleted_H = pStruct->num_deleted_H; - inp_ATOM *atom = pStruct->at2; - XYZ_COORD *pxyz = pStruct->pXYZ; - inp_ATOM *at = NULL; + inp_ATOM* atom = pStruct->at2; + XYZ_COORD* pxyz = pStruct->pXYZ; + inp_ATOM* at = NULL; char szTitle[512]; DRAW_PARMS dp; TBL_DRAW_PARMS tdp; @@ -734,7 +732,7 @@ int DisplayRestoredComponent( struct tagCANON_GLOBALS *pCG, { return 0; } - at = (inp_ATOM *) inchi_calloc( (long long)num_at + (long long)num_deleted_H, sizeof( at[0] ) ); /* djb-rwth: cast operator added */ + at = (inp_ATOM*)inchi_calloc((long long)num_at + (long long)num_deleted_H, sizeof(at[0])); /* djb-rwth: cast operator added */ if (!at) { return RI_ERR_ALLOC; @@ -746,47 +744,47 @@ int DisplayRestoredComponent( struct tagCANON_GLOBALS *pCG, at[i].y = pxyz[i].xyz[1]; at[i].z = pxyz[i].xyz[2]; } - memset( &dp, 0, sizeof( dp ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( &tdp, 0, sizeof( tdp ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(&dp, 0, sizeof(dp)); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(&tdp, 0, sizeof(tdp)); /* djb-rwth: memset_s C11/Annex K variant? */ /*memset( &pdp, 0, sizeof(pdp) );*/ dp.sdp.tdp = &tdp; dp.pdp = &pdp; dp.sdp.nFontSize = -9; sprintf(szTitle, "DBG Restored %s Component %d %c%c", szCurHdr ? szCurHdr : "(No structure name)", iComponent + 1, pStruct->iInchiRec ? 'R' : 'D', pStruct->iMobileH ? 'M' : 'F'); - ret = DisplayStructure( pCG, at, num_at, - NULL, /* OAD_Polymer *polymer, */ - 0 /* nNumDeletedH*/, 0 /*bAdd_DT_to_num_H*/, - 0 /*nNumRemovedProtons*/, NULL /*NUM_H *nNumRemovedProtonsIsotopic*/, - 1 /*int bIsotopic*/, 0 /*bTautomeric*/, - &pInChI, NULL /* INChI_Aux **cur_INChI_Aux*/, - 0 /*bAbcNumbers*/, &dp, 0 /*INCHI_MODE nMode*/, szTitle ); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ + ret = DisplayStructure(pCG, at, num_at, + NULL, /* OAD_Polymer *polymer, */ + 0 /* nNumDeletedH*/, 0 /*bAdd_DT_to_num_H*/, + 0 /*nNumRemovedProtons*/, NULL /*NUM_H *nNumRemovedProtonsIsotopic*/, + 1 /*int bIsotopic*/, 0 /*bTautomeric*/, + &pInChI, NULL /* INChI_Aux **cur_INChI_Aux*/, + 0 /*bAbcNumbers*/, &dp, 0 /*INCHI_MODE nMode*/, szTitle); /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ - inchi_free( at ); + inchi_free(at); return 0; } /****************************************************************************/ -int DisplayStructureComponents( struct tagCANON_GLOBALS *pCG, - ICHICONST INPUT_PARMS *ip, - STRUCT_DATA *sd, - long num_inp, - char *szCurHdr, - ICHICONST SRM *pSrm, - int bReqNonTaut, - StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], - InpInChI *pOneInput ) +int DisplayStructureComponents(struct tagCANON_GLOBALS* pCG, + ICHICONST INPUT_PARMS* ip, + STRUCT_DATA* sd, + long num_inp, + char* szCurHdr, + ICHICONST SRM* pSrm, + int bReqNonTaut, + StrFromINChI* pStruct[INCHI_NUM][TAUT_NUM], + InpInChI* pOneInput) { int iInchiRec, iMobileH, - iCurMobH=-1, + iCurMobH = -1, iAlternH, num_components, tot_just_atoms, tot_atoms, cur_nA, cur_nH; /* djb-rwth: removing redundant variables */ int k, i, j, ret, iCurAtomOffs, iNxtAtomOffs, len, len2; /* djb-rwth: removing redundant variables; removing redundant variables/code */ - int *nAtomOffs = NULL, *nDelHOffs = NULL, iNewCoord = 0, nNewCoord = 0; /* djb-rwth: removing redundant variables */ + int* nAtomOffs = NULL, * nDelHOffs = NULL, iNewCoord = 0, nNewCoord = 0; /* djb-rwth: removing redundant variables */ double x_max = -1.0e16, x_min = 1.0e16, y_max = -1.0e16, y_min = 1.0e16, delta = 0.0; - StrFromINChI *pStruct1; - inp_ATOM *at = NULL, *a; + StrFromINChI* pStruct1; + inp_ATOM* at = NULL, * a; if (!ip->bDisplayCompositeResults && !ip->bDisplay) { @@ -839,8 +837,8 @@ int DisplayStructureComponents( struct tagCANON_GLOBALS *pCG, } num_components = k; - nAtomOffs = (int*) inchi_malloc( ( (long long)num_components + 1 ) * sizeof( nAtomOffs[0] ) ); /* djb-rwth: cast operator added */ - nDelHOffs = (int*) inchi_malloc( ( (long long)num_components + 1 ) * sizeof( nDelHOffs[0] ) ); /* djb-rwth: cast operator added */ + nAtomOffs = (int*)inchi_malloc(((long long)num_components + 1) * sizeof(nAtomOffs[0])); /* djb-rwth: cast operator added */ + nDelHOffs = (int*)inchi_malloc(((long long)num_components + 1) * sizeof(nDelHOffs[0])); /* djb-rwth: cast operator added */ if (!nAtomOffs || !nDelHOffs) { ret = RI_ERR_ALLOC; @@ -849,7 +847,7 @@ int DisplayStructureComponents( struct tagCANON_GLOBALS *pCG, /* count number of atoms and removed H */ /* djb-rwth: removing redundant code */ - iAlternH = ( iMobileH == TAUT_NON && pOneInput->nNumComponents[iInchiRec][TAUT_YES] ) ? TAUT_YES : -1; + iAlternH = (iMobileH == TAUT_NON && pOneInput->nNumComponents[iInchiRec][TAUT_YES]) ? TAUT_YES : -1; nAtomOffs[0] = nDelHOffs[0] = 0; for (k = 0; k < num_components; k++) @@ -888,7 +886,7 @@ int DisplayStructureComponents( struct tagCANON_GLOBALS *pCG, tot_atoms = nDelHOffs[num_components]; /* merge atoms together: 1. Allocate */ - if (NULL == ( at = (inp_ATOM *) inchi_malloc( ( (long long)tot_atoms + 1 ) * sizeof( at[0] ) ) )) /* djb-rwth: cast operator added */ + if (NULL == (at = (inp_ATOM*)inchi_malloc(((long long)tot_atoms + 1) * sizeof(at[0])))) /* djb-rwth: cast operator added */ { ret = RI_ERR_ALLOC; goto exit_function; @@ -907,22 +905,22 @@ int DisplayStructureComponents( struct tagCANON_GLOBALS *pCG, pStruct[iInchiRec][iAlternH][k].num_atoms ? pStruct[iInchiRec][iCurMobH = iAlternH] + k : NULL; if ((len = nAtomOffs[k + 1] - nAtomOffs[k]) && pStruct1) /* djb-rwth: addressing LLVM warning */ { - XYZ_COORD *pxyz = pStruct1->pXYZ; + XYZ_COORD* pxyz = pStruct1->pXYZ; len2 = nDelHOffs[k + 1] - nDelHOffs[k]; /* do not separate H from the atom: we will not need them */ iCurAtomOffs = nAtomOffs[k]; a = at + iCurAtomOffs; memcpy(a, pStruct1->at2, ((long long)len + (long long)len2) * sizeof(at[0])); /* djb-rwth: cast operator added */ - DisconnectedConnectedH( a, len, len2 ); + DisconnectedConnectedH(a, len, len2); if (pxyz) { for (i = 0; i < len; i++) { a[i].x = pxyz[i].xyz[0]; - x_max = inchi_max( x_max, pxyz[i].xyz[0] ); - x_min = inchi_min( x_min, pxyz[i].xyz[0] ); + x_max = inchi_max(x_max, pxyz[i].xyz[0]); + x_min = inchi_min(x_min, pxyz[i].xyz[0]); a[i].y = pxyz[i].xyz[1]; - y_max = inchi_max( y_max, pxyz[i].xyz[1] ); - y_min = inchi_min( y_min, pxyz[i].xyz[1] ); + y_max = inchi_max(y_max, pxyz[i].xyz[1]); + y_min = inchi_min(y_min, pxyz[i].xyz[1]); a[i].z = pxyz[i].xyz[2]; nNewCoord++; } @@ -936,16 +934,16 @@ int DisplayStructureComponents( struct tagCANON_GLOBALS *pCG, ret = 0; goto exit_function; /* empty structure */ } - delta = inchi_max( x_max - x_min, y_max - y_min ); + delta = inchi_max(x_max - x_min, y_max - y_min); if (delta == 0.0) { - delta = 0.5 * ( x_max + x_min ); + delta = 0.5 * (x_max + x_min); if (delta == 0.0) delta = 1.0; } else { - delta /= sqrt( (double) ( (long long)nNewCoord + 1 ) ); /* djb-rwth: cast operator added */ + delta /= sqrt((double)((long long)nNewCoord + 1)); /* djb-rwth: cast operator added */ } } for (i = 0; i < len; i++) @@ -955,7 +953,7 @@ int DisplayStructureComponents( struct tagCANON_GLOBALS *pCG, a[i].z = 0.0; iNewCoord++; } - if ((pStruct1->pXYZ = (XYZ_COORD *) inchi_calloc( len, sizeof( pStruct1->pXYZ[0] )) )) /* djb-rwth: addressing LLVM warning */ + if ((pStruct1->pXYZ = (XYZ_COORD*)inchi_calloc(len, sizeof(pStruct1->pXYZ[0])))) /* djb-rwth: addressing LLVM warning */ { for (i = 0; i < len; i++) @@ -968,11 +966,11 @@ int DisplayStructureComponents( struct tagCANON_GLOBALS *pCG, } if (ip->bDisplay || (ip->bDisplayCompositeResults && 1 == num_components)) /* djb-rwth: addressing LLVM warning */ { - DisplayOneRestoredComponent( pCG, pStruct1, a, k, num_components, iCurMobH, szCurHdr ); + DisplayOneRestoredComponent(pCG, pStruct1, a, k, num_components, iCurMobH, szCurHdr); } if (!pxyz && pStruct1->pXYZ) { - inchi_free( pStruct1->pXYZ ); + inchi_free(pStruct1->pXYZ); pStruct1->pXYZ = NULL; } } @@ -1016,22 +1014,22 @@ int DisplayStructureComponents( struct tagCANON_GLOBALS *pCG, } } tot_atoms = nAtomOffs[num_components]; - DisplayAllRestoredComponents( pCG, at, tot_atoms, szCurHdr ); + DisplayAllRestoredComponents(pCG, at, tot_atoms, szCurHdr); } exit_function: if (at) { - inchi_free( at ); /* in case of failure */ + inchi_free(at); /* in case of failure */ } if (nAtomOffs) { - inchi_free( nAtomOffs ); + inchi_free(nAtomOffs); } if (nDelHOffs) { - inchi_free( nDelHOffs ); + inchi_free(nDelHOffs); } return ret; @@ -1040,29 +1038,29 @@ int DisplayStructureComponents( struct tagCANON_GLOBALS *pCG, /****************************************************************************/ -int AllInchiToStructure( INCHI_CLOCK *ic, - CANON_GLOBALS *pCG, - ICHICONST INPUT_PARMS *ip_inp, - STRUCT_DATA *sd_inp, - long num_inp, - char *szCurHdr, - ICHICONST SRM *pSrm, - int bHasSomeFixedH, - StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], - InpInChI *pOneInput ) +int AllInchiToStructure(INCHI_CLOCK* ic, + CANON_GLOBALS* pCG, + ICHICONST INPUT_PARMS* ip_inp, + STRUCT_DATA* sd_inp, + long num_inp, + char* szCurHdr, + ICHICONST SRM* pSrm, + int bHasSomeFixedH, + StrFromINChI* pStruct[INCHI_NUM][TAUT_NUM], + InpInChI* pOneInput) { int iInchiRec, iMobileH, cur_num_comp, bCurI2A_Flag, k, ret, num_err; int iAtNoOffset; - INPUT_PARMS *ip, ip_loc; - STRUCT_DATA *sd, sd_loc; + INPUT_PARMS* ip, ip_loc; + STRUCT_DATA* sd, sd_loc; long ulProcessingTime = 0; inchiTime ulTStart; - InchiTimeGet( &ulTStart ); + InchiTimeGet(&ulTStart); ip = &ip_loc; *ip = *ip_inp; sd = &sd_loc; - memset( sd, 0, sizeof( *sd ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(sd, 0, sizeof(*sd)); /* djb-rwth: memset_s C11/Annex K variant? */ sd->ulStructTime = sd_inp->ulStructTime; ret = 0; num_err = 0; @@ -1078,14 +1076,14 @@ int AllInchiToStructure( INCHI_CLOCK *ic, continue; } /* allocate memory for all existing components */ - pStruct[iInchiRec][iMobileH] = (StrFromINChI *) inchi_calloc( cur_num_comp, sizeof( pStruct[0][0][0] ) ); + pStruct[iInchiRec][iMobileH] = (StrFromINChI*)inchi_calloc(cur_num_comp, sizeof(pStruct[0][0][0])); if (!pStruct[iInchiRec][iMobileH]) { ret = RI_ERR_ALLOC; goto exit_error; } /* set conversion mode */ - bCurI2A_Flag = ( iMobileH ? 0 : I2A_FLAG_FIXEDH ) | ( iInchiRec ? I2A_FLAG_RECMET : 0 ); + bCurI2A_Flag = (iMobileH ? 0 : I2A_FLAG_FIXEDH) | (iInchiRec ? I2A_FLAG_RECMET : 0); if (iMobileH) { ip->nMode &= ~REQ_MODE_BASIC; @@ -1100,8 +1098,8 @@ int AllInchiToStructure( INCHI_CLOCK *ic, { /* components */ if ((!iMobileH && !pOneInput->pInpInChI[iInchiRec][iMobileH][k].nNumberOfAtoms) || - pOneInput->pInpInChI[iInchiRec][iMobileH][k].bDeleted || - pOneInput->pInpInChI[iInchiRec][iMobileH][k].nLink < 0) /* djb-rwth: addressing LLVM warning */ + pOneInput->pInpInChI[iInchiRec][iMobileH][k].bDeleted || + pOneInput->pInpInChI[iInchiRec][iMobileH][k].nLink < 0) /* djb-rwth: addressing LLVM warning */ { pStruct[iInchiRec][iMobileH][k].nLink = pOneInput->pInpInChI[iInchiRec][iMobileH][k].nLink; pStruct[iInchiRec][iMobileH][k].bDeleted = pOneInput->pInpInChI[iInchiRec][iMobileH][k].bDeleted; @@ -1116,10 +1114,10 @@ int AllInchiToStructure( INCHI_CLOCK *ic, } else if (iMobileH && pOneInput->pInpInChI[iInchiRec][iMobileH][k].nNumberOfAtoms && - pOneInput->pInpInChI[iInchiRec][iMobileH][k].bDeleted && - pOneInput->pInpInChI[iInchiRec][iMobileH][0].bDeleted) + pOneInput->pInpInChI[iInchiRec][iMobileH][k].bDeleted && + pOneInput->pInpInChI[iInchiRec][iMobileH][0].bDeleted) { -/* all components are protons */ + /* all components are protons */ ; } else @@ -1130,7 +1128,7 @@ int AllInchiToStructure( INCHI_CLOCK *ic, } if (bHasSomeFixedH && iMobileH && k < pOneInput->nNumComponents[iInchiRec][TAUT_NON] && - pOneInput->pInpInChI[iInchiRec][TAUT_NON][k].nNumberOfAtoms) + pOneInput->pInpInChI[iInchiRec][TAUT_NON][k].nNumberOfAtoms) { continue; /* do not process Mobile-H if Fixed-H is requested and exists */ } @@ -1144,16 +1142,16 @@ int AllInchiToStructure( INCHI_CLOCK *ic, /* */ /****************************************************/ - ret = InChI2Atom( ic, pCG, ip, sd, szCurHdr, num_inp, pStruct[iInchiRec][iMobileH] + k, k, - iAtNoOffset /* 0*/, bCurI2A_Flag, bHasSomeFixedH, pOneInput ); + ret = InChI2Atom(ic, pCG, ip, sd, szCurHdr, num_inp, pStruct[iInchiRec][iMobileH] + k, k, + iAtNoOffset /* 0*/, bCurI2A_Flag, bHasSomeFixedH, pOneInput); pStruct[iInchiRec][iMobileH][k].nLink = pOneInput->pInpInChI[iInchiRec][iMobileH][k].nLink; if (ret < 0) { #if ( bRELEASE_VERSION != 1 ) #ifndef TARGET_API_LIB /* !!! Conversion Error -- Ignore for now !!! */ - fprintf( stdout, "%ld %s Conversion failed: %d, %c%c comp %d\n", - num_inp, szCurHdr ? szCurHdr : "Struct", ret, iInchiRec ? 'R' : 'D', iMobileH ? 'M' : 'F', k + 1 ); + fprintf(stdout, "%ld %s Conversion failed: %d, %c%c comp %d\n", + num_inp, szCurHdr ? szCurHdr : "Struct", ret, iInchiRec ? 'R' : 'D', iMobileH ? 'M' : 'F', k + 1); #endif #endif if (ret == CT_USER_QUIT_ERR) @@ -1164,13 +1162,13 @@ int AllInchiToStructure( INCHI_CLOCK *ic, ret = 0; /* force to ignore the errors for now !!!! */ num_err++; } - iAtNoOffset += pOneInput->pInpInChI[iInchiRec][iMobileH][k].nNumberOfAtoms ; + iAtNoOffset += pOneInput->pInpInChI[iInchiRec][iMobileH][k].nNumberOfAtoms; } /* k-th component */ } } exit_error: - ulProcessingTime += InchiTimeElapsed( ic, &ulTStart ); + ulProcessingTime += InchiTimeElapsed(ic, &ulTStart); sd->ulStructTime += ulProcessingTime; return ret < 0 ? ret : num_err; @@ -1178,15 +1176,15 @@ int AllInchiToStructure( INCHI_CLOCK *ic, /****************************************************************************/ -int AddProtonAndIsoHBalanceToMobHStruct( INCHI_CLOCK *ic, - CANON_GLOBALS *pCG, - ICHICONST INPUT_PARMS *ip, - STRUCT_DATA *sd, - long num_inp, - int bHasSomeFixedH, - char *szCurHdr, - StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], - InpInChI *pOneInput ) +int AddProtonAndIsoHBalanceToMobHStruct(INCHI_CLOCK* ic, + CANON_GLOBALS* pCG, + ICHICONST INPUT_PARMS* ip, + STRUCT_DATA* sd, + long num_inp, + int bHasSomeFixedH, + char* szCurHdr, + StrFromINChI* pStruct[INCHI_NUM][TAUT_NUM], + InpInChI* pOneInput) { COMPONENT_REM_PROTONS nToBeRemovedByNormFromRevrs[INCHI_NUM]; int nRemovedByNormFromRevrs[INCHI_NUM]; @@ -1216,25 +1214,25 @@ int AddProtonAndIsoHBalanceToMobHStruct( INCHI_CLOCK *ic, nRemovedByNormFromRevrs[INCHI_REC] = 0; nRemovedByRevrs[INCHI_REC] = nRemovedByRevrs[INCHI_BAS] = 0; - /* protons added/removed by InChI Normalization to/from Restored Structure might have been added by StructureRestore */ + /* protons added/removed by InChI Normalization to/from Restored Structure might have been added by StructureRestore */ for (iInchiRec = 0; iInchiRec < INCHI_NUM; iInchiRec++) { for (k = 0; k < pOneInput->nNumComponents[iInchiRec][TAUT_YES]; k++) { - if (!bInpInchiComponentExists( pOneInput, iInchiRec, TAUT_YES, k )) + if (!bInpInchiComponentExists(pOneInput, iInchiRec, TAUT_YES, k)) { continue; } nRemovedProtonsByNormFromRevrs = 0; /* Num protons removed from the Restored Structure by InChI Normalization */ nRemovedProtonsByRevrs = 0; /* Num protons removed by the Reconstruction from the Restored Structure */ - if (iInchiRec == INCHI_REC || (iInchiRec == INCHI_BAS && ( pStruct[iInchiRec][TAUT_YES][k].nLink ) >= 0)) /* djb-rwth: addressing LLVM warning; removing redundant code */ + if (iInchiRec == INCHI_REC || (iInchiRec == INCHI_BAS && (pStruct[iInchiRec][TAUT_YES][k].nLink) >= 0)) /* djb-rwth: addressing LLVM warning; removing redundant code */ { - REV_INCHI *pRevInChI = &pStruct[iInchiRec][TAUT_YES][k].RevInChI; - INChI_Aux **pINChI_Aux2 = pRevInChI->pINChI_Aux[iInchiRec][0]; /* component 0*/ - INChI **pINChI_Revr = pRevInChI->pINChI[iInchiRec][0]; - INChI *pINChI_Orig = pOneInput->pInpInChI[iInchiRec][TAUT_YES] + k; + REV_INCHI* pRevInChI = &pStruct[iInchiRec][TAUT_YES][k].RevInChI; + INChI_Aux** pINChI_Aux2 = pRevInChI->pINChI_Aux[iInchiRec][0]; /* component 0*/ + INChI** pINChI_Revr = pRevInChI->pINChI[iInchiRec][0]; + INChI* pINChI_Orig = pOneInput->pInpInChI[iInchiRec][TAUT_YES] + k; nChargeRevrs = pINChI_Revr ? pINChI_Revr[TAUT_YES]->nTotalCharge : NO_VALUE_INT; nChargeInChI = pINChI_Orig->nTotalCharge; if (pINChI_Aux2) @@ -1247,12 +1245,12 @@ int AddProtonAndIsoHBalanceToMobHStruct( INCHI_CLOCK *ic, } else { - if (0 <= ( k1 = -( 1 + pStruct[iInchiRec][TAUT_YES][k].nLink ) )) + if (0 <= (k1 = -(1 + pStruct[iInchiRec][TAUT_YES][k].nLink))) { - REV_INCHI *pRevInChI = &pStruct[INCHI_REC][TAUT_YES][k1].RevInChI; - INChI_Aux **pINChI_Aux2 = pRevInChI->pINChI_Aux[INCHI_BAS][0]; /* component 0 */ - INChI **pINChI_Revr = pRevInChI->pINChI[INCHI_BAS][0]; - INChI *pINChI_Orig = pOneInput->pInpInChI[INCHI_REC][TAUT_YES] + k1; + REV_INCHI* pRevInChI = &pStruct[INCHI_REC][TAUT_YES][k1].RevInChI; + INChI_Aux** pINChI_Aux2 = pRevInChI->pINChI_Aux[INCHI_BAS][0]; /* component 0 */ + INChI** pINChI_Revr = pRevInChI->pINChI[INCHI_BAS][0]; + INChI* pINChI_Orig = pOneInput->pInpInChI[INCHI_REC][TAUT_YES] + k1; nChargeRevrs = pINChI_Revr ? pINChI_Revr[TAUT_YES]->nTotalCharge : NO_VALUE_INT; nChargeInChI = pINChI_Orig->nTotalCharge; if (pINChI_Aux2) @@ -1276,14 +1274,14 @@ int AddProtonAndIsoHBalanceToMobHStruct( INCHI_CLOCK *ic, } /* Since fixed-H layer is missing we need to add proton balance to the components */ - memset( nIsoDeltaFromDisconnected, 0, sizeof( nIsoDeltaFromDisconnected ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(nIsoDeltaFromDisconnected, 0, sizeof(nIsoDeltaFromDisconnected)); /* djb-rwth: memset_s C11/Annex K variant? */ for (iInchiRec = INCHI_REC; INCHI_BAS <= iInchiRec; iInchiRec--) { /* if ( !pOneInput->nNumComponents[iInchiRec][TAUT_NON] && pOneInput->nNumComponents[iInchiRec][TAUT_YES] ) { */ - int bHasRecMobH = ( iInchiRec == INCHI_BAS && pOneInput->nNumComponents[INCHI_REC][TAUT_YES] ); + int bHasRecMobH = (iInchiRec == INCHI_BAS && pOneInput->nNumComponents[INCHI_REC][TAUT_YES]); /* bHasRecMobH means all components that could not be disconnected are in reconnected part */ if (iInchiRec == INCHI_BAS) { @@ -1292,12 +1290,12 @@ int AddProtonAndIsoHBalanceToMobHStruct( INCHI_CLOCK *ic, } /* after proton removal InChI is recalculated */ - ret = AddRemProtonsInRestrStruct( ic, pCG, ip, sd, num_inp, bHasSomeFixedH, pStruct[iInchiRec][TAUT_YES], - pOneInput->nNumComponents[iInchiRec][TAUT_YES], - bHasRecMobH ? pStruct[INCHI_REC][TAUT_YES] : NULL, - bHasRecMobH ? pOneInput->nNumComponents[INCHI_REC][TAUT_YES] : 0, - &nToBeRemovedByNormFromRevrs[iInchiRec].nNumRemovedProtons, - ( iInchiRec == INCHI_REC ) ? &nDeltaFromDisconnected : NULL ); + ret = AddRemProtonsInRestrStruct(ic, pCG, ip, sd, num_inp, bHasSomeFixedH, pStruct[iInchiRec][TAUT_YES], + pOneInput->nNumComponents[iInchiRec][TAUT_YES], + bHasRecMobH ? pStruct[INCHI_REC][TAUT_YES] : NULL, + bHasRecMobH ? pOneInput->nNumComponents[INCHI_REC][TAUT_YES] : 0, + &nToBeRemovedByNormFromRevrs[iInchiRec].nNumRemovedProtons, + (iInchiRec == INCHI_REC) ? &nDeltaFromDisconnected : NULL); if (ret < 0) { goto exit_function; @@ -1315,7 +1313,7 @@ int AddProtonAndIsoHBalanceToMobHStruct( INCHI_CLOCK *ic, if ( !pOneInput->nNumComponents[iInchiRec][TAUT_NON] && pOneInput->nNumComponents[iInchiRec][TAUT_YES] ) { */ - int bHasRecMobH = ( iInchiRec == INCHI_BAS && pOneInput->nNumComponents[INCHI_REC][TAUT_YES] ); + int bHasRecMobH = (iInchiRec == INCHI_BAS && pOneInput->nNumComponents[INCHI_REC][TAUT_YES]); /* bHasRecMobH means all components that could not be disconnected are in reconnected part */ if (iInchiRec == INCHI_BAS) { @@ -1327,12 +1325,12 @@ int AddProtonAndIsoHBalanceToMobHStruct( INCHI_CLOCK *ic, } /* after proton removal InChI is recalculated */ - ret = AddRemIsoProtonsInRestrStruct( ic, pCG, ip, sd, num_inp, bHasSomeFixedH, pStruct[iInchiRec][TAUT_YES], - pOneInput->nNumComponents[iInchiRec][TAUT_YES], - bHasRecMobH ? pStruct[INCHI_REC][TAUT_YES] : NULL, - bHasRecMobH ? pOneInput->nNumComponents[INCHI_REC][TAUT_YES] : 0, - nToBeRemovedByNormFromRevrs[iInchiRec].nNumRemovedIsotopicH, - ( iInchiRec == INCHI_REC ) ? nIsoDeltaFromDisconnected : NULL ); + ret = AddRemIsoProtonsInRestrStruct(ic, pCG, ip, sd, num_inp, bHasSomeFixedH, pStruct[iInchiRec][TAUT_YES], + pOneInput->nNumComponents[iInchiRec][TAUT_YES], + bHasRecMobH ? pStruct[INCHI_REC][TAUT_YES] : NULL, + bHasRecMobH ? pOneInput->nNumComponents[INCHI_REC][TAUT_YES] : 0, + nToBeRemovedByNormFromRevrs[iInchiRec].nNumRemovedIsotopicH, + (iInchiRec == INCHI_REC) ? nIsoDeltaFromDisconnected : NULL); if (ret < 0) { @@ -1351,17 +1349,17 @@ int AddProtonAndIsoHBalanceToMobHStruct( INCHI_CLOCK *ic, /****************************************************************************/ -void FreeStrFromINChI( StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], - int nNumComponents[INCHI_NUM][TAUT_NUM] ) +void FreeStrFromINChI(StrFromINChI* pStruct[INCHI_NUM][TAUT_NUM], + int nNumComponents[INCHI_NUM][TAUT_NUM]) { int iInchiRec, iMobileH, cur_num_comp, k, j; - StrFromINChI *pStruct1; + StrFromINChI* pStruct1; for (iInchiRec = 0; iInchiRec < INCHI_NUM; iInchiRec++) { for (iMobileH = 0; iMobileH < TAUT_NUM; iMobileH++) { cur_num_comp = nNumComponents[iInchiRec][iMobileH]; - if (!cur_num_comp || !( pStruct1 = pStruct[iInchiRec][iMobileH] )) + if (!cur_num_comp || !(pStruct1 = pStruct[iInchiRec][iMobileH])) { continue; } @@ -1369,19 +1367,19 @@ void FreeStrFromINChI( StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], { if (pStruct1[k].at) { - inchi_free( pStruct1[k].at ); + inchi_free(pStruct1[k].at); } if (pStruct1[k].at2) { - inchi_free( pStruct1[k].at2 ); + inchi_free(pStruct1[k].at2); } if (pStruct1[k].st) { - inchi_free( pStruct1[k].st ); + inchi_free(pStruct1[k].st); } if (pStruct1[k].pVA) { - inchi_free( pStruct1[k].pVA ); + inchi_free(pStruct1[k].pVA); } /* if ( pStruct1[k].ti.t_group ) { @@ -1390,42 +1388,42 @@ void FreeStrFromINChI( StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], */ if (pStruct1[k].pXYZ) { - inchi_free( pStruct1[k].pXYZ ); /* djb-rwth: ui_rr? */ + inchi_free(pStruct1[k].pXYZ); /* djb-rwth: ui_rr? */ } /*==== begin ====*/ - free_t_group_info( &pStruct1[k].ti ); + free_t_group_info(&pStruct1[k].ti); if (pStruct1[k].endpoint) { - inchi_free( pStruct1[k].endpoint ); /* djb-rwth: ui_rr? */ + inchi_free(pStruct1[k].endpoint); /* djb-rwth: ui_rr? */ } if (pStruct1[k].fixed_H) { - inchi_free( pStruct1[k].fixed_H ); /* djb-rwth: ui_rr? */ + inchi_free(pStruct1[k].fixed_H); /* djb-rwth: ui_rr? */ } for (j = 0; j < TAUT_NUM; j++) { if (pStruct1[k].nAtno2Canon[j]) - inchi_free( pStruct1[k].nAtno2Canon[j] ); + inchi_free(pStruct1[k].nAtno2Canon[j]); if (pStruct1[k].nCanon2Atno[j]) - inchi_free( pStruct1[k].nCanon2Atno[j] ); + inchi_free(pStruct1[k].nCanon2Atno[j]); } /*===== end ======*/ /* free INChI memory */ - FreeAllINChIArrays( pStruct1[k].RevInChI.pINChI, - pStruct1[k].RevInChI.pINChI_Aux, - pStruct1[k].RevInChI.num_components ); + FreeAllINChIArrays(pStruct1[k].RevInChI.pINChI, + pStruct1[k].RevInChI.pINChI_Aux, + pStruct1[k].RevInChI.num_components); #ifdef NEVER /* don't do that: these are just pointers to OneInput structure members */ - Free_INChI( &pStruct1[k].pINChI ); - Free_INChI_Aux( &pStruct1[k].pINChI_Aux ); + Free_INChI(&pStruct1[k].pINChI); + Free_INChI_Aux(&pStruct1[k].pINChI_Aux); if (pStruct1[k].inp_norm_data) { - FreeInpAtomData( pStruct1[k].inp_norm_data ); - inchi_free( pStruct1[k].inp_norm_data ); + FreeInpAtomData(pStruct1[k].inp_norm_data); + inchi_free(pStruct1[k].inp_norm_data); } #endif } - inchi_free( pStruct[iInchiRec][iMobileH] ); + inchi_free(pStruct[iInchiRec][iMobileH]); pStruct[iInchiRec][iMobileH] = NULL; } } @@ -1433,7 +1431,7 @@ void FreeStrFromINChI( StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], /****************************************************************************/ -void FreeInpInChI( InpInChI *pOneInput ) +void FreeInpInChI(InpInChI* pOneInput) { int iINChI, k, j; for (iINChI = 0; iINChI < INCHI_NUM; iINChI++) @@ -1445,21 +1443,21 @@ void FreeInpInChI( InpInChI *pOneInput ) for (k = 0; k < pOneInput->nNumComponents[iINChI][j]; k++) { #if (FIX_OSS_FUZZ_25734_28139 == 1) - U_CHAR *k_nAtom = (&pOneInput->pInpInChI[iINChI][j][k])->nAtom; - AT_NUMB *k_nConnTable = (&pOneInput->pInpInChI[iINChI][j][k])->nConnTable; - AT_NUMB *k_nTautomer = (&pOneInput->pInpInChI[iINChI][j][k])->nTautomer; - S_CHAR *k_nNum_H = (&pOneInput->pInpInChI[iINChI][j][k])->nNum_H; - S_CHAR *k_nNum_H_fixed = (&pOneInput->pInpInChI[iINChI][j][k])->nNum_H_fixed; - char *k_szHillFormula = (&pOneInput->pInpInChI[iINChI][j][k])->szHillFormula; - AT_NUMB *k_nPossibleLocationsOfIsotopicH = (&pOneInput->pInpInChI[iINChI][j][k])->nPossibleLocationsOfIsotopicH; - INChI_IsotopicAtom *k_IsotopicAtom = (&pOneInput->pInpInChI[iINChI][j][k])->IsotopicAtom; - INChI_IsotopicTGroup *k_IsotopicTGroup = (&pOneInput->pInpInChI[iINChI][j][k])->IsotopicTGroup; - INChI_Stereo *k_Stereo = (&pOneInput->pInpInChI[iINChI][j][k])->Stereo; - INChI_Stereo *k_StereoIsotopic = (&pOneInput->pInpInChI[iINChI][j][k])->StereoIsotopic; + U_CHAR* k_nAtom = (&pOneInput->pInpInChI[iINChI][j][k])->nAtom; + AT_NUMB* k_nConnTable = (&pOneInput->pInpInChI[iINChI][j][k])->nConnTable; + AT_NUMB* k_nTautomer = (&pOneInput->pInpInChI[iINChI][j][k])->nTautomer; + S_CHAR* k_nNum_H = (&pOneInput->pInpInChI[iINChI][j][k])->nNum_H; + S_CHAR* k_nNum_H_fixed = (&pOneInput->pInpInChI[iINChI][j][k])->nNum_H_fixed; + char* k_szHillFormula = (&pOneInput->pInpInChI[iINChI][j][k])->szHillFormula; + AT_NUMB* k_nPossibleLocationsOfIsotopicH = (&pOneInput->pInpInChI[iINChI][j][k])->nPossibleLocationsOfIsotopicH; + INChI_IsotopicAtom* k_IsotopicAtom = (&pOneInput->pInpInChI[iINChI][j][k])->IsotopicAtom; + INChI_IsotopicTGroup* k_IsotopicTGroup = (&pOneInput->pInpInChI[iINChI][j][k])->IsotopicTGroup; + INChI_Stereo* k_Stereo = (&pOneInput->pInpInChI[iINChI][j][k])->Stereo; + INChI_Stereo* k_StereoIsotopic = (&pOneInput->pInpInChI[iINChI][j][k])->StereoIsotopic; #endif - Free_INChI_Members( &pOneInput->pInpInChI[iINChI][j][k] ); + Free_INChI_Members(&pOneInput->pInpInChI[iINChI][j][k]); #if (FIX_OSS_FUZZ_25734_28139 == 1) { @@ -1467,7 +1465,7 @@ void FreeInpInChI( InpInChI *pOneInput ) int kk; for (kk = k + 1; kk < pOneInput->nNumComponents[iINChI][j]; kk++) { - if (k_nAtom == (&pOneInput->pInpInChI[iINChI][j][kk])->nAtom) + if (k_nAtom == (&pOneInput->pInpInChI[iINChI][j][kk])->nAtom) { (&pOneInput->pInpInChI[iINChI][j][kk])->nAtom = NULL; } @@ -1519,42 +1517,42 @@ void FreeInpInChI( InpInChI *pOneInput ) } } #endif - + } - inchi_free( pOneInput->pInpInChI[iINChI][j] ); + inchi_free(pOneInput->pInpInChI[iINChI][j]); pOneInput->pInpInChI[iINChI][j] = NULL; } if (pOneInput->nNumProtons[iINChI][j].pNumProtons) { - inchi_free( pOneInput->nNumProtons[iINChI][j].pNumProtons ); + inchi_free(pOneInput->nNumProtons[iINChI][j].pNumProtons); pOneInput->nNumProtons[iINChI][j].pNumProtons = NULL; } } } if (pOneInput->atom) { - inchi_free( pOneInput->atom ); + inchi_free(pOneInput->atom); } - FreeExtOrigAtData( pOneInput->polymer, pOneInput->v3000 ); + FreeExtOrigAtData(pOneInput->polymer, pOneInput->v3000); - memset( pOneInput, 0, sizeof( *pOneInput ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(pOneInput, 0, sizeof(*pOneInput)); /* djb-rwth: memset_s C11/Annex K variant? */ } /****************************************************************************/ -int CompareAllOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], - InpInChI *pOneInput, - int bReqNonTaut, - long num_inp, - char *szCurHdr ) +int CompareAllOrigInchiToRevInChI(StrFromINChI* pStruct[INCHI_NUM][TAUT_NUM], + InpInChI* pOneInput, + int bReqNonTaut, + long num_inp, + char* szCurHdr) { int i, iInchiRec, iMobileH, iMobileHpStruct, num_components, iComponent, ret = 0; /* djb-rwth: ignoring LLVM warning: variable used to store function return value */ COMPONENT_REM_PROTONS nCurRemovedProtons, nNumRemovedProtons; - INChI *pInChI[TAUT_NUM]; + INChI* pInChI[TAUT_NUM]; INCHI_MODE CompareInchiFlags[TAUT_NUM]; - memset( pOneInput->CompareInchiFlags[0], 0, sizeof( pOneInput->CompareInchiFlags[0] ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( &nNumRemovedProtons, 0, sizeof( nNumRemovedProtons ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(pOneInput->CompareInchiFlags[0], 0, sizeof(pOneInput->CompareInchiFlags[0])); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(&nNumRemovedProtons, 0, sizeof(nNumRemovedProtons)); /* djb-rwth: memset_s C11/Annex K variant? */ /* do we have reconnected InChI ?*/ iInchiRec = INCHI_REC; @@ -1575,7 +1573,7 @@ int CompareAllOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], int bMobileH = iMobileH; pInChI[0] = pInChI[1] = NULL; if (pOneInput->pInpInChI[iInchiRec][bMobileH][iComponent].nNumberOfAtoms && - !pOneInput->pInpInChI[iInchiRec][bMobileH][iComponent].bDeleted) + !pOneInput->pInpInChI[iInchiRec][bMobileH][iComponent].bDeleted) { /* the requested InChI layer exists */ pInChI[0] = &pOneInput->pInpInChI[iInchiRec][bMobileH][iComponent]; @@ -1595,19 +1593,19 @@ int CompareAllOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], pInChI[0] = &pOneInput->pInpInChI[iInchiRec][bMobileH][iComponent]; } } - memset( CompareInchiFlags, 0, sizeof( CompareInchiFlags ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( &nCurRemovedProtons, 0, sizeof( nCurRemovedProtons ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(CompareInchiFlags, 0, sizeof(CompareInchiFlags)); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(&nCurRemovedProtons, 0, sizeof(nCurRemovedProtons)); /* djb-rwth: memset_s C11/Annex K variant? */ iMobileHpStruct = #if ( bRELEASE_VERSION == 0 ) #ifndef TARGET_API_LIB - /* legacy: reproduce old output */ - OldPrintCompareOneOrigInchiToRevInChI( pStruct[iInchiRec][bMobileH] + iComponent, pInChI, bMobileH, - iComponent, num_inp, szCurHdr ); + /* legacy: reproduce old output */ + OldPrintCompareOneOrigInchiToRevInChI(pStruct[iInchiRec][bMobileH] + iComponent, pInChI, bMobileH, + iComponent, num_inp, szCurHdr); #endif #endif /* one component comparison result bits */ - ret = CompareOneOrigInchiToRevInChI( pStruct[iInchiRec][bMobileH] + iComponent, pInChI, bMobileH, iComponent, - num_inp, szCurHdr, &nCurRemovedProtons, CompareInchiFlags ); + ret = CompareOneOrigInchiToRevInChI(pStruct[iInchiRec][bMobileH] + iComponent, pInChI, bMobileH, iComponent, + num_inp, szCurHdr, &nCurRemovedProtons, CompareInchiFlags); if (ret >= 0) { /* no errors encountered -> accumulate removed protons from individual Mobile-H layers of components */ @@ -1635,7 +1633,7 @@ int CompareAllOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], } else { - /* num removed protons in orig. InChI num removed protons in restored InChi */ + /* num removed protons in orig. InChI num removed protons in restored InChi */ if (nNumRemovedProtons.nNumRemovedProtons != pOneInput->nNumProtons[iInchiRec][iMobileH].nNumRemovedProtons) { /* restored structure InChI has less or more removed protons */ @@ -1645,9 +1643,9 @@ int CompareAllOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], { int num_H_AddedByRevrs = pOneInput->nNumProtons[iInchiRec][iMobileH].nNumRemovedProtons - nNumRemovedProtons.nNumRemovedProtons; - fprintf( stdout, "COMPARE_INCHI: %ld: %s %cM: Proton balance (Diff: %d, RevrsRem=%d)\n", + fprintf(stdout, "COMPARE_INCHI: %ld: %s %cM: Proton balance (Diff: %d, RevrsRem=%d)\n", num_inp, szCurHdr ? szCurHdr : "Struct", iInchiRec ? 'R' : 'D', - pOneInput->nNumProtons[iInchiRec][iMobileH].nNumRemovedProtons, num_H_AddedByRevrs ); + pOneInput->nNumProtons[iInchiRec][iMobileH].nNumRemovedProtons, num_H_AddedByRevrs); } #endif } @@ -1661,9 +1659,9 @@ int CompareAllOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], { int num_H_AddedByRevrs = pOneInput->nNumProtons[iInchiRec][TAUT_YES].nNumRemovedIsotopicH[i] - nNumRemovedProtons.nNumRemovedIsotopicH[i]; - fprintf( stdout, "COMPARE_INCHI: %ld: %s %cM: Iso Xchg %dH balance (Diff: %d, RevrsRem=%d)\n", + fprintf(stdout, "COMPARE_INCHI: %ld: %s %cM: Iso Xchg %dH balance (Diff: %d, RevrsRem=%d)\n", num_inp, szCurHdr ? szCurHdr : "Struct", iInchiRec ? 'R' : 'D', i + 1, - pOneInput->nNumProtons[iInchiRec][TAUT_YES].nNumRemovedIsotopicH[i], num_H_AddedByRevrs ); + pOneInput->nNumProtons[iInchiRec][TAUT_YES].nNumRemovedIsotopicH[i], num_H_AddedByRevrs); } #endif } @@ -1678,11 +1676,11 @@ int CompareAllOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], /****************************************************************************/ -int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][TAUT_NUM], - InpInChI *pOneInput, - int bHasSomeFixedH, - long num_inp, - char *szCurHdr ) +int CompareAllDisconnectedOrigInchiToRevInChI(StrFromINChI* pStruct[INCHI_NUM][TAUT_NUM], + InpInChI* pOneInput, + int bHasSomeFixedH, + long num_inp, + char* szCurHdr) { int i, k, m, n, iInChI, iMobileH, bMobileH, ifk; int num_components_D, num_components_R; @@ -1694,32 +1692,32 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ COMPONENT_REM_PROTONS nNumRemovedProtons_R; /* removed from disconnected layer of the reconstructed struct */ COMPONENT_REM_PROTONS nNumRemovedProtons_R_all; INCHI_MODE CompareInchiFlags[TAUT_NUM]; - StrFromINChI *pStruct1; - INChI_Aux *pINChI_Aux; - INCHI_SORT *pINChISort1 = NULL; /* from reversed structure */ - INCHI_SORT *pINChISort2 = NULL; /* original input InChI */ + StrFromINChI* pStruct1; + INChI_Aux* pINChI_Aux; + INCHI_SORT* pINChISort1 = NULL; /* from reversed structure */ + INCHI_SORT* pINChISort2 = NULL; /* original input InChI */ int nNumNonTaut1 = 0, nNumNonTaut2 = 0; ret = 0; - memset( pOneInput->CompareInchiFlags[1], 0, sizeof( pOneInput->CompareInchiFlags[1] ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(pOneInput->CompareInchiFlags[1], 0, sizeof(pOneInput->CompareInchiFlags[1])); /* djb-rwth: memset_s C11/Annex K variant? */ /* count components that are not subject to disconnection */ if (!pOneInput->nNumComponents[INCHI_REC][TAUT_YES] && - !pOneInput->nNumComponents[INCHI_REC][TAUT_NON]) + !pOneInput->nNumComponents[INCHI_REC][TAUT_NON]) { return 0; /* nothing to do */ } - memset( &nNumRemovedProtons_D, 0, sizeof( nNumRemovedProtons_D ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( &nNumRemovedProtons_R, 0, sizeof( nNumRemovedProtons_R ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( &nNumRemovedProtons_D_all, 0, sizeof( nNumRemovedProtons_D_all ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( &nNumRemovedProtons_R_all, 0, sizeof( nNumRemovedProtons_R_all ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( CompareInchiFlags, 0, sizeof( CompareInchiFlags ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(&nNumRemovedProtons_D, 0, sizeof(nNumRemovedProtons_D)); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(&nNumRemovedProtons_R, 0, sizeof(nNumRemovedProtons_R)); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(&nNumRemovedProtons_D_all, 0, sizeof(nNumRemovedProtons_D_all)); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(&nNumRemovedProtons_R_all, 0, sizeof(nNumRemovedProtons_R_all)); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(CompareInchiFlags, 0, sizeof(CompareInchiFlags)); /* djb-rwth: memset_s C11/Annex K variant? */ - num_components_D = inchi_max( pOneInput->nNumComponents[INCHI_BAS][TAUT_YES], - pOneInput->nNumComponents[INCHI_BAS][TAUT_NON] ); - num_components_R = inchi_max( pOneInput->nNumComponents[INCHI_REC][TAUT_YES], - pOneInput->nNumComponents[INCHI_REC][TAUT_NON] ); + num_components_D = inchi_max(pOneInput->nNumComponents[INCHI_BAS][TAUT_YES], + pOneInput->nNumComponents[INCHI_BAS][TAUT_NON]); + num_components_R = inchi_max(pOneInput->nNumComponents[INCHI_REC][TAUT_YES], + pOneInput->nNumComponents[INCHI_REC][TAUT_NON]); /***********************************************************************************************/ /* InpInChI: count fragments -- disconnected components that do not match reconnected */ @@ -1741,9 +1739,9 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ for (k = 0; k < num_components_D; k++) { bMobileH = iMobileH; - if (!bInpInchiComponentExists( pOneInput, iInChI, bMobileH, k )) + if (!bInpInchiComponentExists(pOneInput, iInChI, bMobileH, k)) { - if (bInpInchiComponentExists( pOneInput, iInChI, TAUT_YES, k )) + if (bInpInchiComponentExists(pOneInput, iInChI, TAUT_YES, k)) { bMobileH = TAUT_YES; } @@ -1752,13 +1750,13 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ continue; /* component is missing ??? */ } } - if (0 > ( nLink = pOneInput->pInpInChI[iInChI][bMobileH][k].nLink )) + if (0 > (nLink = pOneInput->pInpInChI[iInChI][bMobileH][k].nLink)) { /* component in Disconnected layer is linked to the identical one in the Reconnected layer */ if (pOneInput->nNumProtons[INCHI_REC][TAUT_YES].pNumProtons) { nNumCompHaveSeparateProtons_D++; - nLink = -( 1 + nLink ); + nLink = -(1 + nLink); nNumRemovedProtons_D.nNumRemovedProtons += pOneInput->nNumProtons[INCHI_REC][TAUT_YES].pNumProtons[nLink].nNumRemovedProtons; for (m = 0; m < NUM_H_ISOTOPES; m++) { @@ -1768,7 +1766,7 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ continue; /* same as reconnected */ } /* component in the reconnected layer that was disconnected */ - nNumNonTaut2 += ( bMobileH == TAUT_NON ); + nNumNonTaut2 += (bMobileH == TAUT_NON); if (pOneInput->nNumProtons[iInChI][TAUT_YES].pNumProtons) { nNumCompHaveSeparateProtons_D++; @@ -1801,9 +1799,9 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ for (k = 0; k < num_components_R; k++) { bMobileH = iMobileH; - if (!bInpInchiComponentExists( pOneInput, iInChI, bMobileH, k )) + if (!bInpInchiComponentExists(pOneInput, iInChI, bMobileH, k)) { - if (bInpInchiComponentExists( pOneInput, iInChI, TAUT_YES, k )) + if (bInpInchiComponentExists(pOneInput, iInChI, TAUT_YES, k)) { bMobileH = TAUT_YES; } @@ -1822,7 +1820,7 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ ifk = 0; /* 0th component since it is InChI of a single component */ /* The statement in the following line is *WRONG*, component number mixed with bMobileH: */ /* in RevInchi, when only Mobile-H is present then its only non-NULL InChI has index 0==TAUT_NON */ - if (bRevInchiComponentExists( pStruct1, ifInChI, ifMobileH, ifk )) + if (bRevInchiComponentExists(pStruct1, ifInChI, ifMobileH, ifk)) { /* count protons */ pINChI_Aux = pStruct1->RevInChI.pINChI_Aux[ifInChI][ifk][ifMobileH]; @@ -1835,7 +1833,7 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ } } } - nNumCompHaveSeparateProtons_R += bRevInchiComponentExists( pStruct1, ifInChI, ALT_TAUT( ifMobileH ), ifk ); + nNumCompHaveSeparateProtons_R += bRevInchiComponentExists(pStruct1, ifInChI, ALT_TAUT(ifMobileH), ifk); continue; /* same as disconnected, has no metal atoms */ } /* this reconstructed reconnected component WAS DISCONNECTED; check its fragments */ @@ -1847,9 +1845,9 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ for (ifk = 0; ifk < num_fragments; ifk++) { bfMobileH = ifMobileH; - if (!bRevInchiComponentExists( pStruct1, ifInChI, bfMobileH, ifk )) + if (!bRevInchiComponentExists(pStruct1, ifInChI, bfMobileH, ifk)) { - if (bRevInchiComponentExists( pStruct1, ifInChI, TAUT_YES, ifk )) + if (bRevInchiComponentExists(pStruct1, ifInChI, TAUT_YES, ifk)) { bfMobileH = TAUT_YES; } @@ -1858,8 +1856,8 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ continue; /* fragment does not exist ??? */ } } - nNumNonTaut1 += ( bfMobileH == TAUT_NON ); - nNumCompHaveSeparateProtons_R += ( bfMobileH == TAUT_NON ); + nNumNonTaut1 += (bfMobileH == TAUT_NON); + nNumCompHaveSeparateProtons_R += (bfMobileH == TAUT_NON); /* count protons from fragments made by metal disconnection */ pINChI_Aux = pStruct1->RevInChI.pINChI_Aux[ifInChI][ifk][TAUT_YES]; if (pINChI_Aux) @@ -1879,8 +1877,8 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ k = num_components_R - 1; pStruct1 = pStruct[iInChI][iMobileH] + k; if (iMobileH == TAUT_YES && !bHasSomeFixedH && - bInpInchiComponentDeleted( pOneInput, iInChI, iMobileH, k ) && - ( num_fragments = pStruct1->RevInChI.num_components[INCHI_BAS] )) + bInpInchiComponentDeleted(pOneInput, iInChI, iMobileH, k) && + (num_fragments = pStruct1->RevInChI.num_components[INCHI_BAS])) { ifInChI = INCHI_BAS; /* disconnected layer */ @@ -1888,7 +1886,7 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ for (ifk = 0; ifk < num_fragments; ifk++) { bfMobileH = ifMobileH; - if (!bRevInchiComponentDeleted( pStruct1, ifInChI, bfMobileH, ifk )) + if (!bRevInchiComponentDeleted(pStruct1, ifInChI, bfMobileH, ifk)) { continue; /* fragment does exist ??? Should not happen */ } @@ -1910,7 +1908,7 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ } } - num_fragments_DR = inchi_max( num_fragments_D, num_fragments_R ); + num_fragments_DR = inchi_max(num_fragments_D, num_fragments_R); /* in case of correct reconstruction, num_fragments_D, num_fragments_R */ if (!num_fragments_DR) { @@ -1928,8 +1926,8 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ return 1; /* severe error */ } - pINChISort1 = (INCHI_SORT *) inchi_calloc( num_fragments_DR, sizeof( pINChISort1[0] ) ); - pINChISort2 = (INCHI_SORT *) inchi_calloc( num_fragments_DR, sizeof( pINChISort2[0] ) ); + pINChISort1 = (INCHI_SORT*)inchi_calloc(num_fragments_DR, sizeof(pINChISort1[0])); + pINChISort2 = (INCHI_SORT*)inchi_calloc(num_fragments_DR, sizeof(pINChISort2[0])); if (!pINChISort1 || !pINChISort2) { ret = RI_ERR_ALLOC; @@ -1942,9 +1940,9 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ for (k = n = 0; k < num_components_D; k++) { bMobileH = iMobileH; - if (!bInpInchiComponentExists( pOneInput, iInChI, bMobileH, k )) + if (!bInpInchiComponentExists(pOneInput, iInChI, bMobileH, k)) { - if (bInpInchiComponentExists( pOneInput, iInChI, TAUT_YES, k )) + if (bInpInchiComponentExists(pOneInput, iInChI, TAUT_YES, k)) { bMobileH = TAUT_YES; } @@ -1960,8 +1958,8 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ /* the component exists in disconnected layer of the orig. InChI only: it is a fragment */ pINChISort2[n].pINChI[bMobileH] = pOneInput->pInpInChI[iInChI][bMobileH] + k; if (bMobileH == TAUT_NON && - ( bInpInchiComponentExists( pOneInput, iInChI, TAUT_YES, k ) || - bInpInchiComponentDeleted( pOneInput, iInChI, TAUT_YES, k ) )) + (bInpInchiComponentExists(pOneInput, iInChI, TAUT_YES, k) || + bInpInchiComponentDeleted(pOneInput, iInChI, TAUT_YES, k))) { pINChISort2[n].pINChI[TAUT_YES] = pOneInput->pInpInChI[iInChI][TAUT_YES] + k; } @@ -1979,9 +1977,9 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ for (k = n = 0; k < num_components_R; k++) { bMobileH = iMobileH; - if (!bInpInchiComponentExists( pOneInput, iInChI, bMobileH, k )) + if (!bInpInchiComponentExists(pOneInput, iInChI, bMobileH, k)) { - if (bInpInchiComponentExists( pOneInput, iInChI, TAUT_YES, k )) + if (bInpInchiComponentExists(pOneInput, iInChI, TAUT_YES, k)) { bMobileH = TAUT_YES; } @@ -2003,9 +2001,9 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ for (i = 0; i < num_fragments; i++) { bfMobileH = ifMobileH; - if (!bRevInchiComponentExists( pStruct1, ifInChI, bfMobileH, i )) + if (!bRevInchiComponentExists(pStruct1, ifInChI, bfMobileH, i)) { - if (bRevInchiComponentExists( pStruct1, ifInChI, TAUT_YES, i )) + if (bRevInchiComponentExists(pStruct1, ifInChI, TAUT_YES, i)) { bfMobileH = TAUT_YES; } @@ -2020,8 +2018,8 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ pINChISort1[n].pINChI[TAUT_YES] = pStruct1->RevInChI.pINChI[ifInChI][i][TAUT_YES]; /* remove Fixed-H InChI if is is identical to Mobile-H */ /* do it exactly same way the identical components were removed from InpInChI */ - if (!CompareReversedINChI( pINChISort1[n].pINChI[bfMobileH], - pINChISort1[n].pINChI[TAUT_YES], NULL, NULL )) + if (!CompareReversedINChI(pINChISort1[n].pINChI[bfMobileH], + pINChISort1[n].pINChI[TAUT_YES], NULL, NULL)) { pINChISort1[n].pINChI[bfMobileH] = NULL; /* remove Fixed-H layer */ } @@ -2038,20 +2036,20 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ } /* sort fragment InChI before comparing them */ - qsort( pINChISort1, num_fragments_D, sizeof( pINChISort1[0] ), CompINChITaut2 ); - qsort( pINChISort2, num_fragments_R, sizeof( pINChISort2[0] ), CompINChITaut2 ); + qsort(pINChISort1, num_fragments_D, sizeof(pINChISort1[0]), CompINChITaut2); + qsort(pINChISort2, num_fragments_R, sizeof(pINChISort2[0]), CompINChITaut2); /* compare fragments -- components present in disconnected layer only */ for (iComponent = 0; iComponent < num_fragments_DR; iComponent++) { - INChI *pInChI1[TAUT_NUM]; /* from reversed structure */ - INChI *pInChI2[TAUT_NUM]; /* original input InChI */ + INChI* pInChI1[TAUT_NUM]; /* from reversed structure */ + INChI* pInChI2[TAUT_NUM]; /* original input InChI */ for (i = 0; i < TAUT_NUM; i++) { pInChI1[i] = pINChISort1[iComponent].pINChI[i]; pInChI2[i] = pINChISort2[iComponent].pINChI[i]; } - CompareTwoPairsOfInChI( pInChI1, pInChI2, !bHasSomeFixedH, CompareInchiFlags ); + CompareTwoPairsOfInChI(pInChI1, pInChI2, !bHasSomeFixedH, CompareInchiFlags); } if ( /*nNumNonTaut1 && nNumNonTaut2 &&*/ bHasSomeFixedH) @@ -2065,8 +2063,8 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ NUM_H nNumRemovedIsotopicH1[NUM_H_ISOTOPES]; NUM_H nNumRemovedIsotopicH2[NUM_H_ISOTOPES]; - memset( nNumRemovedIsotopicH1, 0, sizeof( nNumRemovedIsotopicH1 ) ); /* djb-rwth: memset_s C11/Annex K variant? */ - memset( nNumRemovedIsotopicH2, 0, sizeof( nNumRemovedIsotopicH2 ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(nNumRemovedIsotopicH1, 0, sizeof(nNumRemovedIsotopicH1)); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(nNumRemovedIsotopicH2, 0, sizeof(nNumRemovedIsotopicH2)); /* djb-rwth: memset_s C11/Annex K variant? */ /* compare removed protons */ if (pINChISort1[iComponent].ord_number != pINChISort2[iComponent].ord_number) { @@ -2080,15 +2078,15 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ pOneInput->nNumProtons[INCHI_BAS][TAUT_YES].pNumProtons[k].nNumRemovedIsotopicH, sizeof(nNumRemovedIsotopicH2)); } - /* get fragments of reconstructed structure removed protons info */ + /* get fragments of reconstructed structure removed protons info */ k = pINChISort1[iComponent].n1; /* restored component number */ i = pINChISort1[iComponent].n2; /* subcomponent number */ iInChI = INCHI_REC; iMobileH = bHasSomeFixedH ? !pOneInput->nNumComponents[iInChI][TAUT_NON] : TAUT_YES; bMobileH = iMobileH; - if (!bInpInchiComponentExists( pOneInput, iInChI, bMobileH, k )) + if (!bInpInchiComponentExists(pOneInput, iInChI, bMobileH, k)) { - if (bInpInchiComponentExists( pOneInput, iInChI, TAUT_YES, k )) + if (bInpInchiComponentExists(pOneInput, iInChI, TAUT_YES, k)) { bMobileH = TAUT_YES; } @@ -2112,9 +2110,9 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ if (i < num_fragments) { bfMobileH = ifMobileH; - if (!bRevInchiComponentExists( pStruct1, ifInChI, bfMobileH, i )) + if (!bRevInchiComponentExists(pStruct1, ifInChI, bfMobileH, i)) { - if (!bRevInchiComponentExists( pStruct1, ifInChI, TAUT_YES, i )) + if (!bRevInchiComponentExists(pStruct1, ifInChI, TAUT_YES, i)) /* djb-rwth: removing redundant code */ { goto compare_iso_H; @@ -2125,7 +2123,7 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ sizeof(nNumRemovedIsotopicH1)); } compare_iso_H: - if (memcmp( nNumRemovedIsotopicH1, nNumRemovedIsotopicH2, sizeof( nNumRemovedIsotopicH1 ) )) + if (memcmp(nNumRemovedIsotopicH1, nNumRemovedIsotopicH2, sizeof(nNumRemovedIsotopicH1))) { CompareInchiFlags[TAUT_YES] |= INCHIDIFF_REM_ISO_H; } @@ -2136,13 +2134,13 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ { /* compare totals for removed protons and isotopic H */ if (pOneInput->nNumProtons[INCHI_BAS][TAUT_YES].nNumRemovedProtons != - nNumRemovedProtons_R.nNumRemovedProtons) + nNumRemovedProtons_R.nNumRemovedProtons) { CompareInchiFlags[TAUT_YES] |= INCHIDIFF_MOBH_PROTONS; } - if (memcmp( pOneInput->nNumProtons[INCHI_BAS][TAUT_YES].nNumRemovedIsotopicH, + if (memcmp(pOneInput->nNumProtons[INCHI_BAS][TAUT_YES].nNumRemovedIsotopicH, nNumRemovedProtons_R.nNumRemovedIsotopicH, - sizeof( nNumRemovedProtons_R.nNumRemovedIsotopicH ) )) + sizeof(nNumRemovedProtons_R.nNumRemovedIsotopicH))) { CompareInchiFlags[TAUT_YES] |= INCHIDIFF_REM_ISO_H; } @@ -2175,9 +2173,9 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ { CompareInchiFlags[TAUT_YES] |= INCHIDIFF_MOBH_PROTONS; /* diff number of removed protons */ } - if (memcmp( nNumRemovedProtons_R.nNumRemovedIsotopicH, + if (memcmp(nNumRemovedProtons_R.nNumRemovedIsotopicH, nNumRemovedProtons_D.nNumRemovedIsotopicH, - sizeof( nNumRemovedProtons_D.nNumRemovedIsotopicH ) )) + sizeof(nNumRemovedProtons_D.nNumRemovedIsotopicH))) { CompareInchiFlags[TAUT_YES] |= INCHIDIFF_REM_ISO_H; } @@ -2186,11 +2184,11 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ if (pINChISort1) { - inchi_free( pINChISort1 ); + inchi_free(pINChISort1); } if (pINChISort2) { - inchi_free( pINChISort2 ); + inchi_free(pINChISort2); } return ret; @@ -2198,10 +2196,10 @@ int CompareAllDisconnectedOrigInchiToRevInChI( StrFromINChI *pStruct[INCHI_NUM][ /****************************************************************************/ -int CompareTwoPairsOfInChI( INChI *pInChI1[TAUT_NUM], - INChI *pInChI2[TAUT_NUM], - int bMobileH, - INCHI_MODE CompareInchiFlags[] ) +int CompareTwoPairsOfInChI(INChI* pInChI1[TAUT_NUM], + INChI* pInChI2[TAUT_NUM], + int bMobileH, + INCHI_MODE CompareInchiFlags[]) { int iMobileH, err = 0; INCHI_MODE cmp; @@ -2210,7 +2208,7 @@ int CompareTwoPairsOfInChI( INChI *pInChI1[TAUT_NUM], if (!pInChI1[iMobileH] != !pInChI2[iMobileH]) { if (iMobileH == TAUT_NON && - pInChI1[TAUT_YES] && pInChI2[TAUT_YES]) /* djb-rwth: condition corrected */ + pInChI1[TAUT_YES] && pInChI2[TAUT_YES]) /* djb-rwth: condition corrected */ { CompareInchiFlags[iMobileH] |= INCHIDIFF_COMP_HLAYER; } @@ -2222,7 +2220,7 @@ int CompareTwoPairsOfInChI( INChI *pInChI1[TAUT_NUM], } if (pInChI1[iMobileH] && pInChI2[iMobileH]) { - cmp = CompareReversedINChI3( pInChI1[iMobileH], pInChI2[iMobileH], NULL, NULL, &err ); + cmp = CompareReversedINChI3(pInChI1[iMobileH], pInChI2[iMobileH], NULL, NULL, &err); if (cmp) { CompareInchiFlags[iMobileH] |= cmp; @@ -2235,14 +2233,14 @@ int CompareTwoPairsOfInChI( INChI *pInChI1[TAUT_NUM], /****************************************************************************/ -int CompareOneOrigInchiToRevInChI( StrFromINChI *pStruct, - INChI *pInChI[TAUT_NUM], - int bMobileH, - int iComponent, - long num_inp, - char *szCurHdr, - COMPONENT_REM_PROTONS *nCurRemovedProtons, - INCHI_MODE CompareInchiFlags[] ) +int CompareOneOrigInchiToRevInChI(StrFromINChI* pStruct, + INChI* pInChI[TAUT_NUM], + int bMobileH, + int iComponent, + long num_inp, + char* szCurHdr, + COMPONENT_REM_PROTONS* nCurRemovedProtons, + INCHI_MODE CompareInchiFlags[]) { int ret = pStruct->RevInChI.nRetVal, err = 0; INCHI_MODE cmp; @@ -2261,13 +2259,13 @@ int CompareOneOrigInchiToRevInChI( StrFromINChI *pStruct, { i = INCHI_BAS; } - if (b == TAUT_NON && ( !pStruct->RevInChI.pINChI[i] || + if (b == TAUT_NON && (!pStruct->RevInChI.pINChI[i] || !pStruct->RevInChI.pINChI[i][0][b] || - !pStruct->RevInChI.pINChI[i][0][b]->nNumberOfAtoms )) + !pStruct->RevInChI.pINChI[i][0][b]->nNumberOfAtoms)) { b = TAUT_YES; } - if (pStruct->bDeleted && ( !pInChI[0] || pInChI[0]->bDeleted )) + if (pStruct->bDeleted && (!pInChI[0] || pInChI[0]->bDeleted)) { return 0; } @@ -2290,8 +2288,12 @@ int CompareOneOrigInchiToRevInChI( StrFromINChI *pStruct, if (pStruct->RevInChI.num_components[i] && pStruct->RevInChI.pINChI[i]) /* djb-rwth: fixing a NULL pointer dereference */ { /* compare InChI from restored structure; '0' in [i][0][b] is the first component */ - if (b != TAUT_YES && pStruct->RevInChI.pINChI[i][0][b]->bDeleted && ( !pInChI[0] || pInChI[0]->bDeleted )) - /* djb-rwth: removing redundant code */ + if (b == TAUT_YES && pStruct->RevInChI.pINChI[i][0][b]->bDeleted && ( !pInChI[0] || pInChI[0]->bDeleted )) + { + /* the 1st component is made out of proton(s) and the input component is missing or also a proton */ + cmp = 0; + } + else { cmp = CompareReversedINChI3( pStruct->RevInChI.pINChI[i][0][b], pInChI[0], NULL, NULL, &err ); if (cmp) @@ -2302,11 +2304,11 @@ int CompareOneOrigInchiToRevInChI( StrFromINChI *pStruct, if (b == b0 && b == TAUT_NON) { if ((pStruct->RevInChI.pINChI[i][0][TAUT_YES] && - !pStruct->RevInChI.pINChI[i][0][TAUT_YES]->bDeleted) || - (pInChI[1] && !pInChI[1]->bDeleted)) /* djb-rwth: addressing LLVM warnings */ + !pStruct->RevInChI.pINChI[i][0][TAUT_YES]->bDeleted) || + (pInChI[1] && !pInChI[1]->bDeleted)) /* djb-rwth: addressing LLVM warnings */ { /* in addition to fixed-H also compare mobile-H InChI */ - cmp = CompareReversedINChI3( pStruct->RevInChI.pINChI[i][0][TAUT_YES], pInChI[1], NULL, NULL, &err ); + cmp = CompareReversedINChI3(pStruct->RevInChI.pINChI[i][0][TAUT_YES], pInChI[1], NULL, NULL, &err); if (cmp) { CompareInchiFlags[TAUT_YES] |= cmp; @@ -2318,7 +2320,7 @@ int CompareOneOrigInchiToRevInChI( StrFromINChI *pStruct, CompareInchiFlags[TAUT_YES] |= INCHIDIFF_MOBH_PROTONS; } } - memset( nCurRemovedProtons, 0, sizeof( *nCurRemovedProtons ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(nCurRemovedProtons, 0, sizeof(*nCurRemovedProtons)); /* djb-rwth: memset_s C11/Annex K variant? */ for (k = 0; k < pStruct->RevInChI.num_components[i]; k++) { if (!k || pStruct->RevInChI.pINChI[i][k][TAUT_YES]->bDeleted) @@ -2343,26 +2345,26 @@ int CompareOneOrigInchiToRevInChI( StrFromINChI *pStruct, /****************************************************************************/ -INCHI_MODE CompareReversedStereoINChI3( INChI_Stereo *s1, - /* InChI from reversed struct */ - INChI_Stereo *s2, - /* input InChI */ - ICR *picr ) +INCHI_MODE CompareReversedStereoINChI3(INChI_Stereo* s1, + /* InChI from reversed struct */ + INChI_Stereo* s2, + /* input InChI */ + ICR* picr) { int ret = 0; int j1, j2, num_dif, num_extra_undf, num_miss_undf, num_in1_only, num_in2_only; /* djb-rwth: removing redundant variables */ - int bAddSb = !( picr->num_sb_undef_in1_only + picr->num_sb_in1_only + picr->num_sb_in2_only ); - int bAddSc = !( picr->num_sc_undef_in1_only + picr->num_sc_in1_only + picr->num_sc_in2_only ); + int bAddSb = !(picr->num_sb_undef_in1_only + picr->num_sb_in1_only + picr->num_sb_in2_only); + int bAddSc = !(picr->num_sc_undef_in1_only + picr->num_sc_in1_only + picr->num_sc_in2_only); int nNumSc1 = s1 ? s1->nNumberOfStereoCenters : 0; int nNumSc2 = s2 ? s2->nNumberOfStereoCenters : 0; int nNumSb1 = s1 ? s1->nNumberOfStereoBonds : 0; int nNumSb2 = s2 ? s2->nNumberOfStereoBonds : 0; - if (( nNumSc1 || nNumSc2 ) && - ( nNumSc1 != nNumSc2 || - memcmp( s1->nNumber, s2->nNumber, nNumSc1 * sizeof( s1->nNumber[0] ) ) || - memcmp( s1->t_parity, s2->t_parity, nNumSc1 * sizeof( s1->t_parity[0] ) ) )) /* djb-rwth: condition corrected */ + if ((nNumSc1 || nNumSc2) && + (nNumSc1 != nNumSc2 || + memcmp(s1->nNumber, s2->nNumber, nNumSc1 * sizeof(s1->nNumber[0])) || + memcmp(s1->t_parity, s2->t_parity, nNumSc1 * sizeof(s1->t_parity[0])))) /* djb-rwth: condition corrected */ { num_dif = num_extra_undf = num_miss_undf = num_in1_only = num_in2_only = 0; /* djb-rwth: removing redundant code */ @@ -2484,24 +2486,24 @@ INCHI_MODE CompareReversedStereoINChI3( INChI_Stereo *s1, } } - if (s1 && s2 && ( s2->nCompInv2Abs != 2 ) && s1->nCompInv2Abs != s2->nCompInv2Abs && s1->nCompInv2Abs && s2->nCompInv2Abs) + if (s1 && s2 && (s2->nCompInv2Abs != 2) && s1->nCompInv2Abs != s2->nCompInv2Abs && s1->nCompInv2Abs && s2->nCompInv2Abs) { ret |= INCHIDIFF_SC_INV; /* 2007-07-13 DT: added (s2->nCompInv2Abs != 2) to fix bug reoprted by Yerin on 2007/02/28 */ - /* Bug description: falsely reported "Stereo centers/allenes: Falsely inverted" for /S2 or /S3 */ + /* Bug description: falsely reported "Stereo centers/allenes: Falsely inverted" for /S2 or /S3 */ } - if (( nNumSb1 || nNumSb2 ) && - ( nNumSb1 != nNumSb2 || - memcmp( s1->nBondAtom1, s2->nBondAtom1, nNumSb1 * sizeof( s1->nBondAtom1[0] ) ) || - memcmp( s1->nBondAtom2, s2->nBondAtom2, nNumSb1 * sizeof( s1->nBondAtom2[0] ) ) || - memcmp( s1->b_parity, s2->b_parity, nNumSb1 * sizeof( s1->b_parity[0] ) ) )) + if ((nNumSb1 || nNumSb2) && + (nNumSb1 != nNumSb2 || + memcmp(s1->nBondAtom1, s2->nBondAtom1, nNumSb1 * sizeof(s1->nBondAtom1[0])) || + memcmp(s1->nBondAtom2, s2->nBondAtom2, nNumSb1 * sizeof(s1->nBondAtom2[0])) || + memcmp(s1->b_parity, s2->b_parity, nNumSb1 * sizeof(s1->b_parity[0])))) { num_dif = num_extra_undf = num_miss_undf = num_in1_only = num_in2_only = 0; /* djb-rwth: removing redundant code */ for (j1 = j2 = 0; j1 < nNumSb1 && j2 < nNumSb2; ) { if (s1->nBondAtom1[j1] == s2->nBondAtom1[j2] && - s1->nBondAtom2[j1] == s2->nBondAtom2[j2]) + s1->nBondAtom2[j1] == s2->nBondAtom2[j2]) { if (s1->b_parity[j1] != s2->b_parity[j2]) /* djb-rwth: removing redundant code */ @@ -2514,7 +2516,7 @@ INCHI_MODE CompareReversedStereoINChI3( INChI_Stereo *s1, else { if (s1->nBondAtom1[j1] < s2->nBondAtom1[j2] || - (s1->nBondAtom1[j1] == s2->nBondAtom1[j2] && s1->nBondAtom2[j1] < s2->nBondAtom2[j2])) /* djb-rwth: addressing LLVM warning */ + (s1->nBondAtom1[j1] == s2->nBondAtom1[j2] && s1->nBondAtom2[j1] < s2->nBondAtom2[j2])) /* djb-rwth: addressing LLVM warning */ { num_in1_only++; if (s1->b_parity[j1] == AB_PARITY_UNDF) @@ -2625,27 +2627,27 @@ INCHI_MODE CompareReversedStereoINChI3( INChI_Stereo *s1, /****************************************************************************/ -INCHI_MODE CompareReversedINChI3( INChI *i1 /* InChI from reversed struct */, - INChI *i2 /* input InChI */, - INChI_Aux *a1, - INChI_Aux *a2, - int *err ) +INCHI_MODE CompareReversedINChI3(INChI* i1 /* InChI from reversed struct */, + INChI* i2 /* input InChI */, + INChI_Aux* a1, + INChI_Aux* a2, + int* err) { INCHI_MODE ret = 0; - INChI_Stereo *Stereo1 = NULL, *Stereo2 = NULL; + INChI_Stereo* Stereo1 = NULL, * Stereo2 = NULL; int n1, n2, m, j, j1, j2, ret2, num_H1, num_H2; ICR icr; - ICR *picr = &icr; + ICR* picr = &icr; *err = 0; - memset( picr, 0, sizeof( *picr ) ); /* djb-rwth: memset_s C11/Annex K variant? */ + memset(picr, 0, sizeof(*picr)); /* djb-rwth: memset_s C11/Annex K variant? */ if (i1 == NULL && i2 == NULL) { return 0; } - if (( i1 == NULL ) ^ ( i2 == NULL )) + if ((i1 == NULL) ^ (i2 == NULL)) { ret |= INCHIDIFF_PROBLEM; /* one InChI exists while another doesn't */ goto exit_function; @@ -2672,13 +2674,13 @@ INCHI_MODE CompareReversedINChI3( INChI *i1 /* InChI from reversed struct */, } if (i1->nNumberOfAtoms > 0) { - if (memcmp( i1->nAtom, i2->nAtom, i1->nNumberOfAtoms * sizeof( i1->nAtom[0] ) )) + if (memcmp(i1->nAtom, i2->nAtom, i1->nNumberOfAtoms * sizeof(i1->nAtom[0]))) { ret |= INCHIDIFF_ATOMS; goto exit_function; } /* INCHIDIFF_NON_TAUT_H, INCHIDIFF_MORE_FH, INCHIDIFF_LESS_FH */ - if (memcmp( i1->nNum_H, i2->nNum_H, i1->nNumberOfAtoms * sizeof( i1->nNum_H[0] ) )) + if (memcmp(i1->nNum_H, i2->nNum_H, i1->nNumberOfAtoms * sizeof(i1->nNum_H[0]))) { ret |= INCHIDIFF_POSITION_H; for (j1 = 0; j1 < i1->nNumberOfAtoms; j1++) @@ -2754,7 +2756,7 @@ INCHI_MODE CompareReversedINChI3( INChI *i1 /* InChI from reversed struct */, else { if (bHasFixedH1 && bHasFixedH2 && - memcmp( i1->nNum_H_fixed, i2->nNum_H_fixed, i1->nNumberOfAtoms * sizeof( i1->nNum_H_fixed[0] ) )) + memcmp(i1->nNum_H_fixed, i2->nNum_H_fixed, i1->nNumberOfAtoms * sizeof(i1->nNum_H_fixed[0]))) { for (i = j1 = j2 = 0; i < i1->nNumberOfAtoms; i++) { @@ -2778,7 +2780,7 @@ INCHI_MODE CompareReversedINChI3( INChI *i1 /* InChI from reversed struct */, } } } - ret |= ( j1 ? INCHIDIFF_MORE_FH : 0 ) | ( j2 ? INCHIDIFF_LESS_FH : 0 ); + ret |= (j1 ? INCHIDIFF_MORE_FH : 0) | (j2 ? INCHIDIFF_LESS_FH : 0); picr->num_fixed_H1_more = j1; picr->num_fixed_H2_more = j2; } @@ -2790,7 +2792,7 @@ INCHI_MODE CompareReversedINChI3( INChI *i1 /* InChI from reversed struct */, /* compare formulas and H */ num_H1 = 0; num_H2 = 0; - ret2 = CompareHillFormulasNoH( i1->szHillFormula, i2->szHillFormula, &num_H1, &num_H2 ); + ret2 = CompareHillFormulasNoH(i1->szHillFormula, i2->szHillFormula, &num_H1, &num_H2); picr->tot_num_H1 = num_H1; picr->tot_num_H2 = num_H2; if (ret2) @@ -2814,7 +2816,7 @@ INCHI_MODE CompareReversedINChI3( INChI *i1 /* InChI from reversed struct */, } else { - if (i1->lenConnTable > 0 && memcmp( i1->nConnTable, i2->nConnTable, i1->lenConnTable * sizeof( i1->nConnTable[0] ) )) + if (i1->lenConnTable > 0 && memcmp(i1->nConnTable, i2->nConnTable, i1->lenConnTable * sizeof(i1->nConnTable[0]))) { ret |= INCHIDIFF_CON_TBL; goto exit_function; @@ -2870,14 +2872,14 @@ INCHI_MODE CompareReversedINChI3( INChI *i1 /* InChI from reversed struct */, /* number of endpoints */ int num1 = 0, num2 = 0, num_M1 = 0, num_M2 = 0; int len, num_eq, num_in1_only, num_in2_only; - AT_NUMB *pe1 = (AT_NUMB *) inchi_malloc( ( (long long)i1->lenTautomer + 1 ) * sizeof( pe1[0] ) ); /* djb-rwth: cast operator added */ - AT_NUMB *pe2 = (AT_NUMB *) inchi_malloc( ( (long long)i2->lenTautomer + 1 ) * sizeof( pe2[0] ) ); /* djb-rwth: cast operator added */ + AT_NUMB* pe1 = (AT_NUMB*)inchi_malloc(((long long)i1->lenTautomer + 1) * sizeof(pe1[0])); /* djb-rwth: cast operator added */ + AT_NUMB* pe2 = (AT_NUMB*)inchi_malloc(((long long)i2->lenTautomer + 1) * sizeof(pe2[0])); /* djb-rwth: cast operator added */ num_H1 = num_H2 = 0; /* collect endpoints, H, (-) */ if (!pe1 || !pe2) { - if (pe1) inchi_free( pe1 ); - if (pe2) inchi_free( pe2 ); + if (pe1) inchi_free(pe1); + if (pe2) inchi_free(pe2); *err = RI_ERR_ALLOC; /* allocation error */ goto exit_function; } @@ -2906,8 +2908,8 @@ INCHI_MODE CompareReversedINChI3( INChI *i1 /* InChI from reversed struct */, picr->num_taut_M1 = num_M1; picr->num_taut_M2 = num_M2; /* sort endpoints */ - insertions_sort_AT_NUMB( pe1, num1 ); - insertions_sort_AT_NUMB( pe2, num2 ); + insertions_sort_AT_NUMB(pe1, num1); + insertions_sort_AT_NUMB(pe2, num2); /* compare */ /* if ( num1 < num2 ) { @@ -2983,13 +2985,13 @@ INCHI_MODE CompareReversedINChI3( INChI *i1 /* InChI from reversed struct */, { ret |= INCHIDIFF_DIFF_TG_ENDP; } - inchi_free( pe1 ); - inchi_free( pe2 ); + inchi_free(pe1); + inchi_free(pe2); } - if (( i1->lenTautomer > 1 && i2->lenTautomer > 1 ) && - ( i1->lenTautomer != i2->lenTautomer || - memcmp( i1->nTautomer, i2->nTautomer, i1->lenTautomer * sizeof( i1->nTautomer[0] ) ) )) + if ((i1->lenTautomer > 1 && i2->lenTautomer > 1) && + (i1->lenTautomer != i2->lenTautomer || + memcmp(i1->nTautomer, i2->nTautomer, i1->lenTautomer * sizeof(i1->nTautomer[0])))) ret |= INCHIDIFF_TG; if (i1->nNumberOfIsotopicAtoms != i2->nNumberOfIsotopicAtoms) @@ -2998,21 +3000,21 @@ INCHI_MODE CompareReversedINChI3( INChI *i1 /* InChI from reversed struct */, } else { - if (i1->nNumberOfIsotopicAtoms > 0 && memcmp( i1->IsotopicAtom, i2->IsotopicAtom, i1->nNumberOfIsotopicAtoms * sizeof( i1->IsotopicAtom[0] ) )) + if (i1->nNumberOfIsotopicAtoms > 0 && memcmp(i1->IsotopicAtom, i2->IsotopicAtom, i1->nNumberOfIsotopicAtoms * sizeof(i1->IsotopicAtom[0]))) { ret |= INCHIDIFF_ISO_AT; } } if (i1->nTotalCharge != i2->nTotalCharge) ret |= INCHIDIFF_CHARGE; - if (a1 && a1->nNumRemovedProtons && ( !a2 || a2->nNumRemovedProtons != a1->nNumRemovedProtons )) + if (a1 && a1->nNumRemovedProtons && (!a2 || a2->nNumRemovedProtons != a1->nNumRemovedProtons)) { ret |= INCHIDIFF_REM_PROT; } - if (a1 && ( !a2 || + if (a1 && (!a2 || a2->nNumRemovedIsotopicH[0] != a1->nNumRemovedIsotopicH[0] || a2->nNumRemovedIsotopicH[1] != a1->nNumRemovedIsotopicH[1] || - a2->nNumRemovedIsotopicH[2] != a1->nNumRemovedIsotopicH[2] )) + a2->nNumRemovedIsotopicH[2] != a1->nNumRemovedIsotopicH[2])) { ret |= INCHIDIFF_REM_ISO_H; } @@ -3029,7 +3031,7 @@ INCHI_MODE CompareReversedINChI3( INChI *i1 /* InChI from reversed struct */, } */ if (i1->StereoIsotopic && - i1->StereoIsotopic->nNumberOfStereoBonds + i1->StereoIsotopic->nNumberOfStereoCenters) + i1->StereoIsotopic->nNumberOfStereoBonds + i1->StereoIsotopic->nNumberOfStereoCenters) { Stereo1 = i1->StereoIsotopic; } @@ -3038,7 +3040,7 @@ INCHI_MODE CompareReversedINChI3( INChI *i1 /* InChI from reversed struct */, Stereo1 = i1->Stereo; } if (i2->StereoIsotopic && - i2->StereoIsotopic->nNumberOfStereoBonds + i2->StereoIsotopic->nNumberOfStereoCenters) + i2->StereoIsotopic->nNumberOfStereoBonds + i2->StereoIsotopic->nNumberOfStereoCenters) { Stereo2 = i2->StereoIsotopic; } @@ -3046,7 +3048,7 @@ INCHI_MODE CompareReversedINChI3( INChI *i1 /* InChI from reversed struct */, { Stereo2 = i2->Stereo; } - ret |= CompareReversedStereoINChI3( Stereo1, Stereo2, picr ); + ret |= CompareReversedStereoINChI3(Stereo1, Stereo2, picr); exit_function: picr->flags = ret; @@ -3119,15 +3121,15 @@ const CMP_INCHI_MSG CompareInchiMsgs[] = /*************************************************************************/ -int AddOneMsg( char *szMsg, - int used_len, - int tot_len, - const char *szAddMsg, - const char *szDelim ) +int AddOneMsg(char* szMsg, + int used_len, + int tot_len, + const char* szAddMsg, + const char* szDelim) { const char ellip[] = "..."; - int len = (int) strlen( szAddMsg ); - int len_delim = ( used_len && szDelim ) ? strlen( szDelim ) : 0; + int len = (int)strlen(szAddMsg); + int len_delim = (used_len && szDelim) ? strlen(szDelim) : 0; int len_to_copy; if (len + len_delim + used_len < tot_len) { @@ -3141,7 +3143,7 @@ int AddOneMsg( char *szMsg, } else { - if (( len_to_copy = ( tot_len - used_len - len_delim - ( int )sizeof( ellip ) ) ) > 10) + if ((len_to_copy = (tot_len - used_len - len_delim - (int)sizeof(ellip))) > 10) { if (len_delim) { @@ -3151,7 +3153,7 @@ int AddOneMsg( char *szMsg, strncpy(szMsg + used_len, szAddMsg, len_to_copy); used_len += len_to_copy; strcpy(szMsg + used_len, ellip); - used_len += sizeof( ellip ) - 1; + used_len += sizeof(ellip) - 1; } } @@ -3160,12 +3162,12 @@ int AddOneMsg( char *szMsg, /****************************************************************************/ -int FillOutCompareMessage( char *szMsg, int nLenMsg, INCHI_MODE bits[] ) +int FillOutCompareMessage(char* szMsg, int nLenMsg, INCHI_MODE bits[]) { - int bMobileH, k, n, len = (int) strlen( szMsg ); + int bMobileH, k, n, len = (int)strlen(szMsg); int iPrevGrpIdx, iCurGrpIdx, bFound; INCHI_MODE bit; - static const char *hdr = " Problems/mismatches:"; + static const char* hdr = " Problems/mismatches:"; char szOneMsg[256]; int mismatch = 0; @@ -3175,9 +3177,9 @@ int FillOutCompareMessage( char *szMsg, int nLenMsg, INCHI_MODE bits[] ) mismatch = -1; - if (!strstr( szMsg, hdr )) + if (!strstr(szMsg, hdr)) { - len = AddOneMsg( szMsg, len, nLenMsg, hdr, NULL ); + len = AddOneMsg(szMsg, len, nLenMsg, hdr, NULL); } for (bMobileH = TAUT_YES; 0 <= bMobileH; bMobileH--) @@ -3187,7 +3189,7 @@ int FillOutCompareMessage( char *szMsg, int nLenMsg, INCHI_MODE bits[] ) if (bits[bMobileH]) { strcpy(szOneMsg, bMobileH == TAUT_YES ? " Mobile-H(" : " Fixed-H("); - len = AddOneMsg( szMsg, len, nLenMsg, szOneMsg, NULL ); + len = AddOneMsg(szMsg, len, nLenMsg, szOneMsg, NULL); } bit = 1; @@ -3201,7 +3203,7 @@ int FillOutCompareMessage( char *szMsg, int nLenMsg, INCHI_MODE bits[] ) bFound = 0; for (k = 0; CompareInchiMsgs[k].nBit != INCHIDIFF_ZERO && !bFound; k++) { - if (bit & (INCHI_MODE) CompareInchiMsgs[k].nBit) + if (bit & (INCHI_MODE)CompareInchiMsgs[k].nBit) { /* message found */ for (n = 0; CompareInchiMsgsGroup[n].nGroupID != IDGRP_ZERO; n++) @@ -3213,11 +3215,11 @@ int FillOutCompareMessage( char *szMsg, int nLenMsg, INCHI_MODE bits[] ) { if (iPrevGrpIdx >= 0) { - len = AddOneMsg( szMsg, len, nLenMsg, ";", NULL ); + len = AddOneMsg(szMsg, len, nLenMsg, ";", NULL); } - len = AddOneMsg( szMsg, len, nLenMsg, CompareInchiMsgsGroup[iCurGrpIdx].szGroupName, NULL ); + len = AddOneMsg(szMsg, len, nLenMsg, CompareInchiMsgsGroup[iCurGrpIdx].szGroupName, NULL); } - len = AddOneMsg( szMsg, len, nLenMsg, CompareInchiMsgs[k].szMsg, iCurGrpIdx == iPrevGrpIdx ? "," : NULL ); + len = AddOneMsg(szMsg, len, nLenMsg, CompareInchiMsgs[k].szMsg, iCurGrpIdx == iPrevGrpIdx ? "," : NULL); iPrevGrpIdx = iCurGrpIdx; bFound = 1; break; @@ -3231,7 +3233,7 @@ int FillOutCompareMessage( char *szMsg, int nLenMsg, INCHI_MODE bits[] ) if (bits[bMobileH]) { - len = AddOneMsg( szMsg, len, nLenMsg, ")", NULL ); + len = AddOneMsg(szMsg, len, nLenMsg, ")", NULL); } } diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichister.c b/INCHI-1-SRC/INCHI_BASE/src/ichister.c index 7adade77..7b7db38d 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichister.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichister.c @@ -3936,14 +3936,21 @@ int set_stereo_atom_parity( CANON_GLOBALS *pCG, num_z++; } - nSbNeighOrigAtNumb[j1] = at_removed_H[next_at].orig_at_number; - at_coord[j1][0] = at_removed_H[next_at].x - at[cur_at].x; - at_coord[j1][1] = at_removed_H[next_at].y - at[cur_at].y; - bond_len_xy[j1] = len2( at_coord[j1] ); - /* bond_len_xy[j1] = sqrt(at_coord[j1][0]*at_coord[j1][0]+at_coord[j1][1]*at_coord[j1][1]); */ - at_coord[j1][2] = ( nType == ZTYPE_3D ? z : nType == ZTYPE_UP - ? bond_len_xy[j1] : nType == ZTYPE_DOWN - ? -bond_len_xy[j1] : 0.0 ); + if (j1 < MAX_NUM_STEREO_ATOM_NEIGH) /* djb-rwth: fixing oss-fuzz issue #71142 */ + { + nSbNeighOrigAtNumb[j1] = at_removed_H[next_at].orig_at_number; + at_coord[j1][0] = at_removed_H[next_at].x - at[cur_at].x; + at_coord[j1][1] = at_removed_H[next_at].y - at[cur_at].y; + bond_len_xy[j1] = len2(at_coord[j1]); + /* bond_len_xy[j1] = sqrt(at_coord[j1][0]*at_coord[j1][0]+at_coord[j1][1]*at_coord[j1][1]); */ + at_coord[j1][2] = (nType == ZTYPE_3D ? z : nType == ZTYPE_UP + ? bond_len_xy[j1] : nType == ZTYPE_DOWN + ? -bond_len_xy[j1] : 0.0); + } + else + { + break; + } } break; case 1: @@ -3964,14 +3971,21 @@ int set_stereo_atom_parity( CANON_GLOBALS *pCG, num_z++; } - nSbNeighOrigAtNumb[j1] = at[next_at].orig_at_number; - at_coord[j1][0] = at[next_at].x - at[cur_at].x; - at_coord[j1][1] = at[next_at].y - at[cur_at].y; - bond_len_xy[j1] = len2( at_coord[j1] ); - /* bond_len_xy[j1] = sqrt(at_coord[j1][0]*at_coord[j1][0]+at_coord[j1][1]*at_coord[j1][1]); */ - at_coord[j1][2] = ( nType == ZTYPE_3D ? z : - nType == ZTYPE_UP ? bond_len_xy[j1] : - nType == ZTYPE_DOWN ? -bond_len_xy[j1] : 0.0 ); + if (j1 < MAX_NUM_STEREO_ATOM_NEIGH) /* djb-rwth: fixing oss-fuzz issue #71142 */ + { + nSbNeighOrigAtNumb[j1] = at[next_at].orig_at_number; + at_coord[j1][0] = at[next_at].x - at[cur_at].x; + at_coord[j1][1] = at[next_at].y - at[cur_at].y; + bond_len_xy[j1] = len2(at_coord[j1]); + /* bond_len_xy[j1] = sqrt(at_coord[j1][0]*at_coord[j1][0]+at_coord[j1][1]*at_coord[j1][1]); */ + at_coord[j1][2] = (nType == ZTYPE_3D ? z : + nType == ZTYPE_UP ? bond_len_xy[j1] : + nType == ZTYPE_DOWN ? -bond_len_xy[j1] : 0.0); + } + else + { + break; + } } break; } diff --git a/INCHI-1-SRC/INCHI_BASE/src/ichitaut.c b/INCHI-1-SRC/INCHI_BASE/src/ichitaut.c index 91993817..005d9395 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ichitaut.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ichitaut.c @@ -50,7 +50,6 @@ #include "util.h" #include "bcf_s.h" -static int tgi_mntg_global; /* Local prototypes */ @@ -4371,6 +4370,8 @@ int MarkTautomerGroups( CANON_GLOBALS *pCG, INCHI_MODE bTautFlagsDone = t_group_info->bTautFlagsDone; /* save previous findings, if any */ TNI tni = t_group_info->tni; AT_NUMB *tGroupNumber = t_group_info->tGroupNumber; + T_GROUP* tgi_tgr = NULL; /* copied from below 2024-09-01 DT */ + bIgnoreIsotopic = t_group_info->bIgnoreIsotopic; memset( t_group_info, 0, sizeof( *t_group_info ) ); /* djb-rwth: memset_s C11/Annex K variant? */ t_group_info->bIgnoreIsotopic = bIgnoreIsotopic; /* restore initial setting */ @@ -4380,8 +4381,7 @@ int MarkTautomerGroups( CANON_GLOBALS *pCG, t_group_info->tGroupNumber = tGroupNumber; t_group_info->max_num_t_groups = num_atoms / 2 + 1; /* upper limit */ /* djb-rwth: fixing oss-fuzz issue #52978 */ - T_GROUP* tgi_tgr = (T_GROUP*)inchi_calloc((long long)t_group_info->max_num_t_groups + 1, sizeof(t_group_info->t_group[0])); - tgi_mntg_global = t_group_info->max_num_t_groups; + tgi_tgr = (T_GROUP*)inchi_calloc((long long)t_group_info->max_num_t_groups + 1, sizeof(t_group_info->t_group[0])); if (!tgi_tgr) { t_group_info->max_num_t_groups = -1; @@ -6370,12 +6370,9 @@ int make_a_copy_of_t_group_info( T_GROUP_INFO *t_group_info, { if (( len = t_group_info_orig->max_num_t_groups ) > 0) { + T_GROUP* tgi_tg = NULL; /* Copied from below 2024-09-01 DT */ /* djb-rwth: fixing oss-fuzz issue #52978 */ - if (len != tgi_mntg_global) - { - len = tgi_mntg_global; - } - T_GROUP* tgi_tg = (T_GROUP*)inchi_malloc(((long long)len+1) * sizeof(t_group_info->t_group[0])); /* djb-rwth: cast operator added */ + tgi_tg = (T_GROUP*)inchi_malloc(((long long)len+1) * sizeof(t_group_info->t_group[0])); /* djb-rwth: cast operator added */ if (tgi_tg && t_group_info_orig->t_group) { t_group_info->t_group = tgi_tg; diff --git a/INCHI-1-SRC/INCHI_BASE/src/ikey_dll.c b/INCHI-1-SRC/INCHI_BASE/src/ikey_dll.c index f3895aed..e37be145 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/ikey_dll.c +++ b/INCHI-1-SRC/INCHI_BASE/src/ikey_dll.c @@ -65,7 +65,6 @@ #include "util.h" #include "bcf_s.h" -int sminor_size; /* djb-rwth: required for fixing oss-fuzz issue #66746 */ /* Local options */ @@ -236,7 +235,6 @@ int INCHI_DECL GetINCHIKeyFromINCHI( const char* szINCHISource, ret = INCHIKEY_NOT_ENOUGH_MEMORY; goto fin; } sminor = (char*) inchi_calloc( 2 * slen + 2, sizeof( char ) ); /* we may double the length ... */ - sminor_size = 2 * slen + 2; if (NULL == sminor) { ret = INCHIKEY_NOT_ENOUGH_MEMORY; goto fin; diff --git a/INCHI-1-SRC/INCHI_BASE/src/inpdef.h b/INCHI-1-SRC/INCHI_BASE/src/inpdef.h index 61d3aefc..fd3bac36 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/inpdef.h +++ b/INCHI-1-SRC/INCHI_BASE/src/inpdef.h @@ -653,7 +653,7 @@ void OAD_Polymer_SetAtProps( OAD_Polymer *pd, int OAD_Polymer_CompareBackboneBondsSeniority( int *b1, int *b2, OAD_AtProps *aprops ); -int OAD_Polymer_CompareRanksOfTwoAtoms( int atom1, +int OAD_Polymer_CompareRanksOfTwoAtoms( int atom1, int atom2, OAD_AtProps *aprops ); int OAD_Polymer_IsFirstAtomRankLower( int atom1, int atom2, OAD_AtProps *aprops ); diff --git a/INCHI-1-SRC/INCHI_BASE/src/mode.h b/INCHI-1-SRC/INCHI_BASE/src/mode.h index e4916491..b42d044f 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/mode.h +++ b/INCHI-1-SRC/INCHI_BASE/src/mode.h @@ -44,6 +44,7 @@ #include #include +#include "bcf_s.h" /*******************/ @@ -71,26 +72,27 @@ #ifdef RENUMBER_ATOMS_AND_RECALC_V106 /* Comment the next line to print all renumbering changing the initial InChIKey */ #define STOP_AFTER_FIRST_CHANGE_ON_RENUMBERING 1 -#define APP_DESCRIPTION "InChI version 1, Software v. 1.07 (inchi-1 executable)" +/* djb-rwth: adding full version number in the output -- GH issue #61 */ +#define APP_DESCRIPTION "InChI version 1, Software " CURRENT_VER " (inchi-1 executable)" /*#define APP_DESCRIPTION "InChI version 1, Software v. 1.06-PT6 (inchi-1 executable) \n*** INTERNAL TEST MODE: ATOM RENUMBERING TEST IS ACTIVE ***"*/ #else -#define APP_DESCRIPTION "InChI version 1, Software v. 1.07 (inchi-1 executable)***" +#define APP_DESCRIPTION "InChI version 1, Software " CURRENT_VER " (inchi-1 executable)***" /*#define APP_DESCRIPTION "InChI version 1, Software v. 1.06-PT6 (inchi-1 executable) \n*** UNOFFICIAL TEST VERSION: 6 PT TAUTO RULES AVAILABLE ***"*/ #endif #elif defined(TARGET_API_LIB) -#define APP_DESCRIPTION "InChI version 1, Software v. 1.07 (API Library)" +#define APP_DESCRIPTION "InChI version 1, Software " CURRENT_VER " (API Library)" #elif defined(TARGET_EXE_USING_API) #ifndef APP_DESCRIPTION -#define APP_DESCRIPTION "InChI version 1, Software v. 1.07 (executable calling API Library)" +#define APP_DESCRIPTION "InChI version 1, Software " CURRENT_VER " (executable calling API Library)" #endif #elif defined(TARGET_LIB_FOR_WINCHI) -#define APP_DESCRIPTION "InChI version 1, Software v. 1.07 (Library for wInChI GUI executable)" +#define APP_DESCRIPTION "InChI version 1, Software " CURRENT_VER " (Library for wInChI GUI executable)" #elif defined(TARGET_WINCHI) -#define APP_DESCRIPTION "InChI version 1, Software v. 1.07 (wInChI GUI executable)" +#define APP_DESCRIPTION "InChI version 1, Software " CURRENT_VER " (wInChI GUI executable)" #else #error No build target #defined, pls check compiler options... (TARGET_EXE_STANDALONE|TARGET_API_LIB|TARGET_EXE_USING_API|TARGET_LIB_FOR_WINCHI) diff --git a/INCHI-1-SRC/INCHI_BASE/src/runichi.c b/INCHI-1-SRC/INCHI_BASE/src/runichi.c index f1135cd5..79402513 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/runichi.c +++ b/INCHI-1-SRC/INCHI_BASE/src/runichi.c @@ -1750,6 +1750,8 @@ int CreateOneComponentINChI( CANON_GLOBALS *pCG, INChI_Aux *cur_INChI_Aux[TAUT_NUM]; long lElapsedTime; + int nAllocMode = 0; /* moved from below 2024-09-01 DT */ + InchiTimeGet( &ulTStart ); bOrigCoord = !( ip->bINChIOutputOptions & ( INCHI_OUT_NO_AUX_INFO | INCHI_OUT_SHORT_AUX_INFO ) ); @@ -1772,7 +1774,7 @@ int CreateOneComponentINChI( CANON_GLOBALS *pCG, if (bTautFlagsDone & (TG_FLAG_FOUND_ISOTOPIC_H_DONE | TG_FLAG_FOUND_ISOTOPIC_ATOM_DONE)) nAM2 = ip->nMode & REQ_MODE_ISO; - int nAllocMode = nAM1 | nAM2; /* djb-rwth: original sequence of bit-wise operations had to be rewritten */ + nAllocMode = nAM1 | nAM2; /* djb-rwth: original sequence of bit-wise operations had to be rewritten */ if ((k == TAUT_NON && ( ip->nMode & REQ_MODE_BASIC )) || diff --git a/INCHI-1-SRC/INCHI_BASE/src/runichi3.c b/INCHI-1-SRC/INCHI_BASE/src/runichi3.c index 7924b034..d897d0b6 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/runichi3.c +++ b/INCHI-1-SRC/INCHI_BASE/src/runichi3.c @@ -75,8 +75,6 @@ #include "bcf_s.h" -static int nat_global; /* djb-rwth: required for fixing oss-fuzz issue #68277 */ - /* Local prototypes */ static int OrigAtData_bCheckUnusualValences( ORIG_ATOM_DATA *orig_at_data, int bAddIsoH, @@ -85,8 +83,6 @@ static int OrigAtData_bCheckUnusualValences( ORIG_ATOM_DATA *orig_at_data, static void OAD_PolymerUnit_RemoveLinkFromCRUChain( int at1, int at2, int *nbonds, int **bonds ); - - /**************************************************************************** Check inp_ATOM's for unusual valence ****************************************************************************/ @@ -3498,6 +3494,7 @@ void OAD_PolymerUnit_DelistHighOrderBackboneBonds( OAD_PolymerUnit *unit, int at1, at2, j = 0, k, check_taut = 0, remove; /* djb-rwth: removing redundant variables/code */ int *orig_num = NULL, *curr_num = NULL; + int bond_is_untouchable = 0, btype; /* DT: moved from below 2024-09-01 DT */ if (unit->na < 2) { @@ -3537,7 +3534,7 @@ void OAD_PolymerUnit_DelistHighOrderBackboneBonds( OAD_PolymerUnit *unit, } /*if ( border > 1 ) */ /* djb-rwth: removing redundant code */ - int bond_is_untouchable = 0, btype; + bond_is_untouchable = 0; if (check_taut && composite_norm_data && composite_norm_data->at && curr_num) /* djb-rwth: fixing a NULL pointer dereference */ { for (k = 0; k < composite_norm_data->at[curr_num[at1]].valence; k++) @@ -3880,7 +3877,7 @@ void OAD_Polymer_SmartReopenCyclizedUnits( OAD_Polymer *p, return; } /* djb-rwth: fixing oss-fuzz issue #68329 */ - if ((nat <= 0) || (nat >= at_size_check1)) + if (nat <= 0) { return; } @@ -3889,7 +3886,6 @@ void OAD_Polymer_SmartReopenCyclizedUnits( OAD_Polymer *p, OAD_Polymer_DebugTrace( p );*/ /* Set atom properties for sorting */ - nat_global = nat + 1; /* djb-rwth: fixing oss-fuzz issue #68277 */ if (!aprops || !at) /* djb-rwth: fixing oss-fuzz issue #68329, #68286 */ { return; @@ -4195,7 +4191,7 @@ int OAD_Polymer_CompareRanksOfTwoAtoms( int atom1, int atom2, OAD_AtProps *aprop int a2typ = CARBOAT; /* djb-rwth: fixing oss-fuzz issue #69501, #68277 */ - if ((a1 >= nat_global) || (a2 >= nat_global) || (a1 < 0) || (a2 < 0)) + if ((a1 < 0) || (a2 < 0)) { return 0; } @@ -4495,4 +4491,4 @@ int Inp_Atom_GetBondType(inp_ATOM *at, int iatom1, int iatom2) } return -1; -} +} \ No newline at end of file diff --git a/INCHI-1-SRC/INCHI_BASE/src/strutil.c b/INCHI-1-SRC/INCHI_BASE/src/strutil.c index 993f115b..0a2cbe7c 100644 --- a/INCHI-1-SRC/INCHI_BASE/src/strutil.c +++ b/INCHI-1-SRC/INCHI_BASE/src/strutil.c @@ -50,8 +50,6 @@ #include "ichi_io.h" #include "ichimain.h" -#include - #include "bcf_s.h" /* Added fix to remove_ion_pairs() -- 2010-03-17 DT */ @@ -4288,6 +4286,7 @@ int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, * component_nbr[j][2] = new number of component #(component_nbr[i][1]+1) */ AT_TRIPLE *component_nbr = NULL; + int fst_at, nxt_at, cur_at, cur_neq_fst; /* moved from below 2024-09-01 DT */ /* initialize */ if (bProcessOldCompNumbers && !orig_at_data->nOldCompNumber) @@ -4328,15 +4327,16 @@ int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, if (!nNewCompNumber[j]) { /* mark starting with at[j] */ - int fst_at = 0, nxt_at = 0, cur_at = j; + fst_at = 0; + nxt_at = 0; + cur_at = j; + cur_neq_fst = 1; num_components++; /* first time at at[j] */ fst_at = cur_at; nNewCompNumber[fst_at] = (AT_NUMB) num_components; - bool cur_neq_fst = true; - /* find next neighbor */ do { @@ -4356,7 +4356,7 @@ int MarkDisconnectedComponents( ORIG_ATOM_DATA *orig_at_data, } else if (cur_at == fst_at) { - cur_neq_fst = false; + cur_neq_fst = 0; /* break; done */ } else diff --git a/INCHI-1-SRC/INCHI_EXE/inchi-1/gcc/makefile b/INCHI-1-SRC/INCHI_EXE/inchi-1/gcc/makefile index 1af2c176..45f37ba4 100644 --- a/INCHI-1-SRC/INCHI_EXE/inchi-1/gcc/makefile +++ b/INCHI-1-SRC/INCHI_EXE/inchi-1/gcc/makefile @@ -56,13 +56,21 @@ LINKER = clang++ -s endif else ifndef C_COMPILER +ifeq ($(OS_ID),0) +C_COMPILER = gcc -static +else C_COMPILER = gcc +endif $(info Both GCC/G++ and Clang(++)/LLVM detected. Compiling with GCC/G++ (default) -- please edit makefile to compile with Clang(++)/LLVM.) $(info ) endif ifndef CPP_COMPILER +ifeq ($(OS_ID),0) +CPP_COMPILER = g++ -static-libgcc +else CPP_COMPILER = g++ endif +endif ifndef LINKER LINKER = g++ -s endif @@ -90,15 +98,15 @@ ifndef P_BASE endif #P_INCL = -I$(P_MAIN) -I$(P_BASE) P_INCL = -I$(P_MAIN) -I$(P_BASE) -C_COMPILER_OPTIONS = $(P_INCL) -std=c11 -ansi -DCOMPILE_ANSI_ONLY -DTARGET_EXE_STANDALONE -O2 -c -fno-strict-aliasing +C_COMPILER_OPTIONS = $(P_INCL) -std=c11 -ansi -DCOMPILE_ANSI_ONLY -DTARGET_EXE_STANDALONE -g -O1 -c -fno-strict-aliasing #C_COMPILER_OPTIONS = -c $(P_INCL) -ansi -O2 -fsigned-char -ffunction-sections -fexpensive-optimizations -fstack-check -fexceptions -Wall -pedantic -Wbad-function-cast -Wreturn-type -Wformat -Wuninitialized -Wcast-align -Wshadow -Wunused -Wunused-value -Wunused-variable -Wunused-function -Wunused-parameter -Wunused-label -Wcomment -Wcast-qual -Wconversion -Wimplicit-int -Wmissing-braces -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wsign-compare -Wfloat-equal -Wstrict-prototypes -Wwrite-strings -Wundef -Waggregate-return -Wchar-subscripts -Wformat-nonliteral -Wnested-externs -Wsequence-point -Wpointer-arith -mfancy-math-387 -mieee-fp -mno-soft-float ifeq ($(OS_ID),0) # no -ansi option due to reported MinGw bug - CPP_COMPILER_OPTIONS = $(P_INCL) -D_LIB -DTARGET_EXE_STANDALONE -O2 -frtti -c -fno-strict-aliasing - #CPP_COMPILER_OPTIONS = -c $(P_INCL) -D_LIB -O2 -frtti -Wall -pedantic -Wreturn-type -Wformat -Wuninitialized -ffunction-sections -fexpensive-optimizations -fstack-check -fexceptions -Wcast-align -Wshadow -Wunused -Wunused-value -Wunused-variable -Wunused-function -fsigned-char -Wcast-qual -Wconversion -Wmissing-braces -Wredundant-decls -Wsign-compare -Wfloat-equal -Wwrite-strings -mfancy-math-387 -mieee-fp -mno-soft-float + CPP_COMPILER_OPTIONS = $(P_INCL) -D_LIB -DTARGET_EXE_STANDALONE -g -O1 -frtti -c -fno-strict-aliasing + #CPP_COMPILER_OPTIONS = -c $(P_INCL) -D_LIB -g -O1 -frtti -Wall -pedantic -Wreturn-type -Wformat -Wuninitialized -ffunction-sections -fexpensive-optimizations -fstack-check -fexceptions -Wcast-align -Wshadow -Wunused -Wunused-value -Wunused-variable -Wunused-function -fsigned-char -Wcast-qual -Wconversion -Wmissing-braces -Wredundant-decls -Wsign-compare -Wfloat-equal -Wwrite-strings -mfancy-math-387 -mieee-fp -mno-soft-float else - CPP_COMPILER_OPTIONS = $(P_INCL) -D_LIB -DTARGET_EXE_STANDALONE -ansi -O2 -frtti -c -fno-strict-aliasing - #CPP_COMPILER_OPTIONS = -c $(P_INCL) -D_LIB -ansi -O2 -frtti -Wall -pedantic -Wreturn-type -Wformat -Wuninitialized -ffunction-sections -fexpensive-optimizations -fstack-check -fexceptions -Wcast-align -Wshadow -Wunused -Wunused-value -Wunused-variable -Wunused-function -fsigned-char -Wcast-qual -Wconversion -Wmissing-braces -Wredundant-decls -Wsign-compare -Wfloat-equal -Wwrite-strings -mfancy-math-387 -mieee-fp -mno-soft-float + CPP_COMPILER_OPTIONS = $(P_INCL) -D_LIB -DTARGET_EXE_STANDALONE -g -ansi -O1 -frtti -c -fno-strict-aliasing + #CPP_COMPILER_OPTIONS = -c $(P_INCL) -D_LIB -ansi -g -O1 -frtti -Wall -pedantic -Wreturn-type -Wformat -Wuninitialized -ffunction-sections -fexpensive-optimizations -fstack-check -fexceptions -Wcast-align -Wshadow -Wunused -Wunused-value -Wunused-variable -Wunused-function -fsigned-char -Wcast-qual -Wconversion -Wmissing-braces -Wredundant-decls -Wsign-compare -Wfloat-equal -Wwrite-strings -mfancy-math-387 -mieee-fp -mno-soft-float endif #LINKER_OPTIONS = -static-libgcc #LINKER_OPTIONS = -Wall -Wunused -Wunused-function diff --git a/INCHI-1-SRC/INCHI_EXE/inchi-1/gcc/makefile32 b/INCHI-1-SRC/INCHI_EXE/inchi-1/gcc/makefile32 index 71656d6b..dd815448 100644 --- a/INCHI-1-SRC/INCHI_EXE/inchi-1/gcc/makefile32 +++ b/INCHI-1-SRC/INCHI_EXE/inchi-1/gcc/makefile32 @@ -33,31 +33,47 @@ ifeq ($(CCN),$(filter $(CCN),1 2)) ifeq ($(GCC_DETECTED),1) ifeq ($(CLANG_DETECTED),1) # djb-rwth: Choose C compiler if both GCC and Clang are detected -- CCN = 1 for GCC, CCN = 2 for Clang/LLVM -CCN = 1 +CCN = 2 endif endif # === C/C++ Compilers =============== ifeq ($(CCN),2) ifndef C_COMPILER +ifeq ($(OS_ID),0) +C_COMPILER = clang -static +else C_COMPILER = clang +endif $(info Both GCC/G++ and Clang(++)/LLVM detected. Compiling with Clang(++) -- please edit makefile to compile with GCC/G++.) $(info ) endif ifndef CPP_COMPILER +ifeq ($(OS_ID),0) +CPP_COMPILER = clang++ -static +else CPP_COMPILER = clang++ endif +endif ifndef LINKER LINKER = clang++ -s endif else ifndef C_COMPILER +ifeq ($(OS_ID),0) +C_COMPILER = gcc -static +else C_COMPILER = gcc +endif $(info Both GCC/G++ and Clang(++)/LLVM detected. Compiling with GCC/G++ (default) -- please edit makefile to compile with Clang(++)/LLVM.) $(info ) endif ifndef CPP_COMPILER +ifeq ($(OS_ID),0) +CPP_COMPILER = g++ -static +else CPP_COMPILER = g++ endif +endif ifndef LINKER LINKER = g++ -s endif @@ -85,8 +101,8 @@ ifndef P_BASE endif #P_INCL = -I$(P_MAIN) -I$(P_BASE) P_INCL = -I$(P_MAIN) -I$(P_BASE) -C_COMPILER_OPTIONS = $(P_INCL) -m32 -std=c11 -ansi -DCOMPILE_ANSI_ONLY -DTARGET_EXE_STANDALONE -O2 -c -fno-strict-aliasing -CPP_COMPILER_OPTIONS = $(P_INCL) -m32 -D_LIB -DTARGET_EXE_STANDALONE -ansi -O2 -frtti -c -fno-strict-aliasing +C_COMPILER_OPTIONS = $(P_INCL) -m32 -std=c11 -ansi -DCOMPILE_ANSI_ONLY -DTARGET_EXE_STANDALONE -O1 -c -fno-strict-aliasing +CPP_COMPILER_OPTIONS = $(P_INCL) -m32 -D_LIB -DTARGET_EXE_STANDALONE -ansi -O1 -frtti -c -fno-strict-aliasing LINKER_OPTIONS = -m32 INCHI_SRCS = $(P_BASE)/ichi_bns.c \ $(P_BASE)/ichi_io.c \ diff --git a/INCHI-1-SRC/INCHI_EXE/inchi-1/vc14/PropertySheet.props b/INCHI-1-SRC/INCHI_EXE/inchi-1/vc14/PropertySheet.props index 08b2b3e9..73bc6ee6 100644 --- a/INCHI-1-SRC/INCHI_EXE/inchi-1/vc14/PropertySheet.props +++ b/INCHI-1-SRC/INCHI_EXE/inchi-1/vc14/PropertySheet.props @@ -1,8 +1,8 @@ - - - - - - - - + + + + + + + + diff --git a/INCHI-1-SRC/INCHI_EXE/inchi-1/vc14/djb-rwth.ruleset b/INCHI-1-SRC/INCHI_EXE/inchi-1/vc14/djb-rwth.ruleset index 6aa4748c..a56d9ae2 100644 --- a/INCHI-1-SRC/INCHI_EXE/inchi-1/vc14/djb-rwth.ruleset +++ b/INCHI-1-SRC/INCHI_EXE/inchi-1/vc14/djb-rwth.ruleset @@ -1,10 +1,10 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/INCHI-1-SRC/INCHI_EXE/inchi-1/vc14/inchi-1.vcxproj b/INCHI-1-SRC/INCHI_EXE/inchi-1/vc14/inchi-1.vcxproj index 1fbd7edf..8ea18861 100644 --- a/INCHI-1-SRC/INCHI_EXE/inchi-1/vc14/inchi-1.vcxproj +++ b/INCHI-1-SRC/INCHI_EXE/inchi-1/vc14/inchi-1.vcxproj @@ -1,288 +1,288 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {61B178D7-60C1-4DB9-8FF5-D9BCB0C6E66B} - inchi1 - Win32Proj - 10.0 - - - - Application - v143 - NotSet - true - - - Application - v143 - NotSet - true - - - Application - v143 - NotSet - true - - - Application - v143 - NotSet - true - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>14.0.25431.1 - - - ../../bin2/Windows/$(Platform)/$(Configuration)\ - ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ - false - - - ../../bin2/Windows/$(Platform)/$(Configuration)\ - ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ - false - NativeRecommendedRules.ruleset - - - ../../bin2/Windows/$(Platform)/$(Configuration)\ - ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ - false - - - ../../bin2/Windows/$(Platform)/$(Configuration)\ - ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ - false - - - - MaxSpeed - ../../common;../../main;../../cmlpp;../../ICHI_LIB;%(AdditionalIncludeDirectories) - WIN32;DEBUG;_CONSOLE;ADD_CMLPP=0;ADD_AMI_MODE=1;TARGET_EXE_STANDALONE=1;%(PreprocessorDefinitions) - false - Default - MultiThreadedDebug - - Level3 - false - ProgramDatabase - Default - - true - true - - - $(CoreLibraryDependencies);%(AdditionalDependencies) - true - Console - 16000000 - MachineX86 - true - true - - - - - X64 - - - MaxSpeed - ../../common;../../main;../../cmlpp;../../ICHI_LIB;%(AdditionalIncludeDirectories) - WIN32;WIN64;DEBUG;_CONSOLE;ADD_CMLPP=0;ADD_AMI_MODE=1;TARGET_EXE_STANDALONE=1;%(PreprocessorDefinitions) - false - Default - MultiThreadedDebug - - Level3 - false - ProgramDatabase - Default - true - true - - - true - Console - 16000000 - MachineX64 - true - true - - - - - MaxSpeed - true - Speed - ../../common;../../main;../../cmlpp;../../ICHI_LIB;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;ADD_CMLPP=0;ADD_AMI_MODE=1;TARGET_EXE_STANDALONE=1;%(PreprocessorDefinitions) - MultiThreaded - true - - Level3 - false - ProgramDatabase - Default - - - setargv.obj;%(AdditionalDependencies) - true - Console - 16000000 - true - true - MachineX86 - - - - - X64 - - - MaxSpeed - true - ../../common;../../main;../../cmlpp;../../ICHI_LIB;%(AdditionalIncludeDirectories) - WIN32;WIN64;NDEBUG;_CONSOLE;ADD_CMLPP=0;ADD_AMI_MODE=1;TARGET_EXE_STANDALONE=1;%(PreprocessorDefinitions) - MultiThreaded - true - - Level3 - false - ProgramDatabase - Default - - - true - Console - 16000000 - true - true - MachineX64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {61B178D7-60C1-4DB9-8FF5-D9BCB0C6E66B} + inchi1 + Win32Proj + 10.0 + + + + Application + v143 + NotSet + true + + + Application + v143 + NotSet + true + + + Application + v143 + NotSet + true + + + Application + v143 + NotSet + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>14.0.25431.1 + + + ../../bin2/Windows/$(Platform)/$(Configuration)\ + ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ + false + + + ../../bin2/Windows/$(Platform)/$(Configuration)\ + ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ + false + NativeRecommendedRules.ruleset + + + ../../bin2/Windows/$(Platform)/$(Configuration)\ + ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ + false + + + ../../bin2/Windows/$(Platform)/$(Configuration)\ + ../../bin2/Windows/intermediate/$(Platform)/$(Configuration)\ + false + + + + MaxSpeed + ../../common;../../main;../../cmlpp;../../ICHI_LIB;%(AdditionalIncludeDirectories) + WIN32;DEBUG;_CONSOLE;ADD_CMLPP=0;ADD_AMI_MODE=1;TARGET_EXE_STANDALONE=1;%(PreprocessorDefinitions) + false + Default + MultiThreadedDebug + + Level3 + false + ProgramDatabase + Default + + true + true + + + $(CoreLibraryDependencies);%(AdditionalDependencies) + true + Console + 16000000 + MachineX86 + true + true + + + + + X64 + + + MaxSpeed + ../../common;../../main;../../cmlpp;../../ICHI_LIB;%(AdditionalIncludeDirectories) + WIN32;WIN64;DEBUG;_CONSOLE;ADD_CMLPP=0;ADD_AMI_MODE=1;TARGET_EXE_STANDALONE=1;%(PreprocessorDefinitions) + false + Default + MultiThreadedDebug + + Level3 + false + ProgramDatabase + Default + true + true + + + true + Console + 16000000 + MachineX64 + true + true + + + + + MaxSpeed + true + Speed + ../../common;../../main;../../cmlpp;../../ICHI_LIB;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;ADD_CMLPP=0;ADD_AMI_MODE=1;TARGET_EXE_STANDALONE=1;%(PreprocessorDefinitions) + MultiThreaded + true + + Level3 + false + ProgramDatabase + Default + + + setargv.obj;%(AdditionalDependencies) + true + Console + 16000000 + true + true + MachineX86 + + + + + X64 + + + MaxSpeed + true + ../../common;../../main;../../cmlpp;../../ICHI_LIB;%(AdditionalIncludeDirectories) + WIN32;WIN64;NDEBUG;_CONSOLE;ADD_CMLPP=0;ADD_AMI_MODE=1;TARGET_EXE_STANDALONE=1;%(PreprocessorDefinitions) + MultiThreaded + true + + Level3 + false + ProgramDatabase + Default + + + true + Console + 16000000 + true + true + MachineX64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/INCHI-1-SRC/INCHI_EXE/inchi-1/vc14/inchi-1.vcxproj.user b/INCHI-1-SRC/INCHI_EXE/inchi-1/vc14/inchi-1.vcxproj.user index 0f14913f..88a55094 100644 --- a/INCHI-1-SRC/INCHI_EXE/inchi-1/vc14/inchi-1.vcxproj.user +++ b/INCHI-1-SRC/INCHI_EXE/inchi-1/vc14/inchi-1.vcxproj.user @@ -1,4 +1,4 @@ - - - + + + \ No newline at end of file diff --git a/INCHI-1-TEST/Dockerfile b/INCHI-1-TEST/Dockerfile index b483f132..9aeff45e 100644 --- a/INCHI-1-TEST/Dockerfile +++ b/INCHI-1-TEST/Dockerfile @@ -11,6 +11,7 @@ COPY .gitignore /inchi/.gitignore # Include only what's necessary for compiling InChI and running the tests. COPY INCHI-1-SRC/INCHI_BASE /inchi/INCHI-1-SRC/INCHI_BASE COPY INCHI-1-SRC/INCHI_API /inchi/INCHI-1-SRC/INCHI_API +COPY INCHI-1-SRC/INCHI_EXE /inchi/INCHI-1-SRC/INCHI_EXE COPY INCHI-1-TEST /inchi/INCHI-1-TEST # Ignore future changes, i.e., mounted custom files. diff --git a/INCHI-1-TEST/tests/test_executable/conftest.py b/INCHI-1-TEST/tests/test_executable/conftest.py index 4c20bc14..97edb219 100644 --- a/INCHI-1-TEST/tests/test_executable/conftest.py +++ b/INCHI-1-TEST/tests/test_executable/conftest.py @@ -1,6 +1,5 @@ import pytest import subprocess -import re from typing import Callable from pathlib import Path from dataclasses import dataclass @@ -19,65 +18,45 @@ def pytest_addoption(parser): class InchiResult: stdout: str stderr: str - inchi: str - aux_info: str output: str - - -def parse_inchi_from_executable_output(output: str) -> str: - """The RegEx does not validate the InChI. - It's meant to be lenient enough to recognize (almost) any InChI in the output. - See https://chemistry.stackexchange.com/questions/82144/what-is-the-correct-regular-expression-for-inchi. - """ - inchi_regex = re.compile(r"InChI=1S?/\S+(\s|$)") - inchi_match = inchi_regex.search(output) - if inchi_match is None: - print("Executable output does not contain an InChI.") - return "" - - return inchi_match.group() - - -def parse_aux_info_from_executable_output(output: str) -> str: - aux_info_regex = re.compile(r"AuxInfo=\S+(\s|$)") - aux_info_match = aux_info_regex.search(output) - if aux_info_match is None: - print("Executable output does not contain an AuxInfo.") - return "" - - return aux_info_match.group() + log: str + problem: str @pytest.fixture def run_inchi_exe(request, tmp_path: Path) -> Callable: - def _run_inchi_exe(molfile: str, args: str = "") -> InchiResult: + def _run_inchi_exe(input: str, args: str = "") -> InchiResult: + + if "ami" in args.lower(): + raise ValueError("'AMI' is not supported by the test wrapper.") exe_path: str = request.config.getoption("--exe-path") if not Path(exe_path).exists(): raise FileNotFoundError(f"InChI executable not found at {exe_path}.") - write_output_to_stdout = "-STDIO" in args + input_path = tmp_path.joinpath("input") + input_path.write_text(input) - output_path = tmp_path.joinpath("output.txt") - molfile_path = tmp_path.joinpath("tmp.mol") - molfile_path.write_text(molfile) - paths = ( - [molfile_path] if write_output_to_stdout else [molfile_path, output_path] - ) + output_path = tmp_path.joinpath("output") + log_path = tmp_path.joinpath("log") + problem_path = tmp_path.joinpath("problem") result = subprocess.run( - [exe_path, *paths, *args.split()], + [ + exe_path, + *[input_path, output_path, log_path, problem_path], + *args.split(), + ], capture_output=True, text=True, ) - output = result.stdout if write_output_to_stdout else output_path.read_text() return InchiResult( stdout=result.stdout, - stderr=result.stderr, # contains log - inchi=parse_inchi_from_executable_output(output), - aux_info=parse_aux_info_from_executable_output(output), - output=output, # complete output + stderr=result.stderr, + output=output_path.read_text(), + log=log_path.read_text(), + problem=problem_path.read_text(), ) return _run_inchi_exe diff --git a/INCHI-1-TEST/tests/test_executable/helpers.py b/INCHI-1-TEST/tests/test_executable/helpers.py new file mode 100644 index 00000000..bfc5accc --- /dev/null +++ b/INCHI-1-TEST/tests/test_executable/helpers.py @@ -0,0 +1,25 @@ +import re + + +def parse_inchi_from_executable_output(output: str) -> str: + """The RegEx does not validate the InChI. + It's meant to be lenient enough to recognize (almost) any InChI in the output. + See https://chemistry.stackexchange.com/questions/82144/what-is-the-correct-regular-expression-for-inchi. + """ + inchi_regex = re.compile(r"InChI=1S?/\S+(\s|$)") + inchi_match = inchi_regex.search(output) + if inchi_match is None: + print("Executable output does not contain an InChI.") + return "" + + return inchi_match.group() + + +def parse_aux_info_from_executable_output(output: str) -> str: + aux_info_regex = re.compile(r"AuxInfo=\S+(\s|$)") + aux_info_match = aux_info_regex.search(output) + if aux_info_match is None: + print("Executable output does not contain an AuxInfo.") + return "" + + return aux_info_match.group() diff --git a/INCHI-1-TEST/tests/test_executable/test_github_67.py b/INCHI-1-TEST/tests/test_executable/test_github_67.py new file mode 100644 index 00000000..8f1836aa --- /dev/null +++ b/INCHI-1-TEST/tests/test_executable/test_github_67.py @@ -0,0 +1,10 @@ +def test_inchi_to_struct(run_inchi_exe): + # https://pubchem.ncbi.nlm.nih.gov/compound/10785244 + inchi = "InChI=1S/C18H16N4O3S/c1-12-2-8-15(9-3-12)26-11-17(24)21-13-4-6-14(7-5-13)22-18(25)16(23)10-20-19/h2-10,19,23H,11H2,1H3/p+1/b16-10+" + result = run_inchi_exe(inchi, "-InChI2Struct") + + assert "Add/Remove protons error; *Conversion failed*" not in result.stderr + assert ( + "Problems/mismatches: Mobile-H( Stereobonds/cumulenes: Extra undefined)" + in result.stderr + ) diff --git a/INCHI-1-TEST/tests/test_executable/test_pubchem_107.py b/INCHI-1-TEST/tests/test_executable/test_pubchem_107.py index df019d54..e86384ce 100644 --- a/INCHI-1-TEST/tests/test_executable/test_pubchem_107.py +++ b/INCHI-1-TEST/tests/test_executable/test_pubchem_107.py @@ -1,4 +1,5 @@ import pytest +from helpers import parse_inchi_from_executable_output @pytest.fixture @@ -558,7 +559,7 @@ def test_CID_166625356(molfile_CID_166625356, run_inchi_exe): result = run_inchi_exe(molfile_CID_166625356) assert ( "InChI=1S/C40H36BN7O3S3/c1-5-52-24-12-15-27-30(19-24)37-43-35-28-16-13-25(53-6-2)20-31(28)39-45-36-29-17-14-26(54-7-3)21-32(29)38-44-34(27)46(37)41(47(35)39,48(36)38)51-23-10-8-22(9-11-23)18-33(42)40(49)50-4/h8-17,19-21,33H,5-7,18,42H2,1-4H3/t33-,41-/m0/s1" - == result.inchi + == parse_inchi_from_executable_output(result.output) ) @@ -567,7 +568,7 @@ def test_CID_6419481(molfile_CID_6419481, run_inchi_exe): result = run_inchi_exe(molfile_CID_6419481) assert ( "InChI=1S/C16H17N5O2S/c1-21(20-16(17)24)10-11-8-13(9-14(23-2)15(11)22)19-18-12-6-4-3-5-7-12/h3-10,18-19H,1H2,2H3,(H2-,17,20,24)/b11-10-" - == result.inchi + == parse_inchi_from_executable_output(result.output) ) @@ -576,12 +577,12 @@ def test_CID_6419538(molfile_CID_6419538, run_inchi_exe): result = run_inchi_exe(molfile_CID_6419538) assert ( "InChI=1S/C16H17N5O2S/c1-21(20-16(17)24)10-11-8-13(9-14(23-2)15(11)22)19-18-12-6-4-3-5-7-12/h3-10,18-19H,1H2,2H3,(H2-,17,20,24)/b11-10+" - == result.inchi + == parse_inchi_from_executable_output(result.output) ) -@pytest.mark.xfail(strict=True, raises=AssertionError) def test_CID_53234134(molfile_CID_53234134, run_inchi_exe): result = run_inchi_exe(molfile_CID_53234134) - re_result = run_inchi_exe(result.output, "-InChI2Struct") + inchi = parse_inchi_from_executable_output(result.output) + re_result = run_inchi_exe(inchi, "-InChI2Struct") assert "Conversion failed" not in re_result.stderr diff --git a/README.md b/README.md index 666e2d2e..beea52a4 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![build](https://github.com/IUPAC-InChI/InChI/actions/workflows/release.yml/badge.svg)](https://github.com/IUPAC-InChI/InChI/actions/workflows/release.yml) [![GitHub contributors](https://img.shields.io/github/contributors/IUPAC-InChI/InChI.svg)](https://GitHub.com/IUPAC-InChI/InChI/graphs/contributors/) [![GitHub release](https://img.shields.io/github/release/IUPAC-InChI/InChI.svg)](https://github.com/IUPAC-InChI/InChI/releases/) -[![Changelog - v1.07.1](https://img.shields.io/badge/Changelog-v1.07.1-2ea44f)](https://github.com/IUPAC-InChI/InChI/blob/v1.07.1/INCHI-1-DOC/CHANGELOG.md) +[![Changelog - v1.07.2](https://img.shields.io/badge/Changelog-v1.07.2-2ea44f)](https://github.com/IUPAC-InChI/InChI/blob/v1.07.2/INCHI-1-DOC/CHANGELOG.md) [![Software Article - JChemInf](https://img.shields.io/badge/Software_Article-JChemInf-blue)](https://doi.org/10.1186/s13321-021-00517-z) [![Good reads](https://img.shields.io/badge/Goodreads-372213?style=flat&logo=goodreads&logoColor=white)](https://www.inchi-trust.org/inchi-overview-papers-presentations/?wpv_aux_current_post_id=4309&wpv_aux_parent_post_id=4309&wpv_view_count=4473) [![InChI - Web Demo](https://img.shields.io/badge/InChI-Web_Demo-2ea44f)](https://iupac-inchi.github.io/InChI-Web-Demo/) @@ -132,7 +132,7 @@ The [Images](https://github.com/IUPAC-InChI/InChI/tree/main/Images) subfolder co 32-bit: INCHI-1-BIN/windows/32bit - MinGW-w64/GCC + MinGW-w64/Clang(1) @@ -151,7 +151,7 @@ The [Images](https://github.com/IUPAC-InChI/InChI/tree/main/Images) subfolder co 32-bit: INCHI-1-BIN/windows/32bit/dll - MinGW-w64/GCC + MinGW-w64/Clang(1) @@ -162,7 +162,7 @@ The [Images](https://github.com/IUPAC-InChI/InChI/tree/main/Images) subfolder co - Files (given in compressed .gz format) + Files (given in compressed `.zip` format) Location(s) @@ -172,30 +172,50 @@ The [Images](https://github.com/IUPAC-InChI/InChI/tree/main/Images) subfolder co - + inchi-1 (ELF file) - 64-bit: INCHI-1-BIN/linux/64bit/
- 32-bit: INCHI-1-BIN/linux/32bit/ + 64-bit: INCHI-1-BIN/linux/64bit GCC - + + 32-bit: INCHI-1-BIN/linux/32bit + + + Clang/LLVM(2) + + + + libinchi.so.1.07
+ corresponding inchi_main (ELF file) - 64-bit: INCHI-1-BIN/linux/64bit/so/
- 32-bit: INCHI-1-BIN/linux/32bit/so/ + 64-bit: INCHI-1-BIN/linux/64bit/so GCC + + + 32-bit: INCHI-1-BIN/linux/32bit/so + + + Clang/LLVM(2) + + +
+ + +(1) IMPORTANT NOTE: Since 32-bit binaries for Microsoft® Windows operating system have been compiled using MinGW-w64, it has been reported that in certain environments a dynamic link library libgcc_s_dw2-1.dll has to be included in the same folder with the executables. Therefore, libgcc_s_dw2-1.dll has been added to INCHI-1-BIN/windows/32bit and INCHI-1-BIN/windows/32bit/dll folders (we would like to thank nbehrnd for his assistance with this matter). +
+(2) In order to make makefile32s more consistent on all operating systems (see the note (1) above), and for easier change of the default compiler, the default compiler on 32-bit UNIX-based OSs has been set to Clang/LLVM.
Precompiled binaries for MacOS® (i.e. .app executables and .dylib libraries) will be provided very soon. Until then, please note that InChI can now be compiled from source on MacOS® using native/default Clang or GCC (if installed). @@ -219,17 +239,22 @@ For `GCC` and `Clang/LLVM` compilers, `InChI v.1.07` can be compiled from the so -`makefile/makefile32` files are configured to detect OSs automatically, so it is no longer needed to specify OS explicitly or run batch/bash script(s) before compiling. -`GCC` and `Clang/LLVM` compilers are also automatically detected by `makefile/makefile32` files, with `GCC` set as default compiler. -If both `GCC` and `Clang/LLVM` compilers are installed, setting `Clang/LLVM` as default compiler can be done simply by changing `CCN` parameter from value `1` to `2` in `makefile/makefile32`. +New features in `makefile/makefile32`: +- `makefile/makefile32` files are configured to detect OSs automatically, so it is no longer needed to specify OS explicitly or run batch/bash script(s) before compiling. +- `GCC` and `Clang/LLVM` compilers are also automatically detected by `makefile/makefile32` files with: + - `GCC` set as a default compiler on 64-bit platforms + - `Clang/LLVM` set as a default compiler on 32-bit platforms (please refer to these notes for more details). +- If both `GCC` and `Clang/LLVM` compilers are installed, setting a default compiler can be done simply by changing `CCN` parameter in `makefile/makefile32` where: + - `CCN = 1` corresponds to `GCC` + - `CCN = 2` corresponds to `Clang/LLVM`. Support for native/default MacOS® `Clang` compiler is now provided with 64-bit versions of `makefile` files (we would like to thank John Mayfield for his assistance with this matter). -If `makefile/makefile32` is used for compiling `libinchi` on Microsoft® Windows, `libinchi.dll` is now generated instead of `libinchi.so.1.07`. +If `makefile/makefile32` is used for compiling `libinchi` on Microsoft® Windows, `libinchi.dll` is now generated instead of `libinchi.so.1.07`. Also. please make sure to read the notes regarding the required libgcc_s_dw2-1.dll for running 32-bit executables on Microsoft® Windows operating system in certain environments. **Additional notes**: -- [Intel® oneAPI DPC++/C++](https://www.intel.com/content/www/us/en/developer/tools/oneapi/dpc-compiler.html) compiler support for UNIX-based OSs/MacOS® will be available in `v.1.07.2`. Please note that the support will **not** be provided for [Intel® C++ Compiler Classic (icc)](https://www.intel.com/content/www/us/en/developer/articles/release-notes/oneapi-c-compiler-release-notes.html) as it has been discontinued since `oneAPI 2024.0 release`. +- [Intel® oneAPI DPC++/C++](https://www.intel.com/content/www/us/en/developer/tools/oneapi/dpc-compiler.html) compiler support for UNIX-based OSs/MacOS® will be available starting from `InChI v.1.07.2`. Please note that the support will **not** be provided for [Intel® C++ Compiler Classic (icc)](https://www.intel.com/content/www/us/en/developer/articles/release-notes/oneapi-c-compiler-release-notes.html) as it has been discontinued since `oneAPI 2024.0 release`. - Compiling from source using [CMake](https://en.wikipedia.org/wiki/CMake) will be available soon. In the meantime, you can check [Gianluca Sforna's fork](https://github.com/giallu/InChI/tree/giallu/port_to_cmake). #### Known issues @@ -288,7 +313,7 @@ Some of the experimental/engineering/hidden options featured in `InChI 1.07` whi - In command line version: - - *32-bit* Microsoft® Visual Studio C++ (MSVC) Win32 compiler-specific issue with the following options: + - *32-bit* Microsoft® Visual Studio C++ (MSVC) Win32 and Microsoft® LLVM/Clang compiler-specific issues with the following options: - `AMI` Allow multiple input files (wildcards supported) - `AMIOutStd` Write output to stdout (in AMI mode)