Commit graph

1488 commits

Author SHA1 Message Date
Jeff Epler
84472921c1 Don't open part 21 files as text files
On Windows, when a file is opened in "text" mode, but it actually
contains Unix-style line endings, the behavior of tellg() is
unexpected.

Consider this program which puts the (binary) contents "a\nb\n" in a
file, then opens it in text mode for reading.  It prints each
character read, along with the value returned by tellg():

    #include <iostream>
    #include <fstream>

    int main()
    {
        {
            std::ofstream f("myfile.txt", std::ios::binary);
            f << "a\nb\n";
        }

        std::ifstream f("myfile.txt");

        for (char c=0; f.get(c);)
            std::cout << f.tellg() << ' ' << int(c) << '\n';
    }

On a UNIX platform which does not have a distinction between "text"
and "binary" files, the output will read
    1 97
    2 10
    3 98
    4 10
because the file position simply advances one position after each
byte is read.

On Windows with the Visual Studio C and C++ runtime, the result is
instead
    -1 97
    1 10
    2 98
    4 10
While it is impossible to say exactly what the Windows runtime is
doing here, it appears that it is trying to adjust for the mismatch
between "number of bytes read in byte oriented mode and "number of
bytes read in text mode".

Since "part21" files don't necessarily contain CRLF line endings
when viewed in binary mode, open the file in binary mode.  This
fixes the test failure seen on appveyor ci running the
"test_inverse_attr3" test.
2017-08-21 17:11:50 -05:00
Mark
a96336ab97 Merge pull request #351 from stepcode/review/327
Review/327
2017-08-13 20:46:34 -04:00
Kunda
15afe96d67 Fixed typos showing up as ascii chars
Using http://www.lisi.ensma.fr/ftp/enseignement/A3_Master_Ingenierie_donnees/fonctionsGrammaire_EXPRESS.pdf I was able to fix typos in the text files for Builtin.py
2017-03-04 07:22:46 -05:00
Cliff Yapp
8627627c5e Add an option to completely bypass the git management of the version header. 2016-08-06 13:53:12 -04:00
Cliff Yapp
a243b4d8c8 Separate shared and static generated files for better parallel building safety. 2016-08-06 11:55:38 -04:00
Cliff Yapp
daec3e2640 Add option handling to the SC target macros, replacing the EXCLUDE_FROM_INSTALL macro. 2016-08-06 11:43:59 -04:00
Cliff Yapp
06b13bb9af Make a stab at adapting the new, simplier verification to vanilla stepcode 2016-08-06 11:23:34 -04:00
Mark Pictor
a160cc9af6 fix #327 - statically initialize t_sdaiINTEGER etc 2015-08-30 11:57:58 -04:00
Mark Pictor
677261d4fb fix LNK2004 getEDesc already defined in sectionReader.obj
is this really the only/best way to fix this?!
2015-08-09 23:36:54 -04:00
Mark Pictor
4207a46f07 fix MSVC link error for NilSTEPentity 2015-08-09 23:30:13 -04:00
Mark Pictor
7316fe5070 msvc warnings/errors 2015-08-09 23:29:15 -04:00
Mark Pictor
4d32009592 'register' storage class specifier is deprecated [-Wdeprecated-register] 2015-08-03 22:00:22 -04:00
Mark Pictor
0b6078b72b missing include 2015-08-03 21:55:00 -04:00
Mark Pictor
36e34862cc cllazyfile: work around LNK2005 error. had to tweak class members so MSVC didn't see MgrNodeBase class twice.
suspect there is a better solution, but I'm not sure what it would be
2015-08-03 21:50:19 -04:00
Mark Pictor
9dcb6aa640 build judy array as part of base lib, else import/export macros don't work 2015-08-03 21:38:37 -04:00
Mark Pictor
bc5533bda8 test for, and use, nullptr if we have it 2015-08-03 21:37:28 -04:00
Mark Pictor
b890c156f5 attempt to silence msvc linker errors 2015-08-02 22:50:26 -04:00
Mark Pictor
f2247d222f use COMPILE_DEFINITIONS property for definitions 2015-08-02 15:58:04 -04:00
Mark Pictor
5288026043 add windows dll import/export macros to cllazyfile 2015-08-02 15:57:10 -04:00
Mark Pictor
46c37207da replace c++ style comments recently introduced with c-style comments 2015-07-26 16:59:42 -04:00
Mark Pictor
ecde882d5a oops, forgot export macro for path2str 2015-07-26 14:32:43 -04:00
Mark Pictor
3d90ffdf83 remove yet more CORBA and ObjectStore stuff... surprised it still exists 2015-07-26 14:22:07 -04:00
Mark Pictor
5dfca2ed78 exp2py - remove unused function USEREFout 2015-07-26 14:20:24 -04:00
Mark Pictor
fbf0272d3b indent a listdo/listod 2015-07-26 13:42:52 -04:00
Mark Pictor
c69f9ebab2 fix length check for keyword detection function 2015-07-26 13:42:25 -04:00
Mark Pictor
942fb89f68 cleanup 2015-07-26 13:41:49 -04:00
Mark Pictor
893936b11f printf(...) -> fprintf( stderr, ...): warnings and errors should not be on stdout 2015-07-26 13:39:40 -04:00
Mark Pictor
e4a8be26da resolve MSVC "unknown escape sequence" warning 2015-07-19 18:29:55 -04:00
Christopher Horler
915e0de65f simplification - invocation of t_STRING / t_BINARY guarantees we can use string slicing rather than strip() 2015-07-08 07:59:37 +01:00
Christopher Horler
9c83ba32a9 fix list / params handling 2015-07-07 18:46:19 +01:00
Christopher Horler
13f36c11a8 implement value conversions for simple types 2015-07-07 18:44:58 +01:00
Christopher Horler
6b26410d9d make default implementation take bigger "slurps" looking for PART21_START tokens 2015-07-06 23:55:16 +01:00
Christopher Horler
3e84677ac9 change handling of base_tokens to simplify subclass implementations 2015-07-06 23:52:27 +01:00
Christopher Horler
081cf35855 Update tests function to parse every .stp file in the stepcode tree
(assumes code is under ~/projects/src/stepcode)
2015-07-05 18:36:33 +01:00
Christopher Horler
c1c3bc1077 Lexer improvements
- change way states are used, could give a substantial performance improvement
 - implement a more flexible approach for exchange_file start token search (more extensibile for subclassing)
 - rework/standardise keyword implementation for DATA token

Parser improvements
 - implement error handling for duplicate entity instances
   * parser catches the error, logs it
   * resyncs and continues (the duplicate is ignored)
 - rework the exchange_file structure detection
   * added parser.reset() to allow a more flexible approach to subclassing
2015-07-05 18:27:46 +01:00
Christopher Horler
6351ff38d9 Python 2.6
- replace another dict comprehension
 - ensure new style classes are used in Python 2.6
 - change the way the tokens list is used (improves ability to subclass)
2015-07-05 18:08:33 +01:00
Christopher Horler
a82f7497a6 Python 2.6 doesn't have NullHandler or dict comprehensions 2015-07-05 17:30:40 +01:00
Christopher Horler
eaf9ffc3f3 raise ValueError instead of sys.exit if input doesn't have valid header / or duplicate entity instances 2015-06-24 22:26:34 +01:00
Christopher Horler
b72f4d404a fix typo in rule 2015-06-24 17:59:01 +01:00
Christopher Horler
b31d8ef853 when subclassing due to ply's dir() usage to determine rules a start rule is necessary 2015-06-24 17:24:23 +01:00
Christopher Horler
c865023114 files may contain multiple exchange structures, to allow for this add rudimentary state tracking 2015-06-24 17:22:49 +01:00
Christopher Horler
25ca2a788d make Python Part21 lexer more extensible for writing custom parser rules 2015-06-22 20:38:20 +01:00
Mark Pictor
97731f8611 warning about extra parens 2015-06-13 21:13:04 -04:00
Christopher Horler
e8afb772f1 remove strncpy as we're not using it anyway - fixes crash on enumeration output 2015-06-13 15:35:32 +01:00
Mark Pictor
0eefd769e3 oops, use our own stdbool 2015-06-08 22:53:45 -04:00
Mark Pictor
1c8225f79a eliminate gcc warnings for exp2py 2015-06-08 22:40:38 -04:00
Mark Pictor
2d8a7373fd fix some MSVC warnings 2015-06-08 22:40:38 -04:00
Mark Pictor
2300021416 MSVC warning - multiple default constructors 2015-06-08 22:40:38 -04:00
Mark Pictor
91a2dcacf3 MSVC lacks __func__, use __FUNCTION__ instead 2015-06-08 22:40:38 -04:00
Mark Pictor
4129d363b0 add stepcore test for segfault in STEPattribute::set_null() 2015-05-20 20:51:14 -04:00