pike.git / lib / modules / Process.pmod

version» Context lines:

pike.git/lib/modules/Process.pmod:388:    ({"\0\"","\0'","\0\\","\0 ","\0\t","\0\n", "\0\r", "\0\0"}));    array(string) x=s/"\0";    array(string) ret = ({});    string last = x[0];    int always_keep_last;      piece_loop:    for(int e=1;e<sizeof(x);e++)    {    string piece = x[e]; -  if (!sizeof(piece)) { -  // Escaped NUL. -  last += "\0"; -  e++; +  if (piece == "") { +  // Escaped NUL. There should always be another element in x. +  last += "\0" + x[++e];    continue;    }    switch(piece[0])    {    case '"': -  +  always_keep_last = 1;    last+=piece[1..]; -  while(sizeof (x) > e + 1 && (piece = x[++e])[0]!='"') -  { -  if(sizeof(piece)==1 && piece[0]=='\\' && x[e+1][0]=='"') +  while (1) { +  if (++e == sizeof (x)) +  break piece_loop; +  if (has_prefix (piece = x[e], "\"")) +  break; +  if (piece == "") { // Escaped NUL. +  last += "\0" + x[++e]; +  } +  else { +  if(piece == "\\" && sizeof (x) > e + 1 && has_prefix (x[e+1], "\""))    piece = x[++e];    last+=piece;    } -  +  }    last+=piece[1..]; -  always_keep_last = 1; +     break;       case '\'': -  +  always_keep_last = 1;    last+=piece[1..]; -  while(sizeof (x) > e + 1 && (piece = x[++e])[0]!='\'') last+=piece; +  while (1) { +  if (++e == sizeof (x)) +  break piece_loop; +  if (has_prefix (piece = x[e], "'")) +  break; +  if (piece == "") { // Escaped NUL. +  last += "\0" + x[++e]; +  } +  else +  last+=piece; +  }    last+=piece[1..]; -  always_keep_last = 1; +     break;       case '\\':    if(sizeof(piece)>1)    {    if (nt_mode) {    // On NT we only escape special characters with \;    // other \'s we keep verbatim.    last+=piece;    } else {
pike.git/lib/modules/Process.pmod:451:    else    break;    }else{    break piece_loop;    }    }    if (sizeof (last) || always_keep_last)    ret += ({last});    last = piece[1..];    break; -  -  default: -  last+="\0"+piece; -  break; +     }    }    if (sizeof (last) || always_keep_last)    ret += ({last});    return ret;   }      Process spawn(string command, void|Stdio.Stream stdin,    void|Stdio.Stream stdout, void|Stdio.Stream stderr,    // These aren't used. Seems to be part of something unfinished. /mast