fix edje_cc on windows, remove some trailing spaces

SVN revision: 31549
This commit is contained in:
doursse 2007-08-27 09:32:17 +00:00 committed by doursse
parent 278279e269
commit 8a6ac30215
3 changed files with 58 additions and 38 deletions

View File

@ -125,7 +125,11 @@ main(int argc, char **argv)
#ifdef HAVE_REALPATH
if (!realpath(file_in, rpath) || stat(rpath, &st) || !S_ISREG(st.st_mode))
#else
# ifdef _WIN32
if (!_fullpath(rpath, file_in, _MAX_PATH) || stat(rpath, &st) || !S_ISREG(st.st_mode))
# else
if (stat(file_in, &st) || !S_ISREG(st.st_mode))
# endif /* _WIN32 */
#endif
{
fprintf(stderr, "%s: Error: file not found: %s.\n", progname, file_in);
@ -157,7 +161,11 @@ main(int argc, char **argv)
#ifdef HAVE_REALPATH
if (realpath(file_out, rpath2) && !strcmp (rpath, rpath2))
#else
# ifdef _WIN32
if (_fullpath(rpath2, file_out, _MAX_PATH) && !strcmp (rpath, rpath2))
# else
if (!strcmp (file_in, file_out))
# endif /* _WIN32 */
#endif
{
fprintf(stderr, "%s: Error: input file equals output file.\n", progname);

View File

@ -706,7 +706,7 @@ compile(void)
free(def);
*/
}
fd = open(file_in, O_RDONLY);
fd = open(file_in, O_RDONLY | _O_BINARY);
if (fd < 0)
{
fprintf(stderr, "%s: Error. cannot open file \"%s\" for input. %s\n",
@ -722,7 +722,7 @@ compile(void)
size = lseek(fd, 0, SEEK_END);
lseek(fd, 0, SEEK_SET);
data = malloc(size);
if (data && read(fd, data, size) == size)
if (data && (read(fd, data, size) == size))
parse(data, size);
else
{

View File

@ -20,6 +20,14 @@
#include "edje_prefix.h"
#ifdef _WIN32
# define EDJE_DIR_SEPARATOR '\\'
# define EDJE_DIR_SEPARATOR_S "\\"
#else
# define EDJE_DIR_SEPARATOR '/'
# define EDJE_DIR_SEPARATOR_S "/"
#endif /* _WIN32 */
/* local subsystem functions */
static int _e_prefix_share_hunt(void);
static int _e_prefix_fallbacks(void);
@ -55,21 +63,21 @@ e_prefix_determine(char *argv0)
{
_prefix_path = strdup(getenv("E_PREFIX"));
if (getenv("E_BIN_DIR"))
snprintf(buf, sizeof(buf), "%s/bin", getenv("E_BIN_DIR"));
snprintf(buf, sizeof(buf), "%s" EDJE_DIR_SEPARATOR_S "bin", getenv("E_BIN_DIR"));
else
snprintf(buf, sizeof(buf), "%s/bin", _prefix_path);
snprintf(buf, sizeof(buf), "%s" EDJE_DIR_SEPARATOR_S "bin", _prefix_path);
_prefix_path_bin = strdup(buf);
if (getenv("E_LIB_DIR"))
snprintf(buf, sizeof(buf), "%s/lib", getenv("E_LIB_DIR"));
snprintf(buf, sizeof(buf), "%s" EDJE_DIR_SEPARATOR_S "lib", getenv("E_LIB_DIR"));
else
snprintf(buf, sizeof(buf), "%s/lib", _prefix_path);
snprintf(buf, sizeof(buf), "%s" EDJE_DIR_SEPARATOR_S "lib", _prefix_path);
_prefix_path_lib = strdup(buf);
if (getenv("E_DATA_DIR"))
snprintf(buf, sizeof(buf), "%s/"SHARE_D, getenv("E_DATA_DIR"));
snprintf(buf, sizeof(buf), "%s" EDJE_DIR_SEPARATOR_S SHARE_D, getenv("E_DATA_DIR"));
else
snprintf(buf, sizeof(buf), "%s/"SHARE_D, _prefix_path);
snprintf(buf, sizeof(buf), "%s" EDJE_DIR_SEPARATOR_S SHARE_D, _prefix_path);
_prefix_path_data = strdup(buf);
return 1;
}
@ -91,13 +99,13 @@ e_prefix_determine(char *argv0)
* data_dir = /blah/whatever/share/enlightenment
* lib_dir = /blah/whatever/lib
*/
p = strrchr(_exe_path, '/');
p = strrchr(_exe_path, EDJE_DIR_SEPARATOR);
if (p)
{
p--;
while (p >= _exe_path)
{
if (*p == '/')
if (*p == EDJE_DIR_SEPARATOR)
{
_prefix_path = malloc(p - _exe_path + 1);
if (_prefix_path)
@ -106,16 +114,16 @@ e_prefix_determine(char *argv0)
_prefix_path[p - _exe_path] = 0;
/* bin and lib always together */
snprintf(buf, sizeof(buf), "%s/bin", _prefix_path);
snprintf(buf, sizeof(buf), "%s" EDJE_DIR_SEPARATOR_S "bin", _prefix_path);
_prefix_path_bin = strdup(buf);
snprintf(buf, sizeof(buf), "%s/lib", _prefix_path);
snprintf(buf, sizeof(buf), "%s" EDJE_DIR_SEPARATOR_S "lib", _prefix_path);
_prefix_path_lib = strdup(buf);
/* check if AUTHORS file is there - then our guess is right */
snprintf(buf, sizeof(buf), "%s/"MAGIC_DAT, _prefix_path);
snprintf(buf, sizeof(buf), "%s" EDJE_DIR_SEPARATOR_S MAGIC_DAT, _prefix_path);
if (stat(buf, &st) == 0)
{
snprintf(buf, sizeof(buf), "%s/"SHARE_D, _prefix_path);
snprintf(buf, sizeof(buf), "%s" EDJE_DIR_SEPARATOR_S SHARE_D, _prefix_path);
_prefix_path_data = strdup(buf);
}
/* AUTHORS file not there. time to start hunting! */
@ -310,7 +318,7 @@ _e_prefix_try_proc(void)
void *func = NULL;
func = (void *)_e_prefix_try_proc;
f = fopen("/proc/self/maps", "r");
f = fopen("/proc/self/maps", "rb");
if (!f) return 0;
while (fgets(buf, sizeof(buf), f))
{
@ -360,7 +368,11 @@ _e_prefix_try_argv(char *argv0)
char buf[4096], buf2[4096], buf3[4096];
/* 1. is argv0 abs path? */
#ifdef _WIN32
if (argv0[1] == ':')
#else
if (argv0[0] == '/')
#endif
{
_exe_path = strdup(argv0);
if (access(_exe_path, X_OK) == 0) return 1;
@ -375,7 +387,7 @@ _e_prefix_try_argv(char *argv0)
{
snprintf(buf2, sizeof(buf2), "%s/%s", buf3, argv0);
#ifdef _WIN32
if (_fullpath(buf2, buf, _MAX_PATH))
if (_fullpath(buf, buf2, _MAX_PATH))
#else
if (realpath(buf2, buf))
#endif /* _WIN32 */
@ -403,7 +415,7 @@ _e_prefix_try_argv(char *argv0)
s[len] = '/';
strcpy(s + len + 1, argv0);
#ifdef _WIN32
if (_fullpath(s, buf, _MAX_PATH))
if (_fullpath(buf, s, _MAX_PATH))
#else
if (realpath(s, buf))
#endif /* _WIN32 */
@ -427,7 +439,7 @@ _e_prefix_try_argv(char *argv0)
s[len] = '/';
strcpy(s + len + 1, argv0);
#ifdef _WIN32
if (_fullpath(s, buf, _MAX_PATH))
if (_fullpath(buf, s, _MAX_PATH))
#else
if (realpath(s, buf))
#endif /* _WIN32 */