Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Revert "Merge branch 'master' of github.com:parrot/parrot into separa…

…tor_fixes"

This reverts commit 6f1762b, reversing
changes made to f43f011.
  • Loading branch information...
commit 1a3b2f22f5a8956722db13d30cf173bae59396b6 1 parent 0775735
@Whiteknight Whiteknight authored
View
11 include/parrot/library.h
@@ -59,14 +59,6 @@ void Parrot_lib_add_path_from_cstring(PARROT_INTERP,
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
-PARROT_CANNOT_RETURN_NULL
-STRING * Parrot_lib_fix_path_separator(PARROT_INTERP,
- ARGIN(const STRING *path))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-PARROT_EXPORT
-PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
STRING* Parrot_lib_search_paths_as_string(PARROT_INTERP,
enum_runtime_ft type)
@@ -121,9 +113,6 @@ void parrot_init_library_paths(PARROT_INTERP)
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(path))
-#define ASSERT_ARGS_Parrot_lib_fix_path_separator __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp) \
- , PARROT_ASSERT_ARG(path))
#define ASSERT_ARGS_Parrot_lib_search_paths_as_string \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
View
2  src/dynpmc/os.pmc
@@ -101,7 +101,7 @@ Returns the current working directory.
*/
METHOD cwd() {
- STRING * const cwd = Parrot_lib_fix_path_separator(INTERP, Parrot_file_getcwd(INTERP));
+ STRING * const cwd = Parrot_file_getcwd(INTERP);
RETURN(STRING *cwd);
}
View
58 src/library.c
@@ -30,6 +30,13 @@ dynext files (via C<loadlib>).
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
+static STRING * cnv_to_win32_filesep(PARROT_INTERP,
+ ARGIN(const STRING *path))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
static PMC* get_search_paths(PARROT_INTERP, enum_lib_paths which)
__attribute__nonnull__(1);
@@ -66,6 +73,9 @@ static STRING* try_load_path(PARROT_INTERP, ARGIN(STRING* path))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
+#define ASSERT_ARGS_cnv_to_win32_filesep __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(path))
#define ASSERT_ARGS_get_search_paths __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_is_abs_path __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -309,8 +319,13 @@ get_search_paths(PARROT_INTERP, enum_lib_paths which)
}
static const int path_separator = '/';
+
+#ifdef WIN32
+
static const int win32_path_separator = '\\';
+#endif
+
/*
=item C<static int is_abs_path(PARROT_INTERP, const STRING *file)>
@@ -357,34 +372,27 @@ is_abs_path(PARROT_INTERP, ARGIN(const STRING *file))
}
+#ifdef WIN32
+
/*
-=item C<STRING * Parrot_lib_fix_path_separator(PARROT_INTERP, const STRING
-*path)>
+=item C<static STRING * cnv_to_win32_filesep(PARROT_INTERP, const STRING *path)>
-Converts path separators in a path to use the current platform's separators.
+Converts a path with forward slashes to one with backward slashes.
=cut
*/
-PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
-STRING *
-Parrot_lib_fix_path_separator(PARROT_INTERP, ARGIN(const STRING *path))
+static STRING *
+cnv_to_win32_filesep(PARROT_INTERP, ARGIN(const STRING *path))
{
- ASSERT_ARGS(Parrot_lib_fix_path_separator)
+ ASSERT_ARGS(cnv_to_win32_filesep)
const UINTVAL len = STRING_length(path);
- STRING *res = Parrot_str_new(interp, "", path->bufused);
+ STRING *res = Parrot_str_new_noinit(interp, path->bufused);
String_iter src, dst;
-#ifdef WIN32
- const INTVAL find = path_separator;
- const INTVAL replace = win32_path_separator;
-#else
- const INTVAL find = win32_path_separator;
- const INTVAL replace = path_separator;
-#endif
res->encoding = path->encoding;
@@ -394,8 +402,8 @@ Parrot_lib_fix_path_separator(PARROT_INTERP, ARGIN(const STRING *path))
while (src.charpos < len) {
INTVAL c = STRING_iter_get_and_advance(interp, path, &src);
- if (c == find)
- c = replace;
+ if (c == path_separator)
+ c = win32_path_separator;
STRING_iter_set_and_advance(interp, res, &dst, c);
}
@@ -406,6 +414,8 @@ Parrot_lib_fix_path_separator(PARROT_INTERP, ARGIN(const STRING *path))
return res;
}
+#endif
+
/*
=item C<static STRING* path_guarantee_trailing_separator(PARROT_INTERP, STRING
@@ -431,7 +441,7 @@ path_guarantee_trailing_separator(PARROT_INTERP, ARGIN(STRING *path))
path = Parrot_str_concat(interp, path,
Parrot_str_chr(interp, path_separator));
- return Parrot_lib_fix_path_separator(interp, path);
+ return path;
}
/*
@@ -459,7 +469,7 @@ path_concat(PARROT_INTERP, ARGIN(STRING *l_path),
join = path_guarantee_trailing_separator(interp, l_path);
join = Parrot_str_concat(interp, join, r_path);
- return Parrot_lib_fix_path_separator(interp, join);
+ return join;
}
/*
@@ -480,7 +490,10 @@ static STRING*
try_load_path(PARROT_INTERP, ARGIN(STRING* path))
{
ASSERT_ARGS(try_load_path)
- path = Parrot_lib_fix_path_separator(interp, path);
+
+#ifdef WIN32
+ path = cnv_to_win32_filesep(interp, path);
+#endif
if (Parrot_file_stat_intval(interp, path, STAT_EXISTS)) {
return path;
@@ -591,7 +604,6 @@ Parrot_lib_add_path(PARROT_INTERP,
PMC * const lib_paths = VTABLE_get_pmc_keyed_int(interp, iglobals,
IGLOBALS_LIB_PATHS);
PMC * const paths = VTABLE_get_pmc_keyed_int(interp, lib_paths, which);
- path_str = Parrot_lib_fix_path_separator(interp, path_str);
VTABLE_unshift_string(interp, paths, path_str);
}
@@ -644,8 +656,6 @@ Parrot_locate_runtime_file_str(PARROT_INTERP, ARGIN(STRING *file),
PMC *paths;
INTVAL i, n;
- file = Parrot_lib_fix_path_separator(interp, file);
-
/* if this is an absolute path return it as is */
if (is_abs_path(interp, file))
return file;
@@ -773,7 +783,7 @@ Parrot_get_runtime_path(PARROT_INTERP)
else
result = CONST_STRING(interp, ".");
}
- return Parrot_lib_fix_path_separator(interp, result);
+ return result;
}
/*
View
13 src/string/api.c
@@ -674,15 +674,10 @@ Parrot_str_new_init(PARROT_INTERP, ARGIN_NULLOK(const char *buffer), UINTVAL len
Parrot_gc_allocate_string_storage(interp, s, len);
- if (len) {
- if (buffer) {
- mem_sys_memcopy(s->strstart, buffer, len);
- s->bufused = len;
- STRING_scan(interp, s);
- }
- else {
- s->bufused = len;
- }
+ if (buffer && len) {
+ mem_sys_memcopy(s->strstart, buffer, len);
+ s->bufused = len;
+ STRING_scan(interp, s);
}
else
s->strlen = s->bufused = 0;
Please sign in to comment.
Something went wrong with that request. Please try again.