Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/coreutils/dos2unix.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/coreutils/dos2unix.c
r3232 r3621 42 42 { 43 43 FILE *in, *out; 44 int i;44 int ch; 45 45 char *temp_fn = temp_fn; /* for compiler */ 46 46 char *resolved_fn = resolved_fn; … … 50 50 if (fn != NULL) { 51 51 struct stat st; 52 int fd; 52 53 53 54 resolved_fn = xmalloc_follow_symlinks(fn); … … 55 56 bb_simple_perror_msg_and_die(fn); 56 57 in = xfopen_for_read(resolved_fn); 57 fstat(fileno(in), &st);58 xfstat(fileno(in), &st, resolved_fn); 58 59 59 60 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) 62 63 bb_simple_perror_msg_and_die(temp_fn); 64 fchown(fd, st.st_uid, st.st_gid); 63 65 64 out = xfdopen_for_write( i);66 out = xfdopen_for_write(fd); 65 67 } 66 68 67 while (( i= fgetc(in)) != EOF) {68 if ( i== '\r')69 while ((ch = fgetc(in)) != EOF) { 70 if (ch == '\r') 69 71 continue; 70 if ( i== '\n')72 if (ch == '\n') 71 73 if (conv_type == CT_UNIX2DOS) 72 74 fputc('\r', out); 73 fputc( i, out);75 fputc(ch, out); 74 76 } 75 77
Note:
See TracChangeset
for help on using the changeset viewer.