summaryrefslogtreecommitdiff
path: root/legacy/edje
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2011-06-17 21:42:27 +0000
committerVincent Torri <vincent.torri@gmail.com>2011-06-17 21:42:27 +0000
commit3c4fd94e9d422d70f8ee181d48b2af2b9457b796 (patch)
tree018132e7ffcde58705cf428b1112882d0d899139 /legacy/edje
parent5f8f61921bae4652c54e2eb2dbbad1b0d576e581 (diff)
epp : use binary mode for (f)open()
SVN revision: 60463
Diffstat (limited to 'legacy/edje')
-rw-r--r--legacy/edje/src/bin/epp/cpplib.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/legacy/edje/src/bin/epp/cpplib.c b/legacy/edje/src/bin/epp/cpplib.c
index c134cbace6..d6c60d2546 100644
--- a/legacy/edje/src/bin/epp/cpplib.c
+++ b/legacy/edje/src/bin/epp/cpplib.c
@@ -56,6 +56,15 @@ void *alloca (size_t);
56#include "cpplib.h" 56#include "cpplib.h"
57#include "cpphash.h" 57#include "cpphash.h"
58 58
59/*
60 * On Windows, if the file is not opened in binary mode,
61 * read does not return the correct size, because of
62 * CR / LF translation.
63 */
64#ifndef O_BINARY
65# define O_BINARY 0
66#endif
67
59const char *version_string = "0.0.0"; 68const char *version_string = "0.0.0";
60 69
61#ifndef STDC_VALUE 70#ifndef STDC_VALUE
@@ -5382,9 +5391,9 @@ read_name_map(cpp_reader * pfile, const char *dirname)
5382 strcat(name, "/"); 5391 strcat(name, "/");
5383 strcat(name, FILE_NAME_MAP_FILE); 5392 strcat(name, FILE_NAME_MAP_FILE);
5384#ifndef __EMX__ 5393#ifndef __EMX__
5385 f = fopen(name, "r"); 5394 f = fopen(name, "rb");
5386#else 5395#else
5387 f = fopen(name, "rt"); 5396 f = fopen(name, "rtb");
5388#endif 5397#endif
5389 if (!f) 5398 if (!f)
5390 map_list_ptr->map_list_map = NULL; 5399 map_list_ptr->map_list_map = NULL;
@@ -5468,7 +5477,7 @@ open_include_file(cpp_reader * pfile, char *filename,
5468 if (!strcmp(map->map_from, from)) 5477 if (!strcmp(map->map_from, from))
5469 { 5478 {
5470 /* Found a match. */ 5479 /* Found a match. */
5471 return open(map->map_to, O_RDONLY, 0666); 5480 return open(map->map_to, O_RDONLY | O_BINARY, 0666);
5472 } 5481 }
5473 } 5482 }
5474 } 5483 }
@@ -5485,7 +5494,7 @@ open_include_file(cpp_reader * pfile, char *filename,
5485 && !strncmp(searchptr->fname, filename, p - filename)) 5494 && !strncmp(searchptr->fname, filename, p - filename))
5486 { 5495 {
5487 /* FILENAME is in SEARCHPTR, which we've already checked. */ 5496 /* FILENAME is in SEARCHPTR, which we've already checked. */
5488 return open(filename, O_RDONLY, 0666); 5497 return open(filename, O_RDONLY | O_BINARY, 0666);
5489 } 5498 }
5490 if (p == filename) 5499 if (p == filename)
5491 { 5500 {
@@ -5504,9 +5513,9 @@ open_include_file(cpp_reader * pfile, char *filename,
5504 } 5513 }
5505 for (map = read_name_map(pfile, dir); map; map = map->map_next) 5514 for (map = read_name_map(pfile, dir); map; map = map->map_next)
5506 if (!strcmp(map->map_from, from)) 5515 if (!strcmp(map->map_from, from))
5507 return open(map->map_to, O_RDONLY, 0666); 5516 return open(map->map_to, O_RDONLY | O_BINARY, 0666);
5508 5517
5509 return open(filename, O_RDONLY, 0666); 5518 return open(filename, O_RDONLY | O_BINARY, 0666);
5510} 5519}
5511 5520
5512#else 5521#else
@@ -5515,7 +5524,7 @@ static int
5515open_include_file(cpp_reader * pfile __UNUSED__, char *filename, 5524open_include_file(cpp_reader * pfile __UNUSED__, char *filename,
5516 file_name_list * searchptr __UNUSED__) 5525 file_name_list * searchptr __UNUSED__)
5517{ 5526{
5518 return open(filename, O_RDONLY, 0666); 5527 return open(filename, O_RDONLY | O_BINARY, 0666);
5519} 5528}
5520 5529
5521#endif /* USE_FILE_NAME_MAPS */ 5530#endif /* USE_FILE_NAME_MAPS */
@@ -5980,7 +5989,7 @@ push_parse_file(cpp_reader * pfile, const char *fname)
5980 { 5989 {
5981 if (pend->cmd && strcmp(pend->cmd, "-imacros") == 0) 5990 if (pend->cmd && strcmp(pend->cmd, "-imacros") == 0)
5982 { 5991 {
5983 int fd = open(pend->arg, O_RDONLY, 0666); 5992 int fd = open(pend->arg, O_RDONLY | O_BINARY, 0666);
5984 5993
5985 if (fd < 0) 5994 if (fd < 0)
5986 { 5995 {
@@ -6002,7 +6011,7 @@ push_parse_file(cpp_reader * pfile, const char *fname)
6002 fname = ""; 6011 fname = "";
6003 f = 0; 6012 f = 0;
6004 } 6013 }
6005 else if ((f = open(fname, O_RDONLY, 0666)) < 0) 6014 else if ((f = open(fname, O_RDONLY | O_BINARY, 0666)) < 0)
6006 cpp_pfatal_with_name(pfile, fname); 6015 cpp_pfatal_with_name(pfile, fname);
6007 6016
6008 /* -MG doesn't select the form of output and must be specified with one of 6017 /* -MG doesn't select the form of output and must be specified with one of
@@ -6124,7 +6133,7 @@ push_parse_file(cpp_reader * pfile, const char *fname)
6124 { 6133 {
6125 if (pend->cmd && strcmp(pend->cmd, "-include") == 0) 6134 if (pend->cmd && strcmp(pend->cmd, "-include") == 0)
6126 { 6135 {
6127 int fd = open(pend->arg, O_RDONLY, 0666); 6136 int fd = open(pend->arg, O_RDONLY | O_BINARY, 0666);
6128 6137
6129 if (fd < 0) 6138 if (fd < 0)
6130 { 6139 {
@@ -6705,7 +6714,7 @@ cpp_finish(cpp_reader * pfile)
6705 if (pfile->errors == 0) 6714 if (pfile->errors == 0)
6706 { 6715 {
6707 const char *deps_mode = 6716 const char *deps_mode =
6708 opts->print_deps_append ? "a" : "w"; 6717 opts->print_deps_append ? "ab" : "wb";
6709 6718
6710 if (!opts->deps_file) 6719 if (!opts->deps_file)
6711 deps_stream = stdout; 6720 deps_stream = stdout;