Diff for /parser3/src/main/pa_common.C between versions 1.328 and 1.333

version 1.328, 2023/11/16 00:40:42 version 1.333, 2024/10/02 22:54:03
Line 12 Line 12
 #include "pa_charsets.h"  #include "pa_charsets.h"
 #include "pa_http.h"  #include "pa_http.h"
 #include "pa_request_charsets.h"  #include "pa_request_charsets.h"
 #include "pcre.h"  
 #include "pa_request.h"  #include "pa_request.h"
   
 #include "pa_idna.h"  #include "pa_idna.h"
Line 332  bool file_write_action_under_lock( Line 331  bool file_write_action_under_lock(
                 } catch(...) {                  } catch(...) {
 #ifdef HAVE_FTRUNCATE  #ifdef HAVE_FTRUNCATE
                         if(!do_append)                          if(!do_append)
                                 ftruncate(f, lseek(f, 0, SEEK_CUR)); // one can not use O_TRUNC, read lower                                  ftruncate(f, lseek(f, 0, SEEK_CUR)); // one cannot use O_TRUNC, read lower
 #endif  #endif
                         pa_unlock(f);close(f);                           pa_unlock(f);close(f); 
                         rethrow;                          rethrow;
Line 756  FormatType format_type(const char* fmt){ Line 755  FormatType format_type(const char* fmt){
 }  }
   
   
 const char* format(double value, const char* fmt) {  const char* format_double(double value, const char* fmt) {
         char local_buf[MAX_NUMBER];          char local_buf[MAX_NUMBER];
         int size=-1;          int size=-1;
   
         if(fmt && strlen(fmt)){          if(fmt && strlen(fmt)){
                 switch(format_type(fmt)){                  switch(format_type(fmt)){
                         case FormatDouble:                          case FormatDouble:
                                 size=snprintf(local_buf, sizeof(local_buf), fmt, value);                                   size=snprintf(local_buf, sizeof(local_buf), fmt, value);
                                 break;                                  break;
                         case FormatUInt:                          case FormatUInt:
                                 if(value >= 0){ // on Apple M1 (uint)<negative value> is 0                                  if(value >= 0){ // on Apple M1 (uint)<negative value> is 0
                                         size=snprintf(local_buf, sizeof(local_buf), fmt, (uint)value);                                          size=snprintf(local_buf, sizeof(local_buf), fmt, clip2uint(value));
                                         break;                                          break;
                                 }                                  }
                         case FormatInt:                          case FormatInt:
                                 size=snprintf(local_buf, sizeof(local_buf), fmt, (int)value);                                   size=snprintf(local_buf, sizeof(local_buf), fmt, clip2int(value));
                                 break;                                  break;
                         case FormatInvalid:                          case FormatInvalid:
                                 throw Exception(PARSER_RUNTIME, 0, "Incorrect format string '%s' was specified.", fmt);                                  throw Exception(PARSER_RUNTIME, 0, "Incorrect format string '%s' was specified.", fmt);
                 }                  }
         } else          } else
                 size=snprintf(local_buf, sizeof(local_buf), "%d", (int)value);                  return pa_itoa(clip2int(value));
   
         if(size < 0 || size >= MAX_NUMBER-1){ // on win32 we manually reduce max size while printing          if(size < 0 || size >= MAX_NUMBER-1){ // on win32 we manually reduce max size while printing
                 throw Exception(PARSER_RUNTIME, 0, "Error occurred white executing snprintf with format string '%s'.", fmt);                  throw Exception(PARSER_RUNTIME, 0, "Error occurred white executing snprintf with format string '%s'.", fmt);

Removed from v.1.328  
changed lines
  Added in v.1.333


E-mail: