strlen(foo) rather than strchr(foo, 0) makes simpler code, and is
Nicholas Clark [Fri, 19 May 2006 16:31:35 +0000 (16:31 +0000)]
likely to be a more efficient implementation.

p4raw-id: //depot/perl@28236

perlio.c

index a0cb4a4..a4b7bb4 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -1423,11 +1423,11 @@ PerlIO_context_layers(pTHX_ const char *mode)
            type = SvPV_const(layers, len);
            if (type && mode[0] != 'r') {
                /*
-                * Skip to write part
+                * Skip to write part, which is separated by a '\0'
                 */
-               const char * const s = strchr(type, 0);
-               if (s && (STRLEN)(s - type) < len) {
-                   type = s + 1;
+               STRLEN read_len = strlen(type);
+               if (read_len < len) {
+                   type += read_len + 1;
                }
            }
        }