Skip to content
This repository
Browse code

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
Andrew Whitworth authored
11  include/parrot/library.h
@@ -59,14 +59,6 @@ void Parrot_lib_add_path_from_cstring(PARROT_INTERP,
59 59
 
60 60
 PARROT_EXPORT
61 61
 PARROT_WARN_UNUSED_RESULT
62  
-PARROT_CANNOT_RETURN_NULL
63  
-STRING * Parrot_lib_fix_path_separator(PARROT_INTERP,
64  
-    ARGIN(const STRING *path))
65  
-        __attribute__nonnull__(1)
66  
-        __attribute__nonnull__(2);
67  
-
68  
-PARROT_EXPORT
69  
-PARROT_WARN_UNUSED_RESULT
70 62
 PARROT_CAN_RETURN_NULL
71 63
 STRING* Parrot_lib_search_paths_as_string(PARROT_INTERP,
72 64
     enum_runtime_ft type)
@@ -121,9 +113,6 @@ void parrot_init_library_paths(PARROT_INTERP)
121 113
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
122 114
        PARROT_ASSERT_ARG(interp) \
123 115
     , PARROT_ASSERT_ARG(path))
124  
-#define ASSERT_ARGS_Parrot_lib_fix_path_separator __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
125  
-       PARROT_ASSERT_ARG(interp) \
126  
-    , PARROT_ASSERT_ARG(path))
127 116
 #define ASSERT_ARGS_Parrot_lib_search_paths_as_string \
128 117
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
129 118
        PARROT_ASSERT_ARG(interp))
2  src/dynpmc/os.pmc
@@ -101,7 +101,7 @@ Returns the current working directory.
101 101
 */
102 102
 
103 103
     METHOD cwd() {
104  
-        STRING * const cwd = Parrot_lib_fix_path_separator(INTERP, Parrot_file_getcwd(INTERP));
  104
+        STRING * const cwd = Parrot_file_getcwd(INTERP);
105 105
         RETURN(STRING *cwd);
106 106
     }
107 107
 
58  src/library.c
@@ -30,6 +30,13 @@ dynext files (via C<loadlib>).
30 30
 
31 31
 PARROT_WARN_UNUSED_RESULT
32 32
 PARROT_CANNOT_RETURN_NULL
  33
+static STRING * cnv_to_win32_filesep(PARROT_INTERP,
  34
+    ARGIN(const STRING *path))
  35
+        __attribute__nonnull__(1)
  36
+        __attribute__nonnull__(2);
  37
+
  38
+PARROT_WARN_UNUSED_RESULT
  39
+PARROT_CANNOT_RETURN_NULL
33 40
 static PMC* get_search_paths(PARROT_INTERP, enum_lib_paths which)
34 41
         __attribute__nonnull__(1);
35 42
 
@@ -66,6 +73,9 @@ static STRING* try_load_path(PARROT_INTERP, ARGIN(STRING* path))
66 73
         __attribute__nonnull__(1)
67 74
         __attribute__nonnull__(2);
68 75
 
  76
+#define ASSERT_ARGS_cnv_to_win32_filesep __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
  77
+       PARROT_ASSERT_ARG(interp) \
  78
+    , PARROT_ASSERT_ARG(path))
69 79
 #define ASSERT_ARGS_get_search_paths __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
70 80
        PARROT_ASSERT_ARG(interp))
71 81
 #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)
309 319
 }
310 320
 
311 321
 static const int path_separator = '/';
  322
+
  323
+#ifdef WIN32
  324
+
312 325
 static const int win32_path_separator = '\\';
313 326
 
  327
+#endif
  328
+
314 329
 /*
315 330
 
316 331
 =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))
357 372
 }
358 373
 
359 374
 
  375
+#ifdef WIN32
  376
+
360 377
 /*
361 378
 
362  
-=item C<STRING * Parrot_lib_fix_path_separator(PARROT_INTERP, const STRING
363  
-*path)>
  379
+=item C<static STRING * cnv_to_win32_filesep(PARROT_INTERP, const STRING *path)>
364 380
 
365  
-Converts path separators in a path to use the current platform's separators.
  381
+Converts a path with forward slashes to one with backward slashes.
366 382
 
367 383
 =cut
368 384
 
369 385
 */
370 386
 
371  
-PARROT_EXPORT
372 387
 PARROT_WARN_UNUSED_RESULT
373 388
 PARROT_CANNOT_RETURN_NULL
374  
-STRING *
375  
-Parrot_lib_fix_path_separator(PARROT_INTERP, ARGIN(const STRING *path))
  389
+static STRING *
  390
+cnv_to_win32_filesep(PARROT_INTERP, ARGIN(const STRING *path))
376 391
 {
377  
-    ASSERT_ARGS(Parrot_lib_fix_path_separator)
  392
+    ASSERT_ARGS(cnv_to_win32_filesep)
378 393
     const UINTVAL  len = STRING_length(path);
379  
-    STRING        *res = Parrot_str_new(interp, "", path->bufused);
  394
+    STRING        *res = Parrot_str_new_noinit(interp, path->bufused);
380 395
     String_iter    src, dst;
381  
-#ifdef WIN32
382  
-    const INTVAL find = path_separator;
383  
-    const INTVAL replace = win32_path_separator;
384  
-#else
385  
-    const INTVAL find = win32_path_separator;
386  
-    const INTVAL replace = path_separator;
387  
-#endif
388 396
 
389 397
     res->encoding = path->encoding;
390 398
 
@@ -394,8 +402,8 @@ Parrot_lib_fix_path_separator(PARROT_INTERP, ARGIN(const STRING *path))
394 402
     while (src.charpos < len) {
395 403
         INTVAL c = STRING_iter_get_and_advance(interp, path, &src);
396 404
 
397  
-        if (c == find)
398  
-            c = replace;
  405
+        if (c == path_separator)
  406
+            c = win32_path_separator;
399 407
 
400 408
         STRING_iter_set_and_advance(interp, res, &dst, c);
401 409
     }
@@ -406,6 +414,8 @@ Parrot_lib_fix_path_separator(PARROT_INTERP, ARGIN(const STRING *path))
406 414
     return res;
407 415
 }
408 416
 
  417
+#endif
  418
+
409 419
 /*
410 420
 
411 421
 =item C<static STRING* path_guarantee_trailing_separator(PARROT_INTERP, STRING
@@ -431,7 +441,7 @@ path_guarantee_trailing_separator(PARROT_INTERP, ARGIN(STRING *path))
431 441
         path = Parrot_str_concat(interp, path,
432 442
                 Parrot_str_chr(interp, path_separator));
433 443
 
434  
-    return Parrot_lib_fix_path_separator(interp, path);
  444
+    return path;
435 445
 }
436 446
 
437 447
 /*
@@ -459,7 +469,7 @@ path_concat(PARROT_INTERP, ARGIN(STRING *l_path),
459 469
     join = path_guarantee_trailing_separator(interp, l_path);
460 470
     join = Parrot_str_concat(interp, join, r_path);
461 471
 
462  
-    return Parrot_lib_fix_path_separator(interp, join);
  472
+    return join;
463 473
 }
464 474
 
465 475
 /*
@@ -480,7 +490,10 @@ static STRING*
480 490
 try_load_path(PARROT_INTERP, ARGIN(STRING* path))
481 491
 {
482 492
     ASSERT_ARGS(try_load_path)
483  
-    path = Parrot_lib_fix_path_separator(interp, path);
  493
+
  494
+#ifdef WIN32
  495
+    path = cnv_to_win32_filesep(interp, path);
  496
+#endif
484 497
 
485 498
     if (Parrot_file_stat_intval(interp, path, STAT_EXISTS)) {
486 499
         return path;
@@ -591,7 +604,6 @@ Parrot_lib_add_path(PARROT_INTERP,
591 604
     PMC * const lib_paths = VTABLE_get_pmc_keyed_int(interp, iglobals,
592 605
         IGLOBALS_LIB_PATHS);
593 606
     PMC * const paths = VTABLE_get_pmc_keyed_int(interp, lib_paths, which);
594  
-    path_str = Parrot_lib_fix_path_separator(interp, path_str);
595 607
     VTABLE_unshift_string(interp, paths, path_str);
596 608
 }
597 609
 
@@ -644,8 +656,6 @@ Parrot_locate_runtime_file_str(PARROT_INTERP, ARGIN(STRING *file),
644 656
     PMC    *paths;
645 657
     INTVAL  i, n;
646 658
 
647  
-    file = Parrot_lib_fix_path_separator(interp, file);
648  
-
649 659
     /* if this is an absolute path return it as is */
650 660
     if (is_abs_path(interp, file))
651 661
         return file;
@@ -773,7 +783,7 @@ Parrot_get_runtime_path(PARROT_INTERP)
773 783
         else
774 784
             result = CONST_STRING(interp, ".");
775 785
     }
776  
-    return Parrot_lib_fix_path_separator(interp, result);
  786
+    return result;
777 787
 }
778 788
 
779 789
 /*
13  src/string/api.c
@@ -674,15 +674,10 @@ Parrot_str_new_init(PARROT_INTERP, ARGIN_NULLOK(const char *buffer), UINTVAL len
674 674
 
675 675
     Parrot_gc_allocate_string_storage(interp, s, len);
676 676
 
677  
-    if (len) {
678  
-        if (buffer) {
679  
-            mem_sys_memcopy(s->strstart, buffer, len);
680  
-            s->bufused = len;
681  
-            STRING_scan(interp, s);
682  
-        }
683  
-        else {
684  
-            s->bufused = len;
685  
-        }
  677
+    if (buffer && len) {
  678
+        mem_sys_memcopy(s->strstart, buffer, len);
  679
+        s->bufused = len;
  680
+        STRING_scan(interp, s);
686 681
     }
687 682
     else
688 683
         s->strlen = s->bufused = 0;

0 notes on commit 1a3b2f2

Please sign in to comment.
Something went wrong with that request. Please try again.