Compare commits

...

14 commits

Author SHA1 Message Date
Jeff Epler
c69f31ac08 OK how about 100x 2017-08-16 21:24:54 -05:00
Jeff Epler
9012f5d438 just run test_inverse_attr3 to speed appveyor turnaround 2017-08-16 21:20:34 -05:00
Jeff Epler
e4eabb0108 does opening in binary help? 2017-08-16 17:41:39 -05:00
Jeff Epler
99379a7d0b these test failures are thought to be fixed 2017-08-16 08:24:56 -05:00
Jeff Epler
7f385521a5 Merge remote-tracking branches 'jepler/appveyor-single-thread-test', 'jepler/mac-inverse-attr3-failure', 'jepler/mismatch-new-delete', 'jepler/nullptr-bool', 'jepler/sanitize' and 'jepler/test-parallelism-failures' 2017-08-16 08:21:49 -05:00
Jeff Epler
0b6cd90dd9 Fix test_inverse_attr3 failure
This fixes the failure in test_inverse_attr3 seen on travis ci's osx
build.

Actually, only the change to sectionReader::getRealInstance is
needed to fix the test, but as the reason that 'unget' can fail is
unclear, I changed all instances of 'unget' to use the 'seekg' +
arithmetic method instead.

I failed to find a reason why 'unget' could fail in this way, or
reports of macos-specific failures in 'unget', but I was not
enlightened.

I do not know whether test_inverse_attr3 would *consistently* hang
on Appveyor, but after this change (and modifying .appveyor.yml
to not skip test_inverse_attr3) it did succeed on the first try.
2017-08-16 07:49:13 -05:00
Jeff Epler
4160f3fe8a customize travis for my fork 2017-08-15 21:25:20 -05:00
Jeff Epler
02910b2d38 Match new[] and delete[]
.. this would otherwise cause a memory use error in the unusual case
where a numeric identifer held more letters than expected.

For instance, passing the following file as the input to tst_inverse_attr3:

ISO-10303-21;
HEADER;
FILE_DESCRIPTION(('SCL test file'),'2;1');
FILE_NAME('test_inverse_attr.p21','2012-06-30T',('mp'),(''),'0','1','2');
FILE_SCHEMA(('test_inverse_attr'));
ENDSEC;
DATA;
ENDSEC;
END-ISO-10303-21;

and running it under valgrind can cause a diagnostic similar to the following to be displayed:
Mismatched free() / delete / delete []
   at 0x4C2D2DB: operator delete(void*) (vg_replace_malloc.c:576)
   by 0x507A5A6: sectionReader::readInstanceNumber() (sectionReader.cc:224)
   by 0x507CCC7: lazyP21DataSectionReader::nextInstance() (lazyP21DataSectionReader.cc:53)
   by 0x507C797: lazyP21DataSectionReader::lazyP21DataSectionReader(lazyFileReader*, std::basic_ifstream<char, std::char_traits<char> >&, std::fpos<__mbstate_t>, unsigned short) (lazyP21DataSectionReader.cc:11)
   by 0x50699F2: lazyFileReader::initP21() (lazyFileReader.cc:14)
   by 0x5069E5D: lazyFileReader::lazyFileReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, lazyInstMgr*, unsigned short) (lazyFileReader.cc:61)
] and delete[]
   by 0x506AAA7: lazyInstMgr::openFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (lazyInstMgr.cc:103)
   by 0x4023A1: main (inverse_attr3.cc:35)
 Address 0x6a861a0 is 0 bytes inside a block of size 21 alloc'd
   at 0x4C2C93F: operator new[](unsigned long) (vg_replace_malloc.c:423)
   by 0x507A3A7: sectionReader::readInstanceNumber() (sectionReader.cc:202)

This problem is also reported in static analysis by clang, and as such can be seen in travis ci build logs.
2017-08-15 21:24:23 -05:00
Jeff Epler
3fd71cf457 appveyor build: don't use ctest parallelism
On Windows, concurrent access to files is severely restricted
compared to standard operating systems.  When ctest is invoking
cmake, this causes it to write simultaneously to the same files in
each concurrent cmake invocation, leading to spurious test failures
like

  error MSB3491: Could not write lines to file "...".  The process
  cannot access the file '...' because it is being used by another
  process.

Explicitly ask for no parallelism with "-j1", even though it is
probably the default.
2017-08-15 20:38:47 -05:00
Jeff Epler
1ff41f76a4 sc_version_string: Use temporary names resilient against parallel builds
In #359 I identify a race condition between multiple parallel invocations
of cmake, which can arise naturally during ctests.  Now that the file
contents will not change without an intervening git commit, it is
sufficient to ensure that the parallel invocations use distinct temporary
file names with high probability.
2017-08-15 19:54:05 -05:00
Jeff Epler
a11c373fc7 sc_version_string: omit the date and time
As analyzed in #359, if the header contains the current time, it will
be updated while running the testsuite; this, in turn, causes multiple
cmake processes to attempt to update targets like lib/libexpress.so.2.0.0
at the same time, causing test failures.
2017-08-15 19:47:26 -05:00
Jeff Epler
6f1b5adc3f errordesc.cc: Correctly append a single character to a std::string
The idiom
    char c = ...;
    _userMsg.append( &c );
is not correct C++, because it treats the address of 'c' as a NUL-
terminated C string.  However, this is not guaranteed.

When building and testing on Debian Stretch with AddressSanitizer:
    ASAN_OPTIONS="detect_leaks=false" CXX="clang++" CC=clang CXXFLAGS="-fsanitize=address" LDFLAGS="-fsanitize=address" cmake .. -DSC_ENABLE_TESTING=ON  -DSC_BUILD_SCHEMAS="ifc2x3;ap214e3;ap209"
    ASAN_OPTIONS="detect_leaks=false" make
    ASAN_OPTIONS="detect_leaks=false" ctest . --output-on-failure
an error like the following is encountered:

==15739==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffeb2ca7621 at pc 0x00000043c943 bp 0x7ffeb2ca75d0 sp 0x7ffeb2ca6d80
READ of size 33 at 0x7ffeb2ca7621 thread T0
    #0 0x43c942 in __interceptor_strlen.part.45 (/home/jepler/src/stepcode/build/bin/lazy_sdai_ap214e3+0x43c942)
    #1 0x7fb9056e6143 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::append(char const*) (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0x11f143)
    #2 0x7fb905b677c3 in ErrorDescriptor::AppendToDetailMsg(char) /home/jepler/src/stepcode/src/clutils/errordesc.cc:150:5

Address 0x7ffeb2ca7621 is located in stack of thread T0 at offset 33 in frame
    #0 0x7fb905b676af in ErrorDescriptor::AppendToDetailMsg(char) /home/jepler/src/stepcode/src/clutils/errordesc.cc:149

  This frame has 1 object(s):
    [32, 33) '' <== Memory access at offset 33 overflows this variable

A similar problem with AppendToUserMsg is found by inspection.

After this change, all 200 tests pass under the AddressSanitizer
configuration
2017-08-15 07:51:44 -05:00
Jeff Epler
9df2f19fc6 express/error.c: Ensure the error buffer does not overflow
On Debian Stretch, when configuring stepcode like so:
    ASAN_OPTIONS="detect_leaks=false" CXX="clang++" CXXFLAGS="-fsanitize=address" cmake ..
a fatal error would be detected:

  ==29661==ERROR: AddressSanitizer: heap-buffer-overflow on address
  0x62100001dca0 at pc 0x0000004435e3 bp 0x7ffed6d9cae0 sp 0x7ffed6d9c290

  READ of size 4001 at 0x62100001dca0 thread T0

      #0 0x4435e2 in __interceptor_strlen.part.45 (/home/jepler/src/stepcode/build/bin/schema_scanner+0x4435e2)
      #1 0x501d7b in ERRORreport_with_symbol /home/jepler/src/stepcode/src/express/error.c:413

  0x62100001dca0 is located 0 bytes to the right of 4000-byte region
  [0x62100001cd00,0x62100001dca0)

  allocated by thread T0 here:

      #0 0x4c3ae8 in __interceptor_malloc (/home/jepler/src/stepcode/build/bin/schema_scanner+0x4c3ae8)
      #1 0x5011fc in ERRORinitialize /home/jepler/src/stepcode/src/express/error.c:129

Operations on ERROR_string were unsafe, because they did not guard
against accesses beyond the end of the allocatd region.

This patch ensures that all accesses via *printf functions do respect
the end of the buffer; and encapsulates the routine for pointing
ERROR_string at the space for the next error text to start, if space is
available.

Finally, because it was found with search and replace, a stray manipulation
of ERROR_string within the print-to-file branch of the code is removed.
This stray line would have had the effect of moving ERROR_string one byte
further along at every warning-to-file, which could also have been a
cause of the problem here.
2017-08-15 07:51:44 -05:00
Jeff Epler
0fbc3c0c84 Fix build error with g++ 6.3 (Debian Stretch)
On this platform, TEST_NULLPTR fails, even though nullptr and
nullptr_t are supported:

/home/jepler/src/stepcode/build/CMakeFiles/CMakeTmp/src.cxx:4:23:
    error: converting to 'bool' from 'std::nullptr_t'
    requires direct-initialization [-fpermissive]
 int main() {return !!f();}
                      ~^~

Subsequent to this failure, the workaround definitions in sc_nullptr.h
prevent standard C++ headers (which must refer to real nullptr) to fail.

The failure occurs because the C++ standard apparently does not state
that operator! may be used on nullptr.  Despite this, some compilers
have historically allowed it.  g++ 6.3's behavior appears to be aligned
with the standard.

As requested by @brlcad, ensure that the function 'f' is used from main,
to avoid a clever (but not nullptr-supporting) compiler from somehow
skipping 'f' altogether, creating a false positive for nullptr support.
2017-08-15 06:50:56 -05:00
8 changed files with 164 additions and 64 deletions

View file

@ -2,10 +2,6 @@ version: '{build}'
# for Appveyor CI (windows)
branches:
only:
- master
os: Windows Server 2012 R2
clone_folder: c:\projects\STEPcode
@ -46,19 +42,127 @@ build_script:
cd build
cmake -version
grep --version
cmake .. -DSC_ENABLE_TESTING=ON -G"$env:GENERATOR" -DSC_BUILD_SCHEMAS="ifc2x3;ap214e3;ap209"
echo "filtering build output with grep"
cmake --build . --config Debug | grep -ve "CMake does not need to re-run because" -e "ZERO_CHECK.ZERO_CHECK" -e "^ Creating directory"
cmake .. -DSC_ENABLE_TESTING=ON -G"$env:GENERATOR" -DSC_BUILD_SCHEMAS="ifc2x3"
cmake --build . --config Debug --target tst_inverse_attr3
#msbuld seems to provide no benefits, and I can't filter its output...
#msbuild SC.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Configuration=Debug /p:Platform=x64
# /toolsversion:14.0 /p:PlatformToolset=v140
test_script:
- cmd: echo Running CTest...
- cmd: echo inverse_attr3 test 100x
- cmd: cd c:\projects\STEPcode\build
- cmd: echo excluding test_inverse_attr3, which hangs
- cmd: ctest -j2 . -C Debug -E test_inverse_attr3 --output-on-failure
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: echo 10
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: echo 20
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: echo 30
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: echo 40
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: echo 50
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: echo 60
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: echo 70
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: echo 80
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: echo 90
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: bin\tst_inverse_attr3 ..\test\p21\test_inverse_attr.p21
- cmd: echo 100
- cmd: echo done
# - cmd: grep -niB20 "Test Failed" Testing/Temporary/LastTest.log

View file

@ -3,17 +3,6 @@ language: cpp
compiler:
- clang
script: mkdir build && cd build && cmake .. -DSC_ENABLE_TESTING=ON && make -j3 && ctest -j2 --output-on-failure
branches:
only:
- master
notifications:
irc: "chat.freenode.net#stepcode"
email: scl-dev@groups.google.com
on_success: change
on_failure: always
os:
- linux
- osx
matrix:
allow_failures:
- os: osx

View file

@ -80,7 +80,7 @@ std::cout << \"1s is \"<< std::chrono::duration_cast<std::chrono::milliseconds>(
set( TEST_NULLPTR "
#include <cstddef>
std::nullptr_t f() {return nullptr;}
int main() {return !!f();}
int main() {return !(f() == f());}
" )
cmake_push_check_state()
if( UNIX )

View file

@ -47,37 +47,24 @@ string(REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COMMIT_ID})
#once cmake_minimum_required is >= 2.8.11, we can use TIMESTAMP:
#string(TIMESTAMP date_time_string)
if(UNIX)
execute_process(COMMAND date "+%d %b %Y %H:%M" OUTPUT_VARIABLE date_time_string OUTPUT_STRIP_TRAILING_WHITESPACE)
elseif(WIN32)
execute_process(COMMAND cmd /c date /t OUTPUT_VARIABLE currentDate OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND cmd /c time /t OUTPUT_VARIABLE currentTime OUTPUT_STRIP_TRAILING_WHITESPACE)
set (date_time_string "${currentDate} ${currentTime}")
else()
set(date_time_string "\" __DATE__ \" \" __TIME__ \" ")
if(NOT SC_IS_SUBBUILD)
message(STATUS "Unknown platform - using date from preprocessor")
endif(NOT SC_IS_SUBBUILD)
endif()
set(header_string "/* sc_version_string.h - written by cmake. Changes will be lost! */\n"
"#ifndef SC_VERSION_STRING\n"
"#define SC_VERSION_STRING\n\n"
"/*\n** The git commit id looks like \"test-1-g5e1fb47\", where test is the\n"
"** name of the last tagged git revision, 1 is the number of commits since that tag,\n"
"** 'g' is unknown, and 5e1fb47 is the first 7 chars of the git sha1 commit id.\n"
"** timestamp is created from date/time commands on known platforms, and uses\n"
"** preprocessor macros elsewhere.\n*/\n\n"
"*/\n\n"
"static char sc_version[512] = {\n"
" \"git commit id: ${GIT_COMMIT_ID}, build timestamp ${date_time_string}\"\n"
" \"git commit id: ${GIT_COMMIT_ID}\"\n"
"}\;\n\n"
"#endif\n"
)
#don't update the file unless somethig changed
file(WRITE ${SC_VERSION_HEADER}.tmp ${header_string})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_VERSION_HEADER}.tmp ${SC_VERSION_HEADER})
execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${SC_VERSION_HEADER}.tmp)
string(RANDOM tmpsuffix)
file(WRITE ${SC_VERSION_HEADER}.${tmpsuffix} ${header_string})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_VERSION_HEADER}.${tmpsuffix} ${SC_VERSION_HEADER})
execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${SC_VERSION_HEADER}.${tmpsuffix})
if(NOT SC_IS_SUBBUILD)
message("-- sc_version_string.h is up-to-date.")

View file

@ -50,7 +50,7 @@ instancesLoaded_t * lazyFileReader::getHeaderInstances() {
}
lazyFileReader::lazyFileReader( std::string fname, lazyInstMgr * i, fileID fid ): _fileName( fname ), _parent( i ), _fileID( fid ) {
_file.open( _fileName.c_str() );
_file.open( _fileName.c_str(), std::ios::binary );
_file.imbue( std::locale::classic() );
_file.unsetf( std::ios_base::skipws );
assert( _file.is_open() && _file.good() );

View file

@ -47,7 +47,7 @@ std::streampos sectionReader::findNormalString( const std::string & str, bool se
}
if( c == '\'' ) {
//push past string
_file.unget();
_file.seekg( _file.tellg() - std::streampos(1) );
GetLiteralStr( _file, _lazyFile->getInstMgr()->getErrorDesc() );
}
if( ( c == '/' ) && ( _file.peek() == '*' ) ) {
@ -129,7 +129,7 @@ std::streampos sectionReader::seekInstanceEnd( instanceRefs ** refs ) {
}
break;
case '\'':
_file.unget();
_file.seekg( _file.tellg() - std::streampos(1) );
GetLiteralStr( _file, _lazyFile->getInstMgr()->getErrorDesc() );
break;
case '=':
@ -155,7 +155,7 @@ std::streampos sectionReader::seekInstanceEnd( instanceRefs ** refs ) {
if( _file.get() == ';' ) {
return _file.tellg();
} else {
_file.unget();
_file.seekg( _file.tellg() - std::streampos(1) );
}
}
default:
@ -186,7 +186,7 @@ instanceID sectionReader::readInstanceNumber() {
if( ( c == '/' ) && ( _file.peek() == '*' ) ) {
findNormalString( "*/" );
} else {
_file.unget();
_file.seekg( _file.tellg() - std::streampos(1) );
}
skipWS();
c = _file.get();
@ -210,7 +210,7 @@ instanceID sectionReader::readInstanceNumber() {
digits++;
} else {
_file.unget();
_file.seekg( _file.tellg() - std::streampos(1) );
break;
}
@ -221,7 +221,7 @@ instanceID sectionReader::readInstanceNumber() {
_error->UserMsg( "A very large instance ID encountered" );
_error->DetailMsg( errorMsg.str() );
delete buffer;
delete [] buffer;
return 0;
}
@ -309,7 +309,7 @@ SDAI_Application_instance * sectionReader::getRealInstance( const Registry * reg
assert( inst->getEDesc() );
_file.seekg( begin );
findNormalString( "(" );
_file.unget();
_file.seekg( _file.tellg() - std::streampos(1) );
sev = inst->STEPread( instance, 0, _lazyFile->getInstMgr()->getAdapter(), _file, sName, true, false );
//TODO do something with 'sev'
inst->InitIAttrs();

View file

@ -131,7 +131,7 @@ void ErrorDescriptor::PrependToUserMsg( const char * msg ) {
}
void ErrorDescriptor::AppendToUserMsg( const char c ) {
_userMsg.append( &c );
_userMsg.push_back( c );
}
void ErrorDescriptor::AppendToUserMsg( const char * msg ) {
@ -147,7 +147,7 @@ void ErrorDescriptor::PrependToDetailMsg( const char * msg ) {
}
void ErrorDescriptor::AppendToDetailMsg( const char c ) {
_detailMsg.append( &c );
_detailMsg.push_back( c );
}
void ErrorDescriptor::AppendToDetailMsg( const char * msg ) {

View file

@ -67,6 +67,9 @@
#include "express/info.h"
#include "express/linklist.h"
#if defined( _WIN32 ) || defined ( __WIN32__ )
# define snprintf _snprintf
#endif
bool __ERROR_buffer_errors = false;
const char * current_filename = "stdin";
@ -112,6 +115,7 @@ static struct heap_element {
static int ERROR_with_lines = 0; /**< number of warnings & errors that have occurred with a line number */
static char * ERROR_string;
static char * ERROR_string_base;
static char * ERROR_string_end;
static bool ERROR_unsafe = false;
static jmp_buf ERROR_safe_env;
@ -119,6 +123,28 @@ static jmp_buf ERROR_safe_env;
#define error_file stderr /**< message buffer file */
static int ERROR_vprintf( const char *format, va_list ap ) {
int result = snprintf( ERROR_string, ERROR_string_end - ERROR_string, format, ap );
if(result < 0) ERROR_string = ERROR_string_end;
else if(result > (ERROR_string_end - ERROR_string)) ERROR_string = ERROR_string_end;
else ERROR_string = ERROR_string + result;
return result;
}
static int ERROR_printf( const char *format, ... ) {
int result;
va_list ap;
va_start( ap, format );
result = ERROR_vprintf( format, ap );
va_end( ap );
return result;
}
static void ERROR_nexterror() {
if( ERROR_string == ERROR_string_end ) return;
ERROR_string++;
}
/** Initialize the Error module */
void ERRORinitialize( void ) {
ERROR_subordinate_failed =
@ -127,6 +153,7 @@ void ERRORinitialize( void ) {
ERRORcreate( "%s, expecting %s in %s %s", SEVERITY_EXIT );
ERROR_string_base = ( char * )sc_malloc( ERROR_MAX_SPACE );
ERROR_string_end = ERROR_string_base + ERROR_MAX_SPACE;
ERROR_start_message_buffer();
@ -377,20 +404,14 @@ va_dcl {
heap[child].msg = ERROR_string;
if( what->severity >= SEVERITY_ERROR ) {
sprintf( ERROR_string, "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, what->serial );
ERROR_string += strlen( ERROR_string );
vsprintf( ERROR_string, what->message, args );
ERROR_string += strlen( ERROR_string );
*ERROR_string++ = '\n';
*ERROR_string++ = '\0';
ERROR_printf( "%s:%d: --ERROR PE%03d: ", sym->filename, sym->line, what->serial );
ERROR_vprintf( what->message, args );
ERROR_nexterror();
ERRORoccurred = true;
} else {
sprintf( ERROR_string, "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, what->serial );
ERROR_string += strlen( ERROR_string );
vsprintf( ERROR_string, what->message, args );
ERROR_string += strlen( ERROR_string );
*ERROR_string++ = '\n';
*ERROR_string++ = '\0';
ERROR_printf( "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, what->serial );
ERROR_vprintf( what->message, args );
ERROR_nexterror();
}
if( what->severity >= SEVERITY_EXIT ||
ERROR_string + ERROR_MAX_STRLEN > ERROR_string_base + ERROR_MAX_SPACE ||
@ -410,7 +431,6 @@ va_dcl {
ERRORoccurred = true;
} else {
fprintf( error_file, "%s:%d: WARNING PW%03d: ", sym->filename, sym->line, what->serial );
ERROR_string += strlen( ERROR_string ) + 1;
vfprintf( error_file, what->message, args );
fprintf( error_file, "\n" );
}