Diff for /parser3/src/main/pa_common.C between versions 1.106 and 1.110

version 1.106, 2002/03/27 15:30:36 version 1.110, 2002/06/10 14:37:35
Line 137  bool file_read(Pool& pool, const String& Line 137  bool file_read(Pool& pool, const String&
         //   they delay update till open, so we would receive "!^test[" string          //   they delay update till open, so we would receive "!^test[" string
         //   if would do stat, next open.          //   if would do stat, next open.
     if((f=open(fname, O_RDONLY|(as_text?_O_TEXT:_O_BINARY)))>=0) {      if((f=open(fname, O_RDONLY|(as_text?_O_TEXT:_O_BINARY)))>=0) {
                 lock_shared_blocking(f);                                  if(lock_shared_blocking(f)!=0) {
                           Exception e("file.lock",
                                           &file_spec, 
                                           "shared lock failed: %s (%d), actual filename '%s'", 
                                                   strerror(errno), errno, fname);
                           unlock(f);
                           close(f);
                           if(fail_on_read_problem)
                                   throw e;
                           return false;
                   }
                 if(stat(fname, &finfo)!=0) {                  if(stat(fname, &finfo)!=0) {
                         Exception e("file.missing",                          Exception e("file.missing",
                                         &file_spec,                                           &file_spec, 
Line 151  bool file_read(Pool& pool, const String& Line 161  bool file_read(Pool& pool, const String&
                 }                  }
 #ifdef NO_FOREIGN_GROUP_FILES  #ifdef NO_FOREIGN_GROUP_FILES
                 if(finfo.st_gid/*foreign?*/!=getegid()) {                  if(finfo.st_gid/*foreign?*/!=getegid()) {
                         Exception e("parser.runtime", 0,                          Exception e("parser.runtime",
                                 &file_spec,                                  &file_spec,
                                 "parser reading files of foreign group disabled [recompile parser without --disable-foreign-group-files configure option], actual filename '%s'",                                   "parser reading files of foreign group disabled [recompile parser without --disable-foreign-group-files configure option], actual filename '%s'", 
                                         fname);                                          fname);
Line 216  bool file_write_action_under_lock( Line 226  bool file_write_action_under_lock(
                                 const char *action_name, void (*action)(int, void *), void *context,                                  const char *action_name, void (*action)(int, void *), void *context,
                                 bool as_text,                                  bool as_text,
                                 bool do_append,                                  bool do_append,
                                 bool do_block) {                                  bool do_block,
                                   bool fail_on_lock_problem) {
         const char *fname=file_spec.cstr(String::UL_FILE_SPEC);          const char *fname=file_spec.cstr(String::UL_FILE_SPEC);
         int f;          int f;
         if(access(fname, W_OK)!=0) // no          if(access(fname, W_OK)!=0) // no
Line 227  bool file_write_action_under_lock( Line 238  bool file_write_action_under_lock(
                 |(as_text?_O_TEXT:_O_BINARY)                  |(as_text?_O_TEXT:_O_BINARY)
                 |(do_append?O_APPEND:O_TRUNC), 0664))>=0) {                  |(do_append?O_APPEND:O_TRUNC), 0664))>=0) {
                 if((do_block?lock_exclusive_blocking(f):lock_exclusive_nonblocking(f))!=0) {                  if((do_block?lock_exclusive_blocking(f):lock_exclusive_nonblocking(f))!=0) {
                           Exception e("file.lock",
                                   &file_spec, 
                                   "shared lock failed: %s (%d), actual filename '%s'", 
                                   strerror(errno), errno, fname);
                         close(f);                          close(f);
                           if(fail_on_lock_problem)
                                   throw e;
                         return false;                          return false;
                 }                  }
   
Line 323  static bool entry_readable(const String& Line 340  static bool entry_readable(const String&
     const char *fname=file_spec.cstr(String::UL_FILE_SPEC);      const char *fname=file_spec.cstr(String::UL_FILE_SPEC);
         struct stat finfo;          struct stat finfo;
         if(access(fname, R_OK)==0 && stat(fname, &finfo)==0) {          if(access(fname, R_OK)==0 && stat(fname, &finfo)==0) {
                 bool is_dir=finfo.st_mode&S_IFDIR != 0;                  bool is_dir=(finfo.st_mode&S_IFDIR) != 0;
                 return is_dir==need_dir;                  return is_dir==need_dir;
         }          }
         return false;          return false;
Line 411  char *rsplit(char *string, char delim) { Line 428  char *rsplit(char *string, char delim) {
   
 /// @todo less stupid type detection  /// @todo less stupid type detection
 char *format(Pool& pool, double value, char *fmt) {  char *format(Pool& pool, double value, char *fmt) {
         char *result=(char *)pool.malloc(MAX_NUMBER, 4);          char local_buf[MAX_NUMBER];
           size_t size;
           
         if(fmt)          if(fmt)
                 if(strpbrk(fmt, "diouxX"))                  if(strpbrk(fmt, "diouxX"))
                         if(strpbrk(fmt, "ouxX"))                          if(strpbrk(fmt, "ouxX"))
                                 snprintf(result, MAX_NUMBER, fmt, (uint)value );                                  size=snprintf(local_buf, sizeof(local_buf), fmt, (uint)value);
                         else                          else
                                 snprintf(result, MAX_NUMBER, fmt, (int)value );                                  size=snprintf(local_buf, sizeof(local_buf), fmt, (int)value);
                 else                  else
                         snprintf(result, MAX_NUMBER, fmt, value);                          size=snprintf(local_buf, sizeof(local_buf), fmt, value);
         else          else
                 snprintf(result, MAX_NUMBER, "%d", (int)value);                  size=snprintf(local_buf, sizeof(local_buf), "%d", (int)value);
                   
         return result;          char *pool_buf=(char *)pool.malloc(size+1, 4);
           memcpy(pool_buf, local_buf, size+1);
           return pool_buf;
 }  }
   
 size_t stdout_write(const void *buf, size_t size) {  size_t stdout_write(const void *buf, size_t size) {

Removed from v.1.106  
changed lines
  Added in v.1.110


E-mail: