mirror of
https://github.com/depp/syncfiles.git
synced 2024-11-22 03:30:57 +00:00
2768a0c856
GitOrigin-RevId: 2c5ded355b43463d20e6e9e65c32a6c566df82a7
27 lines
583 B
C
27 lines
583 B
C
#include "convert.h"
|
|
|
|
int convert_line_endings(short srcRef, short destRef, void *buf,
|
|
unsigned char srcEnding, unsigned char destEnding) {
|
|
unsigned char *ptr, *end;
|
|
long count;
|
|
int r, r2;
|
|
|
|
do {
|
|
count = kBufferBaseSize;
|
|
r = convert_read(srcRef, &count, buf);
|
|
if (r == kConvertError) {
|
|
return 1;
|
|
}
|
|
for (ptr = buf, end = ptr + count; ptr != end; ptr++) {
|
|
if (*ptr == srcEnding) {
|
|
*ptr = destEnding;
|
|
}
|
|
}
|
|
r2 = convert_write(destRef, count, buf);
|
|
if (r2 != kConvertOK) {
|
|
return 1;
|
|
}
|
|
} while (r != kConvertEOF);
|
|
return 0;
|
|
}
|