Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/coreutils/dos2unix.c

    r3232 r3621  
    4242{
    4343    FILE *in, *out;
    44     int i;
     44    int ch;
    4545    char *temp_fn = temp_fn; /* for compiler */
    4646    char *resolved_fn = resolved_fn;
     
    5050    if (fn != NULL) {
    5151        struct stat st;
     52        int fd;
    5253
    5354        resolved_fn = xmalloc_follow_symlinks(fn);
     
    5556            bb_simple_perror_msg_and_die(fn);
    5657        in = xfopen_for_read(resolved_fn);
    57         fstat(fileno(in), &st);
     58        xfstat(fileno(in), &st, resolved_fn);
    5859
    5960        temp_fn = xasprintf("%sXXXXXX", resolved_fn);
    60         i = xmkstemp(temp_fn);
    61         if (fchmod(i, st.st_mode) == -1)
     61        fd = xmkstemp(temp_fn);
     62        if (fchmod(fd, st.st_mode) == -1)
    6263            bb_simple_perror_msg_and_die(temp_fn);
     64        fchown(fd, st.st_uid, st.st_gid);
    6365
    64         out = xfdopen_for_write(i);
     66        out = xfdopen_for_write(fd);
    6567    }
    6668
    67     while ((i = fgetc(in)) != EOF) {
    68         if (i == '\r')
     69    while ((ch = fgetc(in)) != EOF) {
     70        if (ch == '\r')
    6971            continue;
    70         if (i == '\n')
     72        if (ch == '\n')
    7173            if (conv_type == CT_UNIX2DOS)
    7274                fputc('\r', out);
    73         fputc(i, out);
     75        fputc(ch, out);
    7476    }
    7577
Note: See TracChangeset for help on using the changeset viewer.