Remove embedded function and use instead the regex directly as we doesn't need

more lines of code as really necessary.
 The regex stuff is taken from this site:
   http://www.slac.stanford.edu/slac/www/resource/how-to-use/cgi-rexx/cgi-esc.htm
This commit is contained in:
Patrick Winnertz 2009-01-25 22:45:06 +01:00
parent 26992b5e0a
commit e1572aefd3

View File

@ -392,23 +392,17 @@ fish_dir_load(struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
"while( (my $filename = readdir(DIR))){\n"
"my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = lstat(\"$dirname/$filename\");\n"
"my $mloctime= scalar localtime $mtime;\n"
"\n"
"# shell escs are taken from here: http://www.slac.stanford.edu/slac/www/resource/how-to-use/cgi-rexx/cgi-esc.html\n"
" sub esc_shell_chars {\n"
" my $s = $_[0];\n"
" $s =~ s/([;<>\\*\\|`&\\$!#\\(\\)\\[\\]\\{\\}:'\\''\"\\ \\\\])/\\\\$1/g;\n"
" return $s;\n"
" }\n"
"\n"
"my $e_filename = esc_shell_chars($filename);\n"
"my $shell_escape_regex= s/([;<>\\*\\|`&\\$!#\\(\\)\\[\\]\\{\\}:'\\''\"\\ \\\\])/\\\\$1/g;\n"
"my $e_filename = $filename;\n"
"$e_filename =~ $shell_escape_regex;\n"
"if (S_ISLNK($mode) ) {\n"
"my $linkname = readlink (\"$dirname/$filename\");\n"
"my $e_linkname = esc_shell_chars($linkname);\n"
"$linkname =~ $shell_escape_regex;\n"
"\n"
"printf(\"R%%o %%o $uid.$gid\\n"
"S$size\\n"
"d$mloctime\\n"
":\\\"$e_filename\\\" -> \\\"$e_linkname\\\"\\n"
":\\\"$e_filename\\\" -> \\\"$linkname\\\"\\n"
"\\n\", S_IMODE($mode), S_IFMT($mode));\n"
"} else {\n"
"printf(\"R%%o %%o $uid.$gid\\n"