003 File Manager
Current Path:
/usr/local/bin
usr
/
local
/
bin
/
📁
..
📄
2to3-3.8
(101 B)
📄
ab
(50.54 KB)
📄
addftinfo
(63.84 KB)
📄
afmtodit
(161.91 KB)
📄
apr-1-config
(6.77 KB)
📄
apu-1-config
(6.17 KB)
📄
argon2
(43.3 KB)
📄
bash
(918.65 KB)
📄
bashbug
(6.65 KB)
📄
chardetect
(972 B)
📄
chardetect-3.8
(972 B)
📄
chem
(28.51 KB)
📄
corelist
(15.02 KB)
📄
cpan
(8.17 KB)
📄
curl
(163.47 KB)
📄
curl-config
(7.33 KB)
📄
curve_keygen
(5.88 KB)
📁
db5
📄
db_archive-5
(9.28 KB)
📄
db_archive-5.3
(9.28 KB)
📄
db_checkpoint-5
(10.94 KB)
📄
db_checkpoint-5.3
(10.94 KB)
📄
db_deadlock-5
(11.12 KB)
📄
db_deadlock-5.3
(11.12 KB)
📄
db_dump-5
(13.95 KB)
📄
db_dump-5.3
(13.95 KB)
📄
db_dump185-5
(8.61 KB)
📄
db_dump185-5.3
(8.61 KB)
📄
db_hotbackup-5
(14.74 KB)
📄
db_hotbackup-5.3
(14.74 KB)
📄
db_load-5
(25.35 KB)
📄
db_load-5.3
(25.35 KB)
📄
db_log_verify-5
(12.36 KB)
📄
db_log_verify-5.3
(12.36 KB)
📄
db_printlog-5
(31.88 KB)
📄
db_printlog-5.3
(31.88 KB)
📄
db_recover-5
(10.81 KB)
📄
db_recover-5.3
(10.81 KB)
📄
db_replicate-5
(11.78 KB)
📄
db_replicate-5.3
(11.78 KB)
📄
db_stat-5
(11.89 KB)
📄
db_stat-5.3
(11.89 KB)
📄
db_tuner-5
(17.47 KB)
📄
db_tuner-5.3
(17.47 KB)
📄
db_upgrade-5
(9.81 KB)
📄
db_upgrade-5.3
(9.81 KB)
📄
db_verify-5
(10.36 KB)
📄
db_verify-5.3
(10.36 KB)
📄
dehydrated
(80.89 KB)
📄
distro
(961 B)
📄
distro-3.8
(961 B)
📄
enc2xs
(40.78 KB)
📄
encguess
(3.01 KB)
📄
envsubst
(35.84 KB)
📄
epsffit
(11.11 KB)
📄
eqn
(181.15 KB)
📄
eqn2graph
(3.16 KB)
📄
event_rpcgen.py
(53.66 KB)
📄
extractres
(2.69 KB)
📄
fixdlsrps
(1.53 KB)
📄
fixfmps
(605 B)
📄
fixmacps
(2.11 KB)
📄
fixpsditps
(700 B)
📄
fixpspps
(1.28 KB)
📄
fixscribeps
(485 B)
📄
fixtpps
(705 B)
📄
fixwfwps
(863 B)
📄
fixwpps
(738 B)
📄
fixwwps
(433 B)
📄
ftpasswd
(37.06 KB)
📄
ftpcount
(46.63 KB)
📄
ftpdctl
(328.72 KB)
📄
ftpmail
(13.63 KB)
📄
ftpquota
(32.21 KB)
📄
ftptop
(65.33 KB)
📄
ftpwho
(133.71 KB)
📄
gdbm_dump
(19.02 KB)
📄
gdbm_load
(22.2 KB)
📄
gdbmtool
(115.9 KB)
📄
gdiffmk
(7.51 KB)
📄
getafm
(6.18 KB)
📄
gettext
(36.32 KB)
📄
gettext.sh
(5.07 KB)
📄
glilypond
(18.01 KB)
📄
gperl
(6.5 KB)
📄
gpinyin
(5.03 KB)
📄
grap2graph
(3.08 KB)
📄
grn
(118.4 KB)
📄
grodvi
(150.01 KB)
📄
groff
(130.26 KB)
📄
groffer
(8.06 KB)
📄
grog
(2.73 KB)
📄
grolbp
(149.57 KB)
📄
grolj4
(144.72 KB)
📄
gropdf
(70.41 KB)
📄
grops
(192.28 KB)
📄
grotty
(145.68 KB)
📄
h2ph
(28.55 KB)
📄
h2xs
(59.51 KB)
📄
hpftodit
(158.4 KB)
📄
htdbm
(18.69 KB)
📄
htdigest
(10.75 KB)
📄
htpasswd
(17.62 KB)
📄
httxt2dbm
(10.3 KB)
📄
iconv
(25.27 KB)
📄
idle3.8
(99 B)
📄
includeres
(1.44 KB)
📄
indexinfo
(10.87 KB)
📄
indxbib
(73.84 KB)
📄
innochecksum
(3.44 MB)
📄
instmodsh
(4.2 KB)
📄
json_pp
(4.88 KB)
📄
ldapadd
(67.1 KB)
📄
ldapcompare
(56.88 KB)
📄
ldapdelete
(58.27 KB)
📄
ldapexop
(57.43 KB)
📄
ldapmodify
(67.1 KB)
📄
ldapmodrdn
(56.87 KB)
📄
ldappasswd
(57.66 KB)
📄
ldapsearch
(78.48 KB)
📄
ldapurl
(18.74 KB)
📄
ldapwhoami
(55.38 KB)
📄
libnetcfg
(15.42 KB)
📄
lkbib
(80.95 KB)
📄
logresolve
(10.15 KB)
📄
lookbib
(81.07 KB)
📄
lz4
(68.09 KB)
📄
lz4_decompress
(7.7 KB)
📄
lz4c
(68.09 KB)
📄
lz4cat
(68.09 KB)
📄
mmroff
(3.75 KB)
📄
my_print_defaults
(3.4 MB)
📄
myisam_ftdump
(3.63 MB)
📄
myisamchk
(3.73 MB)
📄
myisamlog
(3.61 MB)
📄
myisampack
(3.66 MB)
📄
mysql
(3.66 MB)
📄
mysql_config
(5.05 KB)
📄
mysql_config_editor
(3.4 MB)
📄
mysql_install_db
(4.96 MB)
📄
mysql_plugin
(3.41 MB)
📄
mysql_secure_installation
(3.56 MB)
📄
mysql_ssl_rsa_setup
(3.44 MB)
📄
mysql_tzinfo_to_sql
(3.37 MB)
📄
mysql_upgrade
(4.16 MB)
📄
mysqladmin
(3.56 MB)
📄
mysqlbinlog
(3.78 MB)
📄
mysqlcheck
(3.57 MB)
📄
mysqld_multi
(26.39 KB)
📄
mysqld_safe
(27.21 KB)
📄
mysqldump
(3.63 MB)
📄
mysqldumpslow
(7.67 KB)
📄
mysqlimport
(3.55 MB)
📄
mysqlpump
(3.92 MB)
📄
mysqlshow
(3.55 MB)
📄
mysqlslap
(3.57 MB)
📄
mysqltest
(3.85 MB)
📄
mysqlxtest
(4.2 MB)
📄
neqn
(919 B)
📄
ngettext
(35.89 KB)
📄
nroff
(3.21 KB)
📄
paperconf
(10.55 KB)
📄
pcre-config
(2.31 KB)
📄
pcre2-config
(2.13 KB)
📄
pcre2grep
(46.03 KB)
📄
pcre2test
(166.76 KB)
📄
pcregrep
(35.81 KB)
📄
pcretest
(103.81 KB)
📄
pdfmom
(3.03 KB)
📄
pdfroff
(20.96 KB)
📄
perl
(7.41 KB)
📄
perl5.32.1
(7.41 KB)
📄
perlbug
(44.21 KB)
📄
perldoc
(274 B)
📄
perlivp
(10.58 KB)
📄
perlthanks
(44.21 KB)
📄
perror
(3.53 MB)
📄
pfbtops
(53.68 KB)
📄
php
(5.31 MB)
📄
php-cgi
(5.24 MB)
📄
php-config
(3.16 KB)
📄
phpize
(4.42 KB)
📄
pic
(231.69 KB)
📄
pic2graph
(3.66 KB)
📄
piconv
(8.17 KB)
📄
pl2pm
(4.44 KB)
📄
pod2html
(4.05 KB)
📄
pod2man
(14.69 KB)
📄
pod2text
(10.56 KB)
📄
pod2usage
(3.86 KB)
📄
podchecker
(3.58 KB)
📄
post-grohtml
(247.92 KB)
📄
pre-grohtml
(129.52 KB)
📄
preconv
(78.54 KB)
📄
protoc
(13.9 KB)
📄
prove
(13.35 KB)
📄
prxs
(9.25 KB)
📄
psbook
(16.39 KB)
📄
psmerge
(1.97 KB)
📄
psnup
(24.64 KB)
📄
psresize
(22.61 KB)
📄
psselect
(17.91 KB)
📄
pstops
(23.34 KB)
📄
ptar
(3.48 KB)
📄
ptardiff
(2.58 KB)
📄
ptargrep
(4.3 KB)
📄
pybabel
(960 B)
📄
pybabel-3.8
(960 B)
📄
pydoc3.8
(84 B)
📄
python3.8
(5.13 KB)
📄
python3.8-config
(3.09 KB)
📄
rbash
(918.65 KB)
📄
refer
(161.39 KB)
📄
replace
(3.38 MB)
📄
resolve_stack_dump
(3.4 MB)
📄
resolveip
(3.4 MB)
📄
roff2dvi
(5.58 KB)
📄
roff2html
(5.58 KB)
📄
roff2pdf
(5.58 KB)
📄
roff2ps
(5.58 KB)
📄
roff2text
(5.58 KB)
📄
roff2x
(5.58 KB)
📄
salt
(948 B)
📄
salt-api
(956 B)
📄
salt-call
(958 B)
📄
salt-cloud
(960 B)
📄
salt-cp
(954 B)
📄
salt-key
(956 B)
📄
salt-master
(962 B)
📄
salt-minion
(962 B)
📄
salt-proxy
(972 B)
📄
salt-run
(956 B)
📄
salt-ssh
(956 B)
📄
salt-syndic
(962 B)
📄
salt-unity
(960 B)
📄
screen
(435.05 KB)
📄
setvhost.sh
(3.05 KB)
📄
shasum
(9.75 KB)
📄
showchar
(2.51 KB)
📄
soelim
(66.83 KB)
📄
splain
(18.97 KB)
📄
spm
(946 B)
📄
streamzip
(5.4 KB)
📄
tbl
(149.71 KB)
📄
tfmtodit
(68.05 KB)
📄
troff
(577.19 KB)
📄
uchardet
(8.03 KB)
📄
unlz4
(68.09 KB)
📄
xml2-config
(1.79 KB)
📄
xmlcatalog
(15.22 KB)
📄
xmllint
(61.66 KB)
📄
xmlwf
(31.56 KB)
📄
xsubpp
(5.05 KB)
📄
zipdetails
(50.05 KB)
📄
zlib_decompress
(7.56 KB)
Editing: chem
#! /usr/bin/env perl # chem - a groff preprocessor for producing chemical structure diagrams # Source file position: <groff-source>/contrib/chem/chem.pl # Installed position: <prefix>/bin/chem my $Copyright = 'Copyright (C) 2006-2014 Free Software Foundation, Inc.'; # Written by Bernd Warken <groff-bernd.warken-72@web.de>. # This file is part of 'chem', which is part of 'groff'. # 'groff' is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License (GPL) version 2 as # published by the Free Software Foundation. # 'groff' is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # The GPL2 license text is available in the internet at # <http://www.gnu.org/licenses/gpl-2.0.html>. ######################################################################## # settings ######################################################################## my $Program_Version = '1.0.5'; # this setting of the groff version is only used before make is run, # otherwise 1.22.4 will set it. my $Groff_Version_Preset='1.20preset'; # test on Perl version require v5.6; ######################################################################## # begin ######################################################################## use warnings; use strict; use Math::Trig; # for catfile() use File::Spec; # $Bin is the directory where this script is located use FindBin; my $Chem_Name; my $Groff_Version; my $File_chem_pic; my $File_pic_tmac; BEGIN { { my $before_make; # script before run of 'make' { my $at = '@'; $before_make = 1 if '1.22.4' eq "${at}VERSION${at}"; } my %at_at; if ($before_make) { my $chem_dir = $FindBin::Bin; $at_at{'BINDIR'} = $chem_dir; $at_at{'G'} = ''; $File_chem_pic = File::Spec->catfile($chem_dir, 'chem.pic'); $File_pic_tmac = File::Spec->catfile($chem_dir, '..', 'pic.tmac'); $Groff_Version = ''; $Chem_Name = 'chem'; } else { $Groff_Version = '1.22.4'; $at_at{'BINDIR'} = '/usr/local/bin'; $at_at{'G'} = ''; $at_at{'PICDIR'} = '/usr/local/share/groff/1.22.4/pic'; $at_at{'TMACDIR'} = '/usr/local/share/groff/1.22.4/tmac'; $File_chem_pic = File::Spec->catfile($at_at{'PICDIR'}, 'chem.pic'); $File_pic_tmac = File::Spec->catfile($at_at{'TMACDIR'}, 'pic.tmac'); $Chem_Name = $at_at{'G'} . 'chem'; } } } ######################################################################## # check the parameters ######################################################################## if (@ARGV) { # process any FOO=bar switches # eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift; my @filespec = (); my $dbl_minus; my $wrong; foreach (@ARGV) { next unless $_; if (/=/) { # ignore FOO=bar switches push @filespec, $_ if -f; next; } if ($dbl_minus) { if (-f $_) { push @filespec, $_ if -s $_; } else { warn "chem: argument $_ is not an existing file.\n"; $wrong = 1; } next; } if (/^--$/) { $dbl_minus = 1; next; } if (/^-$/) { push @filespec, $_; next; } if (/^-h$/ or '--help' =~ /^$_/) { &usage(); exit 0; } if (/^-v$/ or '--version' =~ /^$_/) { &version(); exit 0; } if (-f $_) { push @filespec, $_ if -s $_; } else { $wrong = 1; if (/^-/) { warn "chem: wrong option ${_}.\n"; } else { warn "chem: argument $_ is not an existing file.\n"; } } } if (@filespec) { @ARGV = @filespec; } else { exit 0 if $wrong; @ARGV = ('-'); } } else { # @ARGV is empty @ARGV = ('-') unless @ARGV; } ######################################################################## # main process ######################################################################## my %Dc = ( 'up' => 0, 'right' => 90, 'down' => 180, 'left' => 270, 'ne' => 45, 'se' => 135, 'sw' => 225, 'nw' => 315, 0 => 'n', 90 => 'e', 180 => 's', 270 => 'w', 30 => 'ne', 45 => 'ne', 60 => 'ne', 120 => 'se', 135 => 'se', 150 => 'se', 210 => 'sw', 225 => 'sw', 240 => 'sw', 300 => 'nw', 315 => 'nw', 330 => 'nw', ); my $Word_Count; my @Words; my $Line_No; my $Last_Name = ''; # from init() my $First_Time = 1; my $Last_Type; my $Dir; # direction my %Types = ( 'RING' => 'R', 'MOL' => 'M', 'BOND' => 'B', 'OTHER' => 'O' # manifests ); # from setparams() my %Params; # from ring() my $Nput; my $Aromatic; my %Put; my %Dbl; my %Labtype; my %Define = (); my $File_Name = ''; my $Line = ''; &main(); { my $is_pic = ''; my $is_chem = ''; my $former_line = ''; ########## # main() # sub main { my $count_minus = 0; my @stdin = (); my $stdin = 0; # for centralizing the pic code open TMAC, "<$File_pic_tmac" and print <TMAC>; close TMAC; foreach (@ARGV) { $count_minus++ if /^-$/; } foreach my $arg (@ARGV) { &setparams(1.0); next unless $arg; $Line_No = 0; $is_pic = ''; $is_chem = ''; if ($arg eq '-') { $File_Name = 'standard input'; if ($stdin) { &main_line($_) foreach @stdin; } else { $stdin = 1; if ($count_minus <= 1) { while (<STDIN>) { &main_line($_); } } else { @stdin = (); while (<STDIN>) { push @stdin, $_; &main_line($_); } } } ### main() } else { # $arg is not - $File_Name = $arg; open FILE, "<$arg"; &main_line($_) while <FILE>; close FILE; } # if $arg if ($is_pic) { printf ".PE\n"; } } } # main() ########## # main_line() # sub main_line { my $line = $_[0]; # $Last_Type = $Types{'OTHER'}; # $Last_Type = ''; my $stack; $Line_No++; chomp $line; $line = $former_line . $line if $former_line; if ($line =~ /^(.*)\\$/) { $former_line = $1; return 1; } else { $former_line = ''; } $Line = $line; { @Words = (); my $s = $line; $s =~ s/^\s*//; $s =~ s/\s+$//; return 1 unless $s; $s = " $s"; $s =~ s/\s+#.*$// if $is_pic; return 1 unless $s; $line = $s; $line =~ s/^\s*|\s*$//g; my $bool = 1; while ($bool) { $s =~ /^([^"]*)\s("[^"]*"?\S*)(.*)$/; if (defined $1) { my $s1 = $1; my $s2 = $2; $s = $3; $s1 =~ s/^\s*|\s*$//g; push @Words, split(/\s+/, $s1) if $s1; push @Words, $s2; } if ($s !~ /\s"/) { $s =~ s/^\s*|\s*$//g; push @Words, split(/\s+/, $s) if $s; $bool = 0; } } # @Words = split(/\s+/, $s); return 1 unless @Words; # foreach my $i (0..$#Words) { # if ($Words[$i] =~ /^\s*#/) { # $#Words = $i - 1; # last; # } # } # return 1 unless @Words; } if ($line =~ /^([\.']\s*PS\s*)|([\.']\s*PS\s.+)$/) { # .PS unless ($is_pic) { $is_pic = 'running'; print "$line\n"; } return 1; } ### main_line() if ( $line =~ /^([\.']\s*PE\s*)|([\.']\s*PE\s.+)$/ ) { # .PE $is_chem = ''; if ($is_pic) { $is_pic = ''; print "$line\n"; } return 1; } if ($line =~ /^[\.']\s*cstart\s*$/) { # line: '.cstart' if ($is_chem) { &error("additional '.cstart'; chem is already active."); return 1; } unless ($is_pic) { &print_ps(); $is_pic = 'by chem'; } $is_chem = '.cstart'; &init(); return 1; } ### main_line() if ($line =~ /^\s*begin\s+chem\s*$/) { # line: 'begin chem' if ($is_pic) { if ($is_chem) { &error("additional 'begin chem'; chem is already active."); return 1; } $is_chem = 'begin chem'; &init(); } else { print "$line\n"; } return 1; } if ($line =~ /^[\.']\s*cend\s*/) { # line '.cend' if ($is_chem) { &error("you end chem with '.cend', but started it with 'begin chem'.") if $is_chem eq 'begin chem'; if ($is_pic eq 'by chem') { &print_pe(); $is_pic = ''; } $is_chem = ''; } else { print "$line\n"; } return 1; } if ($line =~ /^\s*end\s*$/) { # line: 'end' if ($is_chem) { &error("you end chem with 'end', but started it with '.cstart'.") if $is_chem eq '.cstart'; if ($is_pic eq 'by chem') { &print_pe(); $is_pic = ''; } $is_chem = ''; } else { print "$line\n"; } return 1; } ### main_line() if (! $is_chem) { print "$line\n"; return 1; } if ($line =~ /^[.']/) { # groff request line print "$line\n"; return 1; } if ($Words[0] eq 'pic') { # pic pass-thru return 1 if $#Words == 0; my $s = $line; $s =~ /^\s*pic\s*(.*)$/; $s = $1; print "$s\n" if $s; $Last_Type = $Types{'OTHER'}; $Define{ $Words[2] } = 1 if $#Words >= 2 && $Words[1] eq 'define'; return 1; } if ($Words[0] eq 'textht') { if ($#Words == 0) { &error("'textht' needs a single argument."); return 0; } &error("only the last argument is taken for 'textht', " . "all others are ignored.") unless $#Words <= 1 or ($#Words == 2 && $Words[1] =~ /^=/); $Params{'textht'} = $Words[$#Words]; return 1; } ### main_line() if ($Words[0] eq 'cwid') { # character width if ($#Words == 0) { &error("'cwid' needs a single argument."); return 0; } &error("only the last argument is taken for 'cwid', " . "all others are ignored.") unless $#Words <= 1 or ($#Words == 2 && $Words[1] =~ /^=/); $Params{'cwid'} = $Words[$#Words]; return 1; } if ($Words[0] eq 'db') { # bond length if ($#Words == 0) { &error("'db' needs a single argument."); return 0; } &error("only the last argument is taken for 'db', " . "all others are ignored.") unless $#Words <= 1 or ($#Words == 2 && $Words[1] =~ /^=/); $Params{'db'} = $Words[$#Words]; return 1; } if ($Words[0] eq 'size') { # size for all parts of the whole diagram my $size; if ($#Words == 0) { &error("'size' needs a single argument."); return 0; } &error("only the last argument is taken for 'size', " . "all others are ignored.") unless $#Words <= 1 or ($#Words == 2 && $Words[1] =~ /^=/); if ($Words[$#Words] <= 4) { $size = $Words[$#Words]; } else { $size = $Words[$#Words] / 10; } &setparams($size); return 1; } ### main_line() print "\n#", $Line, "\n"; # debugging, etc. $Last_Name = ''; # $Last_Type = $Types{'OTHER'}; # $Last_Type = ''; if ($Words[0] =~ /^[A-Z].*:$/) { # label; falls thru after shifting left my $w = $Words[0]; $Last_Name = $w; $Last_Name =~ s/:$//; print "$w"; shift @Words; if (@Words) { print " "; $line =~ s/^\s*$w\s*//; } else { print "\n"; return 1; } } if ($Words[0] eq 'define') { print "$line\n"; $Define{ $Words[1] } = 1 if $#Words >= 1; $Last_Type = $Types{'OTHER'}; return 1; } if ($Words[0] =~ /^[\[\]{}]/) { print "$line\n"; $Last_Type = $Types{'OTHER'}; return 1; } if ($Words[0] =~ /^"/) { print 'Last: ', $line, "\n"; $Last_Type = $Types{'OTHER'}; return 1; } if ($Words[0] =~ /bond/) { &bond($Words[0]); return 1; } if ($#Words >= 1) { if ($Words[0] =~ /^(double|triple|front|back)$/ && $Words[1] eq 'bond') { my $w = shift @Words; $Words[0] = $w . $Words[0]; &bond($Words[0]); return 1; } if ($Words[0] eq 'aromatic') { my $temp = $Words[0]; $Words[0] = $Words[1] ? $Words[1] : ''; $Words[1] = $temp; } } if ($Words[0] =~ /ring|benz/) { &ring($Words[0]); return 1; } if ($Words[0] eq 'methyl') { # left here as an example $Words[0] = 'CH3'; } ### main_line() if ($Words[0] =~ /^[A-Z]/) { &molecule(); return 1; } if ($Words[0] eq 'left') { my %left; # not used $left{++$stack} = &fields(1, $#Words); printf (("Last: [\n")); return 1; } if ($Words[0] eq 'right') { &bracket(); $stack--; return 1; } if ($Words[0] eq 'label') { # prints the vertex numbers in a ring if ( exists $Labtype{$Words[1]} and $Labtype{$Words[1]} =~ /^$Types{'RING'}/ ) { my $v = substr($Labtype{$Words[1]}, 1, 1); $Words[1] = '' unless $Words[1]; foreach my $i ( 1..$v ) { printf "\"\\s-3%d\\s0\" at 0.%d<%s.C,%s.V%d>\n", $i, $v + 2, $Words[1], $Words[1], $i; } } else { &error("$Words[1] is not a ring."); } return 1; } if ( exists $Define{ $Words[0] } ) { print $line, "\n"; $Last_Type = $Types{'OTHER'}; return 1; } return 1 unless $line; # print STDERR "# $Line\n"; # &error('This is not a chem command. To include a command for pic, ' . # "add 'pic' as the first word to the command."); print $line, "\n"; $Last_Type = $Types{'OTHER'}; 1; } # main_line() } ######################################################################## # functions ######################################################################## ########## # atom(<string>) # sub atom { # convert CH3 to atom(...) my ($s) = @_; my ($i, $n, $nsub, $cloc, $nsubc, @s); if ($s eq "\"\"") { return $s; } $n = length($s); $nsub = $nsubc = 0; $cloc = index($s, 'C'); if (! defined($cloc) || $cloc < 0) { $cloc = 0; } @s = split('', $s); $i = 0; foreach (@s) { unless (/[A-Z]/) { $nsub++; $nsubc++ if $i < $cloc; $i++; } } $s =~ s/([0-9]+\.[0-9]+)|([0-9]+)/\\s-3\\d$&\\u\\s+3/g; if ($s =~ /([^0-9]\.)|(\.[^0-9])/) { # centered dot $s =~ s/\./\\v#-.3m#.\\v#.3m#/g; } sprintf( "atom(\"%s\", %g, %g, %g, %g, %g, %g)", $s, ($n - $nsub / 2) * $Params{'cwid'}, $Params{'textht'}, ($cloc - $nsubc / 2 + 0.5) * $Params{'cwid'}, $Params{'crh'}, $Params{'crw'}, $Params{'dav'} ); } # atom() ########## # bond(<type>) # sub bond { my ($type) = @_; my ($i, $moiety, $from, $leng); $moiety = ''; for ($i = 1; $i <= $#Words; $i++) { if ($Words[$i] eq ';') { &error("a colon ';' must be followed by a space and a single word.") if $i != $#Words - 1; $moiety = $Words[$i + 1] if $#Words > $i; $#Words = $i - 1; last; } } $leng = $Params{'db'}; # bond length $from = ''; for ($Word_Count = 1; $Word_Count <= $#Words; ) { if ($Words[$Word_Count] =~ /(\+|-)?\d+|up|down|right|left|ne|se|nw|sw/) { $Dir = &cvtdir($Dir); } elsif ($Words[$Word_Count] =~ /^leng/) { $leng = $Words[$Word_Count + 1] if $#Words > $Word_Count; $Word_Count += 2; } elsif ($Words[$Word_Count] eq 'to') { $leng = 0; $from = &fields($Word_Count, $#Words); last; } elsif ($Words[$Word_Count] eq 'from') { $from = &dofrom(); last; } elsif ($Words[$Word_Count] =~ /^#/) { $Word_Count = $#Words + 1; last; } else { $from = &fields($Word_Count, $#Words); last; } } ### bond() if ($from =~ /( to )|^to/) { # said "from ... to ...", so zap length $leng = 0; } elsif (! $from) { # no from given at all $from = 'from Last.' . &leave($Last_Type, $Dir) . ' ' . &fields($Word_Count, $#Words); } printf "Last: %s(%g, %g, %s)\n", $type, $leng, $Dir, $from; $Last_Type = $Types{'BOND'}; $Labtype{$Last_Name} = $Last_Type if $Last_Name; if ($moiety) { @Words = ($moiety); &molecule(); } } # bond() ########## # bracket() # sub bracket { my $t; printf (("]\n")); if ($Words[1] && $Words[1] eq ')') { $t = 'spline'; } else { $t = 'line'; } printf "%s from last [].sw+(%g,0) to last [].sw to last [].nw to last " . "[].nw+(%g,0)\n", $t, $Params{'dbrack'}, $Params{'dbrack'}; printf "%s from last [].se-(%g,0) to last [].se to last [].ne to last " . "[].ne-(%g,0)\n", $t, $Params{'dbrack'}, $Params{'dbrack'}; if ($Words[2] && $Words[2] eq 'sub') { printf "\" %s\" ljust at last [].se\n", &fields(3, $#Words); } } # bracket() ########## # corner(<dir>) # # Return the corner name next to the given angle. # sub corner { my ($d) = @_; $Dc{ (45 * int(($d + 22.5) / 45)) % 360 }; } # corner() ########## # cvtdir(<dir>) # # Maps "[pointing] somewhere" to degrees. # sub cvtdir { my ($d) = @_; if ($Words[$Word_Count] eq 'pointing') { $Word_Count++; } if ($Words[$Word_Count] =~ /^[+\\-]?\d+/) { return ( $Words[$Word_Count++] % 360 ); } elsif ($Words[$Word_Count] =~ /left|right|up|down|ne|nw|se|sw/) { return ( $Dc{$Words[$Word_Count++]} % 360 ); } else { $Word_Count++; return $d; } } # cvtdir() ########## # dblring(<v>) # sub dblring { my ($v) = @_; my ($d, $v1, $v2); # should canonicalize to i,i+1 mod v $d = $Words[$Word_Count]; for ($Word_Count++; $Word_Count <= $#Words && $Words[$Word_Count] =~ /^[1-9]/; $Word_Count++) { $v1 = substr($Words[$Word_Count], 0, 1); $v2 = substr($Words[$Word_Count], 2, 1); if ($v2 == $v1 + 1 || $v1 == $v && $v2 == 1) { # e.g., 2,3 or 5,1 $Dbl{$v1} = $d; } elsif ($v1 == $v2 + 1 || $v2 == $v && $v1 == 1) { # e.g., 3,2 or 1,5 $Dbl{$v2} = $d; } else { &error(sprintf("weird %s bond in\n\t%s", $d, $_)); } } } # dblring() ########## # dofrom() # sub dofrom { my $n; $Word_Count++; # skip "from" $n = $Words[$Word_Count]; if (defined $Labtype{$n}) { # "from Thing" => "from Thing.V.s" return 'from ' . $n . '.' . &leave($Labtype{$n}, $Dir); } if ($n =~ /^\.[A-Z]/) { # "from .V" => "from Last.V.s" return 'from Last' . $n . '.' . &corner($Dir); } if ($n =~ /^[A-Z][^.]*\.[A-Z][^.]*$/) { # "from X.V" => "from X.V.s" return 'from ' . $n . '.' . &corner($Dir); } &fields($Word_Count - 1, $#Words); } # dofrom() ########## # error(<string>) # sub error { my ($s) = @_; printf STDERR "chem: error in %s on line %d: %s\n", $File_Name, $Line_No, $s; } # error() ########## # fields(<n1>, <n2>) # sub fields { my ($n1, $n2) = @_; if ($n1 > $n2) { return ''; } my $s = ''; foreach my $i ($n1..$n2) { if ($Words[$i] =~ /^#/) { last; } $s = $s . $Words[$i] . ' '; } $s; } # fields() ########## # init() # sub init { if ($First_Time) { printf "copy \"%s\"\n", $File_chem_pic; printf "\ttextht = %g; textwid = .1; cwid = %g\n", $Params{'textht'}, $Params{'cwid'}; printf "\tlineht = %g; linewid = %g\n", $Params{'lineht'}, $Params{'linewid'}; $First_Time = 0; } printf "Last: 0,0\n"; $Last_Type = $Types{'OTHER'}; $Dir = 90; } # init() ########## # leave(<last>, <d>) # sub leave { my ($last, $d) = @_; my ($c, $c1); # return vertex of $last in direction $d if ( $last eq $Types{'BOND'} ) { return 'end'; } $d %= 360; if ( $last =~ /^$Types{'RING'}/ ) { return &ringleave($last, $d); } if ( $last eq $Types{'MOL'} ) { if ($d == 0 || $d == 180) { $c = 'C'; } elsif ($d > 0 && $d < 180) { $c = 'R'; } else { $c = 'L'; } if (defined $Dc{$d}) { $c1 = $Dc{$d}; } else { $c1 = &corner($d); } return sprintf('%s.%s', $c, $c1); } if ( $last eq $Types{'OTHER'} ) { return &corner($d); } 'c'; } # leave() ########## # makering(<type>, <pt>, <v>) # sub makering { my ($type, $pt, $v) = @_; my ($i, $j, $a, $r, $rat, $fix, $c1, $c2); if ($type =~ /flat/) { $v = 6; # vertices ; } $r = $Params{'ringside'} / (2 * sin(pi / $v)); printf "\tC: 0,0\n"; for ($i = 0; $i <= $v + 1; $i++) { $a = (($i - 1) / $v * 360 + $pt) / 57.29578; # 57. is $deg printf "\tV%d: (%g,%g)\n", $i, $r * sin($a), $r * cos($a); } if ($type =~ /flat/) { printf "\tV4: V5; V5: V6\n"; $v = 5; } # sides if ($Nput > 0) { # hetero ... for ($i = 1; $i <= $v; $i++) { $c1 = $c2 = 0; if ($Put{$i} ne '') { printf "\tV%d: ellipse invis ht %g wid %g at V%d\n", $i, $Params{'crh'}, $Params{'crw'}, $i; printf "\t%s at V%d\n", $Put{$i}, $i; $c1 = $Params{'cr'}; } $j = $i + 1; if ($j > $v) { $j = 1; } ### makering() if ($Put{$j} ne '') { $c2 = $Params{'cr'}; } printf "\tline from V%d to V%d chop %g chop %g\n", $i, $j, $c1, $c2; if ($Dbl{$i} ne '') { # should check i<j if ($type =~ /flat/ && $i == 3) { $rat = 0.75; $fix = 5; } else { $rat = 0.85; $fix = 1.5; } if ($Put{$i} eq '') { $c1 = 0; } else { $c1 = $Params{'cr'} / $fix; } if ($Put{$j} eq '') { $c2 = 0; } else { $c2 = $Params{'cr'} / $fix; } printf "\tline from %g<C,V%d> to %g<C,V%d> chop %g chop %g\n", $rat, $i, $rat, $j, $c1, $c2; if ($Dbl{$i} eq 'triple') { printf "\tline from %g<C,V%d> to %g<C,V%d> chop %g chop %g\n", 2 - $rat, $i, 2 - $rat, $j, $c1, $c2; } } } ### makering() } else { # regular for ($i = 1; $i <= $v; $i++) { $j = $i + 1; if ($j > $v) { $j = 1; } printf "\tline from V%d to V%d\n", $i, $j; if ($Dbl{$i} ne '') { # should check i<j if ($type =~ /flat/ && $i == 3) { $rat = 0.75; } else { $rat = 0.85; } printf "\tline from %g<C,V%d> to %g<C,V%d>\n", $rat, $i, $rat, $j; if ($Dbl{$i} eq 'triple') { printf "\tline from %g<C,V%d> to %g<C,V%d>\n", 2 - $rat, $i, 2 - $rat, $j; } } } } ### makering() # punt on triple temporarily # circle if ($type =~ /benz/ || $Aromatic > 0) { if ($type =~ /flat/) { $r *= .4; } else { $r *= .5; } printf "\tcircle rad %g at 0,0\n", $r; } } # makering() ########## # molecule() # sub molecule { my ($n, $type); if ($#Words >= 0) { $n = $Words[0]; if ($n eq 'BP') { $Words[0] = "\"\" ht 0 wid 0"; $type = $Types{'OTHER'}; } else { $Words[0] = &atom($n); $type = $Types{'MOL'}; } } $n =~ s/[^A-Za-z0-9]//g; # for stuff like C(OH3): zap non-alnum if ($#Words < 1) { printf "Last: %s: %s with .%s at Last.%s\n", $n, join(' ', @Words), &leave($type, $Dir + 180), &leave($Last_Type, $Dir); ### molecule() } else { if (! $Words[1]) { printf "Last: %s: %s with .%s at Last.%s\n", $n, join(' ', @Words), &leave($type, $Dir + 180), &leave($Last_Type, $Dir); } elsif ($#Words >= 1 and $Words[1] eq 'below') { $Words[2] = '' if ! $Words[2]; printf "Last: %s: %s with .n at %s.s\n", $n, $Words[0], $Words[2]; } elsif ($#Words >= 1 and $Words[1] eq 'above') { $Words[2] = '' if ! $Words[2]; printf "Last: %s: %s with .s at %s.n\n", $n, $Words[0], $Words[2]; } elsif ($#Words >= 2 and $Words[1] eq 'left' && $Words[2] eq 'of') { $Words[3] = '' if ! $Words[3]; printf "Last: %s: %s with .e at %s.w+(%g,0)\n", $n, $Words[0], $Words[3], $Params{'dew'}; } elsif ($#Words >= 2 and $Words[1] eq 'right' && $Words[2] eq 'of') { $Words[3] = '' if ! $Words[3]; printf "Last: %s: %s with .w at %s.e-(%g,0)\n", $n, $Words[0], $Words[3], $Params{'dew'}; } else { printf "Last: %s: %s\n", $n, join(' ', @Words); } } $Last_Type = $type; if ($Last_Name) { # $Last_Type = ''; $Labtype{$Last_Name} = $Last_Type; } $Labtype{$n} = $Last_Type; } # molecule() ########## # print_hash(<hash_or_ref>) # # print the elements of a hash or hash reference # sub print_hash { my $hr; my $n = scalar @_; if ($n == 0) { print STDERR "empty hash\n;"; return 1; } elsif ($n == 1) { if (ref($_[0]) eq 'HASH') { $hr = $_[0]; } else { warn 'print_hash(): the argument is not a hash or hash reference;'; return 0; } } else { if ($n % 2) { warn 'print_hash(): the arguments are not a hash;'; return 0; } else { my %h = @_; $hr = \%h; } } ### print_hash() unless (%$hr) { print STDERR "empty hash\n"; return 1; } print STDERR "hash (ignore the ^ characters):\n"; for my $k (sort keys %$hr) { my $hk = $hr->{$k}; print STDERR " $k => "; if (defined $hk) { print STDERR "^$hk^"; } else { print STDERR "undef"; } print STDERR "\n"; } 1; } # print_hash() ########## # print_pe() # sub print_pe { print ".PE\n"; } # print_pe() ########## # print_ps() # sub print_ps { print ".PS\n"; } # print_ps() ########## # putring(<v>) # sub putring { # collect "put Mol at n" my ($v) = @_; my ($m, $mol, $n); $Word_Count++; $mol = $Words[$Word_Count++]; if ($Words[$Word_Count] eq 'at') { $Word_Count++; } $n = $Words[$Word_Count]; if ($n !~ /^\d+$/) { $n =~ s/(\d)+$/$1/; $n = 0 if $n !~ /^\d+$/; error('use single digit as argument for "put at"'); } if ($n >= 1 && $n <= $v) { $m = $mol; $m =~ s/[^A-Za-z0-9]//g; $Put{$n} = $m . ':' . &atom($mol); } elsif ($n == 0) { error('argument of "put at" must be a single digit'); } else { error('argument of "put at" is too large'); } $Word_Count++; } # putring() ########## # ring(<type>) # sub ring { my ($type) = @_; my ($typeint, $pt, $verts, $i, $other, $fused, $withat); $pt = 0; # points up by default if ($type =~ /([1-8])$/) { $verts = $1; } elsif ($type =~ /flat/) { $verts = 5; } else { $verts = 6; } $fused = $other = ''; for ($i = 1; $i <= $verts; $i++) { $Put{$i} = $Dbl{$i} = ''; } $Nput = $Aromatic = $withat = 0; for ($Word_Count = 1; $Word_Count <= $#Words; ) { if ($Words[$Word_Count] eq 'pointing') { $pt = &cvtdir(0); } elsif ($Words[$Word_Count] eq 'double' || $Words[$Word_Count] eq 'triple') { &dblring($verts); } elsif ($Words[$Word_Count] =~ /arom/) { $Aromatic++; $Word_Count++; # handled later ### ring() } elsif ($Words[$Word_Count] eq 'put') { &putring($verts); $Nput++; } elsif ($Words[$Word_Count] =~ /^#/) { $Word_Count = $#Words + 1; last; } else { if ($Words[$Word_Count] eq 'with' || $Words[$Word_Count] eq 'at') { $withat = 1; } $other = $other . ' ' . $Words[$Word_Count]; $Word_Count++; } } $typeint = $Types{'RING'} . $verts . $pt; # RING | verts | dir if ($withat == 0) { # join a ring to something if ( $Last_Type =~ /^$Types{'RING'}/ ) { # ring to ring if (substr($typeint, 2) eq substr($Last_Type, 2)) { # fails if not 6-sided $fused = 'with .V6 at Last.V2'; } } # if all else fails $fused = sprintf('with .%s at Last.%s', &leave($typeint, $Dir + 180), &leave($Last_Type, $Dir)); } printf "Last: [\n"; &makering($type, $pt, $verts); printf "] %s %s\n", $fused, $other; $Last_Type = $typeint; $Labtype{$Last_Name} = $Last_Type if $Last_Name; } # ring() ########## # ringleave(<last>, <d>) # sub ringleave { my ($last, $d) = @_; my ($rd, $verts); # return vertex of ring in direction d $verts = substr($last, 1, 1); $rd = substr($last, 2); sprintf('V%d.%s', int( (($d - $rd) % 360) / (360 / $verts)) + 1, &corner($d)); } # ringleave() ########## # setparams(<scale>) # sub setparams { my ($scale) = @_; $Params{'lineht'} = $scale * 0.2; $Params{'linewid'} = $scale * 0.2; $Params{'textht'} = $scale * 0.16; $Params{'db'} = $scale * 0.2; # bond length $Params{'cwid'} = $scale * 0.12; # character width $Params{'cr'} = $scale * 0.08; # rad of invis circles at ring vertices $Params{'crh'} = $scale * 0.16; # ht of invis ellipse at ring vertices $Params{'crw'} = $scale * 0.12; # wid $Params{'dav'} = $scale * 0.015; # vertical shift up for atoms in atom macro $Params{'dew'} = $scale * 0.02; # east-west shift for left of/right of $Params{'ringside'} = $scale * 0.3; # side of all rings $Params{'dbrack'} = $scale * 0.1; # length of bottom of bracket } # setparams() ########## # usage() # # Print usage information for --help. # sub usage { print "\n"; &version(); print <<EOF; Usage: $Chem_Name [option]... [filespec]... $Chem_Name is a groff preprocessor for producing chemical structure diagrams. The output suits to the pic preprocessor. "filespec" is one of "filename" name of a readable file "-" for standard input All available options are -h --help print this usage message. -v --version print version information. EOF } # usage() ########## # version() # # Get version information from version.sh and print a text with this. # sub version { $Groff_Version = $Groff_Version_Preset unless $Groff_Version; print <<EOF; $Chem_Name $Program_Version (Perl version) is part of groff version $Groff_Version. $Copyright GNU groff and chem come with ABSOLUTELY NO WARRANTY. You may redistribute copies of groff and its subprograms under the terms of the GNU General Public License. EOF } # version() 1; ### Emacs settings # Local Variables: # mode: CPerl # End:
Upload File
Create Folder