This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Mention the Unicode UTR #18 version referenced.
[perl5.git] / x2p / walk.c
index f4f7fe8..63ceb47 100644 (file)
@@ -1,6 +1,7 @@
 /* $RCSfile: walk.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:31 $
  *
- *    Copyright (c) 1991-2002, Larry Wall
+ *    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1997, 1998, 1999,
+ *    2000, 2001, 2002, by Larry Wall and others
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -34,7 +35,11 @@ static void tab ( STR *str, int lvl );
 
 int prewalk ( int numit, int level, int node, int *numericptr );
 STR * walk ( int useval, int level, int node, int *numericptr, int minprec );
-
+#ifdef NETWARE
+char *savestr(char *str);
+char *cpytill(register char *to, register char *from, register int delim);
+char *instr(char *big, char *little);
+#endif
 
 STR *
 walk(int useval, int level, register int node, int *numericptr, int minprec)
@@ -52,7 +57,7 @@ walk(int useval, int level, register int node, int *numericptr, int minprec)
     STR *tmp2str;
     STR *tmp3str;
     char *t;
-    char *d, *s = 0;
+    char *d, *s;
     int numarg;
     int numeric = FALSE;
     STR *fstr;
@@ -822,11 +827,8 @@ sub Pick {\n\
        str_cat(str,")");
        break;
     case OGSUB:
-    case OSUB:
-       if (type == OGSUB)
-           s = "g";
-       else
-           s = "";
+    case OSUB: {
+       int gsub = type == OGSUB ? 1 : 0;
        str = str_new(0);
        tmpstr = str_new(0);
        i = 0;
@@ -856,6 +858,7 @@ sub Pick {\n\
            }
            *d = '\0';
            str_set(tmp2str,tokenbuf);
+           s = gsub ? "/g" : "/";
        }
        else {
            tmp2str=walk(1,level,ops[node+2].ival,&numarg,P_MIN);
@@ -863,9 +866,10 @@ sub Pick {\n\
            str_scat(tmp3str,tmp2str);
            str_cat(tmp3str,").'\"') =~ s/&/\\$&/g, ");
            str_set(tmp2str,"eval $s_");
-           s = (char*)(*s == 'g' ? "ge" : "e");
+           s = gsub ? "/ge" : "/e";
            i++;
        }
+       str_cat(tmp2str,s);
        type = ops[ops[node+1].ival].ival;
        len = type >> 8;
        type &= 255;
@@ -877,8 +881,6 @@ sub Pick {\n\
            str_scat(str,tmpstr);
            str_scat(str,fstr);
            str_scat(str,tmp2str);
-           str_cat(str,"/");
-           str_cat(str,s);
        }
        else if ((type == OFLD && !split_to_array) || (type == OVAR && len == 1)) {
            if (useval && i)
@@ -889,8 +891,6 @@ sub Pick {\n\
            str_scat(str,fstr);
            str_cat(str,"/");
            str_scat(str,tmp2str);
-           str_cat(str,"/");
-           str_cat(str,s);
        }
        else {
            i++;
@@ -903,8 +903,6 @@ sub Pick {\n\
            str_scat(str,tmpstr);
            str_cat(str,"/$s/");
            str_scat(str,tmp2str);
-           str_cat(str,"/");
-           str_cat(str,s);
        }
        if (useval && i)
            str_cat(str,")");
@@ -913,7 +911,7 @@ sub Pick {\n\
        str_free(tmp2str);
        str_free(tmp3str);
        numeric = 1;
-       break;
+       break; }
     case ONUM:
        str = walk(1,level,ops[node+1].ival,&numarg,P_MIN);
        numeric = 1;