#include <stdint.h>
#include <string.h>
#include <unistd.h>
+#include <libgen.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
filebuf = mmap(NULL, sizeof(*envptr) * filesize, PROT_READ,
MAP_PRIVATE, txt_fd, 0);
if (filebuf == MAP_FAILED) {
- fprintf(stderr, "mmap (%ld bytes) failed: %s\n",
+ fprintf(stderr, "mmap (%zu bytes) failed: %s\n",
sizeof(*envptr) * filesize,
strerror(errno));
fprintf(stderr, "Falling back to read()\n");
filebuf = malloc(sizeof(*envptr) * filesize);
ret = read(txt_fd, filebuf, sizeof(*envptr) * filesize);
if (ret != sizeof(*envptr) * filesize) {
- fprintf(stderr, "Can't read the whole input file (%ld bytes): %s\n",
+ fprintf(stderr, "Can't read the whole input file (%zu bytes): %s\n",
sizeof(*envptr) * filesize,
strerror(errno));
/* End of a variable */
envptr[ep++] = '\0';
}
- } else if (filebuf[fp] == '#') {
- if (fp != 0 && filebuf[fp-1] == '\n') {
- /* This line is a comment, let's skip it */
- while (fp < txt_file_stat.st_size && fp++ &&
- filebuf[fp] != '\n');
- } else {
- envptr[ep++] = filebuf[fp];
- }
} else {
envptr[ep++] = filebuf[fp];
}
crc = crc32(0, envptr, envsize);
targetendian_crc = bigendian ? cpu_to_be32(crc) : cpu_to_le32(crc);
- memcpy(dataptr, &targetendian_crc, sizeof(uint32_t));
+ memcpy(dataptr, &targetendian_crc, sizeof(targetendian_crc));
+ if (redundant)
+ dataptr[sizeof(targetendian_crc)] = 1;
if (!bin_filename || strcmp(bin_filename, "-") == 0) {
bin_fd = STDOUT_FILENO;