/[jscoverage]/trunk/util.c
ViewVC logotype

Diff of /trunk/util.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 311 by siliconforks, Mon Oct 13 17:51:29 2008 UTC revision 370 by siliconforks, Mon Oct 27 20:34:27 2008 UTC
# Line 61  Line 61 
61    exit(EXIT_FAILURE);    exit(EXIT_FAILURE);
62  }  }
63    
64    void fatal_source(const char * source_file, unsigned int line_number, const char * format, ...) {
65      fprintf(stderr, "%s:%s:%u: ", program, source_file, line_number);
66      va_list ap;
67      va_start(ap, format);
68      vfprintf(stderr, format, ap);
69      va_end(ap);
70      fputc('\n', stderr);
71      exit(EXIT_FAILURE);
72    }
73    
74  void version(void) {  void version(void) {
75    printf("%s %s\n", program, VERSION);    printf("%s %s\n", program, VERSION);
76    printf("Character encoding support: ");    printf("Character encoding support: ");
# Line 375  Line 385 
385    
386    copy_stream(source, destination);    copy_stream(source, destination);
387    
388    #ifndef _WIN32
389      /* copy permissions */
390      struct stat buf;
391      if (fstat(fileno(source), &buf) == -1) {
392        fatal("cannot stat file: %s", source_file);
393      }
394      fchmod(fileno(destination), buf.st_mode);
395    #endif
396    
397    fclose(source);    fclose(source);
398    fclose(destination);    fclose(destination);
399  }  }
# Line 417  Line 436 
436        head = recursive_dir_list(root, entry_wrt_root, head);        head = recursive_dir_list(root, entry_wrt_root, head);
437        free(entry_wrt_root);        free(entry_wrt_root);
438      }      }
439    #ifndef _WIN32
440        else if (S_ISLNK(buf.st_mode)) {
441          /* check what it points to */
442          xstat(entry, &buf);
443          if (S_ISREG(buf.st_mode)) {
444            struct DirListEntry * p = xmalloc(sizeof(struct DirListEntry));
445            p->name = entry_wrt_root;
446            p->next = head;
447            head = p;
448          }
449          else {
450            fatal("refusing to follow symbolic link: %s", entry);
451          }
452        }
453    #endif
454      else {      else {
455        fatal("unknown file type: %s", entry);        fatal("unknown file type: %s", entry);
456      }      }

Legend:
Removed from v.311  
changed lines
  Added in v.370

  ViewVC Help
Powered by ViewVC 1.1.24