From 8df75422960e38054b7df77eec3700e694bc6732 Mon Sep 17 00:00:00 2001
From: Jonnhy Jazeix <jazeix@gmail.com>
Date: Sat, 4 Apr 2009 14:34:38 +0000
Subject: [PATCH] =?UTF-8?q?D=C3=A9buggage=20pour=20mac.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/parser/TokenSource.cpp | 21 ++++++-----
 src/parser/TokenSource.hpp |  8 ++--
 src/render/render_svg.cpp  |  7 ++--
 src/render/render_svg.hpp  | 76 +++++++++++++++++---------------------
 4 files changed, 53 insertions(+), 59 deletions(-)

diff --git a/src/parser/TokenSource.cpp b/src/parser/TokenSource.cpp
index 3694ea0b..699c8225 100644
--- a/src/parser/TokenSource.cpp
+++ b/src/parser/TokenSource.cpp
@@ -3,10 +3,11 @@
 using namespace std;
 
 int TokenSource::_cursor = 0;
-#ifndef WIN32
-off_t TokenSource::_filesize = 1;
-#else
+
+#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
 std::ifstream TokenSource::_file;
+#else
+off_t TokenSource::_filesize = 1;
 #endif
 
 TokenSource::TokenSource(){
@@ -22,7 +23,7 @@ TokenSource::TokenSource(const char *filename){
 }
 
 TokenSource::~TokenSource(){
-#ifdef WIN32
+#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
     _file.close();
 #else
     if (munmap(_buffer, _filesize) == -1){
@@ -37,7 +38,7 @@ void TokenSource::open(const char *filename){
     
     _is_eof = false;
 
-#ifdef WIN32
+#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
     _file.open(filename, ios::in);
     fill_buffer();
 #else
@@ -62,7 +63,7 @@ void TokenSource::open(const char *filename){
 #endif
 }
 
-#ifdef WIN32
+#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
 bool TokenSource::fill_buffer() {
     if (_file.eof()) {
         return false;
@@ -78,7 +79,7 @@ bool TokenSource::fill_buffer() {
 bool TokenSource::go_to_next_token() {
     while(_buffer[_cursor] == ' ' || _buffer[_cursor] == '\t') {
         _cursor ++;
-#ifdef WIN32
+#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
         if (_cursor >= _buffer_size) {
             if (!fill_buffer()) {
                 return true;
@@ -96,7 +97,7 @@ bool TokenSource::go_to_next_token() {
 
 void TokenSource::build_composite_token() {
     _cursor ++;
-#ifdef WIN32
+#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
     if (_cursor == _buffer_size) {
         if (!fill_buffer()) {
 	    Error::set_and_print(Error::_FSTAT, Error::_WARNING);
@@ -136,7 +137,7 @@ void TokenSource::build_simple_token() {
 }
 
 bool TokenSource::ensure_capacity() {
-#ifdef WIN32
+#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
     if (_cursor >= _buffer_size) {
         if (!fill_buffer()) {
             _is_eof = true;
@@ -203,7 +204,7 @@ std::string *TokenSource::read_token() {
 
 int TokenSource::get_size_loaded() {
 
-#ifdef WIN32
+#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
     if (_file == NULL)
         return 1;
 
diff --git a/src/parser/TokenSource.hpp b/src/parser/TokenSource.hpp
index 89a82a94..ff487eaf 100644
--- a/src/parser/TokenSource.hpp
+++ b/src/parser/TokenSource.hpp
@@ -10,7 +10,7 @@
 
 #include "../message/Errors.hpp"
 
-#ifdef WIN32 // They do not have mmap
+#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES) // They do not have mmap
     #define BUFFER_SIZE 2048
     #define WORD_SIZE 64
     #include <fstream>
@@ -32,7 +32,7 @@ class TokenSource{
   
 private:
     
-#ifdef WIN32
+#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
     char _buffer[BUFFER_SIZE];
 #else
     char* _buffer;
@@ -43,7 +43,7 @@ private:
 
     bool _is_eof;
    
-#ifdef WIN32
+#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
     int _buffer_size;
     static std::ifstream _file;
 #else
@@ -52,7 +52,7 @@ private:
 #endif
   
     
-#ifdef WIN32
+#if defined (WIN32) || !defined(_POSIX_MAPPED_FILES)
     bool fill_buffer();
 #endif
 
diff --git a/src/render/render_svg.cpp b/src/render/render_svg.cpp
index cd962670..feb92654 100644
--- a/src/render/render_svg.cpp
+++ b/src/render/render_svg.cpp
@@ -10,6 +10,7 @@ Element_pos Svg::_wide_factor = 200.;
 Element_pos Svg::_height_factor = 20.;
 double Svg::_epsilon = 0.1;
 double Svg::_scale_frequency = 50.;
+const double Svg::_MARGINSTATE = 0.5;
 
 void Svg::init(const char *path){
 
@@ -134,8 +135,8 @@ void Svg::display_time_scale() {
     _total_width = _total_time;
 
     Element_pos w = _total_width*_wide_factor;
-    Element_pos h =  (MARGINTOP*1.0)/2;
-    Element_pos x = _container_width_max + MARGINSTATE;
+    Element_pos h =  (_MARGINTOP*1.0)/2;
+    Element_pos x = _container_width_max + _MARGINSTATE;
     Element_pos y = 0;
 
     Element_col r = 255;
@@ -164,7 +165,7 @@ void Svg::display_time_scale() {
     
     for(Element_pos i = _start_interval_time ; i < _total_time ; i+=inc) {
             
-        x = i*_wide_factor + _container_width_max + MARGINSTATE -_start_interval_time*_wide_factor;
+        x = i*_wide_factor + _container_width_max + _MARGINSTATE -_start_interval_time*_wide_factor;
       
         _time_scale << "<text x='" << x <<"' y='" << y + h << "'>|";
         _time_scale << i;
diff --git a/src/render/render_svg.hpp b/src/render/render_svg.hpp
index 9a45ffcf..9fe572fe 100644
--- a/src/render/render_svg.hpp
+++ b/src/render/render_svg.hpp
@@ -9,18 +9,10 @@
 #include <sstream>
 #include <fstream>
 
-       
-
-
 
 #include "render.hpp"
 #include "resource.hpp"
 
-
-
-
-
-
 /*!
  * \brief This class provides a SVG display ,it inherited from the Render interface.
  */
@@ -51,7 +43,7 @@ private:
 
     /*!
      * \brief State of the chronogramme drawer automaton
-     * the automaton can be INIT, WAIT_FOR_POINT and WAIT_NEW_CHRONO
+     * the automaton can be _INIT, _WAIT_FOR_POINT and _WAIT_NEW_CHRONO
      */
     int _chronogramme_state;
 
@@ -115,38 +107,38 @@ public:
     /*!
      * \brief Distance between two container
      */
-    static const double MARGIN = 10.;
+    static const int _MARGIN = 10;
 
     /*!
      * \brief Spike size
      */
-    static const double ARROWSIZE  = 2.;     
+    static const int _ARROWSIZE = 2;
 
 
     /*!
      * \brief Distance between two states
      */
-    static const double MARGINSTATE = 0.5;
-
+    static const double _MARGINSTATE;
+    
     /*!
      * \brief offset between the top and the picture due to the scale
      */
-    static const double MARGINTOP = 20.;
+    static const int _MARGINTOP = 20;
 
     /*!
      * \brief a State of chronogramme drawer automaton 
      */
-    static const double WAIT_NEW_CHRONO = 0.;
+    static const int _WAIT_NEW_CHRONO = 0;
 
     /*!
      * \brief a State of chronogramme drawer automaton
      */
-    static const double INIT = 1.;
+    static const int _INIT = 1;
 
     /*!
      * \brief a State of chronogramme drawer automaton
      */
-    static const double WAIT_FOR_POINT = 2.;
+    static const int _WAIT_FOR_POINT = 2;
 
 
     /*!
@@ -378,9 +370,9 @@ inline void Svg::draw_container_text(const Element_pos x, const Element_pos y, c
   
     Element_pos xprime,yprime;
 
-    /*positions are translated to MARGINTOP            : the upper region reserved for scale*/
+    /*positions are translated to _MARGINTOP            : the upper region reserved for scale*/
     /*heights are grown by _height_factor              : conversion from time in ms to pixel*/
-    yprime =  _height_factor*y + MARGINTOP;
+    yprime =  _height_factor*y + _MARGINTOP;
     xprime =  _height_factor*x;
 
     _thin_element_buffer << "<text x='" << xprime <<"' y='" << yprime << "'> ";
@@ -408,7 +400,7 @@ inline void Svg::end_draw_states(){
  *******************/
 
 inline void Svg::start_draw_counter(){
-    _chronogramme_state = INIT;
+    _chronogramme_state = _INIT;
  
 }
 
@@ -418,32 +410,32 @@ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
     /*widths are widen by _wide_factor                 : conversion from time in ms to pixel*/
     /*heights are grown by _height_factor              : conversion from time in ms to pixel*/
     /*positions are translated to _container_width_max : the left region occupied by containers*/
-    /*positions are translated to MARGINTOP            : the upper region reserved for scale*/
+    /*positions are translated to _MARGINTOP            : the upper region reserved for scale*/
     /*whenever a time selection is set                 : positions are translated to -_start_interval_time (in ms, ie  -_start_interval_time*_wide_factor pixel)*/
 
-    Element_pos xprime = x*_wide_factor +  _container_width_max  ;
-    Element_pos yprime = y* _height_factor + MARGINTOP;
+    Element_pos xprime = x*_wide_factor +  _container_width_max;
+    Element_pos yprime = y* _height_factor + _MARGINTOP;
     Element_pos switchvalue = _container_width_max;
 
  
   
-    if (_chronogramme_state == INIT) {
+    if (_chronogramme_state == _INIT) {
         if (xprime == switchvalue) {
            
             _chronogramme << "\n<path d='M"<< xprime +  _start_interval_time*_wide_factor << " " << yprime;
-            _chronogramme_state=WAIT_FOR_POINT;
+            _chronogramme_state=_WAIT_FOR_POINT;
         }
         else
             std::cerr<<"draw_counter not initialised";
 	  
     }
-    else if (_chronogramme_state == WAIT_FOR_POINT) {
+    else if (_chronogramme_state == _WAIT_FOR_POINT) {
         if (xprime == switchvalue) {
            
             _chronogramme << "'/>";
             _svg_file.write(_chronogramme.str().c_str(), _chronogramme.str().size());
             _chronogramme.str("");
-            _chronogramme_state=WAIT_NEW_CHRONO;
+            _chronogramme_state=_WAIT_NEW_CHRONO;
         }
         else {
             if (_end_interval_time && x > _end_interval_time)
@@ -460,10 +452,10 @@ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
       
     }
   
-    else  if (_chronogramme_state==WAIT_NEW_CHRONO) {
+    else  if (_chronogramme_state==_WAIT_NEW_CHRONO) {
         if (xprime==switchvalue) {
             _chronogramme << "\n<path d='M"<< xprime +  _start_interval_time*_wide_factor<< " " << yprime;
-            _chronogramme_state=WAIT_FOR_POINT;
+            _chronogramme_state=_WAIT_FOR_POINT;
         }
         else
             std::cerr<<"draw_counter not initialised";
@@ -475,7 +467,7 @@ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){
 }
 
 inline void Svg::end_draw_counter() {
-    if (_chronogramme_state!=WAIT_NEW_CHRONO && _chronogramme_state!=INIT)
+    if (_chronogramme_state!=_WAIT_NEW_CHRONO && _chronogramme_state!=_INIT)
         std::cerr<<"draw_counter not un-initialised";
 }
 
@@ -583,21 +575,21 @@ inline void Svg::draw_arrow(const Element_pos start_time, const Element_pos end_
     /*width are widen by _wide_factor                  : conversion from time in ms to pixel*/
     /*heights are grown by _height_factor              : conversion from time in ms to pixel*/
     /*positions are translated to _container_width_max : the left region occupied by containers*/
-    /*positions are translated to MARGINTOP            : the upper region reserved for scale*/
+    /*positions are translated to _MARGINTOP            : the upper region reserved for scale*/
     /*whenever a time selection is set                 : states are translated to -_start_interval_time (in ms, ie  -_start_interval_time*_wide_factor pixel)*/
 
   
     Element_pos x1=start_timeprime*_wide_factor +  _container_width_max -_start_interval_time*_wide_factor ;
-    Element_pos y1=start_heightprime* _height_factor + MARGINTOP;
+    Element_pos y1=start_heightprime* _height_factor + _MARGINTOP;
     Element_pos x2=end_timeprime*_wide_factor+  _container_width_max -_start_interval_time*_wide_factor;
-    Element_pos y2=end_heightprime* _height_factor + MARGINTOP;
+    Element_pos y2=end_heightprime* _height_factor + _MARGINTOP;
 
 
     /*an arrow :*/
     Svg::line("arrow",x1 ,y1 ,x2,y2);
 
     if (!trunc)
-        Svg::triangle("arrow",x2 ,y2+ARROWSIZE,x2 ,y2-ARROWSIZE,x2+ARROWSIZE,y2);
+        Svg::triangle("arrow",x2 ,y2+_ARROWSIZE,x2 ,y2-_ARROWSIZE,x2+_ARROWSIZE,y2);
   
   
 }
@@ -616,10 +608,10 @@ inline void Svg::draw_container(const Element_pos x, const Element_pos y, const
     }
 
     /*parameters are grown                             : conversion from time in ms to pixel*/
-    /*positions are translated to MARGINTOP            : the upper region reserved for scale*/
+    /*positions are translated to _MARGINTOP            : the upper region reserved for scale*/
     wprime =  _height_factor*w;
     hprime =  _height_factor*h;
-    yprime =  _height_factor*y + MARGINTOP;
+    yprime =  _height_factor*y + _MARGINTOP;
     xprime =  _height_factor*x;
 
  
@@ -628,7 +620,7 @@ inline void Svg::draw_container(const Element_pos x, const Element_pos y, const
   
 
   
-  _container_width_max = std::max(wprime+xprime+ MARGIN,_container_width_max);
+  _container_width_max = std::max(wprime+xprime+ _MARGIN,_container_width_max);
   _container_height_min = std::min(hprime,_container_height_min);
 }
 
@@ -677,15 +669,15 @@ inline void Svg::draw_state(const Element_pos start , const Element_pos end, con
     /*states are widen by _wide_factor              : conversion from time in ms to pixel*/
     /*states are grown by _height_factor            : conversion from time in ms to pixel*/
     /*states are translated to _container_width_max : the left region occupied by containers*/
-    /*states are translated to MARGINSTATE          : the margin between two container*/
-    /*states are translated to MARGINTOP            : the upper region reserved for scale*/
+    /*states are translated to _MARGINSTATE          : the margin between two container*/
+    /*states are translated to _MARGINTOP            : the upper region reserved for scale*/
     /*states height is not the specified parameter  : container_height_min replaces height which enable the state to have an uniform size */
     /*whenever a time selection is set              : states are translated to -_start_interval_time (in ms, ie  -_start_interval_time*_wide_factor pixel)*/
   
     w = endprime*_wide_factor-startprime*_wide_factor;
     h = _container_height_min;
-    x = (startprime )*_wide_factor + _container_width_max + MARGINSTATE -_start_interval_time*_wide_factor;
-    y = level* _height_factor + MARGINTOP;
+    x = (startprime )*_wide_factor + _container_width_max + _MARGINSTATE -_start_interval_time*_wide_factor;
+    y = level* _height_factor + _MARGINTOP;
 
 
     if(w < _epsilon){
@@ -719,7 +711,7 @@ inline  void Svg::draw_event(const Element_pos time, const Element_pos height, c
 
     _total_time = std::max( _total_time,time);
 
-  Svg::rectangle("event",MARGINSTATE,_container_height_min, time +  _container_width_max -_start_interval_time*_wide_factor, height + MARGINTOP, 0x17, 0x60, 0xe7);
+  Svg::rectangle("event",_MARGINSTATE,_container_height_min, time +  _container_width_max -_start_interval_time*_wide_factor, height + _MARGINTOP, 0x17, 0x60, 0xe7);
   
 }
 
-- 
GitLab