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

Diff of /trunk/util.c

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

revision 125 by siliconforks, Mon Jun 2 17:52:38 2008 UTC revision 370 by siliconforks, Mon Oct 27 20:34:27 2008 UTC
# Line 47  Line 47 
47    vfprintf(stderr, format, ap);    vfprintf(stderr, format, ap);
48    va_end(ap);    va_end(ap);
49    fputc('\n', stderr);    fputc('\n', stderr);
50      exit(EXIT_FAILURE);
51    }
52    
53    void fatal_command_line(const char * format, ...) {
54      fprintf(stderr, "%s: ", program);
55      va_list ap;
56      va_start(ap, format);
57      vfprintf(stderr, format, ap);
58      va_end(ap);
59      fputc('\n', stderr);
60    fprintf(stderr, "Try `%s --help' for more information.\n", program);    fprintf(stderr, "Try `%s --help' for more information.\n", program);
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) {
75      printf("%s %s\n", program, VERSION);
76      printf("Character encoding support: ");
77    #if HAVE_ICONV
78      printf("iconv\n");
79    #elif HAVE_MULTIBYTETOWIDECHAR
80      printf("MultiByteToWideChar\n");
81    #else
82      printf("none\n");
83    #endif
84      exit(EXIT_SUCCESS);
85    }
86    
87  size_t addst(size_t x, size_t y) {  size_t addst(size_t x, size_t y) {
88    if (SIZE_MAX - x < y) {    if (SIZE_MAX - x < y) {
89      fatal("integer overflow");      fatal("integer overflow");
# Line 352  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 394  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.125  
changed lines
  Added in v.370

  ViewVC Help
Powered by ViewVC 1.1.24