[ragel-users] BUG while processing import directive
alexander.me at gmail.com
Tue Jul 19 10:42:25 UTC 2011
Hi Adrian, Joseph.
I want to express some ideas about cross-platform ragel.
Joseph may add something, or offer the best solutions require minimal changes.
ragel Windows specific code somewhere uses _WIN32 define, but
IMHO it is better do not use _MSC_VER because _MSC_VER define is set
only for Microsoft VC compiler and contain it's version code.
_WIN32 define is used by all (as far as I know), compilers for Windows.
I myself often use this design:
somewhere in the general Include file that is included in all *. cpp files using
# Ifndef __WIN32__
# If defined (_WIN32) | | defined (WIN32)
# Define __WIN32__
and further where necessary
# Ifdef __WIN32__
I found that in the main.cpp include unistd.h twice.
Also, there is no unistd.h header file in Windows, and I and Joseph
have to create empty file to compile the project.
Could you move include unistd.h to use it only for unix-like systems.
# Ifdef __WIN32__
# Include <unistd.h>
Fix it - 3 seconds.
About the problem with '\' and '/' in paths.
I totally agree with Joseph. The first thing you may do - it does
not handle escape sequences in strings that can are the paths of
This is a strings in "include" and "import" directives.
The situation on the one hand is simple - if _WIN32 use '\' in a way
or another, '/', but the other is
some exotics. As I understand it when running under Windows in
Minwig-cigwin-... and other shells, we sometimes get
that even so we should strictly be used '/'-unix separator.
Possible ways how to solve the problem:
- Solution 1.
all strings that are paths - copy in a separate buffer, and
always use '\' to '/' replacement for them.
when concatenating paths with '/' always.
because '/' path work on all systems (windows, * nix, mac). We
simply adjust the path if the user uses the '\'.
- Solution 2
you can create a global variable that will contain the correct
path separator character.
correct path separator character will detect at startup.
For example you can try using argv  (first argument - the
name of the program)
to create path like ".\ragel" - and try opening the file read-only.
if this is possible - then the system in which we started using
'\' as path separator.
save it in a global variable and use later .
Or you can get an environment variable using the getenv (eg
PATH), which will always contain the path to search.
scan the resulting string and find it '/' or '\' - this is the
- Maybe even some ideas:)))
ragel-users mailing list
ragel-users at complang.org
More information about the ragel-users