diff --git a/.gitignore b/.gitignore
index 8957273c9..98370cdbe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,23 +1,296 @@
-plan9.log
-plan9-reverse.log
-state
-state.old
-state.journal
-*.o
*.a
-man/man?/*.html
-src/**/o.*
-y.tab.[ch]
-src/cmd/rc/x.tab.h
-unix/*.tgz
-bin/
-log/
-dict/
-postscript/font/
+*.o
*.orig
+LOCAL.config
+bin/"
+bin/""
+bin/9660srv
+bin/9import
+bin/9p
+bin/9pfuse
+bin/9pserve
+bin/9term
+bin/Mail
+bin/Netfiles
+bin/acid
+bin/acidtypes
+bin/acme
+bin/acmeevent
+bin/aescbc
+bin/ascii
+bin/asn12dsa
+bin/asn12rsa
+bin/astro
+bin/auxclog
+bin/auxstats
+bin/awk
+bin/basename
+bin/bc
+bin/bmp
+bin/bunzip2
+bin/bzip2
+bin/cal
+bin/calendar
+bin/cat
+bin/cb
+bin/cleanname
+bin/clock
+bin/cmapcube
+bin/cmp
+bin/col
+bin/colors
+bin/comm
+bin/compress
+bin/core
+bin/crop
+bin/date
+bin/db
+bin/dc
+bin/dd
+bin/delatex
+bin/deroff
+bin/devdraw
+bin/dial
+bin/dict
+bin/diff
+bin/disk/mkext
+bin/disk/mkfs
+bin/disknfs
+bin/dns
+bin/dnsdebug
+bin/dnsquery
+bin/dnstcp
+bin/dsa2pub
+bin/dsa2ssh
+bin/dsagen
+bin/dsasign
+bin/du
+bin/dump9660
+bin/echo
+bin/ed
+bin/eqn
+bin/factor
+bin/factotum
+bin/file
+bin/fmt
+bin/fontsrv
+bin/fortune
+bin/fossil/conf
+bin/fossil/flchk
+bin/fossil/flfmt
+bin/fossil/fossil
+bin/fossil/last
+bin/fossil/view
+bin/freq
+bin/fs/32vfs
+bin/fs/cpiofs
+bin/fs/tapfs
+bin/fs/tarfs
+bin/fs/tpfs
+bin/fs/v10fs
+bin/fs/v6fs
+bin/fs/zipfs
+bin/fsize
+bin/getflags
+bin/gif
+bin/grap
+bin/graph
+bin/grep
+bin/gunzip
+bin/gview
+bin/gzip
+bin/hget
+bin/hist
+bin/hoc
+bin/htmlfmt
+bin/htmlroff
+bin/ico
+bin/iconv
+bin/idiff
+bin/img
+bin/import
+bin/join
+bin/jpg
+bin/lex
+bin/listen1
+bin/look
+bin/ls
+bin/macargv
+bin/mapd
+bin/mc
+bin/md5sum
+bin/mk
+bin/mk9660
+bin/mkdir
+bin/mklatinkbd
+bin/mtime
+bin/namespace
+bin/ndbipquery
+bin/ndbmkdb
+bin/ndbmkhash
+bin/ndbmkhosts
+bin/ndbquery
+bin/netfileget
+bin/netfilelib.rc
+bin/netfileput
+bin/netfilestat
+bin/netkey
+bin/news
+bin/p
+bin/page
+bin/paint
+bin/passwd
+bin/pbd
+bin/pemdecode
+bin/pemencode
+bin/pic
+bin/plot
+bin/plumb
+bin/plumber
+bin/png
+bin/ppm
+bin/pr
+bin/primes
+bin/proof
+bin/psdownload
+bin/ramfs
+bin/rc
+bin/read
+bin/readcons
+bin/resample
+bin/rio
+bin/rm
+bin/rsa2csr
+bin/rsa2pub
+bin/rsa2ssh
+bin/rsa2x509
+bin/rsafill
+bin/rsagen
+bin/sam
+bin/samterm
+bin/scat
+bin/secstore
+bin/secstored
+bin/secuser
+bin/sed
+bin/seq
+bin/sftpcache
+bin/sha1sum
+bin/sleep
+bin/sort
+bin/split
+bin/sprog
+bin/srv
+bin/ssh-agent
+bin/stats
+bin/statusbar
+bin/strings
+bin/sum
+bin/svgpic
+bin/tail
+bin/tar
+bin/tbl
+bin/tcolors
+bin/tcs
+bin/tee
+bin/test
+bin/time
+bin/togif
+bin/toico
+bin/topng
+bin/toppm
+bin/touch
+bin/tpic
+bin/tr
+bin/tr2post
+bin/troff
+bin/troff2html
+bin/tweak
+bin/uncompress
+bin/unicode
+bin/uniq
+bin/units
+bin/unutf
+bin/unvac
+bin/unzip
+bin/usage
+bin/vac
+bin/vacfs
+bin/vbackup
+bin/vcat
+bin/venti/buildindex
+bin/venti/checkarenas
+bin/venti/checkindex
+bin/venti/clumpstats
+bin/venti/conf
+bin/venti/copy
+bin/venti/dump
+bin/venti/findscore
+bin/venti/fixarenas
+bin/venti/fmtarenas
+bin/venti/fmtbloom
+bin/venti/fmtindex
+bin/venti/fmtisect
+bin/venti/mirrorarenas
+bin/venti/printarena
+bin/venti/printarenapart
+bin/venti/rdarena
+bin/venti/read
+bin/venti/ro
+bin/venti/sync
+bin/venti/syncindex
+bin/venti/venti
+bin/venti/verifyarena
+bin/venti/wrarena
+bin/venti/write
+bin/vmount0
+bin/vnfs
+bin/wc
+bin/win
+bin/winwatch
+bin/xd
+bin/xshove
+bin/yacc
+bin/yuv
+bin/zcat
+bin/zerotrunc
+bin/zip
config
+dict/
install.log
install.sum
last-change
+lib/fortunes.index
+log/
+man/man?/*.html
+plan9-reverse.log
+plan9.log
+postscript/font/
+sky/*.scat
+sky/here
+src/**/o.*
+src/cmd/awk/proctab.c
src/cmd/awk/y.output
+src/cmd/bc.tab.c
+src/cmd/bc.tab.h
+src/cmd/delatex.c
src/cmd/devdraw/latin1.h
+src/cmd/eqn/eqn.c
+src/cmd/eqn/prevy.tab.h
+src/cmd/grap/grap.c
+src/cmd/grap/grapl.c
+src/cmd/jpg/rgbv.h
+src/cmd/jpg/ycbcr.h
+src/cmd/pic/picl.c
+src/cmd/pic/picy.c
+src/cmd/rc/x.tab.h
+src/cmd/svgpic/picl.c
+src/cmd/svgpic/picy.c
+src/cmd/tpic/picy.c
+src/cmd/units.tab.c
+src/cmd/units.tab.h
+state
+state.journal
+state.old
+unix/*.tgz
+y.tab.[ch]
diff --git a/.travis.yml b/.travis.yml
index 94ae95e5a..091fd351f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,6 +2,10 @@ language: c
matrix:
include:
+ - os: osx
+ osx_image: xcode10.2
+ - os: osx
+ osx_image: xcode9.4
- os: osx
osx_image: xcode9
- os: osx
diff --git a/INSTALL b/INSTALL
index 4673056b5..79c0745fa 100755
--- a/INSTALL
+++ b/INSTALL
@@ -15,120 +15,95 @@ x-c)
doinstall=true
;;
x-r)
- shift
- PLAN9_TARGET=$1 export PLAN9_TARGET
- ;;
+ shift
+ PLAN9_TARGET=$1 export PLAN9_TARGET
+ ;;
*)
echo 'usage: INSTALL [-b | -c] [-r path]' 1>&2
exit 1
esac
+echo "+ Mailing list: https://groups.google.com/group/plan9port-dev"
+echo "+ Issue tracker: https://github.com/9fans/plan9port/issues/"
+echo "+ Submitting changes: https://github.com/9fans/plan9port/pulls"
+echo " "
+echo "* Resetting $PLAN9/config"
+rm -f config
+
PLAN9=`pwd` export PLAN9
PATH=/bin:/usr/bin:$PLAN9/bin:$PATH export PATH
case `uname` in
SunOS)
awk=nawk
;;
+DragonFly|*BSD)
+ case `cc -v 2>&1` in
+ *clang*)
+ echo "CC9=clang" >> $PLAN9/config
+ ;;
+ *gcc*)
+ echo "CC9=gcc" >> $PLAN9/config
+ ;;
+ esac
+ echo "* Running on" `uname`", adjusting linker flags"
+ case `uname` in
+ OpenBSD)
+ echo "LDFLAGS='-L/usr/X11R6/lib -pthread'" >> $PLAN9/config
+ ;;
+ NetBSD)
+ echo "LDFLAGS='-L/usr/X11R7/lib -pthread'" >> $PLAN9/config
+ ;;
+ *)
+ echo "LDFLAGS='-L/usr/local/lib -pthread'" >> $PLAN9/config
+ ;;
+ esac
+ echo "CFLAGS='-pthread'" >> $PLAN9/config
+ awk=awk
+ ;;
*)
awk=awk
;;
esac
-echo "+ Mailing list: https://groups.google.com/group/plan9port-dev"
-echo "+ Issue tracker: https://github.com/9fans/plan9port/issues/"
-echo "+ Submitting changes: https://github.com/9fans/plan9port/pulls"
-echo " "
-echo "* Resetting $PLAN9/config"
-rm -f config
-
(
-echo "* Compiler version:"
-9c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/ /'
-
-if [ `uname` = FreeBSD ]; then
- echo "* Running on FreeBSD, adjusting linker flags"
- echo "LDFLAGS='-L/usr/local/lib'" >> $PLAN9/config
-fi
-
-if [ `uname` = DragonFly ]; then
- echo "* Running on DragonFly BSD, adjusting linker flags"
- echo "LDFLAGS='-L/usr/local/lib -pthread'" >> $PLAN9/config
- echo "CFLAGS='-pthread'" >> $PLAN9/config
-fi
-
-if [ `uname` = OpenBSD ]; then
- echo "* Running on OpenBSD, adjusting linker flags"
- echo "LDFLAGS='-L/usr/X11R6/lib -pthread'" >> $PLAN9/config
-fi
-
-if [ `uname` = Linux ]; then
- # On Linux, we use the kernel version to decide whether
- # to use pthreads or not. On 2.6 versions that aren't
- # linking with NPTL by default, pretend to be an older kernel.
- echo "* Running on Linux: checking for NPTL..."
- gcc lib/linux-isnptl.c -lpthread
- if ./a.out >/dev/null
- then
- echo " NPTL found."
- echo "SYSVERSION=2.6.x" >>$PLAN9/config
- else
- echo " NPTL not found."
- echo "SYSVERSION=2.4.x" >>$PLAN9/config
- fi
- rm -f ./a.out
-fi
-
if [ `uname` = SunOS ]; then
# On Solaris x86, uname -p cannot be trusted.
- echo "* Running on Solaris: checking architecture..."
- case "$(isainfo -n)" in
+ echo "* Running on Solaris: checking architecture..."
+ case "$(isainfo -n)" in
*amd64*)
- echo " x86-64 found."
- echo "OBJTYPE=x86_64" >>$PLAN9/config
+ echo " x86-64 found; using gcc."
echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/amd64
;;
*i386*)
- echo " i386 found."
- echo "OBJTYPE=386" >>$PLAN9/config
+ echo " i386 found; using gcc."
echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/i386
;;
- *sparc*)
+ *sparc*)
echo " Sparc found."
- echo "OBJTYPE=sparc" >>$PLAN9/config
;;
esac
fi
if [ `uname` = Darwin ]; then
+ export NPROC=$(sysctl hw.ncpu | sed 's/hw.ncpu: //')
# On Darwin, uname -m -p cannot be trusted.
- echo "* Running on Darwin: checking architecture..."
+ echo "* Running on Darwin..."
rm -f ./a.out
- if ! gcc lib/darwin-main.c >/dev/null 2>&1; then
- echo "Cannot find gcc. You may need to install the command-line tools using Xcode." >&2
+ if ! xcrun --sdk macosx clang lib/darwin-main.c >/dev/null 2>&1; then
+ echo "Cannot find 'xcrun --sdk macosx clang'." >&2
+ echo "You may need to install the command-line tools using Xcode." >&2
echo "See http://swtch.com/go/xcodegcc for details." >&2
exit 1
fi
- case "$(file ./a.out 2>/dev/null)" in
- *x86_64*)
- echo " x86-64 found."
- echo "OBJTYPE=x86_64" >>$PLAN9/config
- ;;
- *i386*)
- echo " i386 found."
- echo "OBJTYPE=386" >>$PLAN9/config
- ;;
- *ppc*)
- echo " power found."
- echo "OBJTYPE=power" >>$PLAN9/config
- ;;
- esac
+ echo "CC9='xcrun --sdk macosx clang'" >>$PLAN9/config
rm -f ./a.out
fi
if [ `uname` != Darwin ]; then
# Determine whether fontsrv X11 files are available.
rm -f a.out
- gcc -o a.out -c -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 \
+ cc -o a.out -c -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 \
+ -I/usr/X11R7/include -I/usr/X11R7/include/freetype2 \
-I/usr/X11R6/include -I/usr/X11R6/include/freetype2 src/cmd/fontsrv/x11.c >/dev/null 2>&1
if [ -f a.out ]; then
echo " fontsrv dependencies found."
@@ -147,17 +122,19 @@ if [ -f LOCAL.config ]; then
cat LOCAL.config >>config
fi
+echo "* Compiler version:"
+9c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/ /'
+
cd src
if $dobuild; then
- if [ ! -x ../bin/mk ]; then
- echo "* Building mk..."
- ../dist/buildmk 2>&1 | sed 's/^[+] //'
- fi
+ echo "* Building mk..."
+ ../dist/buildmk 2>&1 | sed 's/^[+] //'
+
if [ ! -x ../bin/mk ]; then
echo "* Error: mk failed to build."
exit 1
fi
-
+
echo "* Building everything (be patient)..."
mk clean
mk libs-nuke
@@ -205,13 +182,13 @@ if $doinstall; then
mk man
)
fi
-
+
if [ -x LOCAL.INSTALL ]; then
echo "* Running local modifications..."
echo cd `pwd`';' ./LOCAL.INSTALL
./LOCAL.INSTALL
fi
-
+
echo "* Done. "
echo " "
echo "* Add these to your profile environment."
diff --git a/LICENSE b/LICENSE
index 6110e313d..52d0f5ff5 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,257 +1,49 @@
-Copyright © 2000-2009 Lucent Technologies. All Rights Reserved.
+Copyright © 2021 Plan 9 Foundation
Portions Copyright © 2001-2008 Russ Cox
Portions Copyright © 2008-2009 Google Inc.
-===================================================================
-
-The bulk of this software is derived from Plan 9 and is thus distributed
-under the Lucent Public License, Version 1.02, reproduced below.
-
-There are a few exceptions: libutf, libfmt, and libregexp are distributed
-under simpler BSD-like boilerplates. See the LICENSE files in those
-directories. There are other exceptions, also marked with LICENSE files
-in their directories or marked at the top of the file.
-
-The bitmap fonts in the font/luc, font/lucm, font/lucsans, and font/pelm
-directory are copyright B&H Inc. and distributed under more restricted
-terms under agreement with B&H. See the NOTICE file in those directories.
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
===================================================================
-Lucent Public License Version 1.02
-
-THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS PUBLIC
-LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE
-PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
-
-1. DEFINITIONS
-
-"Contribution" means:
-
- a. in the case of Lucent Technologies Inc. ("LUCENT"), the Original
- Program, and
- b. in the case of each Contributor,
-
- i. changes to the Program, and
- ii. additions to the Program;
-
- where such changes and/or additions to the Program were added to the
- Program by such Contributor itself or anyone acting on such
- Contributor's behalf, and the Contributor explicitly consents, in
- accordance with Section 3C, to characterization of the changes and/or
- additions as Contributions.
-
-"Contributor" means LUCENT and any other entity that has Contributed a
-Contribution to the Program.
-
-"Distributor" means a Recipient that distributes the Program,
-modifications to the Program, or any part thereof.
-
-"Licensed Patents" mean patent claims licensable by a Contributor
-which are necessarily infringed by the use or sale of its Contribution
-alone or when combined with the Program.
-
-"Original Program" means the original version of the software
-accompanying this Agreement as released by LUCENT, including source
-code, object code and documentation, if any.
-
-"Program" means the Original Program and Contributions or any part
-thereof
-
-"Recipient" means anyone who receives the Program under this
-Agreement, including all Contributors.
-
-2. GRANT OF RIGHTS
-
- a. Subject to the terms of this Agreement, each Contributor hereby
- grants Recipient a non-exclusive, worldwide, royalty-free copyright
- license to reproduce, prepare derivative works of, publicly display,
- publicly perform, distribute and sublicense the Contribution of such
- Contributor, if any, and such derivative works, in source code and
- object code form.
-
- b. Subject to the terms of this Agreement, each Contributor hereby
- grants Recipient a non-exclusive, worldwide, royalty-free patent
- license under Licensed Patents to make, use, sell, offer to sell,
- import and otherwise transfer the Contribution of such Contributor, if
- any, in source code and object code form. The patent license granted
- by a Contributor shall also apply to the combination of the
- Contribution of that Contributor and the Program if, at the time the
- Contribution is added by the Contributor, such addition of the
- Contribution causes such combination to be covered by the Licensed
- Patents. The patent license granted by a Contributor shall not apply
- to (i) any other combinations which include the Contribution, nor to
- (ii) Contributions of other Contributors. No hardware per se is
- licensed hereunder.
-
- c. Recipient understands that although each Contributor grants the
- licenses to its Contributions set forth herein, no assurances are
- provided by any Contributor that the Program does not infringe the
- patent or other intellectual property rights of any other entity. Each
- Contributor disclaims any liability to Recipient for claims brought by
- any other entity based on infringement of intellectual property rights
- or otherwise. As a condition to exercising the rights and licenses
- granted hereunder, each Recipient hereby assumes sole responsibility
- to secure any other intellectual property rights needed, if any. For
- example, if a third party patent license is required to allow
- Recipient to distribute the Program, it is Recipient's responsibility
- to acquire that license before distributing the Program.
-
- d. Each Contributor represents that to its knowledge it has sufficient
- copyright rights in its Contribution, if any, to grant the copyright
- license set forth in this Agreement.
-
-3. REQUIREMENTS
-
-A. Distributor may choose to distribute the Program in any form under
-this Agreement or under its own license agreement, provided that:
-
- a. it complies with the terms and conditions of this Agreement;
-
- b. if the Program is distributed in source code or other tangible
- form, a copy of this Agreement or Distributor's own license agreement
- is included with each copy of the Program; and
-
- c. if distributed under Distributor's own license agreement, such
- license agreement:
-
- i. effectively disclaims on behalf of all Contributors all warranties
- and conditions, express and implied, including warranties or
- conditions of title and non-infringement, and implied warranties or
- conditions of merchantability and fitness for a particular purpose;
- ii. effectively excludes on behalf of all Contributors all liability
- for damages, including direct, indirect, special, incidental and
- consequential damages, such as lost profits; and
- iii. states that any provisions which differ from this Agreement are
- offered by that Contributor alone and not by any other party.
-
-B. Each Distributor must include the following in a conspicuous
- location in the Program:
-
- Copyright (C) 2003, Lucent Technologies Inc. and others. All Rights
- Reserved.
-
-C. In addition, each Contributor must identify itself as the
-originator of its Contribution in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution.
-Also, each Contributor must agree that the additions and/or changes
-are intended to be a Contribution. Once a Contribution is contributed,
-it may not thereafter be revoked.
-
-4. COMMERCIAL DISTRIBUTION
-
-Commercial distributors of software may accept certain
-responsibilities with respect to end users, business partners and the
-like. While this license is intended to facilitate the commercial use
-of the Program, the Distributor who includes the Program in a
-commercial product offering should do so in a manner which does not
-create potential liability for Contributors. Therefore, if a
-Distributor includes the Program in a commercial product offering,
-such Distributor ("Commercial Distributor") hereby agrees to defend
-and indemnify every Contributor ("Indemnified Contributor") against
-any losses, damages and costs (collectively"Losses") arising from
-claims, lawsuits and other legal actions brought by a third party
-against the Indemnified Contributor to the extent caused by the acts
-or omissions of such Commercial Distributor in connection with its
-distribution of the Program in a commercial product offering. The
-obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement.
-In order to qualify, an Indemnified Contributor must: a) promptly
-notify the Commercial Distributor in writing of such claim, and b)
-allow the Commercial Distributor to control, and cooperate with the
-Commercial Distributor in, the defense and any related settlement
-negotiations. The Indemnified Contributor may participate in any such
-claim at its own expense.
-
-For example, a Distributor might include the Program in a commercial
-product offering, Product X. That Distributor is then a Commercial
-Distributor. If that Commercial Distributor then makes performance
-claims, or offers warranties related to Product X, those performance
-claims and warranties are such Commercial Distributor's responsibility
-alone. Under this section, the Commercial Distributor would have to
-defend claims against the Contributors related to those performance
-claims and warranties, and if a court requires any Contributor to pay
-any damages as a result, the Commercial Distributor must pay those
-damages.
-
-5. NO WARRANTY
-
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
-PROVIDED ON AN"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
-WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
-OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and
-distributing the Program and assumes all risks associated with its
-exercise of rights under this Agreement, including but not limited to
-the risks and costs of program errors, compliance with applicable
-laws, damage to or loss of data, programs or equipment, and
-unavailability or interruption of operations.
-
-6. DISCLAIMER OF LIABILITY
-
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
-ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
-WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
-DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
-HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
-7. EXPORT CONTROL
-
-Recipient agrees that Recipient alone is responsible for compliance
-with the United States export administration regulations (and the
-export control laws and regulation of any other countries).
-
-8. GENERAL
-
-If any provision of this Agreement is invalid or unenforceable under
-applicable law, it shall not affect the validity or enforceability of
-the remainder of the terms of this Agreement, and without further
-action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.
+This software is derived from Plan 9, originally copyright Lucent Technologies
+and distributed under the Lucent Public License, Version 1.02.
+Lucent was bought by Alcatel, which was bought by Nokia.
+On March 23, 2021, Nokia announced the transfer of the Plan 9 copyrights to the
+Plan 9 Foundation, which in turn relicensed Plan 9 under the the MIT license,
+reproduced above.
-If Recipient institutes patent litigation against a Contributor with
-respect to a patent applicable to software (including a cross-claim or
-counterclaim in a lawsuit), then any patent licenses granted by that
-Contributor to such Recipient under this Agreement shall terminate as
-of the date such litigation is filed. In addition, if Recipient
-institutes patent litigation against any entity (including a
-cross-claim or counterclaim in a lawsuit) alleging that the Program
-itself (excluding combinations of the Program with other software or
-hardware) infringes such Recipient's patent(s), then such Recipient's
-rights granted under Section 2(b) shall terminate as of the date such
-litigation is filed.
+There are a few exceptions, noted with LICENSE files in their own directories:
-All Recipient's rights under this Agreement shall terminate if it
-fails to comply with any of the material terms or conditions of this
-Agreement and does not cure such failure in a reasonable period of
-time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use
-and distribution of the Program as soon as reasonably practicable.
-However, Recipient's obligations under this Agreement and any licenses
-granted by Recipient relating to the Program shall continue and
-survive.
+The bzip2 program uses the bzip2 license; see src/cmd/bzip2/LICENSE.
-LUCENT may publish new versions (including revisions) of this
-Agreement from time to time. Each new version of the Agreement will be
-given a distinguishing version number. The Program (including
-Contributions) may always be distributed subject to the version of the
-Agreement under which it was received. In addition, after a new
-version of the Agreement is published, Contributor may elect to
-distribute the Program (including its Contributions) under the new
-version. No one other than LUCENT has the right to modify this
-Agreement. Except as expressly stated in Sections 2(a) and 2(b) above,
-Recipient receives no rights or licenses to the intellectual property
-of any Contributor under this Agreement, whether expressly, by
-implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.
+The fonts from Bigelow and Holmes were licensed only for Plan 9 itself,
+not for derivatives like Plan 9 from User Space.
-This Agreement is governed by the laws of the State of New York and
-the intellectual property laws of the United States of America. No
-party to this Agreement will bring a legal action under this Agreement
-more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.
+Plan 9 from User Space arranged a separate agreement with B&H to include
+the bitmap fonts in the font/luc, font/lucm, font/lucsans, and font/pelm
+directories. Other bitmap fonts have other licenses. See font/LICENSE.
+The Lucida Sans Unicode PostScript fonts were licensed from B&H only for Plan 9
+itself, not derivatives like Plan 9 from User Space. In their place, Plan 9 from
+User Space provides Luxi Sans, also by B&H but available under a more liberal
+license, and Deja Vu, a Unicode extension of the Bitstream Vera family of fonts.
+Luxi Sans is similar to Lucida Sans, but it has no Unicode support.
+Deja Vu does have good Unicode support.
diff --git a/README.md b/README.md
index 1409d5a5d..631dde280 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ Installation
------------
To install, run ./INSTALL. It builds mk and then uses mk to
-run the rest of the installation.
+run the rest of the installation.
For more details, see install(1), at install.txt in this directory
and at https://9fans.github.io/plan9port/man/man1/install.html.
@@ -22,7 +22,7 @@ or differences from Plan 9.
Helping out
-----------
-If you'd like to help out, great! The TODO file contains a small list.
+If you'd like to help out, great!
If you port this code to other architectures, please share your changes
so others can benefit.
@@ -30,7 +30,7 @@ so others can benefit.
Git
---
-You can use Git to keep your local copy up-to-date as we make
+You can use Git to keep your local copy up-to-date as we make
changes and fix bugs. See the git(1) man page here ("9 man git")
for details on using Git.
diff --git a/TODO b/TODO
deleted file mode 100644
index 5378a404b..000000000
--- a/TODO
+++ /dev/null
@@ -1,12 +0,0 @@
-BUGS
- - libdraw sometimes gets initial window size wrong.
-
-PORTS
- - acme Mail in some form?
- - upas/fs in some form?
-
-FEATURES
- - add NTFS, FAT to libdiskfs?
- - more granular packaging (in progress)
- - finish adding 9P2000.u (in progress)
-
diff --git a/bin/9a b/bin/9a
deleted file mode 100755
index 753797c8f..000000000
--- a/bin/9a
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-if [ $# != 1 ]; then
- echo 'usage: 9a file.s' 1>&2
- exit 1
-fi
-
-test -f $PLAN9/config && . $PLAN9/config
-
-aflags=""
-case "`uname`-${OBJTYPE:-`uname -m`}" in
-Darwin-*386*)
- aflags="-arch i386"
- ;;
-Darwin-*x86_64*)
- aflags="-arch x86_64"
- ;;
-esac
-
-out=`echo $1 | sed 's/\.s$//;s/$/.o/'`
-exec as $aflags -o $out $1
diff --git a/bin/9c b/bin/9c
index 3ffb716ca..de8f81e98 100755
--- a/bin/9c
+++ b/bin/9c
@@ -4,7 +4,7 @@ test -f $PLAN9/config && . $PLAN9/config
usegcc()
{
cc=${CC9:-gcc}
- ngflags=" \
+ cflags=" \
-O2 \
-c \
-Wall \
@@ -14,12 +14,18 @@ usegcc()
-Wno-comment \
-Wno-sign-compare \
-Wno-unknown-pragmas \
+ -Wno-misleading-indentation \
+ -Wno-stringop-truncation \
+ -Wno-stringop-overflow \
+ -Wno-format-truncation \
-fno-omit-frame-pointer \
-fsigned-char \
+ -fcommon \
"
# want to put -fno-optimize-sibling-calls here but
# that option only works with gcc3+ it seems
- cflags="$ngflags -ggdb"
+ cflags="$cflags -ggdb"
+ cflags="$cflags $CC9FLAGS"
}
quiet()
@@ -55,7 +61,7 @@ quiet()
useclang()
{
cc=${CC9:-clang}
- ngflags=" \
+ cflags=" \
-O2 \
-c \
-Wall \
@@ -73,45 +79,50 @@ useclang()
-Wno-unneeded-internal-declaration \
-fsigned-char \
-fno-caret-diagnostics \
+ -fcommon \
"
- cflags="$ngflags -g"
+ cflags="$cflags -g"
+ cflags="$cflags $CC9FLAGS"
}
-tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}-${CC9:-cc}"
+usexlc()
+{
+ cc=${CC9:-xlc_r}
+ cflags=" \
+ -c \
+ -O2 \
+ -qmaxmem=-1 \
+ -qsuppress=1506-236 \
+ -qsuppress=1506-358 \
+ -qsuppress=1500-010 \
+ -qsuppress=1506-224 \
+ -qsuppress=1506-1300 \
+ -qsuppress=1506-342 \
+ "
+ cflags="$cflags -g -qdbxextra -qfullpath"
+ cflags="$cflags $CC9FLAGS"
+}
+
+tag="${SYSNAME:-`uname`}-${CC9:-cc}"
case "$tag" in
-*FreeBSD*gcc*) usegcc ;;
-*FreeBSD*clang*) useclang ;;
-*DragonFly*|*BSD*) usegcc ;;
-*Darwin-x86_64*)
+*DragonFly*gcc*|*BSD*gcc*) usegcc ;;
+*DragonFly*clang|*BSD*clang*) useclang ;;
+*Darwin*)
useclang
- cflags="$ngflags -g3 -m64"
+ cflags="$cflags -g3 -m64"
;;
-*Darwin*clang*)
- useclang
- cflags="$ngflags -g3 -m32"
- ;;
-*Darwin*) usegcc
- cflags="$ngflags -g3 -no-cpp-precomp -m32" ;;
*HP-UX*) cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;;
-*Linux*) usegcc
+*Linux*) usegcc
case "${CC9:-gcc}" in
tcc)
cc=tcc
cflags="-c -g"
;;
esac
- case "${SYSVERSION:-`uname -r`}" in
- 2.4.*)
- cflags="$cflags -D__Linux24__"
- ;;
- 2.6.*)
- cflags="$cflags -D__Linux26__"
- ;;
- esac
;;
*OSF1*) cc=${CC9:-cc}; cflags="-g -O -c" ;;
*SunOS*-cc) cc=cc;
- cflags="-mt -g -O -c -xCC -D__sun__"
+ cflags="-mt -g -O -c -xCC -D__sun__"
u=`uname`
v=`uname -r`
s=`echo $u$v | tr '. ' '__'`
@@ -121,11 +132,11 @@ case "$tag" in
u=`uname`
v=`uname -r`
s=`echo $u$v | tr '. ' '__'`
- cflags="$ngflags -g"
+ cflags="$cflags -g"
cflags="$cflags -D__sun__ -D__${s}__"
;;
-*AIX*) usegcc
- cflags="$ngflags -g -D__AIX__"
+*AIX*) usexlc
+ cflags="$cflags -g -D__AIX__"
;;
*)
echo 9c does not know how to compile on "$tag" 1>&2
@@ -133,7 +144,7 @@ case "$tag" in
esac
# N.B. Must use temp file to avoid pipe; pipe loses status.
-xtmp=/tmp/9c.$$.$USER.out
+xtmp=${TMPDIR-/tmp}/9c.$$.$USER.out
$cc -DPLAN9PORT -I$PLAN9/include $cflags "$@" 2>$xtmp
status=$?
quiet $xtmp
diff --git a/bin/9fs b/bin/9fs
index fffdc35b3..467b3191d 100755
--- a/bin/9fs
+++ b/bin/9fs
@@ -19,10 +19,8 @@ fn srv1 {
ns=`{namespace}
switch($1){
-case tip
- srv1 -a tip utumno.tip9ug.jp
case sources
- srv1 -n sources sources.cs.bell-labs.com
+ srv1 -n sources 9p.io
case *
srv1 $1 $1
}
diff --git a/bin/9l b/bin/9l
index 2409e641e..d7c9e2ddc 100755
--- a/bin/9l
+++ b/bin/9l
@@ -9,52 +9,31 @@ verbose=false
nmflags=""
extralibs="-lm"
-tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}"
+tag="${SYSNAME:-`uname`}"
case "$tag" in
-*FreeBSD*)
- ld=${CC9:-gcc}
- userpath=true
- extralibs="$extralibs -lutil"
- case "`uname -r`" in
- 5.2.*)
- extralibs="$extralibs -lkse"
- ;;
- [5-9].*|1[0-1].*)
- extralibs="$extralibs -lpthread"
- ;;
- esac
- ;;
*DragonFly*|*BSD*)
- ld=${CC9:-gcc}
+ ld="${CC9:-gcc} $CC9FLAGS"
userpath=true
extralibs="$extralibs -lutil"
;;
*OSF1*)
- ld=${CC9:-cc}
+ ld="${CC9:-cc} $CC9FLAGS"
userpath=true
extralibs="$extralibs -lutil"
nmflags="-B"
;;
*Linux*)
- ld=${CC9:-gcc}
+ ld="${CC9:-gcc} $CC9FLAGS"
userpath=true
- extralibs="$extralibs -lutil -lresolv"
- case "${SYSVERSION:-`uname -r`}" in
- 2.6.* | 3.* | 4.*)
- extralibs="$extralibs -lpthread"
- ;;
- esac
- ;;
-*Darwin*x86_64*)
- ld="${CC9:-gcc} -m64"
+ extralibs="$extralibs -lutil -lresolv -lpthread"
;;
*Darwin*)
- ld="${CC9:-gcc} -m32"
+ ld="${CC9:-gcc} -m64 $CC9FLAGS"
;;
*SunOS*)
- ld="${CC9:-cc} -g"
+ ld="${CC9:-cc} -g $CC9FLAGS"
extralibs="$extralibs -lrt -lpthread -lsocket -lnsl"
- # Record paths to shared libraries to avoid needing LD_LIBRARY_PATH
+ # Record paths to shared libraries to avoid needing LD_LIBRARY_PATH
for i in "$libsl $@"
do
case "$i" in
@@ -79,8 +58,8 @@ case "$tag" in
esac
;;
*AIX*)
- ld=${CC9:-gcc}
- nmflags="-B"
+ ld="${CC9:-xlc_r} $CC9FLAGS"
+ nmflags="-A -B"
;;
*)
echo do not know how to link on "$tag" 1>&2
@@ -119,7 +98,7 @@ then
lpaths="$lpaths $l"
esac
done
-
+
if $verbose
then
echo "ofiles $ofiles"
@@ -131,8 +110,8 @@ then
then
a=`
nm $nmflags $ofiles |
- grep '__p9l_autolib_[a-zA-Z0-9+-]*$' |
- sed 's/.*__p9l_autolib_//' |
+ grep '__p9l_autolib_[a-zA-Z0-9+-]*' |
+ sed 's/.*__p9l_autolib_//; s/:.*//' |
sort -u
`
for i in $a
@@ -162,8 +141,8 @@ then
do
b=`
nm $lpath/lib$i.a 2>/dev/null |
- grep '__p9l_autolib_[a-zA-Z0-9+-]*$' |
- sed 's/.*__p9l_autolib_//' |
+ grep '__p9l_autolib_[a-zA-Z0-9+-]*' |
+ sed 's/.*__p9l_autolib_//; s/:.*//' |
sort -u |
egrep -v '^(thread|draw)$'
`
@@ -270,7 +249,7 @@ then
fi
# Don't say -L with a non-existent directory: Xcode complains.
# x86_64 seems to put its 64-bit libraries in lib64.
- if [ "${OBJTYPE:-`uname -m`}" = "x86_64" -a -d "$X11/lib64" ]
+ if [ "`uname -m`" = "x86_64" -a -d "$X11/lib64" ]
then
libsl="$libsl -L$X11/lib64"
fi
@@ -322,7 +301,7 @@ then
frameworks=""
for i in $autoframeworks
- do
+ do
frameworks="-framework $i $frameworks"
done
fi
@@ -346,10 +325,10 @@ then
echo $ld -L$PLAN9/lib "$@" $libsl $extralibs $frameworks
fi
-xtmp=/tmp/9l.$$.$USER.out
+xtmp="${TMPDIR-/tmp}/9l.$$.$USER.out"
xxout() {
- sed 's/.*: In function `[^:]*: *//' $xtmp | egrep . |
- egrep -v 'is (often|almost always) misused|is dangerous, better use'
+ sed 's/.*: In function `[^:]*: *//' $xtmp | egrep . |
+ egrep -v 'is (often|almost always) misused|is dangerous, better use|text-based stub'
rm -f $xtmp
}
diff --git a/bin/mount b/bin/mount
index 79b974f77..e29cc201e 100755
--- a/bin/mount
+++ b/bin/mount
@@ -19,11 +19,17 @@ case FreeBSD
exec 9pfuse $1 $2
echo 'don''t know how to mount (no fuse)' >[1=2]
case Darwin
+ version=`{sw_vers -productVersion|cut -d. -f1,2}
+ major_version = `{echo $version|cut -d. -f1}
if(sysctl fuse.version >[2]/dev/null |9 grep -si 'fuse.version' ||
sysctl macfuse.version.number >[2]/dev/null |9 grep -si 'fuse.version' ||
sysctl osxfuse.version.number >[2]/dev/null |9 grep -si 'fuse.version' ||
test -d /System/Library/Extensions/fusefs.kext ||
+ test -d /Library/Filesystems/osxfuse.fs/Contents/Extensions/$version/osxfuse.kext ||
+ test -d /Library/Filesystems/macfuse.fs/Contents/Extensions/$version/macfuse.kext ||
+ test -d /Library/Filesystems/macfuse.fs/Contents/Extensions/$major_version/macfuse.kext ||
test -d /Library/Filesystems/osxfusefs.fs/Support/osxfusefs.kext ||
+ test -d /opt/local/Library/Filesystems/osxfuse.fs ||
test -d /Library/Filesystems/fusefs.fs/Support/fusefs.kext)
exec 9pfuse $1 $2
echo 'don''t know how to mount (no fuse)' >[1=2]
diff --git a/bin/osxvers b/bin/osxvers
index 4af44da24..6ebeb11f3 100755
--- a/bin/osxvers
+++ b/bin/osxvers
@@ -3,5 +3,5 @@
u=`uname`
case "$u" in
Darwin)
- sw_vers | awk '$1 == "ProductVersion:" {print $2}' | awk -F. '{printf("CFLAGS=$CFLAGS -DOSX_VERSION=%d%02d%02d\n", $1, $2, $3)}'
+ sw_vers -productVersion | awk -F. '{printf("CFLAGS=$CFLAGS -DOSX_VERSION=%d%02d%02d\n", $1, $2, $3)}'
esac
diff --git a/bin/quote1 b/bin/quote1
index e0f7c8f93..f52480fd1 100755
--- a/bin/quote1
+++ b/bin/quote1
@@ -2,19 +2,10 @@
. 9.rc
-fn text {
- if(~ $winid [0-9]*)
- 9p read acme/$winid/body
- if not if(~ $text9term unix!*)
- dial -e $text9term [1=2]
exit notfound
diff --git a/bin/soelim b/bin/soelim
new file mode 100755
index 000000000..2ba3de996
--- /dev/null
+++ b/bin/soelim
@@ -0,0 +1,16 @@
+#!/usr/local/plan9/bin/rc
+# joyless reimplementation of soelim
+# the $0 recursion is a bit ugly
+
+# canonicalise troff commands first with sed into ". so file" form.
+# but the space after the dot has to come out; tbl can't cope with it.
+# friggin' html macros can be longer than two characters; grrr.
+sed '/^[.'']/{
+ s/([^\\])\\".*$/\1/
+# s/^(.)[ ]*([^ \\][^ \\])[ ]*/\1 \2 /
+ s/^(.)[ ]*([^ \\][^ \\])/\1 \2/
+}' $* | awk ' BEGIN { me = "'$0'" }
+ $1 !~ /^[.'']$/ { print; next }
+ $2 == "so" { system(me " " $3) ; next }
+ $2 == "nx" { system(me " " $3) ; exit }
+ { print }' | sed 's/^([.'']) /\1/'
diff --git a/bin/web b/bin/web
index 7829229f8..5de673980 100755
--- a/bin/web
+++ b/bin/web
@@ -34,7 +34,7 @@ plumbunix()
$BROWSER -remote 'openURL('"$@"',new-tab)' ||
$BROWSER "$@"
;;
- *chrome*|*chromium*)
+ ?*)
$BROWSER "$@"
;;
esac
diff --git a/bin/wintext b/bin/wintext
index 93fe40ea4..1f36a05c5 100755
--- a/bin/wintext
+++ b/bin/wintext
@@ -1,16 +1,17 @@
-#!/bin/sh
+#!/usr/local/plan9/bin/rc
-case "$winid" in
-[0-9]*)
+if(~ $winid [0-9]*) {
9p read acme/$winid/body
exit 0
-esac
-
-case "$text9term" in
-unix!*)
- dial -e $text9term &1
+echo 'no running window found' >[2=1]
exit 1
diff --git a/dist/buildmk b/dist/buildmk
index 07b223aca..ba21ae023 100755
--- a/dist/buildmk
+++ b/dist/buildmk
@@ -1,21 +1,6 @@
#!/bin/sh
# run this in the src directory
-SYSNAME=`uname` export SYSNAME
-OBJTYPE=`(uname -m -p 2>/dev/null || uname -m) | sed '
- s;.*i[3-6]86.*;386;;
- s;.*i86pc.*;386;;
- s;.*amd64.*;x86_64;;
- s;.*x86_64.*;x86_64;;
- s;.*armv.*;arm;g;
- s;.*powerpc.*;power;g;
- s;.*PowerMacintosh.*;power;g;
- s;.*Power.Macintosh.*;power;g;
- s;.*macppc.*;power;g;
- s;.*mips.*;mips;g;
- s;.*ppc64.*;power;g;
- s;.*ppc.*;power;g;
- s;.*alpha.*;alpha;g;
- s;.*sun4u.*;sun4u;g;
-'` export OBJTYPE
+. ../src/mkenv
+export SYSNAME INSTALL
sh -x mkmk.sh
diff --git a/dist/deb.html b/dist/deb.html
index 840f67556..b02020855 100644
--- a/dist/deb.html
+++ b/dist/deb.html
@@ -20,7 +20,7 @@
|
Most obviously, plan9port derives from
- Plan 9 from Bell Labs
+ Plan 9 from Bell Labs
and would not exist without the work of the Plan 9 team over the
past many years.
@@ -173,7 +173,7 @@
of Plan 9 from User Space for Windows. Only for reference.
-
+
Sean Quinlan's 9pm
− a port of an earlier Plan 9 (including sam(1)) to Windows
diff --git a/dist/pkg/main b/dist/pkg/main
index 52e5efdad..c779a0289 100644
--- a/dist/pkg/main
+++ b/dist/pkg/main
@@ -5,7 +5,7 @@ depends=plan9port-^(base bin devel dict dist faces font-asian \
desc='Plan 9 from User Space
Plan 9 is a distributed computing environment built at Bell Labs
starting in the late 1980s. The system can be obtained from Bell Labs
- at http://plan9.bell-labs.com/plan9 and runs on PCs and a variety
+ at http://9p.io/plan9 and runs on PCs and a variety
of other platforms. Plan 9 became a convenient platform for
experimenting with new ideas, applications, and services.
.
diff --git a/dist/unix.html b/dist/unix.html
index 0e8394c26..33f428a66 100644
--- a/dist/unix.html
+++ b/dist/unix.html
@@ -19,11 +19,11 @@
- These are ports of Plan 9's
+ These are ports of Plan 9's
UTF-8, formatted print, buffered I/O, and regular expression
libraries, along with mk, a simple replacement for make.
-
+
supported systems
@@ -49,7 +49,7 @@
make PREFIX=/usr/elsewhere install.
-
+
On unsupported systems, you will need to create
Make.YourOS-YourArch.
See the existing ones for examples. If you write one for a new system,
@@ -62,27 +62,25 @@
@@ -91,7 +89,7 @@
|
| |
-
+
Libfmt is a port of Plan 9's formatted print library.
As a base it provides all the syntax of ANSI C's printf but adds
the ability for client programs to install new print verbs.
@@ -99,108 +97,104 @@
the system error string.
Instead of perror("foo"), you can write
fprint(2, "foo: %r\n");.
- This is especially nice when you write verbs to format the
+ This is especially nice when you write verbs to format the
data structures used by your particular programs.
Needs libutf.
-
+
-
- manual:
+
+ manual:
print(3),
fmtinstall(3),
quote(3),
fmtstrtod(3)
-
+
-
- download: libfmt.tgz (checksums)
-
+
+ download: libfmt.tgz
+
-
- License: original Bell Labs MIT-like
- or Lucent Public License
+
+ license: MIT
|
-
+
libbio
-
+
libregexp9
|
| |
-
+
Libregexp9 is a port of Plan 9's Unicode-capable regular expression library.
It is small and simple and provides the traditional extended regular
- expressions (without modern complications like
+ expressions (without modern complications like
{} and various \x character classes).
It supports Unicode via wide character or UTF-8 encoding.
Needs libutf and libfmt.
-
+
-
- manual:
+
+ manual:
regexp9(3),
regexp9(7)
-
+
-
- download: libregexp9.tgz (checksums)
-
+
+ download: libregexp9.tgz
+
-
- License: original Bell Labs MIT-like
- or Lucent Public License
+
+ license: MIT
|
-
+
mk
@@ -208,12 +202,11 @@
diff --git a/font/LICENSE b/font/LICENSE
index 6ca96ce60..19b048acc 100644
--- a/font/LICENSE
+++ b/font/LICENSE
@@ -1,5 +1,6 @@
Many of the fonts in this directory come from other sources
-and are distributed under licenses other than the Lucent Public License.
+and are distributed under licenses other than the MIT-style license
+that governs the main distribution.
In particular, see:
@@ -13,4 +14,4 @@ In particular, see:
naga10/README
pelm/NOTICE
shinonome/README
-
+
diff --git a/include/9p.h b/include/9p.h
index 57caac28f..586c59ccb 100644
--- a/include/9p.h
+++ b/include/9p.h
@@ -219,7 +219,6 @@ struct Srv {
};
void srv(Srv*);
-void postmountsrv(Srv*, char*, char*, int);
int postfd(char*, int);
extern int chatty9p;
void respond(Req*, char*);
diff --git a/include/cursor.h b/include/cursor.h
index d53baf81d..e39d2ea58 100644
--- a/include/cursor.h
+++ b/include/cursor.h
@@ -12,6 +12,16 @@ struct Cursor
uchar set[2*16];
};
+typedef struct Cursor2 Cursor2;
+struct Cursor2
+{
+ Point offset;
+ uchar clr[4*32];
+ uchar set[4*32];
+};
+
+void scalecursor(Cursor2*, Cursor*);
+
#if defined(__cplusplus)
}
#endif
diff --git a/include/draw.h b/include/draw.h
index 3a012959f..3b55504d7 100644
--- a/include/draw.h
+++ b/include/draw.h
@@ -199,7 +199,6 @@ struct Display
int obufsize;
uchar *obufp;
Font *defaultfont;
- Subfont *defaultsubfont;
Image *windows;
Image *screenimage;
int _isnewdisplay;
@@ -291,7 +290,7 @@ struct Cachefont
struct Cacheinfo
{
- ushort x; /* left edge of bits */
+ int x; /* left edge of bits */
uchar width; /* width of baseline */
schar left; /* offset of baseline */
Rune value; /* value of character at this slot in cache */
@@ -312,8 +311,8 @@ struct Font
Display *display;
short height; /* max height of image, interline spacing */
short ascent; /* top of image to baseline */
- short width; /* widest so far; used in caching only */
- short nsub; /* number of subfonts */
+ short width; /* widest so far; used in caching only */
+ int nsub; /* number of subfonts */
u32int age; /* increasing counter; used for LRU */
int maxdepth; /* maximum depth of all loaded subfonts */
int ncache; /* size of cache */
@@ -498,7 +497,6 @@ extern Point strsubfontwidth(Subfont*, char*);
extern int loadchar(Font*, Rune, Cacheinfo*, int, int, char**);
extern char* subfontname(char*, char*, int);
extern Subfont* _getsubfont(Display*, char*);
-extern Subfont* getdefont(Display*);
extern void lockdisplay(Display*);
extern void unlockdisplay(Display*);
extern int drawlsetrefresh(u32int, int, void*, void*);
@@ -508,8 +506,6 @@ extern void swapfont(Font*, Font**, Font**);
/*
* Predefined
*/
-extern uchar defontdata[];
-extern int sizeofdefont;
extern Point ZP;
extern Rectangle ZR;
@@ -520,6 +516,7 @@ extern Display *display;
extern Font *font;
extern Image *screen;
extern Screen *_screen;
+extern int drawmousemask; /* set bits to disable receiving those buttons */
extern int _cursorfd;
extern int _drawdebug; /* set to 1 to see errors from flushimage */
extern void _setdrawop(Display*, Drawop);
@@ -568,9 +565,10 @@ int mousescrollsize(int);
*/
struct Mouse;
struct Cursor;
+struct Cursor2;
int _displaybouncemouse(Display *d, struct Mouse *m);
int _displayconnect(Display *d);
-int _displaycursor(Display *d, struct Cursor *c);
+int _displaycursor(Display *d, struct Cursor *c, struct Cursor2 *c2);
int _displayinit(Display *d, char *label, char *winsize);
int _displaylabel(Display *d, char *label);
int _displaymoveto(Display *d, Point p);
diff --git a/include/drawfcall.h b/include/drawfcall.h
index fb339919d..b8535fb65 100644
--- a/include/drawfcall.h
+++ b/include/drawfcall.h
@@ -13,19 +13,28 @@ tag[1] Rmoveto
tag[1] Tcursor cursor[]
tag[1] Rcursor
+tag[1] Tcursor2 cursor[]
+tag[1] Rcursor2
+
tag[1] Tbouncemouse x[4] y[4] button[4]
tag[1] Rbouncemouse
tag[1] Trdkbd
tag[1] Rrdkbd rune[2]
+tag[1] Trdkbd4
+tag[1] Rrdkbd4 rune[4]
+
tag[1] Tlabel label[s]
-tag[1] Rlabel
+tag[1] Rlabel
+
+tag[1] Tctxt wsysid[s]
+tag[1] Rctxt
tag[1] Tinit winsize[s] label[s] font[s]
tag[1] Rinit
-tag[1] Trdsnarf
+tag[1] Trdsnarf
tag[1] Rrdsnarf snarf[s]
tag[1] Twrsnarf snarf[s]
@@ -41,7 +50,7 @@ tag[1] Ttop
tag[1] Rtop
tag[1] Tresize rect[4*4]
-tag[1] Rresize
+tag[1] Rresize
*/
@@ -89,6 +98,12 @@ enum {
Rtop,
Tresize = 26,
Rresize,
+ Tcursor2 = 28,
+ Rcursor2,
+ Tctxt = 30,
+ Rctxt,
+ Trdkbd4 = 32,
+ Rrdkbd4,
Tmax,
};
@@ -104,12 +119,14 @@ struct Wsysmsg
Mouse mouse;
int resized;
Cursor cursor;
+ Cursor2 cursor2;
int arrowcursor;
Rune rune;
char *winsize;
char *label;
char *snarf;
char *error;
+ char *id;
uchar *data;
uint count;
Rectangle rect;
diff --git a/include/event.h b/include/event.h
index 09cb5c78c..e66bf1173 100644
--- a/include/event.h
+++ b/include/event.h
@@ -61,7 +61,9 @@ extern int emenuhit(int, Mouse*, Menu*);
extern int eatomouse(Mouse*, char*, int);
extern Rectangle getrect(int, Mouse*);
struct Cursor;
+struct Cursor2;
extern void esetcursor(struct Cursor*);
+extern void esetcursor2(struct Cursor*, struct Cursor2*);
extern void emoveto(Point);
extern Rectangle egetrect(int, Mouse*);
extern void edrawgetrect(Rectangle, int);
diff --git a/include/libc.h b/include/libc.h
index 45b22b691..1e24f0bb3 100644
--- a/include/libc.h
+++ b/include/libc.h
@@ -11,13 +11,13 @@
#define _LIBC_H_ 1
#if defined(__cplusplus)
extern "C" {
-#endif
+#endif
#include
#include
/*
- * Begin usual libc.h
+ * Begin usual libc.h
*/
#ifndef nil
@@ -361,7 +361,7 @@ enum
extern int p9atexit(void(*)(void));
extern void p9atexitdont(void(*)(void));
extern int atnotify(int(*)(void*, char*), int);
-/*
+/*
*
extern double atof(char*);
*/
@@ -383,8 +383,11 @@ extern int encodefmt(Fmt*);
extern int dirmodefmt(Fmt*);
extern int exitcode(char*);
extern void exits(char*);
-extern double frexp(double, int*);
+extern double p9frexp(double, int*);
extern ulong getcallerpc(void*);
+#if defined(__GNUC__) || defined(__clang__) || defined(__IBMC__)
+#define getcallerpc(x) ((ulong)__builtin_return_address(0))
+#endif
extern char* p9getenv(char*);
extern int p9putenv(char*, char*);
extern int getfields(char*, char**, int, int, char*);
@@ -433,6 +436,8 @@ extern void (*_unpin)(void);
#define atoll p9atoll
#define encrypt p9encrypt
#define decrypt p9decrypt
+#undef frexp
+#define frexp p9frexp
#define getenv p9getenv
#define getwd p9getwd
#define longjmp p9longjmp
@@ -468,10 +473,8 @@ extern _Thread *(*threadnow)(void);
typedef struct Lock Lock;
struct Lock
{
-#ifdef PLAN9PORT_USING_PTHREADS
int init;
pthread_mutex_t mutex;
-#endif
int held;
};
@@ -479,7 +482,7 @@ extern void lock(Lock*);
extern void unlock(Lock*);
extern int canlock(Lock*);
extern int (*_lock)(Lock*, int, ulong);
-extern void (*_unlock)(Lock*, ulong);
+extern void (*_unlock)(Lock*, ulong);
typedef struct QLock QLock;
struct QLock
@@ -670,15 +673,15 @@ extern void freenetconninfo(NetConnInfo*);
enum
{
- RFNAMEG = (1<<0),
- RFENVG = (1<<1),
+ RFNAMEG = (1<<0),
+ RFENVG = (1<<1),
RFFDG = (1<<2),
RFNOTEG = (1<<3),
RFPROC = (1<<4),
RFMEM = (1<<5),
RFNOWAIT = (1<<6),
- RFCNAMEG = (1<<10),
- RFCENVG = (1<<11),
+ RFCNAMEG = (1<<10),
+ RFCENVG = (1<<11),
RFCFDG = (1<<12)
/* RFREND = (1<<13), */
/* RFNOMNT = (1<<14) */
@@ -707,7 +710,7 @@ struct Dir {
char *uid; /* owner name */
char *gid; /* group name */
char *muid; /* last modifier name */
-
+
/* 9P2000.u extensions */
uint uidnum; /* numeric uid */
uint gidnum; /* numeric gid */
@@ -742,7 +745,7 @@ extern int awaitnohang(char*, int);
/* extern int bind(char*, char*, int); give up */
/* extern int brk(void*); */
extern int p9chdir(char*);
-extern int close(int);
+extern int p9close(int);
extern int p9create(char*, int, ulong);
extern int p9dup(int, int);
extern int errstr(char*, uint);
@@ -750,7 +753,7 @@ extern int p9exec(char*, char*[]);
extern int p9execl(char*, ...);
/* extern int p9fork(void); */
extern int p9rfork(int);
-/* not implemented
+/* not implemented
extern int fauth(int, char*);
extern int fstat(int, uchar*, int);
extern int fwstat(int, uchar*, int);
@@ -767,7 +770,7 @@ extern int notifyoff(char*);
extern int p9open(char*, int);
extern int fd2path(int, char*, int);
extern int p9pipe(int*);
-/*
+/*
* use defs from
extern long pread(int, void*, long, vlong);
extern long preadv(int, IOchunk*, int, vlong);
@@ -817,6 +820,8 @@ extern ulong rendezvous(ulong, ulong);
#define create p9create
#undef open
#define open p9open
+#undef close
+#define close p9close
#define pipe p9pipe
#define waitfor p9waitfor
#define write p9write
diff --git a/include/memdraw.h b/include/memdraw.h
index b1495ed82..dc0e0b72f 100644
--- a/include/memdraw.h
+++ b/include/memdraw.h
@@ -178,7 +178,6 @@ extern Memsubfont* allocmemsubfont(char*, int, int, int, Fontchar*, Memimage*);
extern Memsubfont* openmemsubfont(char*);
extern void freememsubfont(Memsubfont*);
extern Point memsubfontwidth(Memsubfont*, char*);
-extern Memsubfont* getmemdefont(void);
/*
* Predefined
@@ -217,7 +216,6 @@ extern Memdrawparam* _memimagedrawsetup(Memimage*,
Rectangle, Memimage*, Point, Memimage*,
Point, int);
extern void _memimagedraw(Memdrawparam*);
-extern void _drawreplacescreenimage(Memimage*);
#if defined(__cplusplus)
}
diff --git a/include/mouse.h b/include/mouse.h
index 3d5c975fe..c46d51e92 100644
--- a/include/mouse.h
+++ b/include/mouse.h
@@ -38,7 +38,9 @@ extern void moveto(Mousectl*, Point);
extern int readmouse(Mousectl*);
extern void closemouse(Mousectl*);
struct Cursor;
+struct Cursor2;
extern void setcursor(Mousectl*, struct Cursor*);
+extern void setcursor2(Mousectl*, struct Cursor*, struct Cursor2*);
extern void drawgetrect(Rectangle, int);
extern Rectangle getrect(int, Mousectl*);
extern int menuhit(int, Mousectl*, Menu*, Screen*);
diff --git a/include/thread.h b/include/thread.h
index c01cd5166..8c8008292 100644
--- a/include/thread.h
+++ b/include/thread.h
@@ -1,7 +1,7 @@
#ifndef _THREAD_H_
#define _THREAD_H_ 1
#if defined(__cplusplus)
-extern "C" {
+extern "C" {
#endif
AUTOLIB(thread)
@@ -15,6 +15,7 @@ void threadexits(char *);
void threadexitsall(char *);
void threadsetname(char*, ...);
void threadsetstate(char*, ...);
+void threadneedbackground(void);
char *threadgetname(void);
int threadyield(void);
int threadidle(void);
@@ -60,6 +61,8 @@ void **threaddata(void);
void threadmain(int argc, char *argv[]);
extern int mainstacksize;
+int threadmaybackground(void);
+
/*
* channel communication
*/
@@ -180,7 +183,7 @@ int threadspawnl(int[3], char*, ...);
Channel* threadwaitchan(void);
/*
- * alternate interface to threadwaitchan - don't use both!
+ * alternate interface to threadwaitchan - don't use both!
*/
Waitmsg* procwait(int pid);
diff --git a/include/u.h b/include/u.h
index d0cd6396f..856e10f4c 100644
--- a/include/u.h
+++ b/include/u.h
@@ -6,6 +6,8 @@
extern "C" {
#endif
+#define HAS_SYS_TERMIOS 1
+
#define __BSD_VISIBLE 1 /* FreeBSD 5.x */
#if defined(__sun__)
# define __EXTENSIONS__ 1 /* SunOS */
@@ -20,7 +22,7 @@ extern "C" {
#define _NETBSD_SOURCE 1 /* NetBSD */
#define _SVID_SOURCE 1
#define _DEFAULT_SOURCE 1
-#if !defined(__APPLE__) && !defined(__OpenBSD__)
+#if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__AIX__)
# define _XOPEN_SOURCE 1000
# define _XOPEN_SOURCE_EXTENDED 1
#endif
@@ -33,10 +35,8 @@ extern "C" {
# define __LONG_LONG_SUPPORTED
#endif
#if defined(__AIX__)
-# define _XOPEN_SOURCE 1
-#endif
-#if defined(__APPLE__)
-# define _DARWIN_NO_64_BIT_INODE /* Snow Leopard */
+# define _ALL_SOURCE
+# undef HAS_SYS_TERMIOS
#endif
#define _LARGEFILE64_SOURCE 1
#define _FILE_OFFSET_BITS 64
@@ -66,10 +66,7 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
#if defined(__linux__)
# include
-# if defined(__Linux26__)
-# include
-# define PLAN9PORT_USING_PTHREADS 1
-# endif
+# include
# if defined(__USE_MISC)
# undef _NEEDUSHORT
# undef _NEEDUINT
@@ -78,7 +75,6 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
#elif defined(__sun__)
# include
# include
-# define PLAN9PORT_USING_PTHREADS 1
# undef _NEEDUSHORT
# undef _NEEDUINT
# undef _NEEDULONG
@@ -86,10 +82,7 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
#elif defined(__FreeBSD__)
# include
# include
-# if __FreeBSD_version >= 500000
-# define PLAN9PORT_USING_PTHREADS 1
-# include
-# endif
+# include
# if !defined(_POSIX_SOURCE)
# undef _NEEDUSHORT
# undef _NEEDUINT
@@ -97,7 +90,6 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
#elif defined(__APPLE__)
# include
# include
-# define PLAN9PORT_USING_PTHREADS 1
# if __GNUC__ < 4
# undef _NEEDUSHORT
# undef _NEEDUINT
@@ -112,20 +104,19 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
#elif defined(__NetBSD__)
# include
# include
+# include
# undef _NEEDUSHORT
# undef _NEEDUINT
# undef _NEEDULONG
#elif defined(__OpenBSD__)
# include
# include
-# define PLAN9PORT_USING_PTHREADS 1
# undef _NEEDUSHORT
# undef _NEEDUINT
# undef _NEEDULONG
#else
/* No idea what system this is -- try some defaults */
# include
-# define PLAN9PORT_USING_PTHREADS 1
#endif
#ifndef O_DIRECT
diff --git a/install.txt b/install.txt
index 2de7fa3a5..e7dd3c65b 100644
--- a/install.txt
+++ b/install.txt
@@ -1,219 +1,102 @@
- INTRO(1) INTRO(1)
+ INSTALL(1) INSTALL(1)
NAME
- intro - introduction to Plan 9 from User Space
+ install - notes about Plan 9 from User Space installation
- DESCRIPTION
- Plan 9 is a distributed computing environment built at Bell
- Labs starting in the late 1980s. The system can be obtained
- from Bell Labs at http://plan9.bell-labs.com/plan9 and runs
- on PCs and a variety of other platforms. Plan 9 became a
- convenient platform for experimenting with new ideas, appli-
- cations, and services.
-
- Plan 9 from User Space provides many of the ideas, applica-
- tions, and services from Plan 9 on Unix-like systems. It
- runs on FreeBSD (x86, x86-64), Linux (x86, x86-64, PowerPC
- and ARM), Mac OS X (x86, x86-64, and PowerPC), NetBSD (x86
- and PowerPC), OpenBSD (x86 and PowerPC), Dragonfly BSD
- (x86-64), and SunOS (x86-64 and Sparc).
-
- Commands
- Plan 9 from User Space expects its own directory tree, con-
- ventionally /usr/local/plan9. When programs need to access
- files in the tree, they expect the $PLAN9 environment vari-
- able to contain the name of the root of the tree. See
- install(1) for details about installation.
-
- Many of the familiar Unix commands, for example cat(1),
- ls(1), and wc(1), are present, but in their Plan 9 forms:
- cat takes no options, ls does not columnate its output when
- printing to a terminal, and wc counts UTF characters. In
- some cases, the differences are quite noticeable: grep(1)
- and sed(1) expect Plan 9 regular expressions (see
- regexp(7)), which are closest to what Unix calls extended
- regular expressions. Because of these differences, it is
- not recommended to put $PLAN9/bin before the usual system
- bin directories in your search path. Instead, put it at the
- end of your path and use the 9(1) script when you want to
- invoke the Plan 9 version of a traditional Unix command.
-
- Occasionally the Plan 9 programs have been changed to adapt
- to Unix. Mk(1) now allows mkfiles to choose their own
- shell, and rc(1) has a ulimit builtin and manages $PATH.
-
- Many of the graphical programs from Plan 9 are present,
- including sam(1) and acme(1). An X11 window manager rio(1)
- mimics Plan 9's window system, with command windows imple-
- mented by the external program 9term(1). Following the style
- of X Windows, these programs run in new windows rather than
- the one in which they are invoked. They all take a -W
- option to specify the size and placement of the new window.
- The argument is one of widthxheight, widthxheight@xmin,xmax,
-
- Page 1 Plan 9 (printed 12/1/14)
-
- INTRO(1) INTRO(1)
-
- or xmin,ymin,xmax,ymax.
-
- The plumber(4) helps to connect the various Plan 9 programs
- together, and fittings like web(1) connect it to external
- programs such as web browsers; one can click on a URL in
- acme and see the page load in Firefox.
-
- User-level file servers
- In Plan 9, user-level file servers present file trees via
- the Plan 9 file protocol, 9P. Processes can mount arbitrary
- file servers and customize their own name spaces. These
- facilities are used to connect programs. Clients interact
- with file servers by reading and writing files.
-
- This cannot be done directly on Unix. Instead the servers
- listen for 9P connections on Unix domain sockets; clients
- connect to these sockets and speak 9P directly using the
- 9pclient(3) library. Intro(4) tells more of the story. The
- effect is not as clean as on Plan 9, but it gets the job
- done and still provides a uniform and easy-to-understand
- mechanism. The 9p(1) client can be used in shell scripts or
- by hand to carry out simple interactions with servers.
- Netfiles(1) is an experimental client for acme.
-
- External databases
- Some programs rely on large databases that would be cumber-
- some to include in every release. Scripts are provided that
- download these databases separately. These databases can be
- downloaded separately. See $PLAN9/dict/README and
- $PLAN9/sky/README.
-
- Programming
- The shell scripts 9c and 9l (see 9c(1)) provide a simple
- interface to the underlying system compiler and linker, sim-
- ilar to the 2c and 2l families on Plan 9. 9c compiles
- source files, and 9l links object files into executables.
- When using Plan 9 libraries, 9l infers the correct set of
- libraries from the object files, so that no -l options are
- needed.
-
- The only way to write multithreaded programs is to use the
- thread(3) library. Rfork(3) exists but is not as capable as
- on Plan 9. There are many unfortunate by necessary prepro-
- cessor diversions to make Plan 9 and Unix libraries coexist.
- See intro(3) for details.
-
- The debuggers acid(1) and db(1) and the debugging library
- mach(3) are works in progress. They are platform-
- independent, so that x86 Linux core dumps can be inspected
- on PowerPC Mac OS X machines, but they are also fairly
- incomplete. The x86 target is the most mature; initial Pow-
- erPC support exists; and other targets are unimplemented.
-
- Page 2 Plan 9 (printed 12/1/14)
-
- INTRO(1) INTRO(1)
-
- The debuggers can only inspect, not manipulate, target pro-
- cesses. Support for operating system threads and for 64-bit
- architectures needs to be rethought. On x86 Linux systems,
- acid and db can be relied upon to produce reasonable stack
- traces (often in cases when GNU gdb cannot) and dump data
- structures, but that it is the extent to which they have
- been developed and exercised.
-
- Porting programs
- The vast majority of the familiar Plan 9 programs have been
- ported, including the Unicode-aware troff(1).
-
- Of the more recent additions to Plan 9, factotum(4),
- secstore(1), and secstored(1), vac(1), vacfs(4), and
- venti(8) are all ported.
-
- A backup system providing a dump file system built atop
- Venti is in progress; see vbackup(8).
-
- Porting to new systems
- Porting the tree to new operating systems or architectures
- should be straightforward, as system-specific code has been
- kept to a minimum. The largest pieces of system-specific
- code are , which must include the right system files
- and set up the right integer type definitions, and
- libthread, which must implement spin locks, operating system
- thread creation, and context switching routines. Portable
- implementations of these using and
- already exist. If your system supports them, you may not
- need to write any system specific code at all.
-
- There are other smaller system dependencies, such as the
- terminal handling code in 9term(1) and the implementation of
- getcallerpc(3), but these are usually simple and are not on
- the critical path for getting the system up and running.
+ SYNOPSIS
+ cd /usr/local/plan9; ./INSTALL [ -b | -c ] [ -r path ]
- SEE ALSO
- The rest of this manual describes Plan 9 from User Space.
- Many of the man pages have been brought from Plan 9, but
- they have been updated, and others have been written from
+ DESCRIPTION
+ To obtain the Plan 9 tree, use Git (see git(1)) or download
+ a tar file from https://9fans.github.io/plan9port.
+
+ The tree can be unpacked anywhere, but the usual place is
+ /usr/local/plan9. In the root of the tree, run ./INSTALL.
+ This script builds the Plan 9 build program mk(1) if neces-
+ sary, cleans all previously built object files and libraries
+ out of the tree, rebuilds and installs everything, and then
+ cleans up.
+
+ There are a few files in tree which have the root hard-coded
+ in them. After the build, INSTALL edits these files to
+ replace the string /usr/local/plan9 with the name of the
+ root of the current tree.
+
+ Finally, INSTALL builds an HTML version of the manual and
+ installs it in /usr/local/plan9/man.
+
+ The installation can be thought of as two steps: build all
+ the binaries, and then edit files as necessary to fix the
+ references to the installation root. If necessary, these
+ can be run separately. Given the -b flag, INSTALL performs
+ only the first step. Given the -c flag, INSTALL performs
+ only the second step. The first step can be done with the
+ tree in a temporary work directory, but the second step must
+ be done once the tree is in its final location. If you want
+ to build the project in one location and then install into
+ another location, use -r path to specify the final location
+ of Plan9 tree. These flags are only necessary when trying
+ to conform to the expectations of certain package management
+ systems.
+
+ At the end of the installation, INSTALL prints suggested
+ settings for the environment variables $PLAN9 and $PATH.
+
+ INSTALL writes various autodetected settings to
+ /usr/local/plan9/config. The file
+ /usr/local/plan9/LOCAL.config is appended to config after
+ this auto-detection and can be used to override the choices.
+ If LOCAL.config contains a line WSYSTYPE=nowsys then the
+ system is built without using X11. LOCAL.config may also
+ list settings for CC9 (the host C compiler) and CC9FLAGS
+ (any additional flags to pass to the compiler). Values more
+
+ Page 1 Plan 9 (printed 4/9/21)
+
+ INSTALL(1) INSTALL(1)
+
+ complex than single words should be quoted with single
+ quotes.
+
+ On most Linux systems, the X11 header packages need to be
+ installed to build using X11. On Debian. the required pack-
+ ages are libfontconfig1-dev, libx11-dev, libxext-dev, and
+ libxt-dev. On Ubuntu, it suffices to install xorg-dev.
+
+ INSTALL can safely be repeated to rebuild the system from
scratch.
- The manual pages are in a Unix style tree, with names like
- $PLAN9/man/man1/cat.1 instead of Plan 9's simpler
- $PLAN9/man/1/cat, so that the Unix man(1) utility can handle
- it. Some systems, for example Debian Linux, deduce the man
- page locations from the search path, so that adding
- $PLAN9/bin to your path is sufficient to cause $PLAN9/man to
- be consulted for manual pages using the system man. On other
- systems, or to look at manual pages with the same name as a
- system page, invoke the Plan 9 man directly, as in 9 man
- cat.
-
- Page 3 Plan 9 (printed 12/1/14)
-
- INTRO(1) INTRO(1)
-
- The manual sections follow the Unix numbering conventions,
- not the Plan 9 ones.
+ Once the system is built for the first time, it can be main-
+ tained and rebuilt using mk(1). To rebuild individual com-
+ mands or libraries, run mk install and mk clean in the
+ appropriate source directory (see src(1)).
- Section (1) describes general publicly accessible commands.
+ FILES
+ /usr/local/plan9/lib/moveplan9.files
+ the list of files that need to have /usr/local/plan9
+ edited out of them
- Section (3) describes C library functions.
+ /usr/local/plan9/lib/moveplan9.sh
+ the script that edits the files
- Section (4) describes user-level file servers.
+ /usr/local/plan9/src/mkmk.sh
+ the shell script used to build mk(1)
- Section (7) describes file formats and protocols. (On Unix,
- section (5) is technically for file formats but seems now to
- be used for describing specific files.)
+ /usr/local/plan9/dist/manweb
+ the shell script that builds the HTML manual
- Section (8) describes commands used for system administra-
- tion.
+ /usr/local/plan9/man/index.html
+ the top-level page in the HTML version of the manual
- Section (9p) describes the Plan 9 file protocol 9P.
+ /usr/local/plan9/install.log
+ logged output from the last run of INSTALL
- These pages describe parts of the system that are new or
- different from Plan 9 from Bell Labs:
+ /usr/local/plan9/install.sum
+ a summary of install.log
- 9(1), 9c(1), 9p(1), 9term(1), acidtypes in acid(1),
- dial(1), git(1), label(1), the MKSHELL variable in
- mk(1), namespace(1), netfiles(1), page(1), psfonts(1),
- rio(1), web(1), wintext(1)
-
- intro(3), 9pclient(3), the unix network in dial(3),
- exits(3), get9root(3), getns(3), notify(3),
- post9pservice(3), rfork(3), searchpath(3), sendfd(3),
- udpread(3), venti(3), wait(3), wctl(3)
-
- intro(4), 9pserve(4), import(4),
-
- vbackup(8)
-
- openfd(9p)
-
- DIAGNOSTICS
- In Plan 9, a program's exit status is an arbitrary text
- string, while on Unix it is an integer. Section (1) of this
- manual describes commands as though they exit with string
- statuses. In fact, exiting with an empty status corresponds
- to exiting with status 0, and exiting with any non-empty
- string corresponds to exiting with status 1. See exits(3).
+ SEE ALSO
+ intro(1), git(1)
- Page 4 Plan 9 (printed 12/1/14)
+ Page 2 Plan 9 (printed 4/9/21)
diff --git a/lib/fortunes b/lib/fortunes
index c1a4580c1..7ac3c1d73 100644
--- a/lib/fortunes
+++ b/lib/fortunes
@@ -1506,7 +1506,7 @@ This terminal is not for your use, please log off!
This time for sure!
This will be a memorable month -- no matter how hard you try to forget it.
This will hurt me more than it hurts you.
-Thos who do not remember the past are condemned to repeat it.
+Those who do not remember the past are condemned to repeat it.
Those who can't write, write manuals.
Those who can, do; those who can't, simulate.
Those who can, do; those who can't, write.
diff --git a/lib/keyboard b/lib/keyboard
index ec16fa302..1a0e85a50 100644
--- a/lib/keyboard
+++ b/lib/keyboard
@@ -475,6 +475,8 @@
2194 ab ↔ left right arrow
21D0 V= ⇐ left double arrow
21D2 =V ⇒ right double arrow
+21E4 |< ⇤ left arrow to bar
+21E5 >| ⇥ right arrow to bar
2200 fa ∀ for all
2202 pd ∂ partial differential
2203 te ∃ there exists
@@ -551,6 +553,8 @@
22E6 !~ ⋧ greater than but not equivalent to
22EF el ⋯ midline horizontal ellipsis
+2308 lc ⌈ left ceiling
+2309 rc ⌉ right ceiling
230A lf ⌊ left floor
230B rf ⌋ right floor
2329 〈 left angle bracket
@@ -580,3 +584,4 @@
F015 ZA raw alt (plan 9 specific)
F016 ZS raw shift (plan 9 specific)
F017 ZC raw ctl (plan 9 specific)
+1F602 :, 😂 face with tears of joy
diff --git a/lib/linux-isnptl.c b/lib/linux-isnptl.c
deleted file mode 100644
index e4c23c637..000000000
--- a/lib/linux-isnptl.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include
-#include
-#include
-#include
-
-int
-main(void)
-{
- ulong x;
-
- x = (ulong)pthread_self();
- printf("%lx\n", x);
- if(x < 1024*1024)
- exit(1); /* NOT NPTL */
- exit(0);
-}
diff --git a/lib/moveplan9.files b/lib/moveplan9.files
index 3ce2d5960..fe47d4ab0 100644
--- a/lib/moveplan9.files
+++ b/lib/moveplan9.files
@@ -17,6 +17,7 @@ bin/netfilestat
bin/quote1
bin/quote2
bin/sig
+bin/soelim
bin/spell
bin/src
bin/ssam
@@ -33,6 +34,7 @@ bin/upas/unspambox
bin/venti/conf
bin/vmount
bin/vwhois
+bin/wintext
bin/yesterday
dist/debian/mkpkg
dist/debian/mkrep
diff --git a/mac/9term.app/Contents/MacOS/9term b/mac/9term.app/Contents/MacOS/9term
index ef6692c3a..b5a46bc89 100755
--- a/mac/9term.app/Contents/MacOS/9term
+++ b/mac/9term.app/Contents/MacOS/9term
@@ -1,5 +1,29 @@
#!/bin/bash
-cd $HOME
-. ~/.bashrc
+fshell=$(finger $(whoami) | sed -n 's/.*Shell: //p' | sed 1q)
+SHELL=${fshell:-$SHELL}
PLAN9=${PLAN9:-/usr/local/plan9}
-$PLAN9/bin/9term -W600x800 &
+cd $HOME
+case "$SHELL" in
+*/rc)
+ echo '
+ if(! ~ $PLAN9/bin $path)
+ path=($path $PLAN9/bin)
+ $PLAN9/bin/9term -l -W600x800 &
+ ' | $SHELL -l
+ exit 0
+ ;;
+*/bash)
+ . ~/.bash_profile
+ ;;
+*)
+ . ~/.profile
+ ;;
+esac
+
+if ! [[ :$PATH: =~ :$PLAN9/bin: ]]
+then
+ PATH=$PATH:$PLAN9/bin
+fi
+$PLAN9/bin/9term -l -W600x800 &
+exit 0
+
diff --git a/man/lookman.index b/man/lookman.index
index 56aabc53c..56f12227b 100644
--- a/man/lookman.index
+++ b/man/lookman.index
@@ -19153,7 +19153,6 @@ posted /usr/local/plan9/man/man4/plumber.4
posted /usr/local/plan9/man/man9/0intro.9p
postfd /usr/local/plan9/man/man3/9p.3
postmark /usr/local/plan9/man/man1/bundle.1
-postmountsrv /usr/local/plan9/man/man3/9p.3
postnote /usr/local/plan9/man/man3/notify.3
postnote /usr/local/plan9/man/man3/postnote.3
postnote /usr/local/plan9/man/man3/rfork.3
diff --git a/man/man1/0intro.1 b/man/man1/0intro.1
index f018fc8a2..780be91da 100644
--- a/man/man1/0intro.1
+++ b/man/man1/0intro.1
@@ -5,7 +5,7 @@ intro \- introduction to Plan 9 from User Space
Plan 9 is a distributed computing environment built
at Bell Labs starting in the late 1980s.
The system can be obtained from Bell Labs at
-.B http://plan9.bell-labs.com/plan9
+.B http://9p.io/plan9
and runs on PCs and a variety of other platforms.
Plan 9 became a convenient platform for experimenting
with new ideas, applications, and services.
@@ -32,15 +32,15 @@ they expect the
environment variable
to contain the name of the root of the tree.
See
-.IR install (1)
+.MR install (1)
for details about installation.
.PP
Many of the familiar Unix commands,
for example
-.IR cat (1),
-.IR ls (1),
+.MR cat (1) ,
+.MR ls (1) ,
and
-.IR wc (1),
+.MR wc (1) ,
are present, but in their Plan 9 forms:
.I cat
takes no options,
@@ -50,12 +50,12 @@ and
.I wc
counts UTF characters.
In some cases, the differences are quite noticeable:
-.IR grep (1)
+.MR grep (1)
and
-.IR sed (1)
+.MR sed (1)
expect Plan 9 regular expressions
(see
-.IR regexp (7)),
+.MR regexp (7) ),
which are closest to what Unix calls extended regular expressions.
Because of these differences, it is not recommended to put
.B $PLAN9/bin
@@ -63,16 +63,16 @@ before the usual system
.B bin
directories in your search path.
Instead, put it at the end of your path and use the
-.IR 9 (1)
+.MR 9 (1)
script when you want to invoke the Plan 9 version of a
traditional Unix command.
.PP
Occasionally the Plan 9 programs have been
changed to adapt to Unix.
-.IR Mk (1)
+.MR Mk (1)
now allows mkfiles to choose their own shell,
and
-.IR rc (1)
+.MR rc (1)
has a
.I ulimit
builtin and manages
@@ -80,14 +80,14 @@ builtin and manages
.PP
Many of the graphical programs from Plan 9 are present,
including
-.IR sam (1)
+.MR sam (1)
and
-.IR acme (1).
+.MR acme (1) .
An X11 window manager
-.IR rio (1)
+.MR rio (1)
mimics Plan 9's window system, with command windows
implemented by the external program
-.IR 9term (1).
+.MR 9term (1) .
Following the style of X Windows, these programs run in new
windows rather than the one in which they are invoked.
They all take a
@@ -101,10 +101,10 @@ The argument is one of
\fIxmin\fL,\fIymin\fL,\fIxmax\fL,\fIymax\fR.
.PP
The
-.IR plumber (4)
+.MR plumber (4)
helps to connect the various Plan 9 programs together,
and fittings like
-.IR web (1)
+.MR web (1)
connect it to external programs such as web browsers;
one can click on a URL in
.I acme
@@ -119,17 +119,17 @@ with file servers by reading and writing files.
This cannot be done directly on Unix.
Instead the servers listen for 9P connections on Unix domain sockets;
clients connect to these sockets and speak 9P directly using the
-.IR 9pclient (3)
+.MR 9pclient (3)
library.
-.IR Intro (4)
+.MR Intro (4)
tells more of the story.
The effect is not as clean as on Plan 9, but it gets the job done
and still provides a uniform and easy-to-understand mechanism.
The
-.IR 9p (1)
+.MR 9p (1)
client can be used in shell scripts or by hand to carry out
simple interactions with servers.
-.IR Netfiles (1)
+.MR Netfiles (1)
is an experimental client for acme.
.SS External databases
Some programs rely on large databases that would be
@@ -146,7 +146,7 @@ The shell scripts
and
.I 9l
(see
-.IR 9c (1))
+.MR 9c (1) )
provide a simple interface to the underlying system compiler and linker,
similar to the
.I 2c
@@ -165,22 +165,22 @@ so that no
options are needed.
.PP
The only way to write multithreaded programs is to use the
-.IR thread (3)
+.MR thread (3)
library.
-.IR Rfork (3)
+.MR Rfork (3)
exists but is not as capable as on Plan 9.
There are many unfortunate by necessary preprocessor
diversions to make Plan 9 and Unix libraries coexist.
See
-.IR intro (3)
+.MR intro (3)
for details.
.PP
The debuggers
-.IR acid (1)
+.MR acid (1)
and
-.IR db (1)
+.MR db (1)
and the debugging library
-.IR mach (3)
+.MR mach (3)
are works in progress.
They are platform-independent, so that x86 Linux core dumps
can be inspected on PowerPC Mac OS X machines,
@@ -203,22 +203,22 @@ but that it is the extent to which they have been developed and exercised.
.SS Porting programs
The vast majority of the familiar Plan 9 programs
have been ported, including the Unicode-aware
-.IR troff (1).
+.MR troff (1) .
.PP
Of the more recent additions to Plan 9,
-.IR factotum (4),
-.IR secstore (1),
+.MR factotum (4) ,
+.MR secstore (1) ,
and
-.IR secstored (1),
-.IR vac (1),
-.IR vacfs (4),
+.MR secstored (1) ,
+.MR vac (1) ,
+.MR vacfs (4) ,
and
-.IR venti (8)
+.MR venti (8)
are all ported.
.PP
A backup system providing a dump file system built atop Venti
is in progress; see
-.IR vbackup (8).
+.MR vbackup (8) .
.SS Porting to new systems
Porting the tree to new operating systems or architectures
should be straightforward, as system-specific code has been
@@ -240,9 +240,9 @@ need to write any system specific code at all.
.PP
There are other smaller system dependencies,
such as the terminal handling code in
-.IR 9term (1)
+.MR 9term (1)
and the implementation of
-.IR getcallerpc (3),
+.MR getcallerpc (3) ,
but these are usually simple and are not on the critical
path for getting the system up and running.
.SH SEE ALSO
@@ -255,7 +255,7 @@ The manual pages are in a Unix style tree, with names like
instead of Plan 9's simpler
.BR $PLAN9/man/1/cat ,
so that the Unix
-.IR man (1)
+.MR man (1)
utility can handle it.
Some systems, for example Debian Linux,
deduce the man page locations from the search path, so that
@@ -300,52 +300,52 @@ describes the Plan 9 file protocol 9P.
These pages describe parts of the system
that are new or different from Plan 9 from Bell Labs:
.IP
-.IR 9 (1),
-.IR 9c (1),
-.IR 9p (1),
-.IR 9term (1),
+.MR 9 (1) ,
+.MR 9c (1) ,
+.MR 9p (1) ,
+.MR 9term (1) ,
.I acidtypes
in
-.IR acid (1),
-.IR dial (1),
-.IR git (1),
-.IR label (1),
+.MR acid (1) ,
+.MR dial (1) ,
+.MR git (1) ,
+.MR label (1) ,
the
.B MKSHELL
variable in
-.IR mk (1),
-.IR namespace (1),
-.IR netfiles (1),
-.IR page (1),
-.IR psfonts (1),
-.IR rio (1),
-.IR web (1),
-.IR wintext (1)
+.MR mk (1) ,
+.MR namespace (1) ,
+.MR netfiles (1) ,
+.MR page (1) ,
+.MR psfonts (1) ,
+.MR rio (1) ,
+.MR web (1) ,
+.MR wintext (1)
.IP
-.IR intro (3),
-.IR 9pclient (3),
+.MR intro (3) ,
+.MR 9pclient (3) ,
the
.B unix
network in
-.IR dial (3),
-.IR exits (3),
-.IR get9root (3),
-.IR getns (3),
-.IR notify (3),
-.IR post9pservice (3),
-.IR rfork (3),
-.IR searchpath (3),
-.IR sendfd (3),
-.IR udpread (3),
-.IR venti (3),
-.IR wait (3),
-.IR wctl (3)
+.MR dial (3) ,
+.MR exits (3) ,
+.MR get9root (3) ,
+.MR getns (3) ,
+.MR notify (3) ,
+.MR post9pservice (3) ,
+.MR rfork (3) ,
+.MR searchpath (3) ,
+.MR sendfd (3) ,
+.MR udpread (3) ,
+.MR venti (3) ,
+.MR wait (3) ,
+.MR wctl (3)
.IP
-.IR intro (4),
-.IR 9pserve (4),
-.IR import (4),
+.MR intro (4) ,
+.MR 9pserve (4) ,
+.MR import (4) ,
.IP
-.IR vbackup (8)
+.MR vbackup (8)
.IP
.IR openfd (9p)
.SH DIAGNOSTICS
@@ -356,4 +356,4 @@ exit with string statuses. In fact, exiting with an empty status
corresponds to exiting with status 0,
and exiting with any non-empty string corresponds to exiting with status 1.
See
-.IR exits (3).
+.MR exits (3) .
diff --git a/man/man1/9.1 b/man/man1/9.1
index a115260d5..34c150d21 100644
--- a/man/man1/9.1
+++ b/man/man1/9.1
@@ -12,7 +12,7 @@
.B .
.B 9
(from
-.IR sh (1))
+.MR sh (1) )
.PP
.B 9.rc
.I cmd
@@ -24,7 +24,7 @@
.B .
.B 9.rc
(from
-.IR rc (1))
+.MR rc (1) )
.PP
.B u
.I cmd
@@ -36,7 +36,7 @@
.B .
.B u
(from
-.IR sh (1))
+.MR sh (1) )
.PP
.B u.rc
.I cmd
@@ -48,7 +48,7 @@
.B .
.B u.rc
(from
-.IR rc (1))
+.MR rc (1) )
.SH DESCRIPTION
Because Plan 9 supplies commands with the same name as but different
behavior than many basic Unix system commands
@@ -86,7 +86,7 @@ in order to make the current shell start running in the Plan 9 environment.
is the same as
.I 9
but written for use by the shell
-.IR rc (1).
+.MR rc (1) .
.PP
.I U
and
@@ -106,7 +106,7 @@ $ 9 grep '[α-ζ]' /etc/passwd
.EE
.PP
Start an
-.IR rc (1)
+.MR rc (1)
with the Plan 9 commands in the path before the system commands,
and then run the Unix
.IR ls :
@@ -124,7 +124,7 @@ $ 9 rc
.br
.B \*9/bin/u.rc
.SH SEE ALSO
-.IR intro (1)
+.MR intro (1)
.SH BUGS
Some shell configurations
(notably, oh-my-zsh)
diff --git a/man/man1/9c.1 b/man/man1/9c.1
index fb04a2961..943df6fbe 100644
--- a/man/man1/9c.1
+++ b/man/man1/9c.1
@@ -1,6 +1,6 @@
.TH 9C 1
.SH NAME
-9c, 9a, 9l, 9ar \- C compiler, assembler, linker, archiver
+9c, 9l, 9ar \- C compiler, assembler, linker, archiver
.SH SYNOPSIS
.B 9c
[
@@ -14,10 +14,6 @@
.I file
\&...
.PP
-.B 9a
-.I file
-\&...
-.PP
.B 9l
[
.I -o
@@ -79,15 +75,7 @@ to the include path.
.I 9c
also defines
.B __sun__
-on SunOS systems and
-.B __Linux26__
-on Linux systems with 2.6-series kernels.
-.PP
-.I 9a
-assembles the named files into object files for the current system.
-Unlike some system assemblers, it does
-.I not
-promise to run the C preprocessor on the source files.
+on SunOS systems.
.PP
.I 9l
links the named object files and libraries to create the target executable.
@@ -136,13 +124,13 @@ but
always provides the following key characters:
.TP
.B d
-Delete
-.I files
+Delete
+.I files
from the archive file.
.TP
.B r
Replace
-.I files
+.I files
in the archive file, or add them if missing.
.TP
.B t
@@ -166,7 +154,7 @@ With
.BR t ,
give a long listing of all information about the files,
somewhat like a listing by
-.IR ls (1),
+.MR ls (1) ,
showing
.br
.ns
@@ -181,7 +169,7 @@ Normally
will create a new archive when
.I afile
does not exist, and give a warning.
-Option
+Option
.B c
discards any old contents and suppresses the warning.
.PD
@@ -205,10 +193,6 @@ rebuilt whenever the archive is modified.
Compile three C source files.
.TP
.L
-9a file4.s
-Assemble one assembler source file.
-.TP
-.L
9ar rvc lib.a file[12].o
Archive the first two object files into a library.
.TP
diff --git a/man/man1/9p.1 b/man/man1/9p.1
index 762e72205..4580587db 100644
--- a/man/man1/9p.1
+++ b/man/man1/9p.1
@@ -121,11 +121,11 @@ copy a line from standard input to the file.
Print errors, but don't give up.
.B Rdwr
is useful for interacting with servers like
-.IR factotum (4).
+.MR factotum (4) .
.TP
.B ls
Print a directory listing in the format of
-.IR ls (1).
+.MR ls (1) .
The
.B -d
and
@@ -150,12 +150,12 @@ it connects to the Unix domain socket
.I service
in the name space directory
(see
-.IR intro (4))
+.MR intro (4) )
and then accesses
.IR subpath .
.SH EXAMPLE
To update
-.IR plumber (4)'s
+.MR plumber (4) 's
copy of your plumbing rules after editing
.BR $HOME/lib/plumbing :
.IP
@@ -164,7 +164,7 @@ cat $HOME/lib/plumbing | 9p write plumb/rules
.EE
.PP
To display the contents of the current
-.IR acme (4)
+.MR acme (4)
window:
.IP
.EX
@@ -173,6 +173,6 @@ window:
.SH SOURCE
.B \*9/src/cmd/9p.c
.SH SEE ALSO
-.IR intro (4),
+.MR intro (4) ,
.IR intro (9p),
-.IR 9pclient (3)
+.MR 9pclient (3)
diff --git a/man/man1/9term.1 b/man/man1/9term.1
index e0e5aad71..2e0426341 100644
--- a/man/man1/9term.1
+++ b/man/man1/9term.1
@@ -58,7 +58,7 @@ uses the imported value of
.B $font
if set; otherwise it uses the graphics system default.
(See
-.IR font (7)
+.MR font (7)
for a full discussion of font syntaxes.)
.PP
.I 9term
@@ -96,7 +96,7 @@ Characters typed on the keyboard replace the selected text;
if this text is not empty, it is placed in a
.I snarf buffer
common to all windows but distinct from that of
-.IR sam (1).
+.MR sam (1) .
.PP
Programs access the text in the window at a single point
maintained automatically by
@@ -163,7 +163,7 @@ and erases the character before the word.
.PP
An ACK character (control-F) or Insert character triggers file name completion
for the preceding string (see
-.IR complete (3)).
+.MR complete (3) ).
.PP
Text may be moved vertically within the window.
A scroll bar on the left of the window shows in its clear portion what fragment of the
@@ -201,7 +201,7 @@ EOT, so the terminal must be set up with EOT
as the ``eof'' character.
.I 9term
runs
-.IR stty (1)
+.MR stty (1)
to establish this when the terminal is created.
.PP
.I 9term
@@ -231,13 +231,13 @@ are a few common ones where they fall short.
First, programs using the GNU readline library typically
disable terminal echo and perform echoing themselves.
The most common example is the shell
-.IR bash (1).
+.MR bash (1) .
Disabling the use of readline with
.RB `` "set +o emacs" ''
.RI [ sic ]
usually restores the desired behavior.
Second, remote terminal programs such as
-.IR ssh (1)
+.MR ssh (1)
typically run with echo disabled, relying on the
remote system to echo characters as desired.
Plan 9's
@@ -279,12 +279,19 @@ The
menu item sends the contents of the selection (not the snarf buffer) to the
.I plumber
(see
-.IR plumb (1)).
+.MR plumb (1) ).
If the selection is empty, it sends the white-space-delimited text
containing the selection (typing cursor).
A typical use of this feature is to tell the editor to find the source of an error
by plumbing the file and line information in a compiler's diagnostic.
.PP
+The
+.B look
+menu item searches forward for the contents of the selection within
+the window. If a match is found, it becomes the new selection and the
+window scrolls to display it. The search wraps around to the beginning
+of the windows if the end of the window is reached.
+.PP
For systems without a three-button mouse, the keyboard modifier
keys can be used to modify the effect of the main mouse button.
On Unix systems, the Control key changes the main button to button 2,
@@ -316,7 +323,7 @@ Not a
.IR 9term
bug:
when running
-.IR bash (1)
+.MR bash (1)
in
.RB `` "set +o emacs" ''
mode, its handling of interrupts is broken.
@@ -327,4 +334,4 @@ character typed.
.PP
Unix makes everything harder.
.SH SEE ALSO
-.IR wintext (1)
+.MR wintext (1)
diff --git a/man/man1/acid.1 b/man/man1/acid.1
index e76aeb25f..ec17c00fd 100644
--- a/man/man1/acid.1
+++ b/man/man1/acid.1
@@ -48,7 +48,7 @@ is a programmable symbolic debugger.
It can inspect one or more processes that share an address space.
A program to be debugged may be specified by the process id of
a running or defunct process,
-or by the name of the program's text file
+or by the name of the program's text file
.RB ( a.out
by default).
At the prompt,
@@ -63,14 +63,14 @@ Allow the textfile to be modified.
Print variable renamings at startup.
.TP
.BI -l " library
-Load from
+Load from
.I library
at startup; see below.
.TP
.BI -m " machine
Assume instructions are for the given CPU type
(see
-.IR mach (3))
+.MR mach (3) )
instead of using the executable header to select
the CPU type.
.TP
@@ -84,8 +84,8 @@ obtains standard function definitions from the library file
architecture-dependent functions from
.BR \*9/acid/$objtype ,
user-specified functions from
-.BR $home/lib/acid ,
-and further functions from
+.BR $HOME/lib/acid ,
+and further functions from
.B -l
files.
Definitions in any file may override previously defined functions.
@@ -106,7 +106,7 @@ to create
.I acid
functions for examining data structures.
.SS Language
-Symbols of the program being debugged become integer
+Symbols of the program being debugged become integer
variables whose values are addresses.
Contents of addresses are obtained by indirection.
Local variables are qualified by
@@ -114,7 +114,7 @@ function name, for example
.BR main:argv .
When program symbols conflict with
.I acid
-words, distinguishing
+words, distinguishing
.B $
signs are prefixed.
Such renamings are reported at startup; option
@@ -127,7 +127,7 @@ and formats are inferred from assignments.
Truth values false/true are attributed to zero/nonzero
integers or floats and to empty/nonempty lists or strings.
Lists are sequences of expressions surrounded by
-.BR {\^}
+.BR {\^}
and separated by commas.
.PP
Expressions are much as in C,
@@ -145,7 +145,7 @@ subscripts counted from 0.
.BI delete " list", " subscript
.PP
Format codes are the same as in
-.IR db (1).
+.MR db (1) .
Formats may be attached to (unary) expressions with
.BR \e ,
e.g.
@@ -219,7 +219,7 @@ Same as
.BR spr();gpr() .
.TP
.BI fmt( expr , format )
-Expression
+Expression
.I expr
with format given by the character value of expression
.IR format .
@@ -230,7 +230,7 @@ Print 10 lines of source around the program address.
.BI Bsrc( address )
Get the source line for the program address
into a window of a running
-.IR sam (1)
+.MR sam (1)
and select it.
.TP
.BI line( address )
@@ -243,7 +243,7 @@ List current source directories.
Add a source directory to the list.
.TP
.BI filepc( where )
-Convert a string of the form
+Convert a string of the form
.IB sourcefile : linenumber
to a machine address.
.TP
@@ -288,7 +288,7 @@ interpreted according to a string of format codes.
.BI dump( address , n , string\fP)
Like
.BR mem (),
-repeated for
+repeated for
.I n
consecutive blocks.
.TP
@@ -300,7 +300,7 @@ Start a new process with arguments given as a string
and halt at the first instruction.
.TP
.B new()
-Like
+Like
.IR newproc (),
but take arguments (except
.BR argv[0] )
@@ -308,7 +308,7 @@ from string variable
.BR progargs .
.TP
.B win()
-Like
+Like
.IR new (),
but run the process in a separate window.
.TP
@@ -323,7 +323,7 @@ Make the given process current.
.TP
.BI rc( string )
Escape to the shell,
-.IR rc (1),
+.MR rc (1) ,
to execute the command string.
.TP
.BI include( string )
@@ -337,7 +337,7 @@ When a pid or core file is specified on the command line,
.I acid
will, as part of its startup, determine the set of shared libraries
in use by the process image and map those at appropriate locations.
-If
+If
.I acid
is started without a pid or core file
and is subsequently attached to a process via
@@ -414,7 +414,7 @@ acid: *argv0
acid: bpset(ls)
acid: cont()
70094: breakpoint ls ADD $-0x16c8,R29
-acid:
+acid:
.EE
.PP
Display elements of a linked list of structures:
@@ -449,7 +449,7 @@ notation)
.BR *array .
.PP
Trace the system calls executed by
-.IR ls (1)
+.MR ls (1)
(neither does this one):
.IP
.EX
@@ -499,12 +499,12 @@ acid: cont()
.br
.B \*9/acid/truss
.br
-.B $home/lib/acid
+.B $HOME/lib/acid
.SH SOURCE
.B \*9/src/cmd/acid
.SH "SEE ALSO"
-.IR mk (1),
-.IR db (1)
+.MR mk (1) ,
+.MR db (1)
.br
Phil Winterbottom,
``Acid Manual''.
diff --git a/man/man1/acme.1 b/man/man1/acme.1
index b3266595b..852a8f7f1 100644
--- a/man/man1/acme.1
+++ b/man/man1/acme.1
@@ -45,7 +45,7 @@ The interactive interface uses the keyboard and mouse; external programs
use a set of files served by
.IR acme ;
these are discussed in
-.IR acme (4).
+.MR acme (4) .
.PP
Any named
.I files
@@ -86,7 +86,7 @@ The
option instructs
.I acme
to use FUSE (see
-.IR 9pfuse (4))
+.MR 9pfuse (4) )
to mount itself at
.IR mtpt .
(Experimental.)
@@ -98,10 +98,10 @@ windows are in two parts: a one-line
above a multi-line
.IR body .
The body typically contains an image of a file, as in
-.IR sam (1),
+.MR sam (1) ,
or the output of a
program, as in an
-.IR rio (1)
+.MR rio (1)
window.
The tag contains a number of
blank-separated words, followed by a vertical bar character, followed by anything.
@@ -118,9 +118,9 @@ a slash.
.SS Scrolling
Each window has a scroll bar to the left of the body.
The scroll bar behaves much as in
-.IR sam (1)
+.MR sam (1)
or
-.IR rio (1)
+.MR rio (1)
except that scrolling occurs when the button is pressed, rather than released,
and continues
as long as the mouse button is held down in the scroll bar.
@@ -129,9 +129,9 @@ hold button 3 down near the top of the scroll bar. Moving the mouse
down the scroll bar speeds up the rate of scrolling.
(The experimental option
.B -r
-reverses the scrolling behavior of buttons 1 and 3, to behave
+reverses the scrolling behavior of buttons 1 and 3, to behave
more like
-.IR xterm (1).)
+.MR xterm (1) .)
.SS Layout
.I Acme
windows are arranged in columns. By default, it creates two columns when starting;
@@ -164,7 +164,7 @@ pre-loads them with useful commands.
Also, the tag across the top maintains a list of executing long-running commands.
.SS Typing
The behavior of typed text is similar to that in
-.IR rio (1)
+.MR rio (1)
except that the characters are delivered to the tag or body under the mouse; there is no
`click to type'.
(The experimental option
@@ -172,7 +172,7 @@ except that the characters are delivered to the tag or body under the mouse; the
causes typing to go to the most recently clicked-at or made window.)
The usual backspacing conventions apply.
As in
-.IR sam (1)
+.MR sam (1)
but not
.IR rio ,
the ESC key selects the text typed since the last mouse action,
@@ -193,10 +193,15 @@ When a window is in autoindent mode
(see the
.B Indent
command below) and a newline character is typed,
-acme copies leading white space on the current line to the new line.
+.I acme
+copies leading white space on the current line to the new line,
+and when a window is
+.BR Put ,
+.I acme
+removes all trailing end-of-line white space before writing the file.
The option
.B -a
-causes each window to start in
+causes each window to start in
autoindent mode.
.SS "Directory context
Each window's tag names a directory: explicitly if the window
@@ -244,7 +249,7 @@ is identified by the context of the command.
These error windows are created when needed.
.SS "Mouse button 1
Mouse button 1 selects text just as in
-.IR sam (1)
+.MR sam (1)
or
.IR rio (1) ,
including the usual double-clicking conventions.
@@ -295,12 +300,12 @@ Delete window without checking for dirtiness.
Write the state of
.I acme
to the file name, if specified, or
-.B $home/acme.dump
+.B $HOME/acme.dump
by default.
.TP
.B Edit
Treat the argument as a text editing command in the style of
-.IR sam (1).
+.MR sam (1) .
The full
.B Sam
language is implemented except for the commands
@@ -374,7 +379,7 @@ With no arguments,
prints the supplementary list.
This command is largely superseded by plumbing
(see
-.IR plumb (7)).
+.MR plumb (7) ).
.TP
.B Indent
Set the autoindent mode according to the argument:
@@ -398,7 +403,7 @@ commands named as arguments.
Restore the state of
.I acme
from a file (default
-.BR $home/acme.dump )
+.BR $HOME/acme.dump )
created by the
.B Dump
command.
@@ -406,7 +411,7 @@ command.
.B Local
In the Plan 9
.IR acme ,
-this prefix causes a command to be run in
+this prefix causes a command to be run in
.IR acme 's own
file name space and environment variable group.
On Unix this is impossible.
@@ -502,7 +507,7 @@ If the text indicated with button 2 is not a recognized built-in, it is executed
a shell command. For example, indicating
.B date
with button 2 runs
-.IR date (1).
+.MR date (1) .
The standard
and error outputs of commands are sent to the error window associated with
the directory from which the command was run, which will be created if
@@ -520,7 +525,7 @@ in a window containing
executing
.B mk
will run
-.IR mk (1)
+.MR mk (1)
in
.BR /home/rob/sam ,
producing output in a window labeled
@@ -534,13 +539,13 @@ and
.B $winid
set to the window's id number
(see
-.IR acme (4)).
+.MR acme (4) ).
.PP
The environment variable
.B $acmeshell
determines which shell is used to execute such commands; the
-.IR rc (1)
-shell is used by default.
+.MR rc (1)
+shell is used by default.
.SS "Mouse button 3
Pointing at text with button 3 instructs
.I acme
@@ -569,7 +574,7 @@ command adds directories to the standard list.)
.PP
If the text begins with a colon, it is taken to be an address, in
the style of
-.IR sam (1),
+.MR sam (1) ,
within the body of the window containing the text.
The address is evaluated, the resulting text highlighted, and the mouse moved to it.
Thus, in
@@ -639,7 +644,7 @@ then execute
clicking button 1 while 2 is held down.
.PP
When an external command (e.g.
-.IR echo (1))
+.MR echo (1) )
is executed this way, the extra argument is passed as expected and an
environment variable
.B $acmeaddr
@@ -658,7 +663,7 @@ button and then typing Option without letting go of the button will
cause a 1-2 chord, cutting the selection.
On Mac systems, the usual keyboard shortcuts
Command-C, -V, -X, and -Z invoke
-copy, paste, cut, and undo,
+copy, paste, cut, and undo,
and Command-Shift-Z invokes redo,
as in other programs.
Especially on Mac laptops, these keyboard shortcuts are
@@ -672,7 +677,7 @@ window and runs a
(default
.BR $SHELL )
in it, turning the window into something analogous to an
-.IR 9term (1)
+.MR 9term (1)
window.
Executing text in a
.I win
@@ -681,7 +686,7 @@ window with button
.BR Send .
.I Win
windows follow the same scrolling heuristic as in
-.IR 9term (1):
+.MR 9term (1) :
the window scrolls on output only if the window is displaying the end of the buffer.
.PP
.I Awd
@@ -740,9 +745,9 @@ and
.I awd
reside.
.SH FILES
-.TF $home/acme.dump
+.TF $HOME/acme.dump
.TP
-.B $home/acme.dump
+.B $HOME/acme.dump
default file for
.B Dump
and
@@ -769,7 +774,7 @@ MIPS-specific binaries for applications
.br
.B \*9/bin/awd
.SH SEE ALSO
-.IR acme (4)
+.MR acme (4)
.br
Rob Pike,
.I
diff --git a/man/man1/acmeevent.1 b/man/man1/acmeevent.1
index d5ff0830e..24fde4f50 100644
--- a/man/man1/acmeevent.1
+++ b/man/man1/acmeevent.1
@@ -61,7 +61,7 @@ acmeevent, acme.rc \- shell script support for acme clients
and
.I acme.rc
make it easy to write simple
-.IR acme (1)
+.MR acme (1)
client programs as shell scripts.
.PP
.I Acme
@@ -69,14 +69,14 @@ clients read the
.B event
files
(see
-.IR acme (4))
+.MR acme (4) )
for the windows they control, reacting to the events.
The events are presented in a format that is easy to read with C programs
but hard to read with shell scripts.
.PP
.I Acmeevent
reads an
-.IR acme (4)
+.MR acme (4)
event stream from standard input, printing a shell-friendly
version of the events, one per line, on standard output.
Each output line from
@@ -165,7 +165,7 @@ above);
below).
.I Flag
remains from the
-.IR acme (4)
+.MR acme (4)
event format.
Because
.IR eq0 ,
@@ -174,7 +174,7 @@ and
.I chordarg
are explicit in each event
(unlike in
-.IR acme (4)
+.MR acme (4)
events),
.I flag
can usually be ignored.
@@ -221,7 +221,7 @@ window.
.PP
.I Acme.rc
is a library of
-.IR rc (1)
+.MR rc (1)
shell functions useful for writing acme clients.
.PP
.I Newwindow
@@ -259,14 +259,14 @@ The most commonly-used command is
.BR clean ,
which marks the window as clean.
See
-.IR acme (4)
+.MR acme (4)
for a full list of commands.
.PP
.I Windump
sets the window's dump directory
and dump command
(see
-.IR acme (4)).
+.MR acme (4) ).
If either argument is omitted or is
.BR - ,
that argument is not set.
@@ -381,9 +381,9 @@ for the full implementation.
.br
.B \*9/lib/acme.rc
.SH SEE ALSO
-.IR acme (1),
-.IR acme (4),
-.IR rc (1)
+.MR acme (1) ,
+.MR acme (4) ,
+.MR rc (1)
.SH BUGS
There is more that could be done to ease the writing
of complicated clients.
diff --git a/man/man1/ascii.1 b/man/man1/ascii.1
index 0857805e9..99265f467 100644
--- a/man/man1/ascii.1
+++ b/man/man1/ascii.1
@@ -91,7 +91,7 @@ control characters or insert newlines.
is similar; it converts between
.SM UTF
and character values from the Unicode Standard (see
-.IR utf (7)).
+.MR utf (7) ).
If given a range of hexadecimal numbers,
.I unicode
prints a table of the specified Unicode characters \(em their values and
@@ -126,7 +126,7 @@ The file
contains a
table of characters and descriptions, sorted in hexadecimal order,
suitable for
-.IR look (1)
+.MR look (1)
on the lower case
.I hex
values of characters.
@@ -154,7 +154,7 @@ table of characters and descriptions.
.br
.B \*9/src/cmd/unicode.c
.SH "SEE ALSO"
-.IR look (1),
-.IR tcs (1),
-.IR utf (7),
-.IR font (7)
+.MR look (1) ,
+.MR tcs (1) ,
+.MR utf (7) ,
+.MR font (7)
diff --git a/man/man1/astro.1 b/man/man1/astro.1
index af5e7afa4..b24cfa3fa 100644
--- a/man/man1/astro.1
+++ b/man/man1/astro.1
@@ -114,7 +114,7 @@ default latitude (N), longitude (W), and elevation (meters)
.SH SOURCE
.B \*9/src/cmd/astro
.SH SEE ALSO
-.IR scat (1)
+.MR scat (1)
.SH BUGS
The
.B k
diff --git a/man/man1/awk.1 b/man/man1/awk.1
index 9a933b709..395dfa96d 100644
--- a/man/man1/awk.1
+++ b/man/man1/awk.1
@@ -377,7 +377,7 @@ Patterns are arbitrary Boolean combinations
of regular expressions and
relational expressions.
Regular expressions are as in
-.IR regexp (7).
+.MR regexp (7) .
Isolated regular expressions
in a pattern apply to the entire line.
Regular expressions may also occur in
@@ -534,8 +534,8 @@ BEGIN { # Simulate echo(1)
.SH SOURCE
.B \*9/src/cmd/awk
.SH SEE ALSO
-.IR sed (1),
-.IR regexp (7),
+.MR sed (1) ,
+.MR regexp (7) ,
.br
A. V. Aho, B. W. Kernighan, P. J. Weinberger,
.I
diff --git a/man/man1/bc.1 b/man/man1/bc.1
index 571943409..497481301 100644
--- a/man/man1/bc.1
+++ b/man/man1/bc.1
@@ -218,7 +218,7 @@ Assignment to
.B scale
influences the number of digits to be retained on arithmetic
operations in the manner of
-.IR dc (1).
+.MR dc (1) .
Assignments to
.B ibase
or
@@ -235,7 +235,7 @@ empty square brackets must follow the array name.
.PP
.I Bc
is actually a preprocessor for
-.IR dc (1),
+.MR dc (1) ,
which it invokes automatically, unless the
.B -c
(compile only)
@@ -273,7 +273,7 @@ mathematical library
.B \*9/src/cmd/bc.y
.SH "SEE ALSO"
.IR dc (1),
-.IR hoc (1)
+.MR hoc (1)
.SH BUGS
No
.LR && ,
diff --git a/man/man1/bundle.1 b/man/man1/bundle.1
index 36bcd8d05..b48803433 100644
--- a/man/man1/bundle.1
+++ b/man/man1/bundle.1
@@ -7,20 +7,20 @@ bundle \- collect files for distribution
.SH DESCRIPTION
.I Bundle
writes on its standard output a shell script for
-.IR rc (1)
+.MR rc (1)
or a Bourne shell
which, when executed,
will recreate the original
.IR files .
Its main use is for distributing small numbers of text files by
-.IR mail (1).
+.MR mail (1) .
.PP
Although less refined than standard archives from
.I 9ar
(see
-.IR 9c (1))
+.MR 9c (1) )
or
-.IR tar (1),
+.MR tar (1) ,
a
.IR bundle
file
@@ -49,7 +49,7 @@ cd gift; sh horse; mk
(in
.IR 9c (1)),
.IR tar (1),
-.IR mail (1)
+.MR mail (1)
.SH BUGS
.I Bundle
will not create directories and is unsatisfactory for non-text files.
diff --git a/man/man1/calendar.1 b/man/man1/calendar.1
index 14c6f911c..5a305699b 100644
--- a/man/man1/calendar.1
+++ b/man/man1/calendar.1
@@ -43,7 +43,7 @@ processing at the end of the week.
On Friday and Saturday, events through Monday are printed.
.PP
To have your calendar mailed to you every day, use
-.IR cron (8).
+.MR cron (8) .
.SH FILES
.TF $HOME/lib/calendar
.TP
diff --git a/man/man1/cat.1 b/man/man1/cat.1
index 0738206aa..7ff12e69b 100644
--- a/man/man1/cat.1
+++ b/man/man1/cat.1
@@ -51,7 +51,7 @@ copies to standard output exactly one line from the named
.IR file ,
default standard input.
It is useful in interactive
-.IR rc (1)
+.MR rc (1)
scripts.
.PP
The
@@ -76,11 +76,11 @@ characters and the characters that precede them.
It is useful to use as
.B $PAGER
with the Unix version of
-.IR man (1)
+.MR man (1)
when run inside a
.I win
(see
-.IR acme (1))
+.MR acme (1) )
window.
.SH SOURCE
.B \*9/src/cmd/cat.c
@@ -89,7 +89,7 @@ window.
.br
.B \*9/bin/nobs
.SH SEE ALSO
-.IR cp (1)
+.MR cp (1)
.SH DIAGNOSTICS
.I Read
exits with status
diff --git a/man/man1/cleanname.1 b/man/man1/cleanname.1
index 02ad0baa2..1f59e6772 100644
--- a/man/man1/cleanname.1
+++ b/man/man1/cleanname.1
@@ -29,4 +29,4 @@ before processing.
.SH SOURCE
.B \*9/src/cmd/cleanname.c
.SH SEE ALSO
-.IR cleanname (3).
+.MR cleanname (3) .
diff --git a/man/man1/col.1 b/man/man1/col.1
index 1cdcbcba4..77d4d46bf 100644
--- a/man/man1/col.1
+++ b/man/man1/col.1
@@ -14,11 +14,11 @@ and half line feeds (ESC-9 and ESC-8)
as produced by
.I nroff
for .2C in
-.IR ms (7)
+.MR ms (7)
or
-.IR man (7)
+.MR man (7)
and for
-.IR tbl (1).
+.MR tbl (1) .
.I Col
is a pure filter.
It normally emits only full line feeds;
@@ -47,7 +47,7 @@ paginate the output.
.SH SOURCE
.B \*9/src/cmd/col.c
.SH SEE ALSO
-.IR pr (1)
+.MR pr (1)
.SH BUGS
.I Col
can't back up more than 128 lines or
diff --git a/man/man1/colors.1 b/man/man1/colors.1
index 9e850621a..b85f3d8b0 100644
--- a/man/man1/colors.1
+++ b/man/man1/colors.1
@@ -17,13 +17,13 @@ colors, cmapcube \- display color map
.I Colors
presents a grid showing the colors in the RGBV color map
(see
-.IR color (7)).
+.MR color (7) ).
.PP
Clicking mouse button 1 over a color in the grid will display the map index for that color,
its
red, green, and blue components,
and the 32-bit hexadecimal color value as defined in
-.IR allocimage (3).
+.MR allocimage (3) .
If the
.B -x
option is specified, the components will also be listed in hexadecimal.
@@ -53,4 +53,4 @@ to black or white.
.SH SOURCE
.B \*9/src/cmd/draw/colors.c
.SH SEE ALSO
-.IR color (7)
+.MR color (7)
diff --git a/man/man1/comm.1 b/man/man1/comm.1
index 1e5d24dc5..86d4c34ac 100644
--- a/man/man1/comm.1
+++ b/man/man1/comm.1
@@ -41,7 +41,7 @@ Print lines common to two sorted files.
.SH SOURCE
.B \*9/src/cmd/comm.c
.SH "SEE ALSO"
-.IR sort (1),
+.MR sort (1) ,
.IR cmp (1),
.IR diff (1),
-.IR uniq (1)
+.MR uniq (1)
diff --git a/man/man1/compress.1 b/man/man1/compress.1
new file mode 100644
index 000000000..7dda3e18b
--- /dev/null
+++ b/man/man1/compress.1
@@ -0,0 +1,237 @@
+.TH COMPRESS 1
+.SH NAME
+compress, uncompress, zcat \- compress and expand data
+.SH SYNOPSIS
+.B compress
+[
+.B \-f
+] [
+.B \-v
+] [
+.B \-c
+] [
+.B \-V
+] [
+.B \-b
+.I bits
+] [
+.I "name \&..."
+]
+.PP
+.B uncompress
+[
+.B \-f
+] [
+.B \-v
+] [
+.B \-c
+] [
+.B \-V
+] [
+.I "name \&..."
+]
+.PP
+.B zcat
+[
+.B \-V
+] [
+.I "name \&..."
+]
+.SH DESCRIPTION
+.I Compress
+reduces the size of the named files using adaptive Lempel-Ziv coding.
+Whenever possible,
+each file is replaced by one with the extension
+.B "\&.Z,"
+while keeping the same ownership modes, access and modification times.
+If no files are specified, the standard input is compressed to the
+standard output.
+Compressed files can be restored to their original form using
+.I uncompress
+or
+.I zcat.
+.PP
+The
+.B \-f
+option will force compression of
+.I name.
+This is useful for compressing an entire directory,
+even if some of the files do not actually shrink.
+If
+.B \-f
+is not given and
+.I compress
+is run in the foreground,
+the user is prompted as to whether an existing file should be overwritten.
+.PP
+The
+.B \-c
+option makes
+.I compress/uncompress
+write to the standard output; no files are changed.
+The nondestructive behavior of
+.I zcat
+is identical to that of
+.I uncompress
+.B \-c.
+.PP
+.I Compress
+uses the modified Lempel-Ziv algorithm popularized in
+"A Technique for High Performance Data Compression",
+Terry A. Welch,
+.I "IEEE Computer,"
+vol. 17, no. 6 (June 1984), pp. 8-19.
+Common substrings in the file are first replaced by 9-bit codes 257 and up.
+When code 512 is reached, the algorithm switches to 10-bit codes and
+continues to use more bits until the
+limit specified by the
+.B \-b
+flag is reached (default 16).
+.I Bits
+must be between 9 and 16. The default can be changed in the source to allow
+.I compress
+to be run on a smaller machine.
+.PP
+After the
+.I bits
+limit is attained,
+.I compress
+periodically checks the compression ratio. If it is increasing,
+.I compress
+continues to use the existing code dictionary. However,
+if the compression ratio decreases,
+.I compress
+discards the table of substrings and rebuilds it from scratch. This allows
+the algorithm to adapt to the next "block" of the file.
+.PP
+Note that the
+.B \-b
+flag is omitted for
+.I uncompress,
+since the
+.I bits
+parameter specified during compression
+is encoded within the output, along with
+a magic number to ensure that neither decompression of random data nor
+recompression of compressed data is attempted.
+.PP
+.ne 8
+The amount of compression obtained depends on the size of the
+input, the number of
+.I bits
+per code, and the distribution of common substrings.
+Typically, text such as source code or English
+is reduced by 50\-60%.
+Compression is generally much better than that achieved by
+Huffman coding (as used in
+.IR pack ),
+or adaptive Huffman coding
+.RI ( compact ),
+and takes less time to compute.
+.PP
+Under the
+.B \-v
+option,
+a message is printed yielding the percentage of
+reduction for each file compressed.
+.PP
+If the
+.B \-V
+option is specified, the current version and compile options are printed on
+stderr.
+.PP
+Exit status is normally 0;
+if the last file is larger after (attempted) compression, the status is 2;
+if an error occurs, exit status is 1.
+.SH "SEE ALSO"
+pack(1), compact(1)
+.SH "DIAGNOSTICS"
+Usage: compress [\-dfvcV] [\-b maxbits] [file ...]
+.in +8
+Invalid options were specified on the command line.
+.in -8
+Missing maxbits
+.in +8
+Maxbits must follow
+.BR \-b \.
+.in -8
+.IR file :
+not in compressed format
+.in +8
+The file specified to
+.I uncompress
+has not been compressed.
+.in -8
+.IR file :
+compressed with
+.I xx
+bits, can only handle
+.I yy
+bits
+.in +8
+.I File
+was compressed by a program that could deal with
+more
+.I bits
+than the compress code on this machine.
+Recompress the file with smaller
+.IR bits \.
+.in -8
+.IR file :
+already has .Z suffix -- no change
+.in +8
+The file is assumed to be already compressed.
+Rename the file and try again.
+.in -8
+.IR file :
+filename too long to tack on .Z
+.in +8
+The file cannot be compressed because its name is longer than
+12 characters.
+Rename and try again.
+This message does not occur on BSD systems.
+.in -8
+.I file
+already exists; do you wish to overwrite (y or n)?
+.in +8
+Respond "y" if you want the output file to be replaced; "n" if not.
+.in -8
+uncompress: corrupt input
+.in +8
+A SIGSEGV violation was detected which usually means that the input file has
+been corrupted.
+.in -8
+Compression:
+.I "xx.xx%"
+.in +8
+Percentage of the input saved by compression.
+(Relevant only for
+.BR \-v \.)
+.in -8
+-- not a regular file: unchanged
+.in +8
+When the input file is not a regular file,
+(e.g. a directory), it is
+left unaltered.
+.in -8
+-- has
+.I xx
+other links: unchanged
+.in +8
+The input file has links; it is left unchanged. See
+.IR ln "(1)"
+for more information.
+.in -8
+-- file unchanged
+.in +8
+No savings is achieved by
+compression. The input remains virgin.
+.in -8
+.SH SOURCE
+.B \*9/src/cmd/compress/compress.c
+.SH "BUGS"
+Although compressed files are compatible between machines with large memory,
+.BR \-b \12
+should be used for file transfer to architectures with
+a small process data space (64KB or less, as exhibited by the DEC PDP
+series, the Intel 80286, etc.)
diff --git a/man/man1/core.1 b/man/man1/core.1
index 51d235fbd..caf6351ba 100644
--- a/man/man1/core.1
+++ b/man/man1/core.1
@@ -35,7 +35,7 @@ The
command, if run, prints a stack trace of the
executing thread at the time of the core dump;
see
-.IR db (1).
+.MR db (1) .
.PP
If no arguments are given,
.I core
@@ -50,6 +50,6 @@ searches the current directory.
.SH SOURCE
.B \*9/src/cmd/core.c
.SH "SEE ALSO
-.IR acid (1),
-.IR db (1),
-.IR core (5)
+.MR acid (1) ,
+.MR db (1) ,
+.MR core (5)
diff --git a/man/man1/crop.1 b/man/man1/crop.1
index 1df8bf91e..c47afac65 100644
--- a/man/man1/crop.1
+++ b/man/man1/crop.1
@@ -53,9 +53,9 @@ crop, iconv \- frame, crop, and convert image
.SH DESCRIPTION
.I Crop
reads an
-.IR image (7)
+.MR image (7)
file (default standard input), crops it, and writes it as a compressed
-.IR image (7)
+.MR image (7)
file to standard output.
There are two ways to specify a crop, by color value or by geometry.
They may be combined in a single run of
@@ -65,7 +65,7 @@ in which case the color value crop will be done first.
The
.B -c
option takes a red-green-blue triplet as described in
-.IR color (3).
+.MR color (3) .
(For example, white
is
.B 255
@@ -118,7 +118,7 @@ changes the format of pixels in the image
Pixels in the image are converted according to the channel descriptor
.IR chandesc ,
(see
-.IR image (7)).
+.MR image (7) ).
For example, to convert a 4-bit-per-pixel grey-scale image to an 8-bit-per-pixel
color-mapped image,
.I chandesc
@@ -139,8 +139,8 @@ crop -c 255 255 255 -i -10 -b 255 150 150 imagefile > cropped
.SH SOURCE
.B \*9/src/cmd/draw/crop.c
.SH SEE ALSO
-.IR image (7),
-.IR color (3)
+.MR image (7) ,
+.MR color (3)
.SH BUGS
.I Iconv
should be able to do Floyd-Steinberg error diffusion or dithering
diff --git a/man/man1/date.1 b/man/man1/date.1
index 1ce96f384..7d68b94fc 100644
--- a/man/man1/date.1
+++ b/man/man1/date.1
@@ -1,6 +1,6 @@
.TH DATE 1
.SH NAME
-date \- date and time
+date, clock \- date and time
.SH SYNOPSIS
.B date
[
@@ -8,8 +8,8 @@ date \- date and time
] [
.I seconds
]
-.\" .br
-.\" .B clock
+.br
+.B clock
.SH DESCRIPTION
Print the date, in the format
.PP
@@ -28,12 +28,15 @@ epoch, 00:00:00 GMT, January 1, 1970.
The conversion from Greenwich Mean Time to local time depends on the
.B $timezone
environment variable; see
-.IR ctime (3).
+.MR ctime (3) .
.PP
If the optional argument
.I seconds
is present, it is used as the time to convert rather than
the real time.
+.PP
+.I Clock
+draws a simple analog clock in its window.
.\" .SH FILES
.\" .TF /adm/timezone/local
.\" .TP
@@ -54,5 +57,5 @@ the real time.
.\" draws a simple analog clock in its window.
.SH SOURCE
.B \*9/src/cmd/date.c
-.\" .br
-.\" .B \*9/src/cmd/draw/clock.c
+.br
+.B \*9/src/cmd/draw/clock.c
diff --git a/man/man1/db.1 b/man/man1/db.1
index 03355508c..5c2cc9db7 100644
--- a/man/man1/db.1
+++ b/man/man1/db.1
@@ -45,11 +45,11 @@ specifies the memory image of a process.
A
.I pid
gives the id of an executing process to be accessed via
-.IR ptrace (2).
+.MR ptrace (2) .
A
.I corefile
specifies the name of a core dump (see
-.IR core (5)
+.MR core (5)
on your system of choice) containing the
memory image of a terminated process.
This manual refers to the memory image specified by
@@ -628,7 +628,7 @@ Dot is assigned to the variable or register named.
.TP
.B !
The rest of the line is passed to
-.IR rc (1)
+.MR rc (1)
for execution.
.TP
.BI $ modifier
@@ -969,8 +969,8 @@ is one the breakpoint will fire.
Beware that local variables may be stored in registers; see the
BUGS section.
.SH "SEE ALSO"
-.IR acid (1),
-.IR core (1)
+.MR acid (1) ,
+.MR core (1)
.SH SOURCE
.B \*9/src/cmd/db
.SH DIAGNOSTICS
diff --git a/man/man1/dc.1 b/man/man1/dc.1
index 5394580a4..70597dcca 100644
--- a/man/man1/dc.1
+++ b/man/man1/dc.1
@@ -235,8 +235,8 @@ lyx
.SH SOURCE
.B \*9/src/cmd/dc.c
.SH "SEE ALSO"
-.IR bc (1),
-.IR hoc (1)
+.MR bc (1) ,
+.MR hoc (1)
.SH DIAGNOSTICS
.I x
.LR "is unimplemented" ,
diff --git a/man/man1/dd.1 b/man/man1/dd.1
index 63b35e145..6e942fd8b 100644
--- a/man/man1/dd.1
+++ b/man/man1/dd.1
@@ -191,7 +191,7 @@ options become a simple file copy.
.SH SOURCE
.B \*9/src/cmd/dd.c
.SH "SEE ALSO"
-.IR cp (1)
+.MR cp (1)
.SH DIAGNOSTICS
.I Dd
reports the number of full + partial input and output
diff --git a/man/man1/deroff.1 b/man/man1/deroff.1
index 9d159f9e4..1489aaddb 100644
--- a/man/man1/deroff.1
+++ b/man/man1/deroff.1
@@ -16,13 +16,13 @@ reads each file in sequence
and removes all
.I nroff
and
-.IR troff (1)
+.MR troff (1)
requests and non-text arguments, backslash constructions,
and constructs of preprocessors such as
-.IR eqn (1),
-.IR pic (1),
+.MR eqn (1) ,
+.MR pic (1) ,
and
-.IR tbl (1).
+.MR tbl (1) .
Remaining text is written on the standard output.
.I Deroff
follows files included by
@@ -67,7 +67,7 @@ requests.
Remove titles, attachments, etc., as well as ordinary
.IR troff
constructs, from
-.IR ms (7)
+.MR ms (7)
or
.I mm
documents.
@@ -84,7 +84,7 @@ does for
and
.I latex
(see
-.IR tex (1))
+.MR tex (1) )
files what
.B deroff -wi
does for
@@ -96,8 +96,8 @@ files.
.B \*9/src/cmd/delatex.lx
.SH "SEE ALSO"
.IR troff (1),
-.IR tex (1),
-.IR spell (1)
+.MR tex (1) ,
+.MR spell (1)
.SH BUGS
These filters are not complete interpreters of
.I troff
diff --git a/man/man1/devdraw.1 b/man/man1/devdraw.1
index 009f5a94d..da36b8e2a 100644
--- a/man/man1/devdraw.1
+++ b/man/man1/devdraw.1
@@ -5,7 +5,7 @@ devdraw \- draw device simulator
invoked via
.I initdraw
(see
-.IR graphics (3))
+.MR graphics (3) )
.SH DESCRIPTION
.I Devdraw
serves a custom graphics protocol and is the only program
@@ -20,9 +20,9 @@ to use all available physical pixels on a retina display.
.SH SOURCE
.B \*9/src/cmd/devdraw
.SH "SEE ALSO
-.IR draw (3),
-.IR drawfcall (3),
-.IR graphics (3)
+.MR draw (3) ,
+.MR drawfcall (3) ,
+.MR graphics (3)
.SH BUGS
.I Devdraw
should probably present a standard 9P server
diff --git a/man/man1/dial.1 b/man/man1/dial.1
index 7fc50bcdb..0245ba16e 100644
--- a/man/man1/dial.1
+++ b/man/man1/dial.1
@@ -12,7 +12,7 @@ dial \- connect to a remote service
connects to the network address
.I addr
(see
-.IR dial (3))
+.MR dial (3) )
and then copies data from the connection to standard output,
and from standard input to the connection.
.PP
@@ -27,4 +27,4 @@ to exit only in response to end of file on the network connection.
.SH SOURCE
.B \*9/src/cmd/dial.c
.SH SEE ALSO
-.IR dial (3)
+.MR dial (3)
diff --git a/man/man1/dict.1 b/man/man1/dict.1
index d382acc47..f4654ea3b 100644
--- a/man/man1/dict.1
+++ b/man/man1/dict.1
@@ -53,7 +53,7 @@ Print a pronunciation key.
.PD
.PP
Patterns are regular expressions (see
-.IR regexp (7)),
+.MR regexp (7) ),
with an implicit leading
.L ^
and trailing
@@ -154,7 +154,7 @@ searches for dictionaries in the directory named by
.PP
.I Adict
is a dictionary browser for
-.IR acme (1).
+.MR acme (1) .
When run with no arguments, it creates a new
.I acme
window named
@@ -193,7 +193,7 @@ window.
dictionaries
.PD
.SH "SEE ALSO"
-.IR regexp (7)
+.MR regexp (7)
.SH SOURCE
.B \*9/src/cmd/dict
.br
diff --git a/man/man1/diff.1 b/man/man1/diff.1
index fd42643d3..c92f45ef4 100644
--- a/man/man1/diff.1
+++ b/man/man1/diff.1
@@ -19,7 +19,7 @@ two directories are compared by the method of
.I diff
for text
files and
-.IR cmp (1)
+.MR cmp (1)
otherwise.
If more than two file names are given, then each argument is compared
to the last argument as above.
@@ -140,9 +140,9 @@ differences.
.SH SOURCE
.B \*9/src/cmd/diff
.SH "SEE ALSO"
-.IR cmp (1),
-.IR comm (1),
-.IR ed (1)
+.MR cmp (1) ,
+.MR comm (1) ,
+.MR ed (1)
.SH DIAGNOSTICS
Exit status is the empty string
for no differences,
diff --git a/man/man1/doctype.1 b/man/man1/doctype.1
index da33653aa..199323f0e 100644
--- a/man/man1/doctype.1
+++ b/man/man1/doctype.1
@@ -17,16 +17,16 @@ doctype \- intuit command line for formatting a document
.SH DESCRIPTION
.I Doctype
examines a
-.IR troff (1)
+.MR troff (1)
input file to deduce the appropriate text formatting command
and prints it on standard output.
.I Doctype
recognizes input for
-.IR troff (1),
+.MR troff (1) ,
related preprocessors like
-.IR eqn (1),
+.MR eqn (1) ,
and the
-.IR ms (7)
+.MR ms (7)
and
.I mm
macro packages.
@@ -56,8 +56,8 @@ Typeset files named
.IR eqn (1),
.IR tbl (1),
.IR pic (1),
-.IR grap (1),
-.IR ms (7),
-.IR man (7)
+.MR grap (1) ,
+.MR ms (7) ,
+.MR man (7)
.SH BUGS
In true A.I. style, its best guesses are inspired rather than accurate.
diff --git a/man/man1/ed.1 b/man/man1/ed.1
index 00eb095a3..8dd6f5355 100644
--- a/man/man1/ed.1
+++ b/man/man1/ed.1
@@ -35,7 +35,7 @@ of character counts by
.LR r ,
and
.L w
-commands and of the confirming
+commands and of the confirming
.L !
by
.L !
@@ -46,7 +46,7 @@ commands.
Write all output to the standard error file except writing by
.L w
commands.
-If no
+If no
.I file
is given, make
.B /dev/stdout
@@ -62,7 +62,7 @@ in the buffer have no effect on the file until a
(write)
command is given.
The copy of the text being edited resides
-in a temporary file called the
+in a temporary file called the
.IR buffer .
.PP
Commands to
@@ -78,7 +78,7 @@ These addresses specify one or more lines in the buffer.
Missing addresses are supplied by default.
.PP
In general, only one command may appear on a line.
-Certain commands allow the
+Certain commands allow the
addition of text to the buffer.
While
.I ed
@@ -87,16 +87,16 @@ to be in
.I "input mode."
In this mode, no commands are recognized;
all input is merely collected.
-Input mode is left by typing a period
+Input mode is left by typing a period
.L .
alone at the
beginning of a line.
.PP
.I Ed
-supports the
+supports the
.I "regular expression"
notation described in
-.IR regexp (7).
+.MR regexp (7) .
Regular expressions are used in addresses to specify
lines and in one command
(see
@@ -108,7 +108,7 @@ the regular expression metacharacters as an ordinary
character, that character may be preceded by
.RB ` \e '.
This also applies to the character bounding the regular
-expression (often
+expression (often
.LR / )
and to
.L \e
@@ -132,7 +132,7 @@ customarily called `dot',
addresses the current line.
.TP
2.
-The character
+The character
.L $
addresses the last line of the buffer.
.TP
@@ -163,7 +163,7 @@ If necessary the search wraps around to the beginning of the
buffer.
.TP
6.
-A regular expression enclosed in queries
+A regular expression enclosed in queries
.L ?
addresses
the line found by searching backward from the current line
@@ -173,7 +173,7 @@ If necessary
the search wraps around to the end of the buffer.
.TP
7.
-An address followed by a plus sign
+An address followed by a plus sign
.L +
or a minus sign
.L -
@@ -182,7 +182,7 @@ followed by a decimal number specifies that address plus
The plus sign may be omitted.
.TP
8.
-An address followed by
+An address followed by
.L +
(or
.LR - )
@@ -190,20 +190,20 @@ followed by a
regular expression enclosed in slashes specifies the first
matching line following (or preceding) that address.
The search wraps around if necessary.
-The
+The
.L +
may be omitted, so
.L 0/x/
addresses the
.I first
-line in the buffer with an
+line in the buffer with an
.LR x .
-Enclosing the regular expression in
+Enclosing the regular expression in
.L ?
reverses the search direction.
.TP
9.
-If an address begins with
+If an address begins with
.L +
or
.L -
@@ -214,7 +214,7 @@ is understood to mean
.LR .-5 .
.TP
10.
-If an address ends with
+If an address ends with
.L +
or
.LR - ,
@@ -236,9 +236,9 @@ line less 2.
.TP
11.
To maintain compatibility with earlier versions of the editor,
-the character
+the character
.L ^
-in addresses is
+in addresses is
equivalent to
.LR - .
.PP
@@ -254,7 +254,7 @@ Addresses are separated from each other typically by a comma
.LR , .
They may also be separated by a semicolon
.LR ; .
-In this case the current line
+In this case the current line
is set to
the previous address before the next address is interpreted.
If no address precedes a comma or semicolon, line 1 is assumed;
@@ -285,7 +285,7 @@ and append it after the addressed line.
Dot is left
on the last line input, if there
were any, otherwise at the addressed line.
-Address
+Address
.L 0
is legal for this command; text is placed
at the beginning of the buffer.
@@ -293,7 +293,7 @@ at the beginning of the buffer.
.RB (\|\fL.,.\fP\|) \|b [ +- ][\fIpagesize\fP][ pln\fR]
Browse.
Print a `page', normally 20 lines.
-The optional
+The optional
.L +
(default) or
.L -
@@ -305,11 +305,11 @@ is the number of lines in a page.
The optional
.LR p ,
.LR n ,
-or
+or
.L l
causes printing in the specified format, initially
.LR p .
-Pagesize and format are remembered between
+Pagesize and format are remembered between
.L b
commands.
Dot is left at the last line displayed.
@@ -397,7 +397,7 @@ and
.L v
are not permitted in the command list.
Any character other than space or newline may
-be used instead of
+be used instead of
.L /
to delimit the regular expression.
The second and third forms mean
@@ -441,10 +441,18 @@ a backspace as
.LR \eb ,
backslashes as
.LR \e\e ,
-and non-printing characters as
+and non-printing ASCII characters as
a backslash, an
.LR x ,
-and four hexadecimal digits.
+and two hexadecimal digits.
+non-ASCII characters in the Basic Multilingual Plane
+are printed as a backslash, a small
+.LR u ,
+and four hexadecimal digits; and characters above the
+Basic Multilingual Plane are printed as a backslash,
+a big
+.LR U ,
+and eight hexadecimal digits.
Long lines are folded,
with the second and subsequent sub-lines indented one tab stop.
If the last character in the line is a blank,
@@ -534,13 +542,13 @@ defaults to 1 if missing),
the
.IR n th
matched string is replaced by the replacement specified.
-If the global replacement indicator
+If the global replacement indicator
.L g
appears after the command,
all subsequent matches on the line are also replaced.
It is an error for the substitution to fail on all addressed lines.
Any character other than space or newline
-may be used instead of
+may be used instead of
.L /
to delimit the regular expression
and the replacement.
@@ -552,7 +560,7 @@ The second
may be omitted if the replacement is
empty.
.IP
-An ampersand
+An ampersand
.L &
appearing in the replacement
is replaced by the string matching the regular expression.
@@ -576,7 +584,7 @@ is determined by counting occurrences of
.L (
starting from the left.
.IP
-A literal
+A literal
.LR & ,
.LR / ,
.L \e
@@ -586,7 +594,7 @@ by prefixing it with
.TP
.RB (\|\fL.,.\fP\|) \|t\|\fIa
Transfer.
-Copy the addressed lines
+Copy the addressed lines
after the line addressed by
.IR a .
Dot is left at the last line of the copy.
@@ -614,7 +622,7 @@ it is created with mode 666 (readable and writable by everyone).
If no
.I filename
is given, the remembered file name, if any, is used.
-The file name is remembered if there were no
+The file name is remembered if there were no
remembered file name already.
Dot is unchanged.
If the write is successful, the number of characters written is
@@ -630,16 +638,16 @@ Print the line number of the addressed line.
Dot is unchanged.
.TP
.BI ! shell\ command
-Send the remainder of the line after the
+Send the remainder of the line after the
.L !
to
-.IR rc (1)
+.MR rc (1)
to be interpreted as a command.
Dot is unchanged.
.TP
.RB (\| .+1 )\|
An address without a command is taken as a
-.L p
+.L p
command.
A terminal
.L /
@@ -649,11 +657,11 @@ A blank line alone is equivalent to
it is useful
for stepping through text.
.PP
-If an interrupt signal
+If an interrupt signal
.SM (DEL)
is sent,
.I ed
-prints a
+prints a
.L ?
and returns to its command level.
.PP
@@ -671,9 +679,9 @@ and all characters after the last newline.
.SH SOURCE
.B \*9/src/cmd/ed.c
.SH "SEE ALSO"
-.IR sam (1),
-.IR sed (1),
-.IR regexp (7)
+.MR sam (1) ,
+.MR sed (1) ,
+.MR regexp (7)
.SH DIAGNOSTICS
.BI ? name
for inaccessible file;
diff --git a/man/man1/eqn.1 b/man/man1/eqn.1
index bf4bac68f..e50a500d4 100644
--- a/man/man1/eqn.1
+++ b/man/man1/eqn.1
@@ -15,7 +15,7 @@ eqn \- typeset mathematics
.SH DESCRIPTION
.I Eqn
is a
-.IR troff (1)
+.MR troff (1)
preprocessor
for typesetting mathematics
on a typesetter.
@@ -34,7 +34,7 @@ named in the
option (default
.BR -Tutf ;
see
-.IR troff (1)).
+.MR troff (1) ).
When run with other preprocessor filters,
.I eqn
usually comes last.
@@ -299,7 +299,7 @@ Mathematical words like
.LR cos ,
.L log
are made Roman automatically.
-.IR Troff (1)
+.MR Troff (1)
four-character escapes like
.L \e(lh
(\(lh) can be used anywhere.
@@ -319,7 +319,7 @@ font descriptions for PostScript
.B \*9/src/cmd/eqn
.SH "SEE ALSO"
.IR troff (1),
-.IR tbl (1)
+.MR tbl (1)
.br
J. F. Ossanna and B. W. Kernighan,
``Troff User's Manual''.
diff --git a/man/man1/freq.1 b/man/man1/freq.1
index cbbd4152e..4a55130ae 100644
--- a/man/man1/freq.1
+++ b/man/man1/freq.1
@@ -36,5 +36,5 @@ character, respectively.
.SH SOURCE
.B \*9/src/cmd/freq.c
.SH SEE ALSO
-.IR utf (7),
-.IR wc (1)
+.MR utf (7) ,
+.MR wc (1)
diff --git a/man/man1/git.1 b/man/man1/git.1
index 9b29b5121..8387407a4 100644
--- a/man/man1/git.1
+++ b/man/man1/git.1
@@ -1,5 +1,5 @@
.TH GIT 1
-.SH NAME
+.SH NAME
git, hg, cvs, codereview \- introduction to using plan9port Git repository
.SH SYNOPSIS
.B git
@@ -17,7 +17,7 @@ git, hg, cvs, codereview \- introduction to using plan9port Git repository
.I path ...
]
.PP
-.B gitk
+.B gitk
.PP
.B web
.B https://9fans.github.io/plan9port
@@ -37,13 +37,13 @@ which it will create.
After
.B git
.BR clone ,
-the other commands listed
+the other commands listed
should be run within the
.B plan9
directory tree.
.PP
Git downloads the entire revision history
-of Plan 9 from User Space
+of Plan 9 from User Space
in addition to the current tree.
.PP
.I Git
@@ -55,7 +55,7 @@ current file tree.
.I Git
.I diff
runs Unix's
-.IR diff (1)
+.MR diff (1)
to compare the files in the local tree with the corresponding
files in the revision history.
The special revision
@@ -76,7 +76,7 @@ directory containing Git local repository
list of files and wildcards to exclude from Git operations
.SH SEE ALSO
Unix's
-\fIgit\fR(1),
+.IR git (1),
.HR http://git-scm.com/doc
.PP
.HR https://9fans.github.io/plan9port/
diff --git a/man/man1/grap.1 b/man/man1/grap.1
index beda727df..d36916dc1 100644
--- a/man/man1/grap.1
+++ b/man/man1/grap.1
@@ -9,7 +9,7 @@ grap \- pic preprocessor for drawing graphs
.SH DESCRIPTION
.I Grap
is a
-.IR pic (1)
+.MR pic (1)
preprocessor for drawing graphs on a typesetter.
Graphs are surrounded by the
.I troff
@@ -407,7 +407,7 @@ definitions of standard plotting characters, e.g., bullet
.B \*9/src/cmd/grap
.SH "SEE ALSO"
.IR pic (1),
-.IR troff (1)
+.MR troff (1)
.br
J. L. Bentley and B. W. Kernighan,
``GRAP\(emA Language for Typesetting Graphs'',
diff --git a/man/man1/graph.1 b/man/man1/graph.1
index bb6d25da9..f8a1e0888 100644
--- a/man/man1/graph.1
+++ b/man/man1/graph.1
@@ -89,7 +89,7 @@ The next argument is
Next argument is one or more of the characters
.B bcgkmrwy,
choosing pen colors by their initial letter, as in
-.IR plot (7).
+.MR plot (7) .
Successive curves will cycle through the colors in the given order.
.TP
.B -s
@@ -145,7 +145,7 @@ is reversed.
.B \*9/src/cmd/graph
.SH "SEE ALSO"
.IR plot (1),
-.IR grap (1)
+.MR grap (1)
.SH BUGS
Segments that run out of bounds are dropped, not windowed.
Logarithmic axes may not be reversed.
diff --git a/man/man1/grep.1 b/man/man1/grep.1
index 238906218..5fe3a9f72 100644
--- a/man/man1/grep.1
+++ b/man/man1/grep.1
@@ -27,7 +27,7 @@ searches the input
for lines that match the
.IR pattern ,
a regular expression as defined in
-.IR regexp (7)
+.MR regexp (7)
with the addition of a newline character as an alternative
(substitute for
.BR | )
@@ -114,11 +114,11 @@ If no files are listed, it searches all files matching
.br
.B \*9/bin/g
.SH SEE ALSO
-.IR ed (1),
-.IR awk (1),
-.IR sed (1),
-.IR sam (1),
-.IR regexp (7)
+.MR ed (1) ,
+.MR awk (1) ,
+.MR sed (1) ,
+.MR sam (1) ,
+.MR regexp (7)
.SH DIAGNOSTICS
Exit status is null if any lines are selected,
or non-null when no lines are selected or an error occurs.
diff --git a/man/man1/gview.1 b/man/man1/gview.1
index 6b0be4c7a..8961b625a 100644
--- a/man/man1/gview.1
+++ b/man/man1/gview.1
@@ -144,7 +144,7 @@ awk 'BEGIN{for(x=.1;x<500;x+=.1)print x,sin(x)/x}' | gview
.SH SOURCE
.B \*9/src/cmd/draw/gview.c
.SH SEE ALSO
-.IR awk (1)
+.MR awk (1)
.SH BUGS
The user interface for the
.I slant
diff --git a/man/man1/gzip.1 b/man/man1/gzip.1
index 683ba3a55..2f78c89f6 100644
--- a/man/man1/gzip.1
+++ b/man/man1/gzip.1
@@ -150,8 +150,8 @@ Produce debugging output.
.br
.B \*9/src/cmd/bzip2
.SH SEE ALSO
-.IR tar (1),
-.IR compress (1)
+.MR tar (1) ,
+.MR compress (1)
.SH BUGS
.I Unzip
can only extract files which are uncompressed or compressed
diff --git a/man/man1/hist.1 b/man/man1/hist.1
index 82175e7e1..bec129a8e 100644
--- a/man/man1/hist.1
+++ b/man/man1/hist.1
@@ -41,7 +41,7 @@ option enables verbose debugging printout.
The
.B -d
option causes
-.IR diff (1)
+.MR diff (1)
.B -c
to be run for each adjacent pair of dump files, while
.B -b
@@ -73,11 +73,11 @@ by convention, root of dump file system
.SH SOURCE
.B \*9/src/cmd/hist.c
.SH SEE ALSO
-.IR yesterday (1),
-.IR vbackup (8)
+.MR yesterday (1) ,
+.MR vbackup (8)
.SH BUGS
Should be called
.IR history ,
but
that name is taken by
-.IR sh (1).
+.MR sh (1) .
diff --git a/man/man1/hoc.1 b/man/man1/hoc.1
index f73ec8a8b..24075b0b0 100644
--- a/man/man1/hoc.1
+++ b/man/man1/hoc.1
@@ -133,8 +133,8 @@ for(i=1; i<12; i++) print gcd(i,12)
.SH SOURCE
.B \*9/src/cmd/hoc
.SH "SEE ALSO"
-.IR bc (1),
-.IR dc (1)
+.MR bc (1) ,
+.MR dc (1)
.br
B. W. Kernighan and R. Pike,
.I
diff --git a/man/man1/htmlroff.1 b/man/man1/htmlroff.1
index 4dff65c84..197c2f04e 100644
--- a/man/man1/htmlroff.1
+++ b/man/man1/htmlroff.1
@@ -21,7 +21,7 @@ htmlroff \- HTML formatting and typesetting
.SH DESCRIPTION
.I Htmlroff
accepts
-.IR troff (1)
+.MR troff (1)
input in the named
.I files
and formats it as HTML for viewing in a web browser.
@@ -63,7 +63,7 @@ HTML entity sequences
and so on).
.I Htmlroff
invokes
-.IR tcs (1)
+.MR tcs (1)
for the conversion.
.TP
.B -v
@@ -73,7 +73,7 @@ Generate debugging output and warnings about suspicious input.
Most
.I troff
input files, especially those using the
-.IR ms (7)
+.MR ms (7)
macros, can be used unaltered.
In general, the macro file
.B tmac.html
@@ -83,10 +83,10 @@ as in
.B -ms
.BR -mhtml .
.PP
-.IR Htmlroff (7)
+.MR Htmlroff (7)
describes the changes to the input language.
.PP
-.IR Mhtml (7)
+.MR Mhtml (7)
describes the new macros.
.SH EXAMPLES
Format the Plan 9 web page:
@@ -113,7 +113,7 @@ to Unicode characters like α.
.SH SOURCE
.B \*9/src/cmd/htmlroff
.SH "SEE ALSO
-.IR tcs (1),
-.IR troff (1),
-.IR htmlroff (7),
-.IR mhtml (7)
+.MR tcs (1) ,
+.MR troff (1) ,
+.MR htmlroff (7) ,
+.MR mhtml (7)
diff --git a/man/man1/idiff.1 b/man/man1/idiff.1
index e8d37615d..49a2df6b7 100644
--- a/man/man1/idiff.1
+++ b/man/man1/idiff.1
@@ -50,7 +50,7 @@ and prompt again.
.PP
.I Idiff
invokes
-.IR diff (1)
+.MR diff (1)
to compare the files.
The
.B -b
@@ -66,7 +66,7 @@ passed to
.SH SOURCE
.B \*9/src/cmd/idiff.c
.SH "SEE ALSO
-.IR diff (1)
+.MR diff (1)
.br
Kernighan and Pike,
.IR "The Unix Programming Environment" ,
diff --git a/man/man1/install.1 b/man/man1/install.1
index be35bd354..66f780c72 100644
--- a/man/man1/install.1
+++ b/man/man1/install.1
@@ -15,7 +15,7 @@ cd \*9; ./INSTALL
.SH DESCRIPTION
To obtain the Plan 9 tree, use Git
(see
-.IR git (1))
+.MR git (1) )
or download a tar file from
.HR https://9fans.github.io/plan9port "" .
.PP
@@ -25,14 +25,14 @@ usual place is
In the root of the tree, run
.BR ./INSTALL .
This script builds the Plan 9 build program
-.IR mk (1)
+.MR mk (1)
if necessary,
cleans all previously built object files and libraries out of the tree,
rebuilds and installs everything, and then cleans up.
.PP
There are a few files in tree which have the root
hard-coded in them.
-After the build,
+After the build,
.I INSTALL
edits these files to replace the string
.B /usr/local/plan9
@@ -71,47 +71,45 @@ expectations of certain package management systems.
.PP
At the end of the installation,
.I INSTALL
-prints suggested settings for the environment variables
+prints suggested settings for the environment variables
.B $PLAN9
and
.BR $PATH .
.PP
-Plan 9 from User Space uses different threading implementations on Linux 2.6 and
-later kernels than on 2.4 and earlier;
-and on FreeBSD 5 and later kernels than on FreeBSD 4 and earlier.
-Running binaries from one class on another will not work.
-.PP
-Some Linux 2.6 systems (e.g., Gentoo) do not use the new NPTL pthread library
-even though the kernel supports them. On these systems, plan9port must
-fall back on the threading code intended for Linux 2.4. To accomplish this,
.I INSTALL
-checks whether the running system uses NPTL and sets
-.B SYSVERSION
-in
-.B \*9/config
-accordingly.
+writes various autodetected settings to
+.BR \*9/config .
The file
.B \*9/LOCAL.config
is appended to
.B config
after this auto-detection and can be used to override the choices.
-If
+If
.B LOCAL.config
contains a line
.B WSYSTYPE=nowsys
then the system is built without using X11.
+.B LOCAL.config
+may also list settings for
+.B CC9
+(the host C compiler)
+and
+.B CC9FLAGS
+(any additional flags to pass to the compiler).
+Values more complex than single words should be quoted
+with single quotes.
.PP
On most Linux systems, the X11 header packages need to be installed
to build using X11. On Debian. the required packages are
-libx11-dev, libxext-dev, and libxt-dev.
+libfontconfig1-dev, libx11-dev, libxext-dev, and libxt-dev.
On Ubuntu, it suffices to install xorg-dev.
.PP
.I INSTALL
can safely be repeated to rebuild the system from scratch.
.PP
Once the system is built for the first time,
-it can be maintained and rebuilt using
-.IR mk (1).
+it can be maintained and rebuilt using
+.MR mk (1) .
To rebuild individual commands or libraries,
run
.B mk
@@ -121,7 +119,7 @@ and
.B clean
in the appropriate source directory
(see
-.IR src (1)).
+.MR src (1) ).
.SH FILES
.TP
.B \*9/lib/moveplan9.files
@@ -134,7 +132,7 @@ the script that edits the files
.TP
.B \*9/src/mkmk.sh
the shell script used to build
-.IR mk (1)
+.MR mk (1)
.TP
.B \*9/dist/manweb
the shell script that builds the HTML manual
@@ -150,5 +148,5 @@ logged output from the last run of
a summary of
.B install.log
.SH SEE ALSO
-.IR intro (1),
-.IR git (1)
+.MR intro (1) ,
+.MR git (1)
diff --git a/man/man1/join.1 b/man/man1/join.1
index 1c0ec9f9c..f9c9d543c 100644
--- a/man/man1/join.1
+++ b/man/man1/join.1
@@ -114,7 +114,7 @@ birthdays empty.
The layout of
.B /adm/users
is given in
-.IR passwd (5);
+.MR passwd (5) ;
.B bdays
contains sorted lines like
.LR "ken:Feb\ 4,\ 1953" .
@@ -132,7 +132,7 @@ Print all pairs of users with identical userids.
.SH "SEE ALSO"
.IR sort (1),
.IR comm (1),
-.IR awk (1)
+.MR awk (1)
.SH BUGS
With default field separation,
the collating sequence is that of
diff --git a/man/man1/jpg.1 b/man/man1/jpg.1
index a59033b6b..037672213 100644
--- a/man/man1/jpg.1
+++ b/man/man1/jpg.1
@@ -122,7 +122,7 @@ Typing a
.BR q ,
DEL, or control-D exits the program.
For a more user-friendly interface, use
-.IR page (1),
+.MR page (1) ,
which invokes these programs to convert the images to standard format,
displays them, and offers scrolling, panning, and menu-driven navigation among the files.
.PP
@@ -147,7 +147,7 @@ any of the following options:
.TP
.B -c
Convert the image to a Plan 9 representation, as defined by
-.IR image (7),
+.MR image (7) ,
and write it to standard output.
.TP
.B -9
@@ -156,7 +156,7 @@ Like
but produce an uncompressed image.
This saves processing time, particularly when the output is
being piped to another program such as
-.IR page (1),
+.MR page (1) ,
since it avoids compression and decompression.
.TP
.B -t
@@ -235,8 +235,8 @@ space in the image. The icon file is written to standard output.
.SH SOURCE
.B \*9/src/cmd/jpg
.SH "SEE ALSO"
-.IR page (1),
-.IR image (7).
+.MR page (1) ,
+.MR image (7) .
.SH BUGS
Writing an animated GIF using
.I togif
diff --git a/man/man1/kill.1 b/man/man1/kill.1
index 5b61d8a10..f82b48776 100644
--- a/man/man1/kill.1
+++ b/man/man1/kill.1
@@ -19,18 +19,18 @@ prints commands that will cause all processes with
.I name
and owned by the current user to be terminated.
Each command is commented with an output line from
-.IR ps (1)
+.MR ps (1)
describing the process that would be killed.
Use the
.B send
command of
-.IR 9term (1),
+.MR 9term (1) ,
or pipe the output of
.I kill
into
-.IR rc (1)
+.MR rc (1)
or
-.IR sh (1)
+.MR sh (1)
to execute the commands.
.PP
.I Kill
@@ -60,8 +60,8 @@ signal.
.SH SOURCE
.B \*9/bin
.SH "SEE ALSO"
-.IR ps (1),
-.IR notify (3)
+.MR ps (1) ,
+.MR notify (3)
.SH BUGS
.I Stop
and
diff --git a/man/man1/label.1 b/man/man1/label.1
index 1748b0be9..6688972d5 100644
--- a/man/man1/label.1
+++ b/man/man1/label.1
@@ -14,12 +14,12 @@ label, awd \- set window label
sets the label of the current
.I win
(see
-.IR acme (1))
+.MR acme (1) )
or X terminal window
.RI ( e.g.,
-.IR 9term (1)
+.MR 9term (1)
or
-.IR xterm (1))
+.MR xterm (1) )
by echoing a special control sequence to standard output.
.PP
.I Acme
@@ -38,7 +38,7 @@ sets the window name to the current directory with a
suffix, using the name of the current system by default.
.SH EXAMPLE
One can use the following
-.IR sh (1)
+.MR sh (1)
function to keep the label up-to-date in response to
.I cd
commands:
@@ -55,7 +55,7 @@ alias cd=_cd
cd .
.EE
.PP
-.IR Rc (1)
+.MR Rc (1)
installs a similar
.B fn
.B cd
@@ -77,4 +77,4 @@ fn cd {
.SH BUGS
.I Awd
is also documented in
-.IR acme (1).
+.MR acme (1) .
diff --git a/man/man1/lex.1 b/man/man1/lex.1
index 6955e7914..a740c2e87 100644
--- a/man/man1/lex.1
+++ b/man/man1/lex.1
@@ -65,7 +65,7 @@ output
template
.SH "SEE ALSO"
.IR yacc (1),
-.IR sed (1)
+.MR sed (1)
.br
M. E. Lesk and E. Schmidt,
`LEX\(emLexical Analyzer Generator',
diff --git a/man/man1/look.1 b/man/man1/look.1
index 02d2cb4b3..731d616e7 100644
--- a/man/man1/look.1
+++ b/man/man1/look.1
@@ -74,7 +74,7 @@ is assumed, with collating sequence
.B \*9/src/cmd/look.c
.SH "SEE ALSO"
.IR sort (1),
-.IR grep (1)
+.MR grep (1)
.SH DIAGNOSTICS
The exit status is
.RB `` "not found" ''
diff --git a/man/man1/ls.1 b/man/man1/ls.1
index edaf11cfb..863f8e222 100644
--- a/man/man1/ls.1
+++ b/man/man1/ls.1
@@ -29,7 +29,7 @@ is the same as
but sets the
.B -p
option and pipes the output through
-.IR mc (1).
+.MR mc (1) .
.PP
There are a number of options:
.TP
@@ -42,7 +42,7 @@ List in long format, giving mode (see below), file system type
(e.g., for devices, the
.B #
code letter that names it; see
-.IR intro (3)),
+.MR intro (3) ),
the instance or subdevice number, owner, group,
size in bytes, and time of last modification
for each file.
@@ -60,7 +60,7 @@ Print only the final path element of each file name.
List the
.I qid
(see
-.IR stat (3))
+.MR stat (3) )
of each file; the printed fields are in the order
path, version, and type.
.TP
@@ -99,7 +99,7 @@ otherwise.
.TP
.B -Q
By default, printed file names are quoted if they contain characters special to
-.IR rc (1).
+.MR rc (1) .
The
.B -Q
flag disables this behavior.
@@ -168,5 +168,5 @@ if none of the above permissions is granted.
.br
.B \*9/bin/lc
.SH SEE ALSO
-.IR stat (3),
-.IR mc (1)
+.MR stat (3) ,
+.MR mc (1)
diff --git a/man/man1/man.1 b/man/man1/man.1
index ec35b7ad1..2fc8c1f5b 100644
--- a/man/man1/man.1
+++ b/man/man1/man.1
@@ -45,7 +45,7 @@ The options are:
.TP
.B -h
Print the pages to HTML and send to a web browser with
-.IR web (1).
+.MR web (1) .
.TP
.B -n
(Default)
@@ -54,17 +54,17 @@ Print the pages on the standard output using
.TP
.B -p
Run
-.IR proof (1)
+.MR proof (1)
on the specified man pages.
.TP
.B -P
Run
-.IR page (1)
+.MR page (1)
on the specified man pages.
.TP
.B -t
Run
-.IR troff (1)
+.MR troff (1)
and send its output
to standard output.
.TP
@@ -106,8 +106,8 @@ index for
.br
.B \*9/bin/lookman
.SH "SEE ALSO"
-.IR page (1),
-.IR proof (1)
+.MR page (1) ,
+.MR proof (1)
.SH BUGS
The manual was intended to be typeset; some detail is sacrificed on text terminals.
.PP
diff --git a/man/man1/map.1 b/man/man1/map.1
index c03200215..d526aa484 100644
--- a/man/man1/map.1
+++ b/man/man1/map.1
@@ -305,7 +305,7 @@ tracks appear as dot-dashed lines if the plotting filter supports them.)
The
.I file
contains
-.IR plot (7)-style
+.MR plot (7) -style
data for
.L :
or
@@ -640,7 +640,7 @@ Map driver program
.B \*9/src/cmd/map
.SH "SEE ALSO"
.IR map (7),
-.IR plot (1)
+.MR plot (1)
.SH DIAGNOSTICS
`Map seems to be empty'\(ema coarse survey found
zero extent within the
diff --git a/man/man1/mc.1 b/man/man1/mc.1
index e914cbabf..627202be7 100644
--- a/man/man1/mc.1
+++ b/man/man1/mc.1
@@ -18,10 +18,10 @@ splits the input into as many columns as will fit in
.I N
print positions.
If run in a
-.IR 9term (1),
-.IR xterm (1),
+.MR 9term (1) ,
+.MR xterm (1) ,
or
-.IR acme (1)
+.MR acme (1)
window, the default
.I N
is the number of blanks that will fit across the window;
@@ -36,14 +36,14 @@ is printed separately.
.SH SOURCE
.B \*9/src/cmd/draw/mc.c
.SH "SEE ALSO"
-.IR 9term (1),
-.IR acme (1),
-.IR acme (4),
-.IR xterm (1),
-.IR pr (1),
+.MR 9term (1) ,
+.MR acme (1) ,
+.MR acme (4) ,
+.MR xterm (1) ,
+.MR pr (1) ,
.I lc
in
-.IR ls (1)
+.MR ls (1)
.SH BUGS
On systems with high-DPI screens,
.I 9term
diff --git a/man/man1/mk.1 b/man/man1/mk.1
index 0698ef5b7..4c3d2b701 100644
--- a/man/man1/mk.1
+++ b/man/man1/mk.1
@@ -29,7 +29,7 @@ contains a
.I rule
for each target that identifies the files and other
targets upon which it depends and an
-.IR sh (1)
+.MR sh (1)
script, a
.IR recipe ,
to update the target.
@@ -157,7 +157,7 @@ In the recipe of a meta-rule, the environment variable
contains the string matched by the
.BR % .
For example, a meta-rule to compile a C program using
-.IR 9c (1)
+.MR 9c (1)
might be:
.IP
.EX
@@ -207,7 +207,7 @@ References to variables are replaced by the variables' values.
Special characters may be quoted using single quotes
.BR \&''
as in
-.IR sh (1).
+.MR sh (1) .
.PP
Assignments and rules are distinguished by
the first unquoted occurrence of
@@ -246,7 +246,7 @@ A legal reference of the form
or
.B ${name}
is expanded as in
-.IR sh (1).
+.MR sh (1) .
A reference of the form
.BI ${name: A % B = C\fL%\fID\fL}\fR,
where
@@ -315,9 +315,9 @@ or
.BR rcsh ,
.I mk
uses
-.IR rc (1)'s
+.MR rc (1) 's
quoting rules; otherwise it uses
-.IR sh (1)'s.
+.MR sh (1) 's.
The
.B MKSHELL
variable is consulted when the mkfile is read, not when it is executed,
@@ -523,7 +523,7 @@ of the aggregate
Currently, the only aggregates supported are
.I 9ar
(see
-.IR 9c (1))
+.MR 9c (1) )
archives.
.SS Attributes
The colon separating the target from the prerequisites
@@ -567,12 +567,12 @@ In the rule,
.B %
has no special meaning.
The target is interpreted as a regular expression as defined in
-.IR regexp (7).
+.MR regexp (7) .
The prerequisites may contain references
to subexpressions in form
.BI \e n\f1,
as in the substitute command of
-.IR sed (1).
+.MR sed (1) .
.TP
.B U
The targets are considered to have been updated
@@ -625,7 +625,7 @@ Regular expression meta-rules:
.EE
.PP
A correct way to deal with
-.IR yacc (1)
+.MR yacc (1)
grammars.
The file
.B lex.c
@@ -656,8 +656,8 @@ x.tab.h:Pcmp -s: y.tab.h
.SH SOURCE
.B \*9/src/cmd/mk
.SH SEE ALSO
-.IR sh (1),
-.IR regexp (7)
+.MR sh (1) ,
+.MR regexp (7)
.PP
A. Hume,
``Mk: a Successor to Make''
diff --git a/man/man1/mk9660.1 b/man/man1/mk9660.1
index 0d655cf01..4f78bd273 100644
--- a/man/man1/mk9660.1
+++ b/man/man1/mk9660.1
@@ -71,11 +71,11 @@ the current directory).
The
.I proto
file is formatted as described in
-.IR proto (3).
+.MR proto (3) .
.PP
The created CD image will be in ISO-9660
format, but by default the file names will
-be stored in UTF-8 with no imposed length
+be stored in UTF-8 with no imposed length
or character restrictions.
The
.B -c
@@ -84,7 +84,7 @@ flag causes
to use only file names in ``8.3'' form
that use digits, letters, and underscore.
File names that do not conform are changed
-to
+to
.BI D nnnnnn
(for directories)
or
@@ -122,7 +122,7 @@ and
.B \e
are allowed in Plan 9 file names but not in Joliet file names;
non-conforming file names are translated
-and a
+and a
.B _CONFORM.MAP
file written
as in the case of the
@@ -133,7 +133,7 @@ If the
.B -r
flag is given, Rock Ridge extensions are written in the
format of the system use sharing protocol;
-this format provides Posix-style file metadata and is
+this format provides Posix-style file metadata and is
common on Unix platforms.
.PP
The options
@@ -155,13 +155,13 @@ if unspecified, the base name of
.I proto
is used.
.PP
-The
+The
.B -:
-flag causes
+flag causes
.B mk9660
to replace colons in scanned file names with spaces;
this is the inverse of the map applied by Plan 9's
-\fIdossrv\fR(4)
+.IR dossrv (4)
and is useful for writing Joliet CDs containing data
from FAT file systems.
.PP
@@ -189,10 +189,11 @@ on standard error.
is similar in specification to
.I mk9660
but creates and updates backup CD images in the style of
-the
+the
.I dump
file system
-(see Plan 9's \fIfs\fR(4)).
+(see Plan 9's
+.IR fs (4)).
The dump is file-based rather than block-based:
if a file's contents have not changed since the last
backup, only its directory entry will be rewritten.
@@ -202,7 +203,7 @@ The
option specifies a time (in seconds since January 1, 1970)
to be used for naming the dump directory.
.PP
-The
+The
.B -m
option specifies a maximum size for the image;
if a backup would cause the image to grow larger than
@@ -212,7 +213,7 @@ it will not be written, and
will exit with a non-empty status.
.SH EXAMPLE
.PP
-Create an image of the Plan 9 source tree,
+Create an image of the Plan 9 source tree,
including a conformant ISO-9660 directory tree,
Plan 9 extensions in the system use fields, and
a Joliet directory tree.
@@ -223,7 +224,7 @@ mk9660 -9cj -s /n/bootes -p srcproto cdimage
.SH SOURCE
\*9/src/cmd/9660
.SH "SEE ALSO
-.IR proto (3)
+.MR proto (3)
.\" .SH "SEE ALSO"
.\" .I 9660srv
.\" (in
diff --git a/man/man1/mkdir.1 b/man/man1/mkdir.1
index e658847cf..b91ba22ed 100644
--- a/man/man1/mkdir.1
+++ b/man/man1/mkdir.1
@@ -28,11 +28,11 @@ The
flag sets the permissions to be used when creating the directory.
The default is 0777.
.SH "SEE ALSO"
-.IR rm (1)
+.MR rm (1)
.br
.IR cd
in
-.IR rc (1)
+.MR rc (1)
.SH SOURCE
.B \*9/src/cmd/mkdir.c
.SH DIAGNOSTICS
diff --git a/man/man1/mount.1 b/man/man1/mount.1
index ec9f016e4..123a395ae 100644
--- a/man/man1/mount.1
+++ b/man/man1/mount.1
@@ -15,7 +15,7 @@ mounts a 9P server's files into the file system.
is typically
either the name of a Unix domain socket
(see
-.IR namespace (1))
+.MR namespace (1) )
or the name or IP address of a machine
serving 9P over TCP port 564.
.PP
@@ -29,7 +29,7 @@ On Linux,
.I mount
uses the native 9P kernel module when present.
Otherwise it tries to use
-.IR 9pfuse (4)
+.MR 9pfuse (4)
with the FUSE file system module.
Using the 9P kernel module requires root access.
FUSE can often be used by regular users.
@@ -45,7 +45,7 @@ should be invoked as
.BR mount .
.SH EXAMPLES
Mount
-.IR acme (4)
+.MR acme (4)
onto
.B /mnt/acme :
.IP
@@ -64,6 +64,6 @@ cat /mnt/plumb/rules
.br
.B \*9/bin/unmount
.SH SEE ALSO
-.IR intro (4),
+.MR intro (4) ,
.IR intro (9p),
-.IR 9pfuse (4)
+.MR 9pfuse (4)
diff --git a/man/man1/namespace.1 b/man/man1/namespace.1
index e02a65097..7015ca257 100644
--- a/man/man1/namespace.1
+++ b/man/man1/namespace.1
@@ -7,9 +7,9 @@ namespace \- print name space directory
.I Namespace
prints the directory representing the current name space.
See
-.IR intro (4).
+.MR intro (4) .
.SH SOURCE
.B \*9/src/cmd/namespace.c
.SH SEE ALSO
-.IR getns (3),
-.IR intro (4)
+.MR getns (3) ,
+.MR intro (4)
diff --git a/man/man1/ndb.1 b/man/man1/ndb.1
index b37509c0b..4ce7616b3 100644
--- a/man/man1/ndb.1
+++ b/man/man1/ndb.1
@@ -24,9 +24,9 @@ ndbquery, ndbmkhash, ndbmkdb, ndbipquery, ndbmkhosts \- network database
The network database holds administrative information used by
.I authdial
(see
-.IR authsrv (3))
+.MR authsrv (3) )
and
-.IR secstored (1).
+.MR secstored (1) .
.PP
.I Ndbquery
searches the database for an attribute of type
@@ -46,7 +46,7 @@ of all the matched entries is returned.
uses
.I ndbipinfo
(see
-.IR ndb (3))
+.MR ndb (3) )
to search for the values of the attributes
.I rattr
corresponding to the system
@@ -382,7 +382,7 @@ and by the ndb library routines.
.PP
.I Ndbmkdb
is used in concert with
-.IR awk (1)
+.MR awk (1)
scripts to convert
uucp systems files and IP host files
into database files.
@@ -395,7 +395,7 @@ it is necessary to run
.I ndbmkhash
whenever the files are modified.
It may be profitable to control this by a frequent
-.IR cron (8)
+.MR cron (8)
job.
.PP
.I Ndbmkhosts
@@ -439,5 +439,5 @@ hash files for
.SH SOURCE
.B \*9/src/cmd/ndb
.SH SEE ALSO
-.IR ndb (3),
-.IR ndb (7)
+.MR ndb (3) ,
+.MR ndb (7)
diff --git a/man/man1/netfiles.1 b/man/man1/netfiles.1
index 69f519b11..97f72c6ff 100644
--- a/man/man1/netfiles.1
+++ b/man/man1/netfiles.1
@@ -21,7 +21,7 @@ Netfiles, netfileget, netfileput, netfilestat \- network file access inside acme
.SH DESCRIPTION
.B Netfiles
presents remote file systems in
-.IR acme (4)
+.MR acme (4)
windows.
Each window is named
.BI /n/ system / path
@@ -35,7 +35,7 @@ reads names of windows to create from the
plumbing channel
.B netfileedit
(see
-.IR plumber (4)
+.MR plumber (4)
and the example section below).
In a
.IR netfiles -controlled
@@ -60,13 +60,13 @@ The three first check to see if
.I system
is a service in the current name space
(see
-.IR intro (4)).
+.MR intro (4) ).
If so, they use
-.IR 9p (1)
+.MR 9p (1)
to access it.
Otherwise, they assume that the system is a network name
and use
-.IR ssh (1)'s
+.MR ssh (1) 's
.I sftp
to access it.
.PP
@@ -100,7 +100,7 @@ or
.SH EXAMPLES
The following plumbing rule
(see
-.IR plumb (7))
+.MR plumb (7) )
passes
.B /n/
paths to
@@ -118,17 +118,17 @@ plumb client Netfiles
.SH SOURCE
.B \*9/src/cmd/netfiles
.SH SEE ALSO
-.IR 9p (1),
-.IR ssh (1),
-.IR ssh-agent (1),
-.IR intro (4),
-.IR acme (4),
-.IR factotum (4),
+.MR 9p (1) ,
+.MR ssh (1) ,
+.MR ssh-agent (1) ,
+.MR intro (4) ,
+.MR acme (4) ,
+.MR factotum (4) ,
.HR http://v9fs.sf.net
.SH BUGS
.I Netfiles
depends on
-.IR sftpcache (1),
+.MR sftpcache (1) ,
which only works with OpenSSH versions 4.3 and earlier;
later versions do not print the
.B sftp>
diff --git a/man/man1/page.1 b/man/man1/page.1
index 99fba2b3f..8edefe260 100644
--- a/man/man1/page.1
+++ b/man/man1/page.1
@@ -1,7 +1,7 @@
.TH PAGE 1
.SH NAME
-page \- view
-FAX,
+page \- view
+FAX,
image, graphic, PostScript, PDF, and
typesetter output
files
@@ -24,23 +24,24 @@ It can be used to display the individual pages
of a
PostScript,
PDF,
-or
-.IR troff (1)
-or
-Unix's \fItex\fR(1)
+or
+.MR troff (1)
+or
+Unix's
+.IR tex (1)
device-independent output
file.
.I Troff
-or
+or
.I tex
output is simply converted to PostScript in order to be viewed.
It can also be used to view any number of
graphics files
-(such as a
+(such as a
FAX
-page,
+page,
a Plan 9
-.IR image (7)
+.MR image (7)
file, an Inferno bitmap file, or other common format).
.I Page
displays these
@@ -53,26 +54,26 @@ By default,
.I page
runs in the window in which it is started
and leaves the window unchanged.
-The
+The
.B -R
-option causes
-.I page
+option causes
+.I page
to grow the window if necessary
to display the page being viewed.
The
.B -w
-option causes
-.I page
+option causes
+.I page
to create a new window for itself.
The newly created window will grow as under the
.B -R
option.
-If being used to display
+If being used to display
multipage documents,
only one file may be specified on the command line.
.PP
-The
-.B -p
+The
+.B -p
option sets the resolution for PostScript and PDF
files, in pixels per inch.
The default is 100 ppi.
@@ -85,13 +86,13 @@ When viewing a document,
will try to guess the true bounding box, usually rounding up from
the file's bounding box to
8½×11 or A4 size.
-The
+The
.B -b
option causes it to respect the bounding box given in the file.
As a more general problem,
some PostScript files claim to conform to Adobe's
Document Structuring Conventions but do not.
-The
+The
.B -P
option enables a slightly slower and slightly more
skeptical version of the PostScript processing code.
@@ -101,34 +102,35 @@ that can only be viewed with the
option, and there are PostScript documents that
can only be viewed without it.
.PP
-When viewing images with
+When viewing images with
.IR page ,
-it listens to the
+it listens to the
.B image
plumbing channel
-(see
-.IR plumber (4))
+(see
+.MR plumber (4) )
for more images to display.
-The
+The
.B -i
-option causes
+option causes
.I page
-to not load any graphics files nor to read
+to not load any graphics files nor to read
from standard input but rather to listen
for ones to load from the plumbing channel.
.PP
-The
+The
.B -v
option turns on extra debugging output, and
the
.B -V
option turns on even more debugging output.
-The
+The
.B -a
-option causes
+option causes
.I page
to call
-Unix's \fIabort\fR(3)
+Unix's
+.IR abort (3)
rather than exit cleanly on errors,
to facilitate debugging.
.PP
@@ -145,7 +147,7 @@ The button 2 menu operations are:
Restores the image to the original. All modifications are lost.
.TP
.B Zoom
-Prompts the user to sweep a rectangle on the image which is
+Prompts the user to sweep a rectangle on the image which is
expanded proportionally to the rectangle.
.TP
.B Fit window
@@ -164,7 +166,7 @@ Displays the next page.
Displays the previous page.
.TP
.B Zerox
-Displays the current image in a new page window.
+Displays the current image in a new page window.
Useful for selecting important pages from large documents.
.TP
.B Reverse
@@ -189,14 +191,14 @@ toggles whether images are displayed upside-down.
Typing a
.B r
reverses the order in which pages are displayed.
-Typing a
+Typing a
.B w
will write the currently viewed page to a new file as a compressed
-.IR image (7)
+.MR image (7)
file.
When possible, the filename is of the form
.IR basename . pagenum . bit .
-Typing a
+Typing a
.B d
removes an image from the working set.
.PP
@@ -208,13 +210,14 @@ changing pages when panning off the top or bottom of the page.
.PP
.I Page
calls
-Unix's \fIgs\fR(1)
+Unix's
+.IR gs (1)
to draw each page of PostScript
and
PDF
.IR files .
It also calls a variety of conversion programs, such as those described in
-.IR jpg (1),
+.MR jpg (1) ,
to convert the various raster graphics formats
into Inferno bitmap files.
Pages are converted ``on the fly,'' as needed.
@@ -232,11 +235,11 @@ Browse the Inferno bitmap library.
man -t page | page -w
Preview this manual in a new window.
.SH "SEE ALSO
-.IR gs (1),
-.IR jpg (1),
-.IR proof (1),
-.IR tex (1),
-.IR troff (1)
+.MR gs (1) ,
+.MR jpg (1) ,
+.MR proof (1) ,
+.MR tex (1) ,
+.MR troff (1)
.SH SOURCE
.B \*9/src/cmd/page
.SH DIAGNOSTICS
@@ -254,19 +257,19 @@ When viewing multipage PostScript files that do not contain
.RB `` %%Page ''
comments, the button 3 menu only contains
``this page'' and ``next page'':
-correctly determining
+correctly determining
page boundaries in Postscript code is not computable
in the general case.
.PP
If
.I page
has trouble viewing a Postscript file,
-it might not be exactly conforming: try viewing it with the
+it might not be exactly conforming: try viewing it with the
.B -P
option.
.PP
The interface to the plumber is unsatisfactory. In particular,
-document references cannot be sent
+document references cannot be sent
via plumbing messages.
.PP
There are too many keyboard commands and menu items.
@@ -274,7 +277,7 @@ There are too many keyboard commands and menu items.
Displaying a PostScript or PDF file depends both on having
GhostScript
(see
-.IR gs (1))
+.MR gs (1) )
installed and on the underlying operating system
providing a file descriptor device tree at
.BR /dev/fd .
diff --git a/man/man1/paint.1 b/man/man1/paint.1
new file mode 100644
index 000000000..838535c02
--- /dev/null
+++ b/man/man1/paint.1
@@ -0,0 +1,85 @@
+.TH PAINT 1
+.CT 1 graphics
+.SH NAME
+paint \- create image files by drawing with a mouse or other pointing device
+.SH SYNOPSIS
+.B paint
+[
+.I file
+]
+.SH DESCRIPTION
+.I Paint
+displays a canvas upon which can be drawn lines using the mouse holding
+down buttons 1 or 2 for foreground or background color. The canvas
+may be moved with button 3. Colors and brush sizes may be selected by
+clicking on the palette at the bottom of the screen with buttons 1 or 2.
+.PP
+If the optional
+.I file
+argument is specified, then it is read and used as the canvas.
+.I Paint
+only recognizes Plan 9 bitmap format (see
+.MR image (6) ).
+.PP
+A number of immediate keyboard commands are recognized:
+.TP
+.B u
+Undos the previous action.
+.TP
+.B c
+Clears the canvas with the background color.
+.TP
+.B 1-9
+Select brush size.
+.TP
+.B f
+Select flood fill brush.
+.TP
+.B +
+Doubles magnification.
+.TP
+.B -
+Halves magnification.
+.TP
+.B esc
+Centers the canvas and resets magnification.
+.PP
+Hitting any other key on the keyboard shows a command prompt
+where the following commands may be entered:
+.TP
+.BI r file
+Reads the canvas from
+.I file.
+.TP
+.BI w file
+Writes the canvas to
+.I file.
+.TP
+.BI < command
+Executes
+.I command
+and reads the canvas from its standard output.
+.TP
+.BI > command
+Executes
+.I command
+and writes the canvas to its standard input.
+.TP
+.BI | command
+Transforms the canvas by piping it thru
+.I command.
+.TP
+.B q
+Quits the program.
+.SH SOURCE
+.B /sys/src/cmd/paint.c
+.SH "SEE ALSO"
+.MR resample (1) ,
+.MR rotate (1) ,
+.MR crop (1) ,
+.MR jpg (1) ,
+.MR page (1) ,
+.MR image (6)
+.SH HISTORY
+.I Paint
+first appeared in 9front (October, 2011).
diff --git a/man/man1/passwd.1 b/man/man1/passwd.1
index f6843b399..9f32497f3 100644
--- a/man/man1/passwd.1
+++ b/man/man1/passwd.1
@@ -36,7 +36,7 @@ It is a substitute for a SecureNet box.
.br
.B \*9/src/cmd/auth/passwd.c
.SH "SEE ALSO"
-.IR encrypt (3)
+.MR encrypt (3)
.PP
Robert Morris and Ken Thompson,
``UNIX Password Security,''
diff --git a/man/man1/pem.1 b/man/man1/pem.1
index 391cd5cce..9911af95f 100644
--- a/man/man1/pem.1
+++ b/man/man1/pem.1
@@ -20,7 +20,7 @@ Privacy Enhanced Mail program but now commonly used for
other applications, notably TLS.
PEM encodes data in base 64
(see
-.IR encode (3))
+.MR encode (3) )
between lines of the form:
.IP
.EX
@@ -33,7 +33,7 @@ where
may be any string describing the encoded data.
The most common use of PEM format on Plan 9 is for encoding
X.509 certificates; see
-.IR rsa (1).
+.MR rsa (1) .
.PP
.I Pemdecode
extracts the named
@@ -62,4 +62,4 @@ hello world
.SH SOURCE
.B \*9/src/cmd/auth
.SH "SEE ALSO
-.IR rsa (1)
+.MR rsa (1)
diff --git a/man/man1/pic.1 b/man/man1/pic.1
index 0ee526fe1..d122ff3b5 100644
--- a/man/man1/pic.1
+++ b/man/man1/pic.1
@@ -31,7 +31,7 @@ pic, tpic, svgpic \- troff and tex preprocessors for drawing pictures
.SH DESCRIPTION
.I Pic
is a
-.IR troff (1)
+.MR troff (1)
preprocessor for drawing figures on a typesetter.
.I Pic
code is contained between
@@ -300,7 +300,7 @@ statement removes the definition of a macro.
.PP
.I Tpic
is a
-.IR tex (1)
+.MR tex (1)
preprocessor that accepts
.IR pic
language.
@@ -345,8 +345,8 @@ A: ellipse
.B \*9/src/cmd/pic
.SH "SEE ALSO"
.IR grap (1),
-.IR doctype (1),
-.IR troff (1)
+.MR doctype (1) ,
+.MR troff (1)
.br
B. W. Kernighan,
``PIC\(ema Graphics Language for Typesetting'',
diff --git a/man/man1/plot.1 b/man/man1/plot.1
index 3c8803f84..87d6936a8 100644
--- a/man/man1/plot.1
+++ b/man/man1/plot.1
@@ -14,7 +14,7 @@ from the
.I files
or standard input,
drawing the results in a newly created
-.IR rio (1)
+.MR rio (1)
window.
Plot persists until a newline is typed in the window.
Various options may be interspersed with the
@@ -31,7 +31,7 @@ Erase the screen.
.TP
.BI -c " col"
Set the foreground color (see
-.IR plot (7)
+.MR plot (7)
for color names).
.TP
.BI -f " fill"
@@ -57,5 +57,5 @@ middle of the screen.
.SH SOURCE
.B \*9/src/cmd/plot
.SH "SEE ALSO"
-.IR rio (1),
-.IR plot (7)
+.MR rio (1) ,
+.MR plot (7)
diff --git a/man/man1/plumb.1 b/man/man1/plumb.1
index 3fa162524..39e4d6c53 100644
--- a/man/man1/plumb.1
+++ b/man/man1/plumb.1
@@ -83,6 +83,6 @@ default rules file
.SH SOURCE
.B \*9/src/cmd/plumb
.SH "SEE ALSO"
-.IR plumb (3),
-.IR plumber (4),
-.IR plumb (7)
+.MR plumb (3) ,
+.MR plumber (4) ,
+.MR plumb (7)
diff --git a/man/man1/pr.1 b/man/man1/pr.1
index 860c026cc..624c25fb9 100644
--- a/man/man1/pr.1
+++ b/man/man1/pr.1
@@ -106,5 +106,5 @@ characters instead of the default 72.
.SH SOURCE
.B \*9/src/cmd/pr.c
.SH "SEE ALSO"
-.IR cat (1),
-.IR lp (1)
+.MR cat (1) ,
+.MR lp (1)
diff --git a/man/man1/proof.1 b/man/man1/proof.1
index 2a1de0841..63b70a6bb 100644
--- a/man/man1/proof.1
+++ b/man/man1/proof.1
@@ -22,7 +22,7 @@ proof \- troff output interpreter
.SH DESCRIPTION
.I Proof
reads
-.IR troff (1)
+.MR troff (1)
intermediate language from
.I file
or standard input
@@ -126,8 +126,8 @@ into screen fonts and character numbers
.B \*9/src/cmd/proof
.SH SEE ALSO
.IR lp (1),
-.IR gs (1),
-.IR page (1)
+.MR gs (1) ,
+.MR page (1)
.br
J. F. Ossanna and B. W. Kernighan,
``Troff User's Manual''
diff --git a/man/man1/ps.1 b/man/man1/ps.1
index bb655d181..5904564ab 100644
--- a/man/man1/ps.1
+++ b/man/man1/ps.1
@@ -102,6 +102,6 @@ to print the arguments for the process. Newlines in arguments will be translate
.br
.B \*9/bin/psu
.SH "SEE ALSO"
-.IR acid (1),
-.IR db (1),
-.IR kill (1)
+.MR acid (1) ,
+.MR db (1) ,
+.MR kill (1)
diff --git a/man/man1/psfonts.1 b/man/man1/psfonts.1
index c408f54a7..2c4b05315 100644
--- a/man/man1/psfonts.1
+++ b/man/man1/psfonts.1
@@ -16,9 +16,9 @@ psfonts, psdownload \- add necessary fonts to PostScript document for printing
]
.SH DESCRIPTION
Plan 9's
-.IR troff (1)
+.MR troff (1)
and
-.IR tr2post (1)
+.MR tr2post (1)
use non-standard PostScript fonts
(found in
.BR \*9/postscript/font ).
@@ -114,12 +114,12 @@ Continue running even after fatal errors occur.
.PD
.SH EXAMPLE
See
-.IR tr2post (1)
+.MR tr2post (1)
for an example.
.SH SOURCE
.B \*9/bin/psfonts
.br
.B \*9/src/cmd/postscript/download
.SH SEE ALSO
-.IR troff (1),
-.IR tr2post (1)
+.MR troff (1) ,
+.MR tr2post (1)
diff --git a/man/man1/pwd.1 b/man/man1/pwd.1
index 0a3e06684..e0a506fb7 100644
--- a/man/man1/pwd.1
+++ b/man/man1/pwd.1
@@ -18,8 +18,8 @@ such as constructing shell prompts.
.SH SEE ALSO
.I cd
in
-.IR rc (1),
-.IR getwd (3)
+.MR rc (1) ,
+.MR getwd (3)
.SH BUGS
.I Pwd
is not provided.
diff --git a/man/man1/rc.1 b/man/man1/rc.1
index 7ea8998a1..38a867d76 100644
--- a/man/man1/rc.1
+++ b/man/man1/rc.1
@@ -50,7 +50,7 @@ exits or is terminated, the
variable
.B $status
gets the process's wait message (see
-.IR wait (3));
+.MR wait (3) );
it will be the null string if the command was successful.
.PP
A long command line may be continued on subsequent lines by typing
@@ -83,7 +83,7 @@ in a directory in
.B $path
is the program to be executed.
To be executable, the user must have execute permission (see
-.IR stat (3))
+.MR stat (3) )
and the file must be either an executable binary
for the current machine's CPU type, or a shell script.
Shell scripts begin with a line containing the full path name of a shell
@@ -109,7 +109,7 @@ The simplest kind of argument is the unquoted word:
a sequence of one or more characters none of which is a blank, tab,
newline, or any of the following:
.EX
- # ; & | ^ $ = ` ' { } ( ) < >
+ # ; & | ^ $ ` ' { } ( ) < >
.EE
An unquoted word that contains any of the characters
.B *
@@ -290,28 +290,10 @@ then one operand must have one component, and the other must be non-empty,
and concatenation is distributive.
.PD
.SS Free Carets
-In most circumstances,
-.I rc
+.I Rc
will insert the
.B ^
operator automatically between words that are not separated by white space.
-Whenever one of
-.B $
-.B '
-.B `
-follows a quoted or unquoted word or an unquoted word follows a quoted word
-with no intervening blanks or tabs,
-a
-.B ^
-is inserted between the two.
-If an unquoted word immediately follows a
-.BR $
-and contains a character other than an alphanumeric, underscore,
-or
-.BR * ,
-a
-.B ^
-is inserted before the first such character.
Thus
.IP
.B cc -$flags $stem.c
@@ -367,8 +349,8 @@ or
.I Fd1
is a previously opened file descriptor and
.I fd0
-becomes a new copy (in the sense of
-.IR dup (3))
+becomes a new copy (in the sense of
+.MR dup (3) )
of it.
A file descriptor may be closed by writing
.BI >[ fd0 =]
@@ -477,7 +459,7 @@ is executed.
The
.I command
is executed once for each
-.IR argument
+.IR argument
with that argument assigned to
.IR name .
If the argument list is omitted,
@@ -561,7 +543,7 @@ function definition.
A function with a special name will be called when
.I rc
receives a corresponding note; see
-.IR notify (3).
+.MR notify (3) .
The valid note names (and corresponding notes) are
.B sighup
.RB ( hangup ),
@@ -680,7 +662,7 @@ is composed of the bitwise OR of the
.B rfork
flags specified by the option letters
(see
-.IR fork (2)).
+.MR fork (2) ).
If no
.I flags
are given, they default to
@@ -824,6 +806,10 @@ is set to its process id.
.B $home
The default directory for
.BR cd .
+Defaults to
+.B $HOME
+or else
+.LR / .
.TP
.B $ifs
The input field separators used in backquote substitutions.
@@ -843,7 +829,7 @@ parsing the
.B $PATH
variable
(as in
-.IR sh (1))
+.MR sh (1) )
or by
.BR "path=(.\ /bin)" .
The variables
@@ -982,8 +968,6 @@ changes
.PP
Functions that use here documents don't work.
.PP
-Free carets don't get inserted next to keywords.
-.PP
The
.BI <{ command }
syntax depends on the underlying operating system
@@ -1009,3 +993,9 @@ and then
.B fstab
ensures causes FreeBSD to mount the file system
automatically at boot time.)
+.PP
+Some systems require
+.B \*9/bin/rc
+to be listed in
+.B /etc/shells
+before it can be used as a login shell.
diff --git a/man/man1/readcons.1 b/man/man1/readcons.1
index 8fa1c392e..6fc56a662 100644
--- a/man/man1/readcons.1
+++ b/man/man1/readcons.1
@@ -27,4 +27,4 @@ is printed instead of an empty string.
.SH SOURCE
.B \*9/src/cmd/readcons.c
.SH SEE ALSO
-.IR readcons (3)
+.MR readcons (3)
diff --git a/man/man1/resample.1 b/man/man1/resample.1
index f41d9e512..71c3b7472 100755
--- a/man/man1/resample.1
+++ b/man/man1/resample.1
@@ -40,19 +40,19 @@ and
.PP
The input should be a Plan 9 image
as described in
-.IR image (7),
+.MR image (7) ,
and the output will be a compressed 24-bit
.B r8g8b8
image.
To uncompress the image or change the pixel format, use
.I iconv
(see
-.IR crop (1)).
+.MR crop (1) ).
.PP
.SH SOURCE
.B \*9/src/cmd/resample.c
.SH "SEE ALSO
-.IR crop (1),
-.IR image (7)
+.MR crop (1) ,
+.MR image (7)
.SH BUGS
Faster algorithms exist, but this implementation produces correct pictures.
diff --git a/man/man1/rio.1 b/man/man1/rio.1
index 1fc0619d8..fb4b5dfb9 100644
--- a/man/man1/rio.1
+++ b/man/man1/rio.1
@@ -68,15 +68,15 @@ specifies an alternative program to run when the
.I New
menu item is selected.
The default is to try
-.IR 9term (1)
+.MR 9term (1)
and then to fall back to
-.IR xterm (1).
+.MR xterm (1) .
The
.B \-s
option has no effect. It formerly set the scrolling mode for
new windows and is recognized to avoid breaking scripts.
See
-.IR 9term (1)
+.MR 9term (1)
for a description of scrolling behavior.
.PP
The
@@ -137,11 +137,11 @@ Very small windows may not be created.
The new window is created running
.IR termprog ,
by default
-.IR 9term (1)
+.MR 9term (1)
or, if
.I 9term
is not available,
-.IR xterm (1).
+.MR xterm (1) .
.TP
.B Resize
Change the size and location of a window.
@@ -165,7 +165,7 @@ Deleting a window causes a
.L hangup
note to be sent to all processes in the window's process group
(see
-.IR notify (3)).
+.MR notify (3) ).
.TP
.B Hide
Hide a window. Click in the window to be hidden (gunsight cursor);
@@ -241,8 +241,8 @@ starts a particular program.)
.PP
There is a currently a compiled-in limit of 128 hidden windows.
.SH "SEE ALSO"
-.IR 9term (1),
-.IR xterm (1)
+.MR 9term (1) ,
+.MR xterm (1)
.PP
As mentioned above,
.I rio
diff --git a/man/man1/rm.1 b/man/man1/rm.1
index 83bc81727..104eda935 100644
--- a/man/man1/rm.1
+++ b/man/man1/rm.1
@@ -25,4 +25,4 @@ and the directory itself.
.SH SOURCE
.B \*9/src/cmd/rm.c
.SH "SEE ALSO"
-.IR remove (3)
+.MR remove (3)
diff --git a/man/man1/rsa.1 b/man/man1/rsa.1
index b01c979d9..4d8f286b2 100644
--- a/man/man1/rsa.1
+++ b/man/man1/rsa.1
@@ -85,7 +85,7 @@ Plan 9 represents DSA and RSA keys as attribute-value pair lists
prefixed with the string
.BR key ;
this is the generic key format used by
-.IR factotum (4).
+.MR factotum (4) .
A full DSA private key has the following attributes:
.TP
.B proto
@@ -334,9 +334,9 @@ scp auth.keys unix:.ssh/authorized_keys
.SH SOURCE
.B \*9/src/cmd/auth
.SH "SEE ALSO
-.IR factotum (4),
-.IR pem (1),
-.IR ssh (1)
+.MR factotum (4) ,
+.MR pem (1) ,
+.MR ssh (1)
.SH BUGS
There are too many key formats.
.PP
diff --git a/man/man1/sam.1 b/man/man1/sam.1
index 460fd6d6d..ac9f6e820 100644
--- a/man/man1/sam.1
+++ b/man/man1/sam.1
@@ -1,7 +1,7 @@
.TH SAM 1
.ds a \fR*\ \fP
.SH NAME
-sam, B, E, sam.save, samterm, samsave \- screen editor with structural regular expressions
+sam, B, E, sam.save, samterm, samsave \- screen editor with structural regular expressions
.SH SYNOPSIS
.B sam
[
@@ -43,7 +43,7 @@ The options are
.TP
.B -a
Autoindent. In this mode, when a newline character is typed
-in the terminal interface,
+in the terminal interface,
.I samterm
copies leading white space on the current line to the new line.
.TP
@@ -51,7 +51,7 @@ copies leading white space on the current line to the new line.
Do not `download' the terminal part of
.IR sam .
Editing will be done with the command language only, as in
-.IR ed (1).
+.MR ed (1) .
.TP
.BI -r " machine
Run the host part remotely
@@ -69,7 +69,7 @@ for debugging.
.PD
.SS Regular expressions
Regular expressions are as in
-.IR regexp (7)
+.MR regexp (7)
with the addition of
.BR \en
to represent newlines.
@@ -121,7 +121,7 @@ is the beginning of the file.
.TP
.BI ? regexp ?
The substring that matches the regular expression,
-found by looking toward the end
+found by looking toward the end
.RB ( / )
or beginning
.RB ( ? )
@@ -248,7 +248,7 @@ or
is reversed.
.PP
It is an error for a compound address to represent a malformed substring.
-Some useful idioms:
+Some useful idioms:
.IB a1 +-
\%(\f2a1\fB-+\f1)
selects the line containing
@@ -258,7 +258,7 @@ locates the first match of the expression in the file.
(The form
.B 0;//
sets dot unnecessarily.)
-.BI ./ regexp ///
+.BI ./ regexp ///
finds the second following occurrence of the expression,
and
.BI .,/ regexp /
@@ -276,7 +276,7 @@ newline may not appear literally;
.B \en
may be typed for newline; and
.B \e/
-quotes the delimiter, here
+quotes the delimiter, here
.LR / .
Backslash is otherwise interpreted literally, except in
.B s
@@ -284,7 +284,7 @@ commands.
.PP
Most commands may be prefixed by an address to indicate their range
of operation.
-Those that may not are marked with a
+Those that may not are marked with a
.L *
below.
If a command takes
@@ -347,12 +347,12 @@ Substitute
.I text
for the first match to the regular expression in the range.
Set dot to the modified range.
-In
+In
.I text
the character
.B &
stands for the string
-that matched the expression.
+that matched the expression.
Backslash behaves as usual unless followed by
a digit:
.BI \e d
@@ -500,7 +500,7 @@ Plan 9 command.
.BI \*acd " directory
Change working directory.
If no directory is specified,
-.B $home
+.B $HOME
is used.
.PD
.PP
@@ -543,7 +543,7 @@ For each match of the regular expression in the range, run the command
with dot set to the match.
Set dot to the last match.
If the regular
-expression and its slashes are omitted,
+expression and its slashes are omitted,
.L /.*\en/
is assumed.
Null string matches potentially occur before every character
@@ -652,7 +652,7 @@ If no address is specified (the
command is a newline) dot is extended in either direction to
line boundaries and printed.
If dot is thereby unchanged, it is set to
-.B .+1
+.B .+1
and printed.
.PD
.SS Grouping and multiple changes
@@ -698,7 +698,7 @@ There is usually a `current window',
marked with a dark border, to which typed text and editing
commands apply.
Text may be typed and edited as in
-.IR rio (1);
+.MR rio (1) ;
also the escape key (ESC) selects (sets dot to) text typed
since the last mouse button hit.
.PP
@@ -713,7 +713,7 @@ of a rectangle.
from the command window or the whole screen, depending on
where the null rectangle is.
.TF resize
-.TP
+.TP
.B new
Create a new, empty file.
.TP
@@ -798,7 +798,7 @@ the white-space-delimited block of text is sent as a plumb message
with a
.B click
attribute defining where the selection lies (see
-.IR plumb (7)).
+.MR plumb (7) ).
.TP
.B look
Search forward for the next occurrence of the literal text in dot.
@@ -819,7 +819,7 @@ typed in a command.
Send the text in dot, or the snarf buffer if
dot is the null string, as if it were typed to the command window.
Saves the sent text in the snarf buffer.
-(Command window only.)
+(Command window only.)
.PD
.SS Simulated buttons
For systems without a three-button mouse, the keyboard modifier
@@ -909,11 +909,11 @@ source for the separate terminal part
.TP
.B \*9/bin/E
.SH SEE ALSO
-.IR ed (1),
-.IR sed (1),
-.IR grep (1),
-.IR rio (1),
-.IR regexp (7).
+.MR ed (1) ,
+.MR sed (1) ,
+.MR grep (1) ,
+.MR rio (1) ,
+.MR regexp (7) .
.PP
Rob Pike,
``The text editor sam''.
diff --git a/man/man1/scat.1 b/man/man1/scat.1
index 57369ab5f..407b97ef5 100644
--- a/man/man1/scat.1
+++ b/man/man1/scat.1
@@ -10,7 +10,7 @@ outside the solar system
and implements database-like manipulations
on sets of such objects.
It also provides an interface to
-.IR astro (1)
+.MR astro (1)
to plot the locations of solar system objects.
Finally, it displays images from the
Space Telescope Science Institute's
@@ -119,7 +119,7 @@ The names
and
.B comet
refer to the earth's penumbra at lunar distance and the comet installed in the current
-.IR astro (1).
+.MR astro (1) .
The output is the planet's name, right ascension and declination, azimuth and altitude, and phase
for the moon and sun, as shown by
.BR astro .
@@ -182,7 +182,7 @@ collects all objects in the patches that cover the current set.
.TP
.BI astro " option"
Run
-.IR astro (1)
+.MR astro (1)
with the specified
.I options
(to which will be appended
@@ -324,7 +324,7 @@ Draw a map of the Pleiades.
.SH SOURCE
.B \*9/src/cmd/scat
.SH SEE ALSO
-.IR astro (1)
+.MR astro (1)
.br
.B \*9/sky/constelnames\ \
the three-letter abbreviations of the constellation names.
diff --git a/man/man1/secstore.1 b/man/man1/secstore.1
index 01c7903b0..9374e3902 100644
--- a/man/man1/secstore.1
+++ b/man/man1/secstore.1
@@ -97,7 +97,7 @@ Option
.B -n
says that the password should be read from NVRAM
(see
-.IR authsrv (3))
+.MR authsrv (3) )
instead of from
.BR /dev/tty .
.PP
@@ -107,7 +107,7 @@ or the server specified by option
.BR -s .
.PP
For example, to add a secret to the file read by
-.IR factotum (4),
+.MR factotum (4) ,
run
.sp
.EX
@@ -192,8 +192,8 @@ block chaining (CBC) mode.
.br
.B \*9/src/cmd/auth/secstore
.SH SEE ALSO
-.IR factotum (4),
-.IR secstored (1)
+.MR factotum (4) ,
+.MR secstored (1)
.SH BUGS
There is deliberately no backup of files on the secstore, so
.B -r
diff --git a/man/man1/secstored.1 b/man/man1/secstored.1
index 3eee78bef..82eaee3cf 100644
--- a/man/man1/secstored.1
+++ b/man/man1/secstored.1
@@ -18,7 +18,7 @@ username
.PP
.I Secstored
serves requests from
-.IR secstore (1).
+.MR secstore (1) .
The
.B -R
option supplements the password check with a
@@ -61,4 +61,4 @@ for mapping local userid to RADIUS userid
.SH SOURCE
.B \*9/src/cmd/auth/secstore
.SH SEE ALSO
-.IR secstore (1)
+.MR secstore (1)
diff --git a/man/man1/sed.1 b/man/man1/sed.1
index 7f2b5f134..8a892da1e 100644
--- a/man/man1/sed.1
+++ b/man/man1/sed.1
@@ -78,7 +78,7 @@ that
addresses the last line of input, or a context address,
.BI / regular-expression / \f1,
in the style of
-.IR regexp (7),
+.MR regexp (7) ,
with the added convention that
.L \en
matches a
@@ -235,7 +235,7 @@ in the pattern space.
Any character may be used instead of
.LR / .
For a fuller description see
-.IR regexp (7).
+.MR regexp (7) .
.I Flags
is zero or more of
.RS
@@ -374,8 +374,8 @@ formatted manuscript.
.IR grep (1),
.IR awk (1),
.IR lex (1),
-.IR sam (1),
-.IR regexp (7)
+.MR sam (1) ,
+.MR regexp (7)
.br
L. E. McMahon,
`SED \(em A Non-interactive Text Editor',
diff --git a/man/man1/seq.1 b/man/man1/seq.1
index 3f295c041..e181f5bef 100644
--- a/man/man1/seq.1
+++ b/man/man1/seq.1
@@ -38,7 +38,7 @@ The options are
.TP "\w'\fL-f \fIformat\fLXX'u"
.BI -f format
Use the
-.IR print (3)-style
+.MR print (3) -style
.I format
.IR print
for printing each (floating point) number.
diff --git a/man/man1/sftpcache.1 b/man/man1/sftpcache.1
index 28499b48d..8c0a0ad8a 100644
--- a/man/man1/sftpcache.1
+++ b/man/man1/sftpcache.1
@@ -7,7 +7,7 @@ sftpcache \- cache sftp connections
.SH DESCRIPTION
.I Sftpcache
multiplexes clients onto persistent
-.IR sftp (1)
+.MR sftp (1)
connections.
It runs
.I sftp
@@ -16,7 +16,7 @@ and posts a socket named
.IB system .sftp
in the name space directory
(see
-.IR intro (4)).
+.MR intro (4) ).
Clients can connect to the socket, one at a time,
to interact with the
.I sftp
@@ -24,13 +24,13 @@ session.
.PP
.I Sftpcache
is used by
-.IR netfiles (1).
+.MR netfiles (1) .
.SH SOURCE
.B \*9/src/cmd/sftpcache.c
.SH SEE ALSO
-.IR ssh (1),
-.IR sftp (1),
-.IR netfiles (1)
+.MR ssh (1) ,
+.MR sftp (1) ,
+.MR netfiles (1)
.SH BUGS
.I Sftpcache
only works with OpenSSH versions 4.3 and earlier;
diff --git a/man/man1/sleep.1 b/man/man1/sleep.1
index 3eb617b46..f5f7c4cff 100644
--- a/man/man1/sleep.1
+++ b/man/man1/sleep.1
@@ -28,4 +28,4 @@ while (){
.SH SOURCE
.B \*9/src/cmd/sleep.c
.SH "SEE ALSO"
-.IR sleep (3)
+.MR sleep (3)
diff --git a/man/man1/snarfer.1 b/man/man1/snarfer.1
index 54200b4b2..ef77c9511 100644
--- a/man/man1/snarfer.1
+++ b/man/man1/snarfer.1
@@ -13,30 +13,31 @@ Each time a program changes the snarf buffer contents,
.I snarfer
copies the new contents and then takes over control
of the buffer.
-Because the snarf buffer contents are managed by
+Because the snarf buffer contents are managed by
.I snarfer
instead of by individual programs, the contents remain
available even after the program that wrote them exits.
.PP
-The
+The
.B -v
option, intended for debugging, causes
.I snarfer
to print the new snarf buffer contents each time it changes.
.PP
-On Mac OS X,
+On Mac OS X,
running
.I snarfer
keeps the X11 snarf buffer in sync with the Carbon snarf buffer,
working around a bug in the OS X X11 server.
See
-.IR getsnarf (3)
+.MR getsnarf (3)
for more details.
.SH SOURCE
.B \*9/src/cmd/snarfer
.SH SEE ALSO
-Unix's \fIxclipboard\fR(1),
-.IR getsnarf (3)
+Unix's
+.IR xclipboard (1),
+.MR getsnarf (3)
.SH BUGS
Both
.I xclipboard
diff --git a/man/man1/soelim.1 b/man/man1/soelim.1
new file mode 100755
index 000000000..c7324035d
--- /dev/null
+++ b/man/man1/soelim.1
@@ -0,0 +1,29 @@
+.TH SOELIM 1
+.\" .so in the NAME line confuses the ptx machinery; sorry
+.SH NAME
+soelim \- preprocess so inclusion commands in troff input
+.SH SYNOPSIS
+.B soelim
+[
+.I files ...
+]
+.SH DESCRIPTION
+.I Soelim
+reads the specified files or the standard input and performs
+the textual inclusion implied by
+.MR troff (1)
+directives of the form
+.TP
+.B "\&.so some_file
+.PP
+when they appear at the beginning of input lines. This is useful when
+using programs such as
+.MR tbl (1)
+that do not normally do this, allowing
+placement of individual tables or other text objects in separate files
+to be run as a part of a large document.
+.SH SOURCE
+.B \*9/bin/soelim
+.SH "SEE ALSO"
+.MR deroff (1) ,
+.MR troff (1)
diff --git a/man/man1/sort.1 b/man/man1/sort.1
index e68a53fcb..6922114b0 100644
--- a/man/man1/sort.1
+++ b/man/man1/sort.1
@@ -242,8 +242,8 @@ come out in their original order.
.SH SOURCE
.B \*9/src/cmd/sort.c
.SH SEE ALSO
-.IR uniq (1),
-.IR look (1)
+.MR uniq (1) ,
+.MR look (1)
.SH DIAGNOSTICS
.I Sort
comments and exits with non-null status for various trouble
diff --git a/man/man1/spell.1 b/man/man1/spell.1
index 5d27609bc..27ae68039 100644
--- a/man/man1/spell.1
+++ b/man/man1/spell.1
@@ -31,7 +31,7 @@ not sanctioned there\(emon the standard output.
.PP
.I Spell
ignores constructs of
-.IR troff (1)
+.MR troff (1)
and its standard preprocessors.
It understands these options:
.TP
@@ -82,10 +82,10 @@ the script
source for
.I sprog
.SH SEE ALSO
-.IR deroff (1)
+.MR deroff (1)
.SH BUGS
The heuristics of
-.IR deroff (1)
+.MR deroff (1)
used to excise formatting information are imperfect.
.PP
The spelling list's coverage is uneven;
diff --git a/man/man1/split.1 b/man/man1/split.1
index 9b2c976f9..b61ef1855 100644
--- a/man/man1/split.1
+++ b/man/man1/split.1
@@ -41,7 +41,7 @@ File divisions occur at each line
that matches a regular
.IR expression ;
see
-.IR regexp (7).
+.MR regexp (7) .
Multiple
.B -e
options may appear.
@@ -77,6 +77,6 @@ to lower case.
.B \*9/src/cmd/split.c
.SH SEE ALSO
.IR sed (1),
-.IR awk (1),
-.IR grep (1),
-.IR regexp (7)
+.MR awk (1) ,
+.MR grep (1) ,
+.MR regexp (7)
diff --git a/man/man1/src.1 b/man/man1/src.1
index 5f6a29cff..7648602b3 100644
--- a/man/man1/src.1
+++ b/man/man1/src.1
@@ -19,11 +19,11 @@ examines the named
to find the corresponding source code, which is then sent to the editor using
.B B
(see
-.IR sam (1)).
+.MR sam (1) ).
If
.I file
is an
-.IR rc (1)
+.MR rc (1)
script, the source is the file itself.
If
.I file
@@ -35,7 +35,7 @@ and
will point the editor at the line that begins the definition.
.I Src
uses
-.IR db (1)
+.MR db (1)
to extract the symbol table information that identifies the source.
.PP
.I Src
@@ -78,6 +78,6 @@ src -s strcmp rc
.SH SOURCE
.B \*9/bin/src
.SH "SEE ALSO"
-.IR db (1),
-.IR plumb (1),
-.IR sam (1).
+.MR db (1) ,
+.MR plumb (1) ,
+.MR sam (1) .
diff --git a/man/man1/ssam.1 b/man/man1/ssam.1
index 6dbdc2364..aa9fc647a 100755
--- a/man/man1/ssam.1
+++ b/man/man1/ssam.1
@@ -63,8 +63,8 @@ Count frequency of words read from standard input.
.B \*9/bin/ssam
.SH SEE ALSO
.IR sed (1),
-.IR sam (1),
-.IR regexp (7)
+.MR sam (1) ,
+.MR regexp (7)
.PP
Rob Pike,
``The text editor sam''.
diff --git a/man/man1/ssh-agent.1 b/man/man1/ssh-agent.1
index 1617e17f6..70ecec647 100644
--- a/man/man1/ssh-agent.1
+++ b/man/man1/ssh-agent.1
@@ -10,9 +10,9 @@ ssh-agent \- SSH authentication agent
.SH DESCRIPTION
.I Ssh-agent
presents
-.IR factotum (4)
+.MR factotum (4)
using the interface that
-.IR ssh (1)
+.MR ssh (1)
requires.
.PP
Once
@@ -33,7 +33,7 @@ via a Unix socket named
.B ssh-agent.socket
in the name space directory
(see
-.IR intro (4)).
+.MR intro (4) ).
Note that although the socket is posted in the name space
directory, it is not for 9P conversations.
.I Ssh
@@ -81,10 +81,10 @@ Invoke this one with
.B 9
.BR ssh-agent ;
see
-.IR 9 (1).
+.MR 9 (1) .
.SH EXAMPLES
Assume
-.IR factotum (4)
+.MR factotum (4)
is already running and initialized with keys.
.PP
Start a new agent, copying the commands by hand:
@@ -103,7 +103,7 @@ $
.EE
.PP
Start the agent from
-.IR sh (1):
+.MR sh (1) :
.IP
.EX
$ eval `9 ssh-agent -e`
@@ -111,7 +111,7 @@ $
.EE
.PP
Start the agent from
-.IR rc (1):
+.MR rc (1) :
.IP
.EX
% eval `{9 ssh-agent}
@@ -128,9 +128,9 @@ tux% ^D
.SH SOURCE
.B \*9/src/cmd/auth/ssh-agent.c
.SH SEE ALSO
-.IR ssh (1),
-.IR rsa (1),
-.IR factotum (4)
+.MR ssh (1) ,
+.MR rsa (1) ,
+.MR factotum (4)
.SH BUGS
A surprise rather than a bug:
.I ssh-agent
diff --git a/man/man1/strings.1 b/man/man1/strings.1
index d04dc41fe..b4070f0fe 100644
--- a/man/man1/strings.1
+++ b/man/man1/strings.1
@@ -25,4 +25,4 @@ line with the offset of the continuation line.
.SH SOURCE
.B \*9/src/cmd/strings.c
.SH SEE ALSO
-.IR nm (1)
+.MR nm (1)
diff --git a/man/man1/sum.1 b/man/man1/sum.1
index b95851db0..727f273fe 100644
--- a/man/man1/sum.1
+++ b/man/man1/sum.1
@@ -73,5 +73,5 @@ summed.
.br
.B \*9/src/cmd/sha1sum.c
.SH "SEE ALSO"
-.IR cmp (1),
-.IR wc (1)
+.MR cmp (1) ,
+.MR wc (1)
diff --git a/man/man1/tar.1 b/man/man1/tar.1
index 4a18d6c8d..dc4d666c3 100644
--- a/man/man1/tar.1
+++ b/man/man1/tar.1
@@ -112,14 +112,14 @@ archive entries.
.B z
Operate on compressed tar archives.
The type of compression is inferred from the file name extension:
-.IR gzip (1)
+.MR gzip (1)
for
.B .tar.gz
and
.BR .tgz ;
.I bzip2
(see
-.IR gzip (1))
+.MR gzip (1) )
for
.BR .tar.bz ,
.BR .tbz ,
@@ -127,7 +127,6 @@ for
and
.BR .tbz2 ;
.I compress
-(not distributed)
for
.B .tar.Z
and
@@ -154,8 +153,8 @@ can be used to copy hierarchies thus:
.SH SEE ALSO
.I 9ar
in
-.IR 9c (1),
-.IR bundle (1)
+.MR 9c (1) ,
+.MR bundle (1)
.SH BUGS
There is no way to ask for any but the last
occurrence of a file.
diff --git a/man/man1/tbl.1 b/man/man1/tbl.1
index ce13a4a49..c241a0ab2 100644
--- a/man/man1/tbl.1
+++ b/man/man1/tbl.1
@@ -11,7 +11,7 @@ tbl \- format tables for nroff or troff
is a preprocessor for formatting tables for
.I nroff
or
-.IR troff (1).
+.MR troff (1) .
The input
.I files
are copied to the standard output,
@@ -74,7 +74,7 @@ recognize
and
.I y
as
-.IR eqn (1)
+.MR eqn (1)
delimiters
.PD
.RE
@@ -275,8 +275,8 @@ Bernardsville 2018 3.30
.B \*9/src/cmd/tbl
.SH SEE ALSO
.IR troff (1),
-.IR eqn (1),
-.IR doctype (1)
+.MR eqn (1) ,
+.MR doctype (1)
.br
M. E. Lesk and L. L. Cherry,
``TBL\(ema Program to Format Tables'',
diff --git a/man/man1/tcs.1 b/man/man1/tcs.1
index f23d1ceef..ef871fa4c 100644
--- a/man/man1/tcs.1
+++ b/man/man1/tcs.1
@@ -36,7 +36,7 @@ is
the
.SM UTF
encoding described in
-.IR utf (7).
+.MR utf (7) .
The
.B -l
option lists the character sets known to
@@ -164,4 +164,4 @@ Print an up to date list of the supported character sets.
.SH SEE ALSO
.IR ascii (1),
.IR rune (3),
-.IR utf (7).
+.MR utf (7) .
diff --git a/man/man1/test.1 b/man/man1/test.1
index 9957b29d7..0a8499138 100644
--- a/man/man1/test.1
+++ b/man/man1/test.1
@@ -182,7 +182,7 @@ and must be enclosed in quotes.
.I Test
is a dubious way to check for specific character strings:
it uses a process to do what an
-.IR rc (1)
+.MR rc (1)
match or switch statement can do.
The first example is not only inefficient but wrong, because
.I test
diff --git a/man/man1/time.1 b/man/man1/time.1
index 57a0a5668..25d3dbf21 100644
--- a/man/man1/time.1
+++ b/man/man1/time.1
@@ -18,4 +18,4 @@ followed by the command line.
.SH SOURCE
.B \*9/src/cmd/time.c
.SH "SEE ALSO"
-.IR prof (1)
+.MR prof (1)
diff --git a/man/man1/touch.1 b/man/man1/touch.1
index a02440d2c..2a48c3c2d 100644
--- a/man/man1/touch.1
+++ b/man/man1/touch.1
@@ -27,9 +27,9 @@ is present.
.SH SOURCE
.B \*9/src/cmd/touch.c
.SH SEE ALSO
-.IR ls (1),
-.IR stat (3),
-.IR chmod (1)
+.MR ls (1) ,
+.MR stat (3) ,
+.MR chmod (1)
.SH BUGS
.I Touch
will not touch directories.
diff --git a/man/man1/tr.1 b/man/man1/tr.1
index cef4a1775..74c512fb2 100644
--- a/man/man1/tr.1
+++ b/man/man1/tr.1
@@ -94,4 +94,4 @@ tr -cs A-Za-z '
.SH SOURCE
.B \*9/src/cmd/tr.c
.SH "SEE ALSO"
-.IR sed (1)
+.MR sed (1)
diff --git a/man/man1/tr2post.1 b/man/man1/tr2post.1
index 3a54e4d22..29d3e85cb 100644
--- a/man/man1/tr2post.1
+++ b/man/man1/tr2post.1
@@ -15,7 +15,7 @@ converts
.I files
(or standard input),
which should be the device-independent output of
-.IR troff (1),
+.MR troff (1) ,
into the PostScript printer language.
.PP
The options are:
@@ -29,7 +29,8 @@ to stretch the PostScript output (default 1.0).
Set a comment in the PostScript output
marking the number of copies that should be printed.
The comment is intended for ancient versions of the Unix
-\fIlp\fR(1) and is not recognized by any current printer
+.IR lp (1)
+and is not recognized by any current printer
or print spooler.
.TP
.BI -d
@@ -46,11 +47,11 @@ logical pages per physical page
Using this option emits PostScript with invalid document structuring
comments.
It will print fine but will not view correctly in
-.IR gv (1)
+.MR gv (1)
or
.I psv
(see
-.IR page (1)).
+.MR page (1) ).
.TP
.BI -o " pagelist
Print only the pages in the
@@ -109,5 +110,5 @@ psv /tmp/a.ps
.SH SOURCE
.B \*9/src/cmd/postscript/tr2post
.SH SEE ALSO
-.IR troff (1),
-.IR psfonts (1)
+.MR troff (1) ,
+.MR psfonts (1)
diff --git a/man/man1/troff.1 b/man/man1/troff.1
index 7af3f3c1c..032e8c70f 100644
--- a/man/man1/troff.1
+++ b/man/man1/troff.1
@@ -176,18 +176,18 @@ font width tables for
.SH SOURCE
.B \*9/src/cmd/troff
.SH "SEE ALSO"
-.IR lpr (1),
-.IR proof (1),
-.IR tr2post (1),
+.MR lpr (1) ,
+.MR proof (1) ,
+.MR tr2post (1) ,
.IR eqn (1),
.IR tbl (1),
.IR pic (1),
-.IR grap (1),
+.MR grap (1) ,
.IR doctype (1),
-.IR ms (7),
-.IR image (7),
-.IR tex (1),
-.IR deroff (1)
+.MR ms (7) ,
+.MR image (7) ,
+.MR tex (1) ,
+.MR deroff (1)
.br
J. F. Ossanna and B. W. Kernighan,
``Troff User's Manual''
diff --git a/man/man1/troff2html.1 b/man/man1/troff2html.1
index a40e22f0e..06465e9b9 100644
--- a/man/man1/troff2html.1
+++ b/man/man1/troff2html.1
@@ -13,7 +13,7 @@ troff2html \- convert troff output into HTML
.SH DESCRIPTION
.I Troff2html
reads the
-.IR troff (1)
+.MR troff (1)
output in the named
.IR files ,
default standard input,
@@ -25,12 +25,13 @@ does a tolerable job with straight
output, but it is helped by annotations, described below.
Its main use is for
.B man2html
-(see Plan 9's \fIhttpd\fR(8)),
+(see Plan 9's
+.IR httpd (8)),
which converts
-.IR man (1)
+.MR man (1)
pages into HTML
and depends on a specially annotated set of
-.IR man (7)
+.MR man (7)
macros, invoked by
.B troff
.BR -manhtml .
@@ -57,25 +58,25 @@ x X html manref end cp 1
.EE
.PP
which are used to create HTML hyperlinks around text of the form
-.IR cp (1)
+.MR cp (1)
pointing to
.BR /magic/man2html/1/cp .
.PP
.I Troff2html
is new and experimental; in time, it may improve and subsume
Plan 9's
-\fIms2html\fR(1).
+.IR ms2html (1).
On the one hand, because it uses the input,
.B ms2html
can handle
-.IR pic (1),
-.IR eqn (1),
+.MR pic (1) ,
+.MR eqn (1) ,
etc., which
.I troff2html
does not handle at all; on the other hand,
.B ms2html
understands only
-.IR ms (7)
+.MR ms (7)
documents and is easily confused by complex
.B troff
constructions.
@@ -83,13 +84,13 @@ constructions.
has the reverse properties: it does not handle the preprocessors but its output
is reliable and (modulo helper annotations) is independent of macro package.
.SH SEE ALSO
-.IR troff (1),
+.MR troff (1) ,
Plan 9's
-\fIms2html\fR(1),
+.IR ms2html (1),
.I man2html
in
Plan 9's
-\fIhttpd\fR(8).
+.IR httpd (8).
.SH BUGS
.B Troff
and HTML have different models, and they don't mesh well in all cases.
diff --git a/man/man1/tweak.1 b/man/man1/tweak.1
index ac52a9b59..773ec325e 100644
--- a/man/man1/tweak.1
+++ b/man/man1/tweak.1
@@ -35,14 +35,14 @@ If the file is a subfont, a second line presents a hexadecimal 16-bit
.B offset
to be applied to character values from the subfont
(typically as stored in a font file; see
-.IR font (7));
+.MR font (7) );
and the subfont's
.BR n ,
.BR height ,
and
.B ascent
as defined in
-.IR cachechars (3).
+.MR cachechars (3) .
.PP
By means described below, magnified views of portions of the images
may be displayed.
@@ -61,7 +61,7 @@ default font; the character's
and
.BR width
as defined in
-.IR cachechars (3);
+.MR cachechars (3) ;
and
.BR iwidth ,
the physical width of the image in the subfont's image.
@@ -158,9 +158,9 @@ The program will complain once about modified but unwritten files.
.SH SOURCE
.B \*9/src/cmd/draw/tweak.c
.SH "SEE ALSO"
-.IR cachechars (3),
-.IR image (7),
-.IR font (7)
+.MR cachechars (3) ,
+.MR image (7) ,
+.MR font (7)
.SH BUGS
For a program written to adjust width tables in fonts,
.I tweak
diff --git a/man/man1/uniq.1 b/man/man1/uniq.1
index ae17f0955..07629ea4e 100644
--- a/man/man1/uniq.1
+++ b/man/man1/uniq.1
@@ -56,4 +56,4 @@ Fields are skipped before characters.
.IR sort (1)
.SH BUGS
Field selection and comparison should be compatible with
-.IR sort (1).
+.MR sort (1) .
diff --git a/man/man1/vac.1 b/man/man1/vac.1
index 39f7c00ff..53f89b2ae 100644
--- a/man/man1/vac.1
+++ b/man/man1/vac.1
@@ -53,7 +53,7 @@ is used on a file tree that shares data with an existing archive, the consumptio
storage will be approximately equal to an incremental backup.
This reduction in storage consumption occurs transparently to the user.
.PP
-As an optimization, the
+As an optimization, the
.B -d
and
.B -q
@@ -78,7 +78,8 @@ the files under an extra two levels of directory hierarchy named
.I yyyy/mmdd
(year, month, day)
in the style of the dump file system
-(see Plan 9's \fIfs\fR(4)).
+(see Plan 9's
+.IR fs (4)).
If
.I vacfile
already exists, an additional backup day is added to the
@@ -89,7 +90,7 @@ Typically, this option
is used as part of a nightly backup script.
This option cannot be used with
.B -d
-or
+or
.BR -f .
.TP
.BI -b " blocksize
@@ -114,13 +115,13 @@ Do not include the file or directory specified by
This option may be repeated multiple times.
.I Exclude
can be a shell pattern as accepted by
-.IR rc (1),
-with one extension:
+.MR rc (1) ,
+with one extension:
.B \&...
matches any sequence of characters including slashes.
.TP
.BI -f " vacfile
-The results of
+The results of
.I vac
are placed in
.IR vacfile ,
@@ -136,7 +137,7 @@ The network address of the Venti server.
The default is taken from the environment variable
.BR venti .
.\" If this variable does not exist, then the default is the
-.\" metaname
+.\" metaname
.\" .BR $venti ,
.\" which can be configured via
.\" .IR ndb (6).
@@ -155,7 +156,7 @@ the archive to be unpacked.
.TP
.B -q
Increase the performance of the
-.B -a
+.B -a
or
.B -d
options by detecting unchanged files based on a match of the files name and other meta data,
@@ -169,9 +170,9 @@ Produce more verbose output on standard error, including the name of the files a
and the vac archives that are expanded and merged.
.TP
.BI -x " excfile
-Read exclude patterns from the file
+Read exclude patterns from the file
.IR excfile .
-Blank lines and lines beginning with
+Blank lines and lines beginning with
.B #
are ignored.
All other lines should be of the form
@@ -224,5 +225,5 @@ If listing files, print metadata in addition to the names.
.SH SOURCE
.B \*9/src/cmd/vac
.SH "SEE ALSO"
-.IR vacfs (4),
-.IR venti (8)
+.MR vacfs (4) ,
+.MR venti (8)
diff --git a/man/man1/venti.1 b/man/man1/venti.1
index e14052aa7..b35b2ac17 100644
--- a/man/man1/venti.1
+++ b/man/man1/venti.1
@@ -40,7 +40,7 @@ read, write, copy \- simple Venti clients
.SH DESCRIPTION
Venti is a SHA1-addressed block storage server.
See
-.IR venti (7)
+.MR venti (7)
for a full introduction.
.PP
.I Read
@@ -167,13 +167,13 @@ messages send/received.
.SH SOURCE
.B \*9/src/cmd/venti
.SH SEE ALSO
-.IR vac (1),
-.IR venti (3),
-.IR vacfs (4),
-.IR venti (7),
-.IR vbackup (8),
-.IR venti (8),
-.IR venti-fmt (8)
+.MR vac (1) ,
+.MR venti (3) ,
+.MR vacfs (4) ,
+.MR venti (7) ,
+.MR vbackup (8) ,
+.MR venti (8) ,
+.MR venti-fmt (8)
.SH BUGS
There should be programs to read and write
venti files and directories.
diff --git a/man/man1/web.1 b/man/man1/web.1
index 06d304df1..0d57ad9f5 100644
--- a/man/man1/web.1
+++ b/man/man1/web.1
@@ -81,7 +81,7 @@ URL passed to
and
.I wmail
are invoked as start commands in the
-.IR plumber (4)'s
+.MR plumber (4) 's
rules for opening web pages and writing mail messages.
.SH FILES
.TP
@@ -93,4 +93,4 @@ and
.SH SOURCE
.B \*9/bin
.SH SEE ALSO
-.IR plumber (4)
+.MR plumber (4)
diff --git a/man/man1/wintext.1 b/man/man1/wintext.1
index 12859f259..b7108e462 100644
--- a/man/man1/wintext.1
+++ b/man/man1/wintext.1
@@ -3,17 +3,17 @@
wintext, ", "" \- access text in current window
.ds x \C'"'
.ds xx \C'"'\^\^\^\^\C'"'
-.ds y \*x\
-.ds yy \*(xx\
+.ds y \*x\^
+.ds yy \*(xx\^
.SH SYNOPSIS
.B wintext
.br
-.B \*x\
+.B \*y
[
.I prefix
]
.br
-.B \*(xx\
+.B \*(yy
[
.I prefix
]
@@ -22,9 +22,11 @@ wintext, ", "" \- access text in current window
prints the text of the current
.I win
(see
-.IR acme (1))
+.MR acme (1) ),
+.MR 9term (1) ,
or
-.IR 9term (1)
+(Unix's)
+.MR tmux (1)
window to standard output.
.PP
.I \*y
@@ -40,8 +42,8 @@ prints the last command executed.
.I \*(yy
prints the last command that
.I \*y
-would print and then executes it by piping it into
-.IR rc (1).
+would print and then executes it by piping it into
+.MR rc (1) .
.PP
Both
.I \*y
@@ -59,7 +61,7 @@ or
.BR # .
.SH EXAMPLES
Print the
-.IR ls (1)
+.MR ls (1)
and
.I lc
commands executed in this window:
@@ -82,11 +84,11 @@ command again:
% \*(xx lc
% lc r*
ramfs rc read rio rm
-%
+%
.EE
.SH SEE ALSO
-.IR 9term (1),
-.IR acme (1)
+.MR 9term (1) ,
+.MR acme (1)
.SH SOURCE
.B \*9/bin
.SH BUGS
@@ -94,5 +96,5 @@ ramfs rc read rio rm
and
.I \*(yy
are hard to type in shells other than
-.IR rc (1).
+.MR rc (1) .
.\" and in troff!
diff --git a/man/man1/winwatch.1 b/man/man1/winwatch.1
new file mode 100644
index 000000000..98031fbc0
--- /dev/null
+++ b/man/man1/winwatch.1
@@ -0,0 +1,57 @@
+.TH WINWATCH 1
+.SH NAME
+winwatch \- monitor rio windows
+.SH SYNOPSIS
+.B winwatch
+[
+.B -e
+.I exclude
+] [
+.B -f
+.I font
+] [
+.B -n
+] [
+.B -s
+]
+.SH DESCRIPTION
+.I Winwatch
+displays the labels of all current
+.MR rio (1)
+windows, refreshing the display every second.
+Right clicking a window's label unhides, raises and gives focus to that window.
+Typing
+.B q
+or
+DEL
+quits
+.IR winwatch .
+.PP
+If the
+.B -e
+flag
+is given,
+windows matching the regular expression
+.I exclude
+are not shown.
+With the
+.B -n
+option,
+the
+label is defined as the window’s name instead of its class,
+and with
+.B -s
+the labels are sorted by alphabet (case insensitive)
+instead of by order of appearance.
+Winwatch is unicode aware.
+.SH EXAMPLE
+Excluding winwatch and stats from being shown.
+.IP
+.EX
+% winwatch -e '^(winwatch|stats)$'
+.EE
+.SH SOURCE
+.B \*9/src/cmd/winwatch.c
+.SH SEE ALSO
+.MR rio (1) ,
+.MR regexp (7) .
diff --git a/man/man1/xd.1 b/man/man1/xd.1
index 5ec167bdc..3a98d9365 100644
--- a/man/man1/xd.1
+++ b/man/man1/xd.1
@@ -91,7 +91,7 @@ followed by an asterisk.
.SH SOURCE
.B \*9/src/cmd/xd.c
.SH "SEE ALSO"
-.IR db (1)
+.MR db (1)
.SH BUGS
The various output formats don't line up properly in the output of
.IR xd .
diff --git a/man/man1/yacc.1 b/man/man1/yacc.1
index cbd1eb73a..b291473f5 100644
--- a/man/man1/yacc.1
+++ b/man/man1/yacc.1
@@ -23,7 +23,7 @@ to produce a program
This program must be loaded with a lexical analyzer function,
.B yylex(void)
(often generated by
-.IR lex (1)),
+.MR lex (1) ),
with a
.B main(int argc, char *argv[])
program, and with an error handling routine,
@@ -115,7 +115,7 @@ option reverses this.
The parser accepts
.SM UTF
input text (see
-.IR utf (7)),
+.MR utf (7) ),
which has a couple of effects.
First, the return value of
.B yylex()
@@ -156,7 +156,7 @@ parser prototype using stdio
.SH SOURCE
.B \*9/src/cmd/yacc.c
.SH "SEE ALSO"
-.IR lex (1)
+.MR lex (1)
.br
S. C. Johnson and R. Sethi,
``Yacc: A parser generator'',
diff --git a/man/man1/yesterday.1 b/man/man1/yesterday.1
index 665c7b221..eae046e03 100644
--- a/man/man1/yesterday.1
+++ b/man/man1/yesterday.1
@@ -91,8 +91,8 @@ by convention, root of the dump file system
.SH SOURCE
.B \*9/bin/yesterday
.SH SEE ALSO
-.IR diff (1),
-.IR hist (1),
-.IR vbackup (8)
+.MR diff (1) ,
+.MR hist (1) ,
+.MR vbackup (8)
.SH BUGS
It's hard to use this command without singing.
diff --git a/man/man3/0intro.3 b/man/man3/0intro.3
index e544cc8d8..fe75e7980 100644
--- a/man/man3/0intro.3
+++ b/man/man3/0intro.3
@@ -49,7 +49,7 @@ automatically, so it is rarely necessary to tell the loader
which
libraries a program needs;
see
-.IR 9c (1).
+.MR 9c (1) .
.PP
The library to which a function belongs is defined by the
header file that defines its interface.
@@ -121,7 +121,7 @@ and
plus macros that define the layout of
.IR jmp_buf
(see
-.IR setjmp (3));
+.MR setjmp (3) );
.\" definitions of the bits in the floating-point control register
.\" as used by
.\" .IR getfcr (2);
@@ -198,27 +198,27 @@ by
or
.I create
(see
-.IR open (3)).
+.MR open (3) ).
These calls return an integer called a
.IR "file descriptor"
which identifies the file
to subsequent I/O calls,
notably
-.IR read (3)
+.MR read (3)
and
.IR write .
The system allocates the numbers by selecting the lowest unused descriptor.
They are allocated dynamically; there is no visible limit to the number of file
descriptors a process may have open.
They may be reassigned using
-.IR dup (3).
+.MR dup (3) .
File descriptors are indices into a
kernel resident
.IR "file descriptor table" .
Each process has an associated file descriptor table.
In threaded programs
(see
-.IR thread (3)),
+.MR thread (3) ),
the file descriptor table is shared by all the procs.
.PP
By convention,
@@ -236,22 +236,22 @@ Files are normally read or written in sequential order.
The I/O position in the file is called the
.IR "file offset"
and may be set arbitrarily using the
-.IR seek (3)
+.MR seek (3)
system call.
.PP
Directories may be opened like regular files.
Instead of reading them with
-.IR read (3),
+.MR read (3) ,
use the
.B Dir
structure-based
routines described in
-.IR dirread (3).
+.MR dirread (3) .
The entry
corresponding to an arbitrary file can be retrieved by
.IR dirstat
(see
-.IR stat (3))
+.MR stat (3) )
or
.IR dirfstat ;
.I dirwstat
@@ -262,9 +262,9 @@ write back entries, thus changing the properties of a file.
New files are made with
.I create
(see
-.IR open (3))
+.MR open (3) )
and deleted with
-.IR remove (3).
+.MR remove (3) .
Directories may not directly be written;
.IR create ,
.IR remove ,
@@ -273,27 +273,27 @@ and
.I fwstat
alter them.
.PP
-.IR Pipe (3)
+.MR Pipe (3)
creates a connected pair of file descriptors,
useful for bidirectional local communication.
.SS "Process execution and control"
A new process is created
when an existing one calls
-.IR fork (2).
+.MR fork (2) .
The new (child) process starts out with
copies of the address space and most other attributes
of the old (parent) process.
In particular,
the child starts out running
the same program as the parent;
-.IR exec (3)
+.MR exec (3)
will bring in a different one.
.PP
Each process has a unique integer process id;
a set of open files, indexed by file descriptor;
and a current working directory
(changed by
-.IR chdir (2)).
+.MR chdir (2) ).
.PP
Each process has a set of attributes \(em memory, open files,
name space, etc. \(em that may be shared or unique.
@@ -302,9 +302,9 @@ Flags to
control the sharing of these attributes.
.PP
A process terminates by calling
-.IR exits (3).
+.MR exits (3) .
A parent process may call
-.IR wait (3)
+.MR wait (3)
to wait for some child to terminate.
A bit of status information
may be passed from
@@ -317,14 +317,14 @@ The Plan 9 interface persists here, although the functionality does not.
Instead, empty strings are converted to exit status 0 and non-empty strings to 1.
.PP
A process can go to sleep for a specified time by calling
-.IR sleep (3).
+.MR sleep (3) .
.PP
There is a
.I notification
mechanism for telling a process about events such as address faults,
floating point faults, and messages from other processes.
A process uses
-.IR notify (3)
+.MR notify (3)
to register the function to be called (the
.IR "notification handler" )
when such events occur.
@@ -334,12 +334,12 @@ the main C library works properly in multiprocess programs;
.IR malloc ,
.IR print ,
and the other routines use locks (see
-.IR lock (3))
+.MR lock (3) )
to synchronize access to their data structures.
The graphics library defined in
.B
is also multi-process capable; details are in
-.IR graphics (3).
+.MR graphics (3) .
In general, though, multiprocess programs should use some form of synchronization
to protect shared data.
.PP
@@ -365,12 +365,12 @@ Therefore, a program that shouldn't block unexpectedly will use a process
to serve the I/O request, passing the result to the main processes
over a channel when the request completes.
For examples of this design, see
-.IR ioproc (3)
+.MR ioproc (3)
or
-.IR mouse (3).
+.MR mouse (3) .
.SH SEE ALSO
.IR nm (1),
-.IR 9c (1)
+.MR 9c (1)
.SH DIAGNOSTICS
Math functions in
.I libc
@@ -378,14 +378,14 @@ return
special values when the function is undefined for the
given arguments or when the value is not representable
(see
-.IR nan (3)).
+.MR nan (3) ).
.PP
Some of the functions in
.I libc
are system calls and many others employ system calls in their implementation.
All system calls return integers,
with \-1 indicating that an error occurred;
-.IR errstr (3)
+.MR errstr (3)
recovers a string describing the error.
Some user-level library functions also use the
.I errstr
diff --git a/man/man3/9p-cmdbuf.3 b/man/man3/9p-cmdbuf.3
index 6aca825bb..4ba3b6c81 100644
--- a/man/man3/9p-cmdbuf.3
+++ b/man/man3/9p-cmdbuf.3
@@ -44,7 +44,7 @@ bytes at
using
.I tokenize
(see
-.IR getfields (3)).
+.MR getfields (3) ).
It returns a
.B Cmdbuf
structure holding pointers to each field in the message.
@@ -116,4 +116,4 @@ is a good example.
.SH SOURCE
.B \*9/src/lib9p/parse.c
.SH SEE ALSO
-.IR 9p (3)
+.MR 9p (3)
diff --git a/man/man3/9p-fid.3 b/man/man3/9p-fid.3
index ddc3e093c..239f58ce0 100644
--- a/man/man3/9p-fid.3
+++ b/man/man3/9p-fid.3
@@ -73,7 +73,7 @@ and
.BR Reqpool s.
They are primarily used by the 9P server loop
described in
-.IR 9p (3).
+.MR 9p (3) .
.PP
.B Fid
structures are intended to represent
@@ -115,7 +115,7 @@ element points at a
.B File
structure
(see
-.IR 9p-file (3))
+.MR 9p-file (3) )
corresponding to the fid.
The
.B aux
@@ -200,5 +200,5 @@ structures.
.SH SOURCE
.B \*9/src/lib9p
.SH SEE ALSO
-.IR 9p (3),
-.IR 9p-file (3)
+.MR 9p (3) ,
+.MR 9p-file (3)
diff --git a/man/man3/9p-file.3 b/man/man3/9p-file.3
index 80866177d..e849f7134 100644
--- a/man/man3/9p-file.3
+++ b/man/man3/9p-file.3
@@ -144,7 +144,7 @@ When creating new file references by copying pointers,
call
.I incref
(see
-.IR lock (3))
+.MR lock (3) )
to update the reference count.
To note the removal of a reference to a file, call
.IR closefile .
@@ -218,6 +218,6 @@ return nf;
.SH SOURCE
.B \*9/src/lib9p/file.c
.SH SEE ALSO
-.IR 9p (3)
+.MR 9p (3)
.SH BUGS
The reference counting is cumbersome.
diff --git a/man/man3/9p-intmap.3 b/man/man3/9p-intmap.3
index 9d4dfef0b..486e18260 100644
--- a/man/man3/9p-intmap.3
+++ b/man/man3/9p-intmap.3
@@ -122,5 +122,5 @@ and
.SH SOURCE
.B \*9/src/lib9p/intmap.c
.SH SEE ALSO
-.IR 9p (3),
-.IR 9p-fid (3)
+.MR 9p (3) ,
+.MR 9p-fid (3)
diff --git a/man/man3/9p.3 b/man/man3/9p.3
index 6dc4c9c17..86b37fafe 100644
--- a/man/man3/9p.3
+++ b/man/man3/9p.3
@@ -6,7 +6,6 @@ emalloc9p,
erealloc9p,
estrdup9p,
postfd,
-postmountsrv,
readbuf,
readstr,
respond,
@@ -61,7 +60,6 @@ typedef struct Srv {
.ft L
.ta \w'\fLvoid* 'u
int srv(Srv *s)
-void postmountsrv(Srv *s, char *name, char *mtpt, int flag)
void threadpostmountsrv(Srv *s, char *name, char *mtpt, int flag)
int postfd(char *srvname, int fd)
void respond(Req *r, char *error)
@@ -96,8 +94,6 @@ and
writing the responses to
.BR s->outfd .
(Typically,
-.I postmountsrv
-or
.I threadpostmountsrv
initializes the
.B infd
@@ -110,13 +106,13 @@ and
.B Fid
structures are allocated one-to-one with uncompleted
requests and active fids, and are described in
-.IR 9p-fid (3).
+.MR 9p-fid (3) .
.PP
The behavior of
.I srv
depends on whether there is a file tree
(see
-.IR 9p-file (3))
+.MR 9p-file (3) )
associated with the server, that is,
whether the
.B tree
@@ -148,12 +144,10 @@ but abort the program if they run out of memory.
If alternate behavior is desired, clients can link against
alternate implementations of these functions.
.PP
-.I Postmountsrv
-and
.I threadpostmountsrv
-are wrappers that create a separate process in which to run
+is a wrapper that creates a separate process in which to run
.IR srv .
-They do the following:
+It does the following:
.IP
If
.IB s -> nopipe
@@ -178,11 +172,11 @@ as
.BI /srv/ name .
.IP
Fork a child process via
-.IR rfork (3)
+.MR rfork (3)
or
.I procrfork
(see
-.IR thread (3)),
+.MR thread (3) ),
using the
.BR RFFDG ,
.RR RFNOTEG ,
@@ -214,7 +208,7 @@ The parent returns to the caller.
.LP
If any error occurs during
this process, the entire process is terminated by calling
-.IR sysfatal (3).
+.MR sysfatal (3) .
.SS Service functions
The functions in a
.B Srv
@@ -296,9 +290,7 @@ the service functions.
The service loop provided by
.I srv
(and indirectly by
-.I postmountsrv
-and
-.IR threadpostmountsrv )
+.I threadpostmountsrv )
is single-threaded.
If it is expected that some requests might
block, arranging for alternate processes
@@ -332,7 +324,7 @@ where
is the program name variable as set by
.I ARGBEGIN
(see
-.IR arg (3)).
+.MR arg (3) ).
.TP
.I Attach
The
@@ -707,7 +699,7 @@ the service loop (which runs in a separate process
from its caller) terminates using
.I _exits
(see
-.IR exits (3)).
+.MR exits (3) ).
.PD
.PP
If the
@@ -752,6 +744,6 @@ or is maintained elsewhere.
.SH SOURCE
.B \*9/src/lib9p
.SH SEE ALSO
-.IR 9p-fid (3),
-.IR 9p-file (3),
+.MR 9p-fid (3) ,
+.MR 9p-file (3) ,
.IR intro (9p)
diff --git a/man/man3/9pclient.3 b/man/man3/9pclient.3
index 1bb868cce..74537ab40 100644
--- a/man/man3/9pclient.3
+++ b/man/man3/9pclient.3
@@ -149,7 +149,7 @@ connects to a service named
.I name
in the current name space directory
(see
-.IR intro (4)).
+.MR intro (4) ).
Both attach to the root of the file system
using the attach name
.IR aname .
@@ -228,7 +228,7 @@ the allocated structures will be freed and the
file descriptor corresponding to the connection
will be closed
(see
-.IR close (2)).
+.MR close (2) ).
Fids are not reference counted: when
.I fsclose
is called, the clunk transaction and freeing of storage
@@ -308,7 +308,7 @@ sets the offset; the
and
.I type
arguments are used as in
-.IR seek (3).
+.MR seek (3) .
Calling
.I fspread
or
@@ -340,7 +340,7 @@ for the given fid.
.PP
.I Fsaccess
behaves like Unix's
-.IR access (2).
+.MR access (2) .
.I Fsremove
removes the named path.
.I Fsfremove
@@ -358,7 +358,7 @@ are like
and
.I vfprint
(see
-.IR print (3))
+.MR print (3) )
but write to
.BR CFid* s.
.PP
@@ -376,7 +376,7 @@ is similar but reads the entire directory.
The returned pointer should be freed with
.I free
(see
-.IR malloc (3))
+.MR malloc (3) )
when no longer needed.
.PP
.I Fsdirfstat
@@ -396,7 +396,7 @@ structure returned by
should be freed with
.I free
(see
-.IR malloc (3))
+.MR malloc (3) )
when no longer needed.
.PP
.I Fsdirstat
@@ -418,7 +418,7 @@ opens a file on the 9P server
for reading or writing but returns a Unix file descriptor
instead of a fid structure.
The file descriptor is actually one end of a
-.IR pipe (2).
+.MR pipe (2) .
A proxy process on the other end is ferrying data
between the pipe and the 9P fid.
Because of the implementation as a pipe,
@@ -443,18 +443,18 @@ If the
flag is set, the library calls
.I threadexitsall
(see
-.IR thread (3))
+.MR thread (3) )
when it detects EOF on a 9P connection.
.SH SOURCE
.B \*9/src/lib9pclient
.SH SEE ALSO
-.IR intro (4),
+.MR intro (4) ,
.IR intro (9p),
.I fsaopen
and
.I nsaopen
in
-.IR auth (3)
+.MR auth (3)
.SH BUGS
The implementation
should use a special version string to distinguish between
diff --git a/man/man3/INDEX b/man/man3/INDEX
index 6654ea7c2..39e10b41a 100644
--- a/man/man3/INDEX
+++ b/man/man3/INDEX
@@ -50,7 +50,6 @@ emalloc9p 9p.3
erealloc9p 9p.3
estrdup9p 9p.3
postfd 9p.3
-postmountsrv 9p.3
readbuf 9p.3
readstr 9p.3
respond 9p.3
diff --git a/man/man3/acme.3 b/man/man3/acme.3
index 1683061a1..7c4ac67a7 100644
--- a/man/man3/acme.3
+++ b/man/man3/acme.3
@@ -141,7 +141,7 @@ char* evsmprint(char *fmt, va_list arg)
.SH DESCRIPTION
.I Libacme
provides a simple C interface for interacting with
-.IR acme (1)
+.MR acme (1)
windows.
.PP
A
@@ -168,7 +168,7 @@ Most of the library routines access files in the window's
.I acme
directory.
See
-.IR acme (4)
+.MR acme (4)
for details.
Many library routines take a format string
.I fmt
@@ -179,11 +179,11 @@ denotes the result of formatting the string and arguments
using
.I smprint
(see
-.IR print (3)).
+.MR print (3) ).
.PP
.I Pipetowin
runs the
-.IR rc (1)
+.MR rc (1)
command line
.I fmt\fR, \fP...
with
@@ -199,7 +199,7 @@ Otherwise the command inherits the caller's standard error.
.PP
.I Pipewinto
runs the
-.IR rc (1)
+.MR rc (1)
command line
.I fmt\fR, \fP...
with the window's
@@ -300,7 +300,7 @@ to position
relative to
.I type
(see
-.IR seek (3)).
+.MR seek (3) ).
.PP
.I Winwrite
writes the
@@ -317,7 +317,7 @@ The fields correspond to the fields in
.IR acme 's
event messages.
See
-.IR acme (4)
+.MR acme (4)
for detailed explanations.
The fields are:
.TP
@@ -384,7 +384,7 @@ that it should be handled internally.
returns a pointer to a
.B Channel
(see
-.IR thread (3))
+.MR thread (3) )
on which event structures (not pointers) can be read.
The first call to
.I wineventchan
@@ -404,20 +404,20 @@ after calling
and
.I evsmprint
are like
-.IR malloc (3),
+.MR malloc (3) ,
.IR realloc ,
.IR strdup
(see
-.IR strcat (3)),
+.MR strcat (3) ),
and
.IR vsmprint
(see
-.IR print (3)),
+.MR print (3) ),
but they call
-.IR sysfatal (3)
+.MR sysfatal (3)
on error rather than returning nil.
.SH SOURCE
.B \*9/src/libacme
.SH SEE ALSO
-.IR acme (1),
-.IR acme (4)
+.MR acme (1) ,
+.MR acme (4)
diff --git a/man/man3/addpt.3 b/man/man3/addpt.3
index c00a1de1c..74d19634b 100644
--- a/man/man3/addpt.3
+++ b/man/man3/addpt.3
@@ -185,4 +185,4 @@ They are implemented as macros.
.SH SOURCE
.B \*9/src/libdraw
.SH SEE ALSO
-.IR graphics (3)
+.MR graphics (3)
diff --git a/man/man3/aes.3 b/man/man3/aes.3
index 06f42de54..94ff54a70 100644
--- a/man/man3/aes.3
+++ b/man/man3/aes.3
@@ -39,13 +39,13 @@ cryptographically strongly unpredictable.
.SH SOURCE
.B \*9/src/libsec
.SH SEE ALSO
-.IR mp (3),
-.IR blowfish (3),
-.IR des (3),
-.IR dsa (3),
-.IR elgamal (3),
-.IR rc4 (3),
-.IR rsa (3),
-.IR sechash (3),
-.IR prime (3),
-.IR rand (3)
+.MR mp (3) ,
+.MR blowfish (3) ,
+.MR des (3) ,
+.MR dsa (3) ,
+.MR elgamal (3) ,
+.MR rc4 (3) ,
+.MR rsa (3) ,
+.MR sechash (3) ,
+.MR prime (3) ,
+.MR rand (3)
diff --git a/man/man3/allocimage.3 b/man/man3/allocimage.3
index 8bfd323dc..518d6b327 100644
--- a/man/man3/allocimage.3
+++ b/man/man3/allocimage.3
@@ -135,7 +135,7 @@ The
field will have been set to the identifying number used by
.B /dev/draw
(see
-.IR draw (3)),
+.MR draw (3) ),
and the
.I cache
field will be zero.
@@ -148,7 +148,7 @@ The
field will be set to the number of bits per pixel specified
by the channel descriptor
(see
-.IR image (7)).
+.MR image (7) ).
.I Allocimage
returns 0 if the server has run out of image memory.
.PP
@@ -191,7 +191,7 @@ These routines permit unrelated applications sharing a display to share an image
for example they provide the mechanism behind
.B getwindow
(see
-.IR graphics (3)).
+.MR graphics (3) ).
.PP
The RGB values in a color are
.I premultiplied
@@ -214,7 +214,7 @@ values between image and user space or external files.
There is a fixed format for the exchange and storage of
image data
(see
-.IR image (7)).
+.MR image (7) ).
.PP
.I Unloadimage
reads a rectangle of pixels from image
@@ -271,7 +271,7 @@ but for
bytes of compressed image
.I data
(see
-.IR image (7)).
+.MR image (7) ).
On each call to
.IR cloadimage,
the
@@ -289,7 +289,7 @@ return the number of bytes copied.
.PP
.I Readimage
creates an image from data contained in an external file (see
-.IR image (7)
+.MR image (7)
for the file format);
.I fd
is a file descriptor obtained by opening such a file for reading.
@@ -333,10 +333,10 @@ To allocate a single-pixel replicated image that may be used to paint a region r
.SH SOURCE
.B \*9/src/libdraw
.SH "SEE ALSO"
-.IR graphics (3),
-.IR draw (3),
-.IR draw (3),
-.IR image (7)
+.MR graphics (3) ,
+.MR draw (3) ,
+.MR draw (3) ,
+.MR image (7)
.SH DIAGNOSTICS
These functions return pointer 0 or integer \-1 on failure, usually due to insufficient
memory.
diff --git a/man/man3/arg.3 b/man/man3/arg.3
index 3124930dc..d9aa812ff 100644
--- a/man/man3/arg.3
+++ b/man/man3/arg.3
@@ -20,7 +20,7 @@ These macros assume the names
and
.I argv
are in scope; see
-.IR exec (3).
+.MR exec (3) .
.I ARGBEGIN
and
.I ARGEND
@@ -58,7 +58,7 @@ but instead of returning zero
runs
.I code
and, if that returns, calls
-.IR abort (3).
+.MR abort (3) .
A typical value for
.I code
is
diff --git a/man/man3/arith3.3 b/man/man3/arith3.3
index 1e764c7b9..039df33ec 100644
--- a/man/man3/arith3.3
+++ b/man/man3/arith3.3
@@ -266,4 +266,4 @@ Subtract the coordinates of two points.
.SH SOURCE
.B \*9/src/libgeometry
.SH "SEE ALSO
-.IR matrix (3)
+.MR matrix (3)
diff --git a/man/man3/atof.3 b/man/man3/atof.3
index 0da223796..8b462aa9d 100644
--- a/man/man3/atof.3
+++ b/man/man3/atof.3
@@ -129,7 +129,7 @@ after calling
.SH SOURCE
.B \*9/src/lib9
.SH SEE ALSO
-.IR fscanf (3)
+.MR fscanf (3)
.SH DIAGNOSTICS
Zero is returned if the beginning of the input string is not
interpretable as a number; even in this case,
@@ -175,4 +175,4 @@ are preprocessor macros defined as
and
.IR p9atoll ;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/auth.3 b/man/man3/auth.3
index 24189822e..9fda7de35 100644
--- a/man/man3/auth.3
+++ b/man/man3/auth.3
@@ -95,7 +95,7 @@ CFsys* nsamount(char *name, char *aname);
.SH DESCRIPTION
.PP
This library, in concert with
-.IR factotum (4),
+.MR factotum (4) ,
is used to authenticate users.
It provides the primary interface to
.IR factotum .
@@ -168,7 +168,7 @@ It provides the primary interface to
The following routines use the
.B AuthInfo
structure returned after a successful authentication by
-.IR factotum (4).
+.MR factotum (4) .
.PP
.ne 8
.EX
@@ -212,11 +212,11 @@ file, as opened by
An
.B sprint
(see
-.IR print (3))
+.MR print (3) )
of
.I fmt
and the variable arg list yields a key template (see
-.IR factotum (4))
+.MR factotum (4) )
specifying the key to use.
The template must specify at least the protocol (
.BI proto= xxx )
@@ -258,7 +258,7 @@ arranges a connection to
either by opening
.B /mnt/factotum/rpc
or by using
-.IR 9pclient (3)
+.MR 9pclient (3)
to connect to a
.B factotum
service posted in the current name space.
@@ -266,7 +266,7 @@ The returned connection
is freed using
.IR auth_freerpc .
Individual commands can be sent to
-.IR factotum (4)
+.MR factotum (4)
by invoking
.IR auth_rpc .
.PP
@@ -418,7 +418,7 @@ and
but execute the protocol on a
.B CFid*
(see
-.IR 9pclient (3))
+.MR 9pclient (3) )
instead of a file descriptor.
.PP
.I Fsamount
@@ -429,15 +429,15 @@ are like
and
.I nsmount
(see
-.IR 9pclient (3))
+.MR 9pclient (3) )
but use
.I factotum
to authenticate to the file servers.
.SH SOURCE
.B \*9/src/libauth
.SH SEE ALSO
-.IR factotum (4),
-.IR authsrv (3)
+.MR factotum (4) ,
+.MR authsrv (3)
.SH DIAGNOSTICS
These routines set
.IR errstr .
diff --git a/man/man3/authsrv.3 b/man/man3/authsrv.3
index a0b68578e..e1ace0c4c 100644
--- a/man/man3/authsrv.3
+++ b/man/man3/authsrv.3
@@ -68,7 +68,7 @@ If
is non-nil,
the network database
(see
-.IR ndb (1))
+.MR ndb (1) )
is queried for an entry which contains
.B authdom=\fIad\fP
or
@@ -212,10 +212,10 @@ to recieve an answer.
.SH SOURCE
.B \*9/src/libauthsrv
.SH SEE ALSO
-.IR passwd (1),
-.IR dial (3),
+.MR passwd (1) ,
+.MR dial (3) ,
Plan 9's
-\fIauthsrv\fR(6).
+.IR authsrv (6).
.SH DIAGNOSTICS
These routines set
.IR errstr .
diff --git a/man/man3/bin.3 b/man/man3/bin.3
index c888193f8..e86854943 100644
--- a/man/man3/bin.3
+++ b/man/man3/bin.3
@@ -82,7 +82,7 @@ are ignored, and the result is the same as calling
and
.I bingrow
allocate large chunks of memory using
-.IR malloc (3)
+.MR malloc (3)
and return pieces of these chunks.
The chunks are
.IR free 'd
@@ -91,7 +91,7 @@ upon a call to
.SH SOURCE
.B \*9/src/libbin
.SH SEE ALSO
-.IR malloc (3)
+.MR malloc (3)
.SH DIAGNOSTICS
.I binalloc
and
diff --git a/man/man3/bio.3 b/man/man3/bio.3
index 0c48bea6e..05721f8b3 100644
--- a/man/man3/bio.3
+++ b/man/man3/bio.3
@@ -93,7 +93,7 @@ for mode
or creates for mode
.BR OWRITE .
It calls
-.IR malloc (3)
+.MR malloc (3)
to allocate a buffer.
.PP
.I Bfdopen
@@ -104,7 +104,7 @@ for mode
or
.BR OWRITE .
It calls
-.IR malloc (3)
+.MR malloc (3)
to allocate a buffer.
.PP
.I Binit
@@ -173,7 +173,7 @@ of the most recent string returned by
.PP
.I Brdstr
returns a
-.IR malloc (3)-allocated
+.MR malloc (3) -allocated
buffer containing the next line of input delimited by
.IR delim ,
terminated by a NUL (0) byte.
@@ -225,7 +225,7 @@ may back up a maximum of five bytes.
uses
.I charstod
(see
-.IR atof (3))
+.MR atof (3) )
and
.I Bgetc
to read the formatted
@@ -246,7 +246,7 @@ and a negative value is returned if a read error occurred.
.PP
.I Bseek
applies
-.IR seek (3)
+.MR seek (3)
to
.IR bp .
It returns the new file offset.
@@ -278,7 +278,7 @@ on the output stream.
.PP
.I Bprint
is a buffered interface to
-.IR print (3).
+.MR print (3) .
If this causes a
.IR write
to occur and there is an error,
@@ -325,10 +325,10 @@ written.
.SH SOURCE
.B \*9/src/libbio
.SH SEE ALSO
-.IR open (3),
-.IR print (3),
-.IR exits (3),
-.IR utf (7),
+.MR open (3) ,
+.MR print (3) ,
+.MR exits (3) ,
+.MR utf (7) ,
.SH DIAGNOSTICS
.I Bio
routines that return integers yield
diff --git a/man/man3/blowfish.3 b/man/man3/blowfish.3
index 20d43f662..95d775072 100644
--- a/man/man3/blowfish.3
+++ b/man/man3/blowfish.3
@@ -40,13 +40,13 @@ must be a multiple of eight bytes as padding is currently unsupported.
.SH SOURCE
.B \*9/src/libsec
.SH SEE ALSO
-.IR mp (3),
-.IR aes (3),
-.IR des (3),
-.IR dsa (3),
-.IR elgamal (3),
-.IR rc4 (3),
-.IR rsa (3),
-.IR sechash (3),
-.IR prime (3),
-.IR rand (3)
+.MR mp (3) ,
+.MR aes (3) ,
+.MR des (3) ,
+.MR dsa (3) ,
+.MR elgamal (3) ,
+.MR rc4 (3) ,
+.MR rsa (3) ,
+.MR sechash (3) ,
+.MR prime (3) ,
+.MR rand (3)
diff --git a/man/man3/cachechars.3 b/man/man3/cachechars.3
index b0c7abfac..1b2cc5b06 100644
--- a/man/man3/cachechars.3
+++ b/man/man3/cachechars.3
@@ -30,7 +30,7 @@ A
may contain too many characters to hold in memory
simultaneously.
The graphics library and draw device (see
-.IR draw (3))
+.MR draw (3) )
cooperate to solve this problem by maintaining a cache of recently used
character images.
The details of this cooperation need not be known by most programs:
@@ -127,7 +127,7 @@ A
.B Font
consists of an overall height and ascent
and a collection of subfonts together with the ranges of runes (see
-.IR utf (7))
+.MR utf (7) )
they represent.
Fonts are described by the following structures.
.IP
@@ -165,7 +165,7 @@ struct Font {
short height; /* max ht of image;interline space*/
short ascent; /* top of image to baseline */
short width; /* widest so far; used in caching */
- short nsub; /* number of subfonts */
+ int nsub; /* number of subfonts */
ulong age; /* increasing counter; for LRU */
int ncache; /* size of cache */
int nsubf; /* size of subfont list */
@@ -181,7 +181,7 @@ The
and
.LR ascent
fields of Font are described in
-.IR graphics (3).
+.MR graphics (3) .
.L Sub
contains
.L nsub
@@ -302,12 +302,12 @@ for replacement when the cache is full.
.SH SOURCE
.B \*9/src/libdraw
.SH SEE ALSO
-.IR graphics (3),
-.IR allocimage (3),
-.IR draw (3),
-.IR subfont (3),
-.IR image (7),
-.IR font (7)
+.MR graphics (3) ,
+.MR allocimage (3) ,
+.MR draw (3) ,
+.MR subfont (3) ,
+.MR image (7) ,
+.MR font (7)
.SH DIAGNOSTICS
All of the functions use the graphics error function (see
-.IR graphics (3)).
+.MR graphics (3) ).
diff --git a/man/man3/cleanname.3 b/man/man3/cleanname.3
index efb7d8231..75fdd8058 100644
--- a/man/man3/cleanname.3
+++ b/man/man3/cleanname.3
@@ -31,4 +31,4 @@ must contain room for at least two bytes.
.SH SOURCE
.B \*9/src/lib9/cleanname.c
.SH SEE ALSO
-.IR cleanname (1)
+.MR cleanname (1)
diff --git a/man/man3/color.3 b/man/man3/color.3
index 5428337b3..e08d91949 100644
--- a/man/man3/color.3
+++ b/man/man3/color.3
@@ -19,7 +19,7 @@ int cmap2rgba(int col)
.SH DESCRIPTION
These routines convert between `true color' red/green/blue triples and the Plan 9 color map.
See
-.IR color (7)
+.MR color (7)
for a description of RGBV, the standard color map.
.PP
.I Rgb2cmap
@@ -41,16 +41,16 @@ and the next 8 representing blue, then green, then red, as for
.I cmap2rgba
shifted up 8 bits.
This 32-bit representation is the format used by
-.IR draw (3)
+.MR draw (3)
and
-.IR memdraw (3)
+.MR memdraw (3)
library routines that
take colors as arguments.
.SH SOURCE
.B \*9/src/libdraw
.SH SEE ALSO
-.IR graphics (3),
-.IR allocimage (3),
-.IR draw (3),
-.IR image (7),
-.IR color (7)
+.MR graphics (3) ,
+.MR allocimage (3) ,
+.MR draw (3) ,
+.MR image (7) ,
+.MR color (7)
diff --git a/man/man3/complete.3 b/man/man3/complete.3
index 52702acca..f1d0c2803 100644
--- a/man/man3/complete.3
+++ b/man/man3/complete.3
@@ -86,15 +86,15 @@ function frees a
structure and its contents.
.PP
In
-.IR rio (1)
+.MR rio (1)
and
-.IR acme (1),
+.MR acme (1) ,
file name completion is triggered by a control-F character or an Insert character.
.SH SOURCE
.B \*9/src/libcomplete
.SH SEE ALSO
-.IR rio (1),
-.IR acme (1)
+.MR rio (1) ,
+.MR acme (1)
.SH DIAGNOSTICS
The
.I complete
diff --git a/man/man3/ctime.3 b/man/man3/ctime.3
index 5491d39fd..5d80d4118 100644
--- a/man/man3/ctime.3
+++ b/man/man3/ctime.3
@@ -26,7 +26,7 @@ long tm2sec(Tm *tm)
converts a time
.I clock
such as returned by
-.IR time (3)
+.MR time (3)
into
.SM ASCII
(sic)
@@ -85,8 +85,8 @@ is not
.br
.B \*9/src/lib9/tm2sec.c
.SH "SEE ALSO"
-.IR date (1),
-.IR time (3)
+.MR date (1) ,
+.MR time (3)
.SH BUGS
The return values point to static data
whose content is overwritten by each call.
@@ -112,4 +112,4 @@ are preprocessor macros defined as
and
.IR p9tm2sec ;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/des.3 b/man/man3/des.3
index 3c3cd2014..686fc4c9e 100644
--- a/man/man3/des.3
+++ b/man/man3/des.3
@@ -132,13 +132,13 @@ using
.SH SOURCE
.B \*9/src/libsec
.SH SEE ALSO
-.IR mp (3),
-.IR aes (3),
-.IR blowfish (3),
-.IR dsa (3),
-.IR elgamal (3),
-.IR rc4 (3),
-.IR rsa (3),
-.IR sechash (3),
-.IR prime (3),
-.IR rand (3)
+.MR mp (3) ,
+.MR aes (3) ,
+.MR blowfish (3) ,
+.MR dsa (3) ,
+.MR elgamal (3) ,
+.MR rc4 (3) ,
+.MR rsa (3) ,
+.MR sechash (3) ,
+.MR prime (3) ,
+.MR rand (3)
diff --git a/man/man3/dial.3 b/man/man3/dial.3
index 39092ae09..24efc7023 100644
--- a/man/man3/dial.3
+++ b/man/man3/dial.3
@@ -264,7 +264,7 @@ int callkremvax(void)
.EE
.PP
Connect to a Unix socket served by
-.IR acme (4):
+.MR acme (4) :
.IP
.EX
int dialacme(void)
@@ -346,4 +346,4 @@ are preprocessor macros defined as
.IR p9announce ,
and so on;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/dirread.3 b/man/man3/dirread.3
index 2522e9a69..cce8d9785 100644
--- a/man/man3/dirread.3
+++ b/man/man3/dirread.3
@@ -19,11 +19,11 @@ long dirreadall(int fd, Dir **buf)
#define DIRMAX (sizeof(Dir)+STATMAX)
.SH DESCRIPTION
The data returned by a
-.IR read (3)
+.MR read (3)
on a directory is a set of complete directory entries
in a machine-independent format, exactly equivalent to
the result of a
-.IR stat (3)
+.MR stat (3)
on each file or subdirectory in the directory.
.I Dirread
decodes the directory entries into a machine-dependent form.
@@ -35,11 +35,11 @@ structures
whose address is returned in
.B *buf
(see
-.IR stat (3)
+.MR stat (3)
for the layout of a
.BR Dir ).
The array is allocated with
-.IR malloc (3)
+.MR malloc (3)
each time
.I dirread
is called.
@@ -50,7 +50,7 @@ is like
but reads in the entire directory; by contrast,
.I dirread
steps through a directory one
-.IR read (3)
+.MR read (3)
at a time.
.PP
Directory entries have variable length.
@@ -85,9 +85,9 @@ The file offset is advanced by the number of bytes actually read.
.SH SOURCE
.B \*9/src/lib9/dirread.c
.SH SEE ALSO
-.IR intro (3),
-.IR open (3),
-.IR read (3)
+.MR intro (3) ,
+.MR open (3) ,
+.MR read (3)
.SH DIAGNOSTICS
.I Dirread
and
diff --git a/man/man3/draw.3 b/man/man3/draw.3
index 1fa5dea1d..4ad680b33 100644
--- a/man/man3/draw.3
+++ b/man/man3/draw.3
@@ -259,7 +259,7 @@ The clipping region may be modified dynamically using
.TP
.B chan
The pixel channel format descriptor, as described in
-.IR image (7).
+.MR image (7) .
The value should not be modified after the image is created.
.TP
.B depth
@@ -268,7 +268,7 @@ number of bits per pixel in the picture;
it is identically
.B chantodepth(chan)
(see
-.IR graphics (3))
+.MR graphics (3) )
and is provided as a convenience.
The value should not be modified after the image is created.
.TP
@@ -712,7 +712,7 @@ what
is to
.B atan
(see
-.IR sin (3)).
+.MR sin (3) ).
.TP
.BI border( dst\fP,\fP\ r\fP,\fP\ i\fP,\fP\ color\fP,\fP\ sp\fP)
.I Border
@@ -810,11 +810,11 @@ is non-zero.
.SH SOURCE
.B \*9/src/libdraw
.SH SEE ALSO
-.IR graphics (3),
-.IR stringsize (3),
-.IR color (7),
-.IR utf (7),
-.IR addpt (3)
+.MR graphics (3) ,
+.MR stringsize (3) ,
+.MR color (7) ,
+.MR utf (7) ,
+.MR addpt (3)
.PP
T. Porter, T. Duff.
``Compositing Digital Images'',
diff --git a/man/man3/drawfcall.3 b/man/man3/drawfcall.3
index 1c8d376b1..1ee37cd8c 100644
--- a/man/man3/drawfcall.3
+++ b/man/man3/drawfcall.3
@@ -30,15 +30,15 @@ int readwsysmsg(int fd, uchar *buf, uint nbuf)
uint sizeW2M(Wsysmsg *w)
.SH DESCRIPTION
These routines are analogues of the routines described in
-.IR fcall (3).
+.MR fcall (3) .
They manipulate graphics device protocol messages
rather than 9P protocol messages.
The graphics device protocol is used for internal
communication between the
-.IR devdraw (1)
+.MR devdraw (1)
graphics server
and the
-.IR draw (3)
+.MR draw (3)
library.
A
.B Wsysmsg
@@ -48,6 +48,6 @@ The protocol is intentionally undocumented and may change.
.SH SOURCE
.B \*9/src/libdraw/drawfcall.c
.SH SEE ALSO
-.IR devdraw (1),
-.IR draw (3),
-.IR graphics (3)
+.MR devdraw (1) ,
+.MR draw (3) ,
+.MR graphics (3)
diff --git a/man/man3/dsa.3 b/man/man3/dsa.3
index 41532b89e..787140101 100644
--- a/man/man3/dsa.3
+++ b/man/man3/dsa.3
@@ -84,7 +84,7 @@ and
generated by
.IR DSAprimes
(see
-.IR prime (3)).
+.MR prime (3) ).
Otherwise,
.B p
and
@@ -128,17 +128,17 @@ are provided to manage signature storage.
converts an ASN1 formatted DSA private key into the corresponding
.B DSApriv
structure; see
-.IR rsa (3)
+.MR rsa (3)
for other ASN1 routines.
.SH SOURCE
.B \*9/src/libsec
.SH SEE ALSO
-.IR mp (3),
-.IR aes (3),
-.IR blowfish (3),
-.IR des (3),
-.IR rc4 (3),
-.IR rsa (3),
-.IR sechash (3),
-.IR prime (3),
-.IR rand (3)
+.MR mp (3) ,
+.MR aes (3) ,
+.MR blowfish (3) ,
+.MR des (3) ,
+.MR rc4 (3) ,
+.MR rsa (3) ,
+.MR sechash (3) ,
+.MR prime (3) ,
+.MR rand (3)
diff --git a/man/man3/dup.3 b/man/man3/dup.3
index 392e6fe63..268873630 100644
--- a/man/man3/dup.3
+++ b/man/man3/dup.3
@@ -36,4 +36,4 @@ To avoid name conflicts with the underlying system,
is a preprocessor macro defined as
.IR p9dup ;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/elgamal.3 b/man/man3/elgamal.3
index 2fc75ac64..af4bc03b6 100644
--- a/man/man3/elgamal.3
+++ b/man/man3/elgamal.3
@@ -113,13 +113,13 @@ are provided to manage signature storage.
.SH SOURCE
.B \*9/src/libsec
.SH SEE ALSO
-.IR mp (3),
-.IR aes (3),
-.IR blowfish (3),
-.IR des (3),
-.IR dsa (3),
-.IR rc4 (3),
-.IR rsa (3),
-.IR sechash (3),
-.IR prime (3),
-.IR rand (3)
+.MR mp (3) ,
+.MR aes (3) ,
+.MR blowfish (3) ,
+.MR des (3) ,
+.MR dsa (3) ,
+.MR rc4 (3) ,
+.MR rsa (3) ,
+.MR sechash (3) ,
+.MR prime (3) ,
+.MR rand (3)
diff --git a/man/man3/encode.3 b/man/man3/encode.3
index fde8296c8..57b5cd081 100644
--- a/man/man3/encode.3
+++ b/man/man3/encode.3
@@ -49,9 +49,9 @@ of 8.
.PP
.I Encodefmt
can be used with
-.IR fmtinstall (3)
+.MR fmtinstall (3)
and
-.IR print (3)
+.MR print (3)
to print encoded representations of byte arrays.
The verbs are
.TP
diff --git a/man/man3/encrypt.3 b/man/man3/encrypt.3
index 1f44689d3..894020d87 100644
--- a/man/man3/encrypt.3
+++ b/man/man3/encrypt.3
@@ -84,4 +84,4 @@ are preprocessor macros defined as
and
.IR p9decrypt ;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/errstr.3 b/man/man3/errstr.3
index 3964d8d5c..703f2ee08 100644
--- a/man/man3/errstr.3
+++ b/man/man3/errstr.3
@@ -53,7 +53,7 @@ the result is an empty string.
The verb
.B r
in
-.IR print (3)
+.MR print (3)
calls
.I errstr
and outputs the error string.
@@ -92,8 +92,8 @@ will reset
.I Errstr
always returns 0.
.SH SEE ALSO
-.IR intro (3),
-.IR perror (3)
+.MR intro (3) ,
+.MR perror (3)
.SH BUGS
The implementation sets
.I errno
@@ -104,4 +104,4 @@ When
.I errno
is set to other values, the error string
is synthesized using
-.IR strerror (3).
+.MR strerror (3) .
diff --git a/man/man3/event.3 b/man/man3/event.3
index 5991a17d3..f76e5ea27 100644
--- a/man/man3/event.3
+++ b/man/man3/event.3
@@ -93,12 +93,12 @@ enum{
These routines provide an interface to multiple sources of input for unthreaded
programs.
Threaded programs (see
-.IR thread (3))
+.MR thread (3) )
should instead use the threaded mouse and keyboard interface described
in
-.IR mouse (3)
+.MR mouse (3)
and
-.IR keyboard (3).
+.MR keyboard (3) .
.PP
.I Einit
must be called first.
@@ -113,7 +113,7 @@ the mouse and keyboard events will be enabled;
in this case,
.IR initdraw
(see
-.IR graphics (3))
+.MR graphics (3) )
must have already been called.
The user must provide a function called
.IR eresized
@@ -123,7 +123,7 @@ is running has been resized; the argument
is a flag specifying whether the program must call
.I getwindow
(see
-.IR graphics (3))
+.MR graphics (3) )
to re-establish a connection to its window.
After resizing (and perhaps calling
.IR getwindow ),
@@ -266,7 +266,7 @@ The return is the same as for
.IR eread .
.PP
As described in
-.IR graphics (3),
+.MR graphics (3) ,
the graphics functions are buffered.
.IR Event ,
.IR eread ,
@@ -370,15 +370,15 @@ changes the cursor image to that described by the
.B Cursor
.I c
(see
-.IR mouse (3)).
+.MR mouse (3) ).
If
.B c
is nil, it restores the image to the default arrow.
.SH SOURCE
.B \*9/src/libdraw
.SH "SEE ALSO"
-.IR rio (1),
-.IR graphics (3),
-.IR plumb (3),
+.MR rio (1) ,
+.MR graphics (3) ,
+.MR plumb (3) ,
.\" .IR cons (3),
-.IR draw (3)
+.MR draw (3)
diff --git a/man/man3/exec.3 b/man/man3/exec.3
index 1a0a8a871..51096cc91 100644
--- a/man/man3/exec.3
+++ b/man/man3/exec.3
@@ -25,11 +25,11 @@ points to the name of the file
to be executed; it must not be a directory, and the permissions
must allow the current user to execute it
(see
-.IR stat (3)).
+.MR stat (3) ).
It should also be a valid binary image, as defined by the local
operating system, or a shell script
(see
-.IR rc (1)).
+.MR rc (1) ).
The first line of a
shell script must begin with
.L #!
@@ -92,24 +92,24 @@ files remain open across
.B OCEXEC
OR'd
into the open mode; see
-.IR open (3));
+.MR open (3) );
and the working directory and environment
(see
-.IR getenv (3))
+.MR getenv (3) )
remain the same.
However, a newly
.I exec'ed
process has no notification handlers
(see
-.IR notify (3)).
+.MR notify (3) ).
.SH SOURCE
.B \*9/src/lib9/exec.c
.br
.B \*9/src/lib9/execl.c
.SH SEE ALSO
-.IR prof (1),
-.IR intro (3),
-.IR stat (3)
+.MR prof (1) ,
+.MR intro (3) ,
+.MR stat (3)
.SH DIAGNOSTICS
If these functions fail, they return and set
.IR errstr .
@@ -138,4 +138,4 @@ are preprocessor macros defined as
and
.IR p9execl ;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/exits.3 b/man/man3/exits.3
index 1bab40af8..2f4b1f4fc 100644
--- a/man/man3/exits.3
+++ b/man/man3/exits.3
@@ -39,7 +39,7 @@ explanation of the reason for
exiting, or a null pointer or empty string to indicate normal termination.
The string is passed to the parent process, prefixed by the name and process
id of the exiting process, when the parent does a
-.IR wait (3).
+.MR wait (3) .
.PP
Before calling
.I _exits
@@ -85,8 +85,8 @@ cancels a previous registration of an exit function.
.br
.B \*9/src/lib9/_exits.c
.SH "SEE ALSO"
-.IR fork (2),
-.IR wait (3)
+.MR fork (2) ,
+.MR wait (3)
.SH BUGS
Because of limitations of Unix, the exit status of a
process can only be an 8-bit integer.
@@ -117,4 +117,4 @@ are preprocessor macros defined as
and
.IR p9atexitdont ;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/fcall.3 b/man/man3/fcall.3
index fe696a4ba..5e9bd1958 100644
--- a/man/man3/fcall.3
+++ b/man/man3/fcall.3
@@ -225,7 +225,7 @@ by a successful call to
Another structure is
.BR Dir ,
used by the routines described in
-.IR stat (3).
+.MR stat (3) .
.I ConvM2D
converts the machine-independent form starting at
.I ap
@@ -293,7 +293,7 @@ contain a validly formatted machine-independent
entry suitable as an argument, for example, for the
.B wstat
(see
-.IR stat (3))
+.MR stat (3) )
system call.
It checks that the sizes of all the elements of the the entry sum to exactly
.IR nbuf ,
@@ -321,7 +321,7 @@ for an incorrectly formatted entry.
and
.I dirmodefmt
are formatting routines, suitable for
-.IR fmtinstall (3).
+.MR fmtinstall (3) .
They convert
.BR Dir* ,
.BR Fcall* ,
@@ -343,7 +343,7 @@ with format letter
.PP
.I Read9pmsg
calls
-.IR read (3)
+.MR read (3)
multiple times, if necessary, to read an entire 9P message into
.BR buf .
The return value is 0 for end of file, or -1 for error; it does not return
@@ -351,7 +351,7 @@ partial messages.
.SH SOURCE
.B \*9/src/lib9
.SH SEE ALSO
-.IR intro (3),
-.IR 9p (3),
-.IR stat (3),
+.MR intro (3) ,
+.MR 9p (3) ,
+.MR stat (3) ,
.IR intro (9p)
diff --git a/man/man3/flate.3 b/man/man3/flate.3
index b7b1a1975..81f82dcf3 100644
--- a/man/man3/flate.3
+++ b/man/man3/flate.3
@@ -173,7 +173,7 @@ The block functions return the number of bytes produced when they succeed.
.I Mkcrctab
allocates
(using
-.IR malloc (3)),
+.MR malloc (3) ),
initializes, and returns a table for rapid computation of 32 bit CRC values using the polynomial
.IR poly .
.I Blockcrc
diff --git a/man/man3/fmtinstall.3 b/man/man3/fmtinstall.3
index da766d776..b68cd008c 100644
--- a/man/man3/fmtinstall.3
+++ b/man/man3/fmtinstall.3
@@ -94,16 +94,16 @@ int fmtrunestrcpy(Fmt *f, Rune *s);
int errfmt(Fmt *f);
.SH DESCRIPTION
The interface described here allows the construction of custom
-.IR print (3)
+.MR print (3)
verbs and output routines.
In essence, they provide access to the workings of the formatted print code.
.PP
The
-.IR print (3)
+.MR print (3)
suite maintains its state with a data structure called
.BR Fmt .
A typical call to
-.IR print (3)
+.MR print (3)
or its relatives initializes a
.B Fmt
structure, passes it to subsidiary routines to process the output,
@@ -154,7 +154,7 @@ to generate the output.
These behave like
.B fprint
(see
-.IR print (3))
+.MR print (3) )
or
.B vfprint
except that the characters are buffered until
@@ -207,7 +207,7 @@ In
are the width and precision, and
.IB fp ->flags
the decoded flags for the verb (see
-.IR print (3)
+.MR print (3)
for a description of these items).
The standard flag values are:
.B FmtSign
@@ -282,7 +282,7 @@ produced.
.PP
Some internal functions may be useful to format primitive types.
They honor the width, precision and flags as described in
-.IR print (3).
+.MR print (3) .
.I Fmtrune
formats a single character
.BR r .
@@ -307,7 +307,7 @@ regardless of whether the output is bytes or runes.
This function prints an error message with a variable
number of arguments and then quits.
Compared to the corresponding example in
-.IR print (3),
+.MR print (3) ,
this version uses a smaller buffer, will never truncate
the output message, but might generate multiple
.B write
@@ -364,9 +364,9 @@ main(...)
.SH SOURCE
.B \*9/src/lib9/fmt
.SH SEE ALSO
-.IR print (3),
-.IR utf (7),
-.IR errstr (3)
+.MR print (3) ,
+.MR utf (7) ,
+.MR errstr (3)
.SH DIAGNOSTICS
These routines return negative numbers or nil for errors and set
.IR errstr .
diff --git a/man/man3/frame.3 b/man/man3/frame.3
index 1e063802c..4b027acb3 100644
--- a/man/man3/frame.3
+++ b/man/man3/frame.3
@@ -73,9 +73,9 @@ enum{
This library supports
.I frames
of editable text in a single font on raster displays, such as in
-.IR sam (1)
+.MR sam (1)
and
-.IR 9term (1).
+.MR 9term (1) .
Frames may hold any character except NUL (0).
Long lines are folded and tabs are at fixed intervals.
.PP
@@ -239,7 +239,7 @@ If a
.B Frame
is being moved but not resized, that is, if the shape of its containing
rectangle is unchanged, it is sufficient to use
-.IR draw (3)
+.MR draw (3)
to copy the containing rectangle from the old to the new location and then call
.I frsetrects
to establish the new geometry.
@@ -357,6 +357,6 @@ and
.SH SOURCE
.B \*9/src/libframe
.SH SEE ALSO
-.IR graphics (3),
-.IR draw (3),
-.IR cachechars (3).
+.MR graphics (3) ,
+.MR draw (3) ,
+.MR cachechars (3) .
diff --git a/man/man3/genrandom.3 b/man/man3/genrandom.3
index ddf481e4c..b58756353 100644
--- a/man/man3/genrandom.3
+++ b/man/man3/genrandom.3
@@ -25,11 +25,11 @@ number generator. The X9.17 generator is seeded by 24
truly random bytes read via
.I truerand
(see
-.IR rand (3)).
+.MR rand (3) ).
.PP
.I Prng
uses the native
-.IR rand (3)
+.MR rand (3)
pseudo-random number generator to fill the buffer. Used with
.IR srand ,
this function can produce a reproducible stream of pseudo random
@@ -38,8 +38,8 @@ numbers useful in testing.
Both functions may be passed to
.I mprand
(see
-.IR mp (3)).
+.MR mp (3) ).
.SH SOURCE
.B \*9/src/libsec
.SH SEE ALSO
-.IR mp (3)
+.MR mp (3)
diff --git a/man/man3/get9root.3 b/man/man3/get9root.3
index 52fb6f094..a6bdd02f8 100644
--- a/man/man3/get9root.3
+++ b/man/man3/get9root.3
@@ -49,7 +49,7 @@ if different from
should be freed with
.I free
(see
-.IR malloc (3))
+.MR malloc (3) )
when no longer needed.
.PP
As a convention, programs should never
@@ -57,7 +57,7 @@ As a convention, programs should never
paths obtained from user input.
.SH EXAMPLE
The
-.IR plumber (4)
+.MR plumber (4)
uses this code to find unrooted file names included by plumb rules.
.IP
.EX
@@ -69,7 +69,7 @@ fd = open(unsharp(buf), OREAD);
.br
.B \*9/src/lib9/unsharp.c
.SH SEE ALSO
-.IR intro (4)
+.MR intro (4)
.SH BUGS
.I Get9root
could be smarter about finding the tree when
diff --git a/man/man3/getenv.3 b/man/man3/getenv.3
index a817b6ef7..a37cb6595 100644
--- a/man/man3/getenv.3
+++ b/man/man3/getenv.3
@@ -18,7 +18,7 @@ int putenv(char *name, char *val)
fetches the environment value associated with
.I name
into memory allocated with
-.IR malloc (3),
+.MR malloc (3) ,
0-terminates it,
and returns a pointer to that area.
If no file exists, 0
@@ -44,4 +44,4 @@ are preprocessor macros defined as
and
.IR p9putenv ;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/getfields.3 b/man/man3/getfields.3
index feaf10d85..79a1ed786 100644
--- a/man/man3/getfields.3
+++ b/man/man3/getfields.3
@@ -75,9 +75,9 @@ with
non-zero,
except that fields may be quoted using single quotes, in the manner
of
-.IR rc (1).
+.MR rc (1) .
See
-.IR quote (3)
+.MR quote (3)
for related quote-handling software.
.PP
.I Tokenize
@@ -91,5 +91,5 @@ set to \f5"\et\er\en "\fP.
.SH SEE ALSO
.I strtok
in
-.IR strcat (3),
-.IR quote (3).
+.MR strcat (3) ,
+.MR quote (3) .
diff --git a/man/man3/getns.3 b/man/man3/getns.3
index b2e03f93d..6d0a5a9c2 100644
--- a/man/man3/getns.3
+++ b/man/man3/getns.3
@@ -14,9 +14,9 @@ returns a pointer to a malloced string that contains the
path to the name space directory for the current process.
The name space directory is a clumsy substitute
for Plan 9's per-process name spaces; see
-.IR intro (4)
+.MR intro (4)
for details.
.SH SOURCE
.B \*9/src/lib9/getns.c
.SH SEE ALSO
-.IR intro (4)
+.MR intro (4)
diff --git a/man/man3/getsnarf.3 b/man/man3/getsnarf.3
index 938aae3f2..30d220828 100644
--- a/man/man3/getsnarf.3
+++ b/man/man3/getsnarf.3
@@ -20,7 +20,7 @@ returns a copy of the current buffer;
the returned pointer should be freed with
.I free
(see
-.IR malloc (3))
+.MR malloc (3) )
when no longer needed.
.PP
.I Putsnarf
@@ -36,4 +36,4 @@ will convert as necessary.
.SH SOURCE
.B \*9/src/libdraw/snarf.c
.SH SEE ALSO
-.IR snarfer (1)
+.MR snarfer (1)
diff --git a/man/man3/getuser.3 b/man/man3/getuser.3
index 41e78e3d9..45531b4c1 100644
--- a/man/man3/getuser.3
+++ b/man/man3/getuser.3
@@ -19,7 +19,7 @@ name of the user who
owns the current process.
.I Getuser
calls
-.IR getuid (2)
+.MR getuid (2)
and then reads
.B /etc/passwd
to find the corresponding name.
@@ -33,7 +33,7 @@ looks first for an environment variable
If there is no such variable,
.I sysname
calls
-.IR gethostname (2)
+.MR gethostname (2)
and truncates the returned name at the first dot.
If
.I gethostname
diff --git a/man/man3/getwd.3 b/man/man3/getwd.3
index 245914f34..f9ef1949b 100644
--- a/man/man3/getwd.3
+++ b/man/man3/getwd.3
@@ -23,10 +23,10 @@ bytes in the buffer provided.
.SH SOURCE
.B \*9/src/lib9/getwd.c
.SH "SEE ALSO"
-.IR pwd (1)
+.MR pwd (1)
.SH DIAGNOSTICS
On error, zero is returned.
-.IR Errstr (3)
+.MR Errstr (3)
may be consulted for more information.
.SH BUGS
To avoid name conflicts with the underlying system,
@@ -34,4 +34,4 @@ To avoid name conflicts with the underlying system,
is a preprocessor macro defined as
.IR p9getwd ;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/graphics.3 b/man/man3/graphics.3
index a2b2d8480..da0b61cfd 100644
--- a/man/man3/graphics.3
+++ b/man/man3/graphics.3
@@ -1,6 +1,6 @@
.TH GRAPHICS 3
.SH NAME
-Display, Point, Rectangle, Cursor, initdraw, geninitdraw, drawerror, initdisplay, closedisplay, getdefont, getwindow, gengetwindow, flushimage, bufimage, lockdisplay, unlockdisplay, cursorswitch, cursorset, openfont, buildfont, freefont, Pfmt, Rfmt, strtochan, chantostr, chantodepth \- interactive graphics
+Display, Point, Rectangle, Cursor, initdraw, geninitdraw, drawerror, initdisplay, closedisplay, getwindow, gengetwindow, flushimage, bufimage, lockdisplay, unlockdisplay, cursorswitch, cursorset, openfont, buildfont, freefont, Pfmt, Rfmt, strtochan, chantostr, chantodepth \- interactive graphics
.SH SYNOPSIS
.nf
.PP
@@ -38,9 +38,6 @@ Display* initdisplay(char *devdir, char *win, void(*errfun)(Display*, char*))
void closedisplay(Display *d)
.PP
.B
-Font* getdefont(Display *d)
-.PP
-.B
int flushimage(Display *d, int vis)
.PP
.B
@@ -110,7 +107,7 @@ extern Font *font
A
.B Display
structure represents a connection to the graphics device,
-.IR draw (3),
+.MR draw (3) ,
holding all graphics resources associated with the connection,
including in particular raster image data in use by the client program.
The structure is defined (in part) as:
@@ -138,7 +135,7 @@ A
.B Point
is a location in an Image
(see below and
-.IR draw (3)),
+.MR draw (3) ),
such as the display, and is defined as:
.IP
.EX
@@ -187,18 +184,18 @@ contains the coordinates of the first point beyond the rectangle.
The
.B Image
data structure is defined in
-.IR draw (3).
+.MR draw (3) .
.PP
A
.B Font
is a set of character images, indexed by runes (see
-.IR utf (7)).
+.MR utf (7) ).
The images are organized into
.BR Subfonts ,
each containing the images for a small, contiguous set of runes.
The detailed format of these data structures,
which are described in detail in
-.IR cachechars (3),
+.MR cachechars (3) ,
is immaterial for most applications.
.B Font
and
@@ -213,7 +210,7 @@ and
the distance from the top of the highest character to the bottom of
the lowest character (and hence, the interline spacing).
See
-.IR cachechars (3)
+.MR cachechars (3)
for more details.
.PP
.I Buildfont
@@ -224,7 +221,7 @@ returning a
pointer that can be used by
.B string
(see
-.IR draw (3))
+.MR draw (3) )
to draw characters from the font.
.I Openfont
does the same, but reads the description
@@ -234,7 +231,7 @@ frees a font.
In contrast to Plan 9, font names in Plan 9 from User Space are
a small language describing the desired font.
See
-.IR font (7)
+.MR font (7)
for details.
.PP
A
@@ -277,7 +274,7 @@ structure representing the connection),
(an
.B Image
representing the display memory itself or, if
-.IR rio (1)
+.MR rio (1)
is running, the client's window),
and
.B font
@@ -290,7 +287,7 @@ which is written to
.B /dev/label
if non-nil
so that it can be used to identify the window when hidden (see
-.IR rio (1)).
+.MR rio (1) ).
The font is created by reading the named
.I font
file. If
@@ -304,7 +301,7 @@ if
is not set, it imports the default (usually minimal)
font from the operating system.
(See
-.IR font (7)
+.MR font (7)
for a full discussion of font syntaxes.)
The global
.I font
@@ -325,7 +322,7 @@ is nil, the library provides a default, called
Another effect of
.I initdraw
is that it installs
-.IR print (3)
+.MR print (3)
formats
.I Pfmt
and
@@ -363,9 +360,9 @@ and
files; and
.I ref
specifies the refresh function to be used to create the window, if running under
-.IR rio (1)
+.MR rio (1)
(see
-.IR window (3)).
+.MR window (3) ).
.\" .PP
.\" The function
.\" .I newwindow
@@ -398,11 +395,7 @@ names the directory, default
in which the files associated with the window reside.
.I Closedisplay
disconnects the display and frees the associated data structures.
-.I Getdefont
-builds a
-.B Font
-structure from in-core data describing a default font.
-None of these routines is needed by most programs, since
+Neither of these routines is needed by most programs, since
.I initdraw
calls them as needed.
.PP
@@ -442,11 +435,11 @@ by looking in
to find the name of the window and opening it using
.B namedimage
(see
-.IR allocimage (3)).
+.MR allocimage (3) ).
The resulting window will be created using the refresh method
.I ref
(see
-.IR window (3));
+.MR window (3) );
this should almost always be
.B Refnone
because
@@ -463,7 +456,7 @@ defining the window (or the overall display, if no window system is running); an
a pointer to the
.B Screen
representing the root of the window's hierarchy. (See
-.IR window (3).
+.MR window (3) .
The overloading of the
.B screen
word is an unfortunate historical accident.)
@@ -535,15 +528,15 @@ the window boundaries; otherwise
is a no-op.
.PP
The graphics functions described in
-.IR draw (3),
-.IR allocimage (3),
-.IR cachechars (3),
+.MR draw (3) ,
+.MR allocimage (3) ,
+.MR cachechars (3) ,
and
-.IR subfont (3)
+.MR subfont (3)
are implemented by writing commands to files under
.B /dev/draw
(see
-.IR draw (3));
+.MR draw (3) );
the writes are buffered, so the functions may not take effect immediately.
.I Flushimage
flushes the buffer, doing all pending graphics operations.
@@ -553,7 +546,7 @@ is non-zero, any changes are also copied from the `soft screen' (if any) in the
driver to the visible frame buffer.
The various allocation routines in the library flush automatically, as does the event
package (see
-.IR event (3));
+.MR event (3) );
most programs do not need to call
.IR flushimage .
It returns \-1 on error.
@@ -570,13 +563,13 @@ and
.I chantostr
convert between the channel descriptor strings
used by
-.IR image (7)
+.MR image (7)
and the internal
.B ulong
representation
used by the graphics protocol
(see
-.IR draw (3)'s
+.MR draw (3) 's
.B b
message).
.B Chantostr
@@ -606,7 +599,7 @@ if(getwindow(display, Refnone) < 0)
.EE
.PP
To create and set up a new
-.IR rio (1)
+.MR rio (1)
window,
.IP
.EX
@@ -637,23 +630,23 @@ if(gengetwindow(display, "/tmp/winname",
.SH SOURCE
.B \*9/src/libdraw
.SH "SEE ALSO"
-.IR rio (1),
-.IR addpt (3),
-.IR allocimage (3),
-.IR cachechars (3),
-.IR subfont (3),
-.IR draw (3),
-.IR event (3),
-.IR frame (3),
-.IR print (3),
-.IR window (3),
-.IR draw (3),
+.MR rio (1) ,
+.MR addpt (3) ,
+.MR allocimage (3) ,
+.MR cachechars (3) ,
+.MR subfont (3) ,
+.MR draw (3) ,
+.MR event (3) ,
+.MR frame (3) ,
+.MR print (3) ,
+.MR window (3) ,
+.MR draw (3) ,
.\" .IR rio (4),
-.IR image (7),
-.IR font (7)
+.MR image (7) ,
+.MR font (7)
.SH DIAGNOSTICS
An error function may call
-.IR errstr (3)
+.MR errstr (3)
for further diagnostics.
.SH BUGS
The names
diff --git a/man/man3/html.3 b/man/man3/html.3
index 7dc486ae4..b77fda919 100644
--- a/man/man3/html.3
+++ b/man/man3/html.3
@@ -1411,7 +1411,7 @@ would not otherwise fit), and
.SH SOURCE
.B \*9/src/libhtml
.SH SEE ALSO
-.IR fmt (1)
+.MR fmt (1)
.PP
W3C World Wide Web Consortium,
``HTML 4.01 Specification''.
diff --git a/man/man3/ioproc.3 b/man/man3/ioproc.3
index a87fa775b..38609d7b6 100644
--- a/man/man3/ioproc.3
+++ b/man/man3/ioproc.3
@@ -80,14 +80,14 @@ and
execute the
similarly named library or system calls
(see
-.IR close (2),
-.IR dial (3),
-.IR open (3),
-.IR read (3),
-.IR fcall (3),
-.IR sendfd (3),
+.MR close (2) ,
+.MR dial (3) ,
+.MR open (3) ,
+.MR read (3) ,
+.MR fcall (3) ,
+.MR sendfd (3) ,
and
-.IR sleep (3))
+.MR sleep (3) )
in the slave process associated with
.IR io .
It is an error to execute more than one call
@@ -187,10 +187,10 @@ ioread(Ioproc *io, int fd, void *a, long n)
.SH SOURCE
.B \*9/src/libthread
.SH SEE ALSO
-.IR dial (3),
-.IR open (3),
-.IR read (3),
-.IR thread (3)
+.MR dial (3) ,
+.MR open (3) ,
+.MR read (3) ,
+.MR thread (3)
.SH BUGS
.I Iointerrupt
is currently unimplemented.
diff --git a/man/man3/ip.3 b/man/man3/ip.3
index 2d9e8289d..da3855ed8 100644
--- a/man/man3/ip.3
+++ b/man/man3/ip.3
@@ -126,7 +126,7 @@ The string representation of Ethernet addresses is exactly
.PP
.I Eipfmt
is a
-.IR print (3)
+.MR print (3)
formatter for Ethernet (verb
.BR E )
addresses,
@@ -340,4 +340,4 @@ point to point.
.SH SOURCE
.B \*9/src/libip
.SH SEE ALSO
-.IR print (3)
+.MR print (3)
diff --git a/man/man3/isalpharune.3 b/man/man3/isalpharune.3
index 7b5cf301f..f9b20a0c9 100644
--- a/man/man3/isalpharune.3
+++ b/man/man3/isalpharune.3
@@ -35,7 +35,7 @@ in particular a subset of their properties as defined in the Unicode standard.
Unicode defines some characters as alphabetic and specifies three cases:
upper, lower, and title.
Analogously to
-.IR isalpha (3)
+.MR isalpha (3)
for
.SM ASCII\c
,
diff --git a/man/man3/keyboard.3 b/man/man3/keyboard.3
index 4641b86dc..feedfd2e9 100644
--- a/man/man3/keyboard.3
+++ b/man/man3/keyboard.3
@@ -23,14 +23,14 @@ void closekeyboard(Keyboard *kc)
.SH DESCRIPTION
These functions access and control a keyboard interface
for character-at-a-time I/O in a multi-threaded environment, usually in combination with
-.IR mouse (3).
+.MR mouse (3) .
They use the message-passing
.B Channel
interface in the threads library
(see
-.IR thread (3));
+.MR thread (3) );
programs that wish a more event-driven, single-threaded approach should use
-.IR event (3).
+.MR event (3) .
.PP
.I Initkeyboard
opens a connection to the keyboard and returns a
@@ -86,10 +86,10 @@ structure.
.SH SOURCE
.B \*9/src/libdraw
.SH SEE ALSO
-.IR graphics (3),
-.IR draw (3),
-.IR event (3),
-.IR thread (3).
+.MR graphics (3) ,
+.MR draw (3) ,
+.MR event (3) ,
+.MR thread (3) .
.SH BUGS
Because the interface delivers complete runes,
there is no way to report lesser actions such as
diff --git a/man/man3/lock.3 b/man/man3/lock.3
index adc75d1fc..2dea7467c 100644
--- a/man/man3/lock.3
+++ b/man/man3/lock.3
@@ -80,7 +80,7 @@ are rendezvous points.
Locks and rendezvous points have trivial implementations in programs
not using the thread library
(see
-.IR thread (3)),
+.MR thread (3) ),
since such programs have no concurrency.
.PP
Used carelessly, spin locks can be expensive and can easily generate deadlocks.
diff --git a/man/man3/mach-cmd.3 b/man/man3/mach-cmd.3
index ac6b3bbdf..a2b4462d5 100644
--- a/man/man3/mach-cmd.3
+++ b/man/man3/mach-cmd.3
@@ -64,7 +64,7 @@ fields) of all currently open headers
(see
.I symopen
in
-.IR mach-symbol (3)).
+.MR mach-symbol (3) ).
When dynamically linked objects have been attached,
they are present in this linked list,
and therefore included in searches by
@@ -73,7 +73,7 @@ and therefore included in searches by
and
.I findsym
(see
-.IR mach-symbol (3)).
+.MR mach-symbol (3) ).
.TP
.I corhdr
The file header for the core dump, if any.
@@ -118,9 +118,9 @@ loaded.
uses all of these functions while
parsing an argument vector as would be passed to
a debugger like
-.IR db (1)
+.MR db (1)
or
-.IR acid (1).
+.MR acid (1) .
It expects a list of executable files, core dump files, or process ids,
given in any order.
If extra arguments are given (for example, more than one executable, or both
@@ -133,9 +133,9 @@ fills them in as best it can.
.SH SOURCE
.B \*9/src/libmach
.SH "SEE ALSO
-.IR mach (3),
-.IR mach-file (3),
-.IR mach-map (3)
+.MR mach (3) ,
+.MR mach-file (3) ,
+.MR mach-map (3)
.SH BUGS
The interface needs to be changed to support
multiple threads, each with its own register set.
diff --git a/man/man3/mach-file.3 b/man/man3/mach-file.3
index 19a10b813..cd275c5e8 100644
--- a/man/man3/mach-file.3
+++ b/man/man3/mach-file.3
@@ -161,10 +161,10 @@ The memory at
should be freed via
.I free
(see
-.IR malloc (3))
+.MR malloc (3) )
when no longer needed.
.SH SOURCE
.B \*9/src/libmach
.SH "SEE ALSO"
-.IR mach (3),
-.IR mach-map (3)
+.MR mach (3) ,
+.MR mach-map (3)
diff --git a/man/man3/mach-map.3 b/man/man3/mach-map.3
index c58225721..a0e274023 100644
--- a/man/man3/mach-map.3
+++ b/man/man3/mach-map.3
@@ -133,10 +133,10 @@ via
data structures that provides access to an address space
and register set.
The functions described in
-.IR mach-file (3)
+.MR mach-file (3)
are typically used to construct these maps.
Related library functions described in
-.IR mach-symbol (3)
+.MR mach-symbol (3)
provide similar access to symbol tables.
.PP
Each
@@ -178,7 +178,7 @@ The
.B rw
function is most commonly used to provide
access to executing processes via
-.IR ptrace (2)
+.MR ptrace (2)
and to zeroed segments.
.PP
.I Allocmap
@@ -346,7 +346,7 @@ such locations are useful for passing specific constants to
functions expect locations, such as
.I unwind
(see
-.IR mach-stack (3)).
+.MR mach-stack (3) ).
.PP
.I Loccmp
compares two locations, returning negative, zero, or positive
@@ -360,7 +360,7 @@ which are ordered before indirections.
.PP
.I Locfmt
is a
-.IR print (3)-verb
+.MR print (3) -verb
that formats a
.B Loc
structure
@@ -371,7 +371,7 @@ Indirection locations are needed in some contexts (e.g., when
using
.I findlsym
(see
-.IR mach-symbol (3))),
+.MR mach-symbol (3) )),
but bothersome in most.
.I Locsimplify
rewrites indirections as absolute memory addresses, by evaluating
@@ -397,8 +397,8 @@ function families as necessary.
.SH SOURCE
.B \*9/src/libmach
.SH "SEE ALSO"
-.IR mach (3),
-.IR mach-file (3)
+.MR mach (3) ,
+.MR mach-file (3)
.SH DIAGNOSTICS
These routines set
.IR errstr .
diff --git a/man/man3/mach-stack.3 b/man/man3/mach-stack.3
index d75f641f5..4c34abb15 100644
--- a/man/man3/mach-stack.3
+++ b/man/man3/mach-stack.3
@@ -68,7 +68,7 @@ a new
.I rget
function, and a symbol
(see
-.IR mach-symbol (3))
+.MR mach-symbol (3) )
describing the current function
(nil if no symbol is known).
The value returned by the tracer
@@ -180,6 +180,6 @@ trace(Map *map, ulong pc, ulong callerpc,
.SH SOURCE
.B \*9/src/libmach
.SH SEE ALSO
-.IR mach (3)
+.MR mach (3)
.SH BUGS
Need to talk about Regs
diff --git a/man/man3/mach-swap.3 b/man/man3/mach-swap.3
index eb6091f32..eda669117 100644
--- a/man/man3/mach-swap.3
+++ b/man/man3/mach-swap.3
@@ -114,4 +114,4 @@ and low 32-bits are in
.SH SOURCE
.B \*9/src/libmach
.SH "SEE ALSO"
-.IR mach (3)
+.MR mach (3)
diff --git a/man/man3/mach-symbol.3 b/man/man3/mach-symbol.3
index e14a7b2e0..a761a12b4 100644
--- a/man/man3/mach-symbol.3
+++ b/man/man3/mach-symbol.3
@@ -61,10 +61,10 @@ int fnbound(ulong pc, ulong bounds[2])
.SH DESCRIPTION
These functions provide machine-independent access to the
symbol table of an executable file or executing process.
-.IR Mach (3),
-.IR mach-file (3),
+.MR Mach (3) ,
+.MR mach-file (3) ,
and
-.IR mach-map (3)
+.MR mach-map (3)
describe additional library functions for
accessing executable files and executing processes.
.PP
@@ -74,7 +74,7 @@ uses the data in the
structure filled by
.I crackhdr
(see
-.IR mach-file (3))
+.MR mach-file (3) )
to initialize in-memory structures used to access the symbol
tables contained in the file.
.IR Symclose
@@ -371,6 +371,6 @@ in the system error buffer where it is available via
.SH SOURCE
.B \*9/src/libmach
.SH "SEE ALSO"
-.IR mach (3),
-.IR mach-file (3),
-.IR mach-map (3)
+.MR mach (3) ,
+.MR mach-file (3) ,
+.MR mach-map (3)
diff --git a/man/man3/mach.3 b/man/man3/mach.3
index 9c065d002..bf260d581 100644
--- a/man/man3/mach.3
+++ b/man/man3/mach.3
@@ -40,7 +40,7 @@ points at the structure for the architecture being debugged.
It is set implicitly by
.I crackhdr
(see
-.IR mach-file (3))
+.MR mach-file (3) )
and can be set explicitly by calling
.I machbyname
or
@@ -66,31 +66,31 @@ Mac OS X).
Other manual pages
describe the library functions in detail.
.PP
-.IR Mach-cmd (3)
+.MR Mach-cmd (3)
describes some convenience routines for attaching to
processes and core files.
.PP
-.IR Mach-file (3)
+.MR Mach-file (3)
describes the manipulation of binary files.
.PP
-.IR Mach-map (3)
+.MR Mach-map (3)
describes the interface to address spaces and register sets
in executable files and executing programs.
.PP
-.IR Mach-stack (3)
+.MR Mach-stack (3)
describes support for unwinding the stack.
.PP
-.IR Mach-swap (3)
+.MR Mach-swap (3)
describes helper functions for accessing data
in a particular byte order.
.PP
-.IR Mach-symbol (3)
+.MR Mach-symbol (3)
describes the interface to debugging symbol information.
.SH SOURCE
.B \*9/src/libmach
.SH "SEE ALSO
-.IR mach-file (3),
-.IR mach-map (3),
-.IR mach-stack (3),
-.IR mach-swap (3),
-.IR mach-symbol (3)
+.MR mach-file (3) ,
+.MR mach-map (3) ,
+.MR mach-stack (3) ,
+.MR mach-swap (3) ,
+.MR mach-symbol (3)
diff --git a/man/man3/malloc.3 b/man/man3/malloc.3
index 1cdff5776..02498ab9b 100644
--- a/man/man3/malloc.3
+++ b/man/man3/malloc.3
@@ -132,8 +132,8 @@ the source of allocation.
.SH SEE ALSO
.I trump
(in
-.IR acid (1)),
-.IR getcallerpc (3)
+.MR acid (1) ),
+.MR getcallerpc (3)
.SH DIAGNOSTICS
.I Malloc, realloc
and
@@ -153,7 +153,7 @@ The
library for
.I acid
can be used to obtain traces of malloc execution; see
-.IR acid (1).
+.MR acid (1) .
.SH BUGS
The different specification of
.I calloc
@@ -182,4 +182,4 @@ are preprocessor macros defined as
and
.IR p9free ;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/matrix.3 b/man/man3/matrix.3
index 7291725c6..7d6c9e6b2 100644
--- a/man/man3/matrix.3
+++ b/man/man3/matrix.3
@@ -347,4 +347,4 @@ coordinates.
.SH SOURCE
.B \*9/src/libgeometry/matrix.c
.SH "SEE ALSO
-.IR arith3 (3)
+.MR arith3 (3)
diff --git a/man/man3/memdraw.3 b/man/man3/memdraw.3
index 3f6c483ef..8dad89d0b 100644
--- a/man/man3/memdraw.3
+++ b/man/man3/memdraw.3
@@ -152,7 +152,6 @@ Memsubfont* allocmemsubfont(char *name, int n, int height,
Memsubfont* openmemsubfont(char *name)
void freememsubfont(Memsubfont *f)
Point memsubfontwidth(Memsubfont *f, char *s)
-Memsubfont* getmemdefont(void)
Point memimagestring(Memimage *dst, Point p, Memimage *color,
Point cp, Memsubfont *f, char *cs, Drawop op)
.PP
@@ -169,46 +168,46 @@ type defines memory-resident rectangular pictures and the methods to draw upon t
differ from
.BR Image s
(see
-.IR draw (3))
+.MR draw (3) )
in that they are manipulated directly in user memory rather than by
RPCs to the
.B /dev/draw
hierarchy.
The
.Bmemdraw
-library is the basis for the kernel
-.IR draw (3)
+library is the basis for the kernel
+.MR draw (3)
driver and also used by a number of programs that must manipulate
images without a display.
.PP
-The
-.BR r,
+The
+.BR r,
.BR clipr ,
.BR depth ,
.BR nchan ,
and
-.BR chan
+.BR chan
structure elements are identical to
the ones of the same name
-in the
+in the
.B Image
structure.
.PP
The
.B flags
-element of the
+element of the
.B Memimage
structure holds a number of bits of information about the image.
In particular, it subsumes the
purpose of the
.B repl
-element of
+element of
.B Image
structures.
.PP
.I Memimageinit
initializes various static data that the library depends on,
-as well as the replicated solid color images
+as well as the replicated solid color images
.BR memopaque ,
.BR memtransparent ,
.BR memblack ,
@@ -217,15 +216,15 @@ and
It should be called before referring to any of these images
and before calling any of the other library functions.
.PP
-Each
+Each
.B Memimage
-points at a
+points at a
.B Memdata
structure that in turn points at the actual pixel data for the image.
-This allows multiple images to be associated with the same
+This allows multiple images to be associated with the same
.BR Memdata .
The first word of the data pointed at by
-the
+the
.B base
element of
.B Memdata
@@ -233,18 +232,19 @@ points back at the
.B Memdata
structure, so that in the Plan 9 kernel, the
memory allocator (see
-Plan 9's \fIpool\fR(3))
+Plan 9's
+.IR pool (3))
can compact image memory
using
.IR memimagemove .
.PP
Because images can have different coordinate systems,
-the
+the
.B zero
-element of the
+element of the
.B Memimage
structure contains the offset that must be added
-to the
+to the
.B bdata
element of the corresponding
.B Memdata
@@ -262,18 +262,18 @@ do not include the origin, although one should only dereference
pointers corresponding to pixels within the image rectangle.
.I Wordaddr
and
-.IR byteaddr
-perform these calculations,
+.IR byteaddr
+perform these calculations,
returning pointers to the word and byte, respectively,
that contain the beginning of the data for a given pixel.
.PP
.I Allocmemimage
-allocages
+allocates
images with a given rectangle and channel descriptor
-(see
+(see
.B strtochan
in
-.IR graphics (3)),
+.MR graphics (3) ),
creating a fresh
.B Memdata
structure and associated storage.
@@ -283,7 +283,7 @@ is similar but uses the supplied
structure rather than a new one.
The
.I readmemimage
-function reads an uncompressed bitmap
+function reads an uncompressed bitmap
from the given file descriptor,
while
.I creadmemimage
@@ -294,7 +294,7 @@ writes a compressed representation of
to file descriptor
.IR fd .
For more on bitmap formats, see
-.IR image (7).
+.MR image (7) .
.I Freememimage
frees images returned by any of these routines.
The
@@ -316,7 +316,7 @@ data, respectively.
When calling
.IR cloadmemimage ,
the buffer must contain an
-integral number of
+integral number of
compressed chunks of data that exactly cover the rectangle.
.I Unloadmemimage
retrieves the uncompressed pixel data for a given rectangle of an image.
@@ -325,8 +325,8 @@ and \-1 in case of an error.
.PP
.I Memfillcolor
fills an image with the given color, a 32-bit number as
-described in
-.IR color (3).
+described in
+.MR color (3) .
.PP
.IR Memarc ,
.IR mempoly ,
@@ -335,7 +335,7 @@ described in
.IR memimageline ,
and
.I memimagedraw
-are identical to the
+are identical to the
.IR arc ,
.IR poly ,
.IR ellipse ,
@@ -344,42 +344,40 @@ are identical to the
and
.IR gendraw ,
routines described in
-.IR draw (3),
+.MR draw (3) ,
except that they operate on
.BR Memimage s
-rather than
+rather than
.BR Image s.
-Similarly,
+Similarly,
.IR allocmemsubfont ,
.IR openmemsubfont ,
.IR freememsubfont ,
.IR memsubfontwidth ,
-.IR getmemdefont ,
and
.I memimagestring
-are the
+are the
.B Memimage
-analogues of
+analogues of
.IR allocsubfont ,
.IR openfont ,
.IR freesubfont ,
.IR strsubfontwidth ,
-.IR getdefont ,
and
.B string
-(see
-.IR subfont (3)
+(see
+.MR subfont (3)
and
-.IR graphics (3)),
+.MR graphics (3) ),
except that they operate
-only on
+only on
.BR Memsubfont s
rather than
.BR Font s.
.PP
.I Drawclip
takes the images involved in a draw operation,
-together with the destination rectangle
+together with the destination rectangle
.B dr
and source
and mask alignment points
@@ -410,7 +408,7 @@ an end of a given style.
.PP
The
.I hwdraw
-and
+and
.I iprint
functions are no-op stubs that may be overridden by clients
of the library.
@@ -418,7 +416,7 @@ of the library.
is called at each call to
.I memimagedraw
with the current request's parameters.
-If it can satisfy the request, it should do so
+If it can satisfy the request, it should do so
and return 1.
If it cannot satisfy the request, it should return 0.
This allows (for instance) the kernel to take advantage
@@ -435,15 +433,15 @@ prints to a serial line rather than the screen, for obvious reasons.
.SH SOURCE
.B \*9/src/libmemdraw
.SH SEE ALSO
-.IR addpt (3),
-.IR color (3),
-.IR draw (3),
-.IR graphics (3),
-.IR memlayer (3),
-.IR stringsize (3),
-.IR subfont (3),
-.IR color (7),
-.IR utf (7)
+.MR addpt (3) ,
+.MR color (3) ,
+.MR draw (3) ,
+.MR graphics (3) ,
+.MR memlayer (3) ,
+.MR stringsize (3) ,
+.MR subfont (3) ,
+.MR color (7) ,
+.MR utf (7)
.SH BUGS
.I Memimagestring
is unusual in using a subfont rather than a font,
diff --git a/man/man3/memlayer.3 b/man/man3/memlayer.3
index a40efdc7a..d7f065100 100644
--- a/man/man3/memlayer.3
+++ b/man/man3/memlayer.3
@@ -97,18 +97,18 @@ int memunload(Memimage *i, Rectangle r,
.PP
.SH DESCRIPTION
These functions build upon the
-.IR memdraw (3)
+.MR memdraw (3)
interface to maintain overlapping graphical windows on in-memory images.
They are used by the kernel to implement the windows interface presented by
-.IR draw (3)
+.MR draw (3)
and
-.IR window (3)
+.MR window (3)
and probably have little use outside of the kernel.
.PP
The basic function is to extend the definition of a
.B Memimage
(see
-.IR memdraw (3))
+.MR memdraw (3) )
to include overlapping windows defined by the
.B Memlayer
type.
@@ -270,7 +270,7 @@ They have the signatures of
and
.I memimageline
(see
-.IR memdraw (3))
+.MR memdraw (3) )
but accept
.B Memlayer
or
@@ -294,12 +294,12 @@ bytes of data in
.I buf
are in compressed image format
(see
-.IR image (7)).
+.MR image (7) ).
.SH SOURCE
.B \*9/src/libmemlayer
.SH SEE ALSO
-.IR graphics (3),
-.IR memdraw (3),
-.IR stringsize (3),
-.IR window (3),
-.IR draw (3)
+.MR graphics (3) ,
+.MR memdraw (3) ,
+.MR stringsize (3) ,
+.MR window (3) ,
+.MR draw (3)
diff --git a/man/man3/memory.3 b/man/man3/memory.3
index 51e54479f..5f191dd4e 100644
--- a/man/man3/memory.3
+++ b/man/man3/memory.3
@@ -109,7 +109,7 @@ All these routines have portable C implementations in
.\" Most also have machine-dependent assembly language implementations in
.\" .BR \*9/lib9/$objtype .
.SH SEE ALSO
-.IR strcat (3)
+.MR strcat (3)
.SH BUGS
ANSI C does not require
.I memcpy
diff --git a/man/man3/mouse.3 b/man/man3/mouse.3
index 216c72b01..9b835891b 100644
--- a/man/man3/mouse.3
+++ b/man/man3/mouse.3
@@ -49,9 +49,9 @@ They use the message-passing
.B Channel
interface in the threads library
(see
-.IR thread (3));
+.MR thread (3) );
programs that wish a more event-driven, single-threaded approach should use
-.IR event (3).
+.MR event (3) .
.PP
The state of the mouse is recorded in a structure,
.BR Mouse ,
@@ -88,15 +88,15 @@ returns a structure through which one may access the mouse:
typedef struct Mousectl Mousectl;
struct Mousectl
{
- Mouse;
- Channel *c; /* chan(Mouse)[16] */
+ Mouse m;
+ Channel *c; /* chan(Mouse)[16] */
Channel *resizec; /* chan(int)[2] */
char *file;
int mfd; /* to mouse file */
int cfd; /* to cursor file */
int pid; /* of slave proc */
- Image* image; /* of associated window/display */
+ Image* image; /* of associated window/display */
};
.EE
.PP
@@ -107,7 +107,7 @@ are a
naming the device file connected to the mouse and an
.I Image
(see
-.IR draw (3))
+.MR draw (3) )
on which the mouse will be visible.
Typically the file is
nil,
@@ -136,13 +136,15 @@ The actual value sent may be discarded; the receipt of the message
tells the program that it should call
.B getwindow
(see
-.IR graphics (3))
+.MR graphics (3) )
to reconnect to the window.
.PP
.I Readmouse
updates the
.B Mouse
-structure held in the
+structure
+.B m
+held in the
.BR Mousectl ,
blocking if the state has not changed since the last
.I readmouse
@@ -150,7 +152,7 @@ or message sent on the channel.
It calls
.B flushimage
(see
-.IR graphics (3))
+.MR graphics (3) )
before blocking, so any buffered graphics requests are displayed.
.PP
.I Closemouse
@@ -172,14 +174,14 @@ is nil, the cursor is set to the default.
The format of the cursor data is spelled out in
.B
and described in
-.IR graphics (3).
+.MR graphics (3) .
.PP
.I Getrect
returns the dimensions of a rectangle swept by the user, using the mouse,
in the manner
-.IR rio (1)
+.MR rio (1)
or
-.IR sam (1)
+.MR sam (1)
uses to create a new window.
The
.I but
@@ -218,7 +220,7 @@ struct Menu
behaves the same as its namesake
.I emenuhit
described in
-.IR event (3),
+.MR event (3) ,
with two exceptions.
First, it uses a
.B Mousectl
@@ -228,7 +230,7 @@ it creates the menu as a true window on the
.B Screen
.I scr
(see
-.IR window (3)),
+.MR window (3) ),
permitting the menu to be displayed in parallel with other activities on the display.
If
.I scr
@@ -242,8 +244,8 @@ restoring the display when the menu is removed.
.SH SOURCE
.B \*9/src/libdraw
.SH SEE ALSO
-.IR graphics (3),
-.IR draw (3),
-.IR event (3),
-.IR keyboard (3),
-.IR thread (3).
+.MR graphics (3) ,
+.MR draw (3) ,
+.MR event (3) ,
+.MR keyboard (3) ,
+.MR thread (3) .
diff --git a/man/man3/mousescrollsize.3 b/man/man3/mousescrollsize.3
index 981473568..c4c24b10b 100644
--- a/man/man3/mousescrollsize.3
+++ b/man/man3/mousescrollsize.3
@@ -28,15 +28,15 @@ causes a half-window scroll increment.
.PP
.I Mousescrollsize
is used by
-.IR 9term (1)
+.MR 9term (1)
and
-.IR acme (1)
+.MR acme (1)
to set their scrolling behavior.
.SH SOURCE
.B \*9/src/libdraw/scroll.c
.SH SEE ALSO
-.IR 9term (1),
-.IR acme (1)
+.MR 9term (1) ,
+.MR acme (1)
.SH BUGS
.I Libdraw
expects up and down scroll wheel events to be expressed as clicks of mouse buttons 4 and 5,
diff --git a/man/man3/mp.3 b/man/man3/mp.3
index f0028c3f6..8ea365dc2 100644
--- a/man/man3/mp.3
+++ b/man/man3/mp.3
@@ -315,9 +315,9 @@ is
the buffer is allocated.
.I Mpfmt
can be used with
-.IR fmtinstall (3)
+.MR fmtinstall (3)
and
-.IR print (3)
+.MR print (3)
to print hexadecimal representations of
.BR mpint s.
.PP
diff --git a/man/man3/mux.3 b/man/man3/mux.3
index 0c429fba9..ed8229403 100644
--- a/man/man3/mux.3
+++ b/man/man3/mux.3
@@ -123,7 +123,7 @@ nil if an error occurred.
.I Muxprocs
allocates new procs
(see
-.IR thread (3))
+.MR thread (3) )
in which to run
.I send
and
@@ -146,7 +146,7 @@ that need to remain active.
.I Libmux
also provides a non-blocking interface, useful for programs forced
to use a
-.IR select (3)-based
+.MR select (3) -based
main loop.
.I Muxrpcstart
runs the first half of
@@ -176,7 +176,7 @@ with
.SH SOURCE
.B \*9/src/libmux
.SH SEE ALSO
-.IR thread (3),
+.MR thread (3) ,
.IR intro (9p)
.SH BUGS
.I Libmux
diff --git a/man/man3/ndb.3 b/man/man3/ndb.3
index 14c845b65..413c11d62 100644
--- a/man/man3/ndb.3
+++ b/man/man3/ndb.3
@@ -88,13 +88,13 @@ Ndbtuple* ndbsubstitute(Ndbtuple *t, Ndbtuple *from, Ndbtuple *to);
These routines are used by network administrative programs to search
the network database.
They operate on the database files described in
-.IR ndb (7).
+.MR ndb (7) .
.PP
.I Ndbopen
opens the database
.I file
and calls
-.IR malloc (3)
+.MR malloc (3)
to allocate a buffer for it.
If
.I file
@@ -128,7 +128,7 @@ is used to find each successive match.
On a successful search both return a linked list of
.I Ndbtuple
structures acquired by
-.IR malloc (3)
+.MR malloc (3)
that represent the attribute/value pairs in the
entry.
On failure they return zero.
@@ -450,8 +450,8 @@ directory of network database files
.SH SOURCE
.B \*9/src/libndb
.SH SEE ALSO
-.IR ndb (1)
-.IR ndb (7)
+.MR ndb (1)
+.MR ndb (7)
.SH DIAGNOSTICS
.IR Ndbgetvalue
and
diff --git a/man/man3/needstack.3 b/man/man3/needstack.3
index 071b89165..52fa8785a 100644
--- a/man/man3/needstack.3
+++ b/man/man3/needstack.3
@@ -45,7 +45,7 @@ is a no-op.
.I Needstack
should be thought of as a comment checked at run time,
like
-.IR assert (3).
+.MR assert (3) .
.SH EXAMPLE
The X Window library implementation of
.I XLookupString
@@ -57,7 +57,7 @@ before making calls to
.IR XLookupString .
If a thread (in this case, the keyboard-reading thread used
inside the
-.IR draw (3)
+.MR draw (3)
library)
does not allocate a large enough stack, the problem is diagnosed
immediately rather than left to corrupt memory.
@@ -66,4 +66,4 @@ immediately rather than left to corrupt memory.
.br
.B \*9/src/libthread
.SH SEE ALSO
-.IR thread (3)
+.MR thread (3)
diff --git a/man/man3/notify.3 b/man/man3/notify.3
index 7dd768e74..9f2efb6db 100644
--- a/man/man3/notify.3
+++ b/man/man3/notify.3
@@ -33,12 +33,12 @@ or writing on a closed pipe, a
is posted to communicate the exception.
A note may also be posted by another process
via
-.IR postnote (3).
+.MR postnote (3) .
On Unix, notes are implemented as signals.
.PP
When a note is received, the action taken depends on the note.
See
-.IR signal (7)
+.MR signal (7)
for the full description of the defaults.
.PP
The default actions may be overridden.
@@ -53,10 +53,10 @@ replaces the previous handler, if any.
An argument of zero cancels a previous handler,
restoring the default action.
A
-.IR fork (2)
+.MR fork (2)
system call leaves the handler registered in
both the parent and the child;
-.IR exec (3)
+.MR exec (3)
restores the default behavior.
Handlers may not perform floating point operations.
.PP
@@ -112,17 +112,17 @@ set up with
using the
.I notejmp
function (see
-.IR setjmp (3)).
+.MR setjmp (3) ).
.PP
Unix provides a fixed set of notes (typically there are 32) called
.IR signals .
It also allows a process to block certain notes from being delivered
(see
-.IR sigprocmask (2))
+.MR sigprocmask (2) )
and to ignore certain notes by setting the signal hander to the special value
.B SIG_IGN
(see
-.IR signal (2)).
+.MR signal (2) ).
.I Noteenable
and
.I notedisable
@@ -137,7 +137,7 @@ is called upon receipt of the note; if the handler is not called, the note is di
Regardless of the origin of the note or the presence of a handler,
if the process is being debugged
(see
-.IR ptrace (2))
+.MR ptrace (2) )
the arrival of a note puts the process in the
.B Stopped
state and awakens the debugger.
@@ -252,7 +252,7 @@ are usually generated by the operating system.
.br
.B \*9/src/lib9/atnotify.c
.SH SEE ALSO
-.IR intro (3),
+.MR intro (3) ,
.I notejmp
in
-.IR setjmp (3)
+.MR setjmp (3)
diff --git a/man/man3/open.3 b/man/man3/open.3
index 750aa65c7..d4b2e2725 100644
--- a/man/man3/open.3
+++ b/man/man3/open.3
@@ -34,7 +34,7 @@ says to truncate the file
to zero length before opening it;
.B OCEXEC
says to close the file when an
-.IR exec (3)
+.MR exec (3)
or
.I execl
system call is made;
@@ -48,7 +48,7 @@ are always appended to the end of the file.
fails if the file does not exist or the user does not have
permission to open it for the requested purpose
(see
-.IR stat (3)
+.MR stat (3)
for a description of permissions).
The user must have write permission on the
.I file
@@ -61,7 +61,7 @@ system call
(unlike the implicit
.I open
in
-.IR exec (3)),
+.MR exec (3) ),
.B OEXEC
is actually identical to
.BR OREAD .
@@ -143,8 +143,8 @@ allows the file descriptor to be reused.
.SH SOURCE
.B \*9/src/lib9
.SH SEE ALSO
-.IR intro (3),
-.IR stat (3)
+.MR intro (3) ,
+.MR stat (3)
.SH DIAGNOSTICS
These functions set
.IR errstr .
@@ -169,4 +169,4 @@ are preprocessor macros defined as
and
.IR p9create ;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/opentemp.3 b/man/man3/opentemp.3
index 63af2da7f..f105a57fd 100644
--- a/man/man3/opentemp.3
+++ b/man/man3/opentemp.3
@@ -25,7 +25,7 @@ to
.L z
are tried until the name of a file that does not yet exist
(see
-.IR access (2))
+.MR access (2) )
is generated.
.I Opentemp
then opens the file for the given
@@ -49,4 +49,4 @@ will never return the same name.
.SH "SEE ALSO
.I create
in
-.IR open (3)
+.MR open (3)
diff --git a/man/man3/pipe.3 b/man/man3/pipe.3
index 10decb696..ef4de3132 100644
--- a/man/man3/pipe.3
+++ b/man/man3/pipe.3
@@ -25,7 +25,7 @@ is available for reading from
After the pipe has been established,
cooperating processes
created by subsequent
-.IR fork (2)
+.MR fork (2)
calls may pass data through the
pipe with
.I read
@@ -53,14 +53,14 @@ calls.
.\" .IR stat (3)).
.PP
When all the data has been read from a pipe and the writer has closed the pipe or exited,
-.IR read (3)
+.MR read (3)
will return 0 bytes. Writes to a pipe with no reader will generate a note
.BR "sys: write on closed pipe" .
.SH SOURCE
.B \*9/src/lib9/pipe.c
.SH SEE ALSO
-.IR intro (3),
-.IR read (3)
+.MR intro (3) ,
+.MR read (3)
.SH DIAGNOSTICS
Sets
.IR errstr .
@@ -79,7 +79,7 @@ Unix pipes are not guaranteed to be bidirectional.
In order to ensure a bidirectional channel,
.I p9pipe
creates Unix domain sockets via the
-.IR socketpair (2)
+.MR socketpair (2)
instead of Unix pipes.
.PP
The implementation of pipes as Unix domain sockets
@@ -89,11 +89,11 @@ Unix's dup device. If a Unix domain socket is open as file
descriptor 0, some implementations disallow the opening of
.BR /dev/fd/0 ;
instead one must
-.IR connect (2)
+.MR connect (2)
to it.
If this functionality is important
(as it is for
-.IR rc (1)),
+.MR rc (1) ),
one must
.B #undef
.B pipe
diff --git a/man/man3/plumb.3 b/man/man3/plumb.3
index fa78a2b5a..409c40bc2 100644
--- a/man/man3/plumb.3
+++ b/man/man3/plumb.3
@@ -68,7 +68,7 @@ Plumbmsg* plumbrecvfid(CFid *fid)
int plumbsendtofid(CFid *fid, Plumbmsg *m)
.SH DESCRIPTION
These routines manipulate
-.IR plumb (7)
+.MR plumb (7)
messages, transmitting them, receiving them, and
converting them between text and these data structures:
.IP
@@ -99,7 +99,7 @@ struct Plumbattr
opens the named plumb
.IR port ,
using
-.IR open (3)
+.MR open (3)
mode
.IR omode .
If
@@ -108,11 +108,11 @@ begins with a slash, it is taken as a literal file name;
otherwise
.I plumbopen
searches for the location of the
-.IR plumber (4)
+.MR plumber (4)
service and opens the port there.
.PP
For programs using the
-.IR event (3)
+.MR event (3)
interface,
.I eplumb
registers, using the given
@@ -121,9 +121,9 @@ receipt of messages from the named
.IR port .
.PP
The library mounts the
-.IR plumber (4)
+.MR plumber (4)
service on demand (using the
-.IR 9pclient (3))
+.MR 9pclient (3) )
library and reuses the mount instance for future
calls to
.IR plumbopen .
@@ -157,7 +157,7 @@ to
frees all the data associated with the message
.IR m ,
all the components of which must therefore have been allocated with
-.IR malloc (3).
+.MR malloc (3) .
.PP
.I Plumbrecv
returns the next message available on the file descriptor
@@ -259,7 +259,7 @@ The file descriptor returned by
is created with
.I fsopenfd
(see
-.IR 9pclient (3)),
+.MR 9pclient (3) ),
which masks information about read and write errors.
This is acceptable for use in
.I plumbrecv
@@ -276,10 +276,10 @@ that preserves the exact error details.
.SH SOURCE
.B \*9/src/libplumb
.SH SEE ALSO
-.IR plumb (1),
-.IR event (3),
-.IR plumber (4),
-.IR plumb (7)
+.MR plumb (1) ,
+.MR event (3) ,
+.MR plumber (4) ,
+.MR plumb (7)
.SH DIAGNOSTICS
When appropriate, including when a
.I plumbsend
diff --git a/man/man3/post9pservice.3 b/man/man3/post9pservice.3
index c3b69d71c..5eeae234f 100644
--- a/man/man3/post9pservice.3
+++ b/man/man3/post9pservice.3
@@ -11,11 +11,11 @@ int post9pservice(int fd, char *name, char *mtpt)
.SH DESCRIPTION
.I Post9pservice
invokes
-.IR 9pserve (4)
+.MR 9pserve (4)
to post a new 9P service in the current
``name space''
(see
-.IR intro (4))
+.MR intro (4) )
named
.IR name .
Clients connecting to the posted service
@@ -30,10 +30,10 @@ is non-nil,
mounts the service on
.IR mtpt ,
using
-.IR 9pfuse (4).
+.MR 9pfuse (4) .
.SH "SEE ALSO
-.IR intro (4),
-.IR 9pfuse (4),
-.IR 9pserve (4)
+.MR intro (4) ,
+.MR 9pfuse (4) ,
+.MR 9pserve (4)
.SH SOURCE
.B \*9/src/lib9/post9p.c
diff --git a/man/man3/postnote.3 b/man/man3/postnote.3
index 7c323964e..907710a1f 100644
--- a/man/man3/postnote.3
+++ b/man/man3/postnote.3
@@ -38,8 +38,8 @@ Returns zero if the write succeeds, otherwise \-1.
.SH SOURCE
.B \*9/src/lib9/postnote.c
.SH "SEE ALSO"
-.IR notify (3),
-.IR intro (3)
+.MR notify (3) ,
+.MR intro (3)
.SH DIAGNOSTICS
Sets
.IR errstr .
diff --git a/man/man3/prime.3 b/man/man3/prime.3
index 01a308e8a..d364b30cb 100644
--- a/man/man3/prime.3
+++ b/man/man3/prime.3
@@ -93,8 +93,8 @@ slow algorithm.
.SH SOURCE
.B \*9/src/libsec
.SH SEE ALSO
-.IR aes (3)
-.IR blowfish (3),
-.IR des (3),
-.IR elgamal (3),
-.IR rsa (3),
+.MR aes (3)
+.MR blowfish (3) ,
+.MR des (3) ,
+.MR elgamal (3) ,
+.MR rsa (3) ,
diff --git a/man/man3/print.3 b/man/man3/print.3
index a701bc040..452ed7c81 100644
--- a/man/man3/print.3
+++ b/man/man3/print.3
@@ -67,7 +67,7 @@ writes to the named output
file descriptor:
a buffered form
is described in
-.IR bio (3).
+.MR bio (3) .
.I Sprint
places text
followed by the NUL character
@@ -104,7 +104,7 @@ is like
.IR sprint ,
except that it prints into and returns a string of the required length, which is
allocated by
-.IR malloc (3).
+.MR malloc (3) .
.PP
The routines
.IR runesprint ,
@@ -361,7 +361,7 @@ The
.B S
verb is similar, but it interprets its pointer as an array
of runes (see
-.IR utf (7));
+.MR utf (7) );
the runes are converted to
.SM UTF
before output.
@@ -389,10 +389,10 @@ but that will change if pointers and integers are different sizes.
The
.B r
verb takes no arguments; it copies the error string returned by a call to
-.IR errstr (3).
+.MR errstr (3) .
.PP
Custom verbs may be installed using
-.IR fmtinstall (3).
+.MR fmtinstall (3) .
.SH EXAMPLE
This function prints an error message with a variable
number of arguments and then quits.
@@ -415,9 +415,9 @@ void fatal(char *msg, ...)
.SH SOURCE
.B \*9/src/lib9/fmt
.SH SEE ALSO
-.IR fmtinstall (3),
-.IR fprintf (3),
-.IR utf (7)
+.MR fmtinstall (3) ,
+.MR fprintf (3) ,
+.MR utf (7)
.SH DIAGNOSTICS
Routines that write to a file descriptor or call
.IR malloc
@@ -425,7 +425,7 @@ set
.IR errstr .
.SH BUGS
The formatting is close to that specified for ANSI
-.IR fprintf (3);
+.MR fprintf (3) ;
the main difference is that
.B b
and
diff --git a/man/man3/proto.3 b/man/man3/proto.3
index 2d5da3afc..571b932e6 100644
--- a/man/man3/proto.3
+++ b/man/man3/proto.3
@@ -24,7 +24,7 @@ int rdproto(char *proto, char *root, Protoenum *enm,
.I Rdproto
reads and interprets the named
.I proto
-file relative to the
+file relative to the
root directory
.IR root .
.PP
@@ -45,9 +45,9 @@ The fifth field is the name of the file from which to copy;
this file is read from the current name space,
not the source file tree.
All fields except the first are optional.
-Specifying
+Specifying
.B -
-for permissions, owner, or group
+for permissions, owner, or group
causes
.I rdproto
to fetch the corresponding information
@@ -92,29 +92,29 @@ Only the
and
.B length
fields are guaranteed to be valid.
-The argument
+The argument
.I a
is the same argument passed to
.IR rdproto ;
typically it points at some extra state
used by the enumeration function.
.PP
-When files or directories do not exist or
-cannot be read by
+When files or directories do not exist or
+cannot be read by
.IR rdproto ,
-it formats a warning message, calls
+it formats a warning message, calls
.IR warn ,
-and continues processing;
+and continues processing;
if
.I warn
-is nil,
+is nil,
.I rdproto
prints the warning message to standard error.
.PP
.I Rdproto
returns zero
if
-.I proto
+.I proto
was processed, \-1 if it could not be opened.
.SH FILES
.TF /sys/lib/sysconfig/proto/portproto
@@ -127,5 +127,6 @@ generic prototype file.
.SH SOURCE
.B \*9/src/libdisk/proto.c
.SH SEE ALSO
-.IR mk9660 (1),
-Plan 9's \fImkfs\fR(8)
+.MR mk9660 (1) ,
+Plan 9's
+.IR mkfs (8)
diff --git a/man/man3/pushtls.3 b/man/man3/pushtls.3
index fa0a080ca..7a086f00e 100644
--- a/man/man3/pushtls.3
+++ b/man/man3/pushtls.3
@@ -46,7 +46,7 @@ TLS is nearly the same as SSL 3.0, and the software should interoperate
with implementations of either standard.
.PP
To use just the record layer, as described in Plan 9's
-\fItls\fR(3),
+.IR tls (3),
call
.I pushtls
to open the record layer device, connect to the communications channel
@@ -108,7 +108,7 @@ used by a client to resume a previously negotiated security association.
On output, the connection directory is set, as with
.B listen
(see
-.IR dial (3)).
+.MR dial (3) ).
The input
.I cert
is freed and a freshly allocated copy of the remote's certificate
@@ -149,7 +149,7 @@ The private key corresponding to
.I cert.pem
should have been previously loaded into factotum.
(See
-.IR rsa (3)
+.MR rsa (3)
.\" XXX should be rsa(8)
for more about key generation.)
By setting
@@ -164,10 +164,10 @@ known to the client.
is not required for the ongoing conversation and may
be freed by the application whenever convenient.
.SH FILES
-.TP
+.TP
.B /sys/lib/tls
thumbprints of trusted services
-.TP
+.TP
.B /sys/lib/ssl
PEM certificate files
.SH SOURCE
@@ -175,12 +175,12 @@ PEM certificate files
.\" .br
.B \*9/src/libsec/port
.SH "SEE ALSO"
-.IR dial (3),
-.IR thumbprint (7);
+.MR dial (3) ,
+.MR thumbprint (7) ;
Plan 9's
-\fIfactotum\fR(4)
+.IR factotum (4)
and
-\fItls\fR(3)
+.IR tls (3)
.SH DIAGNOSTICS
return \-1 on failure.
.SH BUGS
diff --git a/man/man3/qball.3 b/man/man3/qball.3
index 5929ece2d..a5a67a790 100644
--- a/man/man3/qball.3
+++ b/man/man3/qball.3
@@ -68,7 +68,7 @@ and normal to the axis.
.SH SOURCE
.B \*9/src/libgeometry/qball.c
.SH SEE ALSO
-.IR quaternion (3)
+.MR quaternion (3)
.br
Ken Shoemake,
``Animating Rotation with Quaternion Curves'',
diff --git a/man/man3/quaternion.3 b/man/man3/quaternion.3
index 224baea72..31b59b90f 100644
--- a/man/man3/quaternion.3
+++ b/man/man3/quaternion.3
@@ -121,7 +121,7 @@ The following routines operate on rotations or orientations represented as unit
.TP
.B mtoq
Convert a rotation matrix (see
-.IR matrix (3))
+.MR matrix (3) )
to a unit quaternion.
.TP
.B qtom
@@ -148,12 +148,12 @@ This is just a rotation about the same axis by half the angle.
.SH SOURCE
.B \*9/src/libgeometry/quaternion.c
.SH SEE ALSO
-.IR matrix (3),
-.IR qball (3)
+.MR matrix (3) ,
+.MR qball (3)
.SH BUGS
To avoid name conflicts with NetBSD,
.I qdiv
is a preprocessor macro defined as
.IR p9qdiv ;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/quote.3 b/man/man3/quote.3
index ae6c6c28f..30e85bdf5 100644
--- a/man/man3/quote.3
+++ b/man/man3/quote.3
@@ -58,10 +58,10 @@ The empty string is represented by two quotes,
The first four functions act as variants of
.B strdup
(see
-.IR strcat (3)).
+.MR strcat (3) ).
Each returns a
freshly allocated copy of the string, created using
-.IR malloc (3).
+.MR malloc (3) .
.I Quotestrdup
returns a quoted copy of
.IR s ,
@@ -75,7 +75,7 @@ The
versions of these functions do the same for
.CW Rune
strings (see
-.IR runestrcat (3)).
+.MR runestrcat (3) ).
.PP
The string returned by
.I quotestrdup
@@ -124,13 +124,13 @@ blanks, control characters, and quotes are always quoted.
is provided as a
.I doquote
function that flags any character special to
-.IR rc (1).
+.MR rc (1) .
.PP
.I Quotestrfmt
and
.I quoterunestrfmt
are
-.IR print (3)
+.MR print (3)
formatting routines that produce quoted strings as output.
They may be installed by hand, but
.I quotefmtinstall
@@ -154,21 +154,21 @@ statements so the compiler can type-check uses of
and
.B %Q
in
-.IR print (3)
+.MR print (3)
format strings.
.SH SOURCE
.B \*9/src/lib9/quote.c
.br
.B \*9/src/lib9/fmt/fmtquote.c
.SH "SEE ALSO
-.IR rc (1),
-.IR malloc (3),
-.IR print (3),
-.IR strcat (3)
+.MR rc (1) ,
+.MR malloc (3) ,
+.MR print (3) ,
+.MR strcat (3)
.SH BUGS
Because it is provided by the format library,
.I doquote
is a preprocessor macro defined as
.IR fmtdoquote ;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/rand.3 b/man/man3/rand.3
index 3eaa05f53..ba7ef97f8 100644
--- a/man/man3/rand.3
+++ b/man/man3/rand.3
@@ -125,7 +125,7 @@ truly random bytes read from
.PP
.I Prng
uses the native
-.IR rand (3)
+.MR rand (3)
pseudo-random number generator to fill the buffer. Used with
.IR srand ,
this function can produce a reproducible stream of pseudo random
@@ -138,7 +138,7 @@ and
may be passed to
.I mprand
(see
-.IR mp (3)).
+.MR mp (3) ).
.PP
.I Fastrand
uses
@@ -161,7 +161,7 @@ to return a uniform
.B \*9/src/libsec/port
.SH "SEE ALSO
.\" .IR cons (3),
-.IR mp (3)
+.MR mp (3)
.SH BUGS
.I Truerand
and
@@ -181,7 +181,7 @@ are preprocessor macros defined as
.IR p9lrand ,
and so on;
see
-.IR intro (3).
+.MR intro (3) .
.ie \n(HT .ds HT "
.el .ds HT " (see HTML-formatted man page for link)
.PP
diff --git a/man/man3/rc4.3 b/man/man3/rc4.3
index 026c8352f..60849150f 100644
--- a/man/man3/rc4.3
+++ b/man/man3/rc4.3
@@ -43,13 +43,13 @@ structure keeps track of the algorithm.
.SH SOURCE
.B \*9/src/libsec
.SH SEE ALSO
-.IR mp (3),
-.IR aes (3),
-.IR blowfish (3),
-.IR des (3),
-.IR dsa (3),
-.IR elgamal (3),
-.IR rsa (3),
-.IR sechash (3),
-.IR prime (3),
-.IR rand (3)
+.MR mp (3) ,
+.MR aes (3) ,
+.MR blowfish (3) ,
+.MR des (3) ,
+.MR dsa (3) ,
+.MR elgamal (3) ,
+.MR rsa (3) ,
+.MR sechash (3) ,
+.MR prime (3) ,
+.MR rand (3)
diff --git a/man/man3/read.3 b/man/man3/read.3
index cd4dbf3d2..6fd9feb02 100644
--- a/man/man3/read.3
+++ b/man/man3/read.3
@@ -65,7 +65,7 @@ if this is not the same as requested.
and
.I Pwrite
equivalent to a
-.IR seek (3)
+.MR seek (3)
to
.I offset
followed by a
@@ -83,10 +83,10 @@ without interference.
.SH SOURCE
.B \*9/src/lib9/readn.c
.SH SEE ALSO
-.IR intro (3),
+.MR intro (3) ,
.IR open (3),
-.IR dup (3),
-.IR pipe (3)
+.MR dup (3) ,
+.MR pipe (3)
.SH DIAGNOSTICS
These functions set
.IR errstr .
diff --git a/man/man3/readcolmap.3 b/man/man3/readcolmap.3
index 82ccdcfd6..f0c048653 100644
--- a/man/man3/readcolmap.3
+++ b/man/man3/readcolmap.3
@@ -63,14 +63,14 @@ Both return 0 on success, or \-1 on error, setting
.PP
Changing the hardware color map does not change
the color map used by the
-.IR draw (3)
+.MR draw (3)
operator to convert between
mapped and true color or greyscale images,
which is described in
-.IR color (7).
+.MR color (7) .
.SH SOURCE
.B \*9/src/libdraw
.SH "SEE ALSO"
-.IR graphics (3),
-.IR draw (3),
-.IR color (7)
+.MR graphics (3) ,
+.MR draw (3) ,
+.MR color (7)
diff --git a/man/man3/readcons.3 b/man/man3/readcons.3
index dd284b970..9deaa44ef 100644
--- a/man/man3/readcons.3
+++ b/man/man3/readcons.3
@@ -31,7 +31,7 @@ is non-zero, the input is not echoed to the screen.
A stripped-down version of
.I netkey
(see
-.IR passwd (1)):
+.MR passwd (1) ):
.IP
.EX
pass = readcons("password", nil, 1);
diff --git a/man/man3/regexp.3 b/man/man3/regexp.3
index 069e1d232..854ad9967 100644
--- a/man/man3/regexp.3
+++ b/man/man3/regexp.3
@@ -42,11 +42,11 @@ compiles a
regular expression and returns
a pointer to the generated description.
The space is allocated by
-.IR malloc (3)
+.MR malloc (3)
and may be released by
.IR free .
Regular expressions are exactly as in
-.IR regexp (7).
+.MR regexp (7) .
.PP
.I Regcomplit
is like
@@ -196,7 +196,7 @@ array elements should be used.
.SH SOURCE
.B \*9/src/libregexp
.SH "SEE ALSO"
-.IR grep (1)
+.MR grep (1)
.SH DIAGNOSTICS
.I Regcomp
returns
diff --git a/man/man3/rfork.3 b/man/man3/rfork.3
index d1d383cc5..102ec3b34 100644
--- a/man/man3/rfork.3
+++ b/man/man3/rfork.3
@@ -15,14 +15,14 @@ int rfork(int flags)
is a partial implementation of the Plan 9 system call.
It can be used to manipulate some process state and to create
new processes a la
-.IR fork (2).
+.MR fork (2) .
It cannot be used to create shared-memory processes
(Plan 9's
.B RFMEM
flag); for that functionality use
.I proccreate
(see
-.IR thread (3)).
+.MR thread (3) ).
.PP
The
.I flags
@@ -45,7 +45,7 @@ If set, the child process will be dissociated from the parent. Upon
exit the child will leave no
.B Waitmsg
(see
-.IR wait (3))
+.MR wait (3) )
for the parent to collect.
.\" .TP
.\" .B RFNAMEG
@@ -81,9 +81,9 @@ for the parent to collect.
Each process is a member of a group of processes that all
receive notes when a note is sent to the group
(see
-.IR postnote (3)
+.MR postnote (3)
and
-.IR signal (2)).
+.MR signal (2) ).
The group of a new process is by default the same as its parent, but if
.B RFNOTEG
is set (regardless of
@@ -154,7 +154,7 @@ will sleep, if necessary, until required process resources are available.
Calling
.B rfork(RFFDG|RFPROC)
is equivalent to calling
-.IR fork (2).
+.MR fork (2) .
.SH SOURCE
.B \*9/src/lib9/rfork.c
.SH DIAGNOSTICS
diff --git a/man/man3/rsa.3 b/man/man3/rsa.3
index 0c1396a89..35145bda0 100644
--- a/man/man3/rsa.3
+++ b/man/man3/rsa.3
@@ -197,7 +197,7 @@ The subject line is conventionally of the form
using the quoting conventions of
.I tokenize
(see
-.IR getfields (3)).
+.MR getfields (3) ).
.PP
.I X509req
creates an X.509 certification request.
@@ -241,14 +241,14 @@ struct PEMChain
.SH SOURCE
.B \*9/src/libsec
.SH SEE ALSO
-.IR mp (3),
-.IR aes (3),
-.IR blowfish (3),
-.IR des (3),
-.IR dsa (3),
-.IR elgamal (3),
-.IR rc4 (3),
-.IR sechash (3),
-.IR prime (3),
-.IR rand (3)
+.MR mp (3) ,
+.MR aes (3) ,
+.MR blowfish (3) ,
+.MR des (3) ,
+.MR dsa (3) ,
+.MR elgamal (3) ,
+.MR rc4 (3) ,
+.MR sechash (3) ,
+.MR prime (3) ,
+.MR rand (3)
.\" .IR pem (8)
diff --git a/man/man3/rune.3 b/man/man3/rune.3
index 5bb2224ee..2cff02e37 100644
--- a/man/man3/rune.3
+++ b/man/man3/rune.3
@@ -189,5 +189,5 @@ returns
.br
.B \*9/src/lib9/utf/utfrune.c
.SH SEE ALSO
-.IR utf (7),
-.IR tcs (1)
+.MR utf (7) ,
+.MR tcs (1)
diff --git a/man/man3/runestrcat.3 b/man/man3/runestrcat.3
index 347c7219f..42686f10f 100644
--- a/man/man3/runestrcat.3
+++ b/man/man3/runestrcat.3
@@ -56,12 +56,12 @@ Rune* runestrstr(Rune *s1, Rune *s2)
.SH DESCRIPTION
These functions are rune string analogues of
the corresponding functions in
-.IR strcat (3).
+.MR strcat (3) .
.SH SOURCE
.B \*9/src/lib9
.SH SEE ALSO
-.IR memory (3),
-.IR rune (3),
-.IR strcat (3)
+.MR memory (3) ,
+.MR rune (3) ,
+.MR strcat (3)
.SH BUGS
The outcome of overlapping moves varies among implementations.
diff --git a/man/man3/searchpath.3 b/man/man3/searchpath.3
index e0709b2e9..10b741ebb 100644
--- a/man/man3/searchpath.3
+++ b/man/man3/searchpath.3
@@ -13,9 +13,9 @@ char* searchpath(char *name)
searches for the executable
.I name
in the same way that
-.IR sh (1)
+.MR sh (1)
and
-.IR rc (1)
+.MR rc (1)
do.
.PP
The environment variable
@@ -32,9 +32,9 @@ returns a pointer to a malloced string containing a path
or simply
.IR name )
suitable for use in
-.IR open (3)
+.MR open (3)
or
-.IR exec (3).
+.MR exec (3) .
.PP
If
.I name
diff --git a/man/man3/sechash.3 b/man/man3/sechash.3
index d8b1cd48c..cabfbce33 100644
--- a/man/man3/sechash.3
+++ b/man/man3/sechash.3
@@ -138,14 +138,14 @@ and
.I sha1unpickle
unmarshal a pickled digest.
All four routines return a pointer to a newly
-.IR malloc (3)'d
+.MR malloc (3) 'd
object.
.SH SOURCE
.B \*9/src/libsec
.SH SEE ALSO
-.IR aes (3),
-.IR blowfish (3),
-.IR des (3),
-.IR elgamal (3),
-.IR rc4 (3),
-.IR rsa (3)
+.MR aes (3) ,
+.MR blowfish (3) ,
+.MR des (3) ,
+.MR elgamal (3) ,
+.MR rc4 (3) ,
+.MR rsa (3)
diff --git a/man/man3/seek.3 b/man/man3/seek.3
index 36c594c4b..7282c3663 100644
--- a/man/man3/seek.3
+++ b/man/man3/seek.3
@@ -39,8 +39,8 @@ Seeking in a pipe is a no-op.
.SH SOURCE
.B \*9/src/lib9/seek.c
.SH SEE ALSO
-.IR intro (3),
-.IR open (3)
+.MR intro (3) ,
+.MR open (3)
.SH DIAGNOSTICS
Sets
.IR errstr .
@@ -50,4 +50,4 @@ To avoid name conflicts with the underlying system,
is a preprocessor macro defined as
.IR p9seek ;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/sendfd.3 b/man/man3/sendfd.3
index 771bd9ae5..fe6391c2d 100644
--- a/man/man3/sendfd.3
+++ b/man/man3/sendfd.3
@@ -20,14 +20,14 @@ and
can be used to pass an open file descriptor over
a Unix domain socket from one process to another.
Since
-.IR pipe (3)
+.MR pipe (3)
is implemented with
-.IR socketpair (2)
+.MR socketpair (2)
instead of
-.IR pipe (2),
+.MR pipe (2) ,
.I socket
can be a file descriptor obtained from
-.IR pipe (3).
+.MR pipe (3) .
.PP
.I Sendfd
sends the file descriptor
@@ -51,7 +51,7 @@ will not.
.SH SOURCE
.B \*9/src/lib9/sendfd.c
.SH SEE ALSO
-.IR socketpair (2),
+.MR socketpair (2) ,
.I sendmsg
in
-.IR send (2)
+.MR send (2)
diff --git a/man/man3/setjmp.3 b/man/man3/setjmp.3
index 1210c1712..33573ba88 100644
--- a/man/man3/setjmp.3
+++ b/man/man3/setjmp.3
@@ -46,7 +46,7 @@ was called.
is the same as
.I longjmp
except that it is to be called from within a note handler (see
-.IR notify (3)).
+.MR notify (3) ).
The
.I uregs
argument should be the first argument passed to the note handler.
@@ -58,7 +58,7 @@ can also be used to switch stacks.
.SH SOURCE
.B \*9/src/lib9/jmp.c
.SH SEE ALSO
-.IR notify (3)
+.MR notify (3)
.SH BUGS
.PP
.I Notejmp
@@ -78,10 +78,11 @@ are preprocessor macros defined as
and
.IR p9jmp_buf ;
see
-.IR intro (3).
+.MR intro (3) .
.PP
.I P9setjmp
is implemented as a preprocessor macro that calls
.I sigsetjmp
(see
-Unix's \fIsetjmp\fR(3)).
+Unix's
+.IR setjmp (3)).
diff --git a/man/man3/sleep.3 b/man/man3/sleep.3
index 0afa71d22..fabd2b4b9 100644
--- a/man/man3/sleep.3
+++ b/man/man3/sleep.3
@@ -27,7 +27,7 @@ Sleep returns \-1 if interrupted, 0 otherwise.
causes an
.B alarm
note (see
-.IR notify (3))
+.MR notify (3) )
to be sent to the invoking process after the number of milliseconds
given by the argument.
Successive calls to
@@ -39,7 +39,7 @@ the alarm clock.
.SH SOURCE
.B \*9/src/lib9/sleep.c
.SH SEE ALSO
-.IR intro (3)
+.MR intro (3)
.SH DIAGNOSTICS
These functions set
.IR errstr .
@@ -53,4 +53,4 @@ are preprocessor macros defined as
and
.IR p9alarm ;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/stat.3 b/man/man3/stat.3
index a992f9a53..3a652d108 100644
--- a/man/man3/stat.3
+++ b/man/man3/stat.3
@@ -105,7 +105,7 @@ struct Dir {
.EE
.PP
The returned structure is allocated by
-.IR malloc (3);
+.MR malloc (3) ;
freeing it also frees the associated strings.
.PP
This structure and
@@ -283,9 +283,9 @@ to retrieve the initial values first.
.SH SOURCE
.B \*9/src/lib9/dirstat.c
.SH SEE ALSO
-.IR intro (3),
-.IR fcall (3),
-.IR dirread (3),
+.MR intro (3) ,
+.MR fcall (3) ,
+.MR dirread (3) ,
.IR stat (9p)
.SH DIAGNOSTICS
The
@@ -305,7 +305,7 @@ or
is too short for the returned data, the return value will be
.B BIT16SZ
(see
-.IR fcall (3))
+.MR fcall (3) )
and the two bytes
returned will contain the initial count field of the
returned data;
diff --git a/man/man3/strcat.3 b/man/man3/strcat.3
index 2baa90909..7dcf51f70 100644
--- a/man/man3/strcat.3
+++ b/man/man3/strcat.3
@@ -222,7 +222,7 @@ is returned.
returns a pointer to a distinct copy of the null-terminated string
.I s
in space obtained from
-.IR malloc (3)
+.MR malloc (3)
or
.L 0
if no space can be obtained.
@@ -244,14 +244,14 @@ operates analogously, but ignores ASCII case differences when comparing strings.
.SH SOURCE
.B \*9/src/lib9
.SH SEE ALSO
-.IR memory (3),
-.IR rune (3),
-.IR runestrcat (3)
+.MR memory (3) ,
+.MR rune (3) ,
+.MR runestrcat (3)
.SH BUGS
These routines know nothing about
.SM UTF.
Use the routines in
-.IR rune (3)
+.MR rune (3)
as appropriate.
Note, however, that the definition of
.SM UTF
diff --git a/man/man3/string.3 b/man/man3/string.3
index 9b88e8d4b..301185f75 100644
--- a/man/man3/string.3
+++ b/man/man3/string.3
@@ -268,4 +268,4 @@ The input stack has a maximum depth of 32 nested include files.
.SH SOURCE
.B \*9/src/libString
.SH SEE ALSO
-.IR bio (3)
+.MR bio (3)
diff --git a/man/man3/stringsize.3 b/man/man3/stringsize.3
index cbf154531..c0639ab34 100644
--- a/man/man3/stringsize.3
+++ b/man/man3/stringsize.3
@@ -57,13 +57,13 @@ are analogous, but accept an array of runes rather than
.SH SOURCE
.B \*9/src/libdraw
.SH "SEE ALSO"
-.IR addpt (3),
-.IR cachechars (3),
-.IR subfont (3),
-.IR draw (3),
-.IR draw (3),
-.IR image (7),
-.IR font (7)
+.MR addpt (3) ,
+.MR cachechars (3) ,
+.MR subfont (3) ,
+.MR draw (3) ,
+.MR draw (3) ,
+.MR image (7) ,
+.MR font (7)
.SH DIAGNOSTICS
Because strings are loaded dynamically, these routines may generate I/O
to the server and produce calls to the graphics error function.
diff --git a/man/man3/subfont.3 b/man/man3/subfont.3
index 5e1b09ab6..1de30246e 100644
--- a/man/man3/subfont.3
+++ b/man/man3/subfont.3
@@ -53,13 +53,13 @@ Font* mkfont(Subfont *f, Rune min)
.SH DESCRIPTION
Subfonts are the components of fonts that hold the character images.
A font comprises an array of subfonts; see
-.IR cachechars (3).
+.MR cachechars (3) .
A new
.B Subfont
is allocated and initialized with
.IR allocsubfont .
See
-.IR cachechars (3)
+.MR cachechars (3)
for the meaning of
.IR n ,
.IR height ,
@@ -81,7 +81,7 @@ The appropriate fields of the returned
structure are set to
the passed arguments, and the image is registered as a subfont
with the graphics device
-.IR draw (3).
+.MR draw (3) .
.I Allocsubfont
returns 0 on failure.
.PP
@@ -97,7 +97,7 @@ on
if
.B f->info
was not allocated by
-.IR malloc (3)
+.MR malloc (3)
it should be zeroed before calling
.IR subffree .
.PP
@@ -150,7 +150,7 @@ Although it is principally a routine internal to the library,
may be substituted by the application to provide a less file-oriented subfont naming scheme.
.PP
The format of a subfont file is described in
-.IR font (7).
+.MR font (7) .
Briefly, it contains a image with all the characters in it,
followed by a subfont header, followed by character information.
.I Readsubfont
@@ -181,13 +181,13 @@ the part of a subfont file that comes after the image. It should be preceded by
a call to
.IR writeimage
(see
-.IR allocimage (3)).
+.MR allocimage (3) ).
.PP
.I Stringsubfont
is analogous to
.B string
(see
-.IR draw (3))
+.MR draw (3) )
for subfonts. Rather than use the underlying font caching primitives,
it calls
.B draw
@@ -224,12 +224,12 @@ bitmap font file tree
.SH SOURCE
.B \*9/src/libdraw
.SH SEE ALSO
-.IR graphics (3),
-.IR allocimage (3),
-.IR draw (3),
-.IR cachechars (3),
-.IR image (7),
-.IR font (7)
+.MR graphics (3) ,
+.MR allocimage (3) ,
+.MR draw (3) ,
+.MR cachechars (3) ,
+.MR image (7) ,
+.MR font (7)
.SH DIAGNOSTICS
All of the functions use the graphics error function (see
-.IR graphics (3)).
+.MR graphics (3) ).
diff --git a/man/man3/sysfatal.3 b/man/man3/sysfatal.3
index c1e9b83c7..210136a97 100644
--- a/man/man3/sysfatal.3
+++ b/man/man3/sysfatal.3
@@ -16,17 +16,17 @@ void sysfatal(char *fmt, ...)
prints to standard error the name of the running program,
a colon and a space,
the message described by the
-.IR print (3)
+.MR print (3)
format string
.I fmt
and subsequent arguments, and a newline.
It then calls
-.IR exits (3)
+.MR exits (3)
with the formatted message as argument.
The program's name is the value of
.BR argv0 ,
which will be set if the program uses the
-.IR arg (3)
+.MR arg (3)
interface to process its arguments.
If
.B argv0
@@ -44,7 +44,7 @@ The message is a line with several fields:
the name of the machine writing the message;
the date and time;
the message specified by the
-.IR print (3)
+.MR print (3)
format
.I fmt
and any following arguments;
@@ -60,9 +60,9 @@ can be used safely in multi-threaded programs.
.br
.B \*9/src/lib9/syslog.c
.SH "SEE ALSO"
-.IR intro (3),
-.IR errstr (3),
+.MR intro (3) ,
+.MR errstr (3) ,
the
.B %r
format in
-.IR print (3)
+.MR print (3)
diff --git a/man/man3/thread.3 b/man/man3/thread.3
index 0ebbddd0a..c0a59091b 100644
--- a/man/man3/thread.3
+++ b/man/man3/thread.3
@@ -33,6 +33,7 @@ threadintgrp,
threadkill,
threadkillgrp,
threadmain,
+threadmaybackground,
threadnotify,
threadid,
threadpid,
@@ -80,6 +81,7 @@ struct Alt {
.ft L
.ta \w'\fLChannel* 'u +4n +4n +4n +4n
void threadmain(int argc, char *argv[])
+int threadmaybackground(void)
int mainstacksize
int proccreate(void (*fn)(void*), void *arg, uint stacksize)
int threadcreate(void (*fn)(void*), void *arg, uint stacksize)
@@ -156,19 +158,21 @@ by
The thread library provides a
.I main
function that sets up a proc with a single thread executing
-.I threadmain
-on a stack of size
+.IR threadmain .
+.PP
+Every thread is backed by an operating system-provided
+.I pthread
+and runs on its system-provided stack;
.I mainstacksize
-(default eight kilobytes).
-To set
-.IR mainstacksize ,
-declare a global variable
-initialized to the desired value
-.RI ( e.g. ,
-.B int
-.B mainstacksize
-.B =
-.BR 1024 ).
+and the the stack size arguments to
+.I proccreate
+and
+.I threadcreate
+are ignored.
+Although each thread is backed by a separate
+.IR pthread ,
+the threads in a proc are still scheduled non-preemptively
+as on Plan 9 and as described below.
.PP
.I Threadcreate
creates a new thread in the calling proc, returning a unique integer
@@ -177,7 +181,7 @@ executes
.I fn(arg)
on a stack of size
.IR stacksize .
-Thread stacks are allocated in shared memory, making it valid to pass
+Thread stacks are allocated in shared memory, making it valid to pass
pointers to stack variables between threads and procs.
.I Proccreate
creates a new proc, and inside that proc creates
@@ -199,7 +203,7 @@ returning the id of the created thread.
.\" in
.\" .IR rforkflag .)
.\" .I Proccreate
-.\" is identical to
+.\" is identical to
.\" .I procrfork
.\" with
.\" .I rforkflag
@@ -230,6 +234,14 @@ When the last thread in
.IR threadmain 's
proc exits, the program will appear to its parent to have exited.
The remaining procs will still run together, but as a background program.
+This functionality can only be relied upon if the program defines a function
+.I threadmaybackground
+returning a non-zero result.
+Programs that do not define such a
+.I threadmaybackground
+will crash instead should the last thread in
+.IR threadmain 's
+proc exit leaving behind other running procs.
.PP
The threads in a proc are coroutines, scheduled nonpreemptively
in a round-robin fashion.
@@ -259,10 +271,10 @@ in arbitrary ways and should synchronize their
actions using
.B qlocks
(see
-.IR lock (3))
+.MR lock (3) )
or channel communication.
System calls such as
-.IR read (3)
+.MR read (3)
block the entire proc;
all threads in a proc block until the system call finishes.
.PP
@@ -333,18 +345,18 @@ Also for debugging,
threads have a string state associated with them.
.I Threadsetstate
sets the state string.
-There is no
+There is no
.IR threadgetstate ;
since the thread scheduler resets the state to
.B Running
-every time it runs the thread,
+every time it runs the thread,
it is only useful for debuggers to inspect the state.
.PP
.I Threaddata
returns a pointer to a per-thread pointer
that may be modified by threaded programs for
per-thread storage.
-Similarly,
+Similarly,
.I procdata
returns a pointer to a per-proc pointer.
.PP
@@ -356,7 +368,7 @@ are threaded analogues of
and
.I execl
(see
-.IR exec (3));
+.MR exec (3) );
on success,
they replace the calling thread
and invoke the external program, never returning.
@@ -390,11 +402,11 @@ response.
.I Threadexecl
and
.I threadexec
-will duplicate
+will duplicate
(see
-.IR dup (3))
+.MR dup (3) )
the three file descriptors in
-.I fd
+.I fd
onto standard input, output, and error for the external program
and then close them in the calling thread.
Beware of code that sets
@@ -435,14 +447,14 @@ stop the running of the program.
returns a channel of pointers to
.B Waitmsg
structures (see
-.IR wait (3)).
+.MR wait (3) ).
When an exec'ed process exits, a pointer to a
.B Waitmsg
is sent to this channel.
These
.B Waitmsg
structures have been allocated with
-.IR malloc (3)
+.MR malloc (3)
and should be freed after use.
.PP
A
@@ -459,9 +471,9 @@ operation blocks until the corresponding
operation occurs and
.IR "vice versa" .
.IR Chancreate
-allocates a new channel
+allocates a new channel
for messages of size
-.I elsize
+.I elsize
and with a buffer holding
.I nel
messages.
@@ -603,13 +615,13 @@ calls.
.PP
.I Chanprint
formats its arguments in the manner of
-.IR print (3)
+.MR print (3)
and sends the result to the channel
.IR c.
The string delivered by
.I chanprint
is allocated with
-.IR malloc (3)
+.MR malloc (3)
and should be freed upon receipt.
.PP
Thread library functions do not return on failure;
@@ -620,10 +632,10 @@ Threaded programs should use
in place of
.I atnotify
(see
-.IR notify (3)).
+.MR notify (3) ).
.PP
It is safe to use
-.IR sysfatal (3)
+.MR sysfatal (3)
in threaded programs.
.I Sysfatal
will print the error string and call
@@ -637,7 +649,7 @@ from the main proc before any other procs have been created.
To create new processes, use
.IR proccreate .
.\" .PP
-.\" It is safe to use
+.\" It is safe to use
.\" .IR rfork
.\" (see
.\" .IR fork (3))
@@ -655,7 +667,7 @@ To create new processes, use
.\" .BR RFCENVG.
.\" (To create new processes, use
.\" .I proccreate
-.\" and
+.\" and
.\" .IR procrfork .)
.\" As mentioned above,
.\" the thread library depends on all procs being in the
@@ -665,7 +677,7 @@ To create new processes, use
.SH FILES
.B \*9/acid/thread
contains useful
-.IR acid (1)
+.MR acid (1)
functions for debugging threaded programs.
.PP
.B \*9/src/libthread/test
@@ -673,8 +685,8 @@ contains some example programs.
.SH SOURCE
.B \*9/src/libthread
.SH SEE ALSO
-.IR intro (3),
-.IR ioproc (3)
+.MR intro (3) ,
+.MR ioproc (3)
.SH BUGS
To avoid name conflicts,
.IR alt ,
@@ -699,7 +711,7 @@ and so on.
is defined as a macro that expands to
.IR threadyield .
See
-.IR intro (3).
+.MR intro (3) .
.PP
Threadint,
threadintgrp,
diff --git a/man/man3/time.3 b/man/man3/time.3
index dfcafaf90..6095c3291 100644
--- a/man/man3/time.3
+++ b/man/man3/time.3
@@ -41,4 +41,4 @@ are preprocessor macros defined as
and
.IR p9nsec ;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/udpread.3 b/man/man3/udpread.3
index 11412596a..ebf0b9975 100644
--- a/man/man3/udpread.3
+++ b/man/man3/udpread.3
@@ -65,4 +65,4 @@ to send a response back to the sender of the original packet.
.SH SOURCE
.B \*9/src/lib9/udp.c
.SH SEE ALSO
-.IR ip (3)
+.MR ip (3)
diff --git a/man/man3/venti-cache.3 b/man/man3/venti-cache.3
index 54e46c619..15d141ead 100644
--- a/man/man3/venti-cache.3
+++ b/man/man3/venti-cache.3
@@ -112,9 +112,9 @@ the block's cache address.
allocates a new cache using the client connection
.I z
(see
-.IR venti-conn (3)
+.MR venti-conn (3)
and
-.IR venti-client (3)),
+.MR venti-client (3) ),
with
.I maxmem
bytes of memory.
@@ -195,7 +195,7 @@ The default
function is
.I vtwrite
(see
-.IR venti-client (3));
+.MR venti-client (3) );
.I vtsetcachewrite
sets it.
.I Vtsetcachewrite
@@ -230,8 +230,8 @@ or, more commonly, that cache blocks are being leaked.
.SH SOURCE
.B \*9/src/libventi
.SH SEE ALSO
-.IR venti (3),
-.IR venti-client (3),
-.IR venti-conn (3),
-.IR venti-file (3),
-.IR venti (7)
+.MR venti (3) ,
+.MR venti-client (3) ,
+.MR venti-conn (3) ,
+.MR venti-file (3) ,
+.MR venti (7)
diff --git a/man/man3/venti-client.3 b/man/man3/venti-client.3
index cc8d14f49..1f81acaf4 100644
--- a/man/man3/venti-client.3
+++ b/man/man3/venti-client.3
@@ -53,7 +53,7 @@ int vtping(VtConn *z)
extern int ventidoublechecksha1; /* default 1 */
.SH DESCRIPTION
These routines execute the client side of the
-.IR venti (7)
+.MR venti (7)
protocol.
.PP
.I Vtrpc
@@ -84,7 +84,7 @@ is typically called only indirectly, via
calls
.I vtversion
(see
-.IR venti-conn (3))
+.MR venti-conn (3) )
and
.IR vthello ,
in that order, returning success only
@@ -171,14 +171,14 @@ in the same proc should start separate procs running
and
.I vtrecvproc
as described in
-.IR venti-conn (3).
+.MR venti-conn (3) .
.SH SOURCE
.B \*9/src/libventi
.SH SEE ALSO
-.IR venti (3),
-.IR venti-conn (3),
-.IR venti-packet (3),
-.IR venti (7)
+.MR venti (3) ,
+.MR venti-conn (3) ,
+.MR venti-packet (3) ,
+.MR venti (7)
.SH DIAGNOSTICS
.I Vtrpc
and
diff --git a/man/man3/venti-conn.3 b/man/man3/venti-conn.3
index ea597de3a..ba40ff6ec 100644
--- a/man/man3/venti-conn.3
+++ b/man/man3/venti-conn.3
@@ -90,21 +90,21 @@ for reading and writing.
.I Vtdial
dials the given network address
(see
-.IR dial (3))
+.MR dial (3) )
and returns a corresponding connection.
It returns nil if the connection cannot be established.
.PP
.I Vtversion
exchanges version information with the remote side
as described in
-.IR venti (7).
+.MR venti (7) .
The negotiated version is stored in
.IB z ->version \fR.
.PP
.I Vtsend
writes a packet
(see
-.IR venti-packet (3))
+.MR venti-packet (3) )
on the connection
.IR z .
The packet
@@ -115,7 +115,7 @@ be returned by
.I vtsend
will add the two-byte length field
(see
-.IR venti (7))
+.MR venti (7) )
at the begnning.
.I Vtsend
frees
@@ -137,7 +137,7 @@ and
block until the packet can be written or read from the network.
In a threaded program
(see
-.IR thread (3)),
+.MR thread (3) ),
this may not be desirable.
If the caller arranges for
.IR vtsendproc
@@ -192,12 +192,12 @@ as they are sent or received.
.SH SOURCE
.B \*9/src/libventi
.SH SEE ALSO
-.IR venti (1),
-.IR venti (3),
-.IR venti-client (3),
-.IR venti-packet (3),
-.IR venti-server (3),
-.IR venti (7)
+.MR venti (1) ,
+.MR venti (3) ,
+.MR venti-client (3) ,
+.MR venti-packet (3) ,
+.MR venti-server (3) ,
+.MR venti (7)
.SH DIAGNOSTICS
Routines that return pointers return nil on error.
Routines returning integers return 0 on success, \-1 on error.
diff --git a/man/man3/venti-fcall.3 b/man/man3/venti-fcall.3
index ed3916ffd..f721669ec 100644
--- a/man/man3/venti-fcall.3
+++ b/man/man3/venti-fcall.3
@@ -109,7 +109,7 @@ converts a
.B VtEntry
structure describing a Venti file
(see
-.IR venti (7))
+.MR venti (7) )
into a 40-byte
.RB ( VtEntrySize )
structure at
@@ -122,7 +122,7 @@ converts a
.B VtFcall
structure describing a Venti protocol message
(see
-.IR venti (7))
+.MR venti (7) )
into a packet.
.I Vtfcallunpack
does the reverse conversion.
@@ -130,7 +130,7 @@ does the reverse conversion.
The fields in a
.B VtFcall
are named after the protocol fields described in
-.IR venti (7),
+.MR venti (7) ,
except that the
.B type
field is renamed
@@ -158,7 +158,7 @@ and the packet
The block type enumeration defined in
.B
(presented in
-.IR venti (7))
+.MR venti (7) )
differs from the one used on disk and in the network
protocol.
The disk and network representation uses different
@@ -232,7 +232,7 @@ is nil, the label is ignored.
and
.I vtscorefmt
are
-.IR print (3)
+.MR print (3)
formatters to print
.B VtFcall
structures and scores.
@@ -244,9 +244,9 @@ is installed as
.SH SOURCE
.B \*9/src/libventi
.SH SEE ALSO
-.IR venti (1),
-.IR venti (3),
-.IR venti (7)
+.MR venti (1) ,
+.MR venti (3) ,
+.MR venti (7)
.SH DIAGNOSTICS
.IR Vtentrypack ,
.IR vtfcallpack ,
diff --git a/man/man3/venti-file.3 b/man/man3/venti-file.3
index 5378bf5c2..9f3698c95 100644
--- a/man/man3/venti-file.3
+++ b/man/man3/venti-file.3
@@ -99,7 +99,7 @@ void vtfileunlock(VtFile *f);
.SH DESCRIPTION
These routines provide a simple interface to create and
manipulate Venti file trees (see
-.IR venti (7)).
+.MR venti (7) ).
.PP
.I Vtfilecreateroot
creates a new Venti file.
@@ -226,7 +226,7 @@ if an error is encountered.
.I Vtfilewrite
writes to an in-memory copy of the data blocks
(see
-.IR venti-cache (3))
+.MR venti-cache (3) )
instead of writing directly to Venti.
.I Vtfileflush
writes all copied blocks associated with
@@ -319,7 +319,7 @@ in the same directory block.
.SH SOURCE
.B \*9/src/libventi/file.c
.SH SEE ALSO
-.IR venti-cache (3),
-.IR venti-conn (3),
-.IR venti-client (3),
-.IR venti (7)
+.MR venti-cache (3) ,
+.MR venti-conn (3) ,
+.MR venti-client (3) ,
+.MR venti (7)
diff --git a/man/man3/venti-log.3 b/man/man3/venti-log.3
index 6b74c6cd4..b0a99062b 100644
--- a/man/man3/venti-log.3
+++ b/man/man3/venti-log.3
@@ -122,9 +122,9 @@ passed nil log structures.
.PP
The server library
(see
-.IR venti-conn (3)
+.MR venti-conn (3)
and
-.IR venti-server (3))
+.MR venti-server (3) )
writes debugging information to the log named
.IR VtServerLog ,
which defaults to the string
@@ -132,5 +132,5 @@ which defaults to the string
.SH SOURCE
.B \*9/src/libventi
.SH SEE ALSO
-.IR venti (3),
-.IR venti (8)
+.MR venti (3) ,
+.MR venti (8)
diff --git a/man/man3/venti-mem.3 b/man/man3/venti-mem.3
index 0a872a0a3..f9f83fb64 100644
--- a/man/man3/venti-mem.3
+++ b/man/man3/venti-mem.3
@@ -35,7 +35,7 @@ void vtfree(void *ptr)
.SH DESCRIPTION
These routines allocate and free memory.
On failure, they print an error message and call
-.IR sysfatal (3).
+.MR sysfatal (3) .
They do not return.
.PP
.I Vtbrk
@@ -63,4 +63,4 @@ when no longer needed.
.SH SOURCE
.B \*9/src/libventi
.SH SEE ALSO
-.IR venti (3)
+.MR venti (3)
diff --git a/man/man3/venti-packet.3 b/man/man3/venti-packet.3
index 3ed8d6fe4..faea58c2c 100644
--- a/man/man3/venti-packet.3
+++ b/man/man3/venti-packet.3
@@ -129,7 +129,7 @@ because fragments may not be filled completely.
compares the data sections of two packets as
.I memcmp
(see
-.IR memory (3))
+.MR memory (3) )
would.
.PP
.I Packetconcat
@@ -260,7 +260,7 @@ bytes at offset
.SH SOURCE
.B \*9/src/libventi
.SH SEE ALSO
-.IR venti (3)
+.MR venti (3)
.SH DIAGNOSTICS
These functions return errors only when passed
invalid inputs,
diff --git a/man/man3/venti-server.3 b/man/man3/venti-server.3
index 810852e14..0265781aa 100644
--- a/man/man3/venti-server.3
+++ b/man/man3/venti-server.3
@@ -33,7 +33,7 @@ VtReq* vtgetreq(VtSrv *srv)
void vtrespond(VtReq *req)
.SH DESCRIPTION
These routines execute the server side of the
-.IR venti (7)
+.MR venti (7)
protocol.
.PP
.I Vtsrvhello
@@ -115,8 +115,8 @@ blocks written to it and returns error on all reads.
.SH SOURCE
.B \*9/src/libventi
.SH SEE ALSO
-.IR venti (3),
-.IR venti-conn (3),
-.IR venti-packet (3),
-.IR venti (7),
-.IR venti (8)
+.MR venti (3) ,
+.MR venti-conn (3) ,
+.MR venti-packet (3) ,
+.MR venti (7) ,
+.MR venti (8)
diff --git a/man/man3/venti-zero.3 b/man/man3/venti-zero.3
index 270b76801..26bc3fe74 100644
--- a/man/man3/venti-zero.3
+++ b/man/man3/venti-zero.3
@@ -52,5 +52,5 @@ is the score of the zero-length block.
.br
.B \*9/src/libventi/zeroscore.c
.SH SEE ALSO
-.IR venti (3),
-.IR venti (7)
+.MR venti (3) ,
+.MR venti (7)
diff --git a/man/man3/venti.3 b/man/man3/venti.3
index 632d5998e..f5222fad0 100644
--- a/man/man3/venti.3
+++ b/man/man3/venti.3
@@ -15,61 +15,61 @@ This manual page describes general utility functions.
.PP
Other manual pages describe the library functions in detail.
.PP
-.IR Venti-cache (3)
+.MR Venti-cache (3)
describes a simple in-memory block cache to help clients.
.PP
-.IR Venti-conn (3)
+.MR Venti-conn (3)
describes routines for manipulating network connections
between Venti clients and servers.
-.IR Venti-client (3)
+.MR Venti-client (3)
and
-.IR venti-server (3)
+.MR venti-server (3)
describe routines for writing clients
and servers on top of these.
.PP
-.IR Venti-fcall (3)
+.MR Venti-fcall (3)
describes the C representation of Venti protocol messages
and data structures.
It also describes routines that convert between the C representation
and the network and disk representations.
.PP
-.IR Venti-file (3)
+.MR Venti-file (3)
describes routines for writing clients that manipulate
Venti file trees
(see
-.IR venti (7)).
+.MR venti (7) ).
.PP
-.IR Venti-log (3)
+.MR Venti-log (3)
describes routines to access in-memory log buffers
as well as the logging that is done automatically by
the library.
.PP
-.IR Venti-mem (3)
+.MR Venti-mem (3)
describes wrappers around the canonical
-.IR malloc (3)
+.MR malloc (3)
routines that abort on error.
.PP
-.IR Venti-packet (3)
+.MR Venti-packet (3)
describes routines for
manipulating zero-copy chains of
data buffers.
.PP
-.IR Venti-zero (3)
+.MR Venti-zero (3)
describes routines to zero truncate and zero extend blocks
(see
-.IR venti (7)).
+.MR venti (7) ).
.SH SOURCE
.B \*9/src/libventi
.SH SEE ALSO
-.IR venti (1),
-.IR venti-cache (3),
-.IR venti-client (3),
-.IR venti-fcall (3),
-.IR venti-file (3)
-.IR venti-log (3),
-.IR venti-mem (3),
-.IR venti-packet (3),
-.IR venti-server (3),
-.IR venti-zero (3),
-.IR venti (7),
-.IR venti (8)
+.MR venti (1) ,
+.MR venti-cache (3) ,
+.MR venti-client (3) ,
+.MR venti-fcall (3) ,
+.MR venti-file (3)
+.MR venti-log (3) ,
+.MR venti-mem (3) ,
+.MR venti-packet (3) ,
+.MR venti-server (3) ,
+.MR venti-zero (3) ,
+.MR venti (7) ,
+.MR venti (8)
diff --git a/man/man3/wait.3 b/man/man3/wait.3
index 28d5d731e..889ccd1fa 100644
--- a/man/man3/wait.3
+++ b/man/man3/wait.3
@@ -29,9 +29,9 @@ int awaitfor(int pid, char *s, int n)
.SH DESCRIPTION
.I Wait
causes a process to wait for any child process (see
-.IR fork (2)
+.MR fork (2)
and
-.IR rfork (3))
+.MR rfork (3) )
to exit.
It returns a
.B Waitmsg
@@ -62,7 +62,7 @@ the time spent in system calls, and the child's elapsed real time,
all in units of milliseconds.
.B Msg
contains the message that the child specified in
-.IR exits (3).
+.MR exits (3) .
For a normal exit,
.B msg[0]
is zero,
@@ -78,7 +78,7 @@ returns immediately, with return value nil.
The
.B Waitmsg
structure is allocated by
-.IR malloc (3)
+.MR malloc (3)
and should be freed after use.
For programs that only need the pid of the exiting program,
.I waitpid
@@ -114,7 +114,7 @@ The filled-in buffer
may be parsed (after appending a NUL) using
.IR tokenize
(see
-.IR getfields (3));
+.MR getfields (3) );
the resulting fields are, in order, pid, the three times, and the exit string,
which will be
.B ''
@@ -139,8 +139,8 @@ returns
.PP
.B \*9/src/lib9/await.c
.SH "SEE ALSO"
-.IR rfork (3),
-.IR exits (3),
+.MR rfork (3) ,
+.MR exits (3) ,
.SH DIAGNOSTICS
These routines set
.IR errstr .
@@ -156,4 +156,4 @@ are preprocessor macros defined as
and
.IR p9waitfor ;
see
-.IR intro (3).
+.MR intro (3) .
diff --git a/man/man3/window.3 b/man/man3/window.3
index 582504437..b8a6db180 100644
--- a/man/man3/window.3
+++ b/man/man3/window.3
@@ -121,7 +121,7 @@ to color the window initially, and a refresh method
The refresh methods are
.BR Refbackup ,
which provides backing store and is the method used by
-.IR rio (1)
+.MR rio (1)
for its clients;
.BR Refnone ,
which provides no refresh and is designed for temporary uses
@@ -142,7 +142,7 @@ pointer that may be treated like any other image.
In particular, it is freed by calling
.B freeimage
(see
-.IR allocimage (3)).
+.MR allocimage (3) ).
The following functions, however, apply only to windows, not regular images.
.PP
.B Bottomwindow
@@ -199,13 +199,13 @@ and screen position
.RI ( scr ).
Their usage is shown in the Examples section.
.PP
-.IR Rio (1)
+.MR Rio (1)
creates its client windows with backing store,
.BR Refbackup .
The graphics initialization routine,
.B initdraw
(see
-.IR graphics (3)),
+.MR graphics (3) ),
builds a
.B Screen
upon this, and then allocates upon that another window indented
@@ -234,10 +234,10 @@ actual screen position of the window unless it is recorded separately.
.SH SOURCE
.B \*9/src/libdraw
.SH SEE ALSO
-.IR graphics (3),
-.IR draw (3),
-.IR cachechars (3),
-.IR draw (3)
+.MR graphics (3) ,
+.MR draw (3) ,
+.MR cachechars (3) ,
+.MR draw (3)
.SH BUGS
The refresh method
.B Refmesg
diff --git a/man/man4/0intro.4 b/man/man4/0intro.4
index 1e4c81d2c..c80db2080 100644
--- a/man/man4/0intro.4
+++ b/man/man4/0intro.4
@@ -15,7 +15,7 @@ In Plan 9, the kernel mount device
\fImnt\fR(3)
acts as a client to the 9P servers mounted in the current name space,
translating system calls such as
-.IR open (2)
+.MR open (2)
into 9P transactions such as
.IR open (9p).
The kernel also multiplexes the potentially many processes onto a single 9P conversation
@@ -30,17 +30,17 @@ On Unix, 9P clients do not access servers via the traditional
file system call interface. Only the Unix name space can be accessed
that way.
Instead, 9P clients use the
-.IR 9pclient (3)
+.MR 9pclient (3)
library to connect and interact directly with particular 9P servers.
The
-.IR 9p (1)
+.MR 9p (1)
command-line client is useful for interactive use and in shell scripts.
.PP
To preserve the façade of a single 9P conversation with each server,
9P servers invoke
-.IR 9pserve (4),
+.MR 9pserve (4) ,
typically via
-.IR post9pservice (3).
+.MR post9pservice (3) .
.I 9pserve
announces a 9P service at a particular
network address and multiplexes the clients that connect to
@@ -58,7 +58,7 @@ Setting the
.B $NAMESPACE
environment variable overrides this default.
The
-.IR namespace (1)
+.MR namespace (1)
command prints the current name space directory.
.PP
Occasionally it is useful to be able to connect the input or output
@@ -73,7 +73,7 @@ implementation of
(see also
.I fsopenfd
in
-.IR 9pclient (3))
+.MR 9pclient (3) )
returns the read or write end of a pipe;
a helper process transfers data between the other end of the pipe
and the 9P server.
diff --git a/man/man4/9import.4 b/man/man4/9import.4
index e5b177cfb..6ddff346c 100644
--- a/man/man4/9import.4
+++ b/man/man4/9import.4
@@ -19,7 +19,7 @@ tool allows an arbitrary
on a remote
.I system,
with the capability of running the Plan 9
-.IR exportfs (4)
+.MR exportfs (4)
service,
to be imported into the local name space.
Usually
@@ -31,7 +31,7 @@ A process is started on the
remote machine, with authority of the user of
.IR 9import ,
to perform work for the local machine using the
-.IR exportfs (4)
+.MR exportfs (4)
service.
The default port used is TCP 17007.
If
@@ -55,11 +55,11 @@ Use
.I keypattern
to select a key to authenticate to the remote side
(see
-.IR auth (2)).
+.MR auth (2) ).
.TP
.B -p
Push the
-.IR aan (8)
+.MR aan (8)
filter onto the connection to protect against
temporary network outages.
.TP
@@ -69,11 +69,11 @@ Post the connection's mountable file descriptor as
.SH SOURCE
.B \*9/src/cmd/9import.c
.SH SEE ALSO
-.IR srv (4),
-.IR aan (8),
-.IR listen1 (8),
+.MR srv (4) ,
+.MR aan (8) ,
+.MR listen1 (8) ,
.B cs
in
-.IR ndb (7)
+.MR ndb (7)
.SH BUGS
Encryption is not implemented.
diff --git a/man/man4/9pserve.4 b/man/man4/9pserve.4
index cd34d931c..7f691b588 100644
--- a/man/man4/9pserve.4
+++ b/man/man4/9pserve.4
@@ -50,7 +50,7 @@ and clunks any outstanding fids belonging to the client.
.PP
.I 9pserve
is typically not invoked directly; use
-.IR post9pservice (3)
+.MR post9pservice (3)
instead.
.PP
The options are:
@@ -73,7 +73,7 @@ rewrite all attach messages to use
and
.IR afid ;
used to implement
-.IR srv (4)'s
+.MR srv (4) 's
.B -a
option
.TP
@@ -90,8 +90,8 @@ instead assume 9P2000 and a maximum message size of
.IR msize
.PD
.SH "SEE ALSO
-.IR intro (4),
+.MR intro (4) ,
.IR intro (9p),
-.IR 9pfuse (4)
+.MR 9pfuse (4)
.SH SOURCE
.B \*9/src/cmd/9pserve.c
diff --git a/man/man4/acme.4 b/man/man4/acme.4
index 7449dbd29..f55a85b75 100644
--- a/man/man4/acme.4
+++ b/man/man4/acme.4
@@ -15,12 +15,12 @@ acme \- control files for text windows
\&... ]
.SH DESCRIPTION
The text window system
-.IR acme (1)
+.MR acme (1)
serves a variety of files for reading, writing, and controlling
windows.
Some of them are virtual versions of system files for dealing
with the virtual console; others control operations
-of
+of
.I acme
itself.
When a command is run under
@@ -28,12 +28,13 @@ When a command is run under
a directory holding these files is posted as the 9P service
.B acme
(using
-.IR 9pserve (4)).
+.MR 9pserve (4) ).
.PP
Some of these files supply virtual versions of services available from the underlying
environment, in particular the character terminal files in Plan 9's
-\fIcons\fR(3).
-(Unlike in Plan 9's \fIrio\fR(1),
+.IR cons (3).
+(Unlike in Plan 9's
+.IR rio (1),
each command under
.I acme
sees the same set of files; there is not a distinct
@@ -46,7 +47,7 @@ Other files are unique to
is a subdirectory used by
.B win
(see
-.IR acme (1))
+.MR acme (1) )
as a mount point for the
.I acme
files associated with the window in which
@@ -183,9 +184,10 @@ is always appended; the file offset is ignored.
.B ctl
may be read to recover the five numbers as held in the
.B index
-file, described above, plus three more fields: the width of the
-window in pixels, the name of the font used in the window,
-and the width of a tab character in pixels.
+file, described above, plus five more fields: the width of the
+window in pixels; the name of the font used in the window;
+the width of a tab character in pixels; a 1 if there is undo history, 0 otherwise;
+a 1 if there is redo history, 0 otherwise.
Text messages may be written to
.B ctl
to affect the window.
@@ -234,6 +236,11 @@ Equivalent to the
.B Get
interactive command with no arguments; accepts no arguments.
.TP
+.BI font " path
+Equivalent to the
+.B Font
+interactive command with a single (required) argument.
+.TP
.B limit=addr
When the
.B ctl
@@ -430,5 +437,5 @@ except that reads stop at the end address.
.SH SOURCE
.B \*9/src/cmd/acme
.SH SEE ALSO
-.IR rio (1),
-.IR acme (1)
+.MR rio (1) ,
+.MR acme (1)
diff --git a/man/man4/factotum.4 b/man/man4/factotum.4
index 3a2d3d7cc..02466fcfb 100644
--- a/man/man4/factotum.4
+++ b/man/man4/factotum.4
@@ -10,7 +10,7 @@ factotum \- authentication agent
] [
.B -s
.I srvname
-]
+]
.\" [
.\" .B -m
.\" .I mtpt
@@ -79,7 +79,7 @@ same user id as it. For select protocols such as
it can also act as a client for other processes provided
its user id may speak for the other process' user id (see
Plan 9's
-\fIauthsrv\fR(6)).
+.IR authsrv (6)).
.I Factotum
can act in the role of server for any process.
.PP
@@ -127,7 +127,7 @@ RSA encryption and signatures, used by SSH and TLS.
passwords in the clear.
.TP
.B vnc
-.IR vnc (1)'s
+.MR vnc (1) 's
challenge/response.
.TP
.B wep
@@ -186,7 +186,7 @@ cpu server. On starting, it will attempt to get a
key from NVRAM using
.B readnvram
(see
-.IR authsrv (3)),
+.MR authsrv (3) ),
prompting for anything it needs.
It will never subsequently prompt for a
key that it doesn't have.
@@ -227,7 +227,7 @@ the kernel at boot time.
.PP
A
.I "key tuple
-is a space delimited list of
+is a space delimited list of
.IB attribute = value
pairs. An attribute whose name begins with an exclamation point
.RB ( ! )
@@ -245,7 +245,7 @@ specific to each supported protocol.
.PP
All keys can have additional attibutes that act either as comments
or as selectors to distinguish them in the
-.IR auth (3)
+.MR auth (3)
library calls.
.PP
The factotum owner can use any key stored by factotum.
@@ -305,9 +305,9 @@ such as
and
.B auth_challenge
(see
-.IR auth (3))
+.MR auth (3) )
to specify which key and protocol to use for an authentication.
-Like a key tuple, a key template is also a list of
+Like a key tuple, a key template is also a list of
.IB attribute = value
pairs.
It must specify at least the protocol and enough
@@ -367,7 +367,7 @@ turned on by the
option.
.PP
By default when factotum starts it looks for a
-.IR secstore (1)
+.MR secstore (1)
account on $auth for the user and, if one exists,
prompts for a secstore password in order to fetch
the file
@@ -385,11 +385,11 @@ sets a public/private keypair for ssh authentication,
generated by
.B ssh_genkey
(see
-.IR ssh (1)).
+.MR ssh (1) ).
.PD
.SS "Confirming key use
.PP
-The
+The
.B confirm
file provides a connection from
.I factotum
@@ -397,7 +397,7 @@ to a confirmation server, normally the program
.IR auth/fgui .
Whenever a key with the
.B confirm
-attribute is used,
+attribute is used,
.I factotum
requires confirmation of its use. If no process has
.B confirm
@@ -429,7 +429,7 @@ the same user id as
.IR factotum .
.SS "Prompting for keys
.PP
-The
+The
.B needkey
file provides a connection from
.I factotum
@@ -481,11 +481,11 @@ RPC's) until done
if successful, reading back an
.I AuthInfo
structure (see
-.IR authsrv (3)).
+.MR authsrv (3) ).
.PP
The RPC protocol is normally embodied by one of the
routines in
-.IR auth (3).
+.MR auth (3) .
We describe it here should anyone want to extend
the library.
.PP
@@ -545,7 +545,7 @@ necessary
authentication has succeeded, an
.B AuthInfo
structure (see
-.IR auth (3))
+.MR auth (3) )
can be retrieved with an
.B authinfo
RPC
@@ -621,7 +621,7 @@ is expected to be a long hexadecimal string.
These are useful for manually debugging of binary protocols.
.TP
.B authinfo
-retrieve the AuthInfo structure.
+retrieve the AuthInfo structure.
The possible replies are:
.RS
.TP
@@ -661,7 +661,7 @@ with its own roles and required key attributes.
and
.I p9cr
are used to authenticate to Plan 9 systems;
-valid
+valid
.BR role s
are
.B client
@@ -691,7 +691,7 @@ is a meta-protocol that negotiates a protocol
.RB ( p9sk1
or
.BR p9sk2 )
-and an authentication domain and then invokes the
+and an authentication domain and then invokes the
given protocol with a
.B dom=
attribute.
@@ -703,7 +703,7 @@ and
are intended to be proxied via
.I auth_proxy
(see
-.IR auth (3)).
+.MR auth (3) ).
.\" The protocols follow
.\" .IR p9any (7)
.\" and
@@ -736,7 +736,7 @@ before being sent over the network.
.PP
.I Vnc
is the challenge-response protocol used by
-.IR vnc (1);
+.MR vnc (1) ;
valid roles are
.B client
and
@@ -746,7 +746,7 @@ The client protocol requires a
key with attribute
.BR !password .
Conventionally, client keys also have
-.B user
+.B user
and
.B server
attributes.
@@ -763,7 +763,7 @@ except that the challenge and response are not textual.
and
.I cram
are challenge-response protocols typically
-used to authenticate
+used to authenticate
to mail servers.
The client protocols require
.B proto=apop
@@ -774,7 +774,7 @@ keys with
and
.B !password
attributes.
-Conventionally, client keys also have
+Conventionally, client keys also have
.B server
attributes.
The server protocol requires a
@@ -828,7 +828,7 @@ structure (defined in
.PP
.I Pass
is a client-only protocol that hands out passwords
-from
+from
.B proto=pass
keys with
.B user
@@ -840,7 +840,7 @@ a string: a space-separated quoted user name and password
that can be parsed with
.I tokenize
(see
-.IR getfields (3)).
+.MR getfields (3) ).
Conventionally, client keys have distinguishing attributes
like
.B service
@@ -860,7 +860,7 @@ keys with
.BR !key2 ,
or
.B !key3
-attributes.
+attributes.
The protocol with
.I factotum
is:
@@ -873,7 +873,7 @@ opens the device's control file, sets the wireless secret using the key,
and turns on encryption.
If the key has an
.B essid
-attribute,
+attribute,
.I factotum
uses it to set the wireless station ID.
.PP
@@ -891,7 +891,7 @@ uses
keys with
.B ek
and
-.B n
+.B n
attributes, large integers specifying the public half
of the key.
If a key is to be used for decryption or signing,
@@ -905,13 +905,13 @@ and
.BR !dk
specifying the private half of the key;
see
-.IR rsa (3).
+.MR rsa (3) .
Conventionally,
.I rsa
keys also have
.B service
attributes specifying the context in which the key is used:
-.B ssh
+.B ssh
(SSH version 1),
.B ssh-rsa
(SSH version 2),
@@ -946,7 +946,7 @@ and
The hash function must be known to
.I factotum
because the signature encodes the type of hash used.
-The
+The
.B encrypt
and
.B verify
@@ -972,11 +972,11 @@ attributes.
If the key is to be used for signing, it must also have a
.B !secret
attribute; see
-.IR dsa (3).
+.MR dsa (3) .
Conventionally,
.I dsa
keys
-also have
+also have
.B service
attributes specifying the context in which the key is used:
.B ssh-dss
@@ -992,7 +992,7 @@ Unlike
.IR rsa ,
the
.I dsa
-protocol ignores the
+protocol ignores the
.B hash
attribute; it always uses SHA1.
.PP
@@ -1019,4 +1019,4 @@ The response is a hexadecimal string of length 32.
.SH SOURCE
.B \*9/src/cmd/auth/factotum
.SH SEE ALSO
-.IR ssh-agent (1)
+.MR ssh-agent (1)
diff --git a/man/man4/fontsrv.4 b/man/man4/fontsrv.4
index 3fb0d66b9..6cc0d0a7d 100644
--- a/man/man4/fontsrv.4
+++ b/man/man4/fontsrv.4
@@ -20,7 +20,7 @@ fontsrv \- file system access to host fonts
presents the host window system's fonts
in the standard Plan 9 format
(see
-.IR font (7)).
+.MR font (7) ).
It serves a virtual directory tree mounted at
.I mtpt
(if the
@@ -31,13 +31,13 @@ and posted at
(default
.IR font ).
.PP
-The
+The
.B -p
-option changes
+option changes
.IR fontsrv 's
behavior: rather than serve a file system,
.I fontsrv
-prints to standard output the contents of the named
+prints to standard output the contents of the named
.IR path .
If
.I path
@@ -66,20 +66,20 @@ Each size directory contains a
file and subfont files
named
.BR x0000.bit ,
-.BR x0100.bit ,
+.BR x0020.bit ,
and so on
-representing 256-character Unicode ranges.
+representing 32-character Unicode ranges.
.PP
.I Openfont
(see
-.IR graphics (3))
-recognizes font paths beginning with
+.MR graphics (3) )
+recognizes font paths beginning with
.B /mnt/font
and implements them by invoking
.IR fontsrv ;
it need not be running already.
-See
-.IR font (7)
+See
+.MR font (7)
for a full discussion of font name syntaxes.
.SH EXAMPLES
List the fonts on the system:
@@ -95,8 +95,8 @@ or:
% fontsrv -p .
.EE
.LP
-Run
-.IR acme (1)
+Run
+.MR acme (1)
using the operating system's Monaco as the fixed-width font:
.IP
.EX
@@ -104,7 +104,7 @@ using the operating system's Monaco as the fixed-width font:
.EE
.LP
Run
-.IR sam (1)
+.MR sam (1)
using the same font:
.IP
.EX
@@ -113,7 +113,7 @@ using the same font:
.SH SOURCE
.B \*9/src/cmd/fontsrv
.SH SEE ALSO
-.IR font (7)
+.MR font (7)
.SH BUGS
.PP
Due to OS X restrictions,
diff --git a/man/man4/fossil.4 b/man/man4/fossil.4
index 7c06f2f7a..fd6dd0a9a 100644
--- a/man/man4/fossil.4
+++ b/man/man4/fossil.4
@@ -148,10 +148,10 @@ will be named
The attach name used in
.I mount
(see
-.IR bind (1),
-.IR bind (2)
+.MR bind (1) ,
+.MR bind (2)
and
-.IR attach (5))
+.MR attach (5) )
selects a file system to be served
and optionally a subtree,
in the format
@@ -163,7 +163,7 @@ An empty attach name selects
normally requires all users except
.L none
to provide authentication tickets on each
-.IR attach (5).
+.MR attach (5) .
To keep just anyone from connecting,
.L none
is only allowed to attach after another user
@@ -179,7 +179,7 @@ flag to
or
.B srv
(see
-.IR fossilcons (8)).
+.MR fossilcons (8) ).
.PP
The groups called
.B noworld
@@ -207,7 +207,7 @@ readable by the world but writable only to the developers.
starts a new instance of the fossil file server.
It is configured mainly through console commands,
documented in
-.IR fossilcons (8).
+.MR fossilcons (8) .
.PP
The options are:
.TF "-c\fI cmd
@@ -239,7 +239,7 @@ and
which starts a file server console on
.BI /srv/ cons \fR.
See
-.IR fossilcons (8)
+.MR fossilcons (8)
for more information.
.TP
.BI -f " file
@@ -269,7 +269,7 @@ for inconsistencies.
is deprecated in favor of the console
.B check
command (see
-.IR fossilcons (8)).
+.MR fossilcons (8) ).
.I Flchk
prints
.I fossil
@@ -375,7 +375,7 @@ system stored on Venti at
The score should have been generated by
.I fossil
rather than by
-.IR vac (1),
+.MR vac (1) ,
so that the appropriate snapshot metadata is present.
.PD
.PP
@@ -450,7 +450,7 @@ See the discussion of the
and
.B uname
commands in
-.IR fossilcons (8)
+.MR fossilcons (8)
for more about the user table.
.ne 3
.PP
@@ -488,13 +488,13 @@ command to prepare the script.
.SH SOURCE
.B \*9/src/cmd/fossil
.SH SEE ALSO
-.IR yesterday (1),
-.IR fs (3),
-.IR fs (4),
-.IR srv (4),
-.IR fossilcons (8),
-.IR loadfossil (8),
-.IR venti (8)
+.MR yesterday (1) ,
+.MR fs (3) ,
+.MR fs (4) ,
+.MR srv (4) ,
+.MR fossilcons (8) ,
+.MR loadfossil (8) ,
+.MR venti (8)
.SH BUGS
It is possible that the disk format (but not the Venti format)
will change in the future, to make the disk a full cache
diff --git a/man/man4/import.4 b/man/man4/import.4
index 9dd81d724..434a23bd0 100644
--- a/man/man4/import.4
+++ b/man/man4/import.4
@@ -48,7 +48,7 @@ the path have different meanings on the two systems.)
connects to
.I system
using
-.IR ssh (1).
+.MR ssh (1) .
It invokes
.I import
on the remote system to carry out the remote
@@ -109,5 +109,5 @@ sam &
.SH SOURCE
.B \*9/src/cmd/import.c
.SH SEE ALSO
-.IR 9pserve (4),
-.IR intro (4)
+.MR 9pserve (4) ,
+.MR intro (4)
diff --git a/man/man4/plumber.4 b/man/man4/plumber.4
index 0dfe68bb8..c309a39c2 100644
--- a/man/man4/plumber.4
+++ b/man/man4/plumber.4
@@ -4,6 +4,9 @@ plumber \- file system for interprocess messaging
.SH SYNOPSIS
.B plumber
[
+.B -f
+]
+[
.B -p
.I plumbing
]
@@ -11,19 +14,19 @@ plumber \- file system for interprocess messaging
The
.I plumber
is a user-level file server that receives, examines, rewrites, and dispatches
-.IR plumb (7)
+.MR plumb (7)
messages between programs.
Its behavior is programmed by a
.I plumbing
file (default
.BR $HOME/lib/plumbing )
in the format of
-.IR plumb (7).
+.MR plumb (7) .
.PP
Its services are posted via
-.IR 9pserve (4)
+.MR 9pserve (4)
as
-.BR plumb .
+.BR plumb ,
and consist of two
pre-defined files,
.B plumb/send
@@ -36,14 +39,14 @@ for dispatching messages to applications.
Programs use
.B fswrite
(see
-.IR 9pclient (3))
+.MR 9pclient (3) )
to deliver messages to the
.B send
file, and
.I fsread
to receive them from the corresponding port.
For example,
-.IR sam (1)'s
+.MR sam (1) 's
.B plumb
menu item or the
.B B
@@ -95,6 +98,10 @@ Thus the rule set may be edited dynamically with a traditional text editor.
However, ports are never deleted dynamically; if a new set of rules does not
include a port that was defined in earlier rules, that port will still exist (although
no new messages will be delivered there).
+.PP
+The
+.B -f
+option causes the process to run in the foreground.
.SH FILES
.TF $HOME/lib/plumbing
.TP
@@ -108,13 +115,13 @@ statements
.TP
.B plumb
mount name for
-.IR plumber (4).
+.MR plumber (4) .
.SH SOURCE
.B \*9/src/cmd/plumb
.SH "SEE ALSO"
-.IR plumb (1),
-.IR plumb (3),
-.IR plumb (7)
+.MR plumb (1) ,
+.MR plumb (3) ,
+.MR plumb (7)
.\" .SH BUGS
.\" .IR Plumber 's
.\" file name space is fixed, so it is difficult to plumb
diff --git a/man/man4/ramfs.4 b/man/man4/ramfs.4
index 25ae4bf67..794519810 100644
--- a/man/man4/ramfs.4
+++ b/man/man4/ramfs.4
@@ -21,7 +21,7 @@ By default
posts its service as
.B ramfs
using
-.IR 9pserve (4).
+.MR 9pserve (4) .
.PP
The
.B -S
@@ -46,5 +46,5 @@ It can also be used to provide high-performance temporary files.
.SH SOURCE
.B \*9/src/cmd/ramfs.c
.SH "SEE ALSO"
-.IR 9p (3),
-.IR 9pserve (4)
+.MR 9p (3) ,
+.MR 9pserve (4)
diff --git a/man/man4/smugfs.4 b/man/man4/smugfs.4
index 4fb8c7f0f..be3404b1b 100644
--- a/man/man4/smugfs.4
+++ b/man/man4/smugfs.4
@@ -24,7 +24,7 @@ is a user-level file system that provides access to images
stored on the SmugMug photo sharing service.
It logs in after
obtaining a password from
-.IR factotum (4)
+.MR factotum (4)
using
.B server=smugmug.com
and
@@ -32,7 +32,7 @@ and
(if any)
as key criteria
(see
-.IR auth (3)).
+.MR auth (3) ).
Then
.I smugfs
serves a virtual directory tree mounted at
@@ -265,7 +265,7 @@ SmugMug,
If multiple categories or albums have the same name,
only one will be accessible via the file system interface.
Renaming the accessible one via Unix's
-.IR mv (1)
+.MR mv (1)
will resolve the problem.
.PP
Boolean values appear as
diff --git a/man/man4/srv.4 b/man/man4/srv.4
index 856f88ff3..ae6a76349 100644
--- a/man/man4/srv.4
+++ b/man/man4/srv.4
@@ -22,7 +22,7 @@ srv, 9fs \- start network file service
dials the given address and initializes the connection to serve the 9P protocol.
It then posts the resulting connection in the current name space
(see
-.IR intro (4))
+.MR intro (4) )
as
.I srvname
(default
@@ -70,7 +70,7 @@ available as service
.IR sources .
.I 9fs
is an
-.IR rc (1)
+.MR rc (1)
script; examine it to see what local conventions apply.
.SH EXAMPLES
List the root directory on
@@ -98,6 +98,6 @@ sudo mount -t 9p -o trans=unix,uname=$USER,dfltuid=`id -u`,dfltgid=`id -g`
.br
.B \*9/bin/9fs
.SH "SEE ALSO
-.IR dial (3),
-.IR intro (4),
-.IR netfiles (1)
+.MR dial (3) ,
+.MR intro (4) ,
+.MR netfiles (1)
diff --git a/man/man4/tapefs.4 b/man/man4/tapefs.4
index 3297e2a42..669cc819b 100644
--- a/man/man4/tapefs.4
+++ b/man/man4/tapefs.4
@@ -91,7 +91,7 @@ Tenth Edition research Unix systems (4KB block size).
.PP
.I Zipfs
interprets zip archives (see
-.IR gzip (1)).
+.MR gzip (1) ).
.SH SOURCE
.PP
These commands are constructed in a highly stereotyped
@@ -103,7 +103,7 @@ in
.BR \*9/src/cmd/tapefs ,
which in
turn derive substantially from
-.IR ramfs (4).
+.MR ramfs (4) .
.SH "SEE ALSO
-.IR intro (7),
-.IR ramfs (4).
+.MR intro (7) ,
+.MR ramfs (4) .
diff --git a/man/man4/vacfs.4 b/man/man4/vacfs.4
index 143e782bf..f3287e359 100644
--- a/man/man4/vacfs.4
+++ b/man/man4/vacfs.4
@@ -26,7 +26,7 @@ vacfs \- a Venti-based file system
.SH DESCRIPTION
.I Vacfs
interprets the file system created by
-.IR vac (1)
+.MR vac (1)
so that it can be mounted into a Plan 9 file hierarchy.
The data for the file system is stored on a Venti server
with a root fingerprint specified in
@@ -37,7 +37,7 @@ clients are not authenticated, and groups are assumed to
contain a single member with the same name.
These restrictions should eventually be removed.
.PP
-Options to
+Options to
.I vacfs
are:
.TP
@@ -49,7 +49,7 @@ The network address of the Venti server.
The default is taken from the environment variable
.BR venti .
If this variable does not exist, then the default is the
-metaname
+metaname
.BR $venti .
.\" which can be configured via
.\" .IR ndb (6).
@@ -81,5 +81,6 @@ The amount of memory, in bytes, allocated to the block cache. The default is 16M
.SH SOURCE
.B \*9/src/cmd/vac
.SH "SEE ALSO"
-.IR vac (1),
-Plan 9's \fIventi\fR(8)
+.MR vac (1) ,
+Plan 9's
+.IR venti (8)
diff --git a/man/man7/color.7 b/man/man7/color.7
index c8b536a0c..917c25217 100644
--- a/man/man7/color.7
+++ b/man/man7/color.7
@@ -121,11 +121,11 @@ which is scaled so 0 represents fully transparent and 255 represents opaque colo
The alpha is
.I premultiplied
into the other channels, as described in the paper by Porter and Duff cited in
-.IR draw (3).
+.MR draw (3) .
The function
.B setalpha
(see
-.IR allocimage (3))
+.MR allocimage (3) )
aids the initialization of color values with non-trivial alpha.
.PP
The packing of pixels into bytes and words is odd.
@@ -138,13 +138,13 @@ the byte ordering is blue, green, red.
.PP
To maintain a constant external representation,
the
-.IR draw (3)
+.MR draw (3)
interface
as well as the
various graphics libraries represent colors
by 32-bit numbers, as described in
-.IR color (3).
+.MR color (3) .
.SH "SEE ALSO"
-.IR color (3),
-.IR graphics (3),
-.IR draw (3)
+.MR color (3) ,
+.MR graphics (3) ,
+.MR draw (3)
diff --git a/man/man7/face.7 b/man/man7/face.7
index 08b04a463..8cd378257 100644
--- a/man/man7/face.7
+++ b/man/man7/face.7
@@ -25,13 +25,13 @@ per color)).
The large files serve no special purpose; they are stored
as images
(see
-.IR image (7)).
+.MR image (7) ).
The small files are the `icons' displayed by
.B faces
and
.B seemail
(see Plan 9's
-\fIfaces\fR(1));
+.IR faces (1));
for depths less than 4, their format is special.
.PP
One- and two-bit deep icons are stored as text, one line of the file to one scan line
@@ -110,6 +110,6 @@ which then appears as a domain name in the
.B .dict
files.
.SH "SEE ALSO"
-.IR mail (1),
-.IR tweak (1),
-.IR image (7)
+.MR mail (1) ,
+.MR tweak (1) ,
+.MR image (7)
diff --git a/man/man7/font.7 b/man/man7/font.7
index 45331d4d2..c9ebb9197 100644
--- a/man/man7/font.7
+++ b/man/man7/font.7
@@ -5,7 +5,7 @@ font, subfont \- external format for fonts and subfonts
.B #include
.SH DESCRIPTION
Fonts and subfonts are described in
-.IR cachechars (3).
+.MR cachechars (3) .
.PP
External bitmap fonts are described by a plain text file that can be read using
.IR openfont .
@@ -21,7 +21,7 @@ with an optional starting position within the subfont,
and the file name names an external file suitable for
.I readsubfont
(see
-.IR graphics (3)).
+.MR graphics (3) ).
The minimum number of a covered range is mapped to the specified starting position
(default zero) of the
corresponding subfont.
@@ -36,11 +36,11 @@ that can be read and written using
and
.I writesubfont
(see
-.IR subfont (3)).
+.MR subfont (3) ).
The format for subfont files is: an image containing character glyphs,
followed by a subfont header, followed by character information.
The image has the format for external image files described in
-.IR image (7).
+.MR image (7) .
The subfont header has 3
decimal strings:
.BR n ,
@@ -72,7 +72,7 @@ are irrelevant.
.PP
Note that the convention of using the character with value zero (NUL) to represent
characters of zero width (see
-.IR draw (3))
+.MR draw (3) )
means that fonts should have, as their zeroth character,
one with non-zero width.
.SS "Font Names
@@ -121,7 +121,7 @@ The command
.B .
lists the available fonts.
See
-.IR fontsrv (4)
+.MR fontsrv (4)
for more.
.PP
If the font name has the form
@@ -136,7 +136,7 @@ The Plan 9 bitmap fonts were designed for screens with pixel density around 100
When used on screens with pixel density above 200 DPI,
the bitmap fonts are automatically pixel doubled.
Similarly, fonts loaded from
-.IR fontsrv (4)
+.MR fontsrv (4)
are automatically doubled in size by varying the effective
.I size
path element.
@@ -184,7 +184,7 @@ a system-installed vector font on high-density displays:
.B \*9/font/*
font directories
.SH "SEE ALSO"
-.IR graphics (3),
-.IR draw (3),
-.IR cachechars (3),
-.IR subfont (3)
+.MR graphics (3) ,
+.MR draw (3) ,
+.MR cachechars (3) ,
+.MR subfont (3)
diff --git a/man/man7/htmlroff.7 b/man/man7/htmlroff.7
index e908c3ff5..34f2cc5bd 100644
--- a/man/man7/htmlroff.7
+++ b/man/man7/htmlroff.7
@@ -2,7 +2,7 @@
.SH NAME
htmlroff \- HTML formatting and typesetting
.SH DESCRIPTION
-.IR Htmlroff (1)
+.MR Htmlroff (1)
accepts
.I troff
input with a few extensions and changes.
@@ -200,7 +200,7 @@ inside
.B
tags.
This heuristic handles simple equations formatted by
-.IR eqn (1).
+.MR eqn (1) .
.SS Conditional input
.PP
To make it easier to write input files that can be formatted by both
@@ -315,7 +315,7 @@ For example,
redefines the
.B PS
macro that marks the beginning of a
-.IR pic (1)
+.MR pic (1)
picture:
.IP
.EX
diff --git a/man/man7/image.7 b/man/man7/image.7
index 6e613f9c6..bfb299bd3 100644
--- a/man/man7/image.7
+++ b/man/man7/image.7
@@ -5,9 +5,9 @@ image \- external format for images
.B #include
.SH DESCRIPTION
Images are described in
-.IR graphics (3),
+.MR graphics (3) ,
and the definition of pixel values is in
-.IR color (7).
+.MR color (7) .
Fonts and images are stored in external files
in machine-independent formats.
.PP
@@ -21,7 +21,7 @@ and
and
.B writememimage
(see
-.IR memdraw (3)).
+.MR memdraw (3) ).
An uncompressed image file starts with 5
strings:
.BR chan ,
@@ -34,10 +34,10 @@ Each is right-justified and blank padded in 11 characters, followed by a blank.
The
.B chan
value is a textual string describing the pixel format
-(see
+(see
.B strtochan
in
-.IR graphics (3)
+.MR graphics (3)
and the discussion of channel descriptors below),
and the rectangle coordinates are decimal strings.
The rest of the file contains the
@@ -49,7 +49,7 @@ consists of the byte containing pixel
.B r.min.x
and all the bytes up to and including the byte containing pixel
.BR r.max.x -1.
-For images with depth
+For images with depth
.I d
less than eight, a pixel with x-coordinate =
.I x
@@ -73,11 +73,11 @@ The
and
.B unloadimage
functions described in
-.IR allocimage (3)
+.MR allocimage (3)
also deal with rows in this format, stored in user memory.
.PP
The channel format string is a sequence of two-character channel descriptions,
-each comprising a letter
+each comprising a letter
.RB ( r
for red,
.B g
@@ -95,10 +95,10 @@ and
for ``don't care'')
followed by a number of bits per pixel.
The sum of the channel bits per pixel is the
-depth of the image, which must be either
+depth of the image, which must be either
a divisor or a multiple of eight.
It is an error to have more than
-one of any channel but
+one of any channel but
.BR x .
An image must have either a greyscale channel; a color mapped channel;
or red, green, and blue channels.
@@ -110,13 +110,13 @@ In particular
.B 'r8g8b8'
pixels have byte ordering blue, green, and red within the file.
See
-.IR color (7)
+.MR color (7)
for more details of the pixel format.
.PP
A venerable yet deprecated format replaces the channel string
with a decimal
.IR ldepth ,
-which is the base two logarithm of the number
+which is the base two logarithm of the number
of bits per pixel in the image.
In this case,
.IR ldepth s
@@ -177,9 +177,9 @@ Some small images, in particular 48\(mu48 face files
as used by
.I seemail
(see Plan 9's
-\fIfaces\fR(1)
+.IR faces (1)
and
-.IR face (7))
+.MR face (7) )
and 16\(mu16
cursors, can be stored textually, suitable for inclusion in C source.
Each line of text represents one scan line as a
@@ -188,18 +188,18 @@ bytes, shorts, or words in C format.
For cursors, each line defines a pair of bytes.
(It takes two images to define a cursor; each must be stored separately
to be processed by programs such as
-.IR tweak (1).)
+.MR tweak (1) .)
Face files of one bit per pixel are stored as a sequence of shorts,
those of larger pixel sizes as a sequence of longs.
Software that reads these files must deduce the image size from
the input; there is no header.
These formats reflect history rather than design.
.SH "SEE ALSO"
-.IR jpg (1),
-.IR tweak (1),
-.IR graphics (3),
-.IR draw (3),
-.IR allocimage (3),
-.IR color (7),
-.IR face (7),
-.IR font (7)
+.MR jpg (1) ,
+.MR tweak (1) ,
+.MR graphics (3) ,
+.MR draw (3) ,
+.MR allocimage (3) ,
+.MR color (7) ,
+.MR face (7) ,
+.MR font (7)
diff --git a/man/man7/keyboard.7 b/man/man7/keyboard.7
index bc7cb5afb..69094a221 100644
--- a/man/man7/keyboard.7
+++ b/man/man7/keyboard.7
@@ -49,16 +49,16 @@ in particular, control-J is a line feed and control-M a carriage return.
.PP
The down arrow,
used by
-.IR 9term (1),
-.IR acme (1),
+.MR 9term (1) ,
+.MR acme (1) ,
and
-.IR sam (1),
+.MR sam (1) ,
causes windows to scroll forward.
The up arrow scrolls backward.
.PP
Characters in Plan 9 are runes (see
-.IR utf (7)).
-Any 16-bit rune can be typed using a compose key followed by several
+.MR utf (7) ).
+Any rune can be typed using a compose key followed by several
other keys.
The compose key is also generally near the lower right of the main key area:
the
@@ -72,24 +72,31 @@ key on the SLC, the
key on the Magnum, and either
.B Alt
key on the PC.
-After typing the compose key, type a capital
-.L X
-and exactly four hexadecimal characters (digits and
+To type a single rune with the value specified by
+a given four-digit hexadecimal number,
+type the compose key,
+then a capital
+.LR X ,
+and then the four hexadecimal digits (decimal digits and
.L a
to
-.LR f )
-to type a single rune with the value represented by
-the typed number.
+.LR f ).
+For a longer rune, type
+.L X
+twice followed by five digits,
+or type
+.L X
+three times followed by six digits.
There are shorthands for many characters, comprising
the compose key followed by a two- or three-character sequence.
The full list is too long to repeat here, but is contained in the file
.L \*9/lib/keyboard
in a format suitable for
-.IR grep (1)
+.MR grep (1)
or
-.IR look (1).
+.MR look (1) .
To add a sequence, edit that file and then rebuild
-.IR devdraw (1).
+.MR devdraw (1) .
.PP
There are several rules guiding the design of the sequences, as
illustrated by the following examples.
@@ -228,10 +235,10 @@ to run them automatically at startup.
sorted table of characters and keyboard sequences
.PD
.SH "SEE ALSO"
-.IR intro (1),
-.IR ascii (1),
-.IR tcs (1),
-.IR 9term (1),
-.IR acme (1),
-.IR sam (1),
-.IR utf (7)
+.MR intro (1) ,
+.MR ascii (1) ,
+.MR tcs (1) ,
+.MR 9term (1) ,
+.MR acme (1) ,
+.MR sam (1) ,
+.MR utf (7)
diff --git a/man/man7/man.7 b/man/man7/man.7
index 0e2b52bab..f82a1bc7c 100644
--- a/man/man7/man.7
+++ b/man/man7/man.7
@@ -82,9 +82,9 @@ font- or size-setting macros.
The
.B -man
macros admit equations and tables in the style of
-.IR eqn (1)
+.MR eqn (1)
and
-.IR tbl (1),
+.MR tbl (1) ,
but do not support arguments on
.B .EQ
and
@@ -113,7 +113,7 @@ The root directory of the Plan 9 installation.
.B \*9/tmac/tmac.antimes
.SH SEE ALSO
.IR troff (1),
-.IR man (1)
+.MR man (1)
.SH REQUESTS
.ta \w'.TH n c x 'u +\w'Cause 'u +\w'Argument\ 'u
.di xx
diff --git a/man/man7/map.7 b/man/man7/map.7
index 80e1eebff..ced8db491 100644
--- a/man/man7/map.7
+++ b/man/man7/map.7
@@ -80,7 +80,7 @@ in the map file.
Both the map file and the index file are ordered by
patch latitude and longitude.
.SH "SEE ALSO"
-.IR map (7)
+.MR map (7)
.br
The data comes from the World Data Bank I and II and
U.S. Government sources: the Census Bureau, Geological
diff --git a/man/man7/mhtml.7 b/man/man7/mhtml.7
index dcf49868d..f561fb43a 100644
--- a/man/man7/mhtml.7
+++ b/man/man7/mhtml.7
@@ -19,14 +19,14 @@ mhtml \- macros for formatting HTML
\&...
.SH DESCRIPTION
This package of
-.IR htmlroff (1)
+.MR htmlroff (1)
macro definitions provides convenient macros for formatting HTML.
It is usually used along with
-.IR troff (1)
+.MR troff (1)
macro packages such as
-.IR man (7)
+.MR man (7)
and
-.IR ms (7).
+.MR ms (7) .
.I Mhtml
replaces some macros defined in the other packages,
so it should be listed after them on the
@@ -64,7 +64,7 @@ before invoking
Accumulate footnotes and print them at the end of the
document under a \fBNotes\fP heading.
These replace the macros in
-.IR ms (7).
+.MR ms (7) .
To emit the notes accumulated so far, invoke
.BR .NOTES .
.TP
@@ -75,7 +75,7 @@ and
.B .PE
with a PNG image corresponding to the output of
running
-.IR troff (1)
+.MR troff (1)
on the input.
.TP
.B .TS\fR, \fP.TE
@@ -100,6 +100,6 @@ percent of the current output width.
.SH FILES
.B \*9/tmac/tmac.html
.SH SEE ALSO
-.IR htmlroff (1),
-.IR htmlroff (7),
-.IR ms (7)
+.MR htmlroff (1) ,
+.MR htmlroff (7) ,
+.MR ms (7)
diff --git a/man/man7/mpictures.7 b/man/man7/mpictures.7
index d6dbf964d..5da1d547a 100644
--- a/man/man7/mpictures.7
+++ b/man/man7/mpictures.7
@@ -10,7 +10,7 @@ mpictures \- picture inclusion macros
.SH DESCRIPTION
.I Mpictures
macros insert PostScript pictures into
-.IR troff (1)
+.MR troff (1)
documents.
The macros are:
.TP
@@ -129,7 +129,7 @@ comment is present, the picture is
assumed to fill an 8.5\(mu11-inch page.
Nothing prevents the picture from being placed off the page.
.SH SEE ALSO
-.IR troff (1)
+.MR troff (1)
.SH DIAGNOSTICS
A picture file that can't be read by the PostScript
postprocessor is replaced by white space.
diff --git a/man/man7/ms.7 b/man/man7/ms.7
index 931dad1b5..5886a7e19 100644
--- a/man/man7/ms.7
+++ b/man/man7/ms.7
@@ -18,7 +18,7 @@ ms \- macros for formatting manuscripts
This package of
.I nroff
and
-.IR troff (1)
+.MR troff (1)
macro definitions provides a canned formatting
facility for tech%nical papers in various formats.
.PP
@@ -38,11 +38,11 @@ impunity after the first
.LR .na .
.PP
Output of the
-.IR eqn (1),
-.IR tbl (1),
-.IR pic (1)
+.MR eqn (1) ,
+.MR tbl (1) ,
+.MR pic (1)
and
-.IR grap (1)
+.MR grap (1)
preprocessors
for equations, tables, pictures, and graphs is acceptable as input.
.SH FILES
@@ -57,8 +57,8 @@ Tenth Edition, Volume 2.
.br
.IR eqn (1),
.IR troff (1),
-.IR tbl (1),
-.IR pic (1)
+.MR tbl (1) ,
+.MR pic (1)
.SH REQUESTS
.ta \w'..ND \fIdate\fR 'u +\w'Initial 'u +\w'Cause 'u
.br
@@ -153,7 +153,7 @@ Implies
produced by
.I neqn
or
-.IR eqn (1).
+.MR eqn (1) .
.ti0
\fL\&.EQ\fP \fIx y\fR - yes Display equation.
Equation number is
@@ -234,7 +234,7 @@ is subsection level (default 1).
\fL\&.P2\fP - yes End program display.
.ti0
\fL\&.PE\fP - yes End picture; see
-.IR pic (1).
+.MR pic (1) .
.ti0
\fL\&.PF\fP - yes End picture; restore vertical
position.
@@ -280,7 +280,7 @@ font automatically bold.
Default is 5 10 15 ...
.ti0
\fL\&.TE\fP - yes End table; see
-.IR tbl (1).
+.MR tbl (1) .
.ti0
\fL\&.TH\fP - yes End heading section of table.
.ti0
diff --git a/man/man7/ndb.7 b/man/man7/ndb.7
index 4387f99d2..bb59d8aab 100644
--- a/man/man7/ndb.7
+++ b/man/man7/ndb.7
@@ -59,7 +59,7 @@ Within tuples, pairs on the same line bind tighter than
pairs on different lines.
.PP
Programs search the database directly using the routines in
-.IR ndb (3).
+.MR ndb (3) .
.\" or indirectly using
.\" .B ndb/cs
.\" and
@@ -292,8 +292,8 @@ tcp=9fs port=564
first database file searched
.SH "SEE ALSO"
.\" .IR dial (2),
-.IR ndb (1),
-.IR ndb (3)
+.MR ndb (1) ,
+.MR ndb (3)
.\" .IR dhcpd (8),
.\" .IR ipconfig (8),
.\" .IR con (1)
diff --git a/man/man7/plot.7 b/man/man7/plot.7
index d4550f51e..87308b3f2 100644
--- a/man/man7/plot.7
+++ b/man/man7/plot.7
@@ -340,4 +340,4 @@ Restore previous environment.
.PD
.SH "SEE ALSO"
.IR plot (1),
-.IR graph (1)
+.MR graph (1)
diff --git a/man/man7/plumb.7 b/man/man7/plumb.7
index fd30ee04d..37b2385b5 100644
--- a/man/man7/plumb.7
+++ b/man/man7/plumb.7
@@ -6,7 +6,7 @@ plumb \- format of plumb messages and rules
.SH DESCRIPTION
.SS "Message format
The messages formed by the
-.IR plumb (3)
+.MR plumb (3)
library are formatted for transmission between
processes into textual form, using newlines to separate
the fields.
@@ -61,7 +61,7 @@ A missing field is represented by an empty line.
The
.B plumber
(see
-.IR plumb (1))
+.MR plumb (1) )
receives messages on its
.B send
port (applications
@@ -271,7 +271,7 @@ rule should be specified in a rule set.
.RE
.PP
The arguments to all rules may contain quoted strings, exactly as in
-.IR rc (1).
+.MR rc (1) .
They may also contain simple string variables, identified by a leading dollar sign
.BR $ .
Variables may be set, between rule sets, by assignment statements in the style of
@@ -341,7 +341,7 @@ field of the message.
.B $plan9
The root directory of the Plan 9 tree
(see
-.IR get9root (3)).
+.MR get9root (3) ).
.RE
.SH EXAMPLE
The following is a modest, representative file of plumbing rules.
@@ -403,7 +403,7 @@ default rules file.
.TP
.B plumb
service name for
-.IR plumber (4).
+.MR plumber (4) .
.TP
.B \*9/plumb
directory for
@@ -416,7 +416,7 @@ public macro definitions.
.B \*9/plumb/basic
basic rule set.
.SH "SEE ALSO"
-.IR plumb (1),
-.IR plumb (3),
-.IR plumber (4),
-.IR regexp (7)
+.MR plumb (1) ,
+.MR plumb (3) ,
+.MR plumber (4) ,
+.MR regexp (7)
diff --git a/man/man7/regexp.7 b/man/man7/regexp.7
index 91e73adc5..73fd4dded 100644
--- a/man/man7/regexp.7
+++ b/man/man7/regexp.7
@@ -4,9 +4,9 @@ regexp \- Plan 9 regular expression notation
.SH DESCRIPTION
This manual page describes the regular expression
syntax used by the Plan 9 regular expression library
-.IR regexp (3).
+.MR regexp (3) .
It is the form used by
-.IR egrep (1)
+.MR egrep (1)
before
.I egrep
got complicated.
@@ -130,4 +130,4 @@ A match to any part of a regular expression
extends as far as possible without preventing
a match to the remainder of the regular expression.
.SH "SEE ALSO"
-.IR regexp (3)
+.MR regexp (3)
diff --git a/man/man7/thumbprint.7 b/man/man7/thumbprint.7
index 743172de6..5a4b933ba 100644
--- a/man/man7/thumbprint.7
+++ b/man/man7/thumbprint.7
@@ -9,7 +9,7 @@ for example by calling
and
.B okThumbprint
(see
-.IR pushtls (3)),
+.MR pushtls (3) ),
check the remote side's public key by comparing against
thumbprints from a trusted list.
The list is maintained by people who set local policies
@@ -38,4 +38,4 @@ For example, a web server might have thumbprint
x509 sha1=8fe472d31b360a8303cd29f92bd734813cbd923c cn=*.cs.bell-labs.com
.EE
.SH "SEE ALSO"
-.IR pushtls (3)
+.MR pushtls (3)
diff --git a/man/man7/utf.7 b/man/man7/utf.7
index a24094576..5ad61764a 100644
--- a/man/man7/utf.7
+++ b/man/man7/utf.7
@@ -57,7 +57,7 @@ in order to work properly with non-\c
.SM ASCII
input.
See
-.IR rune (3).
+.MR rune (3) .
.PP
Letting numbers be binary,
a rune x is converted to a multibyte
@@ -85,7 +85,7 @@ In the inverse mapping,
any sequence except those described above
is incorrect and is converted to rune hexadecimal 0080.
.SH "SEE ALSO"
-.IR ascii (1),
-.IR tcs (1),
-.IR rune (3),
+.MR ascii (1) ,
+.MR tcs (1) ,
+.MR rune (3) ,
.IR "The Unicode Standard" .
diff --git a/man/man7/venti.7 b/man/man7/venti.7
index 382bf67bd..800c85f3b 100644
--- a/man/man7/venti.7
+++ b/man/man7/venti.7
@@ -14,19 +14,19 @@ of clients.
This manual page documents the basic concepts of
block storage using Venti as well as the Venti network protocol.
.PP
-.IR Venti (1)
+.MR Venti (1)
documents some simple clients.
-.IR Vac (1),
-.IR vacfs (4),
+.MR Vac (1) ,
+.MR vacfs (4) ,
and
-.IR vbackup (8)
+.MR vbackup (8)
are more complex clients.
.PP
-.IR Venti (3)
+.MR Venti (3)
describes a C library interface for accessing
Venti servers and manipulating Venti data structures.
.PP
-.IR Venti (8)
+.MR Venti (8)
describes the programs used to run a Venti server.
.PP
.SS "Scores
@@ -40,11 +40,11 @@ Scores may have an optional
prefix, typically used to
describe the format of the data.
For example,
-.IR vac (1)
+.MR vac (1)
uses a
.B vac:
prefix, while
-.IR vbackup (8)
+.MR vbackup (8)
uses prefixes corresponding to the file system
types:
.BR ext2: ,
@@ -93,7 +93,7 @@ Keeping this parallel representation is a minor annoyance
but makes it possible for general programs like
.I venti/copy
(see
-.IR venti (1))
+.MR venti (1) )
to traverse the block tree without knowing the specific details
of any particular program's data.
.SS "Block Types
@@ -202,7 +202,7 @@ Text strings are represented similarly,
using a two-byte count with
the text itself stored as a UTF-encoded sequence
of Unicode characters (see
-.IR utf (7)).
+.MR utf (7) ).
Text strings are not
.SM NUL\c
-terminated:
@@ -395,7 +395,7 @@ Use
and
.I vtfromdisktype
(see
-.IR venti (3))
+.MR venti (3) )
to convert a block type enumeration value
.RB ( VtDataType ,
etc.)
@@ -457,9 +457,9 @@ in the
packet may be either 2 or 4 bytes;
the total packet length distinguishes the two cases.
.SH SEE ALSO
-.IR venti (1),
-.IR venti (3),
-.IR venti (8)
+.MR venti (1) ,
+.MR venti (3) ,
+.MR venti (8)
.br
Sean Quinlan and Sean Dorward,
``Venti: a new approach to archival storage'',
diff --git a/man/man8/fossilcons.8 b/man/man8/fossilcons.8
index b59b6b6a7..8ad9d4beb 100644
--- a/man/man8/fossilcons.8
+++ b/man/man8/fossilcons.8
@@ -340,7 +340,7 @@ con /srv/fscons
.SH DESCRIPTION
These are configuration and maintenance commands
executed at the console of a
-.IR fossil (4)
+.MR fossil (4)
file server.
The commands are split into three groups above:
file server configuration,
@@ -372,11 +372,11 @@ a file in any file system served by
.I 9p
executes a 9P transaction; the arguments
are in the same format used by
-.IR 9pcon (8).
+.MR 9pcon (8) .
.PP
.I Bind
behaves similarly to
-.IR bind (1).
+.MR bind (1) .
It is useful when fossil
is started without devices it needs configured
into its namespace.
@@ -389,7 +389,7 @@ standard error.
.PP
.I Echo
behaves identically to
-.IR echo (1),
+.MR echo (1) ,
writing to the console.
.PP
.I Listen
@@ -492,7 +492,7 @@ the string used to represent this user in the 9P protocol
.TP
.I leader
the group's leader (see Plan 9's
-.IR stat (5)
+.MR stat (5)
for a description of the special privileges held by a group leader)
.TP
.I members
@@ -821,7 +821,7 @@ removing a non-empty directory.
A subsequent
.I flchk
(see
-.IR fossil (4))
+.MR fossil (4) )
will identify the abandoned storage so it can be reclaimed with
.I bfree
commands.
@@ -1013,7 +1013,7 @@ takes a temporary snapshot of the current file system,
recording it in
.BI /snapshot/ yyyy / mmdd / hhmm \fR,
as described in
-.IR fossil (4).
+.MR fossil (4) .
The
.B -a
flag causes
@@ -1021,7 +1021,7 @@ flag causes
to take an archival snapshot, recording it in
.BI /archive/ yyyy / mmdd \fR,
also described in
-.IR fossil (4).
+.MR fossil (4) .
By default the snapshot is taken of
.BR /active ,
the root of the active file system.
@@ -1132,7 +1132,7 @@ writes dirty blocks in memory to the disk.
.PP
.I Vac
prints the Venti score for a
-.IR vac (1)
+.MR vac (1)
archive containing the tree rooted
at
.IR dir ,
diff --git a/man/man8/getflags.8 b/man/man8/getflags.8
index 86c295b9c..776a17aa2 100644
--- a/man/man8/getflags.8
+++ b/man/man8/getflags.8
@@ -16,7 +16,7 @@ not take arguments, or a letter followed by the space-separated
names of its arguments.
.I Getflags
prints an
-.IR rc (1)
+.MR rc (1)
script on standard output which initializes the
environment variable
.BI $flag x
@@ -51,15 +51,15 @@ and
.BR $0 ,
the program name
(see
-.IR rc (1)).
+.MR rc (1) ).
If run under
-.IR sh (1),
+.MR sh (1) ,
which does not set
.BR $0 ,
the program name must be given explicitly on the command line.
.SH EXAMPLE
Parse the arguments for Plan 9's
-.IR leak (1):
+.MR leak (1) :
.IP
.EX
flagfmt='b,s,f binary,r res,x width'
@@ -74,4 +74,4 @@ if(! ifs=() eval `{getflags $*} || ~ $#* 0){
.br
.B \*9/src/cmd/usage.c
.SH SEE ALSO
-.IR arg (3)
+.MR arg (3)
diff --git a/man/man8/listen1.8 b/man/man8/listen1.8
index 534766bfd..98f560f32 100644
--- a/man/man8/listen1.8
+++ b/man/man8/listen1.8
@@ -17,9 +17,7 @@ listen1 \- listen for calls on a network device
.I Listen1
is a lightweight listener intended for personal use,
modeled from Inferno's
-.\" write out this way so automatic programs
-.\" don't try to make it into a real man page reference.
-\fIlisten\fR(1).
+.IR listen (1).
It
announces on
.IR address ,
@@ -28,7 +26,7 @@ running
.I args...
for each incoming connection;
the network directory is passed in the environment
-as
+as
.BR $net .
The
.B -v
@@ -36,4 +34,4 @@ flag causes verbose logging on standard output.
.SH SOURCE
.B \*9/src/cmd/listen1.c
.SH "SEE ALSO"
-.IR dial (3)
+.MR dial (3)
diff --git a/man/man8/mkfs.8 b/man/man8/mkfs.8
index 2eaba6c1c..073e55b2f 100644
--- a/man/man8/mkfs.8
+++ b/man/man8/mkfs.8
@@ -34,7 +34,7 @@ copies files from the file tree
to a
.B kfs
file system (see
-.IR kfs (4)).
+.MR kfs (4) ).
The kfs service is mounted on
.I root
(default
@@ -47,7 +47,7 @@ The
.I proto
files are read
(see
-.IR proto (2)
+.MR proto (2)
for their format)
and any files specified in them that are out of date are copied to
.BR /n/kfs .
@@ -183,5 +183,5 @@ disk/mkext -u -d /n/newfs < arch
.br
.B \*9/src/cmd/disk/mkext.c
.SH "SEE ALSO"
-.IR prep (8),
-.IR tar (1)
+.MR prep (8) ,
+.MR tar (1)
diff --git a/man/man8/vbackup.8 b/man/man8/vbackup.8
index 89da1da57..fa201f400 100644
--- a/man/man8/vbackup.8
+++ b/man/man8/vbackup.8
@@ -70,7 +70,7 @@ back up Unix file systems to Venti
.SH DESCRIPTION
These programs back up and restore standard
Unix file system images stored in
-.IR venti (8).
+.MR venti (8) .
Images stored in
.I venti
are named by
@@ -102,7 +102,7 @@ The argument
.I disk
should be a disk or disk partition device
that would be appropriate to pass to
-.IR mount (8).
+.MR mount (8) .
.PP
The optional argument
.I score
@@ -135,7 +135,7 @@ The default
is the name returned by
.I sysname
(see
-.IR getuser (3)).
+.MR getuser (3) ).
The default
.I mtpt
is the place where
@@ -149,7 +149,7 @@ command.
The default is the name returned by
.I sysname
(see
-.IR getuser (3)).
+.MR getuser (3) ).
.TP
.B -n
No-op mode: do not write any blocks to the server
@@ -207,7 +207,7 @@ to zero unused blocks instead.
.PP
.I Vftp
presents an
-.IR ftp (1)-like
+.MR ftp (1) -like
interface to a physical or backed-up disk image.
It is used mainly for debugging.
Type
@@ -228,7 +228,7 @@ must be run by the user
Because
.I address
is passed to the host OS kernel rather than interpreted by
-.IR dial (3),
+.MR dial (3) ,
it must be only an IP address, not a full dial address.
.PP
.I Vnfs
@@ -394,7 +394,7 @@ Mount the backups on a client machine using
.IR vmount :
.IP
.EX
-# vmount udp!yourserver!nfs /dump
+# vmount yourserver /dump
# ls /dump/bob/2005
0510
0511
diff --git a/man/man8/venti-backup.8 b/man/man8/venti-backup.8
index 10614a501..131514c65 100644
--- a/man/man8/venti-backup.8
+++ b/man/man8/venti-backup.8
@@ -104,8 +104,8 @@ for a version that does this.
.SH SOURCE
.B \*9/src/cmd/venti/srv
.SH SEE ALSO
-.IR venti (7),
-.IR venti (8)
+.MR venti (7) ,
+.MR venti (8)
.SH BUGS
.I Wrarena
can't read a pipe or network connection containing an arena;
diff --git a/man/man8/venti-fmt.8 b/man/man8/venti-fmt.8
index 7c44754f6..399068621 100644
--- a/man/man8/venti-fmt.8
+++ b/man/man8/venti-fmt.8
@@ -99,9 +99,9 @@ syncindex \- prepare and maintain a venti server
These commands aid in the setup, maintenance, and debugging of
venti servers.
See
-.IR venti (7)
+.MR venti (7)
for an overview of the venti system and
-.IR venti (8)
+.MR venti (8)
for an overview of the data structures used by the venti server.
.PP
Note that the units for the various sizes in the following
@@ -195,7 +195,7 @@ formats the given
.I file
as a Bloom filter
(see
-.IR venti (7)).
+.MR venti (7) ).
The options are:
.TF "\fL-s\fI size"
.PD
@@ -264,7 +264,7 @@ overflow. The total size of the index should be about 2% to 10% of
the total size of the arenas, but the exact percentage depends both on the
index block size and the compressed size of blocks stored.
See the discussion in
-.IR venti (8)
+.MR venti (8)
for more.
.PP
.I Fmtindex
@@ -401,8 +401,8 @@ Increase the verbosity of output.
.SH SOURCE
.B \*9/src/cmd/venti/srv
.SH SEE ALSO
-.IR venti (7),
-.IR venti (8)
+.MR venti (7) ,
+.MR venti (8)
.SH BUGS
.I Buildindex
should allow an individual index section to be rebuilt.
diff --git a/man/man8/venti.8 b/man/man8/venti.8
index d95edaa9b..6a6d53e0d 100644
--- a/man/man8/venti.8
+++ b/man/man8/venti.8
@@ -40,7 +40,7 @@ venti \- archival storage server
.I Venti
is a SHA1-addressed archival storage server.
See
-.IR venti (7)
+.MR venti (7)
for a full introduction to the system.
This page documents the structure and operation of the server.
.PP
@@ -138,7 +138,7 @@ less than 10 are not very useful;
greater than 24 are probably a waste of memory.
.I Fmtbloom
(see
-.IR venti-fmt (8))
+.MR venti-fmt (8) )
can be given either
.I nhash
or
@@ -220,7 +220,7 @@ The venti server announces two network services, one
.BR venti ,
17034) serving
the venti protocol as described in
-.IR venti (7),
+.MR venti (7) ,
and one serving HTTP
(conventionally TCP port
.BR http ,
@@ -272,12 +272,30 @@ Set
to
.IR value .
.TP
-.BI /graph/ name / param / param / \fR...
-A PNG image graphing the named run-time statistic over time.
-The details of names and parameters are undocumented;
-see
+.BI /graph?arg= name [&arg2= name] &graph= type ¶m= value \fR...
+A PNG image graphing the
+.IT name
+run-time statistic over time.
+The details of names and parameters are mostly undocumented;
+see the
+.BR graphname
+array in
.B httpd.c
-in the venti sources.
+in the venti code for a list of possible statistics. The
+.IR type
+of graph defaults to raw, see the
+.BR xgraph
+function for a list of types. Possible
+.IR param
+include the timeframe
+.BR (t0
+and
+.BR t1)
+, the y limits
+.BR (min
+and
+.BR max)
+ etc.
.TP
.B /log
A list of all debugging logs present in the server's memory.
@@ -315,7 +333,7 @@ with
or
.I fmtisect
(see
-.IR venti-fmt (8)).
+.MR venti-fmt (8) ).
In particular, only the configuration needs to be
changed if a component is moved to a different file.
.PP
@@ -376,8 +394,7 @@ network address to announce venti service
.TP
.BI httpaddr " netaddr
network address to announce HTTP service
-(default
-.BR tcp!*!http )
+(default is not to start the service)
.TP
.B queuewrites
queue writes in memory
@@ -489,11 +506,11 @@ Start the server and check the storage statistics:
.SH SOURCE
.B \*9/src/cmd/venti/srv
.SH "SEE ALSO"
-.IR venti (1),
-.IR venti (3),
-.IR venti (7),
-.IR venti-backup (8)
-.IR venti-fmt (8)
+.MR venti (1) ,
+.MR venti (3) ,
+.MR venti (7) ,
+.MR venti-backup (8)
+.MR venti-fmt (8)
.br
Sean Quinlan and Sean Dorward,
``Venti: a new approach to archival storage'',
@@ -506,7 +523,7 @@ Venti should not require the user to decide how to
partition its memory usage.
.PP
Users of shells other than
-.IR rc (1)
+.MR rc (1)
will not be able to use the program names shown.
One solution is to define
.B "V=$PLAN9/bin/venti"
diff --git a/man/man9/0intro.9p b/man/man9/0intro.9p
index 397486f83..30e153a1d 100644
--- a/man/man9/0intro.9p
+++ b/man/man9/0intro.9p
@@ -21,7 +21,7 @@ such a machine is called, somewhat confusingly, a
Another possibility for a server is to synthesize
files on demand, perhaps based on information on data structures
maintained in memory; the
-.IR plumber (4)
+.MR plumber (4)
server is an example of such a server.
.PP
A
@@ -63,7 +63,7 @@ bytes of data.
Text strings are represented this way,
with the text itself stored as a UTF-8
encoded sequence of Unicode characters (see
-.IR utf (7)).
+.MR utf (7) ).
Text strings in 9P messages are not
.SM NUL\c
-terminated:
@@ -114,7 +114,7 @@ Plan 9 names may contain any printable character (that is, any character
outside hexadecimal 00-1F and 80-9F)
except slash.)
Messages are transported in byte form to allow for machine independence;
-.IR fcall (3)
+.MR fcall (3)
describes routines that convert to and from this form into a machine-dependent
C structure.
.SH MESSAGES
@@ -348,7 +348,7 @@ a ``current file'' on the server.
Fids are somewhat like file descriptors in a user process,
but they are not restricted to files open for I/O:
directories being examined, files being accessed by
-.IR stat (3)
+.MR stat (3)
calls, and so on \(em all files being manipulated by the operating
system \(em are identified by fids.
Fids are chosen by the client.
@@ -461,7 +461,7 @@ to have their input or output attached to fids on 9P servers.
See
.IR openfd (9p)
and
-.IR 9pclient (3)
+.MR 9pclient (3)
for details.
.PP
The
@@ -475,7 +475,7 @@ access permissions (read, write and execute for owner, group and public),
access and modification times, and
owner and group identifications
(see
-.IR stat (3)).
+.MR stat (3) ).
The owner and group identifications are textual names.
The
.B wstat
@@ -523,12 +523,12 @@ into 9P messages.
.SS Unix
On Unix, 9P services are posted as Unix domain sockets in a
well-known directory (see
-.IR getns (3)
+.MR getns (3)
and
-.IR 9pserve (4)).
+.MR 9pserve (4) ).
Clients connect to these servers using a 9P client library
(see
-.IR 9pclient (3)).
+.MR 9pclient (3) ).
.SH DIRECTORIES
Directories are created by
.B create
diff --git a/man/man9/attach.9p b/man/man9/attach.9p
index ddcf7476d..4160f30d6 100644
--- a/man/man9/attach.9p
+++ b/man/man9/attach.9p
@@ -122,7 +122,7 @@ and
and
.I fsauth
(see
-.IR 9pclient (3))
+.MR 9pclient (3) )
generate
.B attach
and
@@ -163,6 +163,6 @@ transactions.
.\" .B mount
.\" system call on an uninitialized connection.
.SH SEE ALSO
-.IR 9pclient (3),
+.MR 9pclient (3) ,
.IR version (9P),
Plan 9's \fIauthsrv\fR(6)
diff --git a/man/man9/clunk.9p b/man/man9/clunk.9p
index ef3ecdc47..f014ac426 100644
--- a/man/man9/clunk.9p
+++ b/man/man9/clunk.9p
@@ -41,7 +41,7 @@ generated by
and
.I fsunmount
(see
-.IR 9pclient (3))
+.MR 9pclient (3) )
and indirectly by other actions such as failed
.I fsopen
calls.
diff --git a/man/man9/flush.9p b/man/man9/flush.9p
index 9d3ea2675..862ab9a4a 100644
--- a/man/man9/flush.9p
+++ b/man/man9/flush.9p
@@ -99,11 +99,11 @@ flushing a
and flushing an invalid tag.
.SH ENTRY POINTS
The
-.IR 9pclient (3)
+.MR 9pclient (3)
library does not generate
.B flush
transactions..
-.IR 9pserve (4)
+.MR 9pserve (4)
generates
.B flush
transactions to cancel transactions pending when a client hangs up.
diff --git a/man/man9/open.9p b/man/man9/open.9p
index b8ed973ae..8a54f72c0 100644
--- a/man/man9/open.9p
+++ b/man/man9/open.9p
@@ -160,7 +160,7 @@ in this case, the
.I fscreate
call
(see
-.IR 9pclient (3))
+.MR 9pclient (3) )
uses
.B open
with truncation.
@@ -209,7 +209,7 @@ again.
and
.I fscreate
(see
-.IR 9pclient (3))
+.MR 9pclient (3) )
both generate
.B open
messages; only
diff --git a/man/man9/openfd.9p b/man/man9/openfd.9p
index 89aa254f9..620b1991a 100644
--- a/man/man9/openfd.9p
+++ b/man/man9/openfd.9p
@@ -43,18 +43,18 @@ it cannot be
.PP
.I Openfd
is implemented by
-.IR 9pserve (4).
+.MR 9pserve (4) .
9P servers that post their services using
-.IR 9pserve (4)
+.MR 9pserve (4)
(or indirectly via
-.IR post9pservice (3))
+.MR post9pservice (3) )
will never see a
.B Topenfd
message.
.SH ENTRY POINTS
.I Fsopenfd
(see
-.IR 9pclient (3))
+.MR 9pclient (3) )
generates an
.B openfd
message.
diff --git a/man/man9/read.9p b/man/man9/read.9p
index a68f153e9..675bb7738 100644
--- a/man/man9/read.9p
+++ b/man/man9/read.9p
@@ -114,7 +114,7 @@ to be transferred atomically.
and
.I fswrite
(see
-.IR 9pclient (3))
+.MR 9pclient (3) )
generate the corresponding messages.
Because they take an offset parameter, the
.I fspread
diff --git a/man/man9/remove.9p b/man/man9/remove.9p
index a9a844a1a..232c88f6b 100644
--- a/man/man9/remove.9p
+++ b/man/man9/remove.9p
@@ -45,7 +45,7 @@ so other fids typically remain usable.
.SH ENTRY POINTS
.I Fsremove
(see
-.IR 9pclient (3))
+.MR 9pclient (3) )
generates
.B remove
messages.
diff --git a/man/man9/stat.9p b/man/man9/stat.9p
index ab68133d9..7706d3eb1 100644
--- a/man/man9/stat.9p
+++ b/man/man9/stat.9p
@@ -88,7 +88,7 @@ The
and
.I convD2M
routines (see
-.IR fcall (3))
+.MR fcall (3) )
convert between directory entries and a C structure called a
.BR Dir .
.PP
@@ -263,7 +263,7 @@ messages are generated by
and
.IR fsdirstat
(see
-.IR 9pclient (3)).
+.MR 9pclient (3) ).
.PP
.B Wstat
messages are generated by
diff --git a/man/man9/version.9p b/man/man9/version.9p
index c4961217a..c71ee5566 100644
--- a/man/man9/version.9p
+++ b/man/man9/version.9p
@@ -91,7 +91,7 @@ requests is called a
.SH ENTRY POINTS
.I Fsversion
(see
-.IR 9pclient (3))
+.MR 9pclient (3) )
generates
.B version
messages;
diff --git a/man/man9/walk.9p b/man/man9/walk.9p
index 49777f214..735b7dcb9 100644
--- a/man/man9/walk.9p
+++ b/man/man9/walk.9p
@@ -149,13 +149,13 @@ may be packed in a single message.
This constant is called
.B MAXWELEM
in
-.IR fcall (3).
+.MR fcall (3) .
Despite this restriction, the system imposes no limit on the number of elements in a file name,
only the number that may be transmitted in a single message.
.SH ENTRY POINTS
.I Fswalk
(see
-.IR 9pclient (3))
+.MR 9pclient (3) )
generates walk messages.
One or more walk messages may be generated by
any call that evaluates file names:
diff --git a/plumb/basic b/plumb/basic
index f728132fd..b59b7948f 100644
--- a/plumb/basic
+++ b/plumb/basic
@@ -37,8 +37,8 @@ plumb start wdoc2txt $file
# image files go to page
type is text
-data matches '[a-zA-Z¡-0-9_\-./]+'
-data matches '([a-zA-Z¡-0-9_\-./]+)\.(jpe?g|JPE?G|gif|GIF|tiff?|TIFF?|ppm|bit|png|PNG)'
+data matches '[a-zA-Z¡-0-9_\-./@]+'
+data matches '([a-zA-Z¡-0-9_\-./@]+)\.(jpe?g|JPE?G|gif|GIF|tiff?|TIFF?|ppm|bit|png|PNG)'
arg isfile $0
plumb to image
plumb start 9 page $file
@@ -46,40 +46,40 @@ plumb start 9 page $file
# postscript/pdf/dvi go to page but not over the a plumb port
# the port is here for reference but is unused
type is text
-data matches '[a-zA-Z¡-0-9_\-./]+'
-data matches '([a-zA-Z¡-0-9_\-./]+)\.(ps|PS|eps|EPS|pdf|PDF|dvi|DVI)'
+data matches '[a-zA-Z¡-0-9_\-./@]+'
+data matches '([a-zA-Z¡-0-9_\-./@]+)\.(ps|PS|eps|EPS|pdf|PDF|dvi|DVI)'
arg isfile $0
plumb to postscript
plumb start 9 page $file
# open office - s[xt][cdigmw], doc, xls, ppt
-data matches '[a-zA-Z¡-0-9_\-./]+'
-data matches '([a-zA-Z¡-0-9_\-./]+)\.([Ss][XxTt][CcDdIiGgMmWw]|[Dd][Oo][Cc]|[Xx][Ll][Ss]|[Pp][Pp][Tt])'
+data matches '[a-zA-Z¡-0-9_\-./@]+'
+data matches '([a-zA-Z¡-0-9_\-./@]+)\.([Ss][XxTt][CcDdIiGgMmWw]|[Dd][Oo][Cc]|[Xx][Ll][Ss]|[Pp][Pp][Tt])'
arg isfile $0
plumb to openoffice
plumb start openoffice $file
# existing files tagged by line number:columnumber or linenumber.columnumber, twice, go to editor
type is text
-data matches '([.a-zA-Z¡-0-9_/\-]*[a-zA-Z¡-0-9_/\-])':$twocolonaddr,$twocolonaddr
+data matches '([.a-zA-Z¡-0-9_/\-@]*[a-zA-Z¡-0-9_/\-])':$twocolonaddr,$twocolonaddr
arg isfile $1
data set $file
-attr add addr=$2-#1+#$3,$4-#1+#$5
+attr add addr=$2-#0+#$3-#1,$4-#0+#$5-#1
plumb to edit
plumb client $editor
# existing files tagged by line number:columnumber or linenumber.columnumber, twice, go to editor
type is text
-data matches '([.a-zA-Z¡-0-9_/\-]*[a-zA-Z¡-0-9_/\-])':$twocolonaddr
+data matches '([.a-zA-Z¡-0-9_/\-@]*[a-zA-Z¡-0-9_/\-])':$twocolonaddr
arg isfile $1
data set $file
-attr add addr=$2-#1+#$3
+attr add addr=$2-#0+#$3-#1
plumb to edit
plumb client $editor
# existing files, possibly tagged by line number, go to editor
type is text
-data matches '([.a-zA-Z¡-0-9_/\-]*[a-zA-Z¡-0-9_/\-])('$addr')?'
+data matches '([.a-zA-Z¡-0-9_/\-@]*[a-zA-Z¡-0-9_/\-])('$addr')?'
arg isfile $1
data set $file
attr add addr=$3
diff --git a/src/cmd/9660/boot.c b/src/cmd/9660/boot.c
index 9cae95829..c7d728484 100644
--- a/src/cmd/9660/boot.c
+++ b/src/cmd/9660/boot.c
@@ -42,7 +42,7 @@ g% cdsector 3149 | xd -b # 0x0c4d
55 aa - magic
0000020 88 - 88 = bootable
- 03 - 3 = 2.88MB diskette
+ 03 - 3 = 2.88MB diskette
00 00 - load segment 0 means default 0x7C0
00 - system type (byte 5 of boot image)
00 - unused (0)
@@ -58,13 +58,13 @@ g% cdsector `{h2d 0c4e} | xd -b
1+0 records out
0000000 eb 3c 00 00 00 00 00 00 00 00 00 00 02 00 00 00
0000010 00 00 00 00 00 00 00 00 12 00 02 00 00 00 00 00
-0000020 00 00 00 00 00 16 1f 66 6a 00 51 50 06 53
+0000020 00 00 00 00 00 16 1f 66 6a 00 51 50 06 53
31 c0
FREEBSD
0000000 eb 3c 00 00 00 00 00 00 00 00 00 00 02 00 00 00
0000010 00 00 00 00 00 00 00 00 12 00 02 00 00 00 00 00
-0000020 00 00 00 00 00 16 1f 66 6a 00 51 50 06 53
+0000020 00 00 00 00 00 16 1f 66 6a 00 51 50 06 53
31 c0
DOS 5
@@ -171,7 +171,7 @@ Cupdatebootcat(Cdimg *cd)
Cputc(cd, 0); /* unused */
Cputnl(cd, 1, 2); /* 512-byte sector count for load */
Cputnl(cd, cd->bootdirec->block, 4); /* ptr to disk image */
- Cwseek(cd, o);
+ Cwseek(cd, o);
}
void
diff --git a/src/cmd/9660/cdrdwr.c b/src/cmd/9660/cdrdwr.c
index 757bfcd93..786b798f2 100644
--- a/src/cmd/9660/cdrdwr.c
+++ b/src/cmd/9660/cdrdwr.c
@@ -125,7 +125,7 @@ opencd(char *file, Cdinfo info)
}
/* lowercase because of isostring */
- if(strstr(cd->iso.systemid, "iso9660") == nil
+ if(strstr(cd->iso.systemid, "iso9660") == nil
&& strstr(cd->iso.systemid, "utf8") == nil) {
werrstr("unknown systemid %s", cd->iso.systemid);
free(cd);
@@ -133,7 +133,7 @@ opencd(char *file, Cdinfo info)
close(xfd);
return nil;
}
-
+
if(strstr(cd->iso.systemid, "plan 9"))
cd->flags |= CDplan9;
if(strstr(cd->iso.systemid, "iso9660"))
@@ -307,7 +307,7 @@ parsedesc(Voldesc *v, Cvoldesc *cv, char *(*string)(uchar*, int))
v->biblio = string(cv->biblio, sizeof cv->biblio);
v->notice = string(cv->notice, sizeof cv->notice);
}
-
+
static int
readisodesc(Cdimg *cd, Voldesc *v)
{
@@ -629,4 +629,3 @@ Clinelen(Cdimg *cd)
{
return Blinelen(&cd->brd);
}
-
diff --git a/src/cmd/9660/direc.c b/src/cmd/9660/direc.c
index 8185f6806..e67f0cb76 100644
--- a/src/cmd/9660/direc.c
+++ b/src/cmd/9660/direc.c
@@ -86,9 +86,9 @@ walkdirec(Direc *d, char *name)
* Add the file ``name'' with attributes d to the
* directory ``root''. Name may contain multiple
* elements; all but the last must exist already.
- *
+ *
* The child lists are kept sorted by utfname.
- */
+ */
Direc*
adddirec(Direc *root, char *name, XDir *d)
{
@@ -130,7 +130,7 @@ adddirec(Direc *root, char *name, XDir *d)
return nd;
}
-/*
+/*
* Copy the tree src into dst.
*/
void
@@ -219,4 +219,3 @@ dsort(Direc *d, int (*cmp)(const void*, const void*))
for(i=0; ichild[i], cmp);
}
-
diff --git a/src/cmd/9660/dump.c b/src/cmd/9660/dump.c
index d3504ff94..ad762f217 100644
--- a/src/cmd/9660/dump.c
+++ b/src/cmd/9660/dump.c
@@ -348,7 +348,7 @@ adddumpdir(Direc *root, ulong now, XDir *dir)
Tm tm;
tm = *localtime(now);
-
+
sprint(buf, "%d", tm.year+1900);
if((dyear = walkdirec(root, buf)) == nil) {
dyear = adddirec(root, buf, dir);
@@ -406,7 +406,7 @@ hasdump(Cdimg *cd)
}
return 0;
}
-
+
Direc
readdumpdirs(Cdimg *cd, XDir *dir, char *(*cvt)(uchar*, int))
{
@@ -500,7 +500,7 @@ readdumpconform(Cdimg *cd)
if(tokenize(p, f, 2) != 2 || (f[0][0] != 'D' && f[0][0] != 'F')
|| strlen(f[0]) != 7 || !isalldigit(f[0]+1))
break;
-
+
addtx(atom(f[1]), atom(f[0]));
}
}
diff --git a/src/cmd/9660/dump9660.c b/src/cmd/9660/dump9660.c
index 4e66bd78a..59ee31c0e 100644
--- a/src/cmd/9660/dump9660.c
+++ b/src/cmd/9660/dump9660.c
@@ -168,7 +168,7 @@ main(int argc, char **argv)
Cwseek(cd, cd->nextblock*Blocksize);
goto Dofix;
}
-
+
dumpname = adddumpdir(&idumproot, now, &dir);
/* note that we assume all names are conforming and thus sorted */
if(cd->flags & CDjoliet) {
@@ -192,7 +192,7 @@ main(int argc, char **argv)
findbootimage(cd, &iroot);
Cupdatebootcat(cd);
}
-
+
/* create Joliet tree */
if(cd->flags & CDjoliet)
copydirec(&jroot, &iroot);
@@ -235,14 +235,14 @@ main(int argc, char **argv)
* Write incremental _conform.map block.
*/
wrconform(cd, cd->nconform, &cblock, &clength);
-
+
/* jump here if we're just fixing up the cd */
Dofix:
/*
- * Write null dump header block; everything after this will be
+ * Write null dump header block; everything after this will be
* overwritten at the next dump. Because of this, it needs to be
* reconstructable. We reconstruct the _conform.map and dump trees
- * from the header blocks in dump.c, and we reconstruct the path
+ * from the header blocks in dump.c, and we reconstruct the path
* tables by walking the cd.
*/
newnull = Cputdumpblock(cd);
@@ -254,12 +254,12 @@ main(int argc, char **argv)
dir.mode = 0444;
if(cd->flags & (CDconform|CDjoliet)) {
if(!mk9660 && cd->nconform == 0){
- block = cblock;
+ block = cblock;
length = clength;
}else
wrconform(cd, 0, &block, &length);
- if(mk9660)
+ if(mk9660)
{
idumproot = iroot;
jdumproot = jroot;
@@ -315,11 +315,11 @@ main(int argc, char **argv)
copybutname(r, &jroot);
}
}
-
+
writedumpdirs(cd, &idumproot, Cputisodir);
if(cd->flags & CDjoliet)
writedumpdirs(cd, &jdumproot, Cputjolietdir);
-
+
/*
* Patch in new root directory entry.
*/
@@ -330,7 +330,7 @@ main(int argc, char **argv)
setvolsize(cd, cd->jolietsvd, cd->nextblock*Blocksize);
}
}
- writepathtables(cd);
+ writepathtables(cd);
if(!mk9660){
/*
@@ -341,16 +341,16 @@ main(int argc, char **argv)
if(cd->nulldump && maxsize && Cwoffset(cd) > maxsize){
fprint(2, "too big; writing old tree back\n");
status = "cd too big; aborted";
-
+
rmdumpdir(&idumproot, dumpname);
rmdumpdir(&jdumproot, dumpname);
-
+
cd->nextblock = cd->nulldump+1;
cd->nulldump = 0;
Cwseek(cd, cd->nextblock*Blocksize);
goto Dofix;
}
-
+
/*
* Write old null header block; this commits all our changes.
*/
@@ -399,4 +399,3 @@ addprotofile(char *new, char *old, Dir *d, void *a)
free(name);
}
-
diff --git a/src/cmd/9660/ichar.c b/src/cmd/9660/ichar.c
index 3b2b5367f..ef2944ce6 100644
--- a/src/cmd/9660/ichar.c
+++ b/src/cmd/9660/ichar.c
@@ -31,7 +31,7 @@ isostring(uchar *buf, int len)
return q;
}
-int
+int
isisofrog(char c)
{
if(c >= '0' && c <= '9')
@@ -85,7 +85,7 @@ isbadiso9660(char *s)
/*
* ISO9660 name comparison
- *
+ *
* The standard algorithm is as follows:
* Take the filenames without extensions, pad the shorter with 0x20s (spaces),
* and do strcmp. If they are equal, go on.
@@ -169,7 +169,7 @@ Cputisopvd(Cdimg *cd, Cdinfo info)
strcat(buf, "iso9660");
else
strcat(buf, "utf8");
-
+
struprcpy(buf, buf);
Cputs(cd, buf, 32);
diff --git a/src/cmd/9660/iso9660.h b/src/cmd/9660/iso9660.h
index b5131a27c..c08b2caa7 100644
--- a/src/cmd/9660/iso9660.h
+++ b/src/cmd/9660/iso9660.h
@@ -89,7 +89,7 @@ struct Voldesc {
ulong mpathloc;
/* root of file tree */
- Direc root;
+ Direc root;
};
/*
@@ -116,7 +116,7 @@ struct Cdimg {
ulong bootimageptr;
Direc *bootdirec;
char *bootimage;
-
+
Biobuf brd;
Biobuf bwr;
@@ -406,7 +406,7 @@ int Cputisodir(Cdimg*, Direc*, int, int, int);
int Cputjolietdir(Cdimg*, Direc*, int, int, int);
void Cputendvd(Cdimg*);
-enum {
+enum {
Blocksize = 2048,
Ndirblock = 16, /* directory blocks allocated at once */
diff --git a/src/cmd/9660/jchar.c b/src/cmd/9660/jchar.c
index ccd3b6db7..fbabf26d2 100644
--- a/src/cmd/9660/jchar.c
+++ b/src/cmd/9660/jchar.c
@@ -26,15 +26,15 @@ jolietstring(uchar *buf, int len)
}
/*
- * Joliet name validity check
- *
+ * Joliet name validity check
+ *
* Joliet names have length at most 128 bytes (64 runes),
* and cannot contain '*', '/', ':', ';', '?', or '\'.
*/
int
isjolietfrog(Rune r)
{
- return r=='*' || r=='/' || r==':'
+ return r=='*' || r=='/' || r==':'
|| r==';' || r=='?' || r=='\\';
}
@@ -58,7 +58,7 @@ isbadjoliet(char *s)
* The standard algorithm is the ISO9660 algorithm but
* on the encoded Runes. Runes are encoded in big endian
* format, so we can just use runecmp.
- *
+ *
* Padding is with zeros, but that still doesn't affect us.
*/
@@ -135,4 +135,3 @@ Cputjolietsvd(Cdimg *cd, Cdinfo info)
Cputc(cd, 1); /* file structure version */
Cpadblock(cd);
}
-
diff --git a/src/cmd/9660/path.c b/src/cmd/9660/path.c
index f2757dba9..effc44b18 100644
--- a/src/cmd/9660/path.c
+++ b/src/cmd/9660/path.c
@@ -9,7 +9,7 @@
* Add the requisite path tables to the CD image.
* They get put on the end once everything else is done.
* We use the path table itself as a queue in the breadth-first
- * traversal of the tree.
+ * traversal of the tree.
*
* The only problem with this is that the path table does not
* store the lengths of the directories. So we keep an explicit
diff --git a/src/cmd/9660/rune.c b/src/cmd/9660/rune.c
index 3a436f4a3..8b03f2823 100644
--- a/src/cmd/9660/rune.c
+++ b/src/cmd/9660/rune.c
@@ -36,4 +36,3 @@ runecmp(Rune *s, Rune *t)
s++, t++;
return *s - *t;
}
-
diff --git a/src/cmd/9660/sysuse.c b/src/cmd/9660/sysuse.c
index 787165243..3039b3607 100644
--- a/src/cmd/9660/sysuse.c
+++ b/src/cmd/9660/sysuse.c
@@ -43,11 +43,11 @@ setcelen(Cdimg *cd, ulong woffset, ulong len)
* Rock Ridge data is put into little blockettes, which can be
* at most 256 bytes including a one-byte length. Some number
* of blockettes get packed together into a normal 2048-byte block.
- * Blockettes cannot cross block boundaries.
+ * Blockettes cannot cross block boundaries.
*
- * A Cbuf is a blockette buffer. Len contains
+ * A Cbuf is a blockette buffer. Len contains
* the length of the buffer written so far, and we can
- * write up to 254-28.
+ * write up to 254-28.
*
* We only have one active Cbuf at a time; cdimg.rrcontin is the byte
* offset of the beginning of that Cbuf.
@@ -94,7 +94,7 @@ ensurespace(Cdimg *cd, int n, Cbuf *co, Cbuf *cn, int dowrite)
/*
* the current blockette is full; update cd->rrcontin and then
- * write a CE record to finish it. Unfortunately we need to
+ * write a CE record to finish it. Unfortunately we need to
* figure out which block will be next before we write the CE.
*/
end = Cwoffset(cd)+28;
@@ -134,13 +134,13 @@ ensurespace(Cdimg *cd, int n, Cbuf *co, Cbuf *cn, int dowrite)
return cn;
}
-
+
/*
* Put down the name, but we might need to break it
* into chunks so that each chunk fits in 254-28-5 bytes.
* What a crock.
*
- * The new Plan 9 format uses strings of this form too,
+ * The new Plan 9 format uses strings of this form too,
* since they're already there.
*/
Cbuf*
@@ -211,7 +211,7 @@ Cputsysuse(Cdimg *cd, Direc *d, int dot, int dowrite, int initlen)
what |= RR_SL;
m = CputsuspRR(cd, what, 0);
- cp = ensurespace(cd, m, cp, &cn, dowrite);
+ cp = ensurespace(cd, m, cp, &cn, dowrite);
CputsuspRR(cd, what, dowrite);
if(what & RR_PX) {
@@ -235,7 +235,7 @@ Cputsysuse(Cdimg *cd, Direc *d, int dot, int dowrite, int initlen)
/*
* Put down the symbolic link. This is even more of a crock.
- * Not only are the individual elements potentially split,
+ * Not only are the individual elements potentially split,
* but the whole path itself can be split across SL blocks.
* To keep the code simple as possible (really), we write
* only one element per SL block, wasting 6 bytes per element.
@@ -382,7 +382,7 @@ CputsuspSP(Cdimg *cd, int dowrite)
{
assert(cd!=0);
- if(dowrite) {
+ if(dowrite) {
chat("writing SUSP SP record\n");
Cputc(cd, 'S'); /* SP field marker */
Cputc(cd, 'P');
@@ -406,7 +406,7 @@ CputsuspST(Cdimg *cd, int dowrite)
Cputc(cd, 'S'); /* ST field marker */
Cputc(cd, 'T');
Cputc(cd, 4); /* Length */
- Cputc(cd, 1); /* Version */
+ Cputc(cd, 1); /* Version */
}
return 4;
}
@@ -484,7 +484,7 @@ CputrripPX(Cdimg *cd, Direc *d, int dot, int dowrite)
Cputc(cd, 'X');
Cputc(cd, 36); /* Length */
Cputc(cd, 1); /* Version */
-
+
Cputn(cd, mode(d, dot), 4); /* POSIX File mode */
Cputn(cd, nlink(d), 4); /* POSIX st_nlink */
Cputn(cd, d?d->uidno:0, 4); /* POSIX st_uid */
@@ -514,7 +514,7 @@ CputrripTF(Cdimg *cd, Direc *d, int type, int dowrite)
Cputc(cd, 5+7*length); /* Length */
Cputc(cd, 1); /* Version */
Cputc(cd, type); /* Flags (types) */
-
+
if (type & TFcreation)
Cputdate(cd, d?d->ctime:0);
if (type & TFmodify)
@@ -523,7 +523,7 @@ CputrripTF(Cdimg *cd, Direc *d, int type, int dowrite)
Cputdate(cd, d?d->atime:0);
if (type & TFattributes)
Cputdate(cd, d?d->ctime:0);
-
+
/* if (type & TFbackup) */
/* Cputdate(cd, 0); */
/* if (type & TFexpiration) */
@@ -566,7 +566,7 @@ static long
mode(Direc *d, int dot)
{
long mode;
-
+
if (!d)
return 0;
@@ -582,13 +582,13 @@ mode(Direc *d, int dot)
mode = S_IFDIR | (0755);
mode &= POSIXMODEMASK;
-
+
/* Botch: not all POSIX types supported yet */
assert(mode & (S_IFDIR|S_IFREG));
-chat("writing PX record mode field %ulo with dot %d and name \"%s\"\n", mode, dot, d->name);
+chat("writing PX record mode field %ulo with dot %d and name \"%s\"\n", mode, dot, d->name);
- return mode;
+ return mode;
}
static long
@@ -610,4 +610,3 @@ nlink(Direc *d) /* Trump up the nlink field for POSIX compliance */
return n;
}
-
diff --git a/src/cmd/9660/util.c b/src/cmd/9660/util.c
index ebf944e20..d3182775e 100644
--- a/src/cmd/9660/util.c
+++ b/src/cmd/9660/util.c
@@ -39,7 +39,7 @@ atom(char *str)
{
uint h;
Stringtab *tab;
-
+
h = hash(str) % nelem(stab);
for(tab=stab[h]; tab; tab=tab->link)
if(strcmp(str, tab->str) == 0)
diff --git a/src/cmd/9660/write.c b/src/cmd/9660/write.c
index 944053176..652927ca8 100644
--- a/src/cmd/9660/write.c
+++ b/src/cmd/9660/write.c
@@ -90,7 +90,7 @@ writefiles(Dump *d, Cdimg *cd, Direc *direc)
assert(start != 0);
Cwseek(cd, start*Blocksize);
-
+
s = md5(nil, 0, nil, nil);
length = 0;
while((n = Bread(b, buf, sizeof buf)) > 0) {
@@ -123,7 +123,7 @@ writefiles(Dump *d, Cdimg *cd, Direc *direc)
}
/*
- * Write a directory tree. We work from the leaves,
+ * Write a directory tree. We work from the leaves,
* and patch the dotdot pointers afterward.
*/
static void
diff --git a/src/cmd/9660srv/iobuf.c b/src/cmd/9660srv/iobuf.c
index 01acd06aa..a0b934c09 100644
--- a/src/cmd/9660srv/iobuf.c
+++ b/src/cmd/9660srv/iobuf.c
@@ -14,7 +14,7 @@
* tarring up a Plan 9 distribution CD, we now use 16 128kb
* buffers. This works for ISO9660 because data is required
* to be laid out contiguously; effectively we're doing agressive
- * readahead. Because the buffers are so big and the typical
+ * readahead. Because the buffers are so big and the typical
* disk accesses so concentrated, it's okay that we have so few
* of them.
*
diff --git a/src/cmd/9660srv/main.c b/src/cmd/9660srv/main.c
index 44fdc5124..d4c32b8f3 100644
--- a/src/cmd/9660srv/main.c
+++ b/src/cmd/9660srv/main.c
@@ -138,13 +138,13 @@ main(int argc, char **argv)
open("/dev/null", OWRITE);
if(pipe(pipefd) < 0)
panic(1, "pipe");
-
+
if(post9pservice(pipefd[0], srvname, mtpt) < 0)
sysfatal("post9pservice: %r");
close(pipefd[0]);
}
srvfd = pipefd[1];
-
+
switch(rfork(RFNOWAIT|RFNOTEG|RFFDG|RFPROC)){
case -1:
panic(1, "fork");
diff --git a/src/cmd/9660srv/xfile.c b/src/cmd/9660srv/xfile.c
index c46adf21e..bebf0986d 100644
--- a/src/cmd/9660srv/xfile.c
+++ b/src/cmd/9660srv/xfile.c
@@ -167,4 +167,3 @@ clean(Xfile *f)
f->qid = (Qid){0,0,0};
return f;
}
-
diff --git a/src/cmd/9p.c b/src/cmd/9p.c
index c8d4c4448..a5b97f85f 100644
--- a/src/cmd/9p.c
+++ b/src/cmd/9p.c
@@ -94,7 +94,7 @@ threadmain(int argc, char **argv)
threadexitsall(0);
}
}
- usage();
+ usage();
}
CFsys*
@@ -168,7 +168,7 @@ xread(int argc, char **argv)
fsclose(fid);
if(n < 0)
sysfatal("read error: %r");
- threadexitsall(0);
+ threadexitsall(0);
}
void
@@ -192,7 +192,7 @@ xreadfd(int argc, char **argv)
sysfatal("write error: %r");
if(n < 0)
sysfatal("read error: %r");
- threadexitsall(0);
+ threadexitsall(0);
}
void
@@ -246,7 +246,7 @@ xwrite(int argc, char **argv)
if(n < 0)
sysfatal("read error: %r");
fsclose(fid);
- threadexitsall(0);
+ threadexitsall(0);
}
void
@@ -270,7 +270,7 @@ xwritefd(int argc, char **argv)
sysfatal("write error: %r");
if(n < 0)
sysfatal("read error: %r");
- threadexitsall(0);
+ threadexitsall(0);
}
void
@@ -302,8 +302,10 @@ void
xrdwr(int argc, char **argv)
{
char buf[4096];
+ char *p;
int n;
CFid *fid;
+ Biobuf *b;
ARGBEGIN{
default:
@@ -313,6 +315,8 @@ xrdwr(int argc, char **argv)
if(argc != 1)
usage();
+ if((b = Bfdopen(0, OREAD)) == nil)
+ sysfatal("out of memory");
fid = xopen(argv[0], ORDWR);
for(;;){
fsseek(fid, 0, 0);
@@ -322,16 +326,16 @@ xrdwr(int argc, char **argv)
if(write(1, buf, n) < 0 || write(1, "\n", 1) < 0)
sysfatal("write error: %r");
}
- n = read(0, buf, sizeof buf);
- if(n <= 0)
+ if((p = Brdstr(b, '\n', 1)) == nil)
break;
- if(buf[n-1] == '\n')
- n--;
- if(fswrite(fid, buf, n) != n)
+ n = strlen(p);
+ if(fswrite(fid, p, n) != n)
fprint(2, "write: %r\n");
+ free(p);
}
fsclose(fid);
- threadexitsall(0);
+ Bterm(b);
+ threadexitsall(0);
}
void
@@ -346,10 +350,10 @@ xcreate(int argc, char **argv)
default:
usage();
}ARGEND
-
+
if(argc == 0)
usage();
-
+
for(i=0; iargs, ulong);
@@ -470,7 +474,7 @@ static int
dircmp(const void *va, const void *vb)
{
Dir *a, *b;
-
+
a = (Dir*)va;
b = (Dir*)vb;
return strcmp(a->name, b->name);
@@ -480,7 +484,7 @@ static int
timecmp(const void *va, const void *vb)
{
Dir *a, *b;
-
+
a = (Dir*)va;
b = (Dir*)vb;
if(a->mtime < b->mtime)
@@ -520,12 +524,12 @@ xls(int argc, char **argv)
tflag = 1;
break;
}ARGEND
-
+
fmtinstall('D', dirfmt);
fmtinstall('M', dirmodefmt);
quotefmtinstall();
fmtinstall('T', timefmt);
-
+
if(argc == 0){
argv = dot;
argc = 1;
@@ -600,4 +604,3 @@ xls(int argc, char **argv)
}
threadexitsall(err);
}
-
diff --git a/src/cmd/9pfuse/errstr.c b/src/cmd/9pfuse/errstr.c
index e03d9589a..ef5da00f3 100644
--- a/src/cmd/9pfuse/errstr.c
+++ b/src/cmd/9pfuse/errstr.c
@@ -21,6 +21,7 @@ static Error errortab[] = {
{ "exist", ENOENT },
{ "no such", ENOENT },
{ "not found", ENOENT },
+ { "not implemented", ENOSYS},
{ "input/output", EIO },
{ "timeout", ETIMEDOUT },
{ "timed out", ETIMEDOUT },
@@ -42,6 +43,7 @@ static Error errortab[] = {
{ "invalid", EINVAL },
{ "read-only", EROFS },
{ "read only", EROFS },
+ { "stale ", ESTALE},
#ifdef EPROTO
{ "proto", EPROTO },
#else
@@ -55,7 +57,7 @@ errstr2errno(void)
{
char e[ERRMAX];
int i, len;
-
+
if(errno != EPLAN9)
return errno;
@@ -70,4 +72,3 @@ errstr2errno(void)
return errortab[i].err;
return ERANGE; /* who knows - be blatantly wrong */
}
-
diff --git a/src/cmd/9pfuse/fuse.c b/src/cmd/9pfuse/fuse.c
index 3f91ce787..ea8e3bbf3 100644
--- a/src/cmd/9pfuse/fuse.c
+++ b/src/cmd/9pfuse/fuse.c
@@ -15,7 +15,7 @@ allocfusemsg(void)
{
FuseMsg *m;
void *vbuf;
-
+
lock(&fusemsglock);
if((m = fusemsglist) != nil){
fusemsglist = m->next;
@@ -46,9 +46,8 @@ readfusemsg(void)
{
FuseMsg *m;
int n, nn;
-
+
m = allocfusemsg();
- errno = 0;
/*
* The FUSE kernel device apparently guarantees
* that this read will return exactly one message.
@@ -57,7 +56,11 @@ readfusemsg(void)
* FUSE returns an ENODEV error, not EOF,
* when the connection is unmounted.
*/
- if((n = read(fusefd, m->buf, fusebufsize)) < 0){
+ do{
+ errno = 0;
+ n = read(fusefd, m->buf, fusebufsize);
+ }while(n < 0 && errno == EINTR);
+ if(n < 0){
if(errno != ENODEV)
sysfatal("readfusemsg: %r");
}
@@ -81,7 +84,7 @@ readfusemsg(void)
sysfatal("readfusemsg: got %d wanted %d",
n, m->hdr->len);
m->hdr->len -= sizeof(*m->hdr);
-
+
/*
* Paranoia.
* Make sure lengths are long enough.
@@ -122,7 +125,7 @@ readfusemsg(void)
if(((char*)m->tx)[m->hdr->len-1] != 0
|| memchr(m->tx, 0, m->hdr->len-1) == 0)
goto bad;
- break;
+ break;
case FUSE_MKNOD:
if(m->hdr->len <= sizeof(struct fuse_mknod_in)
|| ((char*)m->tx)[m->hdr->len-1] != 0)
@@ -216,7 +219,7 @@ readfusemsg(void)
}
/*
- * Reply to FUSE request m using additonal
+ * Reply to FUSE request m using additonal
* argument buffer arg of size narg bytes.
* Perhaps should free the FuseMsg here?
*/
@@ -226,7 +229,7 @@ replyfuse(FuseMsg *m, void *arg, int narg)
struct iovec vec[2];
struct fuse_out_header hdr;
int nvec;
-
+
hdr.len = sizeof hdr + narg;
hdr.error = 0;
hdr.unique = m->hdr->unique;
@@ -252,7 +255,7 @@ void
replyfuseerrno(FuseMsg *m, int e)
{
struct fuse_out_header hdr;
-
+
hdr.len = sizeof hdr;
hdr.error = -e; /* FUSE sends negative errnos. */
hdr.unique = m->hdr->unique;
@@ -304,12 +307,12 @@ initfuse(char *mtpt)
/*
* Complain if the kernel is too new.
* We could forge ahead, but at least the one time I tried,
- * the kernel rejected the newer version by making the
+ * the kernel rejected the newer version by making the
* writev fail in replyfuse, which is a much more confusing
- * error message. In the future, might be nice to try to
+ * error message. In the future, might be nice to try to
* support older versions that differ only slightly.
*/
- if(tx->major < FUSE_KERNEL_VERSION
+ if(tx->major < FUSE_KERNEL_VERSION
|| (tx->major == FUSE_KERNEL_VERSION && tx->minor < FUSE_KERNEL_MINOR_VERSION))
sysfatal("fuse: too kernel version %d.%d older than program version %d.%d",
tx->major, tx->minor, FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);
@@ -383,7 +386,7 @@ fusefmt(Fmt *fmt)
}
case FUSE_SYMLINK: {
char *old, *new;
-
+
old = a;
new = a + strlen(a) + 1;
fmtprint(fmt, "Symlink nodeid %#llux old %#q new %#q",
@@ -452,7 +455,7 @@ fusefmt(Fmt *fmt)
case FUSE_RELEASE: {
struct fuse_release_in *tx = a;
fmtprint(fmt, "Release nodeid %#llux fh %#llux flags %#ux",
- hdr->nodeid, tx->fh, tx->flags);
+ hdr->nodeid, tx->fh, tx->flags);
break;
}
case FUSE_FSYNC: {
@@ -513,7 +516,7 @@ fusefmt(Fmt *fmt)
case FUSE_RELEASEDIR: {
struct fuse_release_in *tx = a;
fmtprint(fmt, "Releasedir nodeid %#llux fh %#llux flags %#ux",
- hdr->nodeid, tx->fh, tx->flags);
+ hdr->nodeid, tx->fh, tx->flags);
break;
}
case FUSE_FSYNCDIR: {
@@ -551,7 +554,7 @@ fusefmt(Fmt *fmt)
case FUSE_LOOKUP: {
/*
* For a negative entry, can send back ENOENT
- * or rx->ino == 0.
+ * or rx->ino == 0.
* In protocol version 7.4 and before, can only use
* the ENOENT method.
* Presumably the benefit of sending rx->ino == 0
@@ -568,7 +571,7 @@ fusefmt(Fmt *fmt)
rx->attr_valid+rx->attr_valid_nsec*1e-9);
fmtprint(fmt, " ino %#llux size %lld blocks %lld atime %.20g mtime %.20g ctime %.20g mode %#uo nlink %d uid %d gid %d rdev %#ux",
rx->attr.ino, rx->attr.size, rx->attr.blocks,
- rx->attr.atime+rx->attr.atimensec*1e-9,
+ rx->attr.atime+rx->attr.atimensec*1e-9,
rx->attr.mtime+rx->attr.mtimensec*1e-9,
rx->attr.ctime+rx->attr.ctimensec*1e-9,
rx->attr.mode, rx->attr.nlink, rx->attr.uid,
@@ -589,7 +592,7 @@ fusefmt(Fmt *fmt)
rx->attr_valid+rx->attr_valid_nsec*1e-9);
fmtprint(fmt, " ino %#llux size %lld blocks %lld atime %.20g mtime %.20g ctime %.20g mode %#uo nlink %d uid %d gid %d rdev %#ux",
rx->attr.ino, rx->attr.size, rx->attr.blocks,
- rx->attr.atime+rx->attr.atimensec*1e-9,
+ rx->attr.atime+rx->attr.atimensec*1e-9,
rx->attr.mtime+rx->attr.mtimensec*1e-9,
rx->attr.ctime+rx->attr.ctimensec*1e-9,
rx->attr.mode, rx->attr.nlink, rx->attr.uid,
@@ -730,7 +733,7 @@ fusefmt(Fmt *fmt)
rx->e.attr_valid+rx->e.attr_valid_nsec*1e-9);
fmtprint(fmt, " ino %#llux size %lld blocks %lld atime %.20g mtime %.20g ctime %.20g mode %#uo nlink %d uid %d gid %d rdev %#ux",
rx->e.attr.ino, rx->e.attr.size, rx->e.attr.blocks,
- rx->e.attr.atime+rx->e.attr.atimensec*1e-9,
+ rx->e.attr.atime+rx->e.attr.atimensec*1e-9,
rx->e.attr.mtime+rx->e.attr.mtimensec*1e-9,
rx->e.attr.ctime+rx->e.attr.ctimensec*1e-9,
rx->e.attr.mode, rx->e.attr.nlink, rx->e.attr.uid,
@@ -750,7 +753,7 @@ fusefmt(Fmt *fmt)
/*
* Mounts a fuse file system on mtpt and returns
- * a file descriptor for the corresponding fuse
+ * a file descriptor for the corresponding fuse
* message conversation.
*/
int
@@ -759,7 +762,7 @@ mountfuse(char *mtpt)
#if defined(__linux__)
int p[2], pid, fd;
char buf[20];
-
+
if(socketpair(AF_UNIX, SOCK_STREAM, 0, p) < 0)
return -1;
pid = fork();
@@ -780,11 +783,11 @@ mountfuse(char *mtpt)
#elif defined(__FreeBSD__) && !defined(__APPLE__)
int pid, fd;
char buf[20];
-
+
if((fd = open("/dev/fuse", ORDWR)) < 0)
return -1;
snprint(buf, sizeof buf, "%d", fd);
-
+
pid = fork();
if(pid < 0)
return -1;
@@ -795,18 +798,23 @@ mountfuse(char *mtpt)
}
return fd;
#elif defined(__APPLE__)
- int i, pid, fd, r;
+ int i, pid, fd, r, p[2];
char buf[20];
struct vfsconf vfs;
char *f, *v;
if(getvfsbyname(v="osxfusefs", &vfs) < 0 &&
+ getvfsbyname(v="macfuse", &vfs) < 0 &&
getvfsbyname(v="osxfuse", &vfs) < 0 &&
getvfsbyname(v="fusefs", &vfs) < 0){
if(access((v="osxfusefs", f="/Library/Filesystems/osxfusefs.fs"
"/Support/load_osxfusefs"), 0) < 0 &&
+ access((v="macfuse", f="/Library/Filesystems/macfuse.fs"
+ "/Contents/Resources/load_macfuse"), 0) < 0 &&
access((v="osxfuse", f="/Library/Filesystems/osxfuse.fs"
"/Contents/Resources/load_osxfuse"), 0) < 0 &&
+ access((v="osxfuse", f="/opt/local/Library/Filesystems/osxfuse.fs"
+ "/Contents/Resources/load_osxfuse"), 0) < 0 &&
access((v="fusefs", f="/System/Library/Extensions/fusefs.kext"
"/Contents/Resources/load_fusefs"), 0) < 0 &&
access(f="/Library/Extensions/fusefs.kext"
@@ -832,6 +840,32 @@ mountfuse(char *mtpt)
}
}
+ /* MacFUSE >=4 dropped support for passing fd */
+ if (strcmp(v, "macfuse") == 0) {
+ if(socketpair(AF_UNIX, SOCK_STREAM, 0, p) < 0)
+ return -1;
+ pid = fork();
+ if(pid < 0)
+ return -1;
+ if(pid == 0){
+ close(p[1]);
+ snprint(buf, sizeof buf, "%d", p[0]);
+ putenv("_FUSE_COMMFD", buf);
+ putenv("_FUSE_COMMVERS", "2");
+ putenv("_FUSE_CALL_BY_LIB", "1");
+ putenv("_FUSE_DAEMON_PATH",
+ "/Library/Filesystems/macfuse.fs/Contents/Resources/mount_macfus");
+ execl("/Library/Filesystems/macfuse.fs/Contents/Resources/mount_macfuse",
+ "mount_macfuse", mtpt, nil);
+ fprint(2, "exec mount_macfuse: %r\n");
+ _exit(1);
+ }
+ close(p[0]);
+ fd = recvfd(p[1]);
+ close(p[1]);
+ return fd;
+ }
+
/* Look for available FUSE device. */
/*
* We need to truncate `fs` from the end of the vfs name if
@@ -871,6 +905,12 @@ mountfuse(char *mtpt)
execl("/Library/Filesystems/osxfuse.fs/Contents/Resources/mount_osxfuse",
"mount_osxfuse", buf, mtpt, nil);
+ /* OSXFUSE >=3.3 from macports */
+ putenv("MOUNT_OSXFUSE_DAEMON_PATH",
+ "/opt/local/Library/Filesystems/osxfuse.fs/Contents/Resources/mount_osxfuse");
+ execl("/opt/local/Library/Filesystems/osxfuse.fs/Contents/Resources/mount_osxfuse",
+ "mount_osxfuse", buf, mtpt, nil);
+
/* Lion OSXFUSE location */
putenv("MOUNT_FUSEFS_DAEMON_PATH",
"/Library/Filesystems/osxfusefs.fs/Support/mount_osxfusefs");
@@ -892,7 +932,7 @@ mountfuse(char *mtpt)
_exit(1);
}
return fd;
-
+
#else
werrstr("cannot mount fuse on this system");
return -1;
diff --git a/src/cmd/9pfuse/main.c b/src/cmd/9pfuse/main.c
index a36628988..4fa330a08 100644
--- a/src/cmd/9pfuse/main.c
+++ b/src/cmd/9pfuse/main.c
@@ -14,7 +14,7 @@
* writing the 9P connection. Thus the many threads in the
* request proc can do 9P interactions without blocking.
*/
-
+
#define _GNU_SOURCE 1 /* for O_DIRECTORY on Linux */
#include "a.h"
@@ -51,6 +51,14 @@
# endif
#endif
+#ifndef FMODE_EXEC
+# if defined(__linux__)
+# define FMODE_EXEC 040
+# else
+# define FMODE_EXEC 0
+# endif
+#endif
+
int debug;
char *argv0;
char *aname = "";
@@ -90,6 +98,12 @@ usage(void)
void fusereader(void*);
void watchfd(void*);
+int
+threadmaybackground(void)
+{
+ return 1;
+}
+
void
threadmain(int argc, char **argv)
{
@@ -165,16 +179,16 @@ init9p(char *addr, char *spec)
/*
* FUSE uses nodeids to refer to active "struct inodes"
* (9P's unopened fids). FUSE uses fhs to refer to active
- * "struct fuse_files" (9P's opened fids). The choice of
+ * "struct fuse_files" (9P's opened fids). The choice of
* numbers is up to us except that nodeid 1 is the root directory.
- * We use the same number space for both and call the
+ * We use the same number space for both and call the
* bookkeeping structure a FuseFid.
*
- * FUSE requires nodeids to have associated generation
- * numbers. If we reuse a nodeid, we have to bump the
+ * FUSE requires nodeids to have associated generation
+ * numbers. If we reuse a nodeid, we have to bump the
* generation number to guarantee that the nodeid,gen
* combination is never reused.
- *
+ *
* There are also inode numbers returned in directory reads
* and file attributes, but these do NOT need to match the nodeids.
* We use a combination of qid.path and qid.type as the inode
@@ -192,7 +206,7 @@ struct Fusefid
int id;
int gen;
int isnodeid;
-
+
/* directory read state */
Dir *d0;
Dir *d;
@@ -208,7 +222,7 @@ Fusefid*
allocfusefid(void)
{
Fusefid *f;
-
+
if((f = freefusefidlist) == nil){
f = emalloc(sizeof *f);
fusefid = erealloc(fusefid, (nfusefid+1)*sizeof *fusefid);
@@ -247,7 +261,7 @@ uvlong
_alloc(CFid *fid, int isnodeid)
{
Fusefid *ff;
-
+
ff = allocfusefid();
ff->fid = fid;
ff->isnodeid = isnodeid;
@@ -283,7 +297,7 @@ CFid*
_lookupcfid(uvlong id, int isnodeid)
{
Fusefid *ff;
-
+
if((ff = lookupfusefid(id, isnodeid)) == nil)
return nil;
return ff->fid;
@@ -360,7 +374,7 @@ fuselookup(FuseMsg *m)
CFid *fid, *newfid;
Dir *d;
struct fuse_entry_out out;
-
+
name = m->tx;
if((fid = nodeid2fid(m->hdr->nodeid)) == nil){
replyfuseerrno(m, ESTALE);
@@ -392,7 +406,7 @@ fuselookup(FuseMsg *m)
/*
* Forget. Reference-counted clunk for nodeids.
* Does not send a reply.
- * Each lookup response gives the kernel an additional reference
+ * Each lookup response gives the kernel an additional reference
* to the returned nodeid. Forget says "drop this many references
* to this nodeid". Our fuselookup, when presented with the same query,
* does not return the same results (it allocates a new nodeid for each
@@ -423,7 +437,7 @@ fuseforget(FuseMsg *m)
* Getattr.
* Replies with a fuse_attr_out structure giving the
* attr for the requested nodeid in out.attr.
- * Out.attr_valid and out.attr_valid_nsec give
+ * Out.attr_valid and out.attr_valid_nsec give
* the amount of time that the attributes can
* be cached.
*
@@ -479,7 +493,7 @@ fusesetattr(FuseMsg *m)
/*
* Special case: Linux issues a size change to
* truncate a file before opening it OTRUNC.
- * Synthetic file servers (e.g., plumber) honor
+ * Synthetic file servers (e.g., plumber) honor
* open(OTRUNC) but not wstat.
*/
if(in->valid == FATTR_SIZE && in->size == 0){
@@ -554,7 +568,7 @@ _fuseopenfid(uvlong nodeid, int isdir, int openmode, int *err)
*err = errstr2errno();
return nil;
}
-
+
if(fsfopen(newfid, openmode) < 0){
*err = errstr2errno();
fsclose(newfid);
@@ -583,7 +597,7 @@ _fuseopen(FuseMsg *m, int isdir)
flags = in->flags;
openmode = flags&3;
flags &= ~3;
- flags &= ~(O_DIRECTORY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC);
+ flags &= ~(O_DIRECTORY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|FMODE_EXEC);
#ifdef O_NOFOLLOW
flags &= ~O_NOFOLLOW;
#endif
@@ -602,13 +616,14 @@ _fuseopen(FuseMsg *m, int isdir)
openmode |= OTRUNC;
flags &= ~O_TRUNC;
}
+
/*
* Could translate but not standard 9P:
* O_DIRECT -> ODIRECT
* O_NONBLOCK -> ONONBLOCK
*/
if(flags){
- fprint(2, "unexpected open flags %#uo\n", (uint)in->flags);
+ fprint(2, "unexpected open flags requested=%#uo unhandled=%#uo\n", (uint)in->flags, (uint)flags);
replyfuseerrno(m, EACCES);
return;
}
@@ -617,7 +632,7 @@ _fuseopen(FuseMsg *m, int isdir)
return;
}
out.fh = allocfh(fid);
- out.open_flags = FOPEN_DIRECT_IO; /* no page cache */
+ out.open_flags = FOPEN_DIRECT_IO; /* no page cache */
replyfuse(m, &out, sizeof out);
}
@@ -696,7 +711,7 @@ fusemkdir(FuseMsg *m)
CFid *fid;
int err;
char *name;
-
+
in = m->tx;
name = (char*)(in+1);
if((fid = _fusecreate(m->hdr->nodeid, name, in->mode, 1, OREAD, &out, &err)) == nil){
@@ -716,7 +731,7 @@ fusecreate(FuseMsg *m)
CFid *fid;
int err, openmode, flags;
char *name;
-
+
in = m->tx;
flags = in->flags;
openmode = in->flags&3;
@@ -740,7 +755,7 @@ fusecreate(FuseMsg *m)
}
/*
- * Access.
+ * Access.
* Lib9pclient implements this just as Plan 9 does,
* by opening the file (or not) and then closing it.
*/
@@ -760,7 +775,7 @@ fuseaccess(FuseMsg *m)
ORDWR,
ORDWR
};
-
+
in = m->tx;
if(in->mask >= nelem(a2o)){
replyfuseerrno(m, EINVAL);
@@ -791,7 +806,7 @@ fuserelease(FuseMsg *m)
{
struct fuse_release_in *in;
Fusefid *ff;
-
+
in = m->tx;
if((ff = lookupfusefid(in->fh, 0)) != nil)
freefusefid(ff);
@@ -864,7 +879,7 @@ fusereadlink(FuseMsg *m)
return;
}
-/*
+/*
* Readdir.
* Read from file handle in->fh at offset in->offset for size in->size.
* We truncate size to maxwrite just to keep the buffer reasonable.
@@ -876,7 +891,7 @@ fusereadlink(FuseMsg *m)
* are stored in m->d,nd,d0.
*/
int canpack(Dir*, uvlong, uchar**, uchar*);
-Dir *dotdirs(CFid*);
+Dir *dotdir(CFid*);
void
fusereaddir(FuseMsg *m)
{
@@ -884,17 +899,17 @@ fusereaddir(FuseMsg *m)
uchar *buf, *p, *ep;
int n;
Fusefid *ff;
-
+
in = m->tx;
if((ff = lookupfusefid(in->fh, 0)) == nil){
replyfuseerrno(m, ESTALE);
return;
- }
+ }
if(in->offset == 0){
fsseek(ff->fid, 0, 0);
free(ff->d0);
- ff->d0 = ff->d = dotdirs(ff->fid);
- ff->nd = 2;
+ ff->d0 = ff->d = dotdir(ff->fid);
+ ff->nd = 1;
}
n = in->size;
if(n > fusemaxwrite)
@@ -922,7 +937,7 @@ fusereaddir(FuseMsg *m)
break;
ff->d = ff->d0;
}
-out:
+out:
replyfuse(m, buf, p - buf);
free(buf);
}
@@ -935,20 +950,13 @@ fusereaddir(FuseMsg *m)
* We could add .. too, but it isn't necessary.
*/
Dir*
-dotdirs(CFid *f)
+dotdir(CFid *f)
{
Dir *d;
- CFid *f1;
- d = emalloc(2*sizeof *d);
+ d = emalloc(1*sizeof *d);
d[0].name = ".";
d[0].qid = fsqid(f);
- d[1].name = "..";
- f1 = fswalk(f, "..");
- if(f1){
- d[1].qid = fsqid(f1);
- fsclose(f1);
- }
return d;
}
@@ -958,7 +966,7 @@ canpack(Dir *d, uvlong off, uchar **pp, uchar *ep)
uchar *p;
struct fuse_dirent *de;
int pad, size;
-
+
p = *pp;
size = FUSE_NAME_OFFSET + strlen(d->name);
pad = 0;
@@ -981,7 +989,7 @@ canpack(Dir *d, uvlong off, uchar **pp, uchar *ep)
* Write.
* Write from file handle in->fh at offset in->offset for size in->size.
* Don't know what in->write_flags means.
- *
+ *
* Apparently implementations are allowed to buffer these writes
* and wait until Flush is sent, but FUSE docs say flush may be
* called zero, one, or even more times per close. So better do the
@@ -996,7 +1004,7 @@ fusewrite(FuseMsg *m)
void *a;
CFid *fid;
int n;
-
+
in = m->tx;
a = in+1;
if((fid = fh2fid(in->fh)) == nil){
@@ -1018,7 +1026,7 @@ fusewrite(FuseMsg *m)
/*
* Flush. Supposed to flush any buffered writes. Don't use this.
- *
+ *
* Flush is a total crock. It gets called on close() of a file descriptor
* associated with this open file. Some open files have multiple file
* descriptors and thus multiple closes of those file descriptors.
@@ -1027,7 +1035,7 @@ fusewrite(FuseMsg *m)
* closed explicitly. For those files, Flush is never called.
* Even more amusing, Flush gets called before close() of read-only
* file descriptors too!
- *
+ *
* This is just a bad idea.
*/
void
@@ -1044,7 +1052,7 @@ _fuseremove(FuseMsg *m, int isdir)
{
char *name;
CFid *fid, *newfid;
-
+
name = m->tx;
if((fid = nodeid2fid(m->hdr->nodeid)) == nil){
replyfuseerrno(m, ESTALE);
@@ -1105,7 +1113,7 @@ fuserename(FuseMsg *m)
char *before, *after;
CFid *fid, *newfid;
Dir d;
-
+
in = m->tx;
if(in->newdir != m->hdr->nodeid){
replyfuseerrno(m, EXDEV);
@@ -1146,7 +1154,7 @@ fusefsync(FuseMsg *m)
struct fuse_fsync_in *in;
CFid *fid;
Dir d;
-
+
in = m->tx;
if((fid = fh2fid(in->fh)) == nil){
replyfuseerrno(m, ESTALE);
@@ -1181,7 +1189,7 @@ void
fusestatfs(FuseMsg *m)
{
struct fuse_statfs_out out;
-
+
memset(&out, 0, sizeof out);
replyfuse(m, &out, sizeof out);
}
@@ -1215,7 +1223,7 @@ struct {
{ FUSE_FSYNC, fusefsync },
/*
* FUSE_SETXATTR, FUSE_GETXATTR, FUSE_LISTXATTR, and
- * FUSE_REMOVEXATTR are unimplemented.
+ * FUSE_REMOVEXATTR are unimplemented.
* FUSE will stop sending these requests after getting
* an -ENOSYS reply (see dispatch below).
*/
@@ -1237,7 +1245,7 @@ fusethread(void *v)
FuseMsg *m;
m = v;
- if((uint)m->hdr->opcode >= nelem(fusehandlers)
+ if((uint)m->hdr->opcode >= nelem(fusehandlers)
|| !fusehandlers[m->hdr->opcode]){
replyfuseerrno(m, ENOSYS);
return;
@@ -1267,7 +1275,7 @@ fusedispatch(void *v)
case FUSE_FORGET:
fusehandlers[m->hdr->opcode](m);
break;
- default:
+ default:
threadcreate(fusethread, m, STACK);
}
}
diff --git a/src/cmd/9pserve.c b/src/cmd/9pserve.c
index 077715d6c..e26eef146 100644
--- a/src/cmd/9pserve.c
+++ b/src/cmd/9pserve.c
@@ -137,6 +137,12 @@ usage(void)
threadexitsall("usage");
}
+int
+threadmaybackground(void)
+{
+ return 1;
+}
+
uchar vbuf[128];
extern int _threaddebuglevel;
void
@@ -185,7 +191,7 @@ threadmain(int argc, char **argv)
logging++;
break;
}ARGEND
-
+
if(attached && !versioned){
fprint(2, "-A must be used with -M\n");
usage();
@@ -258,7 +264,7 @@ mainproc(void *v)
/* if(rootfid) */
/* dorootstat(); */
-
+
threadcreate(listenthread, nil, STACK);
threadexits(0);
}
@@ -302,7 +308,7 @@ listenthread(void *arg)
c->outqdead = chancreate(sizeof(void*), 0);
if(verbose) fprint(2, "%T incoming call on %s\n", c->dir);
threadcreate(connthread, c, STACK);
- }
+ }
}
void
@@ -348,7 +354,7 @@ char*
estrdup(char *s)
{
char *t;
-
+
t = emalloc(strlen(s)+1);
strcpy(t, s);
return t;
@@ -713,7 +719,7 @@ openfdthread(void *v)
chanfree(c->internal);
c->internal = 0;
free(c);
-}
+}
int
xopenfd(Msg *m)
@@ -868,7 +874,7 @@ outputthread(void *arg)
closeioproc(io);
fprint(2, "%T output eof\n");
threadexitsall(0);
-}
+}
void
inputthread(void *arg)
@@ -1041,7 +1047,7 @@ msgnew(int x)
* Clear data associated with connections, so that
* if all msgs have been msgcleared, the connection
* can be freed. Note that this does *not* free the tpkt
- * and rpkt; they are freed in msgput with the msg itself.
+ * and rpkt; they are freed in msgput with the msg itself.
* The io write thread might still be holding a ref to msg
* even once the connection has finished with it.
*/
@@ -1080,7 +1086,7 @@ msgput(Msg *m)
if(m == nil)
return;
- if(verbose > 1) fprint(2, "%T msgput 0x%lux %p tag %d/%d ref %d\n",
+ if(verbose > 1) fprint(2, "%T msgput 0x%lux %p tag %d/%d ref %d\n",
getcallerpc(&m), m, m->tag, m->ctag, m->ref);
assert(m->ref > 0);
if(--m->ref > 0)
@@ -1248,6 +1254,8 @@ mread9p(Ioproc *io, int fd)
nn = convM2S(pkt, n, &m->tx);
if(nn != n){
fprint(2, "%T read bad packet from %d\n", fd);
+ free(m->tpkt);
+ free(m);
return nil;
}
return m;
@@ -1294,7 +1302,7 @@ repack(Fcall *f, uchar **ppkt)
{
uint n, nn;
uchar *pkt;
-
+
pkt = *ppkt;
n = GBIT32(pkt);
nn = sizeS2M(f);
@@ -1303,7 +1311,7 @@ repack(Fcall *f, uchar **ppkt)
pkt = emalloc(nn);
*ppkt = pkt;
}
- n = convS2M(f, pkt, nn);
+ n = convS2M(f, pkt, nn);
if(n <= BIT16SZ)
sysfatal("convS2M conversion error");
if(n != nn)
@@ -1399,13 +1407,13 @@ ioaccept(Ioproc *io, int fd, char *dir)
int
timefmt(Fmt *fmt)
{
- static char *mon[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ static char *mon[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
vlong ns;
Tm tm;
ns = nsec();
tm = *localtime(time(0));
- return fmtprint(fmt, "%s %2d %02d:%02d:%02d.%03d",
+ return fmtprint(fmt, "%s %2d %02d:%02d:%02d.%03d",
mon[tm.mon], tm.mday, tm.hour, tm.min, tm.sec,
(int)(ns%1000000000)/1000000);
}
diff --git a/src/cmd/9term/9term.c b/src/cmd/9term/9term.c
index 107afed3f..d7391cf52 100644
--- a/src/cmd/9term/9term.c
+++ b/src/cmd/9term/9term.c
@@ -47,17 +47,23 @@ usage(void)
threadexitsall("usage");
}
+int
+threadmaybackground(void)
+{
+ return 1;
+}
+
void
threadmain(int argc, char *argv[])
{
char *p;
-
+
rfork(RFNOTEG);
font = nil;
_wantfocuschanges = 1;
mainpid = getpid();
messagesize = 8192;
-
+
ARGBEGIN{
default:
usage();
@@ -80,7 +86,7 @@ threadmain(int argc, char *argv[])
winsize = EARGF(usage());
break;
}ARGEND
-
+
if(fontname)
putenv("font", fontname);
@@ -92,7 +98,7 @@ threadmain(int argc, char *argv[])
if(maxtab <= 0)
maxtab = 4;
free(p);
-
+
startdir = ".";
if(initdraw(derror, fontname, "9term") < 0)
@@ -100,7 +106,7 @@ threadmain(int argc, char *argv[])
notify(hangupnote);
noteenable("sys: child");
-
+
mousectl = initmouse(nil, screen);
if(mousectl == nil)
error("cannot find mouse");
@@ -181,13 +187,13 @@ void
resizethread(void *v)
{
Point p;
-
+
USED(v);
-
+
for(;;){
p = stringsize(display->defaultfont, "0");
if(p.x && p.y)
- updatewinsize(Dy(screen->r)/p.y, (Dx(screen->r)-Scrollwid-2)/p.x,
+ updatewinsize(Dy(screen->r)/p.y, (Dx(screen->r)-Scrollwid-2)/p.x,
Dx(screen->r), Dy(screen->r));
wresize(w, screen, 0);
flushimage(display, 1);
@@ -197,7 +203,7 @@ resizethread(void *v)
sysfatal("can't reattach to window");
}
}
-
+
void
mousethread(void *v)
{
@@ -229,7 +235,7 @@ mousethread(void *v)
bouncemouse(mouse);
}
}
-
+
void
wborder(Window *w, int type)
{
@@ -288,6 +294,7 @@ enum
Paste,
Snarf,
Plumb,
+ Look,
Send,
Scroll,
Cook
@@ -298,6 +305,7 @@ char *menu2str[] = {
"paste",
"snarf",
"plumb",
+ "look",
"send",
"cook",
"scroll",
@@ -348,6 +356,10 @@ button2menu(Window *w)
wplumb(w);
break;
+ case Look:
+ wlook(w);
+ break;
+
case Send:
riogetsnarf();
wsnarf(w);
@@ -399,7 +411,7 @@ rcoutputproc(void *arg)
Conswritemesg cwm;
Rune *r;
Stringpair pair;
-
+
i = 0;
cnt = 0;
for(;;){
@@ -426,11 +438,11 @@ rcoutputproc(void *arg)
if(nb < cnt)
memmove(data, data+nb, cnt-nb);
cnt -= nb;
-
+
nr = label(r, nr);
if(nr == 0)
continue;
-
+
recv(w->conswrite, &cwm);
pair.s = r;
pair.ns = nr;
@@ -442,7 +454,7 @@ void
winterrupt(Window *w)
{
char rubout[1];
-
+
USED(w);
rubout[0] = getintr(sfd);
write(rcfd, rubout, 1);
@@ -468,7 +480,7 @@ label(Rune *sr, int n)
{
Rune *sl, *el, *er, *r;
char *p, *dir;
-
+
er = sr+n;
for(r=er-1; r>=sr; r--)
if(*r == '\007')
@@ -521,7 +533,7 @@ rcinputproc(void *arg)
recv(w->consread, &crm);
c1 = crm.c1;
c2 = crm.c2;
-
+
pair.s = data;
pair.ns = sizeof data;
send(c1, &pair);
@@ -541,7 +553,7 @@ void
rioputsnarf(void)
{
char *s;
-
+
s = smprint("%.*S", nsnarf, snarf);
if(s){
putsnarf(s);
@@ -642,7 +654,7 @@ textproc(void *arg)
for(x=0; x= end)
break;
p = buf;
@@ -658,4 +670,3 @@ textproc(void *arg)
break2:
close(fd);
}
-
diff --git a/src/cmd/9term/AIX.c b/src/cmd/9term/AIX.c
new file mode 100644
index 000000000..eec79c286
--- /dev/null
+++ b/src/cmd/9term/AIX.c
@@ -0,0 +1 @@
+#include "bsdpty.c"
diff --git a/src/cmd/9term/FreeBSD.c b/src/cmd/9term/FreeBSD.c
index eec79c286..e91f6ace5 100644
--- a/src/cmd/9term/FreeBSD.c
+++ b/src/cmd/9term/FreeBSD.c
@@ -1 +1,17 @@
+#define getpts not_using_this_getpts
#include "bsdpty.c"
+#undef getpts
+
+#include
+
+int
+getpts(int fd[], char *slave)
+{
+ if(openpty(&fd[1], &fd[0], NULL, NULL, NULL) >= 0){
+ fchmod(fd[1], 0620);
+ strcpy(slave, ttyname(fd[0]));
+ return 0;
+ }
+ sysfatal("no ptys");
+ return 0;
+}
diff --git a/src/cmd/9term/NetBSD.c b/src/cmd/9term/NetBSD.c
index eec79c286..182948033 100644
--- a/src/cmd/9term/NetBSD.c
+++ b/src/cmd/9term/NetBSD.c
@@ -1 +1,17 @@
+#define getpts not_using_this_getpts
#include "bsdpty.c"
+#undef getpts
+
+#include
+
+int
+getpts(int fd[], char *slave)
+{
+ if(openpty(&fd[1], &fd[0], NULL, NULL, NULL) >= 0){
+ fchmod(fd[1], 0620);
+ strcpy(slave, ttyname(fd[0]));
+ return 0;
+ }
+ sysfatal("no ptys: %r");
+ return 0;
+}
diff --git a/src/cmd/9term/SunOS.c b/src/cmd/9term/SunOS.c
index e0f866ab5..73914a674 100644
--- a/src/cmd/9term/SunOS.c
+++ b/src/cmd/9term/SunOS.c
@@ -84,4 +84,3 @@ getintr(int fd)
return 0x7F;
return ttmode.c_cc[VINTR];
}
-
diff --git a/src/cmd/9term/bsdpty.c b/src/cmd/9term/bsdpty.c
index 31281325a..e7e047e35 100644
--- a/src/cmd/9term/bsdpty.c
+++ b/src/cmd/9term/bsdpty.c
@@ -5,7 +5,9 @@
#include
#include
#include
+#ifdef HAS_SYS_TERMIOS
#include
+#endif
#ifdef __linux__
#include
#endif
@@ -20,7 +22,7 @@ static char *abc =
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789";
-static char *_123 =
+static char *_123 =
"0123456789"
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
@@ -61,8 +63,10 @@ childpty(int fd[], char *slave)
sfd = open(slave, ORDWR);
if(sfd < 0)
sysfatal("child open %s: %r\n", slave);
+#if !defined (__AIX__)
if(ioctl(sfd, TIOCSCTTY, 0) < 0)
fprint(2, "ioctl TIOCSCTTY: %r\n");
+#endif
return sfd;
}
@@ -111,4 +115,3 @@ getintr(int fd)
return 0x7F;
return ttmode.c_cc[VINTR];
}
-
diff --git a/src/cmd/9term/dat.h b/src/cmd/9term/dat.h
index c1af6592a..a215253fb 100644
--- a/src/cmd/9term/dat.h
+++ b/src/cmd/9term/dat.h
@@ -91,8 +91,8 @@ struct Mouseinfo
ulong counter; /* serial no. of last mouse event we received */
ulong lastcounter; /* serial no. of last mouse event sent to client */
int lastb; /* last button state we received */
- uchar qfull; /* filled the queue; no more recording until client comes back */
-};
+ uchar qfull; /* filled the queue; no more recording until client comes back */
+};
struct Window
{
@@ -177,6 +177,7 @@ void wmousectl(Window*);
void wmovemouse(Window*, Point);
void wpaste(Window*);
void wplumb(Window*);
+void wlook(Window*);
void wrefresh(Window*, Rectangle);
void wrepaint(Window*);
void wresize(Window*, Image*, int);
diff --git a/src/cmd/9term/data.c b/src/cmd/9term/data.c
index e0f18e873..4c2a76020 100644
--- a/src/cmd/9term/data.c
+++ b/src/cmd/9term/data.c
@@ -48,121 +48,121 @@ Cursor sightcursor = {
Cursor whitearrow = {
{0, 0},
- {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC,
- 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF8, 0xFF, 0xFC,
- 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC,
+ {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC,
+ 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF8, 0xFF, 0xFC,
+ 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC,
0xF3, 0xF8, 0xF1, 0xF0, 0xE0, 0xE0, 0xC0, 0x40, },
- {0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x06, 0xC0, 0x1C,
- 0xC0, 0x30, 0xC0, 0x30, 0xC0, 0x38, 0xC0, 0x1C,
- 0xC0, 0x0E, 0xC0, 0x07, 0xCE, 0x0E, 0xDF, 0x1C,
+ {0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x06, 0xC0, 0x1C,
+ 0xC0, 0x30, 0xC0, 0x30, 0xC0, 0x38, 0xC0, 0x1C,
+ 0xC0, 0x0E, 0xC0, 0x07, 0xCE, 0x0E, 0xDF, 0x1C,
0xD3, 0xB8, 0xF1, 0xF0, 0xE0, 0xE0, 0xC0, 0x40, }
};
Cursor query = {
{-7,-7},
- {0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe,
- 0x7c, 0x7e, 0x78, 0x7e, 0x00, 0xfc, 0x01, 0xf8,
- 0x03, 0xf0, 0x07, 0xe0, 0x07, 0xc0, 0x07, 0xc0,
+ {0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe,
+ 0x7c, 0x7e, 0x78, 0x7e, 0x00, 0xfc, 0x01, 0xf8,
+ 0x03, 0xf0, 0x07, 0xe0, 0x07, 0xc0, 0x07, 0xc0,
0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, },
- {0x00, 0x00, 0x0f, 0xf0, 0x1f, 0xf8, 0x3c, 0x3c,
- 0x38, 0x1c, 0x00, 0x3c, 0x00, 0x78, 0x00, 0xf0,
- 0x01, 0xe0, 0x03, 0xc0, 0x03, 0x80, 0x03, 0x80,
+ {0x00, 0x00, 0x0f, 0xf0, 0x1f, 0xf8, 0x3c, 0x3c,
+ 0x38, 0x1c, 0x00, 0x3c, 0x00, 0x78, 0x00, 0xf0,
+ 0x01, 0xe0, 0x03, 0xc0, 0x03, 0x80, 0x03, 0x80,
0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, }
};
Cursor tl = {
{-4, -4},
- {0xfe, 0x00, 0x82, 0x00, 0x8c, 0x00, 0x87, 0xff,
- 0xa0, 0x01, 0xb0, 0x01, 0xd0, 0x01, 0x11, 0xff,
- 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00,
+ {0xfe, 0x00, 0x82, 0x00, 0x8c, 0x00, 0x87, 0xff,
+ 0xa0, 0x01, 0xb0, 0x01, 0xd0, 0x01, 0x11, 0xff,
+ 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00,
0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x1f, 0x00, },
- {0x00, 0x00, 0x7c, 0x00, 0x70, 0x00, 0x78, 0x00,
- 0x5f, 0xfe, 0x4f, 0xfe, 0x0f, 0xfe, 0x0e, 0x00,
- 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00,
+ {0x00, 0x00, 0x7c, 0x00, 0x70, 0x00, 0x78, 0x00,
+ 0x5f, 0xfe, 0x4f, 0xfe, 0x0f, 0xfe, 0x0e, 0x00,
+ 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00,
0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x00, 0x00, }
};
Cursor t = {
{-7, -8},
- {0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x06, 0xc0,
- 0x1c, 0x70, 0x10, 0x10, 0x0c, 0x60, 0xfc, 0x7f,
- 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xff, 0xff,
+ {0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x06, 0xc0,
+ 0x1c, 0x70, 0x10, 0x10, 0x0c, 0x60, 0xfc, 0x7f,
+ 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
- 0x03, 0x80, 0x0f, 0xe0, 0x03, 0x80, 0x03, 0x80,
- 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x00, 0x00,
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
+ 0x03, 0x80, 0x0f, 0xe0, 0x03, 0x80, 0x03, 0x80,
+ 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }
};
Cursor tr = {
{-11, -4},
- {0x00, 0x7f, 0x00, 0x41, 0x00, 0x31, 0xff, 0xe1,
- 0x80, 0x05, 0x80, 0x0d, 0x80, 0x0b, 0xff, 0x88,
- 0x00, 0x88, 0x0, 0x88, 0x00, 0x88, 0x00, 0x88,
+ {0x00, 0x7f, 0x00, 0x41, 0x00, 0x31, 0xff, 0xe1,
+ 0x80, 0x05, 0x80, 0x0d, 0x80, 0x0b, 0xff, 0x88,
+ 0x00, 0x88, 0x0, 0x88, 0x00, 0x88, 0x00, 0x88,
0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0xf8, },
- {0x00, 0x00, 0x00, 0x3e, 0x00, 0x0e, 0x00, 0x1e,
- 0x7f, 0xfa, 0x7f, 0xf2, 0x7f, 0xf0, 0x00, 0x70,
- 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70,
+ {0x00, 0x00, 0x00, 0x3e, 0x00, 0x0e, 0x00, 0x1e,
+ 0x7f, 0xfa, 0x7f, 0xf2, 0x7f, 0xf0, 0x00, 0x70,
+ 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70,
0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x00, }
};
Cursor r = {
{-8, -7},
- {0x07, 0xc0, 0x04, 0x40, 0x04, 0x40, 0x04, 0x58,
- 0x04, 0x68, 0x04, 0x6c, 0x04, 0x06, 0x04, 0x02,
- 0x04, 0x06, 0x04, 0x6c, 0x04, 0x68, 0x04, 0x58,
+ {0x07, 0xc0, 0x04, 0x40, 0x04, 0x40, 0x04, 0x58,
+ 0x04, 0x68, 0x04, 0x6c, 0x04, 0x06, 0x04, 0x02,
+ 0x04, 0x06, 0x04, 0x6c, 0x04, 0x68, 0x04, 0x58,
0x04, 0x40, 0x04, 0x40, 0x04, 0x40, 0x07, 0xc0, },
- {0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80,
- 0x03, 0x90, 0x03, 0x90, 0x03, 0xf8, 0x03, 0xfc,
- 0x03, 0xf8, 0x03, 0x90, 0x03, 0x90, 0x03, 0x80,
+ {0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80,
+ 0x03, 0x90, 0x03, 0x90, 0x03, 0xf8, 0x03, 0xfc,
+ 0x03, 0xf8, 0x03, 0x90, 0x03, 0x90, 0x03, 0x80,
0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, }
};
Cursor br = {
{-11, -11},
- {0x00, 0xf8, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88,
- 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88,
- 0xff, 0x88, 0x80, 0x0b, 0x80, 0x0d, 0x80, 0x05,
+ {0x00, 0xf8, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88,
+ 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88,
+ 0xff, 0x88, 0x80, 0x0b, 0x80, 0x0d, 0x80, 0x05,
0xff, 0xe1, 0x00, 0x31, 0x00, 0x41, 0x00, 0x7f, },
- {0x00, 0x00, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70,
- 0x0, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70,
- 0x00, 0x70, 0x7f, 0xf0, 0x7f, 0xf2, 0x7f, 0xfa,
+ {0x00, 0x00, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70,
+ 0x0, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70,
+ 0x00, 0x70, 0x7f, 0xf0, 0x7f, 0xf2, 0x7f, 0xfa,
0x00, 0x1e, 0x00, 0x0e, 0x00, 0x3e, 0x00, 0x00, }
};
Cursor b = {
{-7, -7},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
- 0xfc, 0x7f, 0x0c, 0x60, 0x10, 0x10, 0x1c, 0x70,
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
+ 0xfc, 0x7f, 0x0c, 0x60, 0x10, 0x10, 0x1c, 0x70,
0x06, 0xc0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, },
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe,
- 0x03, 0x80, 0x03, 0x80, 0x0f, 0xe0, 0x03, 0x80,
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe,
+ 0x03, 0x80, 0x03, 0x80, 0x0f, 0xe0, 0x03, 0x80,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }
};
Cursor bl = {
{-4, -11},
- {0x1f, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00,
- 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00,
- 0x11, 0xff, 0xd0, 0x01, 0xb0, 0x01, 0xa0, 0x01,
+ {0x1f, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00,
+ 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00,
+ 0x11, 0xff, 0xd0, 0x01, 0xb0, 0x01, 0xa0, 0x01,
0x87, 0xff, 0x8c, 0x00, 0x82, 0x00, 0xfe, 0x00, },
- {0x00, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00,
- 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00,
- 0x0e, 0x00, 0x0f, 0xfe, 0x4f, 0xfe, 0x5f, 0xfe,
+ {0x00, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00,
+ 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00,
+ 0x0e, 0x00, 0x0f, 0xfe, 0x4f, 0xfe, 0x5f, 0xfe,
0x78, 0x00, 0x70, 0x00, 0x7c, 0x00, 0x00, 0x0, }
};
Cursor l = {
{-7, -7},
- {0x03, 0xe0, 0x02, 0x20, 0x02, 0x20, 0x1a, 0x20,
- 0x16, 0x20, 0x36, 0x20, 0x60, 0x20, 0x40, 0x20,
- 0x60, 0x20, 0x36, 0x20, 0x16, 0x20, 0x1a, 0x20,
+ {0x03, 0xe0, 0x02, 0x20, 0x02, 0x20, 0x1a, 0x20,
+ 0x16, 0x20, 0x36, 0x20, 0x60, 0x20, 0x40, 0x20,
+ 0x60, 0x20, 0x36, 0x20, 0x16, 0x20, 0x1a, 0x20,
0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x03, 0xe0, },
- {0x00, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0,
- 0x09, 0xc0, 0x09, 0xc0, 0x1f, 0xc0, 0x3f, 0xc0,
- 0x1f, 0xc0, 0x09, 0xc0, 0x09, 0xc0, 0x01, 0xc0,
+ {0x00, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0,
+ 0x09, 0xc0, 0x09, 0xc0, 0x1f, 0xc0, 0x3f, 0xc0,
+ 0x1f, 0xc0, 0x09, 0xc0, 0x09, 0xc0, 0x01, 0xc0,
0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x00, }
};
diff --git a/src/cmd/9term/fns.h b/src/cmd/9term/fns.h
index 34cebf01e..fd0bd74a3 100644
--- a/src/cmd/9term/fns.h
+++ b/src/cmd/9term/fns.h
@@ -39,4 +39,3 @@ int intrc(void);
void rioputsnarf(void);
void riogetsnarf(void);
-
diff --git a/src/cmd/9term/malloc.c b/src/cmd/9term/malloc.c
index 130942bdc..7b590bc4b 100644
--- a/src/cmd/9term/malloc.c
+++ b/src/cmd/9term/malloc.c
@@ -7,18 +7,14 @@
#define NOPLAN9DEFINES
#include
-static Lock malloclock;
-
void*
p9malloc(ulong n)
{
void *v;
-
+
if(n == 0)
n++;
- lock(&malloclock);
v = malloc(n);
- unlock(&malloclock);
print("p9malloc %lud => %p; pc %lux\n", n, v, getcallerpc(&n));
return v;
}
@@ -28,23 +24,19 @@ p9free(void *v)
{
if(v == nil)
return;
- lock(&malloclock);
print("p9free %p; pc %lux\n", v, getcallerpc(&v));
free(v);
- unlock(&malloclock);
}
void*
p9calloc(ulong a, ulong b)
{
void *v;
-
+
if(a*b == 0)
a = b = 1;
- lock(&malloclock);
v = calloc(a*b, 1);
- unlock(&malloclock);
print("p9calloc %lud %lud => %p; pc %lux\n", a, b, v, getcallerpc(&a));
return v;
}
@@ -53,11 +45,8 @@ void*
p9realloc(void *v, ulong n)
{
void *vv;
-
- lock(&malloclock);
+
vv = realloc(v, n);
- unlock(&malloclock);
print("p9realloc %p %lud => %p; pc %lux\n", v, n, vv, getcallerpc(&v));
return vv;
}
-
diff --git a/src/cmd/9term/rcstart.c b/src/cmd/9term/rcstart.c
index 5e6e11194..a447036d4 100644
--- a/src/cmd/9term/rcstart.c
+++ b/src/cmd/9term/rcstart.c
@@ -34,7 +34,7 @@ int
rcstart(int argc, char **argv, int *pfd, int *tfd)
{
int fd[2], i, pid;
- char *cmd, *xargv[3];
+ char *cmd, *xargv[4];
char slave[256];
int sfd;
@@ -46,6 +46,11 @@ rcstart(int argc, char **argv, int *pfd, int *tfd)
argv[0] = "rc";
argv[1] = "-i";
argv[2] = 0;
+ if(loginshell){
+ argv[2] = "-l";
+ argv[3] = 0;
+ argc = 3;
+ }
}
cmd = argv[0];
if(loginshell){
@@ -64,15 +69,15 @@ rcstart(int argc, char **argv, int *pfd, int *tfd)
}
/*
* notedisable("sys: window size change");
- *
+ *
* Can't disable because will be inherited by other programs
* like if you run an xterm from the prompt, and then xterm's
- * resizes won't get handled right. Sigh.
+ * resizes won't get handled right. Sigh.
*
* Can't not disable because when we stty below we'll get a
* signal, which will drop us into the thread library note handler,
* which will get all confused because we just forked and thus
- * have an unknown pid.
+ * have an unknown pid.
*
* So disable it internally. ARGH!
*/
@@ -87,6 +92,7 @@ rcstart(int argc, char **argv, int *pfd, int *tfd)
// Set $termprog to 9term or win for those who care about what kind of
// dumb terminal this is.
putenv("termprog", (char*)termprog);
+ putenv("TERM_PROGRAM", (char*)termprog);
pid = fork();
switch(pid){
@@ -139,7 +145,7 @@ echoed(char *p, int n)
if(echo.w+n > sizeof echo.buf)
n = 0;
memmove(echo.buf+echo.w, p, n);
- echo.w += n;
+ echo.w += n;
unlock(&echo.l);
}
diff --git a/src/cmd/9term/util.c b/src/cmd/9term/util.c
index 8a35d1d75..32ea08b62 100644
--- a/src/cmd/9term/util.c
+++ b/src/cmd/9term/util.c
@@ -146,4 +146,3 @@ runetobyte(Rune *r, int n, int *ip)
*ip = m;
return s;
}
-
diff --git a/src/cmd/9term/win.c b/src/cmd/9term/win.c
index 017d546b4..9c7a12eb6 100644
--- a/src/cmd/9term/win.c
+++ b/src/cmd/9term/win.c
@@ -134,7 +134,7 @@ threadmain(int argc, char **argv)
char buf1[128];
CFsys *fs;
char *dump;
-
+
dump = onestring(argc, argv);
ARGBEGIN{
@@ -215,7 +215,7 @@ threadmain(int argc, char **argv)
fswrite(ctlfd, buf, strlen(buf));
sprint(buf, "scroll");
fswrite(ctlfd, buf, strlen(buf));
-
+
updatewinsize(25, 80, 0, 0);
proccreate(stdoutproc, nil, STACK);
stdinproc(nil);
@@ -225,7 +225,7 @@ void
error(char *s, ...)
{
va_list arg;
-
+
if(s){
va_start(arg, s);
s = vsmprint(s, arg);
@@ -378,11 +378,11 @@ stdinproc(void *v)
fprint(2, "shift typing %d... ", e.q1-e.q0);
q.p += e.q1-e.q0;
break;
-
+
case 'i':
case 'd': /* tag */
break;
-
+
default:
goto Unknown;
}
@@ -484,7 +484,7 @@ dropcr(char *p, int n)
{
int i;
char *w, *r, *q;
-
+
r = p;
w = p;
for(i=0; i 0 && buf[i-1] == ' ')
i--;
@@ -743,7 +743,7 @@ void
sendtype(int fd0)
{
int i, n, nr, raw;
-
+
raw = israw(fd0);
while(ntypebreak || (raw && ntypeb > 0)){
for(i=0; iname, "window.%d.%d", w->id, w->namecount++);
for(i='A'; i<='Z'; i++){
if(nameimage(w->i, w->name, 1) > 0)
@@ -224,7 +224,7 @@ winctl(void *arg)
crm.c2 = chancreate(sizeof(Stringpair), 0);
cwrm.c1 = chancreate(sizeof(Stringpair), 0);
cwrm.c2 = chancreate(sizeof(Stringpair), 0);
-
+
alts[WKey].c = w->ck;
alts[WKey].v = &kbdr;
@@ -803,7 +803,7 @@ wbswidth(Window *w, Rune c)
if(r == '\n'){ /* eat at most one more character */
if(q == w->q0 && c != '\r') /* eat the newline */
--q;
- break;
+ break;
}
if(c == 0x17){
eq = isalnum(r);
@@ -906,6 +906,31 @@ winborder(Window *w, Point xy)
return ptinrect(xy, w->screenr) && !ptinrect(xy, insetrect(w->screenr, wscale(w, Selborder)));
}
+void
+wlook(Window *w)
+{
+ int i, n, e;
+
+ i = w->q1;
+ n = i - w->q0;
+ e = w->nr - n;
+ if(n <= 0 || e < n)
+ return;
+
+ if(i > e)
+ i = 0;
+
+ while(runestrncmp(w->r+w->q0, w->r+i, n) != 0){
+ if(i < e)
+ i++;
+ else
+ i = 0;
+ }
+
+ wsetselect(w, i, i+n);
+ wshow(w, i);
+}
+
void
wmousectl(Window *w)
{
@@ -1357,15 +1382,15 @@ wsetpid(Window *w, int pid, int dolabel)
}
}
-static Rune left1[] = {
+static Rune left1[] = {
'{', '[', '(', '<', 0xAB,
- 0x207d, 0x2329, 0x27e6, 0x27e8, 0x27ea,
- 0xfe59, 0xfe5b, 0xfe5d, 0xff08, 0xff3b, 0xff5b,
+ 0x207d, 0x2329, 0x27e6, 0x27e8, 0x27ea,
+ 0xfe59, 0xfe5b, 0xfe5d, 0xff08, 0xff3b, 0xff5b,
0
};
static Rune right1[] = {
'}', ']', ')', '>', 0xBB,
- 0x207e, 0x232a, 0x27e7, 0x27e9, 0x27eb,
+ 0x207e, 0x232a, 0x27e7, 0x27e9, 0x27eb,
0xfe5a, 0xfe5c, 0xfe5e, 0xff09, 0xff3d, 0xff5d,
0
};
diff --git a/src/cmd/acid/builtin.c b/src/cmd/acid/builtin.c
index ddc326a48..be387abeb 100644
--- a/src/cmd/acid/builtin.c
+++ b/src/cmd/acid/builtin.c
@@ -635,7 +635,7 @@ includepipe(Node *r, Node *args)
if(pipe(pip) < 0)
error("pipe: %r");
-
+
pid = fork();
switch(pid) {
case -1:
@@ -657,7 +657,7 @@ includepipe(Node *r, Node *args)
close(pip[1]);
pushfd(pip[0]);
-
+
isave = interactive;
interactive = 0;
r->store.u.ival = yyparse();
@@ -746,7 +746,7 @@ doaccess(Node *r, Node *args)
r->op = OCONST;
r->type = TINT;
r->store.fmt = 'D';
- r->store.u.ival = 0;
+ r->store.u.ival = 0;
if(access(res.store.u.string->string, 4) == 0)
r->store.u.ival = 1;
}
@@ -974,7 +974,7 @@ map(Node *r, Node *args)
i = findseg(m, nam, fil);
}
if(i < 0)
- error("%s %s is not a map entry", nam, fil);
+ error("%s %s is not a map entry", nam, fil);
l = l->next;
if(l->type != TINT)
error("map entry not int");
@@ -1008,7 +1008,7 @@ map(Node *r, Node *args)
}
}
-void
+void
flatten(Node **av, Node *n)
{
if(n == 0)
@@ -1086,7 +1086,7 @@ strace(Node *r, Node *args)
l = l->next;
}
regs.rw = straceregrw;
-
+
tracelist = 0;
if(stacktrace(cormap, ®s, trlist) <= 0)
error("no stack frame");
@@ -1482,7 +1482,7 @@ pcfile(Node *r, Node *args)
if(p == 0)
error("pcfile(addr): funny file %s", buf);
*p = '\0';
- r->store.u.string = strnode(buf);
+ r->store.u.string = strnode(buf);
}
void
@@ -1507,7 +1507,7 @@ pcline(Node *r, Node *args)
p = strrchr(buf, ':');
if(p == 0)
error("pcline(addr): funny file %s", buf);
- r->store.u.ival = atoi(p+1);
+ r->store.u.ival = atoi(p+1);
}
void
diff --git a/src/cmd/acid/dot.c b/src/cmd/acid/dot.c
index fd4464925..80ec2d020 100644
--- a/src/cmd/acid/dot.c
+++ b/src/cmd/acid/dot.c
@@ -46,9 +46,9 @@ odot(Node *n, Node *r)
error("no tag for (expr).%s", s);
/* Propagate types */
- if(t->type)
+ if(t->type)
r->store.comt = t->type->lt;
-
+
addr = res.store.u.ival+t->offset;
if(t->fmt == 'a') {
r->op = OCONST;
@@ -56,7 +56,7 @@ odot(Node *n, Node *r)
r->type = TINT;
r->store.u.ival = addr;
}
- else
+ else
indir(cormap, addr, t->fmt, r);
}
@@ -74,7 +74,7 @@ buildtype(Node *m, int d)
switch(m->op) {
case OLIST:
- buildtype(m->left, d);
+ buildtype(m->left, d);
buildtype(m->right, d);
break;
@@ -90,7 +90,7 @@ buildtype(Node *m, int d)
t->offset = m->store.u.ival;
if(m->left) {
t->type = m->left->sym;
- t->fmt = 'a';
+ t->fmt = 'a';
}
else {
t->type = 0;
@@ -101,7 +101,7 @@ buildtype(Node *m, int d)
*tail = t;
tail = &t->next;
- }
+ }
}
void
diff --git a/src/cmd/acid/expr.c b/src/cmd/acid/expr.c
index 088b98f84..dc2f59c76 100644
--- a/src/cmd/acid/expr.c
+++ b/src/cmd/acid/expr.c
@@ -74,7 +74,7 @@ chklval(Node *lp)
if(lp->op == OCALL){
s = chklval(lp->left);
- if(strcmp(s->name, "var") == 0
+ if(strcmp(s->name, "var") == 0
&& (lp->builtin || s->proc == 0)){
if(lp->right == 0)
error("var(string): arg count");
@@ -85,7 +85,7 @@ chklval(Node *lp)
}
}
error("need l-value");
- return nil;
+ return nil;
}
void
@@ -177,7 +177,7 @@ oframe(Node *n, Node *res)
lp = n->left;
if(localaddr(cormap, acidregs, p, lp->sym->name, &ival) < 0)
error("colon: %r");
-
+
res->store.u.ival = ival;
res->op = OCONST;
res->store.fmt = 'X';
@@ -397,7 +397,7 @@ oadd(Node *n, Node *res)
if(r.type == TSTRING) {
res->type = TSTRING;
res->store.fmt = 's';
- res->store.u.string = stradd(l.store.u.string, r.store.u.string);
+ res->store.u.string = stradd(l.store.u.string, r.store.u.string);
break;
}
error("bad rhs for +");
@@ -916,7 +916,7 @@ oeinc(Node *n, Node *res)
v->store.u.ival -= fmtsize(v);
else
v->store.u.ival += fmtsize(v);
- break;
+ break;
case TFLOAT:
if(n->op == OEDEC)
v->store.u.fval--;
@@ -944,7 +944,7 @@ opinc(Node *n, Node *res)
v->store.u.ival -= fmtsize(v);
else
v->store.u.ival += fmtsize(v);
- break;
+ break;
case TFLOAT:
if(n->op == OPDEC)
v->store.u.fval--;
diff --git a/src/cmd/acid/lex.c b/src/cmd/acid/lex.c
index 19581eab3..90e23f787 100644
--- a/src/cmd/acid/lex.c
+++ b/src/cmd/acid/lex.c
@@ -61,7 +61,7 @@ kinit(void)
initcmap();
- for(i = 0; keywds[i].name; i++)
+ for(i = 0; keywds[i].name; i++)
enter(keywds[i].name, keywds[i].terminal);
}
@@ -415,7 +415,7 @@ yylex(void)
return numsym('.');
return '.';
-
+
case '(':
case ')':
case '[':
@@ -671,7 +671,7 @@ delsym(Lsym *s)
for(q = s->name; *q; q++)
h = h*3 + *q;
h %= Hashsize;
-
+
if(hash[h] == s)
hash[h] = s->hash;
else{
diff --git a/src/cmd/acid/list.c b/src/cmd/acid/list.c
index 2c26426e2..af9f77ae6 100644
--- a/src/cmd/acid/list.c
+++ b/src/cmd/acid/list.c
@@ -54,7 +54,7 @@ build(Node *n)
l = al(res.type);
l->store = res.store;
*tail = l;
- tail = &l->next;
+ tail = &l->next;
}
}
diff --git a/src/cmd/acid/main.c b/src/cmd/acid/main.c
index 59ae90b1c..ba3ce46e5 100644
--- a/src/cmd/acid/main.c
+++ b/src/cmd/acid/main.c
@@ -92,7 +92,7 @@ main(int argc, char *argv[])
default:
usage();
}ARGEND
-
+
USED(pid);
fmtinstall('Z', Zfmt);
@@ -198,7 +198,7 @@ attachfiles(int argc, char **argv)
pid = 0;
interactive = 0;
USED(pid);
-
+
if(setjmp(err))
return -1;
diff --git a/src/cmd/acid/proc.c b/src/cmd/acid/proc.c
index e6efc95a0..ff37cd5f3 100644
--- a/src/cmd/acid/proc.c
+++ b/src/cmd/acid/proc.c
@@ -29,7 +29,7 @@ sproc(int xpid)
free(correg);
correg = regs;
}else{
- /* XXX should only change register set here if cormap already mapped */
+ /* XXX should only change register set here if cormap already mapped */
if(xpid <= 0)
error("bad pid");
unmapproc(cormap);
@@ -245,4 +245,3 @@ getstatus(int pid)
{
return "unknown";
}
-
diff --git a/src/cmd/acid/util.c b/src/cmd/acid/util.c
index 29db6d8bc..e44cb5e2f 100644
--- a/src/cmd/acid/util.c
+++ b/src/cmd/acid/util.c
@@ -40,7 +40,7 @@ unique(char *buf, Symbol *s)
if(l == 0)
l = enter(buf, Tid);
s->aux = l;
- return l;
+ return l;
}
void
@@ -122,22 +122,22 @@ addvarsym(Fhdr *fp)
tl->store.u.l = list;
list->store.u.string = strnode(buf);
list->store.fmt = 's';
-
+
list->next = al(TINT);
list = list->next;
list->store.fmt = 'c';
list->store.u.ival = s.type;
-
+
list->next = al(TINT);
list = list->next;
list->store.fmt = 'X';
list->store.u.ival = v;
-
+
list->next = al(TSTRING);
list = list->next;
list->store.fmt = 's';
list->store.u.string = file;
-
+
list->next = al(TSTRING);
list = list->next;
list->store.fmt = 's';
diff --git a/src/cmd/acidtypes/dat.h b/src/cmd/acidtypes/dat.h
index 8a043787c..97b3a1665 100644
--- a/src/cmd/acidtypes/dat.h
+++ b/src/cmd/acidtypes/dat.h
@@ -9,7 +9,7 @@ enum
Base,
Enum,
Aggr,
- Function,
+ Function,
Pointer,
Array,
Range,
@@ -92,4 +92,3 @@ int Bfmt(Fmt*);
#ifdef VARARGCK
#pragma varargck type "B" char*
#endif
-
diff --git a/src/cmd/acidtypes/dwarf.c b/src/cmd/acidtypes/dwarf.c
index f92942865..cb39fcbf8 100644
--- a/src/cmd/acidtypes/dwarf.c
+++ b/src/cmd/acidtypes/dwarf.c
@@ -183,4 +183,3 @@ ds2acid(Dwarf *d, DwarfSym *s, Biobuf *b, char *fn)
break;
}
}
-
diff --git a/src/cmd/acidtypes/main.c b/src/cmd/acidtypes/main.c
index f272f67a9..eb1a94182 100644
--- a/src/cmd/acidtypes/main.c
+++ b/src/cmd/acidtypes/main.c
@@ -64,7 +64,7 @@ main(int argc, char **argv)
}
have = 1;
}
-
+
if(!have){
Bprint(&b, "// no debugging symbols in %s\n\n", argv[i]);
/* fprint(2, "no debugging symbols in %s\n", argv[i]); */
@@ -75,4 +75,3 @@ main(int argc, char **argv)
Bterm(&b);
exits(0);
}
-
diff --git a/src/cmd/acidtypes/stabs.c b/src/cmd/acidtypes/stabs.c
index 5ce0d4611..0ca3b73f0 100644
--- a/src/cmd/acidtypes/stabs.c
+++ b/src/cmd/acidtypes/stabs.c
@@ -192,7 +192,7 @@ parsenum(char *p, int *n1, int *n2, char **pp)
/*
attr ::= '@' text ';'
- text is
+ text is
'a' integer (alignment)
'p' integer (pointer class)
'P' (packed type)
@@ -237,7 +237,7 @@ static Basic baseints[] =
/*13*/ 8, 'f', /* double */
/*14*/ 10, 'f', /* long double */
/*15*/ 4, 'd', /* int32 */
-/*16*/ 4, 'd', /* bool32 */
+/*16*/ 4, 'd', /* bool32 */
/*17*/ 2, 'f', /* short real */
/*18*/ 4, 'f', /* real */
/*19*/ 4, 'x', /* stringptr */
@@ -391,7 +391,7 @@ parsedefn(char *p, Type *t, char **pp)
t->ty = Pointer;
t->sub = parseinfo(p+1, &p);
break;
- case 'a': /* array */
+ case 'a': /* array */
case 'P': /* packed array */
t->ty = Pointer;
tt = newtype();
@@ -422,7 +422,7 @@ parsedefn(char *p, Type *t, char **pp)
}
semi(&p);
break;
-
+
case 's': /* struct */
case 'u': /* union */
p++;
@@ -532,7 +532,7 @@ parsedefn(char *p, Type *t, char **pp)
}
/*
- bound ::=
+ bound ::=
'A' offset (bound is on stack by ref at offset offset from arg list)
| 'T' offset (bound is on stack by val at offset offset from arg list)
| 'a' regnum (bound passed by reference in register)
@@ -642,7 +642,7 @@ stabs2acid(Stab *stabs, Biobuf *b)
fno++;
if((f = findftypes(dir, sym.name)) == nil){
static int cannotprint;
-
+
if(cannotprint++ == 0)
fprint(2, "cannot find remembered %s\n", sym.name);
continue;
@@ -673,7 +673,7 @@ stabs2acid(Stab *stabs, Biobuf *b)
}
if(setjmp(kaboom)){
static int cannotparse;
-
+
if(cannotparse++ == 0)
fprint(2, "cannot parse %s\n", name);
continue;
@@ -683,7 +683,7 @@ stabs2acid(Stab *stabs, Biobuf *b)
continue;
if(*p != 0){
static int extradesc;
-
+
if(extradesc++ == 0)
fprint(2, "extra desc '%s' in '%s'\n", p, desc);
}
diff --git a/src/cmd/acidtypes/type.c b/src/cmd/acidtypes/type.c
index 00897e346..0f1c2f309 100644
--- a/src/cmd/acidtypes/type.c
+++ b/src/cmd/acidtypes/type.c
@@ -95,7 +95,7 @@ typebynum(uint n1, uint n2)
t->n2 = n2;
addhash(t);
return t;
-}
+}
Type*
newtype(void)
@@ -251,10 +251,10 @@ cleanstl(char *name)
{
char *b, *p;
static char buf[65536]; /* These can be huge. */
-
+
if(strchr(name, '<') == nil)
return nonempty(name);
-
+
b = buf;
for(p = name; *p != 0; p++){
switch(*p){
@@ -443,7 +443,7 @@ char*
mkname(char *prefix, char *name)
{
static char buf[65536];
-
+
snprint(buf, sizeof buf, "%s%s", prefix, name);
return buf;
}
@@ -630,7 +630,7 @@ ttt=ttt->sub;
if(nprint == 0)
Bprint(b, "\t'X' 0 __dummy;\n");
Bprint(b, "};\n\n");
-
+
name = nameof(t, 1); /* might have smashed it */
Bprint(b, "defn %B(addr) { %B(addr, \"\"); }\n", name, mkname("indent_", name));
Bprint(b, "defn %B(addr, indent) {\n", mkname("indent_", name));
@@ -675,13 +675,13 @@ ttt=ttt->sub;
}
Bprint(b, "};\n\n");
break;
-
+
case Enum:
name = nameof(t, 1);
Bprint(b, "// enum %s\n", name);
for(j=0; jn; j++)
Bprint(b, "%B = %ld;\n", fixname(t->tname[j]), t->val[j]);
-
+
Bprint(b, "%B = {\n", mkname("vals_", name));
for(j=0; jn; j++)
Bprint(b, "\t%lud,\n", t->val[j]);
@@ -738,7 +738,7 @@ printtypes(Biobuf *b)
* only take one type of a given name; acid is going to do this anyway,
* and this will reduce the amount of code we output considerably.
* we could run a DFA equivalence relaxation sort of algorithm
- * to find the actual equivalence classes, and then rename types
+ * to find the actual equivalence classes, and then rename types
* appropriately, but this will do for now.
*/
all = emalloc(n*sizeof(all[0]));
diff --git a/src/cmd/acidtypes/util.c b/src/cmd/acidtypes/util.c
index 47fe193d7..41883bbd6 100644
--- a/src/cmd/acidtypes/util.c
+++ b/src/cmd/acidtypes/util.c
@@ -68,7 +68,7 @@ Bfmt(Fmt *fmt)
{
int i;
char *s, *t;
-
+
if(!isBfrog['.']){
for(i=0; i<256; i++)
if(i != '_' && i != '$' && i < Runeself && !isalnum(i))
diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c
index 10dcdcc85..d001a2a84 100644
--- a/src/cmd/acme/acme.c
+++ b/src/cmd/acme/acme.c
@@ -393,6 +393,7 @@ acmeerrorproc(void *v)
buf[n] = '\0';
sendp(cerr, estrdup(buf));
}
+ free(buf);
}
void
@@ -963,6 +964,74 @@ Cursor boxcursor = {
0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x00, 0x00}
};
+Cursor2 boxcursor2 = {
+ {-15, -15},
+ {0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xC0, 0x03, 0xFF,
+ 0xFF, 0xC0, 0x03, 0xFF,
+ 0xFF, 0xC0, 0x03, 0xFF,
+ 0xFF, 0xC0, 0x03, 0xFF,
+ 0xFF, 0xC0, 0x03, 0xFF,
+ 0xFF, 0xC0, 0x03, 0xFF,
+ 0xFF, 0xC0, 0x03, 0xFF,
+ 0xFF, 0xC0, 0x03, 0xFF,
+ 0xFF, 0xC0, 0x03, 0xFF,
+ 0xFF, 0xC0, 0x03, 0xFF,
+ 0xFF, 0xC0, 0x03, 0xFF,
+ 0xFF, 0xC0, 0x03, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF},
+ {0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x3F, 0xFF, 0xFF, 0xFC,
+ 0x3F, 0xFF, 0xFF, 0xFC,
+ 0x3F, 0xFF, 0xFF, 0xFC,
+ 0x3F, 0xFF, 0xFF, 0xFC,
+ 0x3F, 0xFF, 0xFF, 0xFC,
+ 0x3F, 0xFF, 0xFF, 0xFC,
+ 0x3F, 0x00, 0x00, 0xFC,
+ 0x3F, 0x00, 0x00, 0xFC,
+ 0x3F, 0x00, 0x00, 0xFC,
+ 0x3F, 0x00, 0x00, 0xFC,
+ 0x3F, 0x00, 0x00, 0xFC,
+ 0x3F, 0x00, 0x00, 0xFC,
+ 0x3F, 0x00, 0x00, 0xFC,
+ 0x3F, 0x00, 0x00, 0xFC,
+ 0x3F, 0x00, 0x00, 0xFC,
+ 0x3F, 0x00, 0x00, 0xFC,
+ 0x3F, 0x00, 0x00, 0xFC,
+ 0x3F, 0x00, 0x00, 0xFC,
+ 0x3F, 0x00, 0x00, 0xFC,
+ 0x3F, 0x00, 0x00, 0xFC,
+ 0x3F, 0x00, 0x00, 0xFC,
+ 0x3F, 0x00, 0x00, 0xFC,
+ 0x3F, 0xFF, 0xFF, 0xFC,
+ 0x3F, 0xFF, 0xFF, 0xFC,
+ 0x3F, 0xFF, 0xFF, 0xFC,
+ 0x3F, 0xFF, 0xFF, 0xFC,
+ 0x3F, 0xFF, 0xFF, 0xFC,
+ 0x3F, 0xFF, 0xFF, 0xFC,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00}
+};
+
void
iconinit(void)
{
@@ -976,7 +1045,7 @@ iconinit(void)
tagcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPurpleblue);
tagcols[TEXT] = display->black;
tagcols[HTEXT] = display->black;
-
+
/* Yellow */
textcols[BACK] = allocimagemix(display, DPaleyellow, DWhite);
textcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DDarkyellow);
@@ -984,7 +1053,7 @@ iconinit(void)
textcols[TEXT] = display->black;
textcols[HTEXT] = display->black;
}
-
+
r = Rect(0, 0, Scrollwid+ButtonBorder, font->height+1);
if(button && eqrect(r, button->r))
return;
@@ -1098,4 +1167,3 @@ timefmt(Fmt *f)
return fmtprint(f, "%04d/%02d/%02d %02d:%02d:%02d",
tm->year+1900, tm->mon+1, tm->mday, tm->hour, tm->min, tm->sec);
}
-
diff --git a/src/cmd/acme/addr.c b/src/cmd/acme/addr.c
index 2ccae960a..6aee8993c 100644
--- a/src/cmd/acme/addr.c
+++ b/src/cmd/acme/addr.c
@@ -240,12 +240,12 @@ address(uint showerr, Text *t, Range lim, Range ar, void *a, uint q0, uint q1, i
case '5': case '6': case '7': case '8': case '9':
n = c -'0';
while(qnw)
ymax = c->w[i]->r.min.y-Border;
else
ymax = c->r.max.y;
-
+
/* new window must start after v's tag ends */
y = max(y, v->tagtop.max.y+Border);
-
+
/* new window must start early enough to end before ymax */
y = min(y, ymax - minht);
-
+
/* if y is too small, too many windows in column */
if(y < v->tagtop.max.y+Border)
buggered = 1;
@@ -118,7 +118,7 @@ coladd(Column *c, Window *w, Window *clone, int y)
r1.min.y = winresize(v, r1, FALSE, FALSE);
r1.max.y = r1.min.y+Border;
draw(screen, r1, display->black, nil, ZP);
-
+
/*
* leave r with w's coordinates
*/
@@ -142,7 +142,7 @@ coladd(Column *c, Window *w, Window *clone, int y)
c->nw++;
c->w[i] = w;
c->safe = TRUE;
-
+
/* if there were too many windows, redraw the whole column */
if(buggered)
colresize(c, c->r);
@@ -232,7 +232,7 @@ colmousebut(Column *c)
void
colresize(Column *c, Rectangle r)
{
- int i;
+ int i, old, new;
Rectangle r1, r2;
Window *w;
@@ -245,13 +245,19 @@ colresize(Column *c, Rectangle r)
r1.max.y += Border;
draw(screen, r1, display->black, nil, ZP);
r1.max.y = r.max.y;
+ new = Dy(r) - c->nw*(Border + font->height);
+ old = Dy(c->r) - c->nw*(Border + font->height);
for(i=0; inw; i++){
w = c->w[i];
w->maxlines = 0;
if(i == c->nw-1)
r1.max.y = r.max.y;
- else
- r1.max.y = r1.min.y+(Dy(w->r)+Border)*Dy(r)/Dy(c->r);
+ else{
+ r1.max.y = r1.min.y;
+ if(new > 0 && old > 0 && Dy(w->r) > Border+font->height){
+ r1.max.y += (Dy(w->r)-Border-font->height)*new/old + Border + font->height;
+ }
+ }
r1.max.y = max(r1.max.y, r1.min.y + Border+font->height);
r2 = r1;
r2.max.y = r2.min.y+Border;
@@ -473,7 +479,7 @@ coldragwin(Column *c, Window *w, int but)
Column *nc;
clearmouse();
- setcursor(mousectl, &boxcursor);
+ setcursor2(mousectl, &boxcursor, &boxcursor2);
b = mouse->buttons;
op = mouse->xy;
while(mouse->buttons == b)
diff --git a/src/cmd/acme/dat.h b/src/cmd/acme/dat.h
index 8c4b14ee2..8a81c97d6 100644
--- a/src/cmd/acme/dat.h
+++ b/src/cmd/acme/dat.h
@@ -525,6 +525,7 @@ Image *button;
Image *but2col;
Image *but3col;
Cursor boxcursor;
+Cursor2 boxcursor2;
Row row;
int timerpid;
Disk *disk;
diff --git a/src/cmd/acme/ecmd.c b/src/cmd/acme/ecmd.c
index ef92e3395..f7613172b 100644
--- a/src/cmd/acme/ecmd.c
+++ b/src/cmd/acme/ecmd.c
@@ -28,7 +28,7 @@ int append(File*, Cmd*, long);
int pdisplay(File*);
void pfilename(File*);
void looper(File*, Cmd*, int);
-void filelooper(Cmd*, int);
+void filelooper(Text*, Cmd*, int);
void linelooper(File*, Cmd*);
Address lineaddr(long, Address, int);
int filematch(File*, String*);
@@ -584,7 +584,7 @@ X_cmd(Text *t, Cmd *cp)
{
USED(t);
- filelooper(cp, cp->cmdc=='X');
+ filelooper(t, cp, cp->cmdc=='X');
return TRUE;
}
@@ -633,8 +633,8 @@ runpipe(Text *t, int cmd, Rune *cr, int ncr, int state)
/*
* The editoutlk exists only so that we can tell when
* the editout file has been closed. It can get closed *after*
- * the process exits because, since the process cannot be
- * connected directly to editout (no 9P kernel support),
+ * the process exits because, since the process cannot be
+ * connected directly to editout (no 9P kernel support),
* the process is actually connected to a pipe to another
* process (arranged via 9pserve) that reads from the pipe
* and then writes the data in the pipe to editout using
@@ -704,7 +704,7 @@ printposn(Text *t, int mode)
if (t != nil && t->file != nil && t->file->name != nil)
warning(nil, "%.*S:", t->file->nname, t->file->name);
-
+
switch(mode) {
case PosnChars:
warning(nil, "#%d", addr.r.q0);
@@ -712,7 +712,7 @@ printposn(Text *t, int mode)
warning(nil, ",#%d", addr.r.q1);
warning(nil, "\n");
return;
-
+
default:
case PosnLine:
l1 = 1+nlcount(t, 0, addr.r.q0, nil);
@@ -978,9 +978,10 @@ alllocker(Window *w, void *v)
}
void
-filelooper(Cmd *cp, int XY)
+filelooper(Text *t, Cmd *cp, int XY)
{
int i;
+ Text *targ;
if(Glooping++)
editerror("can't nest %c command", "YX"[XY]);
@@ -1001,8 +1002,26 @@ filelooper(Cmd *cp, int XY)
*/
allwindows(alllocker, (void*)1);
globalincref = 1;
- for(i=0; ibody, cp->u.cmd);
+
+ /*
+ * Unlock the window running the X command.
+ * We'll need to lock and unlock each target window in turn.
+ */
+ if(t && t->w)
+ winunlock(t->w);
+
+ for(i=0; ibody;
+ if(targ && targ->w)
+ winlock(targ->w, cp->cmdc);
+ cmdexec(targ, cp->u.cmd);
+ if(targ && targ->w)
+ winunlock(targ->w);
+ }
+
+ if(t && t->w)
+ winlock(t->w, cp->cmdc);
+
allwindows(alllocker, (void*)0);
globalincref = 0;
free(loopstruct.w);
diff --git a/src/cmd/acme/edit.c b/src/cmd/acme/edit.c
index d3f820593..82a19b0d5 100644
--- a/src/cmd/acme/edit.c
+++ b/src/cmd/acme/edit.c
@@ -515,7 +515,7 @@ parsecmd(int nest)
if(nextc() == 'g')
cmd.flag = getch();
}
-
+
}
}
}
@@ -613,7 +613,7 @@ simpleaddr(void)
addr.num = getnum(1);
break;
case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
+ case '5': case '6': case '7': case '8': case '9':
addr.num = getnum(1);
addr.type='l';
break;
@@ -635,9 +635,11 @@ simpleaddr(void)
case '.':
case '$':
case '\'':
- if(addr.type!='"')
+ if(addr.type=='"')
+ break;
+ /* fall through */
case '"':
- editerror("bad address syntax");
+ editerror("bad address syntax");
break;
case 'l':
case '#':
diff --git a/src/cmd/acme/elog.c b/src/cmd/acme/elog.c
index c5650f03f..8a8951fb4 100644
--- a/src/cmd/acme/elog.c
+++ b/src/cmd/acme/elog.c
@@ -243,7 +243,7 @@ elogapply(File *f)
* but using coordinates relative to the unmodified buffer. As we apply the log,
* we have to update the coordinates to be relative to the modified buffer.
* Textinsert and textdelete will do this for us; our only work is to apply the
- * convention that an insertion at t->q0==t->q1 is intended to select the
+ * convention that an insertion at t->q0==t->q1 is intended to select the
* inserted text.
*/
@@ -337,7 +337,7 @@ elogapply(File *f)
}
fbuffree(buf);
elogterm(f);
-
+
/*
* Bad addresses will cause bufload to crash, so double check.
* If changes were out of order, we expect problems so don't complain further.
diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c
index deaef0cb1..1dd022889 100644
--- a/src/cmd/acme/exec.c
+++ b/src/cmd/acme/exec.c
@@ -192,8 +192,9 @@ execute(Text *t, uint aq0, uint aq1, int external, Text *argt)
f |= 2;
}
aa = getbytearg(argt, TRUE, TRUE, &a);
- if(a){
+ if(a){
if(strlen(a) > EVENTSIZE){ /* too big; too bad */
+ free(r);
free(aa);
free(a);
warning(nil, "argument string too long\n");
@@ -208,14 +209,14 @@ execute(Text *t, uint aq0, uint aq1, int external, Text *argt)
if(n <= EVENTSIZE)
winevent(t->w, "%c%d %d %d %d %.*S\n", c, aq0, aq1, f, n, n, r);
else
- winevent(t->w, "%c%d %d %d 0 \n", c, aq0, aq1, f, n);
+ winevent(t->w, "%c%d %d %d 0 \n", c, aq0, aq1, f);
if(q0!=aq0 || q1!=aq1){
n = q1-q0;
bufread(&t->file->b, q0, r, n);
if(n <= EVENTSIZE)
winevent(t->w, "%c%d %d 0 %d %.*S\n", c, q0, q1, n, n, r);
else
- winevent(t->w, "%c%d %d 0 0 \n", c, q0, q1, n);
+ winevent(t->w, "%c%d %d 0 0 \n", c, q0, q1);
}
if(a){
winevent(t->w, "%c0 0 0 %d %s\n", c, utflen(a), a);
@@ -673,7 +674,7 @@ checksha1(char *name, File *f, Dir *d)
DigestState *h;
uchar out[20];
uchar *buf;
-
+
fd = open(name, OREAD);
if(fd < 0)
return;
@@ -689,7 +690,7 @@ checksha1(char *name, File *f, Dir *d)
f->qidpath = d->qid.path;
f->mtime = d->mtime;
}
-}
+}
void
putfile(File *f, int q0, int q1, Rune *namer, int nname)
@@ -698,7 +699,7 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname)
Rune *r;
Biobuf *b;
char *s, *name;
- int i, fd, q;
+ int i, fd, q, ret, retc;
Dir *d, *d1;
Window *w;
int isapp;
@@ -721,6 +722,7 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname)
goto Rescue1;
}
}
+
fd = create(name, OWRITE, 0666);
if(fd < 0){
warning(nil, "can't create file %s: %r\n", name);
@@ -760,9 +762,14 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname)
warning(nil, "can't write file %s: %r\n", name);
goto Rescue2;
}
- Bterm(b);
+ ret = Bterm(b);
+ retc = close(fd);
free(b);
b = nil;
+ if(ret < 0 || retc < 0) {
+ warning(nil, "can't write file %s: %r\n", name);
+ goto Rescue2; // flush or close failed
+ }
if(runeeq(namer, nname, f->name, f->nname)){
if(q0!=0 || q1!=f->b.nc){
f->mod = TRUE;
@@ -779,10 +786,9 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname)
// in case we don't have read permission.
// (The create above worked, so we probably
// still have write permission.)
- close(fd);
fd = open(name, OWRITE);
-
d1 = dirfstat(fd);
+ close(fd);
if(d1 != nil){
free(d);
d = d1;
@@ -815,11 +821,11 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname)
if(b != nil) {
Bterm(b);
free(b);
+ close(fd);
}
free(h);
fbuffree(s);
fbuffree(r);
- close(fd);
/* fall through */
Rescue1:
@@ -828,6 +834,65 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname)
free(name);
}
+static void
+trimspaces(Text *et)
+{
+ File *f;
+ Rune *r;
+ Text *t;
+ uint q0, n, delstart;
+ int c, i, marked;
+
+ t = &et->w->body;
+ f = t->file;
+ marked = 0;
+
+ if(t->w!=nil && et->w!=t->w){
+ /* can this happen when t == &et->w->body? */
+ c = 'M';
+ if(et->w)
+ c = et->w->owner;
+ winlock(t->w, c);
+ }
+
+ r = fbufalloc();
+ q0 = f->b.nc;
+ delstart = q0; /* end of current space run, or 0 if no active run; = q0 to delete spaces before EOF */
+ while(q0 > 0) {
+ n = RBUFSIZE;
+ if(n > q0)
+ n = q0;
+ q0 -= n;
+ bufread(&f->b, q0, r, n);
+ for(i=n; ; i--) {
+ if(i == 0 || (r[i-1] != ' ' && r[i-1] != '\t')) {
+ // Found non-space or start of buffer. Delete active space run.
+ if(q0+i < delstart) {
+ if(!marked) {
+ marked = 1;
+ seq++;
+ filemark(f);
+ }
+ textdelete(t, q0+i, delstart, TRUE);
+ }
+ if(i == 0) {
+ /* keep run active into tail of next buffer */
+ if(delstart > 0)
+ delstart = q0;
+ break;
+ }
+ delstart = 0;
+ if(r[i-1] == '\n')
+ delstart = q0+i-1; /* delete spaces before this newline */
+ }
+ }
+ }
+ fbuffree(r);
+
+ if(t->w!=nil && et->w!=t->w)
+ winunlock(t->w);
+}
+
void
put(Text *et, Text *_0, Text *argt, int _1, int _2, Rune *arg, int narg)
{
@@ -850,6 +915,8 @@ put(Text *et, Text *_0, Text *argt, int _1, int _2, Rune *arg, int narg)
warning(nil, "no file name\n");
return;
}
+ if(w->autoindent)
+ trimspaces(et);
namer = bytetorune(name, &nname);
putfile(f, 0, f->b.nc, namer, nname);
xfidlog(w, "put");
diff --git a/src/cmd/acme/fns.h b/src/cmd/acme/fns.h
index 8dc023781..969db417f 100644
--- a/src/cmd/acme/fns.h
+++ b/src/cmd/acme/fns.h
@@ -25,6 +25,8 @@ void savemouse(Window*);
int restoremouse(Window*);
void clearmouse(void);
void allwindows(void(*)(Window*, void*), void*);
+uint seqof(Window*, int);
+
uint loadfile(int, uint, int*, int(*)(void*, uint, Rune*, int), void*, DigestState*);
void movetodel(Window*);
@@ -95,6 +97,7 @@ void flushwarnings(void);
void startplumbing(void);
long nlcount(Text*, long, long, long*);
long nlcounttopos(Text*, long, long, long);
+Rune* parsetag(Window*, int, int*);
Runestr runestr(Rune*, uint);
Range range(int, int);
diff --git a/src/cmd/acme/fsys.c b/src/cmd/acme/fsys.c
index 4c395eb2b..d9d4b30d7 100644
--- a/src/cmd/acme/fsys.c
+++ b/src/cmd/acme/fsys.c
@@ -463,7 +463,7 @@ fsyswalk(Xfid *x, Fid *f)
qunlock(&row.lk);
dir = dirtabw;
goto Accept;
-
+
Regular:
if(strcmp(x->fcall.wname[i], "new") == 0){
if(w)
diff --git a/src/cmd/acme/logf.c b/src/cmd/acme/logf.c
index 567b83839..562026c92 100644
--- a/src/cmd/acme/logf.c
+++ b/src/cmd/acme/logf.c
@@ -20,7 +20,7 @@ struct Log
Rendez r;
vlong start; // msg[0] corresponds to 'start' in the global sequence of events
-
+
// queued events (nev=entries in ev, mev=capacity of p)
char **ev;
int nev;
@@ -30,7 +30,7 @@ struct Log
Fid **f;
int nf;
int mf;
-
+
// active (blocked) reads waiting for events
Xfid **read;
int nread;
@@ -43,7 +43,7 @@ void
xfidlogopen(Xfid *x)
{
qlock(&eventlog.lk);
- if(eventlog.nf >= eventlog.mf) {
+ if(eventlog.nf >= eventlog.mf) {
eventlog.mf = eventlog.mf*2;
if(eventlog.mf == 0)
eventlog.mf = 8;
@@ -78,20 +78,20 @@ xfidlogread(Xfid *x)
Fcall fc;
qlock(&eventlog.lk);
- if(eventlog.nread >= eventlog.mread) {
+ if(eventlog.nread >= eventlog.mread) {
eventlog.mread = eventlog.mread*2;
if(eventlog.mread == 0)
eventlog.mread = 8;
eventlog.read = erealloc(eventlog.read, eventlog.mread*sizeof eventlog.read[0]);
}
eventlog.read[eventlog.nread++] = x;
-
+
if(eventlog.r.l == nil)
eventlog.r.l = &eventlog.lk;
x->flushed = FALSE;
while(x->f->logoff >= eventlog.start+eventlog.nev && !x->flushed)
rsleep(&eventlog.r);
-
+
for(i=0; i= eventlog.mev) {
eventlog.mev = eventlog.mev*2;
diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c
index cbbc71bf5..a7172b505 100644
--- a/src/cmd/acme/look.c
+++ b/src/cmd/acme/look.c
@@ -30,7 +30,7 @@ plumbthread(void *v)
USED(v);
threadsetname("plumbproc");
-
+
/*
* Loop so that if plumber is restarted, acme need not be.
*/
@@ -46,7 +46,7 @@ plumbthread(void *v)
}
plumbeditfid = fid;
plumbsendfid = plumbopenfid("send", OWRITE|OCEXEC);
-
+
/*
* Relay messages.
*/
@@ -378,7 +378,7 @@ search(Text *ct, Rune *r, uint n)
int
isfilec(Rune r)
{
- static Rune Lx[] = { '.', '-', '+', '/', ':', 0 };
+ static Rune Lx[] = { '.', '-', '+', '/', ':', '@', 0 };
if(isalnum(r))
return TRUE;
if(runestrchr(Lx, r))
@@ -432,9 +432,9 @@ includename(Text *t, Rune *r, int n)
char buf[128];
Rune Lsysinclude[] = { '/', 's', 'y', 's', '/', 'i', 'n', 'c', 'l', 'u', 'd', 'e', 0 };
Rune Lusrinclude[] = { '/', 'u', 's', 'r', '/', 'i', 'n', 'c', 'l', 'u', 'd', 'e', 0 };
- Rune Lusrlocalinclude[] = { '/', 'u', 's', 'r', '/', 'l', 'o', 'c', 'a', 'l',
+ Rune Lusrlocalinclude[] = { '/', 'u', 's', 'r', '/', 'l', 'o', 'c', 'a', 'l',
'/', 'i', 'n', 'c', 'l', 'u', 'd', 'e', 0 };
- Rune Lusrlocalplan9include[] = { '/', 'u', 's', 'r', '/', 'l', 'o', 'c', 'a', 'l',
+ Rune Lusrlocalplan9include[] = { '/', 'u', 's', 'r', '/', 'l', 'o', 'c', 'a', 'l',
'/', 'p', 'l', 'a', 'n', '9', '/', 'i', 'n', 'c', 'l', 'u', 'd', 'e', 0 };
Runestr file;
int i;
@@ -443,7 +443,7 @@ includename(Text *t, Rune *r, int n)
sprint(buf, "/%s/include", objtype);
objdir = bytetorune(buf, &i);
objdir = runerealloc(objdir, i+1);
- objdir[i] = '\0';
+ objdir[i] = '\0';
}
w = t->w;
@@ -477,9 +477,9 @@ includename(Text *t, Rune *r, int n)
Runestr
dirname(Text *t, Rune *r, int n)
{
- Rune *b, c;
- uint m, nt;
- int slash;
+ Rune *b;
+ uint nt;
+ int slash, i;
Runestr tmp;
b = nil;
@@ -490,15 +490,13 @@ dirname(Text *t, Rune *r, int n)
goto Rescue;
if(n>=1 && r[0]=='/')
goto Rescue;
- b = runemalloc(nt+n+1);
- bufread(&t->w->tag.file->b, 0, b, nt);
+ b = parsetag(t->w, n, &i);
slash = -1;
- for(m=0; m= 0; i--){
+ if(b[i] == '/'){
+ slash = i;
break;
+ }
}
if(slash < 0)
goto Rescue;
@@ -514,6 +512,19 @@ dirname(Text *t, Rune *r, int n)
return tmp;
}
+static int
+texthas(Text *t, uint q0, Rune *r)
+{
+ int i;
+
+ if((int)q0 < 0)
+ return FALSE;
+ for(i=0; r[i]; i++)
+ if(q0+i >= t->file->b.nc || textreadc(t, q0+i) != r[i])
+ return FALSE;
+ return TRUE;
+}
+
int
expandfile(Text *t, uint q0, uint q1, Expand *e)
{
@@ -522,12 +533,14 @@ expandfile(Text *t, uint q0, uint q1, Expand *e)
Rune *r, c;
Window *w;
Runestr rs;
+ Rune Lhttpcss[] = {'h', 't', 't', 'p', ':', '/', '/', 0};
+ Rune Lhttpscss[] = {'h', 't', 't', 'p', 's', ':', '/', '/', 0};
amax = q1;
if(q1 == q0){
colon = -1;
while(q1file->b.nc && isfilec(c=textreadc(t, q1))){
- if(c == ':'){
+ if(c == ':' && !texthas(t, q1-4, Lhttpcss) && !texthas(t, q1-5, Lhttpscss)){
colon = q1;
break;
}
@@ -535,7 +548,7 @@ expandfile(Text *t, uint q0, uint q1, Expand *e)
}
while(q0>0 && (isfilec(c=textreadc(t, q0-1)) || isaddrc(c) || isregexc(c))){
q0--;
- if(colon<0 && c==':')
+ if(colon<0 && c==':' && !texthas(t, q0-4, Lhttpcss) && !texthas(t, q0-5, Lhttpscss))
colon = q0;
}
/*
@@ -565,8 +578,23 @@ expandfile(Text *t, uint q0, uint q1, Expand *e)
if(n == 0)
return FALSE;
/* see if it's a file name */
- r = runemalloc(n);
+ r = runemalloc(n+1);
bufread(&t->file->b, q0, r, n);
+ r[n] = 0;
+ /* is it a URL? look for http:// and https:// prefix */
+ if(runestrncmp(r, Lhttpcss, 7) == 0 || runestrncmp(r, Lhttpscss, 8) == 0){
+ // Avoid capturing end-of-sentence punctuation.
+ if(r[n-1] == '.') {
+ e->q1--;
+ n--;
+ }
+ e->name = r;
+ e->nname = n;
+ e->u.at = t;
+ e->a0 = e->q1;
+ e->a1 = e->q1;
+ return TRUE;
+ }
/* first, does it have bad chars? */
nname = -1;
for(i=0; i, and turn that into an include
@@ -728,7 +756,7 @@ openfile(Text *t, Expand *e)
/*
* Unrooted path in new window.
* This can happen if we type a pwd-relative path
- * in the topmost tag or the column tags.
+ * in the topmost tag or the column tags.
* Most of the time plumber takes care of these,
* but plumber might not be running or might not
* be configured to accept plumbed directories.
diff --git a/src/cmd/acme/mail/dat.h b/src/cmd/acme/mail/dat.h
index a7ac6a0bb..66bb3a5d4 100644
--- a/src/cmd/acme/mail/dat.h
+++ b/src/cmd/acme/mail/dat.h
@@ -178,4 +178,3 @@ extern int shortmenu;
extern CFsys *mailfs;
extern CFsys *acmefs;
-
diff --git a/src/cmd/acme/mail/html.c b/src/cmd/acme/mail/html.c
index e3a956b06..e193fc4d4 100644
--- a/src/cmd/acme/mail/html.c
+++ b/src/cmd/acme/mail/html.c
@@ -67,7 +67,7 @@ char*
readbody(char *type, char *dir, int *np)
{
char *body;
-
+
body = readfile(dir, "body", np);
if(body != nil && strcmp(type, "text/html") == 0)
return formathtml(body, np);
diff --git a/src/cmd/acme/mail/mail.c b/src/cmd/acme/mail/mail.c
index d79721f80..e1047bb8b 100644
--- a/src/cmd/acme/mail/mail.c
+++ b/src/cmd/acme/mail/mail.c
@@ -558,16 +558,16 @@ mainctl(void *v)
Unknown:
print("unknown message %c%c\n", e->c1, e->c2);
break;
-
+
case 'E': /* write to body; can't affect us */
break;
-
+
case 'F': /* generated by our actions; ignore */
break;
-
+
case 'K': /* type away; we don't care */
break;
-
+
case 'M':
switch(e->c2){
case 'x':
@@ -597,7 +597,7 @@ mainctl(void *v)
if(na)
free(s);
break;
-
+
case 'l':
case 'L':
buf = nil;
@@ -628,17 +628,16 @@ mainctl(void *v)
winwriteevent(w, e);
free(buf);
break;
-
+
case 'I': /* modify away; we don't care */
case 'D':
case 'd':
case 'i':
break;
-
+
default:
goto Unknown;
}
}
}
}
-
diff --git a/src/cmd/acme/mail/mesg.c b/src/cmd/acme/mail/mesg.c
index 9bfe10e15..739ce10a7 100644
--- a/src/cmd/acme/mail/mesg.c
+++ b/src/cmd/acme/mail/mesg.c
@@ -85,7 +85,7 @@ mkaddrs(char *t, char **colon)
int i, nf, inquote;
char **f, *s;
Fmt fmt;
-
+
inquote = 0;
nf = 2;
for(s=t; *s; s++){
@@ -127,7 +127,7 @@ loadinfo(Message *m, char *dir)
data = readfile(dir, "info", &n);
if(data == nil)
return 0;
-
+
p = data;
while((s = line(p, &p)) != nil && *s != 0){
t = strchr(s, ' ');
@@ -282,7 +282,7 @@ mesgadd(Message *mbox, char *dir, Dir *d, char *digest)
if (m->level != 1){
m->recursed = 1;
- readmbox(m, dir, m->name);
+ readmbox(m, dir, m->name);
}
return 1;
}
@@ -351,7 +351,7 @@ readfile(char *dir, char *name, int *np)
fsseek(fid, 0, 0);
free(d);
d = fsdirfstat(fid);
- }
+ }
free(file);
len = 0;
if(d != nil)
@@ -400,13 +400,13 @@ info(Message *m, int ind, int ogf)
i = estrdup(s);
return i;
- }
+ }
i = estrdup("");
i = eappend(i, "\t", p);
i = egrow(i, "\t", stripdate(m->date));
if(ind == 0){
- if(strcmp(m->type, "text")!=0 && strncmp(m->type, "text/", 5)!=0 &&
+ if(strcmp(m->type, "text")!=0 && strncmp(m->type, "text/", 5)!=0 &&
strncmp(m->type, "multipart/", 10)!=0)
i = egrow(i, "\t(", estrstrdup(m->type, ")"));
}else if(strncmp(m->type, "multipart/", 10) != 0)
@@ -647,7 +647,7 @@ mesgsave(Message *m, char *s, int save)
}
return 1;
}
-
+
t = estrstrdup(mbox.name, m->name);
raw = readfile(t, "raw", &n);
unixheader = readfile(t, "unixheader", &k);
@@ -1160,7 +1160,7 @@ tokenizec(char *str, char **args, int max, char *splitc)
if(max <= 0)
return 0;
-
+
/* if(strchr(str, ',') || strchr(str, '"') || strchr(str, '<') || strchr(str, '(')) */
/* splitc = ","; */
for(na=0; *str != '\0';str++){
diff --git a/src/cmd/acme/mail/reply.c b/src/cmd/acme/mail/reply.c
index 5dda0edc3..f28cbef10 100644
--- a/src/cmd/acme/mail/reply.c
+++ b/src/cmd/acme/mail/reply.c
@@ -78,7 +78,7 @@ mkreply(Message *m, char *label, char *to, Plumbattr *attr, char *quotetext)
Plumbattr *a;
quotereply = (label[0] == 'Q');
-
+
if(quotereply && m && m->replywinid > 0){
snprint(buf, sizeof buf, "%d/body", m->replywinid);
if((fd = fsopen(acmefs, buf, OWRITE)) != nil){
@@ -88,7 +88,7 @@ mkreply(Message *m, char *label, char *to, Plumbattr *attr, char *quotetext)
return;
}
}
-
+
r = emalloc(sizeof(Message));
r->isreply = 1;
if(m != nil)
@@ -212,7 +212,7 @@ execproc(void *v)
q[0] = e->q[0];
q[1] = e->q[1];
prog = e->prog; /* known not to be malloc'ed */
-
+
fd[0] = dup(p[0], -1);
if(q[0])
fd[1] = dup(q[1], -1);
@@ -224,7 +224,7 @@ execproc(void *v)
free(e->argv);
chanfree(e->sync);
free(e);
-
+
threadexec(nil, fd, prog, argv);
close(fd[0]);
close(fd[1]);
diff --git a/src/cmd/acme/mail/util.c b/src/cmd/acme/mail/util.c
index 888e7e72c..8ac9f9467 100644
--- a/src/cmd/acme/mail/util.c
+++ b/src/cmd/acme/mail/util.c
@@ -104,4 +104,3 @@ ctlprint(CFid *fd, char *fmt, ...)
if(n <= 0)
error("control file write error: %r");
}
-
diff --git a/src/cmd/acme/mail/win.c b/src/cmd/acme/mail/win.c
index 84c9cee0c..1cf776dda 100644
--- a/src/cmd/acme/mail/win.c
+++ b/src/cmd/acme/mail/win.c
@@ -196,7 +196,7 @@ wingeter(Window *w, char *buf, int *nb)
while(!fullrune(buf, n))
buf[n++] = wingetec(w);
chartorune(&r, buf);
- }
+ }
*nb = n;
return r;
}
diff --git a/src/cmd/acme/regx.c b/src/cmd/acme/regx.c
index 56ea900c6..ec5745631 100644
--- a/src/cmd/acme/regx.c
+++ b/src/cmd/acme/regx.c
@@ -15,6 +15,9 @@
Rangeset sel;
Rune *lastregexp;
+#undef class
+#define class regxclass /* some systems declare "class" in system headers */
+
/*
* Machine Information
*/
diff --git a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c
index 2d6cbccaa..7a64fabf9 100644
--- a/src/cmd/acme/rows.c
+++ b/src/cmd/acme/rows.c
@@ -148,7 +148,7 @@ rowdragcol(Row *row, Column *c, int _0)
USED(_0);
clearmouse();
- setcursor(mousectl, &boxcursor);
+ setcursor2(mousectl, &boxcursor, &boxcursor2);
b = mouse->buttons;
op = mouse->xy;
while(mouse->buttons == b)
@@ -316,7 +316,7 @@ rowclean(Row *row)
void
rowdump(Row *row, char *file)
{
- int i, j, fd, m, n, dumped;
+ int i, j, fd, m, n, start, dumped;
uint q0, q1;
Biobuf *b;
char *buf, *a, *fontname;
@@ -434,9 +434,17 @@ rowdump(Row *row, char *file)
m = min(RBUFSIZE, w->tag.file->b.nc);
bufread(&w->tag.file->b, 0, r, m);
n = 0;
- while(nfile->b.nc;
@@ -613,6 +621,7 @@ rowload(Row *row, char *file, int initing)
}
textdelete(&row->col[i]->tag, 0, row->col[i]->tag.file->b.nc, TRUE);
textinsert(&row->col[i]->tag, 0, r+n+1, nr-(n+1), TRUE);
+ free(r);
break;
case 'w':
l[Blinelen(b)-1] = 0;
@@ -626,6 +635,7 @@ rowload(Row *row, char *file, int initing)
}
textdelete(&row->tag, 0, row->tag.file->b.nc, TRUE);
textinsert(&row->tag, 0, r, nr, TRUE);
+ free(r);
break;
default:
done = 1;
@@ -717,6 +727,10 @@ rowload(Row *row, char *file, int initing)
if(l == nil)
goto Rescue2;
l[Blinelen(b)-1] = 0;
+ /* convert 0xff in multiline tag back to \n */
+ for(i = 0; l[i] != 0; i++)
+ if((uchar)l[i] == 0xff)
+ l[i] = '\n';
r = bytetorune(l+5*12, &nr);
ns = -1;
for(n=0; niq1)
t->iq1 += n;
@@ -549,7 +549,7 @@ textbswidth(Text *t, Rune c)
if(r == '\n'){ /* eat at most one more character */
if(q == t->q0) /* eat the newline */
--q;
- break;
+ break;
}
if(c == 0x17){
eq = isalnum(r);
@@ -771,7 +771,7 @@ texttype(Text *t, Rune r)
case Kcmd+'Z': /* %-shift-Z: redo */
typecommit(t);
undo(t, nil, nil, FALSE, 0, nil, 0);
- return;
+ return;
Tagdown:
/* expand tag to show all text */
@@ -780,7 +780,7 @@ texttype(Text *t, Rune r)
winresize(t->w, t->w->r, FALSE, TRUE);
}
return;
-
+
Tagup:
/* shrink tag to single line */
if(t->w->tagexpand){
@@ -1192,7 +1192,7 @@ void
textsetselect(Text *t, uint q0, uint q1)
{
int p0, p1, ticked;
-
+
/* t->fr.p0 and t->fr.p1 are always right; t->q0 and t->q1 may be off */
t->q0 = q0;
t->q1 = q1;
@@ -1345,7 +1345,7 @@ textselect23(Text *t, uint *q0, uint *q1, Image *high, int mask)
{
uint p0, p1;
int buts;
-
+
p0 = xselect(&t->fr, mousectl, high, &p1);
buts = mousectl->m.buttons;
if((buts & mask) == 0){
@@ -1412,7 +1412,7 @@ textdoubleclick(Text *t, uint *q0, uint *q1)
if(textclickhtmlmatch(t, q0, q1))
return;
-
+
for(i=0; left[i]!=nil; i++){
q = *q0;
l = left[i];
@@ -1444,7 +1444,7 @@ textdoubleclick(Text *t, uint *q0, uint *q1)
return;
}
}
-
+
/* try filling out word to right */
while(*q1file->b.nc && isalnum(textreadc(t, *q1)))
(*q1)++;
@@ -1518,7 +1518,7 @@ static int
ishtmlend(Text *t, uint q, uint *q0)
{
int c, c1, c2;
-
+
if(q < 2)
return 0;
if(textreadc(t, --q) != '>')
@@ -1546,7 +1546,7 @@ textclickhtmlmatch(Text *t, uint *q0, uint *q1)
{
int depth, n;
uint q, nq;
-
+
q = *q0;
// after opening tag? scan forward for closing tag
if(ishtmlend(t, q, nil) == 1) {
@@ -1583,7 +1583,7 @@ textclickhtmlmatch(Text *t, uint *q0, uint *q1)
q--;
}
}
-
+
return 0;
}
diff --git a/src/cmd/acme/util.c b/src/cmd/acme/util.c
index d694634f2..c153f8c18 100644
--- a/src/cmd/acme/util.c
+++ b/src/cmd/acme/util.c
@@ -132,7 +132,7 @@ errorwin(Mntdir *md, int owner)
}
/*
- * Incoming window should be locked.
+ * Incoming window should be locked.
* It will be unlocked and returned window
* will be locked in its place.
*/
@@ -189,7 +189,7 @@ void
addwarningtext(Mntdir *md, Rune *r, int nr)
{
Warning *warn;
-
+
for(warn = warnings; warn; warn=warn->next){
if(warn->md == md){
bufinsert(&warn->buf, warn->buf.nc, r, nr);
@@ -276,6 +276,8 @@ runeeq(Rune *s1, uint n1, Rune *s2, uint n2)
{
if(n1 != n2)
return FALSE;
+ if(n1 == 0)
+ return TRUE;
return memcmp(s1, s2, n1*sizeof(Rune)) == 0;
}
diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c
index 19b52f5c1..98c97368c 100644
--- a/src/cmd/acme/wind.c
+++ b/src/cmd/acme/wind.c
@@ -97,7 +97,7 @@ windrawbutton(Window *w)
{
Image *b;
Rectangle br;
-
+
b = button;
if(!w->isdir && !w->isscratch && (w->body.file->mod || w->body.ncache))
b = modbutton;
@@ -110,25 +110,22 @@ windrawbutton(Window *w)
int
delrunepos(Window *w)
{
- int n;
- Rune rune;
-
- for(n=0; ntag.file->b.nc; n++) {
- bufread(&w->tag.file->b, n, &rune, 1);
- if(rune == ' ')
- break;
- }
- n += 2;
- if(n >= w->tag.file->b.nc)
+ Rune *r;
+ int i;
+
+ r = parsetag(w, 0, &i);
+ free(r);
+ i += 2;
+ if(i >= w->tag.file->b.nc)
return -1;
- return n;
+ return i;
}
void
movetodel(Window *w)
{
int n;
-
+
n = delrunepos(w);
if(n < 0)
return;
@@ -153,7 +150,7 @@ wintaglines(Window *w, Rectangle r)
textresize(&w->tag, r, TRUE);
w->tag.fr.noredraw = 0;
w->tagsafe = FALSE;
-
+
if(!w->tagexpand) {
/* use just as many lines as needed to show the Del */
n = delrunepos(w);
@@ -162,7 +159,7 @@ wintaglines(Window *w, Rectangle r)
p = subpt(frptofchar(&w->tag.fr, n), w->tag.fr.r.min);
return 1 + p.y / w->tag.fr.font->height;
}
-
+
/* can't use more than we have */
if(w->tag.fr.nlines >= w->tag.fr.maxlines)
return w->tag.fr.maxlines;
@@ -224,7 +221,7 @@ winresize(Window *w, Rectangle r, int safe, int keepextra)
moveto(mousectl, p);
}
}
-
+
/* If needed, resize & redraw body. */
r1 = r;
r1.min.y = y;
@@ -293,7 +290,7 @@ winunlock(Window *w)
void
winmousebut(Window *w)
{
- moveto(mousectl, addpt(w->tag.scrollr.min,
+ moveto(mousectl, addpt(w->tag.scrollr.min,
divpt(Pt(Dx(w->tag.scrollr), font->height), 2)));
}
@@ -419,11 +416,7 @@ wincleartag(Window *w)
/* w must be committed */
n = w->tag.file->b.nc;
- r = runemalloc(n);
- bufread(&w->tag.file->b, 0, r, n);
- for(i=0; itag, w->tag.q0, w->tag.q1);
}
+Rune*
+parsetag(Window *w, int extra, int *len)
+{
+ static Rune Ldelsnarf[] = { ' ', 'D', 'e', 'l', ' ', 'S', 'n', 'a', 'r', 'f', 0 };
+ static Rune Lspacepipe[] = { ' ', '|', 0 };
+ static Rune Ltabpipe[] = { '\t', '|', 0 };
+ int i;
+ Rune *r, *p, *pipe;
+
+ r = runemalloc(w->tag.file->b.nc+extra+1);
+ bufread(&w->tag.file->b, 0, r, w->tag.file->b.nc);
+ r[w->tag.file->b.nc] = '\0';
+
+ /*
+ * " |" or "\t|" ends left half of tag
+ * If we find " Del Snarf" in the left half of the tag
+ * (before the pipe), that ends the file name.
+ */
+ pipe = runestrstr(r, Lspacepipe);
+ if((p = runestrstr(r, Ltabpipe)) != nil && (pipe == nil || p < pipe))
+ pipe = p;
+ if((p = runestrstr(r, Ldelsnarf)) != nil && (pipe == nil || p < pipe))
+ i = p - r;
+ else {
+ for(i=0; itag.file->b.nc; i++)
+ if(r[i]==' ' || r[i]=='\t')
+ break;
+ }
+ *len = i;
+ return r;
+}
+
void
winsettag1(Window *w)
{
@@ -458,12 +483,7 @@ winsettag1(Window *w)
/* there are races that get us here with stuff in the tag cache, so we take extra care to sync it */
if(w->tag.ncache!=0 || w->tag.file->mod)
wincommit(w, &w->tag); /* check file name; also guarantees we can modify tag contents */
- old = runemalloc(w->tag.file->b.nc+1);
- bufread(&w->tag.file->b, 0, old, w->tag.file->b.nc);
- old[w->tag.file->b.nc] = '\0';
- for(i=0; itag.file->b.nc; i++)
- if(old[i]==' ' || old[i]=='\t')
- break;
+ old = parsetag(w, 0, &i);
if(runeeq(old, i, w->body.file->name, w->body.file->nname) == FALSE){
textdelete(&w->tag, 0, i, TRUE);
textinsert(&w->tag, 0, w->body.file->name, w->body.file->nname, TRUE);
@@ -476,7 +496,8 @@ winsettag1(Window *w)
/* compute the text for the whole tag, replacing current only if it differs */
new = runemalloc(w->body.file->nname+100);
i = 0;
- runemove(new+i, w->body.file->name, w->body.file->nname);
+ if(w->body.file->nname != 0)
+ runemove(new, w->body.file->name, w->body.file->nname);
i += w->body.file->nname;
runemove(new+i, Ldelsnarf, 10);
i += 10;
@@ -583,11 +604,7 @@ wincommit(Window *w, Text *t)
textcommit(f->text[i], FALSE); /* no-op for t */
if(t->what == Body)
return;
- r = runemalloc(w->tag.file->b.nc);
- bufread(&w->tag.file->b, 0, r, w->tag.file->b.nc);
- for(i=0; itag.file->b.nc; i++)
- if(r[i]==' ' || r[i]=='\t')
- break;
+ r = parsetag(w, 0, &i);
if(runeeq(r, i, w->body.file->name, w->body.file->nname) == FALSE){
seq++;
filemark(w->body.file);
@@ -672,8 +689,8 @@ winctlprint(Window *w, char *buf, int fonts)
sprint(buf, "%11d %11d %11d %11d %11d ", w->id, w->tag.file->b.nc,
w->body.file->b.nc, w->isdir, w->dirty);
if(fonts)
- return smprint("%s%11d %q %11d ", buf, Dx(w->body.fr.r),
- w->body.reffont->f->name, w->body.fr.maxtab);
+ return smprint("%s%11d %q %11d %11d %11d ", buf, Dx(w->body.fr.r),
+ w->body.reffont->f->name, w->body.fr.maxtab, seqof(w, 1) != 0, seqof(w, 0) != 0);
return buf;
}
diff --git a/src/cmd/acme/xfid.c b/src/cmd/acme/xfid.c
index 5aa4a1804..e7d9f4cb7 100644
--- a/src/cmd/acme/xfid.c
+++ b/src/cmd/acme/xfid.c
@@ -701,6 +701,24 @@ xfidctlwrite(Xfid *x, Window *w)
winsetname(w, r, nr);
m += (q+1) - pp;
}else
+ if(strncmp(p, "font ", 5) == 0){ /* execute font command */
+ pp = p+5;
+ m = 5;
+ q = memchr(pp, '\n', e-pp);
+ if(q==nil || q==pp){
+ err = Ebadctl;
+ break;
+ }
+ *q = 0;
+ nulls = FALSE;
+ cvttorunes(pp, q-pp, r, &nb, &nr, &nulls);
+ if(nulls){
+ err = "nulls in font string";
+ break;
+ }
+ fontx(&w->body, nil, nil, FALSE, XXX, r, nr);
+ m += (q+1) - pp;
+ }else
if(strncmp(p, "dump ", 5) == 0){ /* set dump string */
pp = p+5;
m = 5;
@@ -790,10 +808,12 @@ xfidctlwrite(Xfid *x, Window *w)
}else
if(strncmp(p, "nomenu", 6) == 0){ /* turn off automatic menu */
w->filemenu = FALSE;
+ settag = TRUE;
m = 6;
}else
if(strncmp(p, "menu", 4) == 0){ /* enable automatic menu */
w->filemenu = TRUE;
+ settag = TRUE;
m = 4;
}else
if(strncmp(p, "cleartag", 8) == 0){ /* wipe tag right of bar */
diff --git a/src/cmd/astro/cosadd.c b/src/cmd/astro/cosadd.c
index 637ad206b..8ce3748bd 100644
--- a/src/cmd/astro/cosadd.c
+++ b/src/cmd/astro/cosadd.c
@@ -17,7 +17,7 @@ cosadd(int n, ...)
int i;
double sum, a1, a2;
va_list arg;
-
+
sum = 0;
cp = cacp;
va_start(arg, n);
diff --git a/src/cmd/auth/dsa2pub.c b/src/cmd/auth/dsa2pub.c
index d5f26bfc7..684275277 100644
--- a/src/cmd/auth/dsa2pub.c
+++ b/src/cmd/auth/dsa2pub.c
@@ -35,7 +35,7 @@ main(int argc, char **argv)
sysfatal("%r");
s = smprint("key %A p=%lB q=%lB alpha=%lB key=%lB\n",
- a,
+ a,
key->pub.p, key->pub.q, key->pub.alpha, key->pub.key);
if(s == nil)
sysfatal("smprint: %r");
diff --git a/src/cmd/auth/dsa2ssh.c b/src/cmd/auth/dsa2ssh.c
index 489f2d211..26f9ff6d0 100644
--- a/src/cmd/auth/dsa2ssh.c
+++ b/src/cmd/auth/dsa2ssh.c
@@ -18,7 +18,7 @@ main(int argc, char **argv)
DSApriv *k;
char *comment;
uchar buf[8192], *p;
-
+
fmtinstall('B', mpfmt);
fmtinstall('[', encodefmt);
comment = "";
diff --git a/src/cmd/auth/dsagen.c b/src/cmd/auth/dsagen.c
index cb618edee..d938cf5dd 100644
--- a/src/cmd/auth/dsagen.c
+++ b/src/cmd/auth/dsagen.c
@@ -43,6 +43,6 @@ main(int argc, char **argv)
if(write(1, s, strlen(s)) != strlen(s))
sysfatal("write: %r");
-
+
exits(nil);
}
diff --git a/src/cmd/auth/dsasign.c b/src/cmd/auth/dsasign.c
index 913385f9a..594e84e28 100644
--- a/src/cmd/auth/dsasign.c
+++ b/src/cmd/auth/dsasign.c
@@ -30,10 +30,10 @@ threadmain(int argc, char **argv)
uchar digest[SHA1dlen];
AuthRpc *rpc;
Fmt fmt;
-
+
fmtinstall('[', encodefmt);
fmtinstall('H', encodefmt);
-
+
verify = 0;
id = "";
ARGBEGIN{
@@ -46,7 +46,7 @@ threadmain(int argc, char **argv)
default:
usage();
}ARGEND
-
+
if(argc != 1)
usage();
key = argv[0];
@@ -68,7 +68,7 @@ threadmain(int argc, char **argv)
auth_freerpc(rpc);
threadexits("rpc");
}
-
+
print("+%s\n", id);
Binit(&b, 0, OREAD);
@@ -96,7 +96,7 @@ keytomp(Attr *a, char *name)
{
char *p;
mpint *m;
-
+
p = _strfindattr(a, name);
if(p == nil)
sysfatal("missing key attribute %s", name);
@@ -117,7 +117,7 @@ doVerify(void)
Attr *a;
DSAsig dsig;
DSApub dkey;
-
+
a = _parseattr(key);
if(a == nil)
sysfatal("invalid key");
@@ -159,7 +159,7 @@ doVerify(void)
if(dsaverify(&dkey, &dsig, betomp(digest, sizeof digest, nil)) < 0)
sysfatal("signature failed to verify: %r");
-
+
write(1, text, strlen(text));
threadexitsall(0);
}
@@ -169,7 +169,7 @@ getline(int *np)
{
char *p;
int n;
-
+
if((p = Brdline(&b, '\n')) == nil)
return nil;
n = Blinelen(&b);
diff --git a/src/cmd/auth/factotum/apop.c b/src/cmd/auth/factotum/apop.c
index 992cc0ad1..d3d8c95ac 100644
--- a/src/cmd/auth/factotum/apop.c
+++ b/src/cmd/auth/factotum/apop.c
@@ -10,7 +10,7 @@
* S -> C: ok
*
* Note that this is the protocol between factotum and the local
- * program, not between the two factotums. The information
+ * program, not between the two factotums. The information
* exchanged here is wrapped in the APOP protocol by the local
* programs.
*
@@ -42,7 +42,7 @@ apopclient(Conv *c)
Attr *attr;
DigestState *ds;
Key *k;
-
+
chal = nil;
k = nil;
res = nil;
@@ -328,7 +328,7 @@ apopresp(ServerState *s, char *user, char *resp)
}
static Role
-apoproles[] =
+apoproles[] =
{
"client", apopclient,
"server", apopserver,
@@ -350,4 +350,3 @@ Proto cram = {
apopcheck,
nil
};
-
diff --git a/src/cmd/auth/factotum/attr.c b/src/cmd/auth/factotum/attr.c
index 1c037a536..25a461599 100644
--- a/src/cmd/auth/factotum/attr.c
+++ b/src/cmd/auth/factotum/attr.c
@@ -53,7 +53,7 @@ addattrs(Attr *a, Attr *b)
break;
}
}
- return a;
+ return a;
}
void
@@ -201,7 +201,7 @@ matchattr(Attr *pat, Attr *a0, Attr *a1)
break;
}
}
- return 1;
+ return 1;
}
Attr*
diff --git a/src/cmd/auth/factotum/chap.c b/src/cmd/auth/factotum/chap.c
index fa44db96b..d4fee3c4c 100644
--- a/src/cmd/auth/factotum/chap.c
+++ b/src/cmd/auth/factotum/chap.c
@@ -1,6 +1,6 @@
/*
* CHAP, MSCHAP
- *
+ *
* The client does not authenticate the server, hence no CAI
*
* Protocol:
@@ -51,7 +51,7 @@ nthash(uchar hash[MShashlen], char *passwd)
{
uchar buf[512];
int i;
-
+
for(i=0; *passwd && itag, a);
flog("needkey %A", a);
- return nbrecvul(c->keywait);
+
+ // Note: This code used to "return nbrecvul(c->keywait)."
+ // In Jan 2020 we changed nbrecvul to match Plan 9 and
+ // the man page and return 0 on "no data available" instead
+ // of -1. This new code with an explicit nbrecv preserves the
+ // code's old semantics, distinguishing a sent 0 from "no data".
+ // That said, this code seems to return -1 unconditionally:
+ // the c->keywait channel is unbuffered, and the only sending
+ // to it is done with an nbsendul, which won't block waiting for
+ // a receiver. So there is no sender for nbrecv to find here.
+ if(nbrecv(c->keywait, &u) < 0)
+ return -1;
+ return u;
}
int
badkey(Conv *c, Key *k, char *msg, Attr *a)
{
+ ulong u;
+
if(c == nil || *needkeyinuse == 0)
return -1;
@@ -146,5 +162,17 @@ badkey(Conv *c, Key *k, char *msg, Attr *a)
c->tag, k->attr, k->privattr, msg, a);
flog("badkey %A / %N / %s / %A",
k->attr, k->privattr, msg, a);
- return nbrecvul(c->keywait);
+
+ // Note: This code used to "return nbrecvul(c->keywait)."
+ // In Jan 2020 we changed nbrecvul to match Plan 9 and
+ // the man page and return 0 on "no data available" instead
+ // of -1. This new code with an explicit nbrecv preserves the
+ // code's old semantics, distinguishing a sent 0 from "no data".
+ // That said, this code seems to return -1 unconditionally:
+ // the c->keywait channel is unbuffered, and the only sending
+ // to it is done with an nbsendul, which won't block waiting for
+ // a receiver. So there is no sender for nbrecv to find here.
+ if(nbrecv(c->keywait, &u) < 0)
+ return -1;
+ return u;
}
diff --git a/src/cmd/auth/factotum/conv.c b/src/cmd/auth/factotum/conv.c
index 3a8cf590d..090a5ad3c 100644
--- a/src/cmd/auth/factotum/conv.c
+++ b/src/cmd/auth/factotum/conv.c
@@ -268,4 +268,3 @@ convbadkey(Conv *c, Key *k, char *msg, Attr *a)
return -1;
return 0;
}
-
diff --git a/src/cmd/auth/factotum/cpu.c b/src/cmd/auth/factotum/cpu.c
index 46399049e..64c4c9806 100644
--- a/src/cmd/auth/factotum/cpu.c
+++ b/src/cmd/auth/factotum/cpu.c
@@ -168,7 +168,7 @@ main(int argc, char **argv)
/* start up a process to pass along notes */
lclnoteproc(data);
- /*
+ /*
* Wait for the other end to execute and start our file service
* of /mnt/term
*/
@@ -246,7 +246,7 @@ old9p(int fd)
close(fd);
close(p[0]);
}
- return p[1];
+ return p[1];
}
/* Invoked with stdin, stdout and stderr connected to the network connection */
@@ -392,7 +392,7 @@ readstr(int fd, char *str, int len)
while(len) {
n = read(fd, str, 1);
- if(n < 0)
+ if(n < 0)
return -1;
if(*str == '\0')
return 0;
@@ -659,7 +659,7 @@ rmtnoteproc(void)
syslog(0, "cpu", "cpu -R: can't open %s", rmtnotefile);
_exits(0);
}
-
+
for(;;){
n = read(fd, buf, sizeof(buf)-1);
if(n <= 0){
diff --git a/src/cmd/auth/factotum/dat.h b/src/cmd/auth/factotum/dat.h
index 49377f401..db4a3b1e0 100644
--- a/src/cmd/auth/factotum/dat.h
+++ b/src/cmd/auth/factotum/dat.h
@@ -57,7 +57,7 @@ struct Conv
Req *req; /* 9P call to read response */
Channel *keywait; /* wait here for key confirmation */
-
+
};
struct Key
diff --git a/src/cmd/auth/factotum/dsa.c b/src/cmd/auth/factotum/dsa.c
index ced10355f..aa67881eb 100644
--- a/src/cmd/auth/factotum/dsa.c
+++ b/src/cmd/auth/factotum/dsa.c
@@ -3,7 +3,7 @@
/*
* DSA signing and verification
- *
+ *
* Sign:
* start p=xxx q=xxx alpha=xxx key=xxx
* write msg
@@ -14,10 +14,10 @@
* write msg
* write signature(msg)
* read ok or fail
- *
+ *
* all numbers are hexadecimal bigints parsable with strtomp.
*/
-
+
static int
xdsasign(Conv *c)
{
@@ -58,7 +58,7 @@ xdsasign(Conv *c)
}
/*
- * convert to canonical form (lower case)
+ * convert to canonical form (lower case)
* for use in attribute matches.
*/
static void
@@ -78,11 +78,11 @@ readdsapriv(Key *k)
priv = dsaprivalloc();
- if((a=strfindattr(k->attr, "p"))==nil
+ if((a=strfindattr(k->attr, "p"))==nil
|| (priv->pub.p=strtomp(a, nil, 16, nil))==nil)
goto Error;
strlwr(a);
- if((a=strfindattr(k->attr, "q"))==nil
+ if((a=strfindattr(k->attr, "q"))==nil
|| (priv->pub.q=strtomp(a, nil, 16, nil))==nil)
goto Error;
strlwr(a);
@@ -90,15 +90,15 @@ readdsapriv(Key *k)
werrstr("dsa: p or q not prime");
goto Error;
}
- if((a=strfindattr(k->attr, "alpha"))==nil
+ if((a=strfindattr(k->attr, "alpha"))==nil
|| (priv->pub.alpha=strtomp(a, nil, 16, nil))==nil)
goto Error;
strlwr(a);
- if((a=strfindattr(k->attr, "key"))==nil
+ if((a=strfindattr(k->attr, "key"))==nil
|| (priv->pub.key=strtomp(a, nil, 16, nil))==nil)
goto Error;
strlwr(a);
- if((a=strfindattr(k->privattr, "!secret"))==nil
+ if((a=strfindattr(k->privattr, "!secret"))==nil
|| (priv->secret=strtomp(a, nil, 16, nil))==nil)
goto Error;
strlwr(a);
@@ -113,7 +113,7 @@ static int
dsacheck(Key *k)
{
static int first = 1;
-
+
if(first){
fmtinstall('B', mpfmt);
first = 0;
@@ -134,7 +134,7 @@ dsaclose(Key *k)
}
static Role
-dsaroles[] =
+dsaroles[] =
{
"sign", xdsasign,
0
@@ -147,4 +147,3 @@ Proto dsa = {
dsacheck,
dsaclose
};
-
diff --git a/src/cmd/auth/factotum/fs.c b/src/cmd/auth/factotum/fs.c
index fd89b2c28..811bd5b04 100644
--- a/src/cmd/auth/factotum/fs.c
+++ b/src/cmd/auth/factotum/fs.c
@@ -65,7 +65,7 @@ rootdirgen(int n, Dir *dir, void *v)
if(n > 0)
return -1;
-
+
fillstat(dir, factname, QTDIR, Qfactotum, DMDIR|0555);
return 0;
}
@@ -224,7 +224,7 @@ convlist(int i, char *a, uint nn)
memmove(a, buf, n);
return n;
}
-
+
static void
fskickreply(Conv *c)
{
@@ -250,7 +250,7 @@ fskickreply(Conv *c)
respond(r, nil);
c->nreply = 0;
}
-
+
/*
* Some of the file system work happens in the fs proc, but
* fsopen, fsread, fswrite, fsdestroyfid, and fsflush happen in
@@ -305,7 +305,7 @@ fsopen(Req *r)
c->kickreply = fskickreply;
r->fid->aux = c;
}
-
+
respond(r, nil);
}
@@ -538,4 +538,3 @@ fsinit0(void)
fs.destroyfid = fssendclunk;
fs.start = fsstart;
}
-
diff --git a/src/cmd/auth/factotum/httpdigest.c b/src/cmd/auth/factotum/httpdigest.c
index 3e299bf5e..1e9d5793f 100644
--- a/src/cmd/auth/factotum/httpdigest.c
+++ b/src/cmd/auth/factotum/httpdigest.c
@@ -2,7 +2,7 @@
* HTTPDIGEST - MD5 challenge/response authentication (RFC 2617)
*
* Client protocol:
- * write challenge: nonce method uri
+ * write challenge: nonce method uri
* read response: 2*MD5dlen hex digits
*
* Server protocol:
@@ -22,10 +22,10 @@ hdclient(Conv *c)
char *realm, *passwd, *user, *f[4], *s, resp[MD5dlen*2+1];
int ret;
Key *k;
-
+
ret = -1;
s = nil;
-
+
c->state = "keylookup";
k = keyfetch(c, "%A", c->attr);
if(k == nil)
@@ -45,7 +45,7 @@ hdclient(Conv *c)
digest(user, realm, passwd, f[0], f[1], f[2], resp);
convwrite(c, resp, strlen(resp));
ret = 0;
-
+
out:
free(s);
keyclose(k);
@@ -103,7 +103,7 @@ digest(char *user, char *realm, char *passwd,
strtolower(dig);
}
-static Role hdroles[] =
+static Role hdroles[] =
{
"client", hdclient,
0
diff --git a/src/cmd/auth/factotum/key.c b/src/cmd/auth/factotum/key.c
index 9df50eb31..817df97bb 100644
--- a/src/cmd/auth/factotum/key.c
+++ b/src/cmd/auth/factotum/key.c
@@ -161,7 +161,7 @@ keyreplace(Conv *c, Key *k, char *fmt, ...)
sysfatal("out of memory");
va_end(arg);
- /* replace prompted values with prompts */
+ /* replace prompted values with prompts */
a = copyattr(k->attr);
bp = parseattr(k->proto->keyprompt);
for(b=bp; b; b=b->next){
@@ -204,7 +204,7 @@ keyevict(Conv *c, Key *k, char *fmt, ...)
sysfatal("out of memory");
va_end(arg);
- /* replace prompted values with prompts */
+ /* replace prompted values with prompts */
a = copyattr(k->attr);
bp = parseattr(k->proto->keyprompt);
for(b=bp; b; b=b->next){
diff --git a/src/cmd/auth/factotum/log.c b/src/cmd/auth/factotum/log.c
index 4d29536b0..e644028ad 100644
--- a/src/cmd/auth/factotum/log.c
+++ b/src/cmd/auth/factotum/log.c
@@ -118,4 +118,3 @@ flog(char *fmt, ...)
lbvappend(&logbuf, fmt, arg);
va_end(arg);
}
-
diff --git a/src/cmd/auth/factotum/main.c b/src/cmd/auth/factotum/main.c
index 1f603ac7a..6dfc2a400 100644
--- a/src/cmd/auth/factotum/main.c
+++ b/src/cmd/auth/factotum/main.c
@@ -20,6 +20,12 @@ usage(void)
threadexitsall("usage");
}
+int
+threadmaybackground(void)
+{
+ return 1;
+}
+
void
threadmain(int argc, char *argv[])
{
@@ -142,7 +148,7 @@ sendkey(Attr *attr)
int rv;
char buf[8192];
CFid *fid;
-
+
fid = nsopen("factotum", nil, "ctl", OWRITE);
if(fid == nil)
sysfatal("opening factotum/ctl: %r");
diff --git a/src/cmd/auth/factotum/p9any.c b/src/cmd/auth/factotum/p9any.c
index 0267a6164..079eed942 100644
--- a/src/cmd/auth/factotum/p9any.c
+++ b/src/cmd/auth/factotum/p9any.c
@@ -9,7 +9,7 @@
* C->S: proto dom NUL
* [negotiated proto continues]
*/
-
+
extern Proto p9sk1, p9sk2, p9cr;
static Proto* okproto[] =
@@ -111,7 +111,7 @@ p9anyserver(Conv *c)
}
ret = 0;
-
+
out:
free(s);
freeattr(attr);
@@ -222,7 +222,7 @@ p9anyclient(Conv *c)
/* f[i] is the chosen protocol, q the chosen domain */
attr = addattr(attr, "proto=%q dom=%q", f[i], q);
c->state = "write choice";
-
+
/* have a key: go for it */
choice = estrappend(nil, "%q %q", f[i], q);
if(convwrite(c, choice, strlen(choice)+1) < 0){
@@ -258,7 +258,7 @@ p9anyclient(Conv *c)
}
static Role
-p9anyroles[] =
+p9anyroles[] =
{
"client", p9anyclient,
"server", p9anyserver,
@@ -269,4 +269,3 @@ Proto p9any = {
"p9any",
p9anyroles
};
-
diff --git a/src/cmd/auth/factotum/p9cr.c b/src/cmd/auth/factotum/p9cr.c
index 1c3f21e19..84860d161 100644
--- a/src/cmd/auth/factotum/p9cr.c
+++ b/src/cmd/auth/factotum/p9cr.c
@@ -9,7 +9,7 @@
* S -> C: ok or bad
*
* Note that this is the protocol between factotum and the local
- * program, not between the two factotums. The information
+ * program, not between the two factotums. The information
* exchanged here is wrapped in other protocols by the local
* programs.
*/
@@ -290,6 +290,8 @@ p9crresp(ServerState *s, uchar *resp, int resplen)
Ticket t;
Ticketreq tr;
+ memset(&tr, 0, sizeof tr); // TODO: what should tr be initialized to?
+
if(xiowrite(s->asfd, resp, resplen) != resplen)
return -1;
@@ -317,7 +319,7 @@ p9crresp(ServerState *s, uchar *resp, int resplen)
static int
p9response(char *pw, uchar *chal, uchar *resp)
-{
+{
char key[DESKEYLEN];
uchar buf[8];
ulong x;
@@ -338,7 +340,7 @@ static int
vncresponse(char *pw, uchar *chal, uchar *resp)
{
DESstate des;
-
+
memmove(resp, chal, MAXCHAL);
setupDESstate(&des, 0, nil); // XXX put key in for 0
desECBencrypt(resp, MAXCHAL, &des);
diff --git a/src/cmd/auth/factotum/p9sk1.c b/src/cmd/auth/factotum/p9sk1.c
index 0a79a361b..d2d7eb895 100644
--- a/src/cmd/auth/factotum/p9sk1.c
+++ b/src/cmd/auth/factotum/p9sk1.c
@@ -93,7 +93,7 @@ p9skclient(Conv *c)
k = keyfetch(c, "%A", a);
if(k == nil)
goto out;
-
+
/* relay ticket request to auth server, get tickets */
strcpy(tr.hostid, strfindattr(k->attr, "user"));
if(speakfor)
@@ -329,7 +329,7 @@ p9sk1close(Key *k)
}
static Role
-p9sk1roles[] =
+p9sk1roles[] =
{
"client", p9skclient,
"server", p9skserver,
@@ -337,7 +337,7 @@ p9sk1roles[] =
};
static Role
-p9sk2roles[] =
+p9sk2roles[] =
{
"client", p9skclient,
"server", p9skserver,
@@ -356,4 +356,3 @@ Proto p9sk2 = {
"p9sk2",
p9sk2roles
};
-
diff --git a/src/cmd/auth/factotum/pass.c b/src/cmd/auth/factotum/pass.c
index 453045ce8..ddda95964 100644
--- a/src/cmd/auth/factotum/pass.c
+++ b/src/cmd/auth/factotum/pass.c
@@ -15,12 +15,12 @@ static int
passproto(Conv *c)
{
Key *k;
-
+
k = keyfetch(c, "%A", c->attr);
if(k == nil)
return -1;
c->state = "write";
- convprint(c, "%q %q",
+ convprint(c, "%q %q",
strfindattr(k->attr, "user"),
strfindattr(k->privattr, "!password"));
return 0;
diff --git a/src/cmd/auth/factotum/pkcs1.c b/src/cmd/auth/factotum/pkcs1.c
index f3278454c..0e116f2de 100644
--- a/src/cmd/auth/factotum/pkcs1.c
+++ b/src/cmd/auth/factotum/pkcs1.c
@@ -12,7 +12,7 @@
*
* We sign hashes of messages instead of the messages
* themselves.
- *
+ *
* The hashes are encoded in ASN.1 DER to identify
* the signature type, and then prefixed with 0x01 PAD 0x00
* where PAD is as many 0xFF bytes as desired.
@@ -138,7 +138,7 @@ mptoberjust(mpint *b, uchar *buf, uint len)
#define O3(x) \
(((x)>>14)&0x7F)|0x80, \
(((x)>>7)&0x7F)|0x80, \
- ((x)&0x7F)
+ ((x)&0x7F)
uchar oidsha1[] = { O0(1, 3), 14, 3, 2, 26 };
uchar oidmd2[] = { O0(1, 2), O2(840), O3(113549), 2, 2 };
uchar oidmd5[] = { O0(1, 2), O2(840), O3(113549), 2, 5 };
@@ -174,11 +174,11 @@ mkasn1(uchar *asn1, DigestAlg *alg, uchar *d, uint dlen)
sysfatal("bad alg in mkasn1");
return -1;
}
-
+
p = asn1;
*p++ = 0x30; /* sequence */
p++;
-
+
*p++ = 0x30; /* another sequence */
p++;
@@ -186,12 +186,12 @@ mkasn1(uchar *asn1, DigestAlg *alg, uchar *d, uint dlen)
*p++ = olen;
memmove(p, obj, olen);
p += olen;
-
+
*p++ = 0x05; /* null */
*p++ = 0;
-
+
asn1[3] = p - (asn1+4); /* end of inner sequence */
-
+
*p++ = 0x04; /* octet string */
*p++ = dlen;
memmove(p, d, dlen);
@@ -200,4 +200,3 @@ mkasn1(uchar *asn1, DigestAlg *alg, uchar *d, uint dlen)
asn1[1] = p - (asn1+2); /* end of outer sequence */
return p-asn1;
}
-
diff --git a/src/cmd/auth/factotum/rpc.c b/src/cmd/auth/factotum/rpc.c
index ad8943307..26d5fd4b8 100644
--- a/src/cmd/auth/factotum/rpc.c
+++ b/src/cmd/auth/factotum/rpc.c
@@ -32,7 +32,7 @@
* done [haveai] - authentication is done [haveai: you can get an ai with authinfo]
*/
-char *rpcname[] =
+char *rpcname[] =
{
"unknown",
"authinfo",
@@ -196,7 +196,7 @@ rpcexec(Conv *c)
rpcrespond(c, "error conversation not successful");
else{
/* make up an auth info using the attr */
- p = convAI2M((uchar*)c->reply+3, sizeof c->reply-3,
+ p = convAI2M((uchar*)c->reply+3, sizeof c->reply-3,
strfindattr(c->attr, "cuid"),
strfindattr(c->attr, "suid"),
strfindattr(c->attr, "cap"),
@@ -341,4 +341,3 @@ convAI2M(uchar *p, int n, char *cuid, char *suid, char *cap, char *hex)
werrstr("authinfo too big");
return p;
}
-
diff --git a/src/cmd/auth/factotum/rsa.c b/src/cmd/auth/factotum/rsa.c
index 95545f931..e59feaab1 100644
--- a/src/cmd/auth/factotum/rsa.c
+++ b/src/cmd/auth/factotum/rsa.c
@@ -3,7 +3,7 @@
/*
* RSA authentication.
- *
+ *
* Encrypt/Decrypt:
* start n=xxx ek=xxx
* write msg
@@ -13,7 +13,7 @@
* start n=xxx ek=xxx
* write hash(msg)
* read signature(hash(msg))
- *
+ *
* Verify:
* start n=xxx ek=xxx
* write hash(msg)
@@ -44,14 +44,14 @@ xrsadecrypt(Conv *c)
if(k == nil)
goto out;
key = k->priv;
-
+
/* make sure have private half if needed */
role = strfindattr(c->attr, "role");
if(strcmp(role, "decrypt") == 0 && !key->c2){
werrstr("missing private half of key -- cannot decrypt");
goto out;
}
-
+
/* read text */
c->state = "read";
if((n=convreadm(c, &txt)) < 0)
@@ -60,7 +60,7 @@ xrsadecrypt(Conv *c)
convprint(c, "data too short");
goto out;
}
-
+
/* encrypt/decrypt */
m = betomp((uchar*)txt, n, nil);
if(m == nil)
@@ -72,7 +72,7 @@ xrsadecrypt(Conv *c)
if(mm == nil)
goto out;
n = mptobe(mm, (uchar*)buf, sizeof buf, nil);
-
+
/* send response */
c->state = "write";
convwrite(c, buf, n);
@@ -98,7 +98,7 @@ xrsasign(Conv *c)
char *sig2;
ret = -1;
-
+
/* fetch key */
c->state = "keylookup";
k = keylookup("%A", c->attr);
@@ -112,7 +112,7 @@ xrsasign(Conv *c)
werrstr("missing private half of key -- cannot sign");
goto out;
}
-
+
/* get hash type from key */
hash = strfindattr(k->attr, "hash");
if(hash == nil)
@@ -144,7 +144,7 @@ xrsasign(Conv *c)
/* read signature */
if((n = convreadm(c, &sig2)) < 0)
goto out;
-
+
/* verify */
if(rsaverify(&key->pub, hashfn, digest, dlen, (uchar*)sig2, n) == 0)
convprint(c, "ok");
@@ -160,7 +160,7 @@ xrsasign(Conv *c)
}
/*
- * convert to canonical form (lower case)
+ * convert to canonical form (lower case)
* for use in attribute matches.
*/
static void
@@ -180,22 +180,22 @@ readrsapriv(Key *k)
priv = rsaprivalloc();
- if((a=strfindattr(k->attr, "ek"))==nil
+ if((a=strfindattr(k->attr, "ek"))==nil
|| (priv->pub.ek=strtomp(a, nil, 16, nil))==nil)
goto Error;
strlwr(a);
- if((a=strfindattr(k->attr, "n"))==nil
+ if((a=strfindattr(k->attr, "n"))==nil
|| (priv->pub.n=strtomp(a, nil, 16, nil))==nil)
goto Error;
strlwr(a);
if(k->privattr == nil) /* only public half */
return priv;
- if((a=strfindattr(k->privattr, "!p"))==nil
+ if((a=strfindattr(k->privattr, "!p"))==nil
|| (priv->p=strtomp(a, nil, 16, nil))==nil)
goto Error;
strlwr(a);
- if((a=strfindattr(k->privattr, "!q"))==nil
+ if((a=strfindattr(k->privattr, "!q"))==nil
|| (priv->q=strtomp(a, nil, 16, nil))==nil)
goto Error;
strlwr(a);
@@ -203,19 +203,19 @@ readrsapriv(Key *k)
werrstr("rsa: p or q not prime");
goto Error;
}
- if((a=strfindattr(k->privattr, "!kp"))==nil
+ if((a=strfindattr(k->privattr, "!kp"))==nil
|| (priv->kp=strtomp(a, nil, 16, nil))==nil)
goto Error;
strlwr(a);
- if((a=strfindattr(k->privattr, "!kq"))==nil
+ if((a=strfindattr(k->privattr, "!kq"))==nil
|| (priv->kq=strtomp(a, nil, 16, nil))==nil)
goto Error;
strlwr(a);
- if((a=strfindattr(k->privattr, "!c2"))==nil
+ if((a=strfindattr(k->privattr, "!c2"))==nil
|| (priv->c2=strtomp(a, nil, 16, nil))==nil)
goto Error;
strlwr(a);
- if((a=strfindattr(k->privattr, "!dk"))==nil
+ if((a=strfindattr(k->privattr, "!dk"))==nil
|| (priv->dk=strtomp(a, nil, 16, nil))==nil)
goto Error;
strlwr(a);
@@ -230,7 +230,7 @@ static int
rsacheck(Key *k)
{
static int first = 1;
-
+
if(first){
fmtinstall('B', mpfmt);
first = 0;
@@ -251,7 +251,7 @@ rsaclose(Key *k)
}
static Role
-rsaroles[] =
+rsaroles[] =
{
"sign", xrsasign,
"verify", xrsasign, /* public operation */
diff --git a/src/cmd/auth/factotum/secstore.c b/src/cmd/auth/factotum/secstore.c
index c17c3cf27..9928d3610 100644
--- a/src/cmd/auth/factotum/secstore.c
+++ b/src/cmd/auth/factotum/secstore.c
@@ -659,4 +659,3 @@ secstorefetch(void)
free(sta);
return rv;
}
-
diff --git a/src/cmd/auth/factotum/std.h b/src/cmd/auth/factotum/std.h
index 814664e0f..52c55b7c8 100644
--- a/src/cmd/auth/factotum/std.h
+++ b/src/cmd/auth/factotum/std.h
@@ -7,4 +7,3 @@
#include
#include
#include <9p.h>
-
diff --git a/src/cmd/auth/factotum/util.c b/src/cmd/auth/factotum/util.c
index accddddde..dce37dca7 100644
--- a/src/cmd/auth/factotum/util.c
+++ b/src/cmd/auth/factotum/util.c
@@ -50,5 +50,3 @@ estrappend(char *s, char *fmt, ...)
free(t);
return s;
}
-
-
diff --git a/src/cmd/auth/factotum/wep.c b/src/cmd/auth/factotum/wep.c
index 1d516db28..701018e77 100644
--- a/src/cmd/auth/factotum/wep.c
+++ b/src/cmd/auth/factotum/wep.c
@@ -11,11 +11,11 @@ wepclient(Conv *c)
char *dev, buf[128], *p, *kp;
Key *k;
int ret, fd, cfd;
-
+
fd = cfd = -1;
ret = -1;
dev = nil;
-
+
if((k = keylookup("%A !key1?", c->attr)) == nil
&& (k = keylookup("%A !key2?", c->attr)) == nil
&& (k = keylookup("%A !key3?", c->attr)) == nil){
@@ -73,7 +73,7 @@ static Role weproles[] = {
0
};
-Proto wep =
+Proto wep =
{
"wep",
weproles,
diff --git a/src/cmd/auth/factotum/xio.c b/src/cmd/auth/factotum/xio.c
index 2e6b141b0..116fccaf5 100644
--- a/src/cmd/auth/factotum/xio.c
+++ b/src/cmd/auth/factotum/xio.c
@@ -9,7 +9,7 @@ xioproc(void)
{
Ioproc *c;
int i;
-
+
for(i=0; ikp = strtomp(p, &p, 16, nil)) == nil || *p != 0){
fprint(2, "warning: bad !kp\n");
- regen = 1;
+ regen = 1;
goto regen;
}
if((p = _strfindattr(a, "!kq")) == nil){
fprint(2, "warning: no !kq\n");
- regen = 1;
+ regen = 1;
goto regen;
}
if((key->kq = strtomp(p, &p, 16, nil)) == nil || *p != 0){
fprint(2, "warning: bad !kq\n");
- regen = 1;
+ regen = 1;
goto regen;
}
if((p = _strfindattr(a, "!c2")) == nil){
fprint(2, "warning: no !c2\n");
- regen = 1;
+ regen = 1;
goto regen;
}
if((key->c2 = strtomp(p, &p, 16, nil)) == nil || *p != 0){
fprint(2, "warning: bad !c2\n");
- regen = 1;
+ regen = 1;
goto regen;
}
regen:
@@ -285,7 +285,7 @@ uchar*
putmp2(uchar *p, mpint *b)
{
int bits, n;
-
+
if(mpcmp(b, mpzero) == 0)
return put4(p, 0);
bits = mpsignif(b);
diff --git a/src/cmd/auth/rsa2pub.c b/src/cmd/auth/rsa2pub.c
index c0a208a72..e45c04915 100644
--- a/src/cmd/auth/rsa2pub.c
+++ b/src/cmd/auth/rsa2pub.c
@@ -35,7 +35,7 @@ main(int argc, char **argv)
sysfatal("%r");
s = smprint("key %A size=%d ek=%lB n=%lB\n",
- a,
+ a,
mpsignif(key->pub.n), key->pub.ek, key->pub.n);
if(s == nil)
sysfatal("smprint: %r");
diff --git a/src/cmd/auth/rsa2ssh.c b/src/cmd/auth/rsa2ssh.c
index 3de2792e3..9951106b6 100644
--- a/src/cmd/auth/rsa2ssh.c
+++ b/src/cmd/auth/rsa2ssh.c
@@ -19,7 +19,7 @@ main(int argc, char **argv)
{
RSApriv *k;
char *comment;
-
+
fmtinstall('B', mpfmt);
fmtinstall('[', encodefmt);
comment = "";
@@ -42,7 +42,7 @@ main(int argc, char **argv)
if(ssh2){
uchar buf[8192], *p;
-
+
p = buf;
p = put4(p, 7);
p = putn(p, "ssh-rsa", 7);
diff --git a/src/cmd/auth/rsafill.c b/src/cmd/auth/rsafill.c
index 08cb85998..efab877e2 100644
--- a/src/cmd/auth/rsafill.c
+++ b/src/cmd/auth/rsafill.c
@@ -35,7 +35,7 @@ main(int argc, char **argv)
sysfatal("%r");
s = smprint("key %A size=%d ek=%lB !dk=%lB n=%lB !p=%lB !q=%lB !kp=%lB !kq=%lB !c2=%lB\n",
- a,
+ a,
mpsignif(key->pub.n), key->pub.ek,
key->dk, key->pub.n, key->p, key->q,
key->kp, key->kq, key->c2);
diff --git a/src/cmd/auth/rsagen.c b/src/cmd/auth/rsagen.c
index d51560b63..2ca99d349 100644
--- a/src/cmd/auth/rsagen.c
+++ b/src/cmd/auth/rsagen.c
@@ -55,6 +55,6 @@ main(int argc, char **argv)
if(write(1, s, strlen(s)) != strlen(s))
sysfatal("write: %r");
-
+
exits(nil);
}
diff --git a/src/cmd/auth/secstore/SConn.c b/src/cmd/auth/secstore/SConn.c
index 07e92327b..9ffb3d935 100644
--- a/src/cmd/auth/secstore/SConn.c
+++ b/src/cmd/auth/secstore/SConn.c
@@ -211,4 +211,3 @@ readstr(SConn *conn, char *s)
}
return n;
}
-
diff --git a/src/cmd/auth/secstore/SConn.h b/src/cmd/auth/secstore/SConn.h
index 31765f3ec..09ddb637f 100644
--- a/src/cmd/auth/secstore/SConn.h
+++ b/src/cmd/auth/secstore/SConn.h
@@ -23,4 +23,3 @@ extern int readstr(SConn*, char*); /* call with buf of size Maxmsg+1 */
extern void *emalloc(ulong); /* dies on failure; clears memory */
extern void *erealloc(void *, ulong);
extern char *estrdup(char *);
-
diff --git a/src/cmd/auth/secstore/dirls.c b/src/cmd/auth/secstore/dirls.c
index eaae8cdc9..39542a52c 100644
--- a/src/cmd/auth/secstore/dirls.c
+++ b/src/cmd/auth/secstore/dirls.c
@@ -84,4 +84,3 @@ dirls(char *path)
free(dirbuf);
return list;
}
-
diff --git a/src/cmd/auth/secstore/pak.c b/src/cmd/auth/secstore/pak.c
index effc01d9f..1f1a09c5b 100644
--- a/src/cmd/auth/secstore/pak.c
+++ b/src/cmd/auth/secstore/pak.c
@@ -341,4 +341,3 @@ PAKserver(SConn *conn, char *S, char *mess, PW **pwp)
mpfree(H);
return rc;
}
-
diff --git a/src/cmd/auth/secstore/password.c b/src/cmd/auth/secstore/password.c
index b2a00e724..c9e63d19a 100644
--- a/src/cmd/auth/secstore/password.c
+++ b/src/cmd/auth/secstore/password.c
@@ -133,4 +133,3 @@ freePW(PW *pw)
mpfree(pw->Hi);
free(pw);
}
-
diff --git a/src/cmd/auth/secstore/secstore.c b/src/cmd/auth/secstore/secstore.c
index 571c6fae4..2b33e5d4e 100644
--- a/src/cmd/auth/secstore/secstore.c
+++ b/src/cmd/auth/secstore/secstore.c
@@ -85,7 +85,7 @@ getfile(SConn *conn, char *gf, uchar **buf, ulong *buflen, uchar *key, int nkey)
return 0;
}
- /* conn is already encrypted against wiretappers,
+ /* conn is already encrypted against wiretappers,
but gf is also encrypted against server breakin. */
if(buf == nil && (fd =create(gf, OWRITE, 0600)) < 0){
fprint(2, "can't open %s: %r\n", gf);
@@ -197,7 +197,7 @@ putfile(SConn *conn, char *pf, uchar *buf, ulong len, uchar *key, int nkey)
return -1;
}
}else{
- if((n = len - bufi) > Maxmsg-ivo)
+ if((n = len - bufi) > Maxmsg-ivo)
n = Maxmsg-ivo;
memcpy(b+ivo, buf+bufi, n);
bufi += n;
@@ -578,4 +578,3 @@ main(int argc, char **argv)
exits("");
return 0;
}
-
diff --git a/src/cmd/auth/secstore/secstore.h b/src/cmd/auth/secstore/secstore.h
index d9cb807dc..dfc07730b 100644
--- a/src/cmd/auth/secstore/secstore.h
+++ b/src/cmd/auth/secstore/secstore.h
@@ -28,4 +28,3 @@ char *PAK_Hi(char *, char *, mpint *, mpint *);
#define LOG "secstore"
extern char *SECSTORE_DIR;
-
diff --git a/src/cmd/auth/secstore/secstored.c b/src/cmd/auth/secstore/secstored.c
index 9a3c4b66b..d32ec64c1 100644
--- a/src/cmd/auth/secstore/secstored.c
+++ b/src/cmd/auth/secstore/secstored.c
@@ -24,7 +24,7 @@ usage(void)
static int
getdir(SConn *conn, char *id)
{
- char *ls, *s;
+ char *ls, *s;
uchar *msg;
int n, len;
@@ -417,4 +417,3 @@ main(int argc, char **argv)
}
}
}
-
diff --git a/src/cmd/auth/secstore/secureidcheck.c b/src/cmd/auth/secstore/secureidcheck.c
index 8ef6f6aaa..9d8e81ad6 100644
--- a/src/cmd/auth/secstore/secureidcheck.c
+++ b/src/cmd/auth/secstore/secureidcheck.c
@@ -417,7 +417,7 @@ secureidcheck(char *user, char *response)
resp = nil;
continue;
}
-
+
switch(resp->code){
case R_AccessAccept:
syslog(0, AUTHLOG, "%s accepted ruser=%s", dest, ruser);
diff --git a/src/cmd/auth/secstore/secuser.c b/src/cmd/auth/secstore/secuser.c
index 31ba184bb..8e4eae605 100644
--- a/src/cmd/auth/secstore/secuser.c
+++ b/src/cmd/auth/secstore/secuser.c
@@ -241,4 +241,3 @@ userinput(char *buf, int blen)
exits("input too large");
}
}
-
diff --git a/src/cmd/auth/ssh-agent.c b/src/cmd/auth/ssh-agent.c
index 40516a770..e944e3901 100644
--- a/src/cmd/auth/ssh-agent.c
+++ b/src/cmd/auth/ssh-agent.c
@@ -25,7 +25,7 @@ enum /* agent protocol packet types */
SSH_AGENTC_ADD_RSA_IDENTITY,
SSH_AGENTC_REMOVE_RSA_IDENTITY,
SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES,
-
+
SSH2_AGENTC_REQUEST_IDENTITIES = 11,
SSH2_AGENT_IDENTITIES_ANSWER,
SSH2_AGENTC_SIGN_REQUEST,
@@ -42,12 +42,12 @@ enum /* agent protocol packet types */
SSH_AGENTC_ADD_RSA_ID_CONSTRAINED,
SSH2_AGENTC_ADD_ID_CONSTRAINED,
SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED,
-
+
SSH_AGENT_CONSTRAIN_LIFETIME = 1,
SSH_AGENT_CONSTRAIN_CONFIRM = 2,
SSH2_AGENT_FAILURE = 30,
-
+
SSH_COM_AGENT2_FAILURE = 102,
SSH_AGENT_OLD_SIGNATURE = 0x01
};
@@ -90,6 +90,12 @@ usage(void)
threadexitsall("usage");
}
+int
+threadmaybackground(void)
+{
+ return 1;
+}
+
void
threadmain(int argc, char **argv)
{
@@ -121,12 +127,12 @@ threadmain(int argc, char **argv)
default:
usage();
}ARGEND
-
+
if(argc > 1)
usage();
if(argc == 1)
factotum = argv[0];
-
+
if(dotextlist)
listkeystext();
@@ -145,7 +151,7 @@ threadmain(int argc, char **argv)
if((afd = announce(addr, adir)) < 0)
sysfatal("announce %s: %r", addr);
-
+
print("SSH_AUTH_SOCK=%s;\n", sock);
if(export)
print("export SSH_AUTH_SOCK;\n");
@@ -178,7 +184,7 @@ agentproc(void *v)
{
Aconn *a;
int n;
-
+
a = v;
a->fd = accept(a->ctl, a->dir);
close(a->ctl);
@@ -209,7 +215,7 @@ int
get2(Msg *m)
{
uint x;
-
+
if(m->p+2 > m->ep)
return 0;
x = (m->p[0]<<8)|m->p[1];
@@ -232,7 +238,7 @@ uchar*
getn(Msg *m, uint n)
{
uchar *p;
-
+
if(m->p+n > m->ep)
return nil;
p = m->p;
@@ -261,7 +267,7 @@ getmp(Msg *m)
{
int n;
uchar *p;
-
+
n = (get2(m)+7)/8;
if((p=getn(m, n)) == nil)
return nil;
@@ -273,7 +279,7 @@ getmp2(Msg *m)
{
int n;
uchar *p;
-
+
n = get4(m);
if((p = getn(m, n)) == nil)
return nil;
@@ -301,7 +307,7 @@ getm(Msg *m, Msg *mm)
{
uint n;
uchar *p;
-
+
n = get4(m);
if((p = getn(m, n)) == nil)
return nil;
@@ -347,7 +353,7 @@ void
put4(Msg *m, uint n)
{
uchar *p;
-
+
p = ensure(m, 4);
p[0] = (n>>24)&0xFF;
p[1] = (n>>16)&0xFF;
@@ -359,7 +365,7 @@ void
put2(Msg *m, uint n)
{
uchar *p;
-
+
p = ensure(m, 2);
p[0] = (n>>8)&0xFF;
p[1] = n&0xFF;
@@ -369,7 +375,7 @@ void
put1(Msg *m, uint n)
{
uchar *p;
-
+
p = ensure(m, 1);
p[0] = n&0xFF;
}
@@ -378,7 +384,7 @@ void
putn(Msg *m, void *a, uint n)
{
uchar *p;
-
+
p = ensure(m, n);
memmove(p, a, n);
}
@@ -388,7 +394,7 @@ putmp(Msg *m, mpint *b)
{
int bits, n;
uchar *p;
-
+
bits = mpsignif(b);
put2(m, bits);
n = (bits+7)/8;
@@ -401,7 +407,7 @@ putmp2(Msg *m, mpint *b)
{
int bits, n;
uchar *p;
-
+
if(mpcmp(b, mpzero) == 0){
put4(m, 0);
return;
@@ -421,7 +427,7 @@ void
putstr(Msg *m, char *s)
{
int n;
-
+
n = strlen(s);
put4(m, n);
putn(m, s, n);
@@ -431,7 +437,7 @@ void
putm(Msg *m, Msg *mm)
{
uint n;
-
+
n = mm->p - mm->bp;
put4(m, n);
putn(m, mm->bp, n);
@@ -450,7 +456,7 @@ reply(Aconn *a, Msg *m)
{
uint n;
uchar *p;
-
+
n = (m->p - m->bp) - 4;
p = m->bp;
p[0] = (n>>24)&0xFF;
@@ -513,7 +519,7 @@ void
printattr(char **f, int nf)
{
int i;
-
+
print("#");
for(i=0; indata < 4)
return 0;
len = (a->data[0]<<24)|(a->data[1]<<16)|(a->data[2]<<8)|a->data[3];
@@ -993,7 +999,7 @@ runmsg(Aconn *a)
goto Failchal;
md5(sessid, 16, digest, s);
print("md5 %.*H %.*H => %.*H\n", 32, chalbuf, 16, sessid, MD5dlen, digest);
-
+
newreply(&m, SSH_AGENT_RSA_RESPONSE);
putn(&m, digest, 16);
reply(a, &m);
@@ -1020,22 +1026,22 @@ runmsg(Aconn *a)
mreset(&msig);
reply(a, &m);
break;
-
+
case SSH_AGENTC_ADD_RSA_IDENTITY:
/*
msg: n[4] mod[mp] pubexp[exp] privexp[mp]
p^-1 mod q[mp] p[mp] q[mp] comment[str]
*/
goto Failure;
-
+
case SSH_AGENTC_REMOVE_RSA_IDENTITY:
/*
msg: n[4] mod[mp] pubexp[mp]
*/
goto Failure;
-
+
}
-
+
a->ndata -= 4+len;
memmove(a->data, a->data+4+len, a->ndata);
return 1;
@@ -1064,4 +1070,3 @@ erealloc(void *v, int n)
}
return v;
}
-
diff --git a/src/cmd/auxstats/AIX.c b/src/cmd/auxstats/AIX.c
new file mode 100644
index 000000000..33ebdedc1
--- /dev/null
+++ b/src/cmd/auxstats/AIX.c
@@ -0,0 +1,9 @@
+#include
+#include
+#include
+#include "dat.h"
+
+void (*statfn[])(int) =
+{
+ 0
+};
diff --git a/src/cmd/auxstats/Darwin.c b/src/cmd/auxstats/Darwin.c
index b92f682ef..836de5205 100644
--- a/src/cmd/auxstats/Darwin.c
+++ b/src/cmd/auxstats/Darwin.c
@@ -79,7 +79,7 @@ void
sampleinit(void)
{
mach_timebase_info_data_t info;
-
+
if(stat_port)
return;
@@ -115,7 +115,7 @@ samplenet(void)
sample.net_obytes = 0;
sample.net_errors = 0;
sample.net_ifaces = 0;
-
+
for(ifa=ifa_list; ifa; ifa=ifa->ifa_next){
if(ifa->ifa_addr->sa_family != AF_LINK)
continue;
@@ -125,7 +125,7 @@ samplenet(void)
continue;
if(strncmp(ifa->ifa_name, "lo", 2) == 0) /* loopback */
continue;
-
+
if_data = (struct if_data*)ifa->ifa_data;
sample.net_ipackets += if_data->ifi_ipackets;
sample.net_opackets += if_data->ifi_opackets;
@@ -144,7 +144,7 @@ samplenet(void)
* all the other stat monitoring apps get set:
*
* -rwsr-xr-x 1 root wheel 83088 Mar 20 2005 /usr/bin/top
- * -rwsrwxr-x 1 root admin 54048 Mar 20 2005
+ * -rwsrwxr-x 1 root admin 54048 Mar 20 2005
* /Applications/Utilities/Activity Monitor.app/Contents/Resources/pmTool
*
* If Darwin eventually encompases more into sysctl then this
@@ -165,7 +165,7 @@ sampleevents(void)
mach_error_string(error));
return;
}
-
+
sample.p_syscalls_mach = sample.syscalls_mach;
sample.p_syscalls_unix = sample.syscalls_unix;
sample.p_csw = sample.csw;
@@ -173,7 +173,7 @@ sampleevents(void)
sample.syscalls_mach = 0;
sample.syscalls_unix = 0;
sample.csw = 0;
-
+
for(i=0; i
#include "dat.h"
-void (*statfn[])(int) =
+void (*statfn[])(int) =
{
0
};
-
diff --git a/src/cmd/auxstats/FreeBSD.c b/src/cmd/auxstats/FreeBSD.c
index 2497fe35e..2cc82879d 100644
--- a/src/cmd/auxstats/FreeBSD.c
+++ b/src/cmd/auxstats/FreeBSD.c
@@ -203,8 +203,8 @@ xsysctl(int first)
pgsize = 4096;
}
- Bprint(&bout, "mem =%lld %lld\n",
- isys("vm.stats.vm.v_active_count")*pgsize,
+ Bprint(&bout, "mem =%lld %lld\n",
+ isys("vm.stats.vm.v_active_count")*pgsize,
isys("vm.stats.vm.v_page_count")*pgsize);
Bprint(&bout, "context %lld 1000\n", isys("vm.stats.sys.v_swtch"));
Bprint(&bout, "syscall %lld 1000\n", isys("vm.stats.sys.v_syscall"));
@@ -284,4 +284,3 @@ xswap(int first)
Bprint(&bout, "swap =%lld %lld\n", s.ksw_used*(vlong)pgsize, s.ksw_total*(vlong)pgsize);
}
-
diff --git a/src/cmd/auxstats/Linux.c b/src/cmd/auxstats/Linux.c
index 09ca18f30..74491ac29 100644
--- a/src/cmd/auxstats/Linux.c
+++ b/src/cmd/auxstats/Linux.c
@@ -1,6 +1,7 @@
#include
#include
#include
+#include
#include "dat.h"
void xapm(int);
@@ -26,39 +27,25 @@ void (*statfn[])(int) =
void
xapm(int first)
{
- static int fd = -1, fdb = -1;
- int i, last = -1, curr = -1;
+ static int fd = -1;
+ int curr = -1;
if(first){
- fd = open("/proc/acpi/battery/BAT0/info", OREAD);
- fdb = open("/proc/acpi/battery/BAT0/state", OREAD);
+ fd = open("/sys/class/power_supply/BAT0/capacity", OREAD);
return;
}
- if(fd == -1 || fdb == -1)
+ if(fd == -1)
return;
readfile(fd);
- for(i=0; i
#include "dat.h"
-void (*statfn[])(int) =
+void (*statfn[])(int) =
{
0
};
-
diff --git a/src/cmd/auxstats/SunOS.c b/src/cmd/auxstats/SunOS.c
index ec9310447..33ebdedc1 100644
--- a/src/cmd/auxstats/SunOS.c
+++ b/src/cmd/auxstats/SunOS.c
@@ -3,8 +3,7 @@
#include
#include "dat.h"
-void (*statfn[])(int) =
+void (*statfn[])(int) =
{
0
};
-
diff --git a/src/cmd/auxstats/main.c b/src/cmd/auxstats/main.c
index d1c355619..a37c9723e 100644
--- a/src/cmd/auxstats/main.c
+++ b/src/cmd/auxstats/main.c
@@ -21,7 +21,8 @@ notifyf(void *v, char *msg)
if(strstr(msg, "child"))
noted(NCONT);
- postnote(PNPROC, pid, msg);
+ if(pid)
+ postnote(PNPROC, pid, msg);
exits(nil);
}
@@ -120,4 +121,3 @@ tokens(int i)
}
ntok = tokenize(line[i], tok, nelem(tok));
}
-
diff --git a/src/cmd/awk/README b/src/cmd/awk/README
deleted file mode 100644
index e3efb50d9..000000000
--- a/src/cmd/awk/README
+++ /dev/null
@@ -1,13 +0,0 @@
-This 'awk' source is directly downloaded from the Plan 9 source
-
-http://cm.bell-labs.com/sources/plan9/sys/src/cmd/awk/
-
-as such, it's copyright is held by Lucent Technologies and distributed under the
-Lucent Public License version 1.02 [http://www.opensource.org/licenses/lucent1.02.php].
-
-Modifications were made by Jeff Sickel in order to build using Plan 9 from User
-Space [https://9fans.github.io/plan9port/] to the following files:
-
- mkfile
- re.c
-
diff --git a/src/cmd/awk/awk.h b/src/cmd/awk/awk.h
index 1853381d4..913f45092 100644
--- a/src/cmd/awk/awk.h
+++ b/src/cmd/awk/awk.h
@@ -134,7 +134,7 @@ extern Node *nullnode;
#define CCOPY 6
#define CCON 5
#define CTEMP 4
-#define CNAME 3
+#define CNAME 3
#define CVAR 2
#define CFLD 1
#define CUNK 0
@@ -182,4 +182,3 @@ extern int pairstack[], paircnt;
#define freeable(p) ( ((p)->tval & (STR|DONTFREE)) == STR )
#include "proto.h"
-
diff --git a/src/cmd/awk/lex.c b/src/cmd/awk/lex.c
index 74a990305..0a051eded 100644
--- a/src/cmd/awk/lex.c
+++ b/src/cmd/awk/lex.c
@@ -140,7 +140,7 @@ int gettok(char **pbuf, int *psz) /* get next input token */
if (bp-buf >= sz)
if (!adjbuf(&buf, &sz, bp-buf+2, 100, &bp, 0))
FATAL( "out of space for number %.10s...", buf );
- if (isdigit(c) || c == 'e' || c == 'E'
+ if (isdigit(c) || c == 'e' || c == 'E'
|| c == '.' || c == '+' || c == '-')
*bp++ = c;
else {
@@ -191,7 +191,7 @@ int yylex(void)
/* should this also have STR set? */
RET(NUMBER);
}
-
+
yylval.i = c;
switch (c) {
case '\n': /* {EOL} */
@@ -220,7 +220,7 @@ int yylex(void)
case '&':
if (peek() == '&') {
input(); RET(AND);
- } else
+ } else
RET('&');
case '|':
if (peek() == '|') {
@@ -295,7 +295,7 @@ int yylex(void)
input(); yylval.i = POWEQ; RET(ASGNOP);
} else
RET(POWER);
-
+
case '$':
/* BUG: awkward, if not wrong */
c = gettok(&buf, &bufsize);
@@ -313,7 +313,7 @@ int yylex(void)
unputstr(buf);
RET(INDIRECT);
}
-
+
case '}':
if (--bracecnt < 0)
SYNTAX( "extra }" );
@@ -336,10 +336,10 @@ int yylex(void)
case '(':
parencnt++;
RET('(');
-
+
case '"':
return string(); /* BUG: should be like tran.c ? */
-
+
default:
RET(c);
}
@@ -369,7 +369,7 @@ int string(void)
c = input();
switch (c) {
case '"': *bp++ = '"'; break;
- case 'n': *bp++ = '\n'; break;
+ case 'n': *bp++ = '\n'; break;
case 't': *bp++ = '\t'; break;
case 'f': *bp++ = '\f'; break;
case 'r': *bp++ = '\r'; break;
@@ -406,7 +406,7 @@ int string(void)
break;
}
- default:
+ default:
*bp++ = c;
break;
}
@@ -416,7 +416,7 @@ int string(void)
break;
}
}
- *bp = 0;
+ *bp = 0;
s = tostring(buf);
*bp++ = ' '; *bp++ = 0;
yylval.cp = setsymtab(buf, s, 0.0, CON|STR|DONTFREE, symtab);
@@ -442,7 +442,7 @@ int binsearch(char *w, Keyword *kp, int n)
return -1;
}
-int word(char *w)
+int word(char *w)
{
Keyword *kp;
int c, n;
@@ -504,11 +504,11 @@ int regexpr(void)
if (!adjbuf(&buf, &bufsz, bp-buf+3, 500, &bp, 0))
FATAL("out of space for reg expr %.10s...", buf);
if (c == '\n') {
- SYNTAX( "newline in regular expression %.10s...", buf );
+ SYNTAX( "newline in regular expression %.10s...", buf );
unput('\n');
break;
} else if (c == '\\') {
- *bp++ = '\\';
+ *bp++ = '\\';
*bp++ = input();
} else {
*bp++ = c;
@@ -567,4 +567,3 @@ void unputstr(char *s) /* put a string back on input */
for (i = strlen(s)-1; i >= 0; i--)
unput(s[i]);
}
-
diff --git a/src/cmd/awk/lib.c b/src/cmd/awk/lib.c
index 6a6849c54..30c3ddd4b 100644
--- a/src/cmd/awk/lib.c
+++ b/src/cmd/awk/lib.c
@@ -29,6 +29,7 @@ THIS SOFTWARE.
#include
#include
#include
+#include
#include "awk.h"
#include "y.tab.h"
@@ -293,15 +294,19 @@ void fldbld(void) /* create fields from current record */
}
*fr = 0;
} else if ((sep = *inputFS) == 0) { /* new: FS="" => 1 char/field */
- for (i = 0; *r != 0; r++) {
- char buf[2];
+ int nb;
+ for (i = 0; *r != 0; r += nb) {
+ Rune rr;
+ char buf[UTFmax+1];
+
i++;
if (i > nfields)
growfldtab(i);
if (freeable(fldtab[i]))
xfree(fldtab[i]->sval);
- buf[0] = *r;
- buf[1] = 0;
+ nb = chartorune(&rr, r);
+ memmove(buf, r, nb);
+ buf[nb] = '\0';
fldtab[i]->sval = tostring(buf);
fldtab[i]->tval = FLD | STR;
}
@@ -430,7 +435,7 @@ int refldbld(char *rec, char *fs) /* build fields from reg expr in FS */
break;
}
}
- return i;
+ return i;
}
void recbld(void) /* create $0 from $1..$NF if necessary */
@@ -710,4 +715,3 @@ int is_number(char *s)
else
return 0;
}
-
diff --git a/src/cmd/awk/main.c b/src/cmd/awk/main.c
index ea20f63e5..532cc1f64 100644
--- a/src/cmd/awk/main.c
+++ b/src/cmd/awk/main.c
@@ -195,4 +195,3 @@ char *cursource(void) /* current source file name */
else
return NULL;
}
-
diff --git a/src/cmd/awk/maketab.c b/src/cmd/awk/maketab.c
index 50908ce97..13d34e96e 100644
--- a/src/cmd/awk/maketab.c
+++ b/src/cmd/awk/maketab.c
@@ -166,4 +166,3 @@ int main(int argc, char *argv[])
printf("}\n");
return 0;
}
-
diff --git a/src/cmd/awk/parse.c b/src/cmd/awk/parse.c
index d4c883243..2ee6eca62 100644
--- a/src/cmd/awk/parse.c
+++ b/src/cmd/awk/parse.c
@@ -269,4 +269,3 @@ Node *itonp(int i) /* and vice versa */
{
return (Node *) (long) i;
}
-
diff --git a/src/cmd/awk/proto.h b/src/cmd/awk/proto.h
index f124f4e4c..d12a93221 100644
--- a/src/cmd/awk/proto.h
+++ b/src/cmd/awk/proto.h
@@ -177,4 +177,3 @@ extern Cell *gsub(Node **, int);
extern FILE *popen(const char *, const char *);
extern int pclose(FILE *);
-
diff --git a/src/cmd/awk/re.c b/src/cmd/awk/re.c
index a15d2f4dd..2a226768b 100644
--- a/src/cmd/awk/re.c
+++ b/src/cmd/awk/re.c
@@ -215,7 +215,7 @@ nematch(void *p, char *s, char *start)
if (pmatch(p, s, start) == 1 && patlen > 0)
return 1;
patlen = -1;
- patbeg = start;
+ patbeg = start;
return 0;
}
/* in the parsing of regular expressions, metacharacters like . have */
@@ -322,4 +322,3 @@ overflow(void)
{
FATAL("%s", "regular expression too big");
}
-
diff --git a/src/cmd/awk/run.c b/src/cmd/awk/run.c
index b145758cc..9aa3e0e4c 100644
--- a/src/cmd/awk/run.c
+++ b/src/cmd/awk/run.c
@@ -506,7 +506,7 @@ Cell *awkdelete(Node **a, int n) /* a[0] is symtab, a[1] is list of subscripts *
s = getsval(y);
if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, 0))
FATAL("out of memory deleting %s[%s...]", x->nval, buf);
- strcat(buf, s);
+ strcat(buf, s);
if (np->nnext)
strcat(buf, *SUBSEP);
tempfree(y);
@@ -1914,4 +1914,3 @@ void backsub(char **pb_ptr, char **sptr_ptr) /* handle \\& variations */
*pb_ptr = pb;
*sptr_ptr = sptr;
}
-
diff --git a/src/cmd/awk/tran.c b/src/cmd/awk/tran.c
index 272a7fdc0..387bc00bd 100644
--- a/src/cmd/awk/tran.c
+++ b/src/cmd/awk/tran.c
@@ -167,7 +167,7 @@ void freesymtab(Cell *ap) /* free a symbol table */
if (freeable(cp))
xfree(cp->sval);
temp = cp->cnext; /* avoids freeing then using */
- free(cp);
+ free(cp);
}
tp->tab[i] = 0;
}
@@ -180,7 +180,7 @@ void freeelem(Cell *ap, char *s) /* free elem s from ap (i.e., ap["s"] */
Array *tp;
Cell *p, *prev = NULL;
int h;
-
+
tp = (Array *) ap->sval;
h = hash(s, tp->size);
for (p = tp->tab[h]; p != NULL; prev = p, p = p->cnext)
@@ -275,7 +275,7 @@ Awkfloat setfval(Cell *vp, Awkfloat f) /* set float val of a Cell */
{
int fldno;
- if ((vp->tval & (NUM | STR)) == 0)
+ if ((vp->tval & (NUM | STR)) == 0)
funnyvar(vp, "assign to");
if (isfld(vp)) {
donerec = 0; /* mark $0 invalid */
@@ -405,7 +405,7 @@ char *qstring(char *s, int delim) /* collect string up to next delim */
if (c == 0) { /* \ at end */
*bp++ = '\\';
break; /* for loop */
- }
+ }
switch (c) {
case '\\': *bp++ = '\\'; break;
case 'n': *bp++ = '\n'; break;
@@ -432,4 +432,3 @@ char *qstring(char *s, int delim) /* collect string up to next delim */
*bp++ = 0;
return buf;
}
-
diff --git a/src/cmd/bzip2/bunzip2.c b/src/cmd/bzip2/bunzip2.c
index 653ebc33e..38abb7ed3 100644
--- a/src/cmd/bzip2/bunzip2.c
+++ b/src/cmd/bzip2/bunzip2.c
@@ -151,7 +151,7 @@ bunzip(int ofd, char *ofile, Biobuf *bin)
if(!done && strm.avail_in < sizeof buf) {
if(strm.avail_in)
memmove(buf, strm.next_in, strm.avail_in);
-
+
n = Bread(bin, buf+strm.avail_in, sizeof(buf)-strm.avail_in);
if(n <= 0)
done = 1;
diff --git a/src/cmd/bzip2/bzip2.c b/src/cmd/bzip2/bzip2.c
index cc21a57c2..6743acb8e 100644
--- a/src/cmd/bzip2/bzip2.c
+++ b/src/cmd/bzip2/bzip2.c
@@ -175,7 +175,7 @@ bzip(char *file, long mtime, int ifd, Biobuf *bout)
if(!done && strm.avail_in < sizeof buf) {
if(strm.avail_in)
memmove(buf, strm.next_in, strm.avail_in);
-
+
n = Bread(&bin, buf+strm.avail_in, sizeof(buf)-strm.avail_in);
if(n <= 0)
done = 1;
diff --git a/src/cmd/bzip2/bzip2recover.c b/src/cmd/bzip2/bzip2recover.c
index ba3d17563..c31c50abe 100644
--- a/src/cmd/bzip2/bzip2recover.c
+++ b/src/cmd/bzip2/bzip2recover.c
@@ -5,7 +5,7 @@
/*-----------------------------------------------------------*/
/*--
- This program is bzip2recover, a program to attempt data
+ This program is bzip2recover, a program to attempt data
salvage from damaged files created by the accompanying
bzip2-1.0 program.
@@ -18,16 +18,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -324,10 +324,10 @@ Int32 main ( Int32 argc, Char** argv )
}
buffHi = (buffHi << 1) | (buffLo >> 31);
buffLo = (buffLo << 1) | (b & 1);
- if ( ( (buffHi & 0x0000ffff) == BLOCK_HEADER_HI
+ if ( ( (buffHi & 0x0000ffff) == BLOCK_HEADER_HI
&& buffLo == BLOCK_HEADER_LO)
- ||
- ( (buffHi & 0x0000ffff) == BLOCK_ENDMARK_HI
+ ||
+ ( (buffHi & 0x0000ffff) == BLOCK_ENDMARK_HI
&& buffLo == BLOCK_ENDMARK_LO)
) {
if (bitsRead > 49)
@@ -378,7 +378,7 @@ Int32 main ( Int32 argc, Char** argv )
if (b == 2) break;
buffHi = (buffHi << 1) | (buffLo >> 31);
buffLo = (buffLo << 1) | (b & 1);
- if (bitsRead == 47+rbStart[wrBlock])
+ if (bitsRead == 47+rbStart[wrBlock])
blockCRC = (buffHi << 16) | (buffLo >> 16);
if (outFile != NULL && bitsRead >= rbStart[wrBlock]
diff --git a/src/cmd/bzip2/lib/blocksort.c b/src/cmd/bzip2/lib/blocksort.c
index f43d569e6..e6d154b30 100644
--- a/src/cmd/bzip2/lib/blocksort.c
+++ b/src/cmd/bzip2/lib/blocksort.c
@@ -17,16 +17,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -57,8 +57,8 @@
For more information on these sources, see the manual.
- To get some idea how the block sorting algorithms in this file
- work, read my paper
+ To get some idea how the block sorting algorithms in this file
+ work, read my paper
On the Performance of BWT Sorting Algorithms
in Proceedings of the IEEE Data Compression Conference 2000,
Snowbird, Utah, USA, 27-30 March 2000. The main sort in this
@@ -75,11 +75,11 @@
/*---------------------------------------------*/
/*---------------------------------------------*/
-static
+static
__inline__
-void fallbackSimpleSort ( UInt32* fmap,
- UInt32* eclass,
- Int32 lo,
+void fallbackSimpleSort ( UInt32* fmap,
+ UInt32* eclass,
+ Int32 lo,
Int32 hi )
{
Int32 i, j, tmp;
@@ -138,9 +138,9 @@ void fallbackSimpleSort ( UInt32* fmap,
static
-void fallbackQSort3 ( UInt32* fmap,
+void fallbackQSort3 ( UInt32* fmap,
UInt32* eclass,
- Int32 loSt,
+ Int32 loSt,
Int32 hiSt )
{
Int32 unLo, unHi, ltLo, gtHi, n, m;
@@ -165,9 +165,9 @@ void fallbackQSort3 ( UInt32* fmap,
}
/* Random partitioning. Median of 3 sometimes fails to
- avoid bad cases. Median of 9 seems to help but
+ avoid bad cases. Median of 9 seems to help but
looks rather expensive. This too seems to work but
- is cheaper. Guidance for the magic constants
+ is cheaper. Guidance for the magic constants
7621 and 32768 is taken from Sedgewick's algorithms
book, chapter 35.
*/
@@ -184,10 +184,10 @@ void fallbackQSort3 ( UInt32* fmap,
while (1) {
if (unLo > unHi) break;
n = (Int32)eclass[fmap[unLo]] - (Int32)med;
- if (n == 0) {
- fswap(fmap[unLo], fmap[ltLo]);
- ltLo++; unLo++;
- continue;
+ if (n == 0) {
+ fswap(fmap[unLo], fmap[ltLo]);
+ ltLo++; unLo++;
+ continue;
};
if (n > 0) break;
unLo++;
@@ -195,10 +195,10 @@ void fallbackQSort3 ( UInt32* fmap,
while (1) {
if (unLo > unHi) break;
n = (Int32)eclass[fmap[unHi]] - (Int32)med;
- if (n == 0) {
- fswap(fmap[unHi], fmap[gtHi]);
- gtHi--; unHi--;
- continue;
+ if (n == 0) {
+ fswap(fmap[unHi], fmap[gtHi]);
+ gtHi--; unHi--;
+ continue;
};
if (n < 0) break;
unHi--;
@@ -257,8 +257,8 @@ void fallbackQSort3 ( UInt32* fmap,
#define UNALIGNED_BH(zz) ((zz) & 0x01f)
static
-void fallbackSort ( UInt32* fmap,
- UInt32* eclass,
+void fallbackSort ( UInt32* fmap,
+ UInt32* eclass,
UInt32* bhtab,
Int32 nblock,
Int32 verb )
@@ -299,7 +299,7 @@ void fallbackSort ( UInt32* fmap,
--*/
/*-- set sentinel bits for block-end detection --*/
- for (i = 0; i < 32; i++) {
+ for (i = 0; i < 32; i++) {
SET_BH(nblock + 2*i);
CLEAR_BH(nblock + 2*i + 1);
}
@@ -308,7 +308,7 @@ void fallbackSort ( UInt32* fmap,
H = 1;
while (1) {
- if (verb >= 4)
+ if (verb >= 4)
VPrintf1 ( " depth %6d has ", H );
j = 0;
@@ -353,14 +353,14 @@ void fallbackSort ( UInt32* fmap,
}
}
- if (verb >= 4)
+ if (verb >= 4)
VPrintf1 ( "%6d unresolved strings\n", nNotDone );
H *= 2;
if (H > nblock || nNotDone == 0) break;
}
- /*--
+ /*--
Reconstruct the original block in
eclass8 [0 .. nblock-1], since the
previous phase destroyed it.
@@ -392,9 +392,9 @@ void fallbackSort ( UInt32* fmap,
/*---------------------------------------------*/
static
__inline__
-Bool mainGtU ( UInt32 i1,
+Bool mainGtU ( UInt32 i1,
UInt32 i2,
- UChar* block,
+ UChar* block,
UInt16* quadrant,
UInt32 nblock,
Int32* budget )
@@ -534,8 +534,8 @@ void mainSimpleSort ( UInt32* ptr,
UChar* block,
UInt16* quadrant,
Int32 nblock,
- Int32 lo,
- Int32 hi,
+ Int32 lo,
+ Int32 hi,
Int32 d,
Int32* budget )
{
@@ -559,8 +559,8 @@ void mainSimpleSort ( UInt32* ptr,
if (i > hi) break;
v = ptr[i];
j = i;
- while ( mainGtU (
- ptr[j-h]+d, v+d, block, quadrant, nblock, budget
+ while ( mainGtU (
+ ptr[j-h]+d, v+d, block, quadrant, nblock, budget
) ) {
ptr[j] = ptr[j-h];
j = j - h;
@@ -573,8 +573,8 @@ void mainSimpleSort ( UInt32* ptr,
if (i > hi) break;
v = ptr[i];
j = i;
- while ( mainGtU (
- ptr[j-h]+d, v+d, block, quadrant, nblock, budget
+ while ( mainGtU (
+ ptr[j-h]+d, v+d, block, quadrant, nblock, budget
) ) {
ptr[j] = ptr[j-h];
j = j - h;
@@ -587,8 +587,8 @@ void mainSimpleSort ( UInt32* ptr,
if (i > hi) break;
v = ptr[i];
j = i;
- while ( mainGtU (
- ptr[j-h]+d, v+d, block, quadrant, nblock, budget
+ while ( mainGtU (
+ ptr[j-h]+d, v+d, block, quadrant, nblock, budget
) ) {
ptr[j] = ptr[j-h];
j = j - h;
@@ -626,13 +626,13 @@ void mainSimpleSort ( UInt32* ptr,
} \
}
-static
+static
__inline__
UChar mmed3 ( UChar a, UChar b, UChar c )
{
UChar t;
if (a > b) { t = a; a = b; b = t; };
- if (b > c) {
+ if (b > c) {
b = c;
if (a > b) b = a;
}
@@ -670,8 +670,8 @@ void mainQSort3 ( UInt32* ptr,
UChar* block,
UInt16* quadrant,
Int32 nblock,
- Int32 loSt,
- Int32 hiSt,
+ Int32 loSt,
+ Int32 hiSt,
Int32 dSt,
Int32* budget )
{
@@ -694,14 +694,14 @@ void mainQSort3 ( UInt32* ptr,
AssertH ( sp < MAIN_QSORT_STACK_SIZE, 1001 );
mpop ( lo, hi, d );
- if (hi - lo < MAIN_QSORT_SMALL_THRESH ||
+ if (hi - lo < MAIN_QSORT_SMALL_THRESH ||
d > MAIN_QSORT_DEPTH_THRESH) {
mainSimpleSort ( ptr, block, quadrant, nblock, lo, hi, d, budget );
if (*budget < 0) return;
continue;
}
- med = (Int32)
+ med = (Int32)
mmed3 ( block[ptr[ lo ]+d],
block[ptr[ hi ]+d],
block[ptr[ (lo+hi)>>1 ]+d] );
@@ -713,9 +713,9 @@ void mainQSort3 ( UInt32* ptr,
while (True) {
if (unLo > unHi) break;
n = ((Int32)block[ptr[unLo]+d]) - med;
- if (n == 0) {
- mswap(ptr[unLo], ptr[ltLo]);
- ltLo++; unLo++; continue;
+ if (n == 0) {
+ mswap(ptr[unLo], ptr[ltLo]);
+ ltLo++; unLo++; continue;
};
if (n > 0) break;
unLo++;
@@ -723,9 +723,9 @@ void mainQSort3 ( UInt32* ptr,
while (True) {
if (unLo > unHi) break;
n = ((Int32)block[ptr[unHi]+d]) - med;
- if (n == 0) {
- mswap(ptr[unHi], ptr[gtHi]);
- gtHi--; unHi--; continue;
+ if (n == 0) {
+ mswap(ptr[unHi], ptr[gtHi]);
+ gtHi--; unHi--; continue;
};
if (n < 0) break;
unHi--;
@@ -796,9 +796,9 @@ void mainQSort3 ( UInt32* ptr,
#define CLEARMASK (~(SETMASK))
static
-void mainSort ( UInt32* ptr,
+void mainSort ( UInt32* ptr,
UChar* block,
- UInt16* quadrant,
+ UInt16* quadrant,
UInt32* ftab,
Int32 nblock,
Int32 verb,
@@ -926,7 +926,7 @@ void mainSort ( UInt32* ptr,
/*--
Step 1:
Complete the big bucket [ss] by quicksorting
- any unsorted small buckets [ss, j], for j != ss.
+ any unsorted small buckets [ss, j], for j != ss.
Hopefully previous pointer-scanning phases have already
completed many of the small buckets [ss, j], so
we don't have to sort them at all.
@@ -942,10 +942,10 @@ void mainSort ( UInt32* ptr,
VPrintf4 ( " qsort [0x%x, 0x%x] "
"done %d this %d\n",
ss, j, numQSorted, hi - lo + 1 );
- mainQSort3 (
- ptr, block, quadrant, nblock,
- lo, hi, BZ_N_RADIX, budget
- );
+ mainQSort3 (
+ ptr, block, quadrant, nblock,
+ lo, hi, BZ_N_RADIX, budget
+ );
numQSorted += (hi - lo + 1);
if (*budget < 0) return;
}
@@ -977,7 +977,7 @@ void mainSort ( UInt32* ptr,
for (j = (ftab[(ss+1) << 8] & CLEARMASK) - 1; j > copyEnd[ss]; j--) {
k = ptr[j]-1; if (k < 0) k += nblock;
c1 = block[k];
- if (!bigDone[c1])
+ if (!bigDone[c1])
ptr[ copyEnd[c1]-- ] = k;
}
}
@@ -996,7 +996,7 @@ void mainSort ( UInt32* ptr,
updating for the last bucket is pointless.
The quadrant array provides a way to incrementally
- cache sort orderings, as they appear, so as to
+ cache sort orderings, as they appear, so as to
make subsequent comparisons in fullGtU() complete
faster. For repetitive blocks this makes a big
difference (but not big enough to be able to avoid
@@ -1006,9 +1006,9 @@ void mainSort ( UInt32* ptr,
for 0 <= i < nblock and 0 <= j <= nblock
- if block[i] != block[j],
+ if block[i] != block[j],
- then the relative values of quadrant[i] and
+ then the relative values of quadrant[i] and
quadrant[j] are meaningless.
else {
@@ -1071,7 +1071,7 @@ void mainSort ( UInt32* ptr,
*/
void BZ2_blockSort ( EState* s )
{
- UInt32* ptr = s->ptr;
+ UInt32* ptr = s->ptr;
UChar* block = s->block;
UInt32* ftab = s->ftab;
Int32 nblock = s->nblock;
@@ -1095,8 +1095,8 @@ void BZ2_blockSort ( EState* s )
quadrant = (UInt16*)(&(block[i]));
/* (wfact-1) / 3 puts the default-factor-30
- transition point at very roughly the same place as
- with v0.1 and v0.9.0.
+ transition point at very roughly the same place as
+ with v0.1 and v0.9.0.
Not that it particularly matters any more, since the
resulting compressed stream is now the same regardless
of whether or not we use the main sort or fallback sort.
@@ -1107,14 +1107,14 @@ void BZ2_blockSort ( EState* s )
budget = budgetInit;
mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget );
- if (verb >= 3)
+ if (verb >= 3)
VPrintf3 ( " %d work, %d block, ratio %5.2f\n",
budgetInit - budget,
- nblock,
+ nblock,
(float)(budgetInit - budget) /
- (float)(nblock==0 ? 1 : nblock) );
+ (float)(nblock==0 ? 1 : nblock) );
if (budget < 0) {
- if (verb >= 2)
+ if (verb >= 2)
VPrintf0 ( " too repetitive; using fallback"
" sorting algorithm\n" );
fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb );
diff --git a/src/cmd/bzip2/lib/buffcompress.c b/src/cmd/bzip2/lib/buffcompress.c
index 849c8ff00..cd3509342 100644
--- a/src/cmd/bzip2/lib/buffcompress.c
+++ b/src/cmd/bzip2/lib/buffcompress.c
@@ -28,16 +28,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -89,30 +89,30 @@
#include "bzlib_private.h"
/*---------------------------------------------------*/
-int BZ_API(BZ2_bzBuffToBuffCompress)
- ( char* dest,
+int BZ_API(BZ2_bzBuffToBuffCompress)
+ ( char* dest,
unsigned int* destLen,
- char* source,
+ char* source,
unsigned int sourceLen,
- int blockSize100k,
- int verbosity,
+ int blockSize100k,
+ int verbosity,
int workFactor )
{
bz_stream strm;
int ret;
- if (dest == NULL || destLen == NULL ||
+ if (dest == NULL || destLen == NULL ||
source == NULL ||
blockSize100k < 1 || blockSize100k > 9 ||
verbosity < 0 || verbosity > 4 ||
- workFactor < 0 || workFactor > 250)
+ workFactor < 0 || workFactor > 250)
return BZ_PARAM_ERROR;
if (workFactor == 0) workFactor = 30;
strm.bzalloc = NULL;
strm.bzfree = NULL;
strm.opaque = NULL;
- ret = BZ2_bzCompressInit ( &strm, blockSize100k,
+ ret = BZ2_bzCompressInit ( &strm, blockSize100k,
verbosity, workFactor );
if (ret != BZ_OK) return ret;
@@ -126,7 +126,7 @@ int BZ_API(BZ2_bzBuffToBuffCompress)
if (ret != BZ_STREAM_END) goto errhandler;
/* normal termination */
- *destLen -= strm.avail_out;
+ *destLen -= strm.avail_out;
BZ2_bzCompressEnd ( &strm );
return BZ_OK;
@@ -138,4 +138,3 @@ int BZ_API(BZ2_bzBuffToBuffCompress)
BZ2_bzCompressEnd ( &strm );
return ret;
}
-
diff --git a/src/cmd/bzip2/lib/buffdecompress.c b/src/cmd/bzip2/lib/buffdecompress.c
index 944166f3f..474924709 100644
--- a/src/cmd/bzip2/lib/buffdecompress.c
+++ b/src/cmd/bzip2/lib/buffdecompress.c
@@ -28,16 +28,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -89,10 +89,10 @@
#include "bzlib_private.h"
/*---------------------------------------------------*/
-int BZ_API(BZ2_bzBuffToBuffDecompress)
- ( char* dest,
+int BZ_API(BZ2_bzBuffToBuffDecompress)
+ ( char* dest,
unsigned int* destLen,
- char* source,
+ char* source,
unsigned int sourceLen,
int small,
int verbosity )
@@ -100,10 +100,10 @@ int BZ_API(BZ2_bzBuffToBuffDecompress)
bz_stream strm;
int ret;
- if (dest == NULL || destLen == NULL ||
+ if (dest == NULL || destLen == NULL ||
source == NULL ||
(small != 0 && small != 1) ||
- verbosity < 0 || verbosity > 4)
+ verbosity < 0 || verbosity > 4)
return BZ_PARAM_ERROR;
strm.bzalloc = NULL;
@@ -133,11 +133,9 @@ int BZ_API(BZ2_bzBuffToBuffDecompress)
} else {
BZ2_bzDecompressEnd ( &strm );
return BZ_OUTBUFF_FULL;
- };
+ };
errhandler:
BZ2_bzDecompressEnd ( &strm );
- return ret;
+ return ret;
}
-
-
diff --git a/src/cmd/bzip2/lib/bzassert.c b/src/cmd/bzip2/lib/bzassert.c
index 56d58fc24..8a578bd02 100644
--- a/src/cmd/bzip2/lib/bzassert.c
+++ b/src/cmd/bzip2/lib/bzassert.c
@@ -28,16 +28,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -93,7 +93,7 @@
void BZ2_bz__AssertH__fail ( int errcode )
{
- fprintf(stderr,
+ fprintf(stderr,
"\n\nbzip2/libbzip2: internal error number %d.\n"
"This is a bug in bzip2/libbzip2, %s.\n"
"Please report it to me at: jseward@acm.org. If this happened\n"
diff --git a/src/cmd/bzip2/lib/bzbuffcompress.c b/src/cmd/bzip2/lib/bzbuffcompress.c
index 849c8ff00..cd3509342 100644
--- a/src/cmd/bzip2/lib/bzbuffcompress.c
+++ b/src/cmd/bzip2/lib/bzbuffcompress.c
@@ -28,16 +28,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -89,30 +89,30 @@
#include "bzlib_private.h"
/*---------------------------------------------------*/
-int BZ_API(BZ2_bzBuffToBuffCompress)
- ( char* dest,
+int BZ_API(BZ2_bzBuffToBuffCompress)
+ ( char* dest,
unsigned int* destLen,
- char* source,
+ char* source,
unsigned int sourceLen,
- int blockSize100k,
- int verbosity,
+ int blockSize100k,
+ int verbosity,
int workFactor )
{
bz_stream strm;
int ret;
- if (dest == NULL || destLen == NULL ||
+ if (dest == NULL || destLen == NULL ||
source == NULL ||
blockSize100k < 1 || blockSize100k > 9 ||
verbosity < 0 || verbosity > 4 ||
- workFactor < 0 || workFactor > 250)
+ workFactor < 0 || workFactor > 250)
return BZ_PARAM_ERROR;
if (workFactor == 0) workFactor = 30;
strm.bzalloc = NULL;
strm.bzfree = NULL;
strm.opaque = NULL;
- ret = BZ2_bzCompressInit ( &strm, blockSize100k,
+ ret = BZ2_bzCompressInit ( &strm, blockSize100k,
verbosity, workFactor );
if (ret != BZ_OK) return ret;
@@ -126,7 +126,7 @@ int BZ_API(BZ2_bzBuffToBuffCompress)
if (ret != BZ_STREAM_END) goto errhandler;
/* normal termination */
- *destLen -= strm.avail_out;
+ *destLen -= strm.avail_out;
BZ2_bzCompressEnd ( &strm );
return BZ_OK;
@@ -138,4 +138,3 @@ int BZ_API(BZ2_bzBuffToBuffCompress)
BZ2_bzCompressEnd ( &strm );
return ret;
}
-
diff --git a/src/cmd/bzip2/lib/bzcompress.c b/src/cmd/bzip2/lib/bzcompress.c
index d27e67573..7f3deec0e 100644
--- a/src/cmd/bzip2/lib/bzcompress.c
+++ b/src/cmd/bzip2/lib/bzcompress.c
@@ -28,16 +28,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -125,8 +125,8 @@ Bool isempty_RL ( EState* s )
/*---------------------------------------------------*/
-int BZ_API(BZ2_bzCompressInit)
- ( bz_stream* strm,
+int BZ_API(BZ2_bzCompressInit)
+ ( bz_stream* strm,
int blockSize100k,
int verbosity,
int workFactor )
@@ -136,7 +136,7 @@ int BZ_API(BZ2_bzCompressInit)
if (!bz_config_ok()) return BZ_CONFIG_ERROR;
- if (strm == NULL ||
+ if (strm == NULL ||
blockSize100k < 1 || blockSize100k > 9 ||
workFactor < 0 || workFactor > 250)
return BZ_PARAM_ERROR;
@@ -279,7 +279,7 @@ Bool copy_input_until_stop ( EState* s )
/*-- no input? --*/
if (s->strm->avail_in == 0) break;
progress_in = True;
- ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
+ ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
s->strm->next_in++;
s->strm->avail_in--;
s->strm->total_in_lo32++;
@@ -297,7 +297,7 @@ Bool copy_input_until_stop ( EState* s )
/*-- flush/finish end? --*/
if (s->avail_in_expect == 0) break;
progress_in = True;
- ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
+ ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
s->strm->next_in++;
s->strm->avail_in--;
s->strm->total_in_lo32++;
@@ -343,18 +343,18 @@ Bool handle_compress ( bz_stream* strm )
Bool progress_in = False;
Bool progress_out = False;
EState* s = strm->state;
-
+
while (True) {
if (s->state == BZ_S_OUTPUT) {
progress_out |= copy_output_until_stop ( s );
if (s->state_out_pos < s->numZ) break;
- if (s->mode == BZ_M_FINISHING &&
+ if (s->mode == BZ_M_FINISHING &&
s->avail_in_expect == 0 &&
isempty_RL(s)) break;
prepare_new_block ( s );
s->state = BZ_S_INPUT;
- if (s->mode == BZ_M_FLUSHING &&
+ if (s->mode == BZ_M_FLUSHING &&
s->avail_in_expect == 0 &&
isempty_RL(s)) break;
}
@@ -402,7 +402,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
if (action == BZ_RUN) {
progress = handle_compress ( strm );
return progress ? BZ_RUN_OK : BZ_PARAM_ERROR;
- }
+ }
else
if (action == BZ_FLUSH) {
s->avail_in_expect = strm->avail_in;
@@ -415,12 +415,12 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
s->mode = BZ_M_FINISHING;
goto preswitch;
}
- else
+ else
return BZ_PARAM_ERROR;
case BZ_M_FLUSHING:
if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR;
- if (s->avail_in_expect != s->strm->avail_in)
+ if (s->avail_in_expect != s->strm->avail_in)
return BZ_SEQUENCE_ERROR;
progress = handle_compress ( strm );
if (!progress) return BZ_SEQUENCE_ERROR; /*rsc added */
@@ -431,7 +431,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
case BZ_M_FINISHING:
if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR;
- if (s->avail_in_expect != s->strm->avail_in)
+ if (s->avail_in_expect != s->strm->avail_in)
return BZ_SEQUENCE_ERROR;
progress = handle_compress ( strm );
if (!progress) return BZ_SEQUENCE_ERROR;
@@ -458,8 +458,7 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm )
if (s->ftab != NULL) BZFREE(s->ftab);
BZFREE(strm->state);
- strm->state = NULL;
+ strm->state = NULL;
return BZ_OK;
}
-
diff --git a/src/cmd/bzip2/lib/bzdecompress.c b/src/cmd/bzip2/lib/bzdecompress.c
index 25ed92536..da3251fbe 100644
--- a/src/cmd/bzip2/lib/bzdecompress.c
+++ b/src/cmd/bzip2/lib/bzdecompress.c
@@ -28,16 +28,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -93,8 +93,8 @@
/*---------------------------------------------------*/
/*---------------------------------------------------*/
-int BZ_API(BZ2_bzDecompressInit)
- ( bz_stream* strm,
+int BZ_API(BZ2_bzDecompressInit)
+ ( bz_stream* strm,
int verbosity,
int small )
{
@@ -153,34 +153,34 @@ void unRLE_obuf_to_output_FAST ( DState* s )
s->strm->total_out_lo32++;
if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
}
-
+
/* can a new run be started? */
if (s->nblock_used == s->save_nblock+1) return;
-
-
+
+
s->state_out_len = 1;
s->state_out_ch = s->k0;
- BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
+ BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
+
s->state_out_len = 2;
- BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
+ BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
+
s->state_out_len = 3;
- BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
+ BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
- BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
+
+ BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
s->state_out_len = ((Int32)k1) + 4;
- BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK;
+ BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK;
s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
}
@@ -217,7 +217,7 @@ void unRLE_obuf_to_output_FAST ( DState* s )
}
s_state_out_len_eq_one:
{
- if (cs_avail_out == 0) {
+ if (cs_avail_out == 0) {
c_state_out_len = 1; goto return_notr;
};
*( (UChar*)(cs_next_out) ) = c_state_out_ch;
@@ -225,29 +225,29 @@ void unRLE_obuf_to_output_FAST ( DState* s )
cs_next_out++;
cs_avail_out--;
}
- }
+ }
/* can a new run be started? */
if (c_nblock_used == s_save_nblockPP) {
c_state_out_len = 0; goto return_notr;
- };
+ };
c_state_out_ch = c_k0;
BZ_GET_FAST_C(k1); c_nblock_used++;
- if (k1 != c_k0) {
- c_k0 = k1; goto s_state_out_len_eq_one;
+ if (k1 != c_k0) {
+ c_k0 = k1; goto s_state_out_len_eq_one;
};
- if (c_nblock_used == s_save_nblockPP)
+ if (c_nblock_used == s_save_nblockPP)
goto s_state_out_len_eq_one;
-
+
c_state_out_len = 2;
BZ_GET_FAST_C(k1); c_nblock_used++;
if (c_nblock_used == s_save_nblockPP) continue;
if (k1 != c_k0) { c_k0 = k1; continue; };
-
+
c_state_out_len = 3;
BZ_GET_FAST_C(k1); c_nblock_used++;
if (c_nblock_used == s_save_nblockPP) continue;
if (k1 != c_k0) { c_k0 = k1; continue; };
-
+
BZ_GET_FAST_C(k1); c_nblock_used++;
c_state_out_len = ((Int32)k1) + 4;
BZ_GET_FAST_C(c_k0); c_nblock_used++;
@@ -311,34 +311,34 @@ void unRLE_obuf_to_output_SMALL ( DState* s )
s->strm->total_out_lo32++;
if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
}
-
+
/* can a new run be started? */
if (s->nblock_used == s->save_nblock+1) return;
-
-
+
+
s->state_out_len = 1;
s->state_out_ch = s->k0;
- BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
+ BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
+
s->state_out_len = 2;
- BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
+ BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
+
s->state_out_len = 3;
- BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
+ BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
- BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
+
+ BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
s->state_out_len = ((Int32)k1) + 4;
- BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK;
+ BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK;
s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
}
@@ -357,26 +357,26 @@ void unRLE_obuf_to_output_SMALL ( DState* s )
s->strm->total_out_lo32++;
if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
}
-
+
/* can a new run be started? */
if (s->nblock_used == s->save_nblock+1) return;
-
+
s->state_out_len = 1;
s->state_out_ch = s->k0;
BZ_GET_SMALL(k1); s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
+
s->state_out_len = 2;
BZ_GET_SMALL(k1); s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
+
s->state_out_len = 3;
BZ_GET_SMALL(k1); s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
-
+
BZ_GET_SMALL(k1); s->nblock_used++;
s->state_out_len = ((Int32)k1) + 4;
BZ_GET_SMALL(s->k0); s->nblock_used++;
@@ -403,14 +403,14 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
unRLE_obuf_to_output_FAST ( s );
if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) {
BZ_FINALISE_CRC ( s->calculatedBlockCRC );
- if (s->verbosity >= 3)
- VPrintf2 ( " {0x%x, 0x%x}", s->storedBlockCRC,
+ if (s->verbosity >= 3)
+ VPrintf2 ( " {0x%x, 0x%x}", s->storedBlockCRC,
s->calculatedBlockCRC );
if (s->verbosity >= 2) VPrintf0 ( "]" );
if (s->calculatedBlockCRC != s->storedBlockCRC)
return BZ_DATA_ERROR;
- s->calculatedCombinedCRC
- = (s->calculatedCombinedCRC << 1) |
+ s->calculatedCombinedCRC
+ = (s->calculatedCombinedCRC << 1) |
(s->calculatedCombinedCRC >> 31);
s->calculatedCombinedCRC ^= s->calculatedBlockCRC;
s->state = BZ_X_BLKHDR_1;
@@ -422,7 +422,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
Int32 r = BZ2_decompress ( s );
if (r == BZ_STREAM_END) {
if (s->verbosity >= 3)
- VPrintf2 ( "\n combined CRCs: stored = 0x%x, computed = 0x%x",
+ VPrintf2 ( "\n combined CRCs: stored = 0x%x, computed = 0x%x",
s->storedCombinedCRC, s->calculatedCombinedCRC );
if (s->calculatedCombinedCRC != s->storedCombinedCRC)
return BZ_DATA_ERROR;
@@ -435,7 +435,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
/*
AssertH ( 0, 6001 );
- return 0;
+ return 0;
*/
}
@@ -458,4 +458,3 @@ int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm )
return BZ_OK;
}
-
diff --git a/src/cmd/bzip2/lib/bzfeof.c b/src/cmd/bzip2/lib/bzfeof.c
index 74e1f88da..c96974dae 100644
--- a/src/cmd/bzip2/lib/bzfeof.c
+++ b/src/cmd/bzip2/lib/bzfeof.c
@@ -28,16 +28,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -97,4 +97,3 @@ Bool bz_feof ( FILE* f )
ungetc ( c, f );
return False;
}
-
diff --git a/src/cmd/bzip2/lib/bzlib.c b/src/cmd/bzip2/lib/bzlib.c
index 66b89a2e8..12a4bf90f 100644
--- a/src/cmd/bzip2/lib/bzlib.c
+++ b/src/cmd/bzip2/lib/bzlib.c
@@ -28,16 +28,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
diff --git a/src/cmd/bzip2/lib/bzlib.h b/src/cmd/bzip2/lib/bzlib.h
index 0ece4e8a6..fae78bcbd 100644
--- a/src/cmd/bzip2/lib/bzlib.h
+++ b/src/cmd/bzip2/lib/bzlib.h
@@ -29,16 +29,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -96,7 +96,7 @@ extern "C" {
#define BZ_OUTBUFF_FULL (-8)
#define BZ_CONFIG_ERROR (-9)
-typedef
+typedef
struct {
char *next_in;
unsigned int avail_in;
@@ -113,7 +113,7 @@ typedef
void *(*bzalloc)(void *,int,int);
void (*bzfree)(void *,void *);
void *opaque;
- }
+ }
bz_stream;
@@ -144,57 +144,57 @@ typedef
/*-- Core (low-level) library functions --*/
-BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
- bz_stream* strm,
- int blockSize100k,
- int verbosity,
- int workFactor
+BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
+ bz_stream* strm,
+ int blockSize100k,
+ int verbosity,
+ int workFactor
);
-BZ_EXTERN int BZ_API(BZ2_bzCompress) (
- bz_stream* strm,
- int action
+BZ_EXTERN int BZ_API(BZ2_bzCompress) (
+ bz_stream* strm,
+ int action
);
-BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
- bz_stream* strm
+BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
+ bz_stream* strm
);
-BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
- bz_stream *strm,
- int verbosity,
+BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
+ bz_stream *strm,
+ int verbosity,
int small
);
-BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
- bz_stream* strm
+BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
+ bz_stream* strm
);
-BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
- bz_stream *strm
+BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
+ bz_stream *strm
);
/*-- Utility functions --*/
-BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
- char* dest,
+BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
+ char* dest,
unsigned int* destLen,
- char* source,
+ char* source,
unsigned int sourceLen,
- int blockSize100k,
- int verbosity,
- int workFactor
+ int blockSize100k,
+ int verbosity,
+ int workFactor
);
-BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
- char* dest,
+BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
+ char* dest,
unsigned int* destLen,
- char* source,
+ char* source,
unsigned int sourceLen,
- int small,
- int verbosity
+ int small,
+ int verbosity
);
diff --git a/src/cmd/bzip2/lib/bzlib_private.h b/src/cmd/bzip2/lib/bzlib_private.h
index ad5787063..002d79b32 100644
--- a/src/cmd/bzip2/lib/bzlib_private.h
+++ b/src/cmd/bzip2/lib/bzlib_private.h
@@ -29,16 +29,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -80,7 +80,7 @@
#ifndef __GNUC__
#define __inline__ /* */
-#endif
+#endif
/* these #defines can be overridden by bzlib_stdio.h */
extern void bz_internal_error ( int errcode );
@@ -257,19 +257,19 @@ typedef
/*-- externs for compression. --*/
-extern void
+extern void
BZ2_blockSort ( EState* );
-extern void
+extern void
BZ2_compressBlock ( EState*, Bool );
-extern void
+extern void
BZ2_bsInitWrite ( EState* );
-extern void
+extern void
BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 );
-extern void
+extern void
BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
@@ -413,7 +413,7 @@ typedef
Int32 save_N;
Int32 save_curr;
Int32 save_zt;
- Int32 save_zn;
+ Int32 save_zn;
Int32 save_zvec;
Int32 save_zj;
Int32 save_gSel;
@@ -463,13 +463,13 @@ typedef
/*-- externs for decompression. --*/
-extern Int32
+extern Int32
BZ2_indexIntoF ( Int32, Int32* );
-extern Int32
+extern Int32
BZ2_decompress ( DState* );
-extern void
+extern void
BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
Int32, Int32, Int32 );
diff --git a/src/cmd/bzip2/lib/bzlib_stdio.h b/src/cmd/bzip2/lib/bzlib_stdio.h
index 30d41d998..18805f0ba 100644
--- a/src/cmd/bzip2/lib/bzlib_stdio.h
+++ b/src/cmd/bzip2/lib/bzlib_stdio.h
@@ -28,16 +28,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -99,17 +99,17 @@ BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
int fd,
const char *mode
);
-
+
BZ_EXTERN int BZ_API(BZ2_bzread) (
- BZFILE* b,
- void* buf,
- int len
+ BZFILE* b,
+ void* buf,
+ int len
);
BZ_EXTERN int BZ_API(BZ2_bzwrite) (
- BZFILE* b,
- void* buf,
- int len
+ BZFILE* b,
+ void* buf,
+ int len
);
BZ_EXTERN int BZ_API(BZ2_bzflush) (
@@ -121,70 +121,69 @@ BZ_EXTERN void BZ_API(BZ2_bzclose) (
);
BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
- BZFILE *b,
+ BZFILE *b,
int *errnum
);
/*-- High(er) level library functions --*/
-BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
- int* bzerror,
- FILE* f,
- int verbosity,
+BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
+ int* bzerror,
+ FILE* f,
+ int verbosity,
int small,
- void* unused,
- int nUnused
+ void* unused,
+ int nUnused
);
-BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
- int* bzerror,
- BZFILE* b
+BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
+ int* bzerror,
+ BZFILE* b
);
-BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
- int* bzerror,
- BZFILE* b,
- void** unused,
- int* nUnused
+BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
+ int* bzerror,
+ BZFILE* b,
+ void** unused,
+ int* nUnused
);
-BZ_EXTERN int BZ_API(BZ2_bzRead) (
- int* bzerror,
- BZFILE* b,
- void* buf,
- int len
+BZ_EXTERN int BZ_API(BZ2_bzRead) (
+ int* bzerror,
+ BZFILE* b,
+ void* buf,
+ int len
);
-BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
- int* bzerror,
- FILE* f,
- int blockSize100k,
- int verbosity,
- int workFactor
+BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
+ int* bzerror,
+ FILE* f,
+ int blockSize100k,
+ int verbosity,
+ int workFactor
);
-BZ_EXTERN void BZ_API(BZ2_bzWrite) (
- int* bzerror,
- BZFILE* b,
- void* buf,
- int len
+BZ_EXTERN void BZ_API(BZ2_bzWrite) (
+ int* bzerror,
+ BZFILE* b,
+ void* buf,
+ int len
);
-BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
- int* bzerror,
- BZFILE* b,
- int abandon,
- unsigned int* nbytes_in,
- unsigned int* nbytes_out
+BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
+ int* bzerror,
+ BZFILE* b,
+ int abandon,
+ unsigned int* nbytes_in,
+ unsigned int* nbytes_out
);
-BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
- int* bzerror,
- BZFILE* b,
- int abandon,
- unsigned int* nbytes_in_lo32,
- unsigned int* nbytes_in_hi32,
- unsigned int* nbytes_out_lo32,
+BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
+ int* bzerror,
+ BZFILE* b,
+ int abandon,
+ unsigned int* nbytes_in_lo32,
+ unsigned int* nbytes_in_hi32,
+ unsigned int* nbytes_out_lo32,
unsigned int* nbytes_out_hi32
);
-
diff --git a/src/cmd/bzip2/lib/bzlib_stdio_private.h b/src/cmd/bzip2/lib/bzlib_stdio_private.h
index 24b311443..caacf36a1 100644
--- a/src/cmd/bzip2/lib/bzlib_stdio_private.h
+++ b/src/cmd/bzip2/lib/bzlib_stdio_private.h
@@ -53,7 +53,7 @@ extern void BZ2_bz__AssertH__fail ( int errcode );
if (bzf != NULL) bzf->lastErr = eee; \
}
-typedef
+typedef
struct {
FILE* handle;
Char buf[BZ_MAX_UNUSED];
@@ -66,4 +66,3 @@ typedef
bzFile;
extern Bool bz_feof( FILE* );
-
diff --git a/src/cmd/bzip2/lib/bzread.c b/src/cmd/bzip2/lib/bzread.c
index 8bd03888d..e523d249c 100644
--- a/src/cmd/bzip2/lib/bzread.c
+++ b/src/cmd/bzip2/lib/bzread.c
@@ -19,16 +19,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -82,9 +82,9 @@
#include "bzlib_stdio_private.h"
/*---------------------------------------------------*/
-BZFILE* BZ_API(BZ2_bzReadOpen)
- ( int* bzerror,
- FILE* f,
+BZFILE* BZ_API(BZ2_bzReadOpen)
+ ( int* bzerror,
+ FILE* f,
int verbosity,
int small,
void* unused,
@@ -95,7 +95,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen)
BZ_SETERR(BZ_OK);
- if (f == NULL ||
+ if (f == NULL ||
(small != 0 && small != 1) ||
(verbosity < 0 || verbosity > 4) ||
(unused == NULL && nUnused != 0) ||
@@ -106,7 +106,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen)
{ BZ_SETERR(BZ_IO_ERROR); return NULL; };
bzf = malloc ( sizeof(bzFile) );
- if (bzf == NULL)
+ if (bzf == NULL)
{ BZ_SETERR(BZ_MEM_ERROR); return NULL; };
BZ_SETERR(BZ_OK);
@@ -118,7 +118,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen)
bzf->strm.bzalloc = NULL;
bzf->strm.bzfree = NULL;
bzf->strm.opaque = NULL;
-
+
while (nUnused > 0) {
bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++;
unused = ((void*)( 1 + ((UChar*)(unused)) ));
@@ -133,7 +133,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen)
bzf->strm.next_in = bzf->buf;
bzf->initialisedOk = True;
- return bzf;
+ return bzf;
}
@@ -156,10 +156,10 @@ void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b )
/*---------------------------------------------------*/
-int BZ_API(BZ2_bzRead)
- ( int* bzerror,
- BZFILE* b,
- void* buf,
+int BZ_API(BZ2_bzRead)
+ ( int* bzerror,
+ BZFILE* b,
+ void* buf,
int len )
{
Int32 n, ret;
@@ -181,11 +181,11 @@ int BZ_API(BZ2_bzRead)
while (True) {
- if (ferror(bzf->handle))
+ if (ferror(bzf->handle))
{ BZ_SETERR(BZ_IO_ERROR); return 0; };
if (bzf->strm.avail_in == 0 && !bz_feof(bzf->handle)) {
- n = fread ( bzf->buf, sizeof(UChar),
+ n = fread ( bzf->buf, sizeof(UChar),
BZ_MAX_UNUSED, bzf->handle );
if (ferror(bzf->handle))
{ BZ_SETERR(BZ_IO_ERROR); return 0; };
@@ -199,7 +199,7 @@ int BZ_API(BZ2_bzRead)
if (ret != BZ_OK && ret != BZ_STREAM_END)
{ BZ_SETERR(ret); return 0; };
- if (ret == BZ_OK && bz_feof(bzf->handle) &&
+ if (ret == BZ_OK && bz_feof(bzf->handle) &&
bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0)
{ BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; };
@@ -208,7 +208,7 @@ int BZ_API(BZ2_bzRead)
return len - bzf->strm.avail_out; };
if (bzf->strm.avail_out == 0)
{ BZ_SETERR(BZ_OK); return len; };
-
+
}
/* return 0; not reached*/
@@ -216,10 +216,10 @@ int BZ_API(BZ2_bzRead)
/*---------------------------------------------------*/
-void BZ_API(BZ2_bzReadGetUnused)
- ( int* bzerror,
- BZFILE* b,
- void** unused,
+void BZ_API(BZ2_bzReadGetUnused)
+ ( int* bzerror,
+ BZFILE* b,
+ void** unused,
int* nUnused )
{
bzFile* bzf = (bzFile*)b;
diff --git a/src/cmd/bzip2/lib/bzstdio.c b/src/cmd/bzip2/lib/bzstdio.c
index 3e1f2de50..31b0a7688 100644
--- a/src/cmd/bzip2/lib/bzstdio.c
+++ b/src/cmd/bzip2/lib/bzstdio.c
@@ -28,16 +28,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -95,4 +95,3 @@ Bool bz_feof ( FILE* f )
ungetc ( c, f );
return False;
}
-
diff --git a/src/cmd/bzip2/lib/bzversion.c b/src/cmd/bzip2/lib/bzversion.c
index 5320144b2..601d0c91e 100644
--- a/src/cmd/bzip2/lib/bzversion.c
+++ b/src/cmd/bzip2/lib/bzversion.c
@@ -28,16 +28,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -96,4 +96,3 @@ const char * BZ_API(BZ2_bzlibVersion)(void)
{
return BZ_VERSION;
}
-
diff --git a/src/cmd/bzip2/lib/bzwrite.c b/src/cmd/bzip2/lib/bzwrite.c
index a37a66bab..086b6e2d0 100644
--- a/src/cmd/bzip2/lib/bzwrite.c
+++ b/src/cmd/bzip2/lib/bzwrite.c
@@ -19,16 +19,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -82,10 +82,10 @@
#include "bzlib_stdio_private.h"
/*---------------------------------------------------*/
-BZFILE* BZ_API(BZ2_bzWriteOpen)
- ( int* bzerror,
- FILE* f,
- int blockSize100k,
+BZFILE* BZ_API(BZ2_bzWriteOpen)
+ ( int* bzerror,
+ FILE* f,
+ int blockSize100k,
int verbosity,
int workFactor )
{
@@ -117,23 +117,23 @@ BZFILE* BZ_API(BZ2_bzWriteOpen)
bzf->strm.opaque = NULL;
if (workFactor == 0) workFactor = 30;
- ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k,
+ ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k,
verbosity, workFactor );
if (ret != BZ_OK)
{ BZ_SETERR(ret); free(bzf); return NULL; };
bzf->strm.avail_in = 0;
bzf->initialisedOk = True;
- return bzf;
+ return bzf;
}
/*---------------------------------------------------*/
void BZ_API(BZ2_bzWrite)
- ( int* bzerror,
- BZFILE* b,
- void* buf,
+ ( int* bzerror,
+ BZFILE* b,
+ void* buf,
int len )
{
Int32 n, n2, ret;
@@ -162,7 +162,7 @@ void BZ_API(BZ2_bzWrite)
if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
n = BZ_MAX_UNUSED - bzf->strm.avail_out;
- n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
+ n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
n, bzf->handle );
if (n != n2 || ferror(bzf->handle))
{ BZ_SETERR(BZ_IO_ERROR); return; };
@@ -176,20 +176,20 @@ void BZ_API(BZ2_bzWrite)
/*---------------------------------------------------*/
void BZ_API(BZ2_bzWriteClose)
- ( int* bzerror,
- BZFILE* b,
+ ( int* bzerror,
+ BZFILE* b,
int abandon,
unsigned int* nbytes_in,
unsigned int* nbytes_out )
{
- BZ2_bzWriteClose64 ( bzerror, b, abandon,
+ BZ2_bzWriteClose64 ( bzerror, b, abandon,
nbytes_in, NULL, nbytes_out, NULL );
}
void BZ_API(BZ2_bzWriteClose64)
- ( int* bzerror,
- BZFILE* b,
+ ( int* bzerror,
+ BZFILE* b,
int abandon,
unsigned int* nbytes_in_lo32,
unsigned int* nbytes_in_hi32,
@@ -221,7 +221,7 @@ void BZ_API(BZ2_bzWriteClose64)
if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
n = BZ_MAX_UNUSED - bzf->strm.avail_out;
- n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
+ n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
n, bzf->handle );
if (n != n2 || ferror(bzf->handle))
{ BZ_SETERR(BZ_IO_ERROR); return; };
@@ -250,4 +250,3 @@ void BZ_API(BZ2_bzWriteClose64)
BZ2_bzCompressEnd ( &(bzf->strm) );
free ( bzf );
}
-
diff --git a/src/cmd/bzip2/lib/bzzlib.c b/src/cmd/bzip2/lib/bzzlib.c
index 87b691289..56b0b7dea 100644
--- a/src/cmd/bzip2/lib/bzzlib.c
+++ b/src/cmd/bzip2/lib/bzzlib.c
@@ -28,16 +28,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -128,7 +128,7 @@ BZFILE * bzopen_or_bzdopen
int verbosity = 0;
int workFactor = 30;
int smallMode = 0;
- int nUnused = 0;
+ int nUnused = 0;
if (mode == NULL) return NULL;
while (*mode) {
@@ -168,7 +168,7 @@ BZFILE * bzopen_or_bzdopen
if (writing) {
/* Guard against total chaos and anarchy -- JRS */
if (blockSize100k < 1) blockSize100k = 1;
- if (blockSize100k > 9) blockSize100k = 9;
+ if (blockSize100k > 9) blockSize100k = 9;
bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k,
verbosity,workFactor);
} else {
@@ -247,7 +247,7 @@ void BZ_API(BZ2_bzclose) (BZFILE* b)
{
int bzerr;
FILE *fp = ((bzFile *)b)->handle;
-
+
if (b==NULL) {return;}
if(((bzFile*)b)->writing){
BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL);
@@ -265,7 +265,7 @@ void BZ_API(BZ2_bzclose) (BZFILE* b)
/*---------------------------------------------------*/
/*--
- return last error code
+ return last error code
--*/
static char *bzerrorstrings[] = {
"OK"
diff --git a/src/cmd/bzip2/lib/compress.c b/src/cmd/bzip2/lib/compress.c
index 96c559183..c7a1aa80b 100644
--- a/src/cmd/bzip2/lib/compress.c
+++ b/src/cmd/bzip2/lib/compress.c
@@ -17,16 +17,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -66,7 +66,7 @@
0.9.0a/b -- no changes in this file.
0.9.0c
- * changed setting of nGroups in sendMTFValues() so as to
+ * changed setting of nGroups in sendMTFValues() so as to
do a bit better on small files
--*/
@@ -171,11 +171,11 @@ void generateMTFValues ( EState* s )
Int32 wr;
Int32 EOB;
- /*
+ /*
After sorting (eg, here),
s->arr1 [ 0 .. s->nblock-1 ] holds sorted order,
and
- ((UChar*)s->arr2) [ 0 .. s->nblock-1 ]
+ ((UChar*)s->arr2) [ 0 .. s->nblock-1 ]
holds the original block data.
The first thing to do is generate the MTF values,
@@ -190,7 +190,7 @@ void generateMTFValues ( EState* s )
(UChar*) (&((UChar*)s->arr2)[s->nblock])
These storage aliases are set up in bzCompressInit(),
- except for the last one, which is arranged in
+ except for the last one, which is arranged in
compressBlock().
*/
UInt32* ptr = s->ptr;
@@ -213,7 +213,7 @@ void generateMTFValues ( EState* s )
ll_i = s->unseqToSeq[block[j]];
AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" );
- if (yy[0] == ll_i) {
+ if (yy[0] == ll_i) {
zPend++;
} else {
@@ -221,11 +221,11 @@ void generateMTFValues ( EState* s )
zPend--;
while (True) {
if (zPend & 1) {
- mtfv[wr] = BZ_RUNB; wr++;
- s->mtfFreq[BZ_RUNB]++;
+ mtfv[wr] = BZ_RUNB; wr++;
+ s->mtfFreq[BZ_RUNB]++;
} else {
- mtfv[wr] = BZ_RUNA; wr++;
- s->mtfFreq[BZ_RUNA]++;
+ mtfv[wr] = BZ_RUNA; wr++;
+ s->mtfFreq[BZ_RUNA]++;
}
if (zPend < 2) break;
zPend = (zPend - 2) / 2;
@@ -259,11 +259,11 @@ void generateMTFValues ( EState* s )
zPend--;
while (True) {
if (zPend & 1) {
- mtfv[wr] = BZ_RUNB; wr++;
- s->mtfFreq[BZ_RUNB]++;
+ mtfv[wr] = BZ_RUNB; wr++;
+ s->mtfFreq[BZ_RUNB]++;
} else {
- mtfv[wr] = BZ_RUNA; wr++;
- s->mtfFreq[BZ_RUNA]++;
+ mtfv[wr] = BZ_RUNA; wr++;
+ s->mtfFreq[BZ_RUNA]++;
}
if (zPend < 2) break;
zPend = (zPend - 2) / 2;
@@ -306,7 +306,7 @@ void sendMTFValues ( EState* s )
if (s->verbosity >= 3)
VPrintf3( " %d in block, %d after MTF & 1-2 coding, "
- "%d+2 syms in use\n",
+ "%d+2 syms in use\n",
s->nblock, s->nMTF, s->nInUse );
alphaSize = s->nInUse+2;
@@ -323,7 +323,7 @@ void sendMTFValues ( EState* s )
nGroups = 6;
/*--- Generate an initial set of coding tables ---*/
- {
+ {
Int32 nPart, remF, tFreq, aFreq;
nPart = nGroups;
@@ -338,8 +338,8 @@ void sendMTFValues ( EState* s )
aFreq += s->mtfFreq[ge];
}
- if (ge > gs
- && nPart != nGroups && nPart != 1
+ if (ge > gs
+ && nPart != nGroups && nPart != 1
&& ((nGroups-nPart) % 2 == 1)) {
aFreq -= s->mtfFreq[ge];
ge--;
@@ -348,21 +348,21 @@ void sendMTFValues ( EState* s )
if (s->verbosity >= 3)
VPrintf5( " initial group %d, [%d .. %d], "
"has %d syms (%4.1f%%)\n",
- nPart, gs, ge, aFreq,
+ nPart, gs, ge, aFreq,
(100.0 * (float)aFreq) / (float)(s->nMTF) );
-
+
for (v = 0; v < alphaSize; v++)
- if (v >= gs && v <= ge)
+ if (v >= gs && v <= ge)
s->len[nPart-1][v] = BZ_LESSER_ICOST; else
s->len[nPart-1][v] = BZ_GREATER_ICOST;
-
+
nPart--;
gs = ge+1;
remF -= aFreq;
}
}
- /*---
+ /*---
Iterate up to BZ_N_ITERS times to improve the tables.
---*/
nSelectors = 40000; /* shut up some compilers' warnings about used and not set */
@@ -377,7 +377,7 @@ void sendMTFValues ( EState* s )
/*---
Set up an auxiliary length table which is used to fast-track
- the common case (nGroups == 6).
+ the common case (nGroups == 6).
---*/
if (nGroups == 6) {
for (v = 0; v < alphaSize; v++) {
@@ -394,10 +394,10 @@ void sendMTFValues ( EState* s )
/*--- Set group start & end marks. --*/
if (gs >= s->nMTF) break;
- ge = gs + BZ_G_SIZE - 1;
+ ge = gs + BZ_G_SIZE - 1;
if (ge >= s->nMTF) ge = s->nMTF-1;
- /*--
+ /*--
Calculate the cost of this group as coded
by each of the coding tables.
--*/
@@ -434,13 +434,13 @@ void sendMTFValues ( EState* s )
} else {
/*--- slow version which correctly handles all situations ---*/
- for (i = gs; i <= ge; i++) {
+ for (i = gs; i <= ge; i++) {
UInt16 icv = mtfv[i];
for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv];
}
}
-
- /*--
+
+ /*--
Find the coding table which is best for this group,
and record its identity in the selector table.
--*/
@@ -452,7 +452,7 @@ void sendMTFValues ( EState* s )
s->selector[nSelectors] = bt;
nSelectors++;
- /*--
+ /*--
Increment the symbol frequencies for the selected table.
--*/
if (nGroups == 6 && 50 == ge-gs+1) {
@@ -482,7 +482,7 @@ void sendMTFValues ( EState* s )
gs = ge+1;
}
if (s->verbosity >= 3) {
- VPrintf2 ( " pass %d: size is %d, grp uses are ",
+ VPrintf2 ( " pass %d: size is %d, grp uses are ",
iter+1, totc/8 );
for (t = 0; t < nGroups; t++)
VPrintf1 ( "%d ", fave[t] );
@@ -493,7 +493,7 @@ void sendMTFValues ( EState* s )
Recompute the tables based on the accumulated frequencies.
--*/
for (t = 0; t < nGroups; t++)
- BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]),
+ BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]),
alphaSize, 20 );
}
@@ -533,19 +533,19 @@ void sendMTFValues ( EState* s )
}
AssertH ( !(maxLen > 20), 3004 );
AssertH ( !(minLen < 1), 3005 );
- BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]),
+ BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]),
minLen, maxLen, alphaSize );
}
/*--- Transmit the mapping table. ---*/
- {
+ {
Bool inUse16[16];
for (i = 0; i < 16; i++) {
inUse16[i] = False;
for (j = 0; j < 16; j++)
if (s->inUse[i * 16 + j]) inUse16[i] = True;
}
-
+
nBytes = s->numZ;
for (i = 0; i < 16; i++)
if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0);
@@ -556,7 +556,7 @@ void sendMTFValues ( EState* s )
if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0);
}
- if (s->verbosity >= 3)
+ if (s->verbosity >= 3)
VPrintf1( " bytes: mapping %d, ", s->numZ-nBytes );
}
@@ -564,7 +564,7 @@ void sendMTFValues ( EState* s )
nBytes = s->numZ;
bsW ( s, 3, nGroups );
bsW ( s, 15, nSelectors );
- for (i = 0; i < nSelectors; i++) {
+ for (i = 0; i < nSelectors; i++) {
for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1);
bsW(s,1,0);
}
@@ -593,14 +593,14 @@ void sendMTFValues ( EState* s )
gs = 0;
while (True) {
if (gs >= s->nMTF) break;
- ge = gs + BZ_G_SIZE - 1;
+ ge = gs + BZ_G_SIZE - 1;
if (ge >= s->nMTF) ge = s->nMTF-1;
AssertH ( s->selector[selCtr] < nGroups, 3006 );
if (nGroups == 6 && 50 == ge-gs+1) {
/*--- fast track the common case ---*/
UInt16 mtfv_i;
- UChar* s_len_sel_selCtr
+ UChar* s_len_sel_selCtr
= &(s->len[s->selector[selCtr]][0]);
Int32* s_code_sel_selCtr
= &(s->code[s->selector[selCtr]][0]);
@@ -627,7 +627,7 @@ void sendMTFValues ( EState* s )
} else {
/*--- slow version which correctly handles all situations ---*/
for (i = gs; i <= ge; i++) {
- bsW ( s,
+ bsW ( s,
s->len [s->selector[selCtr]] [mtfv[i]],
s->code [s->selector[selCtr]] [mtfv[i]] );
}
@@ -682,8 +682,8 @@ void BZ2_compressBlock ( EState* s, Bool is_last_block )
/*-- Now the block's CRC, so it is in a known place. --*/
bsPutUInt32 ( s, s->blockCRC );
- /*--
- Now a single bit indicating (non-)randomisation.
+ /*--
+ Now a single bit indicating (non-)randomisation.
As of version 0.9.5, we use a better sorting algorithm
which makes randomisation unnecessary. So always set
the randomised bit to 'no'. Of course, the decoder
diff --git a/src/cmd/bzip2/lib/crctable.c b/src/cmd/bzip2/lib/crctable.c
index db1eb93f8..efd1f8fb2 100644
--- a/src/cmd/bzip2/lib/crctable.c
+++ b/src/cmd/bzip2/lib/crctable.c
@@ -17,16 +17,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
diff --git a/src/cmd/bzip2/lib/decompress.c b/src/cmd/bzip2/lib/decompress.c
index 734bfee7b..e9f8a59d5 100644
--- a/src/cmd/bzip2/lib/decompress.c
+++ b/src/cmd/bzip2/lib/decompress.c
@@ -17,16 +17,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -169,7 +169,7 @@ Int32 BZ2_decompress ( DState* s )
Int32 N;
Int32 curr;
Int32 zt;
- Int32 zn;
+ Int32 zn;
Int32 zvec;
Int32 zj;
Int32 gSel;
@@ -223,7 +223,7 @@ Int32 BZ2_decompress ( DState* s )
N = s->save_N;
curr = s->save_curr;
zt = s->save_zt;
- zn = s->save_zn;
+ zn = s->save_zn;
zvec = s->save_zvec;
zj = s->save_zj;
gSel = s->save_gSel;
@@ -246,14 +246,14 @@ Int32 BZ2_decompress ( DState* s )
if (uc != 'h') RETURN(BZ_DATA_ERROR_MAGIC);
GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8)
- if (s->blockSize100k < '1' ||
+ if (s->blockSize100k < '1' ||
s->blockSize100k > '9') RETURN(BZ_DATA_ERROR_MAGIC);
s->blockSize100k -= '0';
if (s->smallDecompress) {
s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
- s->ll4 = BZALLOC(
- ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
+ s->ll4 = BZALLOC(
+ ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
);
if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
} else {
@@ -279,7 +279,7 @@ Int32 BZ2_decompress ( DState* s )
s->currBlockNo++;
if (s->verbosity >= 2)
VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo );
-
+
s->storedBlockCRC = 0;
GET_UCHAR(BZ_X_BCRC_1, uc);
s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
@@ -302,14 +302,14 @@ Int32 BZ2_decompress ( DState* s )
if (s->origPtr < 0)
RETURN(BZ_DATA_ERROR);
- if (s->origPtr > 10 + 100000*s->blockSize100k)
+ if (s->origPtr > 10 + 100000*s->blockSize100k)
RETURN(BZ_DATA_ERROR);
/*--- Receive the mapping table ---*/
for (i = 0; i < 16; i++) {
GET_BIT(BZ_X_MAPPING_1, uc);
- if (uc == 1)
- s->inUse16[i] = True; else
+ if (uc == 1)
+ s->inUse16[i] = True; else
s->inUse16[i] = False;
}
@@ -345,7 +345,7 @@ Int32 BZ2_decompress ( DState* s )
{
UChar pos[BZ_N_GROUPS], tmp, v;
for (v = 0; v < nGroups; v++) pos[v] = v;
-
+
for (i = 0; i < nSelectors; i++) {
v = s->selectorMtf[i];
tmp = pos[v];
@@ -378,10 +378,10 @@ Int32 BZ2_decompress ( DState* s )
if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
if (s->len[t][i] < minLen) minLen = s->len[t][i];
}
- BZ2_hbCreateDecodeTables (
- &(s->limit[t][0]),
- &(s->base[t][0]),
- &(s->perm[t][0]),
+ BZ2_hbCreateDecodeTables (
+ &(s->limit[t][0]),
+ &(s->base[t][0]),
+ &(s->perm[t][0]),
&(s->len[t][0]),
minLen, maxLen, alphaSize
);
@@ -473,23 +473,23 @@ Int32 BZ2_decompress ( DState* s )
s->mtfa[(z)-3] = s->mtfa[(z)-4];
nn -= 4;
}
- while (nn > 0) {
- s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--;
+ while (nn > 0) {
+ s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--;
};
s->mtfa[pp] = uc;
- } else {
+ } else {
/* general case */
lno = nn / MTFL_SIZE;
off = nn % MTFL_SIZE;
pp = s->mtfbase[lno] + off;
uc = s->mtfa[pp];
- while (pp > s->mtfbase[lno]) {
- s->mtfa[pp] = s->mtfa[pp-1]; pp--;
+ while (pp > s->mtfbase[lno]) {
+ s->mtfa[pp] = s->mtfa[pp-1]; pp--;
};
s->mtfbase[lno]++;
while (lno > 0) {
s->mtfbase[lno]--;
- s->mtfa[s->mtfbase[lno]]
+ s->mtfa[s->mtfbase[lno]]
= s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1];
lno--;
}
@@ -565,7 +565,7 @@ Int32 BZ2_decompress ( DState* s )
if (s->blockRandomised) {
BZ_RAND_INIT_MASK;
BZ_GET_SMALL(s->k0); s->nblock_used++;
- BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
+ BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
} else {
BZ_GET_SMALL(s->k0); s->nblock_used++;
}
@@ -584,7 +584,7 @@ Int32 BZ2_decompress ( DState* s )
if (s->blockRandomised) {
BZ_RAND_INIT_MASK;
BZ_GET_FAST(s->k0); s->nblock_used++;
- BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
+ BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
} else {
BZ_GET_FAST(s->k0); s->nblock_used++;
}
@@ -653,7 +653,7 @@ Int32 BZ2_decompress ( DState* s )
s->save_gBase = gBase;
s->save_gPerm = gPerm;
- return retVal;
+ return retVal;
}
diff --git a/src/cmd/bzip2/lib/huffman.c b/src/cmd/bzip2/lib/huffman.c
index 9cad09706..9388ef213 100644
--- a/src/cmd/bzip2/lib/huffman.c
+++ b/src/cmd/bzip2/lib/huffman.c
@@ -17,16 +17,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -102,7 +102,7 @@
/*---------------------------------------------------*/
-void BZ2_hbMakeCodeLengths ( UChar *len,
+void BZ2_hbMakeCodeLengths ( UChar *len,
Int32 *freq,
Int32 alphaSize,
Int32 maxLen )
@@ -116,7 +116,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len,
Int32 heap [ BZ_MAX_ALPHA_SIZE + 2 ];
Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ];
- Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ];
+ Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ];
for (i = 0; i < alphaSize; i++)
weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
@@ -138,7 +138,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len,
}
AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 );
-
+
while (nHeap > 1) {
n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
@@ -161,7 +161,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len,
len[i-1] = j;
if (j > maxLen) tooLong = True;
}
-
+
if (! tooLong) break;
for (i = 1; i < alphaSize; i++) {
diff --git a/src/cmd/bzip2/lib/os.h b/src/cmd/bzip2/lib/os.h
index aa196a878..1236e5d58 100644
--- a/src/cmd/bzip2/lib/os.h
+++ b/src/cmd/bzip2/lib/os.h
@@ -76,7 +76,7 @@ typedef int Int32;
typedef unsigned int UInt32;
typedef short Int16;
typedef unsigned short UInt16;
-
+
#define True ((Bool)1)
#define False ((Bool)0)
@@ -85,4 +85,3 @@ typedef unsigned short UInt16;
Only here to avoid probs with 64-bit platforms.
--*/
typedef int IntNative;
-
diff --git a/src/cmd/bzip2/lib/randtable.c b/src/cmd/bzip2/lib/randtable.c
index 2ab1e952d..c6d70773a 100644
--- a/src/cmd/bzip2/lib/randtable.c
+++ b/src/cmd/bzip2/lib/randtable.c
@@ -17,16 +17,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@@ -64,58 +64,58 @@
/*---------------------------------------------*/
-Int32 BZ2_rNums[512] = {
- 619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
- 985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
- 733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
- 419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
- 878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
- 862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
- 150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
- 170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
- 73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
- 909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
- 641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
- 161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
- 382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
- 98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
- 227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
- 469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
- 184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
- 715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
- 951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
- 652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
- 645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
- 609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
- 653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
- 411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
- 170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
- 857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
- 669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
- 944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
- 344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
- 897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
- 433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
- 686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
- 946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
- 978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
- 680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
- 707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
- 297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
- 134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
- 343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
- 140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
- 170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
- 369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
- 804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
- 896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
- 661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
- 768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
- 61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
- 372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
- 780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
- 920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
- 645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
+Int32 BZ2_rNums[512] = {
+ 619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
+ 985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
+ 733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
+ 419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
+ 878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
+ 862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
+ 150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
+ 170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
+ 73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
+ 909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
+ 641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
+ 161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
+ 382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
+ 98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
+ 227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
+ 469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
+ 184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
+ 715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
+ 951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
+ 652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
+ 645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
+ 609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
+ 653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
+ 411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
+ 170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
+ 857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
+ 669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
+ 944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
+ 344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
+ 897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
+ 433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
+ 686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
+ 946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
+ 978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
+ 680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
+ 707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
+ 297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
+ 134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
+ 343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
+ 140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
+ 170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
+ 369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
+ 804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
+ 896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
+ 661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
+ 768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
+ 61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
+ 372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
+ 780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
+ 920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
+ 645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
936, 638
};
diff --git a/src/cmd/bzip2/lib/unix.h b/src/cmd/bzip2/lib/unix.h
index e47197b82..797ba1187 100644
--- a/src/cmd/bzip2/lib/unix.h
+++ b/src/cmd/bzip2/lib/unix.h
@@ -5,4 +5,3 @@
#include
#include
#include
-
diff --git a/src/cmd/calendar.c b/src/cmd/calendar.c
index 778c76082..c936a286a 100644
--- a/src/cmd/calendar.c
+++ b/src/cmd/calendar.c
@@ -99,7 +99,7 @@ main(int argc, char *argv[])
exits("");
}
-char *months[] =
+char *months[] =
{
"january",
"february",
@@ -146,7 +146,7 @@ dates(Date **last, Tm *tm)
first = alloc(sizeof(Date));
if(*last)
(*last)->next = first;
- first->p = regcomp(buf);
+ first->p = regcomp(buf);
if (matchyear)
snprint(buf, sizeof buf,
@@ -159,7 +159,7 @@ dates(Date **last, Tm *tm)
if(debug)
print("%s\n", buf);
nd = alloc(sizeof(Date));
- nd->p = regcomp(buf);
+ nd->p = regcomp(buf);
nd->next = 0;
first->next = nd;
*last = nd;
diff --git a/src/cmd/cat.c b/src/cmd/cat.c
index ac5888979..8fdcf4ec3 100644
--- a/src/cmd/cat.c
+++ b/src/cmd/cat.c
@@ -33,4 +33,3 @@ main(int argc, char *argv[])
}
exits(0);
}
-
diff --git a/src/cmd/cb/cb.c b/src/cmd/cb/cb.c
index 0b2458965..ebca5cc5e 100644
--- a/src/cmd/cb/cb.c
+++ b/src/cmd/cb/cb.c
@@ -29,7 +29,7 @@ main(int argc, char *argv[])
maxleng -= (maxleng + 5)/10;
continue;
default:
- fprint(2, "cb: illegal option %c\n", *argv[1]);
+ fprint(2, "cb: illegal option %c\n", (*argv)[1]);
exits("boom");
}
}
@@ -354,7 +354,7 @@ work(void){
continue;
}
}
- else if (lbegin == 0 || p > string)
+ else if (lbegin == 0 || p > string)
if(strict)
putch(c,NO);
else putch(c,YES);
@@ -969,7 +969,7 @@ getnext(int must){
if(nlct++ > 2)goto done;
}
puttmp(c,1);
- star:
+star:
if(puttmp((c=Bgetc(input)),1) == '/'){
beg = tp;
puttmp((c=Bgetc(input)),1);
@@ -1007,7 +1007,7 @@ clearif(struct indent *cl)
int i;
for(i=0;iifc[i] = 0;
}
-char
+char
puttmp(char c, int keep)
{
if(tp < &temp[TEMP-120])
diff --git a/src/cmd/cmp.c b/src/cmd/cmp.c
index 4f69e1815..f06f12a51 100644
--- a/src/cmd/cmp.c
+++ b/src/cmd/cmp.c
@@ -88,7 +88,7 @@ main(int argc, char *argv[])
print("%6lld 0x%.2x 0x%.2x\n", nc+i, *p, *q);
}
}
- }
+ }
if(Lflag)
for(p = b1s; p < b1e;)
if(*p++ == '\n')
diff --git a/src/cmd/compress/compress.c b/src/cmd/compress/compress.c
new file mode 100755
index 000000000..808762cad
--- /dev/null
+++ b/src/cmd/compress/compress.c
@@ -0,0 +1,1274 @@
+/*
+ * compress - File compression ala IEEE Computer, June 1984.
+ *
+ * Algorithm from "A Technique for High Performance Data Compression",
+ * Terry A. Welch, IEEE Computer Vol 17, No 6 (June 1984), pp 8-19.
+ *
+ * Usage: compress [-dfvc] [-b bits] [file ...]
+ * Inputs:
+ * -b: limit the max number of bits/code.
+ * -c: write output on stdout, don't remove original.
+ * -d: decompress instead.
+ * -f: Forces output file to be generated, even if one already
+ * exists, and even if no space is saved by compressing.
+ * If -f is not used, the user will be prompted if stdin is
+ * a tty, otherwise, the output file will not be overwritten.
+ * -v: Write compression statistics
+ *
+ * file ...: Files to be compressed. If none specified, stdin is used.
+ * Outputs:
+ * file.Z: Compressed form of file with same mode, owner, and utimes
+ * or stdout (if stdin used as input)
+ *
+ * Assumptions:
+ * When filenames are given, replaces with the compressed version
+ * (.Z suffix) only if the file decreases in size.
+ * Algorithm:
+ * Modified Lempel-Ziv method (LZW). Basically finds common
+ * substrings and replaces them with a variable size code. This is
+ * deterministic, and can be done on the fly. Thus, the decompression
+ * procedure needs no input table, but tracks the way the table was built.
+
+ * Authors: Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas)
+ * Jim McKie (decvax!mcvax!jim)
+ * Steve Davies (decvax!vax135!petsd!peora!srd)
+ * Ken Turkowski (decvax!decwrl!turtlevax!ken)
+ * James A. Woods (decvax!ihnp4!ames!jaw)
+ * Joe Orost (decvax!vax135!petsd!joe)
+ */
+
+#ifndef USED
+# define USED(x) if(x);else
+#endif
+
+#define _PLAN9_SOURCE
+#define _BSD_EXTENSION
+#define _POSIX_SOURCE
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define min(a,b) ((a>b) ? b : a)
+
+#define BITS 16
+#define HSIZE 69001 /* 95% occupancy */
+
+/*
+ * a code_int must be able to hold 2**BITS values of type int, and also -1
+ */
+typedef long code_int;
+typedef long count_int;
+
+static char rcs_ident[] = "$Header: compress.c,v 4.0 85/07/30 12:50:00 joe Release $";
+
+uchar magic_header[] = { 0x1F, 0x9D }; /* 1F 9D */
+
+/* Defines for third byte of header */
+#define BIT_MASK 0x1f
+#define BLOCK_MASK 0x80
+/* Masks 0x40 and 0x20 are free. I think 0x20 should mean that there is
+ a fourth header byte (for expansion).
+*/
+#define INIT_BITS 9 /* initial number of bits/code */
+
+#define ARGVAL() (*++(*argv) || (--argc && *++argv))
+
+int n_bits; /* number of bits/code */
+int maxbits = BITS; /* user settable max # bits/code */
+code_int maxcode; /* maximum code, given n_bits */
+code_int maxmaxcode = 1 << BITS; /* should NEVER generate this code */
+
+#define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
+
+count_int htab[HSIZE];
+ushort codetab[HSIZE];
+
+#define htabof(i) htab[i]
+#define codetabof(i) codetab[i]
+
+code_int hsize = HSIZE; /* for dynamic table sizing */
+count_int fsize;
+
+/*
+ * To save much memory, we overlay the table used by compress() with those
+ * used by decompress(). The tab_prefix table is the same size and type
+ * as the codetab. The tab_suffix table needs 2**BITS characters. We
+ * get this from the beginning of htab. The output stack uses the rest
+ * of htab, and contains characters. There is plenty of room for any
+ * possible stack (stack used to be 8000 characters).
+ */
+
+#define tab_prefixof(i) codetabof(i)
+#define tab_suffixof(i) ((uchar *)(htab))[i]
+#define de_stack ((uchar *)&tab_suffixof(1< 0; argc--, argv++) {
+ if (**argv == '-') { /* A flag argument */
+ while (*++(*argv)) { /* Process all flags in this arg */
+ switch (**argv) {
+ case 'C':
+ block_compress = 0;
+ break;
+#ifdef DEBUG
+ case 'D':
+ debug = 1;
+ break;
+ case 'V':
+ verbose = 1;
+ version();
+ break;
+#else
+ case 'V':
+ version();
+ break;
+#endif
+ case 'b':
+ if (!ARGVAL()) {
+ fprintf(stderr, "Missing maxbits\n");
+ Usage();
+ exit(1);
+ }
+ maxbits = atoi(*argv);
+ goto nextarg;
+ case 'c':
+ zcat_flg = 1;
+ break;
+ case 'd':
+ do_decomp = 1;
+ break;
+ case 'f':
+ case 'F':
+ overwrite = 1;
+ force = 1;
+ break;
+ case 'n':
+ nomagic = 1;
+ break;
+ case 'q':
+ quiet = 1;
+ break;
+ case 'v':
+ quiet = 0;
+ break;
+ default:
+ fprintf(stderr, "Unknown flag: '%c'; ", **argv);
+ Usage();
+ exit(1);
+ }
+ }
+ } else { /* Input file name */
+ *fileptr++ = *argv; /* Build input file list */
+ *fileptr = NULL;
+ /* process nextarg; */
+ }
+nextarg:
+ continue;
+ }
+
+ if(maxbits < INIT_BITS) maxbits = INIT_BITS;
+ if (maxbits > BITS) maxbits = BITS;
+ maxmaxcode = 1 << maxbits;
+
+ if (*filelist != NULL) {
+ for (fileptr = filelist; *fileptr; fileptr++) {
+ exit_stat = 0;
+ if (do_decomp != 0) { /* DECOMPRESSION */
+ /* Check for .Z suffix */
+ if (strcmp(*fileptr + strlen(*fileptr) - 2, ".Z") != 0) {
+ /* No .Z: tack one on */
+ strcpy(tempname, *fileptr);
+ strcat(tempname, ".Z");
+ *fileptr = tempname;
+ }
+ /* Open input file */
+ if ((freopen(*fileptr, "r", stdin)) == NULL) {
+ perror(*fileptr);
+ continue;
+ }
+ /* Check the magic number */
+ if (nomagic == 0) {
+ if ((getchar() != (magic_header[0] & 0xFF))
+ || (getchar() != (magic_header[1] & 0xFF))) {
+ fprintf(stderr, "%s: not in compressed format\n",
+ *fileptr);
+ continue;
+ }
+ maxbits = getchar(); /* set -b from file */
+ block_compress = maxbits & BLOCK_MASK;
+ maxbits &= BIT_MASK;
+ maxmaxcode = 1 << maxbits;
+ if(maxbits > BITS) {
+ fprintf(stderr,
+ "%s: compressed with %d bits, can only handle %d bits\n",
+ *fileptr, maxbits, BITS);
+ continue;
+ }
+ }
+ /* Generate output filename */
+ strcpy(ofname, *fileptr);
+ ofname[strlen(*fileptr) - 2] = '\0'; /* Strip off .Z */
+ } else { /* COMPRESSION */
+ if (strcmp(*fileptr + strlen(*fileptr) - 2, ".Z") == 0) {
+ fprintf(stderr,
+ "%s: already has .Z suffix -- no change\n",
+ *fileptr);
+ continue;
+ }
+ /* Open input file */
+ if ((freopen(*fileptr, "r", stdin)) == NULL) {
+ perror(*fileptr);
+ continue;
+ }
+ (void) stat(*fileptr, &statbuf);
+ fsize = (long) statbuf.st_size;
+ /*
+ * tune hash table size for small files -- ad hoc,
+ * but the sizes match earlier #defines, which
+ * serve as upper bounds on the number of output codes.
+ */
+ hsize = HSIZE;
+ if (fsize < (1 << 12))
+ hsize = min(5003, HSIZE);
+ else if (fsize < (1 << 13))
+ hsize = min(9001, HSIZE);
+ else if (fsize < (1 << 14))
+ hsize = min (18013, HSIZE);
+ else if (fsize < (1 << 15))
+ hsize = min (35023, HSIZE);
+ else if (fsize < 47000)
+ hsize = min (50021, HSIZE);
+
+ /* Generate output filename */
+ strcpy(ofname, *fileptr);
+#ifndef BSD4_2
+ if ((cp=strrchr(ofname,'/')) != NULL)
+ cp++;
+ else
+ cp = ofname;
+ /*
+ *** changed 12 to 25; should be NAMELEN-3, but I don't want
+ * to fight the headers. ehg 5 Nov 92 **
+ */
+ if (strlen(cp) > 25) {
+ fprintf(stderr, "%s: filename too long to tack on .Z\n",
+ cp);
+ continue;
+ }
+#endif
+ strcat(ofname, ".Z");
+ }
+ /* Check for overwrite of existing file */
+ if (overwrite == 0 && zcat_flg == 0 &&
+ stat(ofname, &statbuf) == 0) {
+ char response[2];
+
+ response[0] = 'n';
+ fprintf(stderr, "%s already exists;", ofname);
+ if (foreground()) {
+ fprintf(stderr,
+ " do you wish to overwrite %s (y or n)? ",
+ ofname);
+ fflush(stderr);
+ (void) read(2, response, 2);
+ while (response[1] != '\n')
+ if (read(2, response+1, 1) < 0) {
+ /* Ack! */
+ perror("stderr");
+ break;
+ }
+ }
+ if (response[0] != 'y') {
+ fprintf(stderr, "\tnot overwritten\n");
+ continue;
+ }
+ }
+ if(zcat_flg == 0) { /* Open output file */
+ if (freopen(ofname, "w", stdout) == NULL) {
+ perror(ofname);
+ continue;
+ }
+ if(!quiet)
+ fprintf(stderr, "%s: ", *fileptr);
+ }
+
+ /* Actually do the compression/decompression */
+ if (do_decomp == 0)
+ compress();
+#ifndef DEBUG
+ else
+ decompress();
+#else
+ else if (debug == 0)
+ decompress();
+ else
+ printcodes();
+ if (verbose)
+ dump_tab();
+#endif /* DEBUG */
+ if(zcat_flg == 0) {
+ copystat(*fileptr, ofname); /* Copy stats */
+ if (exit_stat == 1 || !quiet)
+ putc('\n', stderr);
+ }
+ }
+ } else { /* Standard input */
+ if (do_decomp == 0) {
+ compress();
+#ifdef DEBUG
+ if(verbose)
+ dump_tab();
+#endif
+ if(!quiet)
+ putc('\n', stderr);
+ } else {
+ /* Check the magic number */
+ if (nomagic == 0) {
+ if ((getchar()!=(magic_header[0] & 0xFF))
+ || (getchar()!=(magic_header[1] & 0xFF))) {
+ fprintf(stderr, "stdin: not in compressed format\n");
+ exit(1);
+ }
+ maxbits = getchar(); /* set -b from file */
+ block_compress = maxbits & BLOCK_MASK;
+ maxbits &= BIT_MASK;
+ maxmaxcode = 1 << maxbits;
+ fsize = 100000; /* assume stdin large for USERMEM */
+ if(maxbits > BITS) {
+ fprintf(stderr,
+ "stdin: compressed with %d bits, can only handle %d bits\n",
+ maxbits, BITS);
+ exit(1);
+ }
+ }
+#ifndef DEBUG
+ decompress();
+#else
+ if (debug == 0)
+ decompress();
+ else
+ printcodes();
+ if (verbose)
+ dump_tab();
+#endif /* DEBUG */
+ }
+ }
+ exit(exit_stat);
+ return 0;
+}
+
+static int offset;
+long in_count = 1; /* length of input */
+long bytes_out; /* length of compressed output */
+long out_count = 0; /* # of codes output (for debugging) */
+
+/*
+ * compress stdin to stdout
+ *
+ * Algorithm: use open addressing double hashing (no chaining) on the
+ * prefix code / next character combination. We do a variant of Knuth's
+ * algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
+ * secondary probe. Here, the modular division first probe is gives way
+ * to a faster exclusive-or manipulation. Also do block compression with
+ * an adaptive reset, whereby the code table is cleared when the compression
+ * ratio decreases, but after the table fills. The variable-length output
+ * codes are re-sized at this point, and a special CLEAR code is generated
+ * for the decompressor. Late addition: construct the table according to
+ * file size for noticeable speed improvement on small files. Please direct
+ * questions about this implementation to ames!jaw.
+ */
+void
+compress(void)
+{
+ code_int ent, hsize_reg;
+ code_int i;
+ int c, disp, hshift;
+ long fcode;
+
+ if (nomagic == 0) {
+ putchar(magic_header[0]);
+ putchar(magic_header[1]);
+ putchar((char)(maxbits | block_compress));
+ if(ferror(stdout))
+ writeerr();
+ }
+ offset = 0;
+ bytes_out = 3; /* includes 3-byte header mojo */
+ out_count = 0;
+ clear_flg = 0;
+ ratio = 0;
+ in_count = 1;
+ checkpoint = CHECK_GAP;
+ maxcode = MAXCODE(n_bits = INIT_BITS);
+ free_ent = (block_compress? FIRST: 256);
+
+ ent = getchar ();
+
+ hshift = 0;
+ for (fcode = (long)hsize; fcode < 65536L; fcode *= 2)
+ hshift++;
+ hshift = 8 - hshift; /* set hash code range bound */
+
+ hsize_reg = hsize;
+ cl_hash( (count_int) hsize_reg); /* clear hash table */
+
+ while ((c = getchar()) != EOF) {
+ in_count++;
+ fcode = (long) (((long) c << maxbits) + ent);
+ i = ((c << hshift) ^ ent); /* xor hashing */
+
+ if (htabof (i) == fcode) {
+ ent = codetabof(i);
+ continue;
+ } else if ((long)htabof(i) < 0 ) /* empty slot */
+ goto nomatch;
+ disp = hsize_reg - i; /* secondary hash (after G. Knott) */
+ if (i == 0)
+ disp = 1;
+probe:
+ if ((i -= disp) < 0)
+ i += hsize_reg;
+
+ if (htabof (i) == fcode) {
+ ent = codetabof(i);
+ continue;
+ }
+ if ((long)htabof(i) > 0)
+ goto probe;
+nomatch:
+ output((code_int)ent);
+ out_count++;
+ ent = c;
+ if (free_ent < maxmaxcode) {
+ codetabof(i) = free_ent++; /* code -> hashtable */
+ htabof(i) = fcode;
+ } else if ((count_int)in_count >= checkpoint && block_compress)
+ cl_block ();
+ }
+ /*
+ * Put out the final code.
+ */
+ output( (code_int)ent );
+ out_count++;
+ output( (code_int)-1 );
+
+ /*
+ * Print out stats on stderr
+ */
+ if(zcat_flg == 0 && !quiet) {
+#ifdef DEBUG
+ fprintf( stderr,
+ "%ld chars in, %ld codes (%ld bytes) out, compression factor: ",
+ in_count, out_count, bytes_out );
+ prratio( stderr, in_count, bytes_out );
+ fprintf( stderr, "\n");
+ fprintf( stderr, "\tCompression as in compact: " );
+ prratio( stderr, in_count-bytes_out, in_count );
+ fprintf( stderr, "\n");
+ fprintf( stderr, "\tLargest code (of last block) was %d (%d bits)\n",
+ free_ent - 1, n_bits );
+#else /* !DEBUG */
+ fprintf( stderr, "Compression: " );
+ prratio( stderr, in_count-bytes_out, in_count );
+#endif /* DEBUG */
+ }
+ if(bytes_out > in_count) /* exit(2) if no savings */
+ exit_stat = 2;
+}
+
+/*
+ * TAG( output )
+ *
+ * Output the given code.
+ * Inputs:
+ * code: A n_bits-bit integer. If == -1, then EOF. This assumes
+ * that n_bits =< (long)wordsize - 1.
+ * Outputs:
+ * Outputs code to the file.
+ * Assumptions:
+ * Chars are 8 bits long.
+ * Algorithm:
+ * Maintain a BITS character long buffer (so that 8 codes will
+ * fit in it exactly). When the buffer fills up empty it and start over.
+ */
+
+static char buf[BITS];
+
+uchar lmask[9] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00};
+uchar rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
+
+void
+output( code )
+code_int code;
+{
+#ifdef DEBUG
+ static int col = 0;
+#endif
+ int r_off = offset, bits= n_bits;
+ char *bp = buf;
+
+#ifdef DEBUG
+ if (verbose)
+ fprintf(stderr, "%5d%c", code,
+ (col+=6) >= 74? (col = 0, '\n'): ' ');
+#endif
+ if (code >= 0) {
+ /*
+ * byte/bit numbering on the VAX is simulated by the
+ * following code
+ */
+ /*
+ * Get to the first byte.
+ */
+ bp += (r_off >> 3);
+ r_off &= 7;
+ /*
+ * Since code is always >= 8 bits, only need to mask the first
+ * hunk on the left.
+ */
+ *bp = (*bp & rmask[r_off]) | (code << r_off) & lmask[r_off];
+ bp++;
+ bits -= 8 - r_off;
+ code >>= 8 - r_off;
+ /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
+ if ( bits >= 8 ) {
+ *bp++ = code;
+ code >>= 8;
+ bits -= 8;
+ }
+ /* Last bits. */
+ if(bits)
+ *bp = code;
+
+ offset += n_bits;
+ if ( offset == (n_bits << 3) ) {
+ bp = buf;
+ bits = n_bits;
+ bytes_out += bits;
+ do {
+ putchar(*bp++);
+ } while(--bits);
+ offset = 0;
+ }
+
+ /*
+ * If the next entry is going to be too big for the code size,
+ * then increase it, if possible.
+ */
+ if ( free_ent > maxcode || (clear_flg > 0)) {
+ /*
+ * Write the whole buffer, because the input side won't
+ * discover the size increase until after it has read it.
+ */
+ if ( offset > 0 ) {
+ if( fwrite( buf, 1, n_bits, stdout ) != n_bits)
+ writeerr();
+ bytes_out += n_bits;
+ }
+ offset = 0;
+
+ if ( clear_flg ) {
+ maxcode = MAXCODE (n_bits = INIT_BITS);
+ clear_flg = 0;
+ } else {
+ n_bits++;
+ if ( n_bits == maxbits )
+ maxcode = maxmaxcode;
+ else
+ maxcode = MAXCODE(n_bits);
+ }
+#ifdef DEBUG
+ if ( debug ) {
+ fprintf(stderr,
+ "\nChange to %d bits\n", n_bits);
+ col = 0;
+ }
+#endif
+ }
+ } else {
+ /*
+ * At EOF, write the rest of the buffer.
+ */
+ if ( offset > 0 )
+ fwrite( buf, 1, (offset + 7) / 8, stdout );
+ bytes_out += (offset + 7) / 8;
+ offset = 0;
+ fflush( stdout );
+#ifdef DEBUG
+ if ( verbose )
+ fprintf( stderr, "\n" );
+#endif
+ if( ferror( stdout ) )
+ writeerr();
+ }
+}
+
+/*
+ * Decompress stdin to stdout. This routine adapts to the codes in the
+ * file building the "string" table on-the-fly; requiring no table to
+ * be stored in the compressed file. The tables used herein are shared
+ * with those of the compress() routine. See the definitions above.
+ */
+void
+decompress(void)
+{
+ int finchar;
+ code_int code, oldcode, incode;
+ uchar *stackp;
+
+ /*
+ * As above, initialize the first 256 entries in the table.
+ */
+ maxcode = MAXCODE(n_bits = INIT_BITS);
+ for (code = 255; code >= 0; code--) {
+ tab_prefixof(code) = 0;
+ tab_suffixof(code) = (uchar)code;
+ }
+ free_ent = (block_compress? FIRST: 256);
+
+ finchar = oldcode = getcode();
+ if(oldcode == -1) /* EOF already? */
+ return; /* Get out of here */
+ putchar((char)finchar); /* first code must be 8 bits = char */
+ if(ferror(stdout)) /* Crash if can't write */
+ writeerr();
+ stackp = de_stack;
+
+ while ((code = getcode()) > -1) {
+ if ((code == CLEAR) && block_compress) {
+ for (code = 255; code >= 0; code--)
+ tab_prefixof(code) = 0;
+ clear_flg = 1;
+ free_ent = FIRST - 1;
+ if ((code = getcode()) == -1) /* O, untimely death! */
+ break;
+ }
+ incode = code;
+ /*
+ * Special case for KwKwK string.
+ */
+ if (code >= free_ent) {
+ *stackp++ = finchar;
+ code = oldcode;
+ }
+
+ /*
+ * Generate output characters in reverse order
+ */
+ while (code >= 256) {
+ *stackp++ = tab_suffixof(code);
+ code = tab_prefixof(code);
+ }
+ *stackp++ = finchar = tab_suffixof(code);
+
+ /*
+ * And put them out in forward order
+ */
+ do {
+ putchar(*--stackp);
+ } while (stackp > de_stack);
+
+ /*
+ * Generate the new entry.
+ */
+ if ( (code=free_ent) < maxmaxcode ) {
+ tab_prefixof(code) = (ushort)oldcode;
+ tab_suffixof(code) = finchar;
+ free_ent = code+1;
+ }
+ /*
+ * Remember previous code.
+ */
+ oldcode = incode;
+ }
+ fflush(stdout);
+ if(ferror(stdout))
+ writeerr();
+}
+
+/*
+ * TAG( getcode )
+ *
+ * Read one code from the standard input. If EOF, return -1.
+ * Inputs:
+ * stdin
+ * Outputs:
+ * code or -1 is returned.
+ */
+code_int
+getcode()
+{
+ int r_off, bits;
+ code_int code;
+ static int offset = 0, size = 0;
+ static uchar buf[BITS];
+ uchar *bp = buf;
+
+ if ( clear_flg > 0 || offset >= size || free_ent > maxcode ) {
+ /*
+ * If the next entry will be too big for the current code
+ * size, then we must increase the size. This implies reading
+ * a new buffer full, too.
+ */
+ if ( free_ent > maxcode ) {
+ n_bits++;
+ if ( n_bits == maxbits )
+ maxcode = maxmaxcode; /* won't get any bigger now */
+ else
+ maxcode = MAXCODE(n_bits);
+ }
+ if ( clear_flg > 0) {
+ maxcode = MAXCODE(n_bits = INIT_BITS);
+ clear_flg = 0;
+ }
+ size = fread(buf, 1, n_bits, stdin);
+ if (size <= 0)
+ return -1; /* end of file */
+ offset = 0;
+ /* Round size down to integral number of codes */
+ size = (size << 3) - (n_bits - 1);
+ }
+ r_off = offset;
+ bits = n_bits;
+ /*
+ * Get to the first byte.
+ */
+ bp += (r_off >> 3);
+ r_off &= 7;
+ /* Get first part (low order bits) */
+ code = (*bp++ >> r_off);
+ bits -= (8 - r_off);
+ r_off = 8 - r_off; /* now, offset into code word */
+ /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
+ if (bits >= 8) {
+ code |= *bp++ << r_off;
+ r_off += 8;
+ bits -= 8;
+ }
+ /* high order bits. */
+ code |= (*bp & rmask[bits]) << r_off;
+ offset += n_bits;
+ return code;
+}
+
+#ifdef DEBUG
+printcodes()
+{
+ /*
+ * Just print out codes from input file. For debugging.
+ */
+ code_int code;
+ int col = 0, bits;
+
+ bits = n_bits = INIT_BITS;
+ maxcode = MAXCODE(n_bits);
+ free_ent = ((block_compress) ? FIRST : 256 );
+ while ( ( code = getcode() ) >= 0 ) {
+ if ( (code == CLEAR) && block_compress ) {
+ free_ent = FIRST - 1;
+ clear_flg = 1;
+ }
+ else if ( free_ent < maxmaxcode )
+ free_ent++;
+ if ( bits != n_bits ) {
+ fprintf(stderr, "\nChange to %d bits\n", n_bits );
+ bits = n_bits;
+ col = 0;
+ }
+ fprintf(stderr, "%5d%c", code, (col+=6) >= 74 ? (col = 0, '\n') : ' ' );
+ }
+ putc( '\n', stderr );
+ exit( 0 );
+}
+
+code_int sorttab[1<= 0) {
+ sorttab[codetabof(i)] = i;
+ }
+ }
+ first = block_compress ? FIRST : 256;
+ for(i = first; i < free_ent; i++) {
+ fprintf(stderr, "%5d: \"", i);
+ de_stack[--stack_top] = '\n';
+ de_stack[--stack_top] = '"';
+ stack_top = in_stack((htabof(sorttab[i])>>maxbits)&0xff,
+ stack_top);
+ for(ent=htabof(sorttab[i]) & ((1< 256;
+ ent=htabof(sorttab[ent]) & ((1<> maxbits,
+ stack_top);
+ }
+ stack_top = in_stack(ent, stack_top);
+ fwrite( &de_stack[stack_top], 1, STACK_SIZE-stack_top, stderr);
+ stack_top = STACK_SIZE;
+ }
+ } else if(!debug) { /* decompressing */
+
+ for ( i = 0; i < free_ent; i++ ) {
+ ent = i;
+ c = tab_suffixof(ent);
+ if ( isascii(c) && isprint(c) )
+ fprintf( stderr, "%5d: %5d/'%c' \"",
+ ent, tab_prefixof(ent), c );
+ else
+ fprintf( stderr, "%5d: %5d/\\%03o \"",
+ ent, tab_prefixof(ent), c );
+ de_stack[--stack_top] = '\n';
+ de_stack[--stack_top] = '"';
+ for ( ; ent != NULL;
+ ent = (ent >= FIRST ? tab_prefixof(ent) : NULL) ) {
+ stack_top = in_stack(tab_suffixof(ent), stack_top);
+ }
+ fwrite( &de_stack[stack_top], 1, STACK_SIZE - stack_top, stderr );
+ stack_top = STACK_SIZE;
+ }
+ }
+}
+
+int
+in_stack(int c, int stack_top)
+{
+ if ( (isascii(c) && isprint(c) && c != '\\') || c == ' ' ) {
+ de_stack[--stack_top] = c;
+ } else {
+ switch( c ) {
+ case '\n': de_stack[--stack_top] = 'n'; break;
+ case '\t': de_stack[--stack_top] = 't'; break;
+ case '\b': de_stack[--stack_top] = 'b'; break;
+ case '\f': de_stack[--stack_top] = 'f'; break;
+ case '\r': de_stack[--stack_top] = 'r'; break;
+ case '\\': de_stack[--stack_top] = '\\'; break;
+ default:
+ de_stack[--stack_top] = '0' + c % 8;
+ de_stack[--stack_top] = '0' + (c / 8) % 8;
+ de_stack[--stack_top] = '0' + c / 64;
+ break;
+ }
+ de_stack[--stack_top] = '\\';
+ }
+ return stack_top;
+}
+#endif /* DEBUG */
+
+void
+writeerr(void)
+{
+ perror(ofname);
+ unlink(ofname);
+ exit(1);
+}
+
+void
+copystat(ifname, ofname)
+char *ifname, *ofname;
+{
+ int mode;
+ time_t timep[2]; /* should be struct utimbuf */
+ struct stat statbuf;
+
+ fclose(stdout);
+ if (stat(ifname, &statbuf)) { /* Get stat on input file */
+ perror(ifname);
+ return;
+ }
+ if (!S_ISREG(statbuf.st_mode)) {
+ if (quiet)
+ fprintf(stderr, "%s: ", ifname);
+ fprintf(stderr, " -- not a regular file: unchanged");
+ exit_stat = 1;
+ } else if (exit_stat == 2 && !force) {
+ /* No compression: remove file.Z */
+ if (!quiet)
+ fprintf(stderr, " -- file unchanged");
+ } else { /* Successful Compression */
+ exit_stat = 0;
+ mode = statbuf.st_mode & 0777;
+ if (chmod(ofname, mode)) /* Copy modes */
+ perror(ofname);
+ /* Copy ownership */
+ chown(ofname, statbuf.st_uid, statbuf.st_gid);
+ timep[0] = statbuf.st_atime;
+ timep[1] = statbuf.st_mtime;
+ /* Update last accessed and modified times */
+ utime(ofname, (struct utimbuf *)timep);
+// if (unlink(ifname)) /* Remove input file */
+// perror(ifname);
+ return; /* success */
+ }
+
+ /* Unsuccessful return -- one of the tests failed */
+ if (unlink(ofname))
+ perror(ofname);
+}
+
+/*
+ * This routine returns 1 if we are running in the foreground and stderr
+ * is a tty.
+ */
+int
+foreground(void)
+{
+ if(bgnd_flag) /* background? */
+ return 0;
+ else /* foreground */
+ return isatty(2); /* and stderr is a tty */
+}
+
+void
+onintr(int x)
+{
+ USED(x);
+ unlink(ofname);
+ exit(1);
+}
+
+void
+oops(int x) /* wild pointer -- assume bad input */
+{
+ USED(x);
+ if (do_decomp == 1)
+ fprintf(stderr, "uncompress: corrupt input\n");
+ unlink(ofname);
+ exit(1);
+}
+
+void
+cl_block(void) /* table clear for block compress */
+{
+ long rat;
+
+ checkpoint = in_count + CHECK_GAP;
+#ifdef DEBUG
+ if ( debug ) {
+ fprintf ( stderr, "count: %ld, ratio: ", in_count );
+ prratio ( stderr, in_count, bytes_out );
+ fprintf ( stderr, "\n");
+ }
+#endif /* DEBUG */
+
+ if (in_count > 0x007fffff) { /* shift will overflow */
+ rat = bytes_out >> 8;
+ if (rat == 0) /* Don't divide by zero */
+ rat = 0x7fffffff;
+ else
+ rat = in_count / rat;
+ } else
+ rat = (in_count << 8) / bytes_out; /* 8 fractional bits */
+ if (rat > ratio)
+ ratio = rat;
+ else {
+ ratio = 0;
+#ifdef DEBUG
+ if (verbose)
+ dump_tab(); /* dump string table */
+#endif
+ cl_hash((count_int)hsize);
+ free_ent = FIRST;
+ clear_flg = 1;
+ output((code_int)CLEAR);
+#ifdef DEBUG
+ if (debug)
+ fprintf(stderr, "clear\n");
+#endif /* DEBUG */
+ }
+}
+
+void
+cl_hash(count_int hsize) /* reset code table */
+{
+ count_int *htab_p = htab+hsize;
+ long i;
+ long m1 = -1;
+
+ i = hsize - 16;
+ do { /* might use Sys V memset(3) here */
+ *(htab_p-16) = m1;
+ *(htab_p-15) = m1;
+ *(htab_p-14) = m1;
+ *(htab_p-13) = m1;
+ *(htab_p-12) = m1;
+ *(htab_p-11) = m1;
+ *(htab_p-10) = m1;
+ *(htab_p-9) = m1;
+ *(htab_p-8) = m1;
+ *(htab_p-7) = m1;
+ *(htab_p-6) = m1;
+ *(htab_p-5) = m1;
+ *(htab_p-4) = m1;
+ *(htab_p-3) = m1;
+ *(htab_p-2) = m1;
+ *(htab_p-1) = m1;
+ htab_p -= 16;
+ } while ((i -= 16) >= 0);
+ for ( i += 16; i > 0; i-- )
+ *--htab_p = m1;
+}
+
+void
+prratio(stream, num, den)
+FILE *stream;
+long num, den;
+{
+ int q; /* Doesn't need to be long */
+
+ if(num > 214748L) /* 2147483647/10000 */
+ q = num / (den / 10000L);
+ else
+ q = 10000L * num / den; /* Long calculations, though */
+ if (q < 0) {
+ putc('-', stream);
+ q = -q;
+ }
+ fprintf(stream, "%d.%02d%%", q / 100, q % 100);
+}
+
+void
+version(void)
+{
+ fprintf(stderr, "%s\n", rcs_ident);
+ fprintf(stderr, "Options: ");
+#ifdef DEBUG
+ fprintf(stderr, "DEBUG, ");
+#endif
+#ifdef BSD4_2
+ fprintf(stderr, "BSD4_2, ");
+#endif
+ fprintf(stderr, "BITS = %d\n", BITS);
+}
+
+/*
+ * The revision-history novel:
+ *
+ * $Header: compress.c,v 4.0 85/07/30 12:50:00 joe Release $
+ * $Log: compress.c,v $
+ * Revision 4.0 85/07/30 12:50:00 joe
+ * Removed ferror() calls in output routine on every output except first.
+ * Prepared for release to the world.
+ *
+ * Revision 3.6 85/07/04 01:22:21 joe
+ * Remove much wasted storage by overlaying hash table with the tables
+ * used by decompress: tab_suffix[1<putc] and
+ * added signal catcher [plus beef in writeerr()] to delete effluvia.
+ *
+ * Revision 2.0 84/08/28 22:00:00 petsd!joe
+ * Add check for foreground before prompting user. Insert maxbits into
+ * compressed file. Force file being uncompressed to end with ".Z".
+ * Added "-c" flag and "zcat". Prepared for release.
+ *
+ * Revision 1.10 84/08/24 18:28:00 turtlevax!ken
+ * Will only compress regular files (no directories), added a magic number
+ * header (plus an undocumented -n flag to handle old files without headers),
+ * added -f flag to force overwriting of possibly existing destination file,
+ * otherwise the user is prompted for a response. Will tack on a .Z to a
+ * filename if it doesn't have one when decompressing. Will only replace
+ * file if it was compressed.
+ *
+ * Revision 1.9 84/08/16 17:28:00 turtlevax!ken
+ * Removed scanargs(), getopt(), added .Z extension and unlimited number of
+ * filenames to compress. Flags may be clustered (-Ddvb12) or separated
+ * (-D -d -v -b 12), or combination thereof. Modes and other status is
+ * copied with copystat(). -O bug for 4.2 seems to have disappeared with
+ * 1.8.
+ *
+ * Revision 1.8 84/08/09 23:15:00 joe
+ * Made it compatible with vax version, installed jim's fixes/enhancements
+ *
+ * Revision 1.6 84/08/01 22:08:00 joe
+ * Sped up algorithm significantly by sorting the compress chain.
+ *
+ * Revision 1.5 84/07/13 13:11:00 srd
+ * Added C version of vax asm routines. Changed structure to arrays to
+ * save much memory. Do unsigned compares where possible (faster on
+ * Perkin-Elmer)
+ *
+ * Revision 1.4 84/07/05 03:11:11 thomas
+ * Clean up the code a little and lint it. (Lint complains about all
+ * the regs used in the asm, but I'm not going to "fix" this.)
+ *
+ * Revision 1.3 84/07/05 02:06:54 thomas
+ * Minor fixes.
+ *
+ * Revision 1.2 84/07/05 00:27:27 thomas
+ * Add variable bit length output.
+ */
diff --git a/src/cmd/compress/mkfile b/src/cmd/compress/mkfile
new file mode 100755
index 000000000..5af1958dc
--- /dev/null
+++ b/src/cmd/compress/mkfile
@@ -0,0 +1,15 @@
+<$PLAN9/src/mkhdr
+
+TARG=\
+ compress \
+ zcat \
+ uncompress
+
+$O.uncompress:Q: $O.compress
+ cp $prereq $target
+
+$O.zcat:Q: $O.compress
+ cp $prereq $target
+
+<$PLAN9/src/mkmany
+
diff --git a/src/cmd/date.c b/src/cmd/date.c
index fc2ec5af5..272f5ec8c 100644
--- a/src/cmd/date.c
+++ b/src/cmd/date.c
@@ -25,6 +25,6 @@ main(int argc, char *argv[])
print("%s", asctime(gmtime(now)));
else
print("%s", ctime(now));
-
+
exits(0);
}
diff --git a/src/cmd/db/command.c b/src/cmd/db/command.c
index 55ed02a82..b89318e80 100644
--- a/src/cmd/db/command.c
+++ b/src/cmd/db/command.c
@@ -76,26 +76,26 @@ command(char *buf, int defcom)
break;
case '>':
- lastcom = savecom;
+ lastcom = savecom;
savc=rdc();
if (reg=regname(savc))
rput(correg, reg, dot);
- else
+ else
error("bad variable");
break;
case '!':
lastcom=savecom;
- shell();
+ shell();
break;
case '$':
lastcom=savecom;
- printdollar(nextchar());
+ printdollar(nextchar());
break;
case ':':
- if (!executing) {
+ if (!executing) {
executing=TRUE;
subpcs(nextchar());
executing=FALSE;
@@ -107,7 +107,7 @@ command(char *buf, int defcom)
prints(DBNAME);
break;
- default:
+ default:
error("bad command");
}
flushbuf();
@@ -159,21 +159,21 @@ acommand(int pc)
{
case 'm':
if (eqcom)
- error(BADEQ);
+ error(BADEQ);
cmdmap(map);
break;
case 'L':
case 'l':
if (eqcom)
- error(BADEQ);
+ error(BADEQ);
cmdsrc(lastc, map);
break;
case 'W':
case 'w':
if (eqcom)
- error(BADEQ);
+ error(BADEQ);
cmdwrite(lastc, map);
break;
@@ -199,10 +199,10 @@ cmdsrc(int c, Map *map)
else
dotinc = 2;
savdot=dot;
- expr(1);
+ expr(1);
locval=expv;
if (expr(0))
- locmsk=expv;
+ locmsk=expv;
else
locmsk = ~0;
if (c == 'L')
@@ -211,8 +211,8 @@ cmdsrc(int c, Map *map)
else
while ((ret = get2(map, dot, &sh)) > 0 && (sh&locmsk) != locval)
dot = inkdot(dotinc);
- if (ret < 0) {
- dot=savdot;
+ if (ret < 0) {
+ dot=savdot;
error("%r");
}
symoff(buf, 512, dot, CANY);
@@ -235,7 +235,7 @@ cmdwrite(int wcom, Map *map)
expr(1);
pass = 0;
do {
- pass++;
+ pass++;
savdot=dot;
exform(1, 1, format, map, 0, pass);
dot=savdot;
@@ -247,7 +247,7 @@ cmdwrite(int wcom, Map *map)
error(badwrite);
}
savdot=dot;
- dprint("=%8t");
+ dprint("=%8t");
exform(1, 0, format, map, 0, pass);
newline();
} while (expr(0));
@@ -305,7 +305,7 @@ shell(void)
}
break;
}
- prints("!");
+ prints("!");
reread();
}
}
diff --git a/src/cmd/db/expr.c b/src/cmd/db/expr.c
index 74c9319a7..72b8c9067 100644
--- a/src/cmd/db/expr.c
+++ b/src/cmd/db/expr.c
@@ -186,7 +186,7 @@ item(int a)
return 1;
}
error("bad file location");
- } else if (symchar(0)) {
+ } else if (symchar(0)) {
readsym(gsym);
if (lastc=='.') {
readchar(); /* ugh */
@@ -212,7 +212,7 @@ item(int a)
reread();
} else if (getnum(readchar)) {
;
- } else if (lastc=='.') {
+ } else if (lastc=='.') {
readchar();
if (!symchar(0) && lastc != '.') {
expv = dot;
@@ -228,7 +228,7 @@ item(int a)
if (localaddr(cormap, correg, s.name, lsym, &u) < 0)
error("%r");
expv = u;
- }
+ }
reread();
} else if (lastc=='"') {
expv=ditto;
@@ -245,7 +245,7 @@ item(int a)
expv = ascval();
else if (a)
error("address expected");
- else {
+ else {
reread();
return(0);
}
diff --git a/src/cmd/db/input.c b/src/cmd/db/input.c
index 8cd091b01..bd97cd707 100644
--- a/src/cmd/db/input.c
+++ b/src/cmd/db/input.c
@@ -144,7 +144,7 @@ getformat(char *deformat)
*
* we handle this case specially because we have to look ahead
* at the token after the colon to decide if it is a file reference
- * or a colon-command with a symbol name prefix.
+ * or a colon-command with a symbol name prefix.
*/
int
diff --git a/src/cmd/db/output.c b/src/cmd/db/output.c
index 176cec285..db4d0fa25 100644
--- a/src/cmd/db/output.c
+++ b/src/cmd/db/output.c
@@ -77,7 +77,7 @@ iclose(int stack, int err)
infile = STDIN;
} else {
if (infile) {
- close(infile);
+ close(infile);
infile=STDIN;
}
if (ifiledepth > 0) {
diff --git a/src/cmd/db/pcs.c b/src/cmd/db/pcs.c
index b876f50ab..681819da6 100644
--- a/src/cmd/db/pcs.c
+++ b/src/cmd/db/pcs.c
@@ -29,7 +29,7 @@ subpcs(int modif)
switch (modif) {
/* delete breakpoint */
- case 'd':
+ case 'd':
case 'D':
if ((bk=scanbkpt(dot)) == 0)
error("no breakpoint set");
@@ -37,7 +37,7 @@ subpcs(int modif)
return;
/* set breakpoint */
- case 'b':
+ case 'b':
case 'B':
if (bk=scanbkpt(dot))
bk->flag=BKPTCLR;
@@ -80,7 +80,7 @@ subpcs(int modif)
return;
/* run program */
- case 'r':
+ case 'r':
case 'R':
endpcs();
setup();
@@ -88,7 +88,7 @@ subpcs(int modif)
break;
/* single step */
- case 's':
+ case 's':
if (pid == 0) {
setup();
loopcnt--;
@@ -119,8 +119,8 @@ subpcs(int modif)
loopcnt = 0;
break;
/* continue with optional note */
- case 'c':
- case 'C':
+ case 'c':
+ case 'C':
if (pid==0)
error(NOPCS);
runmode=CONTIN;
diff --git a/src/cmd/db/setup.c b/src/cmd/db/setup.c
index eaeb61f2b..15a196e11 100644
--- a/src/cmd/db/setup.c
+++ b/src/cmd/db/setup.c
@@ -100,15 +100,15 @@ cmdmap(Map *map)
/* textseg(expv, &fhdr); */
map->seg[i].base = expv;
} else
- error("Invalid base address");
+ error("Invalid base address");
if (expr(0))
map->seg[i].size = expv - map->seg[i].base;
else
- error("Invalid end address");
+ error("Invalid end address");
if (expr(0))
- map->seg[i].offset = expv;
+ map->seg[i].offset = expv;
else
- error("Invalid file offset");
+ error("Invalid file offset");
/*
if (rdc()=='?' && map == cormap) {
if (fcor)
diff --git a/src/cmd/deroff.c b/src/cmd/deroff.c
index 1b758efec..0ad083759 100644
--- a/src/cmd/deroff.c
+++ b/src/cmd/deroff.c
@@ -13,7 +13,7 @@
* Deroff follows .so and .nx commands, removes contents of macro
* definitions, equations (both .EQ ... .EN and $...$),
* Tbl command sequences, and Troff backslash vconstructions.
- *
+ *
* All input is through the C macro; the most recently read character is in c.
*/
@@ -37,7 +37,7 @@
#define C fC()
#define C1 fC1()
-#define SKIP while(C != '\n')
+#define SKIP while(C != '\n')
#define SKIP1 while(C1 != '\n')
#define SKIP_TO_COM SKIP;\
SKIP;\
@@ -211,7 +211,7 @@ skeqn(void)
c = C1;
else if(c == '"')
while(C1 != '"')
- if(c == '\\')
+ if(c == '\\')
C1;
if (msflag)
eqnflag = 1;
@@ -257,9 +257,9 @@ getfname(void)
Rune r;
Dir *dir;
struct chain
- {
- struct chain* nextp;
- char* datap;
+ {
+ struct chain* nextp;
+ char* datap;
} *q;
static struct chain *namechain= 0;
@@ -470,7 +470,7 @@ comline(void)
else
if(filesp==files && c1=='T' && (c2=='S' || c2=='C' || c2=='&')) {
if(msflag)
- stbl();
+ stbl();
else
tbl();
}
@@ -512,11 +512,11 @@ comline(void)
SKIP;
else
if(c1=='h' && c2=='w')
- SKIP;
+ SKIP;
else
if(msflag && c1 == 'T' && c2 == 'L') {
SKIP_TO_COM;
- goto comx;
+ goto comx;
}
else
if(msflag && c1=='N' && c2 == 'R')
@@ -526,17 +526,17 @@ comline(void)
if(mac==MM)SKIP;
else {
SKIP_TO_COM;
- goto comx;
+ goto comx;
}
} else
if(msflag && c1=='F' && c2=='S') {
SKIP_TO_COM;
- goto comx;
+ goto comx;
}
else
if(msflag && (c1=='S' || c1=='N') && c2=='H') {
SKIP_TO_COM;
- goto comx;
+ goto comx;
} else
if(c1 == 'U' && c2 == 'X') {
if(wordflag)
@@ -546,7 +546,7 @@ comline(void)
} else
if(msflag && c1=='O' && c2=='K') {
SKIP_TO_COM;
- goto comx;
+ goto comx;
} else
if(msflag && c1=='N' && c2=='D')
SKIP;
@@ -565,11 +565,11 @@ comline(void)
if(!msflag && c1=='P' && c2=='S') {
inpic();
} else
- if(msflag && (c1=='D' || c1=='N' || c1=='K'|| c1=='P') && c2=='S') {
- sdis(c1, 'E');
+ if(msflag && (c1=='D' || c1=='N' || c1=='K'|| c1=='P') && c2=='S') {
+ sdis(c1, 'E');
} else
- if(msflag && (c1 == 'K' && c2 == 'F')) {
- sdis(c1,'E');
+ if(msflag && (c1 == 'K' && c2 == 'F')) {
+ sdis(c1,'E');
} else
if(msflag && c1=='n' && c2=='f')
sdis('f','i');
@@ -601,8 +601,8 @@ void
macro(void)
{
if(msflag) {
- do {
- SKIP1;
+ do {
+ SKIP1;
} while(C1 != '.' || C1 != '.' || C1 == '.');
if(c != '\n')
SKIP;
@@ -660,7 +660,7 @@ sdis(char a1, char a2)
SKIP1;
} else
if(a1 == 'D' && c1 == 'E' && c2 == 'Q') {
- eqn();
+ eqn();
eqnf = 0;
} else
if(a1 == 'f') {
@@ -720,8 +720,8 @@ eqn(void)
Bputc(&bout, 'x');
Bputc(&bout, ' ');
if(last) {
- Bputc(&bout, last);
- Bputc(&bout, '\n');
+ Bputc(&bout, last);
+ Bputc(&bout, '\n');
}
}
return;
@@ -744,7 +744,7 @@ eqn(void)
dflg = 0;
}
if(c != '\n')
- while(C1 != '\n') {
+ while(C1 != '\n') {
if(chars[c] == PUNCT)
last = c;
else
@@ -762,7 +762,7 @@ backsl(void)
{
int bdelim;
-sw:
+sw:
switch(C1)
{
case '"':
diff --git a/src/cmd/devdraw/bigarrow.h b/src/cmd/devdraw/bigarrow.h
index a46f19a09..4bfe02450 100644
--- a/src/cmd/devdraw/bigarrow.h
+++ b/src/cmd/devdraw/bigarrow.h
@@ -1,11 +1,83 @@
-Cursor bigarrow = {
- {0, 0},
- {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC,
- 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF8, 0xFF, 0xFC,
- 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC,
- 0xF3, 0xF8, 0xF1, 0xF0, 0xE0, 0xE0, 0xC0, 0x40},
- {0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFC, 0x7F, 0xF0,
- 0x7F, 0xE0, 0x7F, 0xE0, 0x7F, 0xF0, 0x7F, 0xF8,
- 0x7F, 0xFC, 0x7F, 0xFE, 0x7F, 0xFC, 0x73, 0xF8,
- 0x61, 0xF0, 0x60, 0xE0, 0x40, 0x40, 0x00, 0x00},
+Cursor bigarrow = {
+ { -1, -1 },
+ { 0xFF, 0xFF, 0x80, 0x01, 0x80, 0x02, 0x80, 0x0C,
+ 0x80, 0x10, 0x80, 0x10, 0x80, 0x08, 0x80, 0x04,
+ 0x80, 0x02, 0x80, 0x01, 0x80, 0x02, 0x8C, 0x04,
+ 0x92, 0x08, 0x91, 0x10, 0xA0, 0xA0, 0xC0, 0x40,
+ },
+ { 0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFC, 0x7F, 0xF0,
+ 0x7F, 0xE0, 0x7F, 0xE0, 0x7F, 0xF0, 0x7F, 0xF8,
+ 0x7F, 0xFC, 0x7F, 0xFE, 0x7F, 0xFC, 0x73, 0xF8,
+ 0x61, 0xF0, 0x60, 0xE0, 0x40, 0x40, 0x00, 0x00,
+ },
+};
+
+Cursor2 bigarrow2 = {
+ { -2, -2 },
+ { 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xC0, 0x00, 0x00, 0x03,
+ 0xC0, 0x00, 0x00, 0x07,
+ 0xC0, 0x00, 0x00, 0x1E,
+ 0xC0, 0x00, 0x00, 0x3C,
+ 0xC0, 0x00, 0x00, 0xF0,
+ 0xC0, 0x00, 0x03, 0xE0,
+ 0xC0, 0x00, 0x0F, 0x80,
+ 0xC0, 0x00, 0x0E, 0x00,
+ 0xC0, 0x00, 0x07, 0x00,
+ 0xC0, 0x00, 0x03, 0x80,
+ 0xC0, 0x00, 0x01, 0xC0,
+ 0xC0, 0x00, 0x00, 0xE0,
+ 0xC0, 0x00, 0x00, 0x70,
+ 0xC0, 0x00, 0x00, 0x38,
+ 0xC0, 0x00, 0x00, 0x1C,
+ 0xC0, 0x00, 0x00, 0x0E,
+ 0xC0, 0x00, 0x00, 0x07,
+ 0xC0, 0x00, 0x00, 0x03,
+ 0xC0, 0xC0, 0x00, 0x07,
+ 0xC0, 0xE0, 0x00, 0x0E,
+ 0xC1, 0xF0, 0x00, 0x1C,
+ 0xC1, 0xB8, 0x00, 0x38,
+ 0xC3, 0x9C, 0x00, 0x70,
+ 0xC3, 0x0E, 0x00, 0xE0,
+ 0xC7, 0x07, 0x01, 0xC0,
+ 0xCE, 0x03, 0x83, 0x80,
+ 0xCC, 0x01, 0xC7, 0x00,
+ 0xDC, 0x00, 0xEE, 0x00,
+ 0xF8, 0x00, 0x7C, 0x00,
+ 0xF0, 0x00, 0x38, 0x00,
+ },
+ { 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x3F, 0xFF, 0xFF, 0xFC,
+ 0x3F, 0xFF, 0xFF, 0xF8,
+ 0x3F, 0xFF, 0xFF, 0xE0,
+ 0x3F, 0xFF, 0xFF, 0xC0,
+ 0x3F, 0xFF, 0xFF, 0x00,
+ 0x3F, 0xFF, 0xFC, 0x00,
+ 0x3F, 0xFF, 0xF0, 0x00,
+ 0x3F, 0xFF, 0xF0, 0x00,
+ 0x3F, 0xFF, 0xF8, 0x00,
+ 0x3F, 0xFF, 0xFC, 0x00,
+ 0x3F, 0xFF, 0xFE, 0x00,
+ 0x3F, 0xFF, 0xFF, 0x00,
+ 0x3F, 0xFF, 0xFF, 0x80,
+ 0x3F, 0xFF, 0xFF, 0xC0,
+ 0x3F, 0xFF, 0xFF, 0xE0,
+ 0x3F, 0xFF, 0xFF, 0xF0,
+ 0x3F, 0xFF, 0xFF, 0xF8,
+ 0x3F, 0xFF, 0xFF, 0xFC,
+ 0x3F, 0x3F, 0xFF, 0xF8,
+ 0x3F, 0x1F, 0xFF, 0xF0,
+ 0x3E, 0x0F, 0xFF, 0xE0,
+ 0x3E, 0x07, 0xFF, 0xC0,
+ 0x3C, 0x03, 0xFF, 0x80,
+ 0x3C, 0x01, 0xFF, 0x00,
+ 0x38, 0x00, 0xFE, 0x00,
+ 0x30, 0x00, 0x7C, 0x00,
+ 0x30, 0x00, 0x38, 0x00,
+ 0x20, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ }
};
diff --git a/src/cmd/devdraw/cocoa-screen.h b/src/cmd/devdraw/cocoa-screen.h
deleted file mode 100644
index 3c4c94c5c..000000000
--- a/src/cmd/devdraw/cocoa-screen.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#define setcursor dsetcursor
-
-Memimage *attachscreen(char*, char*);
-void setmouse(Point);
-void setcursor(Cursor*);
-void setlabel(char*);
-char* getsnarf(void);
-void putsnarf(char*);
-void topwin(void);
-
-void mousetrack(int, int, int, uint);
-void keystroke(int);
-void kicklabel(char*);
-
-void servep9p(void);
-void zlock(void);
-void zunlock(void);
-
-Rectangle mouserect;
-int mouseresized;
diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m
deleted file mode 100644
index e7296e44d..000000000
--- a/src/cmd/devdraw/cocoa-screen.m
+++ /dev/null
@@ -1,1658 +0,0 @@
-/*
- * Cocoa's event loop must be in main thread.
- *
- * Unless otherwise stated, all coordinate systems
- * are bottom-left-based.
- */
-
-#define Cursor OSXCursor
-#define Point OSXPoint
-#define Rect OSXRect
-
-#import
-
-#undef Cursor
-#undef Point
-#undef Rect
-
-#include
-#include
-#include "cocoa-thread.h"
-#include
-#include
-#include
-#include
-#include "cocoa-screen.h"
-#include "osx-keycodes.h"
-#include "devdraw.h"
-#include "bigarrow.h"
-#include "glendapng.h"
-
-// Use non-deprecated names.
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
-#define NSKeyDown NSEventTypeKeyDown
-#define NSShiftKeyMask NSEventModifierFlagShift
-#define NSAlternateKeyMask NSEventModifierFlagOption
-#define NSCommandKeyMask NSEventModifierFlagCommand
-#define NSResizableWindowMask NSWindowStyleMaskResizable
-#define NSLeftMouseDown NSEventTypeLeftMouseDown
-#define NSLeftMouseUp NSEventTypeLeftMouseUp
-#define NSRightMouseDown NSEventTypeRightMouseDown
-#define NSRightMouseUp NSEventTypeRightMouseUp
-#define NSOtherMouseDown NSEventTypeOtherMouseDown
-#define NSOtherMouseUp NSEventTypeOtherMouseUp
-#define NSScrollWheel NSEventTypeScrollWheel
-#define NSMouseMoved NSEventTypeMouseMoved
-#define NSLeftMouseDragged NSEventTypeLeftMouseDragged
-#define NSRightMouseDragged NSEventTypeRightMouseDragged
-#define NSOtherMouseDragged NSEventTypeOtherMouseDragged
-#define NSCompositeCopy NSCompositingOperationCopy
-#define NSCompositeSourceIn NSCompositingOperationSourceIn
-#define NSFlagsChanged NSEventTypeFlagsChanged
-#define NSTitledWindowMask NSWindowStyleMaskTitled
-#define NSClosableWindowMask NSWindowStyleMaskClosable
-#define NSMiniaturizableWindowMask NSWindowStyleMaskMiniaturizable
-#define NSBorderlessWindowMask NSWindowStyleMaskBorderless
-#endif
-
-AUTOFRAMEWORK(Cocoa)
-
-#define LOG if(0)NSLog
-#define panic sysfatal
-
-int usegestures = 0;
-int useliveresizing = 0;
-int useoldfullscreen = 0;
-int usebigarrow = 0;
-
-static void setprocname(const char*);
-
-/*
- * By default, devdraw uses retina displays.
- * Set devdrawretina=0 in the environment to override.
- */
-int devdrawretina = 1;
-
-void
-usage(void)
-{
- fprint(2, "usage: devdraw (don't run directly)\n");
- threadexitsall("usage");
-}
-
-@interface appdelegate : NSObject @end
-
-NSObject *myApp;
-
-void
-threadmain(int argc, char **argv)
-{
- char *envvar;
-
- /*
- * Move the protocol off stdin/stdout so that
- * any inadvertent prints don't screw things up.
- */
- dup(0,3);
- dup(1,4);
- close(0);
- close(1);
- open("/dev/null", OREAD);
- open("/dev/null", OWRITE);
-
- ARGBEGIN{
- case 'D': /* for good ps -a listings */
- break;
- case 'f':
- useoldfullscreen = 1;
- break;
- case 'g':
- usegestures = 1;
- break;
- case 'b':
- usebigarrow = 1;
- break;
- default:
- usage();
- }ARGEND
-
- setprocname(argv0);
-
- if (envvar = getenv("devdrawretina"))
- devdrawretina = atoi(envvar) > 0;
-
- if(OSX_VERSION < 100700)
- [NSAutoreleasePool new];
-
- [NSApplication sharedApplication];
- [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
- myApp = [appdelegate new];
- [NSApp setDelegate:myApp];
- [NSApp run];
-}
-
-#define WIN win.ofs[win.isofs]
-
-struct
-{
- NSWindow *ofs[2]; /* ofs[1] for old fullscreen; ofs[0] else */
- int isofs;
- int isnfs;
- NSView *content;
- NSBitmapImageRep *img;
- int needimg;
- int deferflush;
- NSCursor *cursor;
- CGFloat topointscale;
- CGFloat topixelscale;
-} win;
-
-struct
-{
- NSCursor *bigarrow;
- int kbuttons;
- int mbuttons;
- NSPoint mpos;
- int mscroll;
- int willactivate;
-} in;
-
-static void hidebars(int);
-static void flushimg(NSRect);
-static void autoflushwin(int);
-static void flushwin(void);
-static void followzoombutton(NSRect);
-static void getmousepos(void);
-static void makeicon(void);
-static void makemenu(void);
-static void makewin(char*);
-static void sendmouse(void);
-static void kicklabel0(char*);
-static void setcursor0(Cursor*);
-static void togglefs(void);
-static void acceptresizing(int);
-
-static NSCursor* makecursor(Cursor*);
-
-static NSSize winsizepixels();
-static NSSize winsizepoints();
-static NSRect scalerect(NSRect, CGFloat);
-static NSPoint scalepoint(NSPoint, CGFloat);
-static NSRect dilate(NSRect);
-
-@implementation appdelegate
-- (void)applicationDidFinishLaunching:(id)arg
-{
- in.bigarrow = makecursor(&bigarrow);
- makeicon();
- makemenu();
- [NSApplication
- detachDrawingThread:@selector(callservep9p:)
- toTarget:[self class] withObject:nil];
-}
-
-- (void)windowDidBecomeKey:(id)arg
-{
- getmousepos();
- sendmouse();
-}
-- (void)windowDidResize:(id)arg
-{
- getmousepos();
- sendmouse();
-}
-- (void)windowWillStartLiveResize:(id)arg
-{
- if(useliveresizing == 0)
- [win.content setHidden:YES];
-}
-- (void)windowDidEndLiveResize:(id)arg
-{
- if(useliveresizing == 0)
- [win.content setHidden:NO];
-}
-- (void)windowDidChangeScreen:(id)arg
-{
- if(win.isnfs || win.isofs)
- hidebars(1);
- [win.ofs[1] setFrame:[[WIN screen] frame] display:YES];
-}
-- (BOOL)windowShouldZoom:(id)arg toFrame:(NSRect)r
-{
- followzoombutton(r);
- return YES;
-}
-- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(id)arg
-{
- return YES;
-}
-- (void)applicationDidBecomeActive:(id)arg{ in.willactivate = 0;}
-- (void)windowWillEnterFullScreen:(id)arg{ acceptresizing(1);}
-- (void)windowDidEnterFullScreen:(id)arg{ win.isnfs = 1; hidebars(1);}
-- (void)windowWillExitFullScreen:(id)arg{ win.isnfs = 0; hidebars(0);}
-- (void)windowDidExitFullScreen:(id)arg
-{
- NSButton *b;
-
- b = [WIN standardWindowButton:NSWindowMiniaturizeButton];
-
- if([b isEnabled] == 0){
- [b setEnabled:YES];
- hidebars(0);
- }
-}
-- (void)windowWillClose:(id)arg
-{
- autoflushwin(0); /* can crash otherwise */
-}
-
-+ (void)callservep9p:(id)arg
-{
- servep9p();
- [NSApp terminate:self];
-}
-- (void)plumbmanual:(id)arg
-{
- if(fork() != 0)
- return;
- execl("plumb", "plumb", "devdraw(1)", nil);
-}
-+ (void)callflushwin:(id)arg{ flushwin();}
-- (void)calltogglefs:(id)arg{ togglefs();}
-
-+ (void)callflushimg:(NSValue*)v{ flushimg([v rectValue]);}
-+ (void)callmakewin:(NSValue*)v{ makewin([v pointerValue]);}
-+ (void)callsetcursor0:(NSValue*)v{ setcursor0([v pointerValue]);}
-+ (void)callkicklabel0:(NSValue*)v{ kicklabel0([v pointerValue]);}
-@end
-
-static Memimage* initimg(void);
-
-Memimage*
-attachscreen(char *label, char *winsize)
-{
- static int first = 1;
-
- if(first)
- first = 0;
- else
- panic("attachscreen called twice");
-
- if(label == nil)
- label = "gnot a label";
- if(strcmp(label, "page") == 0)
- useliveresizing = 1;
-
- /*
- * Create window in main thread, else no cursor
- * change while resizing.
- */
- [appdelegate
- performSelectorOnMainThread:@selector(callmakewin:)
- withObject:[NSValue valueWithPointer:winsize]
- waitUntilDone:YES];
-// makewin(winsize);
-
- kicklabel(label);
- return initimg();
-}
-
-@interface appwin : NSWindow @end
-@interface contentview : NSView @end
-
-@implementation appwin
-- (NSTimeInterval)animationResizeTime:(NSRect)r
-{
- return 0;
-}
-- (BOOL)canBecomeKeyWindow
-{
- return YES; /* else no keyboard for old fullscreen */
-}
-- (void)makeKeyAndOrderFront:(id)arg
-{
- LOG(@"makeKeyAndOrderFront");
-
- autoflushwin(1);
- [win.content setHidden:NO];
- [super makeKeyAndOrderFront:arg];
-}
-- (void)miniaturize:(id)arg
-{
- [super miniaturize:arg];
- [NSApp hide:nil];
-
- [win.content setHidden:YES];
- autoflushwin(0);
-}
-- (void)deminiaturize:(id)arg
-{
- autoflushwin(1);
- [win.content setHidden:NO];
- [super deminiaturize:arg];
-}
-
-- (NSDragOperation)draggingEntered:(id)arg
-{
- NSPasteboard *b;
- NSDragOperation op;
-
- op = [arg draggingSourceOperationMask];
- b = [arg draggingPasteboard];
-
- if([[b types] containsObject:NSFilenamesPboardType])
- if(op&NSDragOperationLink)
- return NSDragOperationLink;
-
- return NSDragOperationNone;
-}
-
-- (BOOL)performDragOperation:(id)arg
-{
- NSPasteboard *b;
- NSArray *files;
- int i, n;
-
- b = [arg draggingPasteboard];
- if(![[b types] containsObject:NSFilenamesPboardType])
- return NO;
-
- files = [b propertyListForType:NSFilenamesPboardType];
- n = [files count];
- for(i=0; i= 100700
- [w setCollectionBehavior:
- NSWindowCollectionBehaviorFullScreenPrimary];
-#endif
- [w setContentMinSize:NSMakeSize(128,128)];
-
- [w registerForDraggedTypes:[NSArray arrayWithObjects:
- NSFilenamesPboardType, nil]];
-
- win.ofs[0] = w;
- win.ofs[1] = [[appwin alloc]
- initWithContentRect:sr
- styleMask:NSBorderlessWindowMask
- backing:NSBackingStoreBuffered defer:YES];
- for(i=0; i<2; i++){
- [win.ofs[i] setAcceptsMouseMovedEvents:YES];
- [win.ofs[i] setDelegate:myApp];
- [win.ofs[i] setDisplaysWhenScreenProfileChanges:NO];
- }
- win.isofs = 0;
- win.content = [contentview new];
- [WIN setContentView:win.content];
-
- topwin();
-}
-
-static Memimage*
-initimg(void)
-{
- Memimage *i;
- NSSize size, ptsize;
- Rectangle r;
-
- size = winsizepixels();
- LOG(@"initimg %.0f %.0f", size.width, size.height);
-
- r = Rect(0, 0, size.width, size.height);
- i = allocmemimage(r, XBGR32);
- if(i == nil)
- panic("allocmemimage: %r");
- if(i->data == nil)
- panic("i->data == nil");
-
- win.img = [[NSBitmapImageRep alloc]
- initWithBitmapDataPlanes:&i->data->bdata
- pixelsWide:Dx(r)
- pixelsHigh:Dy(r)
- bitsPerSample:8
- samplesPerPixel:3
- hasAlpha:NO
- isPlanar:NO
- colorSpaceName:NSDeviceRGBColorSpace
- bytesPerRow:bytesperline(r, 32)
- bitsPerPixel:32];
- ptsize = winsizepoints();
- [win.img setSize: ptsize];
- win.topixelscale = size.width / ptsize.width;
- win.topointscale = 1.0f / win.topixelscale;
-
- // NOTE: This is not really the display DPI.
- // On retina, topixelscale is 2; otherwise it is 1.
- // This formula gives us 220 for retina, 110 otherwise.
- // That's not quite right but it's close to correct.
- // http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density#Apple
- displaydpi = win.topixelscale * 110;
-
- return i;
-}
-
-void
-resizeimg(void)
-{
- [win.img release];
- _drawreplacescreenimage(initimg());
-
- mouseresized = 1;
- sendmouse();
-}
-
-static void
-waitimg(int msec)
-{
- NSDate *limit;
- int n;
-
- win.needimg = 1;
- win.deferflush = 0;
-
- n = 0;
- limit = [NSDate dateWithTimeIntervalSinceNow:msec/1000.0];
- do{
- [[NSRunLoop currentRunLoop]
- runMode:@"waiting image"
- beforeDate:limit];
- n++;
- }while(win.needimg && [(NSDate*)[NSDate date] compare:limit]<0);
-
- win.deferflush = win.needimg;
-
- LOG(@"waitimg %s (%d loop)", win.needimg?"defer":"ok", n);
-}
-
-void
-_flushmemscreen(Rectangle r)
-{
- static int n;
- NSRect rect;
-
- LOG(@"_flushmemscreen");
-
- if(n==0){
- n++;
- return; /* to skip useless white init rect */
- }else
- if(n==1){
- [WIN performSelectorOnMainThread:
- @selector(makeKeyAndOrderFront:)
- withObject:nil
- waitUntilDone:NO];
- n++;
- }else
- if([win.content canDraw] == 0)
- return;
-
- rect = NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r));
- [appdelegate
- performSelectorOnMainThread:@selector(callflushimg:)
- withObject:[NSValue valueWithRect:rect]
- waitUntilDone:YES
- modes:[NSArray arrayWithObjects:
- NSRunLoopCommonModes,
- @"waiting image", nil]];
-}
-
-static void drawimg(NSRect, uint);
-static void drawresizehandle(void);
-
-enum
-{
- Pixel = 1,
- Barsize = 4*Pixel,
- Cornersize = 3*Pixel,
- Handlesize = 3*Barsize + 1*Pixel,
-};
-
-/*
- * |rect| is in pixel coordinates.
- */
-static void
-flushimg(NSRect rect)
-{
- NSRect dr, r;
-
- if([win.content lockFocusIfCanDraw] == 0)
- return;
-
- if(win.needimg){
- if(!NSEqualSizes(scalerect(rect, win.topointscale).size, [win.img size])){
- LOG(@"flushimg reject %.0f %.0f",
- rect.size.width, rect.size.height);
- [win.content unlockFocus];
- return;
- }
- win.needimg = 0;
- }else
- win.deferflush = 1;
-
- LOG(@"flushimg ok %.0f %.0f", rect.size.width, rect.size.height);
-
- /*
- * Unless we are inside "drawRect", we have to round
- * the corners ourselves, if this is the custom.
- * "NSCompositeSourceIn" can do that, but we don't
- * apply it to the whole rectangle, because this
- * slows down trackpad scrolling considerably in
- * Acme.
- */
- r = [win.content bounds];
- rect = dilate(scalerect(rect, win.topointscale));
- r.size.height -= Cornersize;
- dr = NSIntersectionRect(r, rect);
- LOG(@"r %.0f %.0f %.0f %.0f", r.origin.x, r.origin.y, rect.size.width, rect.size.height);
- LOG(@"rect in points %f %f %.0f %.0f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
- LOG(@"dr in points %f %f %.0f %.0f", dr.origin.x, dr.origin.y, dr.size.width, dr.size.height);
- drawimg(dr, NSCompositeCopy);
-
- r.origin.y = r.size.height;
- r.size = NSMakeSize(Cornersize, Cornersize);
- dr = NSIntersectionRect(r, rect);
- drawimg(dr, NSCompositeSourceIn);
-
- r.origin.x = [win.img size].width - Cornersize;
- dr = NSIntersectionRect(r, rect);
- drawimg(dr, NSCompositeSourceIn);
-
- r.size.width = r.origin.x - Cornersize;
- r.origin.x -= r.size.width;
- dr = NSIntersectionRect(r, rect);
- drawimg(dr, NSCompositeCopy);
-
- if(OSX_VERSION<100700 && win.isofs==0){
- r.origin.x = [win.img size].width - Handlesize;
- r.origin.y = [win.img size].height - Handlesize;
- r.size = NSMakeSize(Handlesize, Handlesize);
- if(NSIntersectsRect(r, rect))
- drawresizehandle();
- }
- [win.content unlockFocus];
-}
-
-static void
-autoflushwin(int set)
-{
- static NSTimer *t;
-
- if(set){
- if(t)
- return;
- /*
- * We need "NSRunLoopCommonModes", otherwise the
- * timer will not fire during live resizing.
- */
- t = [NSTimer
- timerWithTimeInterval:0.033
- target:[appdelegate class]
- selector:@selector(callflushwin:) userInfo:nil
- repeats:YES];
- [[NSRunLoop currentRunLoop] addTimer:t
- forMode:NSRunLoopCommonModes];
- }else{
- [t invalidate];
- t = nil;
- win.deferflush = 0;
- }
-}
-
-static void
-flushwin(void)
-{
- if(win.deferflush && win.needimg==0){
- [WIN flushWindow];
- win.deferflush = 0;
- }
-}
-
-/*
- * |dr| is sized in points. What if I make it pixels?
- */
-static void
-drawimg(NSRect dr, uint op)
-{
- CGContextRef c;
- CGImageRef i;
- NSRect sr;
-
- if(NSIsEmptyRect(dr))
- return;
-
- sr = [win.content convertRect:dr fromView:nil];
- LOG(@"before dr: %f %f %f %f\n", dr.origin.x, dr.origin.y, dr.size.width, dr.size.height);
- LOG(@"before sr: %f %f %f %f\n", sr.origin.x, sr.origin.y, sr.size.width, sr.size.height);
-
- dr = scalerect(dr, win.topixelscale);
- sr = scalerect(sr, win.topixelscale);
-
- LOG(@"dr: %f %f %f %f\n", dr.origin.x, dr.origin.y, dr.size.width, dr.size.height);
- LOG(@"sr: %f %f %f %f\n", sr.origin.x, sr.origin.y, sr.size.width, sr.size.height);
- if(OSX_VERSION >= 100800){
- i = CGImageCreateWithImageInRect([win.img CGImage], NSRectToCGRect(dr));
- c = [[WIN graphicsContext] graphicsPort];
-
- CGContextSaveGState(c);
- if(op == NSCompositeSourceIn)
- CGContextSetBlendMode(c, kCGBlendModeSourceIn);
- LOG(@"wim.img size %f %f\n", [win.img size].width, [win.img size].height);
- CGContextTranslateCTM(c, 0, [win.img size].height);
- CGContextScaleCTM(c, win.topointscale, -win.topointscale);
- CGContextDrawImage(c, NSRectToCGRect(sr), i);
- CGContextRestoreGState(c);
-
- CGImageRelease(i);
- }else{
- [win.img drawInRect:dr fromRect:sr
- operation:op fraction:1
- respectFlipped:YES hints:nil];
- }
-// NSFrameRect(dr);
-}
-
-static void
-drawresizehandle(void)
-{
- NSColor *color[Barsize];
- NSPoint a,b;
- Point c;
- int i,j;
-
- c = Pt([win.img size].width, [win.img size].height);
-
- [[WIN graphicsContext] setShouldAntialias:NO];
-
- color[0] = [NSColor clearColor];
- color[1] = [NSColor darkGrayColor];
- color[2] = [NSColor lightGrayColor];
- color[3] = [NSColor whiteColor];
-
- for(i=1; i+Barsize <= Handlesize; )
- for(j=0; j0)
- keystroke(k);
- else
- keystroke([s characterAtIndex:0]);
- break;
-
- case NSFlagsChanged:
- if(in.mbuttons || in.kbuttons){
- in.kbuttons = 0;
- if(m & NSAlternateKeyMask)
- in.kbuttons |= 2;
- if(m & NSCommandKeyMask)
- in.kbuttons |= 4;
- sendmouse();
- }else
- if(m&NSAlternateKeyMask && (omod&NSAlternateKeyMask)==0)
- keystroke(Kalt);
- break;
-
- default:
- panic("getkey: unexpected event type");
- }
- omod = m;
-}
-
-/*
- * Devdraw does not use NSTrackingArea, that often
- * forgets to update the cursor on entering and on
- * leaving the area, and that sometimes stops sending
- * us MouseMove events, at least on OS X Lion.
- */
-static void
-updatecursor(void)
-{
- NSCursor *c;
- int isdown, isinside;
-
- isinside = NSPointInRect(in.mpos, [win.content bounds]);
- isdown = (in.mbuttons || in.kbuttons);
-
- if(win.cursor && (isinside || isdown))
- c = win.cursor;
- else if(isinside && usebigarrow)
- c = in.bigarrow;
- else
- c = [NSCursor arrowCursor];
- [c set];
-
- /*
- * Without this trick, we can come back from the dock
- * with a resize cursor.
- */
- if(OSX_VERSION >= 100700)
- [NSCursor unhide];
-}
-
-static void
-acceptresizing(int set)
-{
- uint old, style;
-
- old = [WIN styleMask];
-
- if((old | NSResizableWindowMask) != Winstyle)
- return; /* when entering new fullscreen */
-
- if(set)
- style = Winstyle;
- else
- style = Winstyle & ~NSResizableWindowMask;
-
- if(style != old)
- [WIN setStyleMask:style];
-}
-
-static void
-getmousepos(void)
-{
- NSPoint p, q;
-
- p = [WIN mouseLocationOutsideOfEventStream];
- q = [win.content convertPoint:p fromView:nil];
-
- /* q is in point coordinates. in.mpos is in pixels. */
- q = scalepoint(q, win.topixelscale);
-
- in.mpos.x = round(q.x);
- in.mpos.y = round(q.y);
-
- updatecursor();
-
- if(win.isnfs || win.isofs)
- hidebars(1);
- else if(OSX_VERSION>=100700 && [WIN inLiveResize]==0){
- if(p.x<12 && p.y<12 && p.x>2 && p.y>2)
- acceptresizing(0);
- else
- acceptresizing(1);
- }
-}
-
-static void
-getmouse(NSEvent *e)
-{
- float d;
- int b, m;
-
- if([WIN isKeyWindow] == 0)
- return;
-
- getmousepos();
-
- switch([e type]){
- case NSLeftMouseDown:
- case NSLeftMouseUp:
- case NSOtherMouseDown:
- case NSOtherMouseUp:
- case NSRightMouseDown:
- case NSRightMouseUp:
- b = [NSEvent pressedMouseButtons];
- b = b&~6 | (b&4)>>1 | (b&2)<<1;
- b = mouseswap(b);
-
- if(b == 1){
- m = [e modifierFlags];
- if(m & NSAlternateKeyMask){
- abortcompose();
- b = 2;
- }else
- if(m & NSCommandKeyMask)
- b = 4;
- }
- in.mbuttons = b;
- break;
-
- case NSScrollWheel:
-#if OSX_VERSION >= 100700
- d = [e scrollingDeltaY];
-#else
- d = [e deltaY];
-#endif
- if(d>0)
- in.mscroll = 8;
- else
- if(d<0)
- in.mscroll = 16;
- break;
-
- case NSMouseMoved:
- case NSLeftMouseDragged:
- case NSRightMouseDragged:
- case NSOtherMouseDragged:
- break;
-
- default:
- panic("getmouse: unexpected event type");
- }
- sendmouse();
-}
-
-#define Minpinch 0.02
-
-static void
-getgesture(NSEvent *e)
-{
- switch([e type]){
- case NSEventTypeMagnify:
- if(fabs([e magnification]) > Minpinch)
- togglefs();
- break;
- }
-}
-
-static void sendclick(int);
-
-static uint
-msec(void)
-{
- return nsec()/1000000;
-}
-
-static void
-gettouch(NSEvent *e, int type)
-{
- static int tapping;
- static uint taptime;
- NSSet *set;
- int p;
-
- switch(type){
- case NSTouchPhaseBegan:
- p = NSTouchPhaseTouching;
- set = [e touchesMatchingPhase:p inView:nil];
- if(set.count == 3){
- tapping = 1;
- taptime = msec();
- }else
- if(set.count > 3)
- tapping = 0;
- break;
-
- case NSTouchPhaseMoved:
- tapping = 0;
- break;
-
- case NSTouchPhaseEnded:
- p = NSTouchPhaseTouching;
- set = [e touchesMatchingPhase:p inView:nil];
- if(set.count == 0){
- if(tapping && msec()-taptime<400)
- sendclick(2);
- tapping = 0;
- }
- break;
-
- case NSTouchPhaseCancelled:
- break;
-
- default:
- panic("gettouch: unexpected event type");
- }
-}
-
-static void
-sendclick(int b)
-{
- in.mbuttons = b;
- sendmouse();
- in.mbuttons = 0;
- sendmouse();
-}
-
-static void
-sendmouse(void)
-{
- NSSize size;
- int b;
-
- size = winsizepixels();
- mouserect = Rect(0, 0, size.width, size.height);
-
- b = in.kbuttons | in.mbuttons | in.mscroll;
- mousetrack(in.mpos.x, in.mpos.y, b, msec());
- in.mscroll = 0;
-}
-
-/*
- * |p| is in pixels.
- */
-void
-setmouse(Point p)
-{
- NSPoint q;
- NSRect r;
-
- if([NSApp isActive]==0 && in.willactivate==0)
- return;
-
- if([WIN inLiveResize])
- return;
-
- in.mpos = scalepoint(NSMakePoint(p.x, p.y), win.topointscale); // race condition
-
- q = [win.content convertPoint:in.mpos toView:nil];
- q = [WIN convertRectToScreen:NSMakeRect(q.x, q.y, 0, 0)].origin;
-
- r = [[[NSScreen screens] objectAtIndex:0] frame];
- q.y = r.size.height - q.y; /* Quartz is top-left-based here */
-
- CGWarpMouseCursorPosition(NSPointToCGPoint(q));
- CGAssociateMouseAndMouseCursorPosition(true);
-}
-
-/*
- * |r| is in points.
- */
-static void
-followzoombutton(NSRect r)
-{
- NSRect wr;
- Point p;
- NSPoint pt;
-
- wr = [WIN frame];
- wr.origin.y += wr.size.height;
- r.origin.y += r.size.height;
-
- getmousepos();
- pt.x = in.mpos.x;
- pt.y = in.mpos.y;
- pt = scalepoint(pt, win.topointscale);
- pt.x = (r.origin.x - wr.origin.x) + pt.x;
- pt.y = -(r.origin.y - wr.origin.y) + pt.y;
- pt = scalepoint(pt, win.topixelscale);
-
- p.x = pt.x;
- p.y = pt.y;
-
- setmouse(p);
-}
-
-static void
-togglefs(void)
-{
- uint opt, tmp;
-
-#if OSX_VERSION >= 100700
- NSScreen *s, *s0;
-
- s = [WIN screen];
- s0 = [[NSScreen screens] objectAtIndex:0];
-
- if((s==s0 && useoldfullscreen==0) || win.isnfs) {
- [WIN toggleFullScreen:nil];
- return;
- }
-#endif
- [win.content retain];
- [WIN orderOut:nil];
- [WIN setContentView:nil];
-
- win.isofs = ! win.isofs;
- hidebars(win.isofs);
-
- /*
- * If we move the window from one space to another,
- * ofs[0] and ofs[1] can be on different spaces.
- * This "setCollectionBehavior" trick moves the
- * window to the active space.
- */
- opt = [WIN collectionBehavior];
- tmp = opt | NSWindowCollectionBehaviorCanJoinAllSpaces;
- [WIN setContentView:win.content];
- [WIN setCollectionBehavior:tmp];
- [WIN makeKeyAndOrderFront:nil];
- [WIN setCollectionBehavior:opt];
- [win.content release];
-}
-
-enum
-{
- Autohiddenbars = NSApplicationPresentationAutoHideDock
- | NSApplicationPresentationAutoHideMenuBar,
-
- Hiddenbars = NSApplicationPresentationHideDock
- | NSApplicationPresentationHideMenuBar,
-};
-
-static void
-hidebars(int set)
-{
- NSScreen *s,*s0;
- uint old, opt;
-
- s = [WIN screen];
- s0 = [[NSScreen screens] objectAtIndex:0];
- old = [NSApp presentationOptions];
-
-#if OSX_VERSION >= 100700
- /* This bit can get lost, resulting in dreadful bugs. */
- if(win.isnfs)
- old |= NSApplicationPresentationFullScreen;
-#endif
-
- if(set && s==s0)
- opt = (old & ~Autohiddenbars) | Hiddenbars;
- else
- opt = old & ~(Autohiddenbars | Hiddenbars);
-
- if(opt != old)
- [NSApp setPresentationOptions:opt];
-}
-
-static void
-makemenu(void)
-{
- NSMenu *m;
- NSMenuItem *i0,*i1;
-
- m = [NSMenu new];
- i0 = [m addItemWithTitle:@"app" action:NULL keyEquivalent:@""];
- i1 = [m addItemWithTitle:@"help" action:NULL keyEquivalent:@""];
- [NSApp setMainMenu:m];
- [m release];
-
- m = [[NSMenu alloc] initWithTitle:@"app"];
- [m addItemWithTitle:@"Full Screen"
- action:@selector(calltogglefs:)
- keyEquivalent:@"f"];
- [m addItemWithTitle:@"Hide"
- action:@selector(hide:)
- keyEquivalent:@"h"];
- [m addItemWithTitle:@"Quit"
- action:@selector(terminate:)
- keyEquivalent:@"q"];
- [i0 setSubmenu:m];
- [m release];
-
- m = [[NSMenu alloc] initWithTitle:@"help"];
- [m addItemWithTitle:@"Plumb devdraw(1)"
- action:@selector(plumbmanual:)
- keyEquivalent:@""];
- [i1 setSubmenu:m];
- [m release];
-}
-
-// FIXME: Introduce a high-resolution Glenda image.
-static void
-makeicon(void)
-{
- NSData *d;
- NSImage *i;
-
- d = [[NSData alloc]
- initWithBytes:glenda_png
- length:(sizeof glenda_png)];
-
- i = [[NSImage alloc] initWithData:d];
- [NSApp setApplicationIconImage:i];
- [[NSApp dockTile] display];
- [i release];
- [d release];
-}
-
-QLock snarfl;
-
-char*
-getsnarf(void)
-{
- NSPasteboard *pb;
- NSString *s;
-
- pb = [NSPasteboard generalPasteboard];
-
- qlock(&snarfl);
- s = [pb stringForType:NSPasteboardTypeString];
- qunlock(&snarfl);
-
- if(s)
- return strdup((char*)[s UTF8String]);
- else
- return nil;
-}
-
-void
-putsnarf(char *s)
-{
- NSArray *t;
- NSPasteboard *pb;
- NSString *str;
-
- if(strlen(s) >= SnarfSize)
- return;
-
- t = [NSArray arrayWithObject:NSPasteboardTypeString];
- pb = [NSPasteboard generalPasteboard];
- str = [[NSString alloc] initWithUTF8String:s];
-
- qlock(&snarfl);
- [pb declareTypes:t owner:nil];
- [pb setString:str forType:NSPasteboardTypeString];
- qunlock(&snarfl);
-
- [str release];
-}
-
-void
-kicklabel(char *label)
-{
- if(label == nil)
- return;
-
- [appdelegate
- performSelectorOnMainThread:@selector(callkicklabel0:)
- withObject:[NSValue valueWithPointer:label]
- waitUntilDone:YES];
-}
-
-static void
-kicklabel0(char *label) {
- NSString *s;
-
- s = [[NSString alloc] initWithUTF8String:label];
- [win.ofs[0] setTitle:s];
- [win.ofs[1] setTitle:s];
- [[NSApp dockTile] setBadgeLabel:s];
- [s release];
-}
-
-void
-setcursor(Cursor *c)
-{
- /*
- * No cursor change unless in main thread.
- */
- [appdelegate
- performSelectorOnMainThread:@selector(callsetcursor0:)
- withObject:[NSValue valueWithPointer:c]
- waitUntilDone:YES];
-}
-
-static void
-setcursor0(Cursor *c)
-{
- NSCursor *d;
-
- d = win.cursor;
-
- if(c)
- win.cursor = makecursor(c);
- else
- win.cursor = nil;
-
- updatecursor();
-
- if(d)
- [d release];
-}
-
-/*
- * Cursors will be scaled on retina display.
- */
-static NSCursor*
-makecursor(Cursor *c)
-{
- NSBitmapImageRep *r;
- NSCursor *d;
- NSImage *i;
- NSPoint p;
- int b;
- uchar *plane[5];
-
- r = [[NSBitmapImageRep alloc]
- initWithBitmapDataPlanes:nil
- pixelsWide:16
- pixelsHigh:16
- bitsPerSample:1
- samplesPerPixel:2
- hasAlpha:YES
- isPlanar:YES
- colorSpaceName:NSDeviceWhiteColorSpace
- bytesPerRow:2
- bitsPerPixel:1];
-
- [r getBitmapDataPlanes:plane];
-
- for(b=0; b<2*16; b++){
- plane[0][b] = ~c->set[b];
- plane[1][b] = c->clr[b];
- }
- p = NSMakePoint(-c->offset.x, -c->offset.y);
- i = [NSImage new];
- [i addRepresentation:r];
- [r release];
-
- d = [[NSCursor alloc] initWithImage:i hotSpot:p];
- [i release];
- return d;
-}
-
-void
-topwin(void)
-{
- [WIN performSelectorOnMainThread:
- @selector(makeKeyAndOrderFront:)
- withObject:nil
- waitUntilDone:NO];
-
- in.willactivate = 1;
- [NSApp activateIgnoringOtherApps:YES];
-}
-
-static NSSize
-winsizepoints()
-{
- return [win.content bounds].size;
-}
-
-static NSSize
-winsizepixels()
-{
-#if OSX_VERSION >= 100700
- if (OSX_VERSION >= 100700 && devdrawretina)
- return [win.content convertSizeToBacking: winsizepoints()];
- else
-#endif
- return winsizepoints();
-}
-
-static NSRect
-scalerect(NSRect r, CGFloat scale)
-{
- r.origin.x *= scale;
- r.origin.y *= scale;
- r.size.width *= scale;
- r.size.height *= scale;
- return r;
-}
-
-/*
- * Expands rectangle |r|'s bounds to more inclusive integer bounds to
- * eliminate 1 pixel gaps.
- */
-static NSRect
-dilate(NSRect r)
-{
- if(win.topixelscale > 1.0f){
- r.origin.x = floorf(r.origin.x);
- r.origin.y = floorf(r.origin.y);
- r.size.width = ceilf(r.size.width + 0.5);
- r.size.height = ceilf(r.size.height + 0.5);
- }
- return r;
-}
-
-static NSPoint
-scalepoint(NSPoint pt, CGFloat scale)
-{
- pt.x *= scale;
- pt.y *= scale;
- return pt;
-}
-
-static void
-setprocname(const char *s)
-{
- CFStringRef process_name;
-
- process_name = CFStringCreateWithBytes(nil, (uchar*)s, strlen(s), kCFStringEncodingUTF8, false);
-
- // Adapted from Chrome's mac_util.mm.
- // http://src.chromium.org/viewvc/chrome/trunk/src/base/mac/mac_util.mm
- //
- // Copyright (c) 2012 The Chromium Authors. All rights reserved.
- //
- // Redistribution and use in source and binary forms, with or without
- // modification, are permitted provided that the following conditions are
- // met:
- //
- // * Redistributions of source code must retain the above copyright
- // notice, this list of conditions and the following disclaimer.
- // * Redistributions in binary form must reproduce the above
- // copyright notice, this list of conditions and the following disclaimer
- // in the documentation and/or other materials provided with the
- // distribution.
- // * Neither the name of Google Inc. nor the names of its
- // contributors may be used to endorse or promote products derived from
- // this software without specific prior written permission.
- //
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- // Warning: here be dragons! This is SPI reverse-engineered from WebKit's
- // plugin host, and could break at any time (although realistically it's only
- // likely to break in a new major release).
- // When 10.7 is available, check that this still works, and update this
- // comment for 10.8.
-
- // Private CFType used in these LaunchServices calls.
- typedef CFTypeRef PrivateLSASN;
- typedef PrivateLSASN (*LSGetCurrentApplicationASNType)();
- typedef OSStatus (*LSSetApplicationInformationItemType)(int, PrivateLSASN,
- CFStringRef,
- CFStringRef,
- CFDictionaryRef*);
-
- static LSGetCurrentApplicationASNType ls_get_current_application_asn_func =
- NULL;
- static LSSetApplicationInformationItemType
- ls_set_application_information_item_func = NULL;
- static CFStringRef ls_display_name_key = NULL;
-
- static bool did_symbol_lookup = false;
- if (!did_symbol_lookup) {
- did_symbol_lookup = true;
- CFBundleRef launch_services_bundle =
- CFBundleGetBundleWithIdentifier(CFSTR("com.apple.LaunchServices"));
- if (!launch_services_bundle) {
- fprint(2, "Failed to look up LaunchServices bundle\n");
- return;
- }
-
- ls_get_current_application_asn_func =
- (LSGetCurrentApplicationASNType)(
- CFBundleGetFunctionPointerForName(
- launch_services_bundle, CFSTR("_LSGetCurrentApplicationASN")));
- if (!ls_get_current_application_asn_func)
- fprint(2, "Could not find _LSGetCurrentApplicationASN\n");
-
- ls_set_application_information_item_func =
- (LSSetApplicationInformationItemType)(
- CFBundleGetFunctionPointerForName(
- launch_services_bundle,
- CFSTR("_LSSetApplicationInformationItem")));
- if (!ls_set_application_information_item_func)
- fprint(2, "Could not find _LSSetApplicationInformationItem\n");
-
- CFStringRef* key_pointer = (CFStringRef*)(
- CFBundleGetDataPointerForName(launch_services_bundle,
- CFSTR("_kLSDisplayNameKey")));
- ls_display_name_key = key_pointer ? *key_pointer : NULL;
- if (!ls_display_name_key)
- fprint(2, "Could not find _kLSDisplayNameKey\n");
-
- // Internally, this call relies on the Mach ports that are started up by the
- // Carbon Process Manager. In debug builds this usually happens due to how
- // the logging layers are started up; but in release, it isn't started in as
- // much of a defined order. So if the symbols had to be loaded, go ahead
- // and force a call to make sure the manager has been initialized and hence
- // the ports are opened.
- ProcessSerialNumber psn;
- GetCurrentProcess(&psn);
- }
- if (!ls_get_current_application_asn_func ||
- !ls_set_application_information_item_func ||
- !ls_display_name_key) {
- return;
- }
-
- PrivateLSASN asn = ls_get_current_application_asn_func();
- // Constant used by WebKit; what exactly it means is unknown.
- const int magic_session_constant = -2;
- OSErr err =
- ls_set_application_information_item_func(magic_session_constant, asn,
- ls_display_name_key,
- process_name,
- NULL /* optional out param */);
- if(err != noErr)
- fprint(2, "Call to set process name failed\n");
-}
diff --git a/src/cmd/devdraw/cocoa-srv.c b/src/cmd/devdraw/cocoa-srv.c
deleted file mode 100644
index 197fd512a..000000000
--- a/src/cmd/devdraw/cocoa-srv.c
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- * Window system protocol server.
- */
-
-#include
-#include
-#include "cocoa-thread.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include "cocoa-screen.h"
-#include "devdraw.h"
-
-typedef struct Kbdbuf Kbdbuf;
-typedef struct Mousebuf Mousebuf;
-typedef struct Fdbuf Fdbuf;
-typedef struct Tagbuf Tagbuf;
-
-struct Kbdbuf
-{
- Rune r[32];
- int ri;
- int wi;
- int stall;
-};
-
-struct Mousebuf
-{
- Mouse m[32];
- Mouse last;
- int ri;
- int wi;
- int stall;
-};
-
-struct Tagbuf
-{
- int t[32];
- int ri;
- int wi;
-};
-
-Kbdbuf kbd;
-Mousebuf mouse;
-Tagbuf kbdtags;
-Tagbuf mousetags;
-
-void runmsg(Wsysmsg*);
-void replymsg(Wsysmsg*);
-void matchkbd(void);
-void matchmouse(void);
-
-
-QLock lk;
-void
-zlock(void)
-{
- qlock(&lk);
-}
-
-void
-zunlock(void)
-{
- qunlock(&lk);
-}
-
-int trace = 0;
-
-void
-servep9p(void)
-{
- uchar buf[4], *mbuf;
- int nmbuf, n, nn;
- Wsysmsg m;
-
- fmtinstall('W', drawfcallfmt);
-
- mbuf = nil;
- nmbuf = 0;
- while((n = read(3, buf, 4)) == 4){
- GET(buf, n);
- if(n > nmbuf){
- free(mbuf);
- mbuf = malloc(4+n);
- if(mbuf == nil)
- sysfatal("malloc: %r");
- nmbuf = n;
- }
- memmove(mbuf, buf, 4);
- nn = readn(3, mbuf+4, n-4);
- if(nn != n-4)
- sysfatal("eof during message");
-
- /* pick off messages one by one */
- if(convM2W(mbuf, nn+4, &m) <= 0)
- sysfatal("cannot convert message");
- if(trace) fprint(2, "<- %W\n", &m);
- runmsg(&m);
- }
-}
-
-void
-replyerror(Wsysmsg *m)
-{
- char err[256];
-
- rerrstr(err, sizeof err);
- m->type = Rerror;
- m->error = err;
- replymsg(m);
-}
-
-/*
- * Handle a single wsysmsg.
- * Might queue for later (kbd, mouse read)
- */
-void
-runmsg(Wsysmsg *m)
-{
- static uchar buf[65536];
- int n;
- Memimage *i;
-
- switch(m->type){
- case Tinit:
- memimageinit();
- i = attachscreen(m->label, m->winsize);
- _initdisplaymemimage(i);
- replymsg(m);
- break;
-
- case Trdmouse:
- zlock();
- mousetags.t[mousetags.wi++] = m->tag;
- if(mousetags.wi == nelem(mousetags.t))
- mousetags.wi = 0;
- if(mousetags.wi == mousetags.ri)
- sysfatal("too many queued mouse reads");
- mouse.stall = 0;
- matchmouse();
- zunlock();
- break;
-
- case Trdkbd:
- zlock();
- kbdtags.t[kbdtags.wi++] = m->tag;
- if(kbdtags.wi == nelem(kbdtags.t))
- kbdtags.wi = 0;
- if(kbdtags.wi == kbdtags.ri)
- sysfatal("too many queued keyboard reads");
- kbd.stall = 0;
- matchkbd();
- zunlock();
- break;
-
- case Tmoveto:
- setmouse(m->mouse.xy);
- replymsg(m);
- break;
-
- case Tcursor:
- if(m->arrowcursor)
- setcursor(nil);
- else
- setcursor(&m->cursor);
- replymsg(m);
- break;
-
- case Tbouncemouse:
- // _xbouncemouse(&m->mouse);
- replymsg(m);
- break;
-
- case Tlabel:
- kicklabel(m->label);
- replymsg(m);
- break;
-
- case Trdsnarf:
- m->snarf = getsnarf();
- replymsg(m);
- free(m->snarf);
- break;
-
- case Twrsnarf:
- putsnarf(m->snarf);
- replymsg(m);
- break;
-
- case Trddraw:
- n = m->count;
- if(n > sizeof buf)
- n = sizeof buf;
- n = _drawmsgread(buf, n);
- if(n < 0)
- replyerror(m);
- else{
- m->count = n;
- m->data = buf;
- replymsg(m);
- }
- break;
-
- case Twrdraw:
- if(_drawmsgwrite(m->data, m->count) < 0)
- replyerror(m);
- else
- replymsg(m);
- break;
-
- case Ttop:
- topwin();
- replymsg(m);
- break;
-
- case Tresize:
- // _xresizewindow(m->rect);
- replymsg(m);
- break;
- }
-}
-
-/*
- * Reply to m.
- */
-QLock replylock;
-void
-replymsg(Wsysmsg *m)
-{
- int n;
- static uchar *mbuf;
- static int nmbuf;
-
- /* T -> R msg */
- if(m->type%2 == 0)
- m->type++;
-
- if(trace) fprint(2, "-> %W\n", m);
- /* copy to output buffer */
- n = sizeW2M(m);
-
- qlock(&replylock);
- if(n > nmbuf){
- free(mbuf);
- mbuf = malloc(n);
- if(mbuf == nil)
- sysfatal("out of memory");
- nmbuf = n;
- }
- convW2M(m, mbuf, n);
- if(write(4, mbuf, n) != n)
- sysfatal("write: %r");
- qunlock(&replylock);
-}
-
-/*
- * Match queued kbd reads with queued kbd characters.
- */
-void
-matchkbd(void)
-{
- Wsysmsg m;
-
- if(kbd.stall)
- return;
- while(kbd.ri != kbd.wi && kbdtags.ri != kbdtags.wi){
- m.type = Rrdkbd;
- m.tag = kbdtags.t[kbdtags.ri++];
- if(kbdtags.ri == nelem(kbdtags.t))
- kbdtags.ri = 0;
- m.rune = kbd.r[kbd.ri++];
- if(kbd.ri == nelem(kbd.r))
- kbd.ri = 0;
- replymsg(&m);
- }
-}
-
-/*
- * Match queued mouse reads with queued mouse events.
- */
-void
-matchmouse(void)
-{
- Wsysmsg m;
-
- while(mouse.ri != mouse.wi && mousetags.ri != mousetags.wi){
- m.type = Rrdmouse;
- m.tag = mousetags.t[mousetags.ri++];
- if(mousetags.ri == nelem(mousetags.t))
- mousetags.ri = 0;
- m.mouse = mouse.m[mouse.ri];
- m.resized = mouseresized;
- /*
- if(m.resized)
- fprint(2, "sending resize\n");
- */
- mouseresized = 0;
- mouse.ri++;
- if(mouse.ri == nelem(mouse.m))
- mouse.ri = 0;
- replymsg(&m);
- }
-}
-
-void
-mousetrack(int x, int y, int b, uint ms)
-{
- Mouse *m;
-
- if(x < mouserect.min.x)
- x = mouserect.min.x;
- if(x > mouserect.max.x)
- x = mouserect.max.x;
- if(y < mouserect.min.y)
- y = mouserect.min.y;
- if(y > mouserect.max.y)
- y = mouserect.max.y;
-
- zlock();
- // If reader has stopped reading, don't bother.
- // If reader is completely caught up, definitely queue.
- // Otherwise, queue only button change events.
- if(!mouse.stall)
- if(mouse.wi == mouse.ri || mouse.last.buttons != b){
- m = &mouse.last;
- m->xy.x = x;
- m->xy.y = y;
- m->buttons = b;
- m->msec = ms;
-
- mouse.m[mouse.wi] = *m;
- if(++mouse.wi == nelem(mouse.m))
- mouse.wi = 0;
- if(mouse.wi == mouse.ri){
- mouse.stall = 1;
- mouse.ri = 0;
- mouse.wi = 1;
- mouse.m[0] = *m;
- }
- matchmouse();
- }
- zunlock();
-}
-
-void
-kputc(int c)
-{
- zlock();
- kbd.r[kbd.wi++] = c;
- if(kbd.wi == nelem(kbd.r))
- kbd.wi = 0;
- if(kbd.ri == kbd.wi)
- kbd.stall = 1;
- matchkbd();
- zunlock();
-}
-
-static int alting;
-
-void
-abortcompose(void)
-{
- if(alting)
- keystroke(Kalt);
-}
-
-void resizeimg(void);
-
-void
-keystroke(int c)
-{
- static Rune k[10];
- static int nk;
- int i;
-
- if(c == Kalt){
- alting = !alting;
- nk = 0;
- return;
- }
- if(c == Kcmd+'r') {
- if(forcedpi)
- forcedpi = 0;
- else if(displaydpi >= 200)
- forcedpi = 100;
- else
- forcedpi = 225;
- resizeimg();
- return;
- }
- if(!alting){
- kputc(c);
- return;
- }
- if(nk >= nelem(k)) // should not happen
- nk = 0;
- k[nk++] = c;
- c = _latin1(k, nk);
- if(c > 0){
- alting = 0;
- kputc(c);
- nk = 0;
- return;
- }
- if(c == -1){
- alting = 0;
- for(i=0; i
-#include
-#include "cocoa-thread.h"
-
-#ifndef TRY_LIBTHREAD
-
-static pthread_mutex_t initlock = PTHREAD_MUTEX_INITIALIZER;
-
-void
-qlock(QLock *q)
-{
- if(q->init == 0){
- pthread_mutex_lock(&initlock);
- if(q->init == 0){
- pthread_mutex_init(&q->m, nil);
- q->init = 1;
- }
- pthread_mutex_unlock(&initlock);
- }
- pthread_mutex_lock(&q->m);
-}
-
-void
-qunlock(QLock *q)
-{
- pthread_mutex_unlock(&q->m);
-}
-#endif
diff --git a/src/cmd/devdraw/cocoa-thread.h b/src/cmd/devdraw/cocoa-thread.h
deleted file mode 100644
index c2f3e9821..000000000
--- a/src/cmd/devdraw/cocoa-thread.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * I am too ignorant to know if Cocoa and Libthread
- * can coexist: if I try to include thread.h, now
- * that Devdraw uses Cocoa's threads (and timers), it
- * crashes immediately; when Devdraw was using
- * proccreate(), it could run a little while before to
- * crash; the origin of those crashes is hard to
- * ascertain, because other programs using Libthread
- * (such as 9term, Acme, Plumber, and Sam) currently
- * don't run when compiled with Xcode 4.1.
- */
-//#define TRY_LIBTHREAD
-
-#ifdef TRY_LIBTHREAD
- #include
-#else
- #define QLock DQLock
- #define qlock dqlock
- #define qunlock dqunlock
- #define threadexitsall exits
- #define threadmain main
-
- typedef struct QLock QLock;
-
- struct QLock
- {
- int init;
- pthread_mutex_t m;
- };
-
- void qlock(QLock*);
- void qunlock(QLock*);
-#endif
diff --git a/src/cmd/devdraw/devdraw.c b/src/cmd/devdraw/devdraw.c
index 7f0bff211..234cdf1b2 100644
--- a/src/cmd/devdraw/devdraw.c
+++ b/src/cmd/devdraw/devdraw.c
@@ -8,181 +8,59 @@
#include
#include
#include
+#include
+#include
+#include
+#include
#include "devdraw.h"
-extern void _flushmemscreen(Rectangle);
-int forcedpi = 0;
-int displaydpi = 100;
+QLock drawlk;
-#define NHASH (1<<5)
-#define HASHMASK (NHASH-1)
-
-typedef struct Client Client;
-typedef struct Draw Draw;
-typedef struct DImage DImage;
-typedef struct DScreen DScreen;
-typedef struct CScreen CScreen;
-typedef struct FChar FChar;
-typedef struct Refresh Refresh;
-typedef struct Refx Refx;
-typedef struct DName DName;
-
-struct Draw
-{
- QLock lk;
- int clientid;
- int nclient;
- Client* client[1];
- int nname;
- DName* name;
- int vers;
- int softscreen;
-};
-
-struct Client
-{
- /*Ref r;*/
- DImage* dimage[NHASH];
- CScreen* cscreen;
- Refresh* refresh;
- Rendez refrend;
- uchar* readdata;
- int nreaddata;
- int busy;
- int clientid;
- int slot;
- int refreshme;
- int infoid;
- int op;
-};
-
-struct Refresh
-{
- DImage* dimage;
- Rectangle r;
- Refresh* next;
-};
-
-struct Refx
-{
- Client* client;
- DImage* dimage;
-};
-
-struct DName
-{
- char *name;
- Client *client;
- DImage* dimage;
- int vers;
-};
-
-struct FChar
-{
- int minx; /* left edge of bits */
- int maxx; /* right edge of bits */
- uchar miny; /* first non-zero scan-line */
- uchar maxy; /* last non-zero scan-line + 1 */
- schar left; /* offset of baseline */
- uchar width; /* width of baseline */
-};
-
-/*
- * Reference counts in DImages:
- * one per open by original client
- * one per screen image or fill
- * one per image derived from this one by name
- */
-struct DImage
-{
- int id;
- int ref;
- char *name;
- int vers;
- Memimage* image;
- int ascent;
- int nfchar;
- FChar* fchar;
- DScreen* dscreen; /* 0 if not a window */
- DImage* fromname; /* image this one is derived from, by name */
- DImage* next;
-};
-
-struct CScreen
-{
- DScreen* dscreen;
- CScreen* next;
-};
-
-struct DScreen
-{
- int id;
- int public;
- int ref;
- DImage *dimage;
- DImage *dfill;
- Memscreen* screen;
- Client* owner;
- DScreen* next;
-};
-
-static Draw sdraw;
-static Client *client0;
-static Memimage *screenimage;
-static Rectangle flushrect;
-static int waste;
-static DScreen* dscreen;
static int drawuninstall(Client*, int);
static Memimage* drawinstall(Client*, int, Memimage*, DScreen*);
-static void drawfreedimage(DImage*);
+static void drawfreedimage(Client*, DImage*);
void
-_initdisplaymemimage(Memimage *m)
+draw_initdisplaymemimage(Client *c, Memimage *m)
{
- screenimage = m;
+ c->screenimage = m;
m->screenref = 1;
- client0 = mallocz(sizeof(Client), 1);
- if(client0 == nil){
- fprint(2, "initdraw: allocating client0: out of memory");
- abort();
- }
- client0->slot = 0;
- client0->clientid = ++sdraw.clientid;
- client0->op = SoverD;
- sdraw.client[0] = client0;
- sdraw.nclient = 1;
- sdraw.softscreen = 1;
+ c->slot = 0;
+ c->clientid = 1;
+ c->op = SoverD;
}
+// gfx_replacescreenimage replaces c's screen image with m.
+// It is called by the host driver on the main host thread.
void
-_drawreplacescreenimage(Memimage *m)
+gfx_replacescreenimage(Client *c, Memimage *m)
{
/*
* Replace the screen image because the screen
* was resized.
- *
+ *
* In theory there should only be one reference
* to the current screen image, and that's through
* client0's image 0, installed a few lines above.
- * Once the client drops the image, the underlying backing
+ * Once the client drops the image, the underlying backing
* store freed properly. The client is being notified
* about the resize through external means, so all we
* need to do is this assignment.
*/
Memimage *om;
- qlock(&sdraw.lk);
- om = screenimage;
- screenimage = m;
+ qlock(&drawlk);
+ om = c->screenimage;
+ c->screenimage = m;
m->screenref = 1;
if(om && --om->screenref == 0){
_freememimage(om);
}
- qunlock(&sdraw.lk);
+ qunlock(&drawlk);
+ gfx_mouseresized(c);
}
-static
-void
+static void
drawrefreshscreen(DImage *l, Client *client)
{
while(l != nil && l->dscreen == nil)
@@ -191,8 +69,7 @@ drawrefreshscreen(DImage *l, Client *client)
l->dscreen->owner->refreshme = 1;
}
-static
-void
+static void
drawrefresh(Memimage *m, Rectangle r, void *v)
{
Refx *x;
@@ -222,57 +99,65 @@ drawrefresh(Memimage *m, Rectangle r, void *v)
}
static void
-addflush(Rectangle r)
+addflush(Client *c, Rectangle r)
{
int abb, ar, anbb;
- Rectangle nbb;
+ Rectangle nbb, fr;
- if(sdraw.softscreen==0 || !rectclip(&r, screenimage->r))
+ if(/*sdraw.softscreen==0 ||*/ !rectclip(&r, c->screenimage->r))
return;
- if(flushrect.min.x >= flushrect.max.x){
- flushrect = r;
- waste = 0;
+ if(c->flushrect.min.x >= c->flushrect.max.x){
+ c->flushrect = r;
+ c->waste = 0;
return;
}
- nbb = flushrect;
+ nbb = c->flushrect;
combinerect(&nbb, r);
ar = Dx(r)*Dy(r);
- abb = Dx(flushrect)*Dy(flushrect);
+ abb = Dx(c->flushrect)*Dy(c->flushrect);
anbb = Dx(nbb)*Dy(nbb);
/*
* Area of new waste is area of new bb minus area of old bb,
* less the area of the new segment, which we assume is not waste.
* This could be negative, but that's OK.
*/
- waste += anbb-abb - ar;
- if(waste < 0)
- waste = 0;
+ c->waste += anbb-abb - ar;
+ if(c->waste < 0)
+ c->waste = 0;
/*
* absorb if:
* total area is small
* waste is less than half total area
* rectangles touch
*/
- if(anbb<=1024 || waste*2waste*2flushrect, r)){
+ c->flushrect = nbb;
return;
}
/* emit current state */
- if(flushrect.min.x < flushrect.max.x)
- _flushmemscreen(flushrect);
- flushrect = r;
- waste = 0;
+ fr = c->flushrect;
+ c->flushrect = r;
+ c->waste = 0;
+ if(fr.min.x < fr.max.x) {
+ // Unlock drawlk because rpc_flush may want to run on gfx thread,
+ // and gfx thread might be blocked on drawlk trying to install a new screen
+ // during a resize.
+ rpc_gfxdrawunlock();
+ qunlock(&drawlk);
+ c->impl->rpc_flush(c, fr);
+ qlock(&drawlk);
+ rpc_gfxdrawlock();
+ }
}
-static
-void
-dstflush(int dstid, Memimage *dst, Rectangle r)
+static void
+dstflush(Client *c, int dstid, Memimage *dst, Rectangle r)
{
Memlayer *l;
if(dstid == 0){
- combinerect(&flushrect, r);
+ combinerect(&c->flushrect, r);
return;
}
/* how can this happen? -rsc, dec 12 2002 */
@@ -284,25 +169,34 @@ dstflush(int dstid, Memimage *dst, Rectangle r)
if(l == nil)
return;
do{
- if(l->screen->image->data != screenimage->data)
+ if(l->screen->image->data != c->screenimage->data)
return;
r = rectaddpt(r, l->delta);
l = l->screen->image->layer;
}while(l);
- addflush(r);
+ addflush(c, r);
}
-static
-void
-drawflush(void)
+static void
+drawflush(Client *c)
{
- if(flushrect.min.x < flushrect.max.x)
- _flushmemscreen(flushrect);
- flushrect = Rect(10000, 10000, -10000, -10000);
+ Rectangle r;
+
+ r = c->flushrect;
+ c->flushrect = Rect(10000, 10000, -10000, -10000);
+ if(r.min.x < r.max.x) {
+ // Unlock drawlk because rpc_flush may want to run on gfx thread,
+ // and gfx thread might be blocked on drawlk trying to install a new screen
+ // during a resize.
+ rpc_gfxdrawunlock();
+ qunlock(&drawlk);
+ c->impl->rpc_flush(c, r);
+ qlock(&drawlk);
+ rpc_gfxdrawlock();
+ }
}
-static
-int
+static int
drawcmp(char *a, char *b, int n)
{
if(strlen(a) != n)
@@ -310,41 +204,38 @@ drawcmp(char *a, char *b, int n)
return memcmp(a, b, n);
}
-static
-DName*
-drawlookupname(int n, char *str)
+static DName*
+drawlookupname(Client *client, int n, char *str)
{
DName *name, *ename;
- name = sdraw.name;
- ename = &name[sdraw.nname];
+ name = client->name;
+ ename = &name[client->nname];
for(; namename, str, n) == 0)
return name;
return 0;
}
-static
-int
-drawgoodname(DImage *d)
+static int
+drawgoodname(Client *client, DImage *d)
{
DName *n;
/* if window, validate the screen's own images */
if(d->dscreen)
- if(drawgoodname(d->dscreen->dimage) == 0
- || drawgoodname(d->dscreen->dfill) == 0)
+ if(drawgoodname(client, d->dscreen->dimage) == 0
+ || drawgoodname(client, d->dscreen->dfill) == 0)
return 0;
if(d->name == nil)
return 1;
- n = drawlookupname(strlen(d->name), d->name);
+ n = drawlookupname(client, strlen(d->name), d->name);
if(n==nil || n->vers!=d->vers)
return 0;
return 1;
}
-static
-DImage*
+static DImage*
drawlookup(Client *client, int id, int checkname)
{
DImage *d;
@@ -356,7 +247,7 @@ drawlookup(Client *client, int id, int checkname)
* BUG: should error out but too hard.
* Return 0 instead.
*/
- if(checkname && !drawgoodname(d))
+ if(checkname && !drawgoodname(client, d))
return 0;
return d;
}
@@ -365,13 +256,12 @@ drawlookup(Client *client, int id, int checkname)
return 0;
}
-static
-DScreen*
-drawlookupdscreen(int id)
+static DScreen*
+drawlookupdscreen(Client *c, int id)
{
DScreen *s;
- s = dscreen;
+ s = c->dscreen;
while(s){
if(s->id == id)
return s;
@@ -380,8 +270,7 @@ drawlookupdscreen(int id)
return 0;
}
-static
-DScreen*
+static DScreen*
drawlookupscreen(Client *client, int id, CScreen **cs)
{
CScreen *s;
@@ -398,8 +287,7 @@ drawlookupscreen(Client *client, int id, CScreen **cs)
return 0;
}
-static
-Memimage*
+static Memimage*
drawinstall(Client *client, int id, Memimage *i, DScreen *dscreen)
{
DImage *d;
@@ -423,8 +311,7 @@ drawinstall(Client *client, int id, Memimage *i, DScreen *dscreen)
return i;
}
-static
-Memscreen*
+static Memscreen*
drawinstallscreen(Client *client, DScreen *d, int id, DImage *dimage, DImage *dfill, int public)
{
Memscreen *s;
@@ -466,9 +353,9 @@ drawinstallscreen(Client *client, DScreen *d, int id, DImage *dimage, DImage *df
d->id = id;
d->screen = s;
d->public = public;
- d->next = dscreen;
+ d->next = client->dscreen;
d->owner = client;
- dscreen = d;
+ client->dscreen = d;
}
c->dscreen = d;
d->ref++;
@@ -477,20 +364,18 @@ drawinstallscreen(Client *client, DScreen *d, int id, DImage *dimage, DImage *df
return d->screen;
}
-static
-void
-drawdelname(DName *name)
+static void
+drawdelname(Client *client, DName *name)
{
int i;
- i = name-sdraw.name;
- memmove(name, name+1, (sdraw.nname-(i+1))*sizeof(DName));
- sdraw.nname--;
+ i = name-client->name;
+ memmove(name, name+1, (client->nname-(i+1))*sizeof(DName));
+ client->nname--;
}
-static
-void
-drawfreedscreen(DScreen *this)
+static void
+drawfreedscreen(Client *client, DScreen *this)
{
DScreen *ds, *next;
@@ -499,9 +384,9 @@ drawfreedscreen(DScreen *this)
fprint(2, "negative ref in drawfreedscreen\n");
if(this->ref > 0)
return;
- ds = dscreen;
+ ds = client->dscreen;
if(ds == this){
- dscreen = this->next;
+ client->dscreen = this->next;
goto Found;
}
while(next = ds->next){ /* assign = */
@@ -518,16 +403,15 @@ drawfreedscreen(DScreen *this)
Found:
if(this->dimage)
- drawfreedimage(this->dimage);
+ drawfreedimage(client, this->dimage);
if(this->dfill)
- drawfreedimage(this->dfill);
+ drawfreedimage(client, this->dfill);
free(this->screen);
free(this);
}
-static
-void
-drawfreedimage(DImage *dimage)
+static void
+drawfreedimage(Client *client, DImage *dimage)
{
int i;
Memimage *l;
@@ -540,13 +424,13 @@ drawfreedimage(DImage *dimage)
return;
/* any names? */
- for(i=0; inname; )
+ if(client->name[i].dimage == dimage)
+ drawdelname(client, client->name+i);
else
i++;
if(dimage->fromname){ /* acquired by name; owned by someone else*/
- drawfreedimage(dimage->fromname);
+ drawfreedimage(client, dimage->fromname);
goto Return;
}
ds = dimage->dscreen;
@@ -554,16 +438,16 @@ drawfreedimage(DImage *dimage)
dimage->dscreen = nil; /* paranoia */
dimage->image = nil;
if(ds){
- if(l->data == screenimage->data)
- addflush(l->layer->screenr);
+ if(l->data == client->screenimage->data)
+ addflush(client, l->layer->screenr);
if(l->layer->refreshfn == drawrefresh) /* else true owner will clean up */
free(l->layer->refreshptr);
l->layer->refreshptr = nil;
- if(drawgoodname(dimage))
+ if(drawgoodname(client, dimage))
memldelete(l);
else
memlfree(l);
- drawfreedscreen(ds);
+ drawfreedscreen(client, ds);
}else{
if(l->screenref==0)
freememimage(l);
@@ -575,8 +459,7 @@ drawfreedimage(DImage *dimage)
free(dimage);
}
-static
-void
+static void
drawuninstallscreen(Client *client, CScreen *this)
{
CScreen *cs, *next;
@@ -584,14 +467,14 @@ drawuninstallscreen(Client *client, CScreen *this)
cs = client->cscreen;
if(cs == this){
client->cscreen = this->next;
- drawfreedscreen(this->dscreen);
+ drawfreedscreen(client, this->dscreen);
free(this);
return;
}
while(next = cs->next){ /* assign = */
if(next == this){
cs->next = this->next;
- drawfreedscreen(this->dscreen);
+ drawfreedscreen(client, this->dscreen);
free(this);
return;
}
@@ -599,8 +482,7 @@ drawuninstallscreen(Client *client, CScreen *this)
}
}
-static
-int
+static int
drawuninstall(Client *client, int id)
{
DImage *d, **l;
@@ -608,28 +490,27 @@ drawuninstall(Client *client, int id)
for(l=&client->dimage[id&HASHMASK]; (d=*l) != nil; l=&d->next){
if(d->id == id){
*l = d->next;
- drawfreedimage(d);
+ drawfreedimage(client, d);
return 0;
}
}
return -1;
}
-static
-int
+static int
drawaddname(Client *client, DImage *di, int n, char *str, char **err)
{
DName *name, *ename, *new, *t;
char *ns;
- name = sdraw.name;
- ename = &name[sdraw.nname];
+ name = client->name;
+ ename = &name[client->nname];
for(; namename, str, n) == 0){
*err = "image name in use";
return -1;
}
- t = mallocz((sdraw.nname+1)*sizeof(DName), 1);
+ t = mallocz((client->nname+1)*sizeof(DName), 1);
ns = malloc(n+1);
if(t == nil || ns == nil){
free(t);
@@ -637,16 +518,16 @@ drawaddname(Client *client, DImage *di, int n, char *str, char **err)
*err = "out of memory";
return -1;
}
- memmove(t, sdraw.name, sdraw.nname*sizeof(DName));
- free(sdraw.name);
- sdraw.name = t;
- new = &sdraw.name[sdraw.nname++];
+ memmove(t, client->name, client->nname*sizeof(DName));
+ free(client->name);
+ client->name = t;
+ new = &client->name[client->nname++];
new->name = ns;
memmove(new->name, str, n);
new->name[n] = 0;
new->dimage = di;
new->client = client;
- new->vers = ++sdraw.vers;
+ new->vers = ++client->namevers;
return 0;
}
@@ -660,8 +541,7 @@ drawclientop(Client *cl)
return op;
}
-static
-Memimage*
+static Memimage*
drawimage(Client *client, uchar *a)
{
DImage *d;
@@ -672,8 +552,7 @@ drawimage(Client *client, uchar *a)
return d->image;
}
-static
-void
+static void
drawrectangle(Rectangle *r, uchar *a)
{
r->min.x = BGLONG(a+0*4);
@@ -682,16 +561,14 @@ drawrectangle(Rectangle *r, uchar *a)
r->max.y = BGLONG(a+3*4);
}
-static
-void
+static void
drawpoint(Point *p, uchar *a)
{
p->x = BGLONG(a+0*4);
p->y = BGLONG(a+1*4);
}
-static
-Point
+static Point
drawchar(Memimage *dst, Point p, Memimage *src, Point *sp, DImage *font, int index, int op)
{
FChar *fc;
@@ -711,8 +588,7 @@ drawchar(Memimage *dst, Point p, Memimage *src, Point *sp, DImage *font, int ind
return p;
}
-static
-uchar*
+static uchar*
drawcoord(uchar *p, uchar *maxp, int oldx, int *newx)
{
int b, x;
@@ -738,12 +614,9 @@ drawcoord(uchar *p, uchar *maxp, int oldx, int *newx)
}
int
-_drawmsgread(void *a, int n)
+draw_dataread(Client *cl, void *a, int n)
{
- Client *cl;
-
- qlock(&sdraw.lk);
- cl = client0;
+ qlock(&drawlk);
if(cl->readdata == nil){
werrstr("no draw data");
goto err;
@@ -756,23 +629,22 @@ _drawmsgread(void *a, int n)
memmove(a, cl->readdata, cl->nreaddata);
free(cl->readdata);
cl->readdata = nil;
- qunlock(&sdraw.lk);
+ qunlock(&drawlk);
return n;
err:
- qunlock(&sdraw.lk);
+ qunlock(&drawlk);
return -1;
}
int
-_drawmsgwrite(void *v, int n)
+draw_datawrite(Client *client, void *v, int n)
{
char cbuf[40], *err, ibuf[12*12+1], *s;
int c, ci, doflush, dstid, e0, e1, esize, j, m;
- int ni, nw, oesize, oldn, op, ox, oy, repl, scrnid, y;
+ int ni, nw, oesize, oldn, op, ox, oy, repl, scrnid, y;
uchar *a, refresh, *u;
u32int chan, value;
- Client *client;
CScreen *cs;
DImage *di, *ddst, *dsrc, *font, *ll;
DName *dn;
@@ -786,11 +658,11 @@ _drawmsgwrite(void *v, int n)
Refreshfn reffn;
Refx *refx;
- qlock(&sdraw.lk);
+ qlock(&drawlk);
+ rpc_gfxdrawlock();
a = v;
m = 0;
oldn = n;
- client = client0;
while((n-=m) > 0){
a += m;
@@ -844,7 +716,7 @@ _drawmsgwrite(void *v, int n)
l = memlalloc(scrn, r, reffn, 0, value);
if(l == 0)
goto Edrawmem;
- addflush(l->layer->screenr);
+ addflush(client, l->layer->screenr);
l->clipr = clipr;
rectclip(&l->clipr, r);
if(drawinstall(client, dstid, l, dscrn) == 0){
@@ -891,7 +763,7 @@ _drawmsgwrite(void *v, int n)
dstid = BGLONG(a+1);
if(dstid == 0)
goto Ebadarg;
- if(drawlookupdscreen(dstid))
+ if(drawlookupdscreen(client, dstid))
goto Escreenexists;
ddst = drawlookup(client, BGLONG(a+5), 1);
dsrc = drawlookup(client, BGLONG(a+9), 1);
@@ -935,7 +807,7 @@ _drawmsgwrite(void *v, int n)
drawpoint(&q, a+37);
op = drawclientop(client);
memdraw(dst, r, src, p, mask, q, op);
- dstflush(dstid, dst, r);
+ dstflush(client, dstid, dst, r);
continue;
/* toggle debugging: 'D' val[1] */
@@ -969,7 +841,7 @@ _drawmsgwrite(void *v, int n)
err = "negative ellipse thickness";
goto error;
}
-
+
drawpoint(&sp, a+29);
c = j;
if(*a == 'E')
@@ -984,7 +856,7 @@ _drawmsgwrite(void *v, int n)
memarc(dst, p, e0, e1, c, src, sp, ox, oy, op);
}else
memellipse(dst, p, e0, e1, c, src, sp, op);
- dstflush(dstid, dst, Rect(p.x-e0-j, p.y-e1-j, p.x+e0+j+1, p.y+e1+j+1));
+ dstflush(client, dstid, dst, Rect(p.x-e0-j, p.y-e1-j, p.x+e0+j+1, p.y+e1+j+1));
continue;
/* free: 'f' id[4] */
@@ -1049,7 +921,7 @@ _drawmsgwrite(void *v, int n)
goto Eshortdraw;
if(drawlookup(client, 0, 0))
goto Eimageexists;
- drawinstall(client, 0, screenimage, 0);
+ drawinstall(client, 0, client->screenimage, 0);
client->infoid = 0;
continue;
@@ -1061,7 +933,7 @@ _drawmsgwrite(void *v, int n)
if(client->infoid < 0)
goto Enodrawimage;
if(client->infoid == 0){
- i = screenimage;
+ i = client->screenimage;
if(i == nil)
goto Enodrawimage;
}else{
@@ -1073,11 +945,11 @@ _drawmsgwrite(void *v, int n)
ni = sprint(ibuf, "%11d %11d %11s %11d %11d %11d %11d %11d"
" %11d %11d %11d %11d ",
client->clientid,
- client->infoid,
+ client->infoid,
chantostr(cbuf, i->chan),
(i->flags&Frepl)==Frepl,
i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y,
- i->clipr.min.x, i->clipr.min.y,
+ i->clipr.min.x, i->clipr.min.y,
i->clipr.max.x, i->clipr.max.y);
free(client->readdata);
client->readdata = malloc(ni);
@@ -1087,7 +959,7 @@ _drawmsgwrite(void *v, int n)
client->nreaddata = ni;
client->infoid = -1;
continue;
-
+
/* query: 'Q' n[1] queryspec[n] */
case 'q':
if(n < 2)
@@ -1102,10 +974,10 @@ _drawmsgwrite(void *v, int n)
err = "unknown query";
goto error;
case 'd': /* dpi */
- if(forcedpi)
- fmtprint(&fmt, "%11d ", forcedpi);
+ if(client->forcedpi)
+ fmtprint(&fmt, "%11d ", client->forcedpi);
else
- fmtprint(&fmt, "%11d ", displaydpi);
+ fmtprint(&fmt, "%11d ", client->displaydpi);
break;
}
}
@@ -1169,7 +1041,7 @@ _drawmsgwrite(void *v, int n)
if(dstid==0 || dst->layer!=nil){
/* BUG: this is terribly inefficient: update maximal containing rect*/
r = memlinebbox(p, q, e0, e1, j);
- dstflush(dstid, dst, insetrect(r, -(1+1+j)));
+ dstflush(client, dstid, dst, insetrect(r, -(1+1+j)));
}
continue;
@@ -1198,7 +1070,7 @@ _drawmsgwrite(void *v, int n)
dstid = BGLONG(a+1);
if(drawlookup(client, dstid, 0))
goto Eimageexists;
- dn = drawlookupname(j, (char*)a+6);
+ dn = drawlookupname(client, j, (char*)a+6);
if(dn == nil)
goto Enoname;
s = malloc(j+1);
@@ -1239,12 +1111,12 @@ _drawmsgwrite(void *v, int n)
if(drawaddname(client, di, j, (char*)a+7, &err) < 0)
goto error;
else{
- dn = drawlookupname(j, (char*)a+7);
+ dn = drawlookupname(client, j, (char*)a+7);
if(dn == nil)
goto Enoname;
if(dn->dimage != di)
goto Ewrongname;
- drawdelname(dn);
+ drawdelname(client, dn);
}
continue;
@@ -1266,8 +1138,8 @@ _drawmsgwrite(void *v, int n)
goto error;
}
if(ni > 0){
- addflush(r);
- addflush(dst->layer->screenr);
+ addflush(client, r);
+ addflush(client, dst->layer->screenr);
ll = drawlookup(client, BGLONG(a+1), 1);
drawrefreshscreen(ll, client);
}
@@ -1316,7 +1188,7 @@ _drawmsgwrite(void *v, int n)
if(pp == nil)
goto Enomem;
doflush = 0;
- if(dstid==0 || (dst->layer && dst->layer->screen->image->data == screenimage->data))
+ if(dstid==0 || (dst->layer && dst->layer->screen->image->data == client->screenimage->data))
doflush = 1; /* simplify test in loop */
ox = oy = 0;
esize = 0;
@@ -1353,12 +1225,12 @@ _drawmsgwrite(void *v, int n)
combinerect(&r, Rect(p.x-esize, p.y-esize, p.x+esize+1, p.y+esize+1));
}
if(rectclip(&r, dst->clipr)) /* should perhaps be an arg to dstflush */
- dstflush(dstid, dst, r);
+ dstflush(client, dstid, dst, r);
}
pp[y] = p;
}
if(y == 1)
- dstflush(dstid, dst, Rect(p.x-esize, p.y-esize, p.x+esize+1, p.y+esize+1));
+ dstflush(client, dstid, dst, Rect(p.x-esize, p.y-esize, p.x+esize+1, p.y+esize+1));
op = drawclientop(client);
if(*a == 'p')
mempoly(dst, pp, ni, e0, e1, j, src, sp, op);
@@ -1462,7 +1334,7 @@ _drawmsgwrite(void *v, int n)
}
dst->clipr = clipr;
p.y -= font->ascent;
- dstflush(dstid, dst, Rect(p.x, p.y, q.x, p.y+Dy(font->image->r)));
+ dstflush(client, dstid, dst, Rect(p.x, p.y, q.x, p.y+Dy(font->image->r)));
continue;
/* use public screen: 'S' id[4] chan[4] */
@@ -1473,7 +1345,7 @@ _drawmsgwrite(void *v, int n)
dstid = BGLONG(a+1);
if(dstid == 0)
goto Ebadarg;
- dscrn = drawlookupdscreen(dstid);
+ dscrn = drawlookupdscreen(client, dstid);
if(dscrn==0 || (dscrn->public==0 && dscrn->owner!=client))
goto Enodrawscreen;
if(dscrn->screen->image->chan != BGLONG(a+5)){
@@ -1522,9 +1394,9 @@ _drawmsgwrite(void *v, int n)
memltofrontn(lp, nw);
else
memltorearn(lp, nw);
- if(lp[0]->layer->screen->image->data == screenimage->data)
+ if(lp[0]->layer->screen->image->data == client->screenimage->data)
for(j=0; jlayer->screenr);
+ addflush(client, lp[j]->layer->screenr);
free(lp);
ll = drawlookup(client, BGLONG(a+1+1+2), 1);
drawrefreshscreen(ll, client);
@@ -1533,7 +1405,7 @@ _drawmsgwrite(void *v, int n)
/* visible: 'v' */
case 'v':
m = 1;
- drawflush();
+ drawflush(client);
continue;
/* write: 'y' id[4] R[4*4] data[x*1] */
@@ -1555,12 +1427,13 @@ _drawmsgwrite(void *v, int n)
err = "bad writeimage call";
goto error;
}
- dstflush(dstid, dst, r);
+ dstflush(client, dstid, dst, r);
m += y;
continue;
}
}
- qunlock(&sdraw.lk);
+ rpc_gfxdrawunlock();
+ qunlock(&drawlk);
return oldn - n;
Enodrawimage:
@@ -1630,8 +1503,7 @@ _drawmsgwrite(void *v, int n)
error:
werrstr("%s", err);
- qunlock(&sdraw.lk);
+ rpc_gfxdrawunlock();
+ qunlock(&drawlk);
return -1;
}
-
-
diff --git a/src/cmd/devdraw/devdraw.h b/src/cmd/devdraw/devdraw.h
index f768735f5..261d04d1e 100644
--- a/src/cmd/devdraw/devdraw.h
+++ b/src/cmd/devdraw/devdraw.h
@@ -1,10 +1,236 @@
-int _drawmsgread(void*, int);
-int _drawmsgwrite(void*, int);
-void _initdisplaymemimage(Memimage*);
-int _latin1(Rune*, int);
-int parsewinsize(char*, Rectangle*, int*);
+
+#define NHASH (1<<5)
+#define HASHMASK (NHASH-1)
+
+typedef struct Kbdbuf Kbdbuf;
+typedef struct Mousebuf Mousebuf;
+typedef struct Tagbuf Tagbuf;
+
+typedef struct Client Client;
+typedef struct ClientImpl ClientImpl;
+typedef struct DImage DImage;
+typedef struct DScreen DScreen;
+typedef struct CScreen CScreen;
+typedef struct FChar FChar;
+typedef struct Refresh Refresh;
+typedef struct Refx Refx;
+typedef struct DName DName;
+
+struct Kbdbuf
+{
+ Rune r[256];
+ int ri;
+ int wi;
+ int stall;
+ int alting;
+ Rune k[10];
+ int nk;
+};
+
+struct Mousebuf
+{
+ Mouse m[256];
+ Mouse last;
+ int ri;
+ int wi;
+ int stall;
+ int resized;
+};
+
+struct Tagbuf
+{
+ int t[256];
+ int ri;
+ int wi;
+};
+
+struct ClientImpl
+{
+ void (*rpc_resizeimg)(Client*);
+ void (*rpc_resizewindow)(Client*, Rectangle);
+ void (*rpc_setcursor)(Client*, Cursor*, Cursor2*);
+ void (*rpc_setlabel)(Client*, char*);
+ void (*rpc_setmouse)(Client*, Point);
+ void (*rpc_topwin)(Client*);
+ void (*rpc_bouncemouse)(Client*, Mouse);
+ void (*rpc_flush)(Client*, Rectangle);
+};
+
+extern QLock drawlk;
+
+struct Client
+{
+ int rfd;
+
+ // wfdlk protects writes to wfd, which can be issued from either
+ // the RPC thread or the graphics thread.
+ QLock wfdlk;
+ int wfd;
+ uchar* mbuf;
+ int nmbuf;
+
+ char* wsysid;
+
+ // drawlk protects the draw data structures for all clients.
+ // It can be acquired by an RPC thread or a graphics thread
+ // but must not be held on one thread while waiting for the other.
+ /*Ref r;*/
+ DImage* dimage[NHASH];
+ CScreen* cscreen;
+ Refresh* refresh;
+ Rendez refrend;
+ uchar* readdata;
+ int nreaddata;
+ int busy;
+ int clientid;
+ int slot;
+ int refreshme;
+ int infoid;
+ int op;
+ int displaydpi;
+ int forcedpi;
+ int waste;
+ Rectangle flushrect;
+ Memimage *screenimage;
+ DScreen* dscreen;
+ int nname;
+ DName* name;
+ int namevers;
+ ClientImpl* impl;
+
+ // Only accessed/modified by the graphics thread.
+ const void* view;
+
+ // eventlk protects the keyboard and mouse events.
+ QLock eventlk;
+ Kbdbuf kbd;
+ Mousebuf mouse;
+ Tagbuf kbdtags;
+ Tagbuf mousetags;
+ Rectangle mouserect;
+};
+
+struct Refresh
+{
+ DImage* dimage;
+ Rectangle r;
+ Refresh* next;
+};
+
+struct Refx
+{
+ Client* client;
+ DImage* dimage;
+};
+
+struct DName
+{
+ char *name;
+ Client *client;
+ DImage* dimage;
+ int vers;
+};
+
+struct FChar
+{
+ int minx; /* left edge of bits */
+ int maxx; /* right edge of bits */
+ uchar miny; /* first non-zero scan-line */
+ uchar maxy; /* last non-zero scan-line + 1 */
+ schar left; /* offset of baseline */
+ uchar width; /* width of baseline */
+};
+
+/*
+ * Reference counts in DImages:
+ * one per open by original client
+ * one per screen image or fill
+ * one per image derived from this one by name
+ */
+struct DImage
+{
+ int id;
+ int ref;
+ char *name;
+ int vers;
+ Memimage* image;
+ int ascent;
+ int nfchar;
+ FChar* fchar;
+ DScreen* dscreen; /* 0 if not a window */
+ DImage* fromname; /* image this one is derived from, by name */
+ DImage* next;
+};
+
+struct CScreen
+{
+ DScreen* dscreen;
+ CScreen* next;
+};
+
+struct DScreen
+{
+ int id;
+ int public;
+ int ref;
+ DImage *dimage;
+ DImage *dfill;
+ Memscreen* screen;
+ Client* owner;
+ DScreen* next;
+};
+
+// For the most part, the graphics driver-specific code in files
+// like mac-screen.m runs in the graphics library's main thread,
+// while the RPC service code in srv.c runs on the RPC service thread.
+// The exceptions in each file, which are called by the other,
+// are marked with special prefixes: gfx_* indicates code that
+// is in srv.c but nonetheless runs on the main graphics thread,
+// while rpc_* indicates code that is in, say, mac-screen.m but
+// nonetheless runs on the RPC service thread.
+//
+// The gfx_* and rpc_* calls typically synchronize with the other
+// code in the file by acquiring a lock (or running a callback on the
+// target thread, which amounts to the same thing).
+// To avoid deadlock, callers of those routines must not hold any locks.
+
+// gfx_* routines are called on the graphics thread,
+// invoked from graphics driver callbacks to do RPC work.
+// No locks are held on entry.
+void gfx_abortcompose(Client*);
+void gfx_keystroke(Client*, int);
+void gfx_main(void);
+void gfx_mousetrack(Client*, int, int, int, uint);
+void gfx_replacescreenimage(Client*, Memimage*);
+void gfx_mouseresized(Client*);
+void gfx_started(void);
+
+// rpc_* routines are called on the RPC thread,
+// invoked by the RPC server code to do graphics work.
+// No locks are held on entry.
+Memimage *rpc_attach(Client*, char*, char*);
+char* rpc_getsnarf(void);
+void rpc_putsnarf(char*);
+void rpc_shutdown(void);
+void rpc_main(void);
+
+// rpc_gfxdrawlock and rpc_gfxdrawunlock
+// are called around drawing operations to lock and unlock
+// access to the graphics display, for systems where the
+// individual memdraw operations use the graphics display (X11, not macOS).
+void rpc_gfxdrawlock(void);
+void rpc_gfxdrawunlock(void);
+
+// draw* routines are called on the RPC thread,
+// invoked by the RPC server to do pixel pushing.
+// No locks are held on entry.
+int draw_dataread(Client*, void*, int);
+int draw_datawrite(Client*, void*, int);
+void draw_initdisplaymemimage(Client*, Memimage*);
+
+// utility routines
+int latin1(Rune*, int);
int mouseswap(int);
-void abortcompose(void);
+int parsewinsize(char*, Rectangle*, int*);
-extern int displaydpi;
-extern int forcedpi;
+extern Client *client0; // set in single-client mode
diff --git a/src/cmd/devdraw/drawclient.c b/src/cmd/devdraw/drawclient.c
index 87df3f18c..71c7142d1 100644
--- a/src/cmd/devdraw/drawclient.c
+++ b/src/cmd/devdraw/drawclient.c
@@ -4,7 +4,7 @@
#include
#include
#include
-#include
+#include
typedef struct Cmd Cmd;
struct Cmd {
@@ -20,7 +20,7 @@ void
startsrv(void)
{
int pid, p[2];
-
+
if(pipe(p) < 0)
sysfatal("pipe");
if((pid=fork()) < 0)
@@ -29,7 +29,7 @@ startsrv(void)
close(p[0]);
dup(p[1], 0);
dup(p[1], 1);
- execl("o.drawsrv", "o.drawsrv", "-D", nil);
+ execl("./o.devdraw", "o.devdraw", "-D", nil);
sysfatal("exec: %r");
}
close(p[1]);
@@ -47,7 +47,7 @@ fprint(2, "write %d to %d\n", n, fd);
n = readwsysmsg(fd, buf, sizeof buf);
nn = convM2W(buf, n, m);
assert(nn == n);
- if(m->op == Rerror)
+ if(m->type == Rerror)
return -1;
return 0;
}
@@ -56,12 +56,11 @@ void
cmdinit(int argc, char **argv)
{
Wsysmsg m;
-
+
memset(&m, 0, sizeof m);
- m.op = Tinit;
+ m.type = Tinit;
m.winsize = "100x100";
m.label = "label";
- m.font = "";
if(domsg(&m) < 0)
sysfatal("domsg");
}
@@ -70,9 +69,9 @@ void
cmdmouse(int argc, char **argv)
{
Wsysmsg m;
-
+
memset(&m, 0, sizeof m);
- m.op = Trdmouse;
+ m.type = Trdmouse;
if(domsg(&m) < 0)
sysfatal("domsg");
print("%c %d %d %d\n",
@@ -86,12 +85,12 @@ void
cmdkbd(int argc, char **argv)
{
Wsysmsg m;
-
+
memset(&m, 0, sizeof m);
- m.op = Trdkbd;
+ m.type = Trdkbd;
if(domsg(&m) < 0)
sysfatal("domsg");
- print("%s\n", m.runes);
+ print("%d\n", m.rune);
}
Cmd cmdtab[] = {
@@ -125,4 +124,3 @@ fprint(2, "%s...\n", p);
}
exits(0);
}
-
diff --git a/src/cmd/devdraw/latin1.c b/src/cmd/devdraw/latin1.c
index 09c67523c..87c0be458 100644
--- a/src/cmd/devdraw/latin1.c
+++ b/src/cmd/devdraw/latin1.c
@@ -17,16 +17,15 @@ static struct cvlist
};
/*
- * Given 5 characters k[0]..k[4], find the rune or return -1 for failure.
+ * Given 5 characters k[0]..k[n], find the rune or return -1 for failure.
*/
static long
-unicode(Rune *k)
+unicode(Rune *k, int n)
{
long i, c;
- k++; /* skip 'X' */
c = 0;
- for(i=0; i<4; i++,k++){
+ for(i=0; i Runemax)
+ return -1;
}
return c;
}
@@ -46,19 +47,41 @@ unicode(Rune *k)
* is minus the required n.
*/
int
-_latin1(Rune *k, int n)
+latin1(Rune *k, int n)
{
struct cvlist *l;
int c;
char* p;
if(k[0] == 'X'){
- if(n>=5)
- return unicode(k);
- else
- return -5;
+ if(n < 2)
+ return -2;
+ if(k[1] == 'X') {
+ if(n < 3)
+ return -3;
+ if(k[2] == 'X') {
+ if(n < 9) {
+ if(unicode(k+3, n-3) < 0)
+ return -1;
+ return -(n+1);
+ }
+ return unicode(k+3, 6);
+ }
+ if(n < 7) {
+ if(unicode(k+2, n-2) < 0)
+ return -1;
+ return -(n+1);
+ }
+ return unicode(k+2, 5);
+ }
+ if(n < 5) {
+ if(unicode(k+1, n-1) < 0)
+ return -1;
+ return -(n+1);
+ }
+ return unicode(k+1, 4);
}
-
+
for(l=latintab; l->ld!=0; l++)
if(k[0] == l->ld[0]){
if(n == 1)
diff --git a/src/cmd/devdraw/osx-draw.c b/src/cmd/devdraw/mac-draw.c
similarity index 99%
rename from src/cmd/devdraw/osx-draw.c
rename to src/cmd/devdraw/mac-draw.c
index d3f083316..fdf7acecd 100644
--- a/src/cmd/devdraw/osx-draw.c
+++ b/src/cmd/devdraw/mac-draw.c
@@ -56,4 +56,3 @@ unloadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
{
return _unloadmemimage(i, r, data, ndata);
}
-
diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m
new file mode 100644
index 000000000..9e51eec6e
--- /dev/null
+++ b/src/cmd/devdraw/mac-screen.m
@@ -0,0 +1,1253 @@
+#define Cursor OSXCursor
+#define Point OSXPoint
+#define Rect OSXRect
+
+#import
+#import
+#import
+
+#undef Cursor
+#undef Point
+#undef Rect
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "devdraw.h"
+#include "bigarrow.h"
+#include "glendapng.h"
+
+AUTOFRAMEWORK(Cocoa)
+AUTOFRAMEWORK(Metal)
+AUTOFRAMEWORK(QuartzCore)
+AUTOFRAMEWORK(CoreFoundation)
+
+#define LOG if(0)NSLog
+
+// TODO: Maintain list of views for dock menu.
+
+static void setprocname(const char*);
+static uint keycvt(uint);
+static uint msec(void);
+
+static void rpc_resizeimg(Client*);
+static void rpc_resizewindow(Client*, Rectangle);
+static void rpc_setcursor(Client*, Cursor*, Cursor2*);
+static void rpc_setlabel(Client*, char*);
+static void rpc_setmouse(Client*, Point);
+static void rpc_topwin(Client*);
+static void rpc_bouncemouse(Client*, Mouse);
+static void rpc_flush(Client*, Rectangle);
+
+static ClientImpl macimpl = {
+ rpc_resizeimg,
+ rpc_resizewindow,
+ rpc_setcursor,
+ rpc_setlabel,
+ rpc_setmouse,
+ rpc_topwin,
+ rpc_bouncemouse,
+ rpc_flush
+};
+
+@class DrawView;
+@class DrawLayer;
+
+@interface AppDelegate : NSObject
+@end
+
+static AppDelegate *myApp = NULL;
+
+void
+gfx_main(void)
+{
+ if(client0)
+ setprocname(argv0);
+
+ @autoreleasepool{
+ [NSApplication sharedApplication];
+ [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
+ myApp = [AppDelegate new];
+ [NSApp setDelegate:myApp];
+ [NSApp run];
+ }
+}
+
+
+void
+rpc_shutdown(void)
+{
+ [NSApp terminate:myApp];
+}
+
+@implementation AppDelegate
+- (void)applicationDidFinishLaunching:(id)arg
+{
+ NSMenu *m, *sm;
+ NSData *d;
+ NSImage *i;
+
+ LOG(@"applicationDidFinishLaunching");
+
+ sm = [NSMenu new];
+ [sm addItemWithTitle:@"Toggle Full Screen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"];
+ [sm addItemWithTitle:@"Hide" action:@selector(hide:) keyEquivalent:@"h"];
+ [sm addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
+ m = [NSMenu new];
+ [m addItemWithTitle:@"DEVDRAW" action:NULL keyEquivalent:@""];
+ [m setSubmenu:sm forItem:[m itemWithTitle:@"DEVDRAW"]];
+ [NSApp setMainMenu:m];
+
+ d = [[NSData alloc] initWithBytes:glenda_png length:(sizeof glenda_png)];
+ i = [[NSImage alloc] initWithData:d];
+ [NSApp setApplicationIconImage:i];
+ [[NSApp dockTile] display];
+
+ gfx_started();
+}
+
+- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication {
+ return client0 != nil;
+}
+@end
+
+@interface DrawLayer : CAMetalLayer
+@property (nonatomic, retain) id cmd;
+@property (nonatomic, retain) id texture;
+@end
+
+@implementation DrawLayer
+- (void)display
+{
+ LOG(@"display");
+ LOG(@"display query drawable");
+
+ @autoreleasepool{
+ id drawable = [self nextDrawable];
+ if(!drawable){
+ LOG(@"display couldn't get drawable");
+ [self setNeedsDisplay];
+ return;
+ }
+
+ LOG(@"display got drawable");
+
+ id cbuf = [self.cmd commandBuffer];
+ id blit = [cbuf blitCommandEncoder];
+ [blit copyFromTexture:self.texture
+ sourceSlice:0
+ sourceLevel:0
+ sourceOrigin:MTLOriginMake(0, 0, 0)
+ sourceSize:MTLSizeMake(self.texture.width, self.texture.height, self.texture.depth)
+ toTexture:drawable.texture
+ destinationSlice:0
+ destinationLevel:0
+ destinationOrigin:MTLOriginMake(0, 0, 0)];
+ [blit endEncoding];
+
+ [cbuf presentDrawable:drawable];
+ drawable = nil;
+ [cbuf addCompletedHandler:^(id cmdBuff){
+ if(cmdBuff.error){
+ NSLog(@"command buffer finished with error: %@",
+ cmdBuff.error.localizedDescription);
+ }else
+ LOG(@"command buffer finishes present drawable");
+ }];
+ [cbuf commit];
+ }
+ LOG(@"display commit");
+}
+@end
+
+@interface DrawView : NSView
+@property (nonatomic, assign) Client *client;
+@property (nonatomic, retain) DrawLayer *dlayer;
+@property (nonatomic, retain) NSWindow *win;
+@property (nonatomic, retain) NSCursor *currentCursor;
+@property (nonatomic, assign) Memimage *img;
+
+- (id)attach:(Client*)client winsize:(char*)winsize label:(char*)label;
+- (void)topwin;
+- (void)setlabel:(char*)label;
+- (void)setcursor:(Cursor*)c cursor2:(Cursor2*)c2;
+- (void)setmouse:(Point)p;
+- (void)clearInput;
+- (void)getmouse:(NSEvent*)e;
+- (void)sendmouse:(NSUInteger)b;
+- (void)resetLastInputRect;
+- (void)enlargeLastInputRect:(NSRect)r;
+@end
+
+@implementation DrawView
+{
+ NSMutableString *_tmpText;
+ NSRange _markedRange;
+ NSRange _selectedRange;
+ NSRect _lastInputRect; // The view is flipped, this is not.
+ BOOL _tapping;
+ NSUInteger _tapFingers;
+ NSUInteger _tapTime;
+}
+
+- (id)init
+{
+ LOG(@"View init");
+ self = [super init];
+ [self setAllowedTouchTypes:NSTouchTypeMaskDirect|NSTouchTypeMaskIndirect];
+ _tmpText = [[NSMutableString alloc] initWithCapacity:2];
+ _markedRange = NSMakeRange(NSNotFound, 0);
+ _selectedRange = NSMakeRange(0, 0);
+ return self;
+}
+
+- (CALayer*)makeBackingLayer { return [DrawLayer layer]; }
+- (BOOL)wantsUpdateLayer { return YES; }
+- (BOOL)isOpaque { return YES; }
+- (BOOL)isFlipped { return YES; }
+- (BOOL)acceptsFirstResponder { return YES; }
+
+// rpc_attach allocates a new screen window with the given label and size
+// and attaches it to client c (by setting c->view).
+Memimage*
+rpc_attach(Client *c, char *label, char *winsize)
+{
+ LOG(@"attachscreen(%s, %s)", label, winsize);
+
+ c->impl = &macimpl;
+ dispatch_sync(dispatch_get_main_queue(), ^(void) {
+ @autoreleasepool {
+ DrawView *view = [[DrawView new] attach:c winsize:winsize label:label];
+ [view initimg];
+ }
+ });
+ return ((__bridge DrawView*)c->view).img;
+}
+
+- (id)attach:(Client*)client winsize:(char*)winsize label:(char*)label {
+ NSRect r, sr;
+ Rectangle wr;
+ int set;
+ char *s;
+ NSArray *allDevices;
+
+ NSWindowStyleMask Winstyle = NSWindowStyleMaskTitled
+ | NSWindowStyleMaskClosable
+ | NSWindowStyleMaskMiniaturizable
+ | NSWindowStyleMaskResizable;
+
+ if(label == nil || *label == '\0')
+ Winstyle &= ~NSWindowStyleMaskTitled;
+
+ s = winsize;
+ sr = [[NSScreen mainScreen] frame];
+ r = [[NSScreen mainScreen] visibleFrame];
+
+ LOG(@"makewin(%s)", s);
+ if(s == nil || *s == '\0' || parsewinsize(s, &wr, &set) < 0) {
+ wr = Rect(0, 0, sr.size.width*2/3, sr.size.height*2/3);
+ set = 0;
+ }
+
+ r.origin.x = wr.min.x;
+ r.origin.y = sr.size.height-wr.max.y; /* winsize is top-left-based */
+ r.size.width = fmin(Dx(wr), r.size.width);
+ r.size.height = fmin(Dy(wr), r.size.height);
+ r = [NSWindow contentRectForFrameRect:r styleMask:Winstyle];
+
+ NSWindow *win = [[NSWindow alloc]
+ initWithContentRect:r
+ styleMask:Winstyle
+ backing:NSBackingStoreBuffered defer:NO];
+ [win setTitle:@"devdraw"];
+
+ if(!set)
+ [win center];
+ [win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
+ [win setContentMinSize:NSMakeSize(64,64)];
+ [win setOpaque:YES];
+ [win setRestorable:NO];
+ [win setAcceptsMouseMovedEvents:YES];
+
+ client->view = CFBridgingRetain(self);
+ self.client = client;
+ self.win = win;
+ self.currentCursor = nil;
+ [win setContentView:self];
+ [win setDelegate:self];
+ [self setWantsLayer:YES];
+ [self setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay];
+
+ id device = nil;
+ allDevices = MTLCopyAllDevices();
+ for(id mtlDevice in allDevices) {
+ if ([mtlDevice isLowPower] && ![mtlDevice isRemovable]) {
+ device = mtlDevice;
+ break;
+ }
+ }
+ if(!device)
+ device = MTLCreateSystemDefaultDevice();
+
+ DrawLayer *layer = (DrawLayer*)[self layer];
+ self.dlayer = layer;
+ layer.device = device;
+ layer.cmd = [device newCommandQueue];
+ layer.pixelFormat = MTLPixelFormatBGRA8Unorm;
+ layer.framebufferOnly = YES;
+ layer.opaque = YES;
+
+ // We use a default transparent layer on top of the CAMetalLayer.
+ // This seems to make fullscreen applications behave.
+ // Specifically, without this code if you enter full screen with Cmd-F,
+ // the screen goes black until the first mouse click.
+ if(1) {
+ CALayer *stub = [CALayer layer];
+ stub.frame = CGRectMake(0, 0, 1, 1);
+ [stub setNeedsDisplay];
+ [layer addSublayer:stub];
+ }
+
+ [NSEvent setMouseCoalescingEnabled:NO];
+
+ [self topwin];
+ [self setlabel:label];
+ [self setcursor:nil cursor2:nil];
+
+ return self;
+}
+
+// rpc_topwin moves the window to the top of the desktop.
+// Called from an RPC thread with no client lock held.
+static void
+rpc_topwin(Client *c)
+{
+ DrawView *view = (__bridge DrawView*)c->view;
+ dispatch_sync(dispatch_get_main_queue(), ^(void) {
+ [view topwin];
+ });
+}
+
+- (void)topwin {
+ [self.win makeKeyAndOrderFront:nil];
+ [NSApp activateIgnoringOtherApps:YES];
+}
+
+// rpc_setlabel updates the client window's label.
+// If label == nil, the call is a no-op.
+// Called from an RPC thread with no client lock held.
+static void
+rpc_setlabel(Client *client, char *label)
+{
+ DrawView *view = (__bridge DrawView*)client->view;
+ dispatch_sync(dispatch_get_main_queue(), ^(void){
+ [view setlabel:label];
+ });
+}
+
+- (void)setlabel:(char*)label {
+ LOG(@"setlabel(%s)", label);
+ if(label == nil)
+ return;
+
+ @autoreleasepool{
+ NSString *s = [[NSString alloc] initWithUTF8String:label];
+ [self.win setTitle:s];
+ if(client0)
+ [[NSApp dockTile] setBadgeLabel:s];
+ }
+}
+
+// rpc_setcursor updates the client window's cursor image.
+// Either c and c2 are both non-nil, or they are both nil to use the default arrow.
+// Called from an RPC thread with no client lock held.
+static void
+rpc_setcursor(Client *client, Cursor *c, Cursor2 *c2)
+{
+ DrawView *view = (__bridge DrawView*)client->view;
+ dispatch_sync(dispatch_get_main_queue(), ^(void){
+ [view setcursor:c cursor2:c2];
+ });
+}
+
+- (void)setcursor:(Cursor*)c cursor2:(Cursor2*)c2 {
+ if(!c) {
+ c = &bigarrow;
+ c2 = &bigarrow2;
+ }
+
+ NSBitmapImageRep *r, *r2;
+ NSImage *i;
+ NSPoint p;
+ uchar *plane[5], *plane2[5];
+ uint b;
+
+ r = [[NSBitmapImageRep alloc]
+ initWithBitmapDataPlanes:nil
+ pixelsWide:16
+ pixelsHigh:16
+ bitsPerSample:1
+ samplesPerPixel:2
+ hasAlpha:YES
+ isPlanar:YES
+ colorSpaceName:NSDeviceWhiteColorSpace
+ bytesPerRow:2
+ bitsPerPixel:0];
+ [r getBitmapDataPlanes:plane];
+ for(b=0; bset); b++){
+ plane[0][b] = ~c->set[b] & c->clr[b];
+ plane[1][b] = c->set[b] | c->clr[b];
+ }
+
+ r2 = [[NSBitmapImageRep alloc]
+ initWithBitmapDataPlanes:nil
+ pixelsWide:32
+ pixelsHigh:32
+ bitsPerSample:1
+ samplesPerPixel:2
+ hasAlpha:YES
+ isPlanar:YES
+ colorSpaceName:NSDeviceWhiteColorSpace
+ bytesPerRow:4
+ bitsPerPixel:0];
+ [r2 getBitmapDataPlanes:plane2];
+ for(b=0; bset); b++){
+ plane2[0][b] = ~c2->set[b] & c2->clr[b];
+ plane2[1][b] = c2->set[b] | c2->clr[b];
+ }
+
+ static BOOL debug = NO;
+ if(debug){
+ NSData *data = [r representationUsingType: NSBitmapImageFileTypeBMP properties: @{}];
+ [data writeToFile: @"/tmp/r.bmp" atomically: NO];
+ data = [r2 representationUsingType: NSBitmapImageFileTypeBMP properties: @{}];
+ [data writeToFile: @"/tmp/r2.bmp" atomically: NO];
+ debug = NO;
+ }
+
+ i = [[NSImage alloc] initWithSize:NSMakeSize(16, 16)];
+ [i addRepresentation:r2];
+ [i addRepresentation:r];
+
+ p = NSMakePoint(-c->offset.x, -c->offset.y);
+ self.currentCursor = [[NSCursor alloc] initWithImage:i hotSpot:p];
+ [self.win invalidateCursorRectsForView:self];
+}
+
+- (void)initimg {
+ @autoreleasepool {
+ CGFloat scale;
+ NSSize size;
+ MTLTextureDescriptor *textureDesc;
+
+ size = [self convertSizeToBacking:[self bounds].size];
+ self.client->mouserect = Rect(0, 0, size.width, size.height);
+
+ LOG(@"initimg %.0f %.0f", size.width, size.height);
+
+ self.img = allocmemimage(self.client->mouserect, XRGB32);
+ if(self.img == nil)
+ panic("allocmemimage: %r");
+ if(self.img->data == nil)
+ panic("img->data == nil");
+
+ textureDesc = [MTLTextureDescriptor
+ texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm
+ width:size.width
+ height:size.height
+ mipmapped:NO];
+ textureDesc.allowGPUOptimizedContents = YES;
+ textureDesc.usage = MTLTextureUsageShaderRead;
+ textureDesc.cpuCacheMode = MTLCPUCacheModeWriteCombined;
+ self.dlayer.texture = [self.dlayer.device newTextureWithDescriptor:textureDesc];
+
+ scale = [self.win backingScaleFactor];
+ [self.dlayer setDrawableSize:size];
+ [self.dlayer setContentsScale:scale];
+
+ // NOTE: This is not really the display DPI.
+ // On retina, scale is 2; otherwise it is 1.
+ // This formula gives us 220 for retina, 110 otherwise.
+ // That's not quite right but it's close to correct.
+ // https://en.wikipedia.org/wiki/Retina_display#Models
+ self.client->displaydpi = scale * 110;
+ }
+}
+
+// rpc_flush flushes changes to view.img's rectangle r
+// to the on-screen window, making them visible.
+// Called from an RPC thread with no client lock held.
+static void
+rpc_flush(Client *client, Rectangle r)
+{
+ DrawView *view = (__bridge DrawView*)client->view;
+ dispatch_async(dispatch_get_main_queue(), ^(void){
+ [view flush:r];
+ });
+}
+
+- (void)flush:(Rectangle)r {
+ @autoreleasepool{
+ if(!rectclip(&r, Rect(0, 0, self.dlayer.texture.width, self.dlayer.texture.height)) || !rectclip(&r, self.img->r))
+ return;
+
+ // drawlk protects the pixel data in self.img.
+ // In addition to avoiding a technical data race,
+ // the lock avoids drawing partial updates, which makes
+ // animations like sweeping windows much less flickery.
+ qlock(&drawlk);
+ [self.dlayer.texture
+ replaceRegion:MTLRegionMake2D(r.min.x, r.min.y, Dx(r), Dy(r))
+ mipmapLevel:0
+ withBytes:byteaddr(self.img, Pt(r.min.x, r.min.y))
+ bytesPerRow:self.img->width*sizeof(u32int)];
+ qunlock(&drawlk);
+
+ NSRect nr = NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r));
+ dispatch_time_t time;
+
+ LOG(@"callsetNeedsDisplayInRect(%g, %g, %g, %g)", nr.origin.x, nr.origin.y, nr.size.width, nr.size.height);
+ nr = [self.win convertRectFromBacking:nr];
+ LOG(@"setNeedsDisplayInRect(%g, %g, %g, %g)", nr.origin.x, nr.origin.y, nr.size.width, nr.size.height);
+ [self.dlayer setNeedsDisplayInRect:nr];
+
+ time = dispatch_time(DISPATCH_TIME_NOW, 16 * NSEC_PER_MSEC);
+ dispatch_after(time, dispatch_get_main_queue(), ^(void){
+ [self.dlayer setNeedsDisplayInRect:nr];
+ });
+
+ [self enlargeLastInputRect:nr];
+ }
+}
+
+// rpc_resizeimg forces the client window to discard its current window and make a new one.
+// It is called when the user types Cmd-R to toggle whether retina mode is forced.
+// Called from an RPC thread with no client lock held.
+static void
+rpc_resizeimg(Client *c)
+{
+ DrawView *view = (__bridge DrawView*)c->view;
+ dispatch_async(dispatch_get_main_queue(), ^(void){
+ [view resizeimg];
+ });
+}
+
+- (void)resizeimg {
+ [self initimg];
+ gfx_replacescreenimage(self.client, self.img);
+}
+
+- (void)windowDidResize:(NSNotification *)notification {
+ if(![self inLiveResize] && self.img) {
+ [self resizeimg];
+ }
+}
+- (void)viewDidEndLiveResize
+{
+ [super viewDidEndLiveResize];
+ if(self.img)
+ [self resizeimg];
+}
+
+- (void)viewDidChangeBackingProperties
+{
+ [super viewDidChangeBackingProperties];
+ if(self.img)
+ [self resizeimg];
+}
+
+// rpc_resizewindow asks for the client window to be resized to size r.
+// Called from an RPC thread with no client lock held.
+static void
+rpc_resizewindow(Client *c, Rectangle r)
+{
+ DrawView *view = (__bridge DrawView*)c->view;
+
+ LOG(@"resizewindow %d %d %d %d", r.min.x, r.min.y, Dx(r), Dy(r));
+ dispatch_async(dispatch_get_main_queue(), ^(void){
+ NSSize s;
+
+ s = [view convertSizeFromBacking:NSMakeSize(Dx(r), Dy(r))];
+ [view.win setContentSize:s];
+ });
+}
+
+
+- (void)windowDidBecomeKey:(id)arg {
+ [self sendmouse:0];
+}
+
+- (void)windowDidResignKey:(id)arg {
+ gfx_abortcompose(self.client);
+}
+
+- (void)mouseMoved:(NSEvent*)e{ [self getmouse:e];}
+- (void)mouseDown:(NSEvent*)e{ [self getmouse:e];}
+- (void)mouseDragged:(NSEvent*)e{ [self getmouse:e];}
+- (void)mouseUp:(NSEvent*)e{ [self getmouse:e];}
+- (void)otherMouseDown:(NSEvent*)e{ [self getmouse:e];}
+- (void)otherMouseDragged:(NSEvent*)e{ [self getmouse:e];}
+- (void)otherMouseUp:(NSEvent*)e{ [self getmouse:e];}
+- (void)rightMouseDown:(NSEvent*)e{ [self getmouse:e];}
+- (void)rightMouseDragged:(NSEvent*)e{ [self getmouse:e];}
+- (void)rightMouseUp:(NSEvent*)e{ [self getmouse:e];}
+
+- (void)scrollWheel:(NSEvent*)e
+{
+ NSInteger s;
+
+ s = [e scrollingDeltaY];
+ if(s > 0)
+ [self sendmouse:8];
+ else if (s < 0)
+ [self sendmouse:16];
+}
+
+- (void)keyDown:(NSEvent*)e
+{
+ LOG(@"keyDown to interpret");
+
+ [self interpretKeyEvents:[NSArray arrayWithObject:e]];
+
+ [self resetLastInputRect];
+}
+
+- (void)flagsChanged:(NSEvent*)e
+{
+ static NSEventModifierFlags omod;
+ NSEventModifierFlags m;
+ uint b;
+
+ LOG(@"flagsChanged");
+ m = [e modifierFlags];
+
+ b = [NSEvent pressedMouseButtons];
+ b = (b&~6) | (b&4)>>1 | (b&2)<<1;
+ if(b){
+ if(m & ~omod & NSEventModifierFlagControl)
+ b |= 1;
+ if(m & ~omod & NSEventModifierFlagOption)
+ b |= 2;
+ if(m & ~omod & NSEventModifierFlagCommand)
+ b |= 4;
+ [self sendmouse:b];
+ }else if(m & ~omod & NSEventModifierFlagOption)
+ gfx_keystroke(self.client, Kalt);
+
+ omod = m;
+}
+
+- (void)magnifyWithEvent:(NSEvent*)e
+{
+ if(fabs([e magnification]) > 0.02)
+ [[self window] toggleFullScreen:nil];
+}
+
+- (void)touchesBeganWithEvent:(NSEvent*)e
+{
+ _tapping = YES;
+ _tapFingers = [e touchesMatchingPhase:NSTouchPhaseTouching inView:nil].count;
+ _tapTime = msec();
+}
+- (void)touchesMovedWithEvent:(NSEvent*)e
+{
+ _tapping = NO;
+}
+- (void)touchesEndedWithEvent:(NSEvent*)e
+{
+ if(_tapping
+ && [e touchesMatchingPhase:NSTouchPhaseTouching inView:nil].count == 0
+ && msec() - _tapTime < 250){
+ switch(_tapFingers){
+ case 3:
+ [self sendmouse:2];
+ [self sendmouse:0];
+ break;
+ case 4:
+ [self sendmouse:2];
+ [self sendmouse:1];
+ [self sendmouse:0];
+ break;
+ }
+ _tapping = NO;
+ }
+}
+- (void)touchesCancelledWithEvent:(NSEvent*)e
+{
+ _tapping = NO;
+}
+
+- (void)getmouse:(NSEvent *)e
+{
+ NSUInteger b;
+ NSEventModifierFlags m;
+
+ b = [NSEvent pressedMouseButtons];
+ b = b&~6 | (b&4)>>1 | (b&2)<<1;
+ b = mouseswap(b);
+
+ if(b == 1){
+ m = [e modifierFlags];
+ if(m & NSEventModifierFlagOption){
+ gfx_abortcompose(self.client);
+ b = 2;
+ }else
+ if(m & NSEventModifierFlagCommand)
+ b = 4;
+ }
+ [self sendmouse:b];
+}
+
+- (void)sendmouse:(NSUInteger)b
+{
+ NSPoint p;
+
+ p = [self.window convertPointToBacking:
+ [self.window mouseLocationOutsideOfEventStream]];
+ p.y = Dy(self.client->mouserect) - p.y;
+ // LOG(@"(%g, %g) <- sendmouse(%d)", p.x, p.y, (uint)b);
+ gfx_mousetrack(self.client, p.x, p.y, b, msec());
+ if(b && _lastInputRect.size.width && _lastInputRect.size.height)
+ [self resetLastInputRect];
+}
+
+// rpc_setmouse moves the mouse cursor.
+// Called from an RPC thread with no client lock held.
+static void
+rpc_setmouse(Client *c, Point p)
+{
+ DrawView *view = (__bridge DrawView*)c->view;
+ dispatch_async(dispatch_get_main_queue(), ^(void){
+ [view setmouse:p];
+ });
+}
+
+- (void)setmouse:(Point)p {
+ @autoreleasepool{
+ NSPoint q;
+
+ LOG(@"setmouse(%d,%d)", p.x, p.y);
+ q = [self.win convertPointFromBacking:NSMakePoint(p.x, p.y)];
+ LOG(@"(%g, %g) <- fromBacking", q.x, q.y);
+ q = [self convertPoint:q toView:nil];
+ LOG(@"(%g, %g) <- toWindow", q.x, q.y);
+ q = [self.win convertPointToScreen:q];
+ LOG(@"(%g, %g) <- toScreen", q.x, q.y);
+ // Quartz has the origin of the "global display
+ // coordinate space" at the top left of the primary
+ // screen with y increasing downward, while Cocoa has
+ // the origin at the bottom left of the primary screen
+ // with y increasing upward. We flip the coordinate
+ // with a negative sign and shift upward by the height
+ // of the primary screen.
+ q.y = NSScreen.screens[0].frame.size.height - q.y;
+ LOG(@"(%g, %g) <- setmouse", q.x, q.y);
+ CGWarpMouseCursorPosition(NSPointToCGPoint(q));
+ CGAssociateMouseAndMouseCursorPosition(true);
+ }
+}
+
+
+- (void)resetCursorRects {
+ [super resetCursorRects];
+ [self addCursorRect:self.bounds cursor:self.currentCursor];
+}
+
+// conforms to protocol NSTextInputClient
+- (BOOL)hasMarkedText { return _markedRange.location != NSNotFound; }
+- (NSRange)markedRange { return _markedRange; }
+- (NSRange)selectedRange { return _selectedRange; }
+
+- (void)setMarkedText:(id)string
+ selectedRange:(NSRange)sRange
+ replacementRange:(NSRange)rRange
+{
+ NSString *str;
+
+ LOG(@"setMarkedText: %@ (%ld, %ld) (%ld, %ld)", string,
+ sRange.location, sRange.length,
+ rRange.location, rRange.length);
+
+ [self clearInput];
+
+ if([string isKindOfClass:[NSAttributedString class]])
+ str = [string string];
+ else
+ str = string;
+
+ if(rRange.location == NSNotFound){
+ if(_markedRange.location != NSNotFound){
+ rRange = _markedRange;
+ }else{
+ rRange = _selectedRange;
+ }
+ }
+
+ if(str.length == 0){
+ [_tmpText deleteCharactersInRange:rRange];
+ [self unmarkText];
+ }else{
+ _markedRange = NSMakeRange(rRange.location, str.length);
+ [_tmpText replaceCharactersInRange:rRange withString:str];
+ }
+ _selectedRange.location = rRange.location + sRange.location;
+ _selectedRange.length = sRange.length;
+
+ if(_tmpText.length){
+ uint i;
+ LOG(@"text length %ld", _tmpText.length);
+ for(i = 0; i <= _tmpText.length; ++i){
+ if(i == _markedRange.location)
+ gfx_keystroke(self.client, '[');
+ if(_selectedRange.length){
+ if(i == _selectedRange.location)
+ gfx_keystroke(self.client, '{');
+ if(i == NSMaxRange(_selectedRange))
+ gfx_keystroke(self.client, '}');
+ }
+ if(i == NSMaxRange(_markedRange))
+ gfx_keystroke(self.client, ']');
+ if(i < _tmpText.length)
+ gfx_keystroke(self.client, [_tmpText characterAtIndex:i]);
+ }
+ int l;
+ l = 1 + _tmpText.length - NSMaxRange(_selectedRange)
+ + (_selectedRange.length > 0);
+ LOG(@"move left %d", l);
+ for(i = 0; i < l; ++i)
+ gfx_keystroke(self.client, Kleft);
+ }
+
+ LOG(@"text: \"%@\" (%ld,%ld) (%ld,%ld)", _tmpText,
+ _markedRange.location, _markedRange.length,
+ _selectedRange.location, _selectedRange.length);
+}
+
+- (void)unmarkText {
+ //NSUInteger i;
+ NSUInteger len;
+
+ LOG(@"unmarkText");
+ len = [_tmpText length];
+ //for(i = 0; i < len; ++i)
+ // gfx_keystroke(self.client, [_tmpText characterAtIndex:i]);
+ [_tmpText deleteCharactersInRange:NSMakeRange(0, len)];
+ _markedRange = NSMakeRange(NSNotFound, 0);
+ _selectedRange = NSMakeRange(0, 0);
+}
+
+- (NSArray*)validAttributesForMarkedText {
+ LOG(@"validAttributesForMarkedText");
+ return @[];
+}
+
+- (NSAttributedString*)attributedSubstringForProposedRange:(NSRange)r
+ actualRange:(NSRangePointer)actualRange
+{
+ NSRange sr;
+ NSAttributedString *s;
+
+ LOG(@"attributedSubstringForProposedRange: (%ld, %ld) (%ld, %ld)",
+ r.location, r.length, actualRange->location, actualRange->length);
+ sr = NSMakeRange(0, [_tmpText length]);
+ sr = NSIntersectionRange(sr, r);
+ if(actualRange)
+ *actualRange = sr;
+ LOG(@"use range: %ld, %ld", sr.location, sr.length);
+ s = nil;
+ if(sr.length)
+ s = [[NSAttributedString alloc]
+ initWithString:[_tmpText substringWithRange:sr]];
+ LOG(@" return %@", s);
+ return s;
+}
+
+- (void)insertText:(id)s replacementRange:(NSRange)r {
+ NSUInteger i;
+ NSUInteger len;
+
+ LOG(@"insertText: %@ replacementRange: %ld, %ld", s, r.location, r.length);
+
+ [self clearInput];
+
+ len = [s length];
+ for(i = 0; i < len; ++i)
+ gfx_keystroke(self.client, [s characterAtIndex:i]);
+ [_tmpText deleteCharactersInRange:NSMakeRange(0, _tmpText.length)];
+ _markedRange = NSMakeRange(NSNotFound, 0);
+ _selectedRange = NSMakeRange(0, 0);
+}
+
+- (NSUInteger)characterIndexForPoint:(NSPoint)point
+{
+ LOG(@"characterIndexForPoint: %g, %g", point.x, point.y);
+ return 0;
+}
+
+- (NSRect)firstRectForCharacterRange:(NSRange)r actualRange:(NSRangePointer)actualRange {
+ LOG(@"firstRectForCharacterRange: (%ld, %ld) (%ld, %ld)",
+ r.location, r.length, actualRange->location, actualRange->length);
+ if(actualRange)
+ *actualRange = r;
+ return [[self window] convertRectToScreen:_lastInputRect];
+}
+
+- (void)doCommandBySelector:(SEL)s {
+ NSEvent *e;
+ NSEventModifierFlags m;
+ uint c, k;
+
+ LOG(@"doCommandBySelector (%@)", NSStringFromSelector(s));
+
+ e = [NSApp currentEvent];
+ c = [[e characters] characterAtIndex:0];
+ k = keycvt(c);
+ LOG(@"keyDown: character0: 0x%x -> 0x%x", c, k);
+ m = [e modifierFlags];
+
+ if(m & NSEventModifierFlagCommand){
+ if((m & NSEventModifierFlagShift) && 'a' <= k && k <= 'z')
+ k += 'A' - 'a';
+ if(' '<=k && k<='~')
+ k += Kcmd;
+ }
+ if(k>0)
+ gfx_keystroke(self.client, k);
+}
+
+// Helper for managing input rect approximately
+- (void)resetLastInputRect {
+ LOG(@"resetLastInputRect");
+ _lastInputRect.origin.x = 0.0;
+ _lastInputRect.origin.y = 0.0;
+ _lastInputRect.size.width = 0.0;
+ _lastInputRect.size.height = 0.0;
+}
+
+- (void)enlargeLastInputRect:(NSRect)r {
+ r.origin.y = [self bounds].size.height - r.origin.y - r.size.height;
+ _lastInputRect = NSUnionRect(_lastInputRect, r);
+ LOG(@"update last input rect (%g, %g, %g, %g)",
+ _lastInputRect.origin.x, _lastInputRect.origin.y,
+ _lastInputRect.size.width, _lastInputRect.size.height);
+}
+
+- (void)clearInput {
+ if(_tmpText.length){
+ uint i;
+ int l;
+ l = 1 + _tmpText.length - NSMaxRange(_selectedRange)
+ + (_selectedRange.length > 0);
+ LOG(@"move right %d", l);
+ for(i = 0; i < l; ++i)
+ gfx_keystroke(self.client, Kright);
+ l = _tmpText.length+2+2*(_selectedRange.length > 0);
+ LOG(@"backspace %d", l);
+ for(uint i = 0; i < l; ++i)
+ gfx_keystroke(self.client, Kbs);
+ }
+}
+
+- (NSApplicationPresentationOptions)window:(id)arg
+ willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions {
+ // The default for full-screen is to auto-hide the dock and menu bar,
+ // but the menu bar in particular comes back when the cursor is just
+ // near the top of the screen, which makes acme's top tag line very difficult to use.
+ // Disable the menu bar entirely.
+ // In theory this code disables the dock entirely too, but if you drag the mouse
+ // down far enough off the bottom of the screen the dock still unhides.
+ // That's OK.
+ NSApplicationPresentationOptions o;
+ o = proposedOptions;
+ o &= ~(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar);
+ o |= NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar;
+ return o;
+}
+
+- (void)windowWillEnterFullScreen:(NSNotification*)notification {
+ // This is a heavier-weight way to make sure the menu bar and dock go away,
+ // but this affects all screens even though the app is running on full screen
+ // on only one screen, so it's not great. The behavior from the
+ // willUseFullScreenPresentationOptions seems to be enough for now.
+ /*
+ [[NSApplication sharedApplication]
+ setPresentationOptions:NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock];
+ */
+}
+
+- (void)windowDidExitFullScreen:(NSNotification*)notification {
+ /*
+ [[NSApplication sharedApplication]
+ setPresentationOptions:NSApplicationPresentationDefault];
+ */
+}
+@end
+
+static uint
+msec(void)
+{
+ return nsec()/1000000;
+}
+
+static uint
+keycvt(uint code)
+{
+ switch(code){
+ case '\r': return '\n';
+ case 127: return '\b';
+ case NSUpArrowFunctionKey: return Kup;
+ case NSDownArrowFunctionKey: return Kdown;
+ case NSLeftArrowFunctionKey: return Kleft;
+ case NSRightArrowFunctionKey: return Kright;
+ case NSInsertFunctionKey: return Kins;
+ case NSDeleteFunctionKey: return Kdel;
+ case NSHomeFunctionKey: return Khome;
+ case NSEndFunctionKey: return Kend;
+ case NSPageUpFunctionKey: return Kpgup;
+ case NSPageDownFunctionKey: return Kpgdown;
+ case NSF1FunctionKey: return KF|1;
+ case NSF2FunctionKey: return KF|2;
+ case NSF3FunctionKey: return KF|3;
+ case NSF4FunctionKey: return KF|4;
+ case NSF5FunctionKey: return KF|5;
+ case NSF6FunctionKey: return KF|6;
+ case NSF7FunctionKey: return KF|7;
+ case NSF8FunctionKey: return KF|8;
+ case NSF9FunctionKey: return KF|9;
+ case NSF10FunctionKey: return KF|10;
+ case NSF11FunctionKey: return KF|11;
+ case NSF12FunctionKey: return KF|12;
+ case NSBeginFunctionKey:
+ case NSPrintScreenFunctionKey:
+ case NSScrollLockFunctionKey:
+ case NSF13FunctionKey:
+ case NSF14FunctionKey:
+ case NSF15FunctionKey:
+ case NSF16FunctionKey:
+ case NSF17FunctionKey:
+ case NSF18FunctionKey:
+ case NSF19FunctionKey:
+ case NSF20FunctionKey:
+ case NSF21FunctionKey:
+ case NSF22FunctionKey:
+ case NSF23FunctionKey:
+ case NSF24FunctionKey:
+ case NSF25FunctionKey:
+ case NSF26FunctionKey:
+ case NSF27FunctionKey:
+ case NSF28FunctionKey:
+ case NSF29FunctionKey:
+ case NSF30FunctionKey:
+ case NSF31FunctionKey:
+ case NSF32FunctionKey:
+ case NSF33FunctionKey:
+ case NSF34FunctionKey:
+ case NSF35FunctionKey:
+ case NSPauseFunctionKey:
+ case NSSysReqFunctionKey:
+ case NSBreakFunctionKey:
+ case NSResetFunctionKey:
+ case NSStopFunctionKey:
+ case NSMenuFunctionKey:
+ case NSUserFunctionKey:
+ case NSSystemFunctionKey:
+ case NSPrintFunctionKey:
+ case NSClearLineFunctionKey:
+ case NSClearDisplayFunctionKey:
+ case NSInsertLineFunctionKey:
+ case NSDeleteLineFunctionKey:
+ case NSInsertCharFunctionKey:
+ case NSDeleteCharFunctionKey:
+ case NSPrevFunctionKey:
+ case NSNextFunctionKey:
+ case NSSelectFunctionKey:
+ case NSExecuteFunctionKey:
+ case NSUndoFunctionKey:
+ case NSRedoFunctionKey:
+ case NSFindFunctionKey:
+ case NSHelpFunctionKey:
+ case NSModeSwitchFunctionKey: return 0;
+ default: return code;
+ }
+}
+
+// rpc_getsnarf reads the current pasteboard as a plain text string.
+// Called from an RPC thread with no client lock held.
+char*
+rpc_getsnarf(void)
+{
+ char __block *ret;
+
+ ret = nil;
+ dispatch_sync(dispatch_get_main_queue(), ^(void) {
+ @autoreleasepool {
+ NSPasteboard *pb = [NSPasteboard generalPasteboard];
+ NSString *s = [pb stringForType:NSPasteboardTypeString];
+ if(s)
+ ret = strdup((char*)[s UTF8String]);
+ }
+ });
+ return ret;
+}
+
+// rpc_putsnarf writes the given text to the pasteboard.
+// Called from an RPC thread with no client lock held.
+void
+rpc_putsnarf(char *s)
+{
+ if(s == nil || strlen(s) >= SnarfSize)
+ return;
+
+ dispatch_sync(dispatch_get_main_queue(), ^(void) {
+ @autoreleasepool{
+ NSArray *t = [NSArray arrayWithObject:NSPasteboardTypeString];
+ NSPasteboard *pb = [NSPasteboard generalPasteboard];
+ NSString *str = [[NSString alloc] initWithUTF8String:s];
+ [pb declareTypes:t owner:nil];
+ [pb setString:str forType:NSPasteboardTypeString];
+ }
+ });
+}
+
+// rpc_bouncemouse is for sending a mouse event
+// back to the X11 window manager rio(1).
+// Does not apply here.
+static void
+rpc_bouncemouse(Client *c, Mouse m)
+{
+}
+
+// We don't use the graphics thread state during memimagedraw,
+// so rpc_gfxdrawlock and rpc_gfxdrawunlock are no-ops.
+void
+rpc_gfxdrawlock(void)
+{
+}
+
+void
+rpc_gfxdrawunlock(void)
+{
+}
+
+static void
+setprocname(const char *s)
+{
+ CFStringRef process_name;
+
+ process_name = CFStringCreateWithBytes(nil, (uchar*)s, strlen(s), kCFStringEncodingUTF8, false);
+
+ // Adapted from Chrome's mac_util.mm.
+ // http://src.chromium.org/viewvc/chrome/trunk/src/base/mac/mac_util.mm
+ //
+ // Copyright (c) 2012 The Chromium Authors. All rights reserved.
+ //
+ // Redistribution and use in source and binary forms, with or without
+ // modification, are permitted provided that the following conditions are
+ // met:
+ //
+ // * Redistributions of source code must retain the above copyright
+ // notice, this list of conditions and the following disclaimer.
+ // * Redistributions in binary form must reproduce the above
+ // copyright notice, this list of conditions and the following disclaimer
+ // in the documentation and/or other materials provided with the
+ // distribution.
+ // * Neither the name of Google Inc. nor the names of its
+ // contributors may be used to endorse or promote products derived from
+ // this software without specific prior written permission.
+ //
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ // Warning: here be dragons! This is SPI reverse-engineered from WebKit's
+ // plugin host, and could break at any time (although realistically it's only
+ // likely to break in a new major release).
+ // When 10.7 is available, check that this still works, and update this
+ // comment for 10.8.
+
+ // Private CFType used in these LaunchServices calls.
+ typedef CFTypeRef PrivateLSASN;
+ typedef PrivateLSASN (*LSGetCurrentApplicationASNType)();
+ typedef OSStatus (*LSSetApplicationInformationItemType)(int, PrivateLSASN,
+ CFStringRef,
+ CFStringRef,
+ CFDictionaryRef*);
+
+ static LSGetCurrentApplicationASNType ls_get_current_application_asn_func =
+ NULL;
+ static LSSetApplicationInformationItemType
+ ls_set_application_information_item_func = NULL;
+ static CFStringRef ls_display_name_key = NULL;
+
+ static bool did_symbol_lookup = false;
+ if (!did_symbol_lookup) {
+ did_symbol_lookup = true;
+ CFBundleRef launch_services_bundle =
+ CFBundleGetBundleWithIdentifier(CFSTR("com.apple.LaunchServices"));
+ if (!launch_services_bundle) {
+ fprint(2, "Failed to look up LaunchServices bundle\n");
+ return;
+ }
+
+ ls_get_current_application_asn_func =
+ (LSGetCurrentApplicationASNType)(
+ CFBundleGetFunctionPointerForName(
+ launch_services_bundle, CFSTR("_LSGetCurrentApplicationASN")));
+ if (!ls_get_current_application_asn_func)
+ fprint(2, "Could not find _LSGetCurrentApplicationASN\n");
+
+ ls_set_application_information_item_func =
+ (LSSetApplicationInformationItemType)(
+ CFBundleGetFunctionPointerForName(
+ launch_services_bundle,
+ CFSTR("_LSSetApplicationInformationItem")));
+ if (!ls_set_application_information_item_func)
+ fprint(2, "Could not find _LSSetApplicationInformationItem\n");
+
+ CFStringRef* key_pointer = (CFStringRef*)(
+ CFBundleGetDataPointerForName(launch_services_bundle,
+ CFSTR("_kLSDisplayNameKey")));
+ ls_display_name_key = key_pointer ? *key_pointer : NULL;
+ if (!ls_display_name_key)
+ fprint(2, "Could not find _kLSDisplayNameKey\n");
+
+ // Internally, this call relies on the Mach ports that are started up by the
+ // Carbon Process Manager. In debug builds this usually happens due to how
+ // the logging layers are started up; but in release, it isn't started in as
+ // much of a defined order. So if the symbols had to be loaded, go ahead
+ // and force a call to make sure the manager has been initialized and hence
+ // the ports are opened.
+ ProcessSerialNumber psn;
+ GetCurrentProcess(&psn);
+ }
+ if (!ls_get_current_application_asn_func ||
+ !ls_set_application_information_item_func ||
+ !ls_display_name_key) {
+ return;
+ }
+
+ PrivateLSASN asn = ls_get_current_application_asn_func();
+ // Constant used by WebKit; what exactly it means is unknown.
+ const int magic_session_constant = -2;
+ OSErr err =
+ ls_set_application_information_item_func(magic_session_constant, asn,
+ ls_display_name_key,
+ process_name,
+ NULL /* optional out param */);
+ if(err != noErr)
+ fprint(2, "Call to set process name failed\n");
+}
diff --git a/src/cmd/devdraw/macargv.c b/src/cmd/devdraw/macargv.c
deleted file mode 100644
index a5ea1ade7..000000000
--- a/src/cmd/devdraw/macargv.c
+++ /dev/null
@@ -1,90 +0,0 @@
-#include
-#include
-#include
-
-AUTOFRAMEWORK(Carbon)
-
-static OSErr Handler(const AppleEvent *event, AppleEvent *reply, long handlerRefcon);
-
-int
-main(void)
-{
- AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, Handler, 0, false);
- RunApplicationEventLoop();
- return 0;
-}
-
-static OSErr
-GetFullPathname(FSSpec *fss, char *path, int len)
-{
- FSRef fsr;
- OSErr err;
-
- *path = '\0';
- err = FSpMakeFSRef(fss, &fsr);
- if (err == fnfErr) {
- /* FSSpecs can point to non-existing files, fsrefs can't. */
- FSSpec fss2;
- int tocopy;
-
- err = FSMakeFSSpec(fss->vRefNum, fss->parID,
- (unsigned char*)"", &fss2);
- if (err)
- return err;
- err = FSpMakeFSRef(&fss2, &fsr);
- if (err)
- return err;
- err = (OSErr)FSRefMakePath(&fsr, (unsigned char*)path, len-1);
- if (err)
- return err;
- /* This part is not 100% safe: we append the filename part, but
- ** I'm not sure that we don't run afoul of the various 8bit
- ** encodings here. Will have to look this up at some point...
- */
- strcat(path, "/");
- tocopy = fss->name[0];
- if ((strlen(path) + tocopy) >= len)
- tocopy = len - strlen(path) - 1;
- if (tocopy > 0)
- strncat(path, (char*)fss->name+1, tocopy);
- }
- else {
- if (err)
- return err;
- err = (OSErr)FSRefMakePath(&fsr, (unsigned char*)path, len);
- if (err)
- return err;
- }
- return 0;
-}
-
-static void
-chk(int err)
-{
- if(err != 0) {
- printf("err %d\n", err);
- exit(1);
- }
-}
-
-static OSErr
-Handler(const AppleEvent *event, AppleEvent *reply, long handlerRefcon)
-{
- AEDesc list;
- DescType type;
- FSSpec f;
- AEKeyword keyword;
- Size actual;
- long len;
- char s[1000];
-
- chk(AEGetParamDesc(event, keyDirectObject, typeAEList, &list));
- chk(AECountItems(&list, &len));
- chk(AEGetNthPtr(&list, 1, typeFSS, &keyword, &type, (Ptr*)&f, sizeof(FSSpec), &actual));
- chk(GetFullPathname(&f, s, sizeof s));
- printf("%s\n", s);
- fflush(stdout);
-
- // uncomment to keep handling more open events
- exit(0);
-}
diff --git a/src/cmd/devdraw/macargv.m b/src/cmd/devdraw/macargv.m
index 8db56be7b..92df2a6f7 100644
--- a/src/cmd/devdraw/macargv.m
+++ b/src/cmd/devdraw/macargv.m
@@ -12,9 +12,6 @@ @interface appdelegate : NSObject @end
void
main(void)
{
- if(OSX_VERSION < 100700)
- [NSAutoreleasePool new];
-
[NSApplication sharedApplication];
NSObject *delegate = [appdelegate new];
[NSApp setDelegate:delegate];
diff --git a/src/cmd/devdraw/mkfile b/src/cmd/devdraw/mkfile
index cad244ac5..6bcf18909 100644
--- a/src/cmd/devdraw/mkfile
+++ b/src/cmd/devdraw/mkfile
@@ -3,10 +3,13 @@
TARG=devdraw
+SHORTLIB=draw memdraw
+
WSYSOFILES=\
devdraw.$O\
latin1.$O\
mouseswap.$O\
+ srv.$O\
winsize.$O\
<|sh ./mkwsysrules.sh
@@ -14,14 +17,15 @@ WSYSOFILES=\
OFILES=$WSYSOFILES
HFILES=\
+ bigarrow.h\
devdraw.h\
+ glendapng.h\
+ latin1.h\
+ $WSYSHFILES\
<$PLAN9/src/mkone
-$O.drawclient: drawclient.$O drawfcall.$O
- $LD -o $target $prereq
-
-$O.snarf: x11-alloc.$O x11-cload.$O x11-draw.$O x11-fill.$O x11-get.$O x11-init.$O x11-itrans.$O x11-keysym2ucs.$O x11-load.$O x11-pixelbits.$O x11-unload.$O x11-wsys.$O snarf.$O latin1.$O devdraw.$O
+$O.drawclient: drawclient.$O
$LD -o $target $prereq
$O.mklatinkbd: mklatinkbd.$O
@@ -35,13 +39,13 @@ latin1.h: $PLAN9/lib/keyboard $O.mklatinkbd
$O.macargv: $MACARGV
$LD -o $target $prereq
-%-objc.$O: %.m
- $CC $CFLAGS -o $target $stem.m
+%.$O: %.m
+ $CC $CFLAGS $OBJCFLAGS -fobjc-arc -o $target $stem.m
-CLEANFILES=$O.macargv $O.mklatinkbd latin1.h
+CLEANFILES=$O.devdraw $O.macargv $O.drawclient $O.mklatinkbd latin1.h
install: mklatinkbd.install
-install:Q:
+install:Q:
if [ $MACARGV ]; then
mk $MKFLAGS macargv.install
fi
diff --git a/src/cmd/devdraw/mklatinkbd.c b/src/cmd/devdraw/mklatinkbd.c
index abd202fb7..50dd26b05 100644
--- a/src/cmd/devdraw/mklatinkbd.c
+++ b/src/cmd/devdraw/mklatinkbd.c
@@ -132,7 +132,7 @@ printtrie(Biobuf *b, Trie *t)
printtrie(b, t->link[i]);
if(t->n == 0)
return;
-
+
if(xflag) {
for(i=0; i<256; i++) {
if(t->r[i] == 0)
@@ -142,7 +142,7 @@ printtrie(Biobuf *b, Trie *t)
Bprint(b, " %k", *p);
Bprint(b, " %k : \"%C\" U%04X\n", i, t->r[i], t->r[i]);
}
- return;
+ return;
}
Bprint(b, "\t\"");
@@ -191,7 +191,7 @@ readfile(char *fname)
r = strtol(line, nil, 16);
p = strchr(line, ' ');
- if(r == 0 || p != line+4 || p[0] != ' ' || p[1] != ' ') {
+ if(r == 0 || (p != line+4 && p != line+5) || p[0] != ' ' || (p == line+4 && p[1] != ' ')) {
fprint(2, "%s:%d: cannot parse line\n", fname, lineno);
continue;
}
@@ -315,5 +315,3 @@ kfmt(Fmt *f)
return fmtprint(f, "<%s>", xkey[i].s);
return fmtprint(f, "<%c>", c);
}
-
-
diff --git a/src/cmd/devdraw/mkwsysrules.sh b/src/cmd/devdraw/mkwsysrules.sh
index 9c422261a..56dff55a3 100644
--- a/src/cmd/devdraw/mkwsysrules.sh
+++ b/src/cmd/devdraw/mkwsysrules.sh
@@ -7,6 +7,8 @@ if [ "x$X11" = "x" ]; then
X11=/usr/X11R6
elif [ -d /usr/local/X11R6 ]; then
X11=/usr/local/X11R6
+ elif [ -d /usr/X11R7 ]; then
+ X11=/usr/X11R7
elif [ -d /usr/X ]; then
X11=/usr/X
elif [ -d /usr/openwin ]; then # for Sun
@@ -22,12 +24,11 @@ fi
if [ "x$WSYSTYPE" = "x" ]; then
if [ "x`uname`" = "xDarwin" ]; then
- if sw_vers | grep 'ProductVersion: 10\.[0-5]\.' >/dev/null; then
- WSYSTYPE=osx
- else
- #echo 1>&2 'WARNING: OS X Lion is not working. Copy binaries from a Snow Leopard system.'
- WSYSTYPE=osx-cocoa
+ if sw_vers | egrep 'ProductVersion: (10\.[0-9]\.|10\.1[012])$' >/dev/null; then
+ echo 1>&2 'OS X 10.12 and older are not supported'
+ exit 1
fi
+ WSYSTYPE=mac
elif [ -d "$X11" ]; then
WSYSTYPE=x11
else
@@ -52,16 +53,11 @@ if [ $WSYSTYPE = x11 ]; then
echo 'HFILES=$HFILES $XHFILES'
XO=`ls x11-*.c 2>/dev/null | sed 's/\.c$/.o/'`
echo 'WSYSOFILES=$WSYSOFILES '$XO
-elif [ $WSYSTYPE = osx ]; then
- if [ -d /System/Library/PrivateFrameworks/MultitouchSupport.framework ]; then
- echo 'CFLAGS=$CFLAGS -DMULTITOUCH'
- echo 'LDFLAGS=$LDFLAGS -F/System/Library/PrivateFrameworks'
- fi
- echo 'WSYSOFILES=$WSYSOFILES osx-screen-carbon-objc.o osx-draw.o osx-srv.o'
+ echo 'WSYSHFILES=x11-inc.h x11-keysym2ucs.h x11-memdraw.h'
+elif [ $WSYSTYPE = mac ]; then
+ echo 'WSYSOFILES=$WSYSOFILES mac-draw.o mac-screen.o'
+ echo 'WSYSHFILES='
echo 'MACARGV=macargv.o'
-elif [ $WSYSTYPE = osx-cocoa ]; then
- echo 'WSYSOFILES=$WSYSOFILES osx-draw.o cocoa-screen-objc.o cocoa-srv.o cocoa-thread.o'
- echo 'MACARGV=macargv-objc.o'
elif [ $WSYSTYPE = nowsys ]; then
echo 'WSYSOFILES=nowsys.o'
fi
diff --git a/src/cmd/devdraw/mouseswap.c b/src/cmd/devdraw/mouseswap.c
index e6ece3339..d2dea6669 100644
--- a/src/cmd/devdraw/mouseswap.c
+++ b/src/cmd/devdraw/mouseswap.c
@@ -2,6 +2,11 @@
#include
#include
#include
+#include
+#include
+#include
+#include
+#include
#include "devdraw.h"
enum
@@ -51,7 +56,7 @@ mouseswap(int but)
if(!map.init)
initmap();
-
+
nbut = 0;
for(i=0; i= 0)
diff --git a/src/cmd/devdraw/nowsys.c b/src/cmd/devdraw/nowsys.c
index fd8b7ee16..08e0521fd 100644
--- a/src/cmd/devdraw/nowsys.c
+++ b/src/cmd/devdraw/nowsys.c
@@ -18,14 +18,14 @@ main(int argc, char **argv)
int n;
uchar buf[1024*1024];
Wsysmsg m;
-
+
ARGBEGIN{
case 'D':
break;
default:
usage();
}ARGEND
-
+
if(argc != 0)
usage();
diff --git a/src/cmd/devdraw/osx-keycodes.h b/src/cmd/devdraw/osx-keycodes.h
deleted file mode 100644
index 52328ace0..000000000
--- a/src/cmd/devdraw/osx-keycodes.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/* These are the Macintosh key scancode constants -- from Inside Macintosh */
-#define QZ_ESCAPE 0x35
-#define QZ_F1 0x7A
-#define QZ_F2 0x78
-#define QZ_F3 0x63
-#define QZ_F4 0x76
-#define QZ_F5 0x60
-#define QZ_F6 0x61
-#define QZ_F7 0x62
-#define QZ_F8 0x64
-#define QZ_F9 0x65
-#define QZ_F10 0x6D
-#define QZ_F11 0x67
-#define QZ_F12 0x6F
-#define QZ_PRINT 0x69
-#define QZ_SCROLLOCK 0x6B
-#define QZ_PAUSE 0x71
-#define QZ_POWER 0x7F
-#define QZ_BACKQUOTE 0x32
-#define QZ_1 0x12
-#define QZ_2 0x13
-#define QZ_3 0x14
-#define QZ_4 0x15
-#define QZ_5 0x17
-#define QZ_6 0x16
-#define QZ_7 0x1A
-#define QZ_8 0x1C
-#define QZ_9 0x19
-#define QZ_0 0x1D
-#define QZ_MINUS 0x1B
-#define QZ_EQUALS 0x18
-#define QZ_BACKSPACE 0x33
-#define QZ_INSERT 0x72
-#define QZ_HOME 0x73
-#define QZ_PAGEUP 0x74
-#define QZ_NUMLOCK 0x47
-#define QZ_KP_EQUALS 0x51
-#define QZ_KP_DIVIDE 0x4B
-#define QZ_KP_MULTIPLY 0x43
-#define QZ_TAB 0x30
-#define QZ_q 0x0C
-#define QZ_w 0x0D
-#define QZ_e 0x0E
-#define QZ_r 0x0F
-#define QZ_t 0x11
-#define QZ_y 0x10
-#define QZ_u 0x20
-#define QZ_i 0x22
-#define QZ_o 0x1F
-#define QZ_p 0x23
-#define QZ_LEFTBRACKET 0x21
-#define QZ_RIGHTBRACKET 0x1E
-#define QZ_BACKSLASH 0x2A
-#define QZ_DELETE 0x75
-#define QZ_END 0x77
-#define QZ_PAGEDOWN 0x79
-#define QZ_KP7 0x59
-#define QZ_KP8 0x5B
-#define QZ_KP9 0x5C
-#define QZ_KP_MINUS 0x4E
-#define QZ_CAPSLOCK 0x39
-#define QZ_a 0x00
-#define QZ_s 0x01
-#define QZ_d 0x02
-#define QZ_f 0x03
-#define QZ_g 0x05
-#define QZ_h 0x04
-#define QZ_j 0x26
-#define QZ_k 0x28
-#define QZ_l 0x25
-#define QZ_SEMICOLON 0x29
-#define QZ_QUOTE 0x27
-#define QZ_RETURN 0x24
-#define QZ_KP4 0x56
-#define QZ_KP5 0x57
-#define QZ_KP6 0x58
-#define QZ_KP_PLUS 0x45
-#define QZ_LSHIFT 0x38
-#define QZ_z 0x06
-#define QZ_x 0x07
-#define QZ_c 0x08
-#define QZ_v 0x09
-#define QZ_b 0x0B
-#define QZ_n 0x2D
-#define QZ_m 0x2E
-#define QZ_COMMA 0x2B
-#define QZ_PERIOD 0x2F
-#define QZ_SLASH 0x2C
-/* These are the same as the left versions - use left by default */
-#if 0
-#define QZ_RSHIFT 0x38
-#endif
-#define QZ_UP 0x7E
-#define QZ_KP1 0x53
-#define QZ_KP2 0x54
-#define QZ_KP3 0x55
-#define QZ_KP_ENTER 0x4C
-#define QZ_LCTRL 0x3B
-#define QZ_LALT 0x3A
-#define QZ_LMETA 0x37
-#define QZ_SPACE 0x31
-/* These are the same as the left versions - use left by default */
-#if 0
-#define QZ_RMETA 0x37
-#define QZ_RALT 0x3A
-#define QZ_RCTRL 0x3B
-#endif
-#define QZ_LEFT 0x7B
-#define QZ_DOWN 0x7D
-#define QZ_RIGHT 0x7C
-#define QZ_KP0 0x52
-#define QZ_KP_PERIOD 0x41
-
-/* Wierd, these keys are on my iBook under MacOS X */
-#define QZ_IBOOK_ENTER 0x34
-#define QZ_IBOOK_LEFT 0x3B
-#define QZ_IBOOK_RIGHT 0x3C
-#define QZ_IBOOK_DOWN 0x3D
-#define QZ_IBOOK_UP 0x3E
-#define KEY_ENTER 13
-#define KEY_TAB 9
-
-#define KEY_BASE 0x100
-
-/* Function keys */
-#define KEY_F (KEY_BASE+64)
-
-/* Control keys */
-#define KEY_CTRL (KEY_BASE)
-#define KEY_BACKSPACE (KEY_CTRL+0)
-#define KEY_DELETE (KEY_CTRL+1)
-#define KEY_INSERT (KEY_CTRL+2)
-#define KEY_HOME (KEY_CTRL+3)
-#define KEY_END (KEY_CTRL+4)
-#define KEY_PAGE_UP (KEY_CTRL+5)
-#define KEY_PAGE_DOWN (KEY_CTRL+6)
-#define KEY_ESC (KEY_CTRL+7)
-
-/* Control keys short name */
-#define KEY_BS KEY_BACKSPACE
-#define KEY_DEL KEY_DELETE
-#define KEY_INS KEY_INSERT
-#define KEY_PGUP KEY_PAGE_UP
-#define KEY_PGDOWN KEY_PAGE_DOWN
-#define KEY_PGDWN KEY_PAGE_DOWN
-
-/* Cursor movement */
-#define KEY_CRSR (KEY_BASE+16)
-#define KEY_RIGHT (KEY_CRSR+0)
-#define KEY_LEFT (KEY_CRSR+1)
-#define KEY_DOWN (KEY_CRSR+2)
-#define KEY_UP (KEY_CRSR+3)
-
-/* Multimedia keyboard/remote keys */
-#define KEY_MM_BASE (0x100+384)
-#define KEY_POWER (KEY_MM_BASE+0)
-#define KEY_MENU (KEY_MM_BASE+1)
-#define KEY_PLAY (KEY_MM_BASE+2)
-#define KEY_PAUSE (KEY_MM_BASE+3)
-#define KEY_PLAYPAUSE (KEY_MM_BASE+4)
-#define KEY_STOP (KEY_MM_BASE+5)
-#define KEY_FORWARD (KEY_MM_BASE+6)
-#define KEY_REWIND (KEY_MM_BASE+7)
-#define KEY_NEXT (KEY_MM_BASE+8)
-#define KEY_PREV (KEY_MM_BASE+9)
-#define KEY_VOLUME_UP (KEY_MM_BASE+10)
-#define KEY_VOLUME_DOWN (KEY_MM_BASE+11)
-#define KEY_MUTE (KEY_MM_BASE+12)
-
-/* Keypad keys */
-#define KEY_KEYPAD (KEY_BASE+32)
-#define KEY_KP0 (KEY_KEYPAD+0)
-#define KEY_KP1 (KEY_KEYPAD+1)
-#define KEY_KP2 (KEY_KEYPAD+2)
-#define KEY_KP3 (KEY_KEYPAD+3)
-#define KEY_KP4 (KEY_KEYPAD+4)
-#define KEY_KP5 (KEY_KEYPAD+5)
-#define KEY_KP6 (KEY_KEYPAD+6)
-#define KEY_KP7 (KEY_KEYPAD+7)
-#define KEY_KP8 (KEY_KEYPAD+8)
-#define KEY_KP9 (KEY_KEYPAD+9)
-#define KEY_KPDEC (KEY_KEYPAD+10)
-#define KEY_KPINS (KEY_KEYPAD+11)
-#define KEY_KPDEL (KEY_KEYPAD+12)
-#define KEY_KPENTER (KEY_KEYPAD+13)
-
-/* Special keys */
-#define KEY_INTERN (0x1000)
-#define KEY_CLOSE_WIN (KEY_INTERN+0)
diff --git a/src/cmd/devdraw/osx-screen-carbon.m b/src/cmd/devdraw/osx-screen-carbon.m
deleted file mode 100644
index d41e9d10d..000000000
--- a/src/cmd/devdraw/osx-screen-carbon.m
+++ /dev/null
@@ -1,1302 +0,0 @@
-#define Point OSXPoint
-#define Rect OSXRect
-#define Cursor OSXCursor
-#include
-#import
-#ifdef MULTITOUCH
-#include
-#include
-#endif
-#undef Rect
-#undef Point
-#undef Cursor
-#undef offsetof
-#undef nil
-
-#include "u.h"
-#include "libc.h"
-#include
-#include
-#include
-#include
-#include "mouse.h"
-#include
-#include "osx-screen.h"
-#include "osx-keycodes.h"
-#include "devdraw.h"
-#include "glendapng.h"
-
-AUTOFRAMEWORK(Carbon)
-AUTOFRAMEWORK(Cocoa)
-
-#ifdef MULTITOUCH
-AUTOFRAMEWORK(MultitouchSupport)
-AUTOFRAMEWORK(IOKit)
-#endif
-
-#define panic sysfatal
-
-extern Rectangle mouserect;
-
-struct {
- char *label;
- char *winsize;
- QLock labellock;
-
- Rectangle fullscreenr;
- Rectangle screenr;
- Memimage *screenimage;
- int isfullscreen;
- ulong fullscreentime;
-
- Point xy;
- int buttons;
- int kbuttons;
-
- CGDataProviderRef provider;
- MenuRef wmenu;
- MenuRef vmenu;
- WindowRef window;
- CGImageRef image;
- CGContextRef windowctx;
- PasteboardRef snarf;
- int needflush;
- QLock flushlock;
- int active;
- int infullscreen;
- int kalting; // last keystroke was Kalt
- int touched; // last mouse event was touchCallback
- int collapsed; // parked in dock
- int flushing; // flushproc has started
- NSMutableArray* devicelist;
-} osx;
-
-/*
- These structs are required, in order to handle some parameters returned from the
- Support.framework
- */
-typedef struct {
- float x;
- float y;
-}mtPoint;
-
-typedef struct {
- mtPoint position;
- mtPoint velocity;
-}mtReadout;
-
-/*
- Some reversed engineered informations from MultiTouchSupport.framework
- */
-typedef struct
-{
- int frame; //the current frame
- double timestamp; //event timestamp
- int identifier; //identifier guaranteed unique for life of touch per device
- int state; //the current state (not sure what the values mean)
- int unknown1; //no idea what this does
- int unknown2; //no idea what this does either
- mtReadout normalized; //the normalized position and vector of the touch (0,0 to 1,1)
- float size; //the size of the touch (the area of your finger being tracked)
- int unknown3; //no idea what this does
- float angle; //the angle of the touch -|
- float majorAxis; //the major axis of the touch -|-- an ellipsoid. you can track the angle of each finger!
- float minorAxis; //the minor axis of the touch -|
- mtReadout unknown4; //not sure what this is for
- int unknown5[2]; //no clue
- float unknown6; //no clue
-}Touch;
-
-//a reference pointer for the multitouch device
-typedef void *MTDeviceRef;
-
-//the prototype for the callback function
-typedef int (*MTContactCallbackFunction)(int,Touch*,int,double,int);
-
-//returns a pointer to the default device (the trackpad?)
-MTDeviceRef MTDeviceCreateDefault(void);
-
-//returns a CFMutableArrayRef array of all multitouch devices
-CFMutableArrayRef MTDeviceCreateList(void);
-
-//registers a device's frame callback to your callback function
-void MTRegisterContactFrameCallback(MTDeviceRef, MTContactCallbackFunction);
-void MTUnregisterContactFrameCallback(MTDeviceRef, MTContactCallbackFunction);
-
-//start sending events
-void MTDeviceStart(MTDeviceRef, int);
-void MTDeviceStop(MTDeviceRef);
-
-MTDeviceRef MTDeviceCreateFromService(io_service_t);
-io_service_t MTDeviceGetService(MTDeviceRef);
-
-#define kNTracks 10
-struct TouchTrack {
- int id;
- float firstThreshTime;
- mtPoint pos;
-} tracks[kNTracks];
-
-#define kSizeSensitivity 1.25f
-#define kTimeSensitivity 0.03f /* seconds */
-#define kButtonLimit 0.6f /* percentage from base of pad */
-
-int
-findTrack(int id)
-{
- int i;
- for(i = 0; i < kNTracks; ++i)
- if(tracks[i].id == id)
- return i;
- return -1;
-}
-
-#define kMoveSensitivity 0.05f
-
-int
-moved(mtPoint a, mtPoint b)
-{
- if(fabs(a.x - b.x) > kMoveSensitivity)
- return 1;
- if(fabs(a.y - b.y) > kMoveSensitivity)
- return 1;
- return 0;
-}
-
-int
-classifyTouch(Touch *t)
-{
- mtPoint p;
- int i;
-
- p = t->normalized.position;
-
- i = findTrack(t->identifier);
- if(i == -1) {
- i = findTrack(-1);
- if(i == -1)
- return 0; // No empty tracks.
- tracks[i].id = t->identifier;
- tracks[i].firstThreshTime = t->timestamp;
- tracks[i].pos = p;
- // we don't have a touch yet - we wait kTimeSensitivity before reporting it.
- return 0;
- }
-
- if(t->size == 0) { // lost touch
- tracks[i].id = -1;
- return 0;
- }
- if(t->size < kSizeSensitivity) {
- tracks[i].firstThreshTime = t->timestamp;
- }
- if((t->timestamp - tracks[i].firstThreshTime) < kTimeSensitivity) {
- return 0;
- }
- if(p.y > kButtonLimit && t->size > kSizeSensitivity) {
- if(p.x < 0.35)
- return 1;
- if(p.x > 0.65)
- return 4;
- if(p.x > 0.35 && p.x < 0.65)
- return 2;
- }
- return 0;
-}
-
-static ulong msec(void);
-
-int
-touchCallback(int device, Touch *data, int nFingers, double timestamp, int frame)
-{
-#ifdef MULTITOUCH
- int buttons, delta, i;
- static int obuttons;
- CGPoint p;
- CGEventRef e;
-
- p.x = osx.xy.x+osx.screenr.min.x;
- p.y = osx.xy.y+osx.screenr.min.y;
- if(!ptinrect(Pt(p.x, p.y), osx.screenr))
- return 0;
- osx.touched = 1;
- buttons = 0;
- for(i = 0; i < nFingers; ++i)
- buttons |= classifyTouch(data+i);
- delta = buttons ^ obuttons;
- obuttons = buttons;
- if(delta & 1) {
- e = CGEventCreateMouseEvent(NULL,
- (buttons & 1) ? kCGEventOtherMouseDown : kCGEventOtherMouseUp,
- p,
- 29);
- CGEventPost(kCGSessionEventTap, e);
- CFRelease(e);
- }
- if(delta & 2) {
- e = CGEventCreateMouseEvent(NULL,
- (buttons & 2) ? kCGEventOtherMouseDown : kCGEventOtherMouseUp,
- p,
- 30);
- CGEventPost(kCGSessionEventTap, e);
- CFRelease(e);
- }
- if(delta & 4){
- e = CGEventCreateMouseEvent(NULL,
- (buttons & 4) ? kCGEventOtherMouseDown : kCGEventOtherMouseUp,
- p,
- 31);
- CGEventPost(kCGSessionEventTap, e);
- CFRelease(e);
- }
- return delta != 0;
-#else
- return 0;
-#endif
-}
-
-extern int multitouch;
-
-enum
-{
- WindowAttrs =
- kWindowCloseBoxAttribute |
- kWindowCollapseBoxAttribute |
- kWindowResizableAttribute |
- kWindowStandardHandlerAttribute |
- kWindowFullZoomAttribute
-};
-
-enum
-{
- P9PEventLabelUpdate = 1
-};
-
-static void screenproc(void*);
-static void eresized(int);
-static void fullscreen(int);
-static void seticon(void);
-static void activated(int);
-
-static OSStatus quithandler(EventHandlerCallRef, EventRef, void*);
-static OSStatus eventhandler(EventHandlerCallRef, EventRef, void*);
-static OSStatus cmdhandler(EventHandlerCallRef, EventRef, void*);
-
-enum
-{
- CmdFullScreen = 1,
-};
-
-void screeninit(void);
-void _flushmemscreen(Rectangle r);
-
-#ifdef MULTITOUCH
-static void
-RegisterMultitouch(void *ctx, io_iterator_t iter)
-{
- io_object_t io;
- MTDeviceRef dev;
-
- while((io = IOIteratorNext(iter)) != 0){
- dev = MTDeviceCreateFromService(io);
- if (dev != nil){
- MTRegisterContactFrameCallback(dev, touchCallback);
- [osx.devicelist addObject:dev];
- if(osx.active)
- MTDeviceStart(dev, 0);
- }
-
- IOObjectRelease(io);
- }
-}
-
-static void
-UnregisterMultitouch(void *ctx, io_iterator_t iter)
-{
- io_object_t io;
- MTDeviceRef dev;
- int i;
-
- while((io = IOIteratorNext(iter)) != 0){
- for(i = 0; i < [osx.devicelist count]; i++){
- dev = [osx.devicelist objectAtIndex:i];
- if(IOObjectIsEqualTo(MTDeviceGetService(dev), io)){
- if(osx.active)
- MTDeviceStop(dev);
- MTUnregisterContactFrameCallback(dev, touchCallback);
- [osx.devicelist removeObjectAtIndex:i];
- break;
- }
- }
-
- IOObjectRelease(io);
- }
-}
-
-#endif /*MULTITOUCH*/
-
-static void
-InitMultiTouch()
-{
-#ifdef MULTITOUCH
- IONotificationPortRef port;
- CFRunLoopSourceRef source;
- io_iterator_t iter;
- kern_return_t kr;
- io_object_t obj;
- int i;
-
- if(!multitouch)
- return;
-
- osx.devicelist = [[NSMutableArray alloc] init];
-
- for(i = 0; i < kNTracks; ++i)
- tracks[i].id = -1;
-
- port = IONotificationPortCreate(kIOMasterPortDefault);
- if(port == nil){
- fprint(2, "failed to get an IO notification port\n");
- return;
- }
-
- source = IONotificationPortGetRunLoopSource(port);
- if(source == nil){
- fprint(2, "failed to get loop source for port");
- return;
- }
-
- CFRunLoopAddSource(
- (CFRunLoopRef)GetCFRunLoopFromEventLoop(GetMainEventLoop()),
- source,
- kCFRunLoopDefaultMode);
-
- kr = IOServiceAddMatchingNotification(
- port, kIOTerminatedNotification,
- IOServiceMatching("AppleMultitouchDevice"),
- &UnregisterMultitouch,
- nil, &iter);
-
- if(kr != KERN_SUCCESS){
- fprint(2, "failed to add termination notification\n");
- return;
- }
-
- /* Arm the notification */
- while((obj = IOIteratorNext(iter)) != 0)
- IOObjectRelease(obj);
-
- kr = IOServiceAddMatchingNotification(
- port, kIOMatchedNotification,
- IOServiceMatching("AppleMultitouchDevice"),
- &RegisterMultitouch,
- nil, &iter);
-
- if(kr != KERN_SUCCESS){
- fprint(2, "failed to add matching notification\n");
- return;
- }
-
- RegisterMultitouch(nil, iter);
-#endif
-}
-
-Memimage*
-attachscreen(char *label, char *winsize)
-{
- if(label == nil)
- label = "gnot a label";
- osx.label = strdup(label);
- osx.winsize = winsize;
- if(osx.screenimage == nil){
- screeninit();
- if(osx.screenimage == nil)
- panic("cannot create OS X screen");
- }
- return osx.screenimage;
-}
-
-extern int multitouch;
-
-void
-_screeninit(void)
-{
- CGRect cgr;
- OSXRect or;
- Rectangle r;
- int havemin;
-
- memimageinit();
-
- ProcessSerialNumber psn = { 0, kCurrentProcess };
- TransformProcessType(&psn, kProcessTransformToForegroundApplication);
- SetFrontProcess(&psn);
-
- cgr = CGDisplayBounds(CGMainDisplayID());
- osx.fullscreenr = Rect(0, 0, cgr.size.width, cgr.size.height);
-
- InitCursor();
-
- // Create minimal menu with full-screen option.
- ClearMenuBar();
- CreateStandardWindowMenu(0, &osx.wmenu);
- InsertMenu(osx.wmenu, 0);
- MenuItemIndex ix;
- CreateNewMenu(1004, 0, &osx.vmenu); // XXX 1004?
- SetMenuTitleWithCFString(osx.vmenu, CFSTR("View"));
- AppendMenuItemTextWithCFString(osx.vmenu,
- CFSTR("Full Screen"), 0, CmdFullScreen, &ix);
- SetMenuItemCommandKey(osx.vmenu, ix, 0, 'F');
- AppendMenuItemTextWithCFString(osx.vmenu,
- CFSTR("Cmd-F exits full screen"),
- kMenuItemAttrDisabled, CmdFullScreen, &ix);
- InsertMenu(osx.vmenu, GetMenuID(osx.wmenu));
- DrawMenuBar();
-
- // Create the window.
- r = Rect(0, 0, Dx(osx.fullscreenr)*2/3, Dy(osx.fullscreenr)*2/3);
- havemin = 0;
- if(osx.winsize && osx.winsize[0]){
- if(parsewinsize(osx.winsize, &r, &havemin) < 0)
- sysfatal("%r");
- }
- if(!havemin)
- r = rectaddpt(r, Pt((Dx(osx.fullscreenr)-Dx(r))/2, (Dy(osx.fullscreenr)-Dy(r))/2));
- or.left = r.min.x;
- or.top = r.min.y;
- or.right = r.max.x;
- or.bottom = r.max.y;
- CreateNewWindow(kDocumentWindowClass, WindowAttrs, &or, &osx.window);
- setlabel(osx.label);
- seticon();
-
- // Set up the clip board.
- if(PasteboardCreate(kPasteboardClipboard, &osx.snarf) != noErr)
- panic("pasteboard create");
-
- // Explain in great detail which events we want to handle.
- // Why can't we just have one handler?
- const EventTypeSpec quits[] = {
- { kEventClassApplication, kEventAppQuit }
- };
- const EventTypeSpec cmds[] = {
- { kEventClassWindow, kEventWindowClosed },
- { kEventClassWindow, kEventWindowBoundsChanged },
- { kEventClassWindow, kEventWindowDrawContent },
- { kEventClassCommand, kEventCommandProcess },
- { kEventClassWindow, kEventWindowActivated },
- { kEventClassWindow, kEventWindowDeactivated },
- { kEventClassWindow, kEventWindowCollapsed },
- { kEventClassWindow, kEventWindowExpanded },
- };
- const EventTypeSpec events[] = {
- { kEventClassApplication, kEventAppShown },
- { kEventClassKeyboard, kEventRawKeyDown },
- { kEventClassKeyboard, kEventRawKeyModifiersChanged },
- { kEventClassKeyboard, kEventRawKeyRepeat },
- { kEventClassMouse, kEventMouseDown },
- { kEventClassMouse, kEventMouseUp },
- { kEventClassMouse, kEventMouseMoved },
- { kEventClassMouse, kEventMouseDragged },
- { kEventClassMouse, kEventMouseWheelMoved },
- { 'P9PE', P9PEventLabelUpdate}
- };
-
- InstallApplicationEventHandler(
- NewEventHandlerUPP(quithandler),
- nelem(quits), quits, nil, nil);
-
- InstallApplicationEventHandler(
- NewEventHandlerUPP(eventhandler),
- nelem(events), events, nil, nil);
-
- InstallWindowEventHandler(osx.window,
- NewEventHandlerUPP(cmdhandler),
- nelem(cmds), cmds, osx.window, nil);
-
- // Finally, put the window on the screen.
- ShowWindow(osx.window);
- ShowMenuBar();
- eresized(0);
- SelectWindow(osx.window);
-
- if(multitouch)
- InitMultiTouch();
-
- // CoreGraphics pins mouse events to the destination point of a
- // CGWarpMouseCursorPosition (see setmouse) for an interval of time
- // following the move. Disable this by setting the interval to zero
- // seconds.
- CGSetLocalEventsSuppressionInterval(0.0);
-
- InitCursor();
-}
-
-static Rendez scr;
-static QLock slock;
-
-void
-screeninit(void)
-{
- scr.l = &slock;
- qlock(scr.l);
- proccreate(screenproc, nil, 256*1024);
- while(osx.window == nil)
- rsleep(&scr);
- qunlock(scr.l);
-}
-
-static void
-screenproc(void *v)
-{
- qlock(scr.l);
- _screeninit();
- rwakeup(&scr);
- qunlock(scr.l);
- RunApplicationEventLoop();
-}
-
-static OSStatus kbdevent(EventRef);
-static OSStatus mouseevent(EventRef);
-
-static OSStatus
-cmdhandler(EventHandlerCallRef next, EventRef event, void *arg)
-{
- return eventhandler(next, event, arg);
-}
-
-static OSStatus
-quithandler(EventHandlerCallRef next, EventRef event, void *arg)
-{
- exit(0);
- return 0;
-}
-
-static OSStatus
-eventhandler(EventHandlerCallRef next, EventRef event, void *arg)
-{
- OSStatus result;
-
- result = CallNextEventHandler(next, event);
-
- switch(GetEventClass(event)){
-
- case 'P9PE':
- if(GetEventKind(event) == P9PEventLabelUpdate) {
- qlock(&osx.labellock);
- setlabel(osx.label);
- qunlock(&osx.labellock);
- return noErr;
- } else
- return eventNotHandledErr;
-
- case kEventClassApplication:;
- Rectangle r = Rect(0, 0, Dx(osx.screenr), Dy(osx.screenr));
- _flushmemscreen(r);
- return eventNotHandledErr;
-
- case kEventClassKeyboard:
- return kbdevent(event);
-
- case kEventClassMouse:
- return mouseevent(event);
-
- case kEventClassCommand:;
- HICommand cmd;
- GetEventParameter(event, kEventParamDirectObject,
- typeHICommand, nil, sizeof cmd, nil, &cmd);
- switch(cmd.commandID){
- case kHICommandQuit:
- exit(0);
-
- case CmdFullScreen:
- fullscreen(1);
- break;
-
- default:
- return eventNotHandledErr;
- }
- break;
-
- case kEventClassWindow:
- switch(GetEventKind(event)){
- case kEventWindowClosed:
- exit(0);
-
- case kEventWindowBoundsChanged:;
- // We see kEventWindowDrawContent
- // if we grow a window but not if we shrink it.
- UInt32 flags;
- GetEventParameter(event, kEventParamAttributes,
- typeUInt32, 0, sizeof flags, 0, &flags);
- int new = (flags & kWindowBoundsChangeSizeChanged) != 0;
- eresized(new);
- break;
-
- case kEventWindowDrawContent:
- // Tried using just flushmemimage here, but
- // it causes an odd artifact in which making a window
- // bigger in both width and height can then only draw
- // on the new border: it's like the old window is stuck
- // floating on top. Doing a full "get a new window"
- // seems to solve the problem.
- eresized(1);
- break;
-
- case kEventWindowActivated:
- if(!osx.collapsed)
- activated(1);
- return eventNotHandledErr;
-
- case kEventWindowDeactivated:
- activated(0);
- return eventNotHandledErr;
-
- case kEventWindowCollapsed:
- osx.collapsed = 1;
- activated(0);
- return eventNotHandledErr;
-
- case kEventWindowExpanded:
- osx.collapsed = 0;
- activated(1);
- return eventNotHandledErr;
-
- default:
- return eventNotHandledErr;
- }
- break;
- }
-
- return result;
-}
-
-static ulong
-msec(void)
-{
- return nsec()/1000000;
-}
-
-static OSStatus
-mouseevent(EventRef event)
-{
- int wheel;
- OSXPoint op;
-
- GetEventParameter(event, kEventParamMouseLocation,
- typeQDPoint, 0, sizeof op, 0, &op);
-
- osx.xy = subpt(Pt(op.h, op.v), osx.screenr.min);
- wheel = 0;
-
- switch(GetEventKind(event)){
- case kEventMouseWheelMoved:;
- SInt32 delta;
- GetEventParameter(event, kEventParamMouseWheelDelta,
- typeSInt32, 0, sizeof delta, 0, &delta);
-
- // if I have any active touches in my region, I need to ignore the wheel motion.
- //int i;
- //for(i = 0; i < kNTracks; ++i) {
- // if(tracks[i].id != -1 && tracks[i].pos.y > kButtonLimit) break;
- //}
- //if(i == kNTracks) { // No active touches, go ahead and scroll.
- if(delta > 0)
- wheel = 8;
- else
- wheel = 16;
- //}
- break;
-
- case kEventMouseDown:
- case kEventMouseUp:;
- UInt32 but, mod;
- GetEventParameter(event, kEventParamMouseChord,
- typeUInt32, 0, sizeof but, 0, &but);
- GetEventParameter(event, kEventParamKeyModifiers,
- typeUInt32, 0, sizeof mod, 0, &mod);
-
- // OS X swaps button 2 and 3
- but = (but & ~6) | ((but & 4)>>1) | ((but&2)<<1);
- but = (but & ~((1<<10)-1)) | mouseswap(but & ((1<<10)-1));
- if(osx.touched) {
- // in multitouch we use the clicks down to enable our
- // virtual buttons.
- if(but & 0x7) {
- if(but>>29)
- but = but >> 29;
- } else
- but = 0;
- osx.touched = 0;
- }
-
- // Apply keyboard modifiers and pretend it was a real mouse button.
- // (Modifiers typed while holding the button go into kbuttons,
- // but this one does not.)
- if(but == 1){
- if(mod & optionKey) {
- // Take the ALT away from the keyboard handler.
- if(osx.kalting) {
- osx.kalting = 0;
- keystroke(Kalt);
- }
- but = 2;
- }
- else if(mod & cmdKey)
- but = 4;
- }
- osx.buttons = but;
- break;
-
- case kEventMouseMoved:
- case kEventMouseDragged:
- break;
-
- default:
- return eventNotHandledErr;
- }
-
- mousetrack(osx.xy.x, osx.xy.y, osx.buttons|osx.kbuttons|wheel, msec());
- return noErr;
-}
-
-static int keycvt[] =
-{
- [QZ_IBOOK_ENTER] '\n',
- [QZ_RETURN] '\n',
- [QZ_ESCAPE] 27,
- [QZ_BACKSPACE] '\b',
- [QZ_LALT] Kalt,
- [QZ_LCTRL] Kctl,
- [QZ_LSHIFT] Kshift,
- [QZ_F1] KF+1,
- [QZ_F2] KF+2,
- [QZ_F3] KF+3,
- [QZ_F4] KF+4,
- [QZ_F5] KF+5,
- [QZ_F6] KF+6,
- [QZ_F7] KF+7,
- [QZ_F8] KF+8,
- [QZ_F9] KF+9,
- [QZ_F10] KF+10,
- [QZ_F11] KF+11,
- [QZ_F12] KF+12,
- [QZ_INSERT] Kins,
- [QZ_DELETE] 0x7F,
- [QZ_HOME] Khome,
- [QZ_END] Kend,
- [QZ_KP_PLUS] '+',
- [QZ_KP_MINUS] '-',
- [QZ_TAB] '\t',
- [QZ_PAGEUP] Kpgup,
- [QZ_PAGEDOWN] Kpgdown,
- [QZ_UP] Kup,
- [QZ_DOWN] Kdown,
- [QZ_LEFT] Kleft,
- [QZ_RIGHT] Kright,
- [QZ_KP_MULTIPLY] '*',
- [QZ_KP_DIVIDE] '/',
- [QZ_KP_ENTER] '\n',
- [QZ_KP_PERIOD] '.',
- [QZ_KP0] '0',
- [QZ_KP1] '1',
- [QZ_KP2] '2',
- [QZ_KP3] '3',
- [QZ_KP4] '4',
- [QZ_KP5] '5',
- [QZ_KP6] '6',
- [QZ_KP7] '7',
- [QZ_KP8] '8',
- [QZ_KP9] '9',
-};
-
-static OSStatus
-kbdevent(EventRef event)
-{
- char ch;
- UInt32 code;
- UInt32 mod;
- int k;
-
- GetEventParameter(event, kEventParamKeyMacCharCodes,
- typeChar, nil, sizeof ch, nil, &ch);
- GetEventParameter(event, kEventParamKeyCode,
- typeUInt32, nil, sizeof code, nil, &code);
- GetEventParameter(event, kEventParamKeyModifiers,
- typeUInt32, nil, sizeof mod, nil, &mod);
-
- switch(GetEventKind(event)){
- case kEventRawKeyDown:
- case kEventRawKeyRepeat:
- osx.kalting = 0;
- if(mod == cmdKey){
- if(ch == 'F' || ch == 'f'){
- if(osx.isfullscreen && msec() - osx.fullscreentime > 500)
- fullscreen(0);
- return noErr;
- }
-
- // Pass most Cmd keys through as Kcmd + ch.
- // OS X interprets a few no matter what we do,
- // so it is useless to pass them through as keystrokes too.
- switch(ch) {
- case 'm': // minimize window
- case 'h': // hide window
- case 'H': // hide others
- case 'q': // quit
- return eventNotHandledErr;
- }
- if(' ' <= ch && ch <= '~') {
- keystroke(Kcmd + ch);
- return noErr;
- }
- return eventNotHandledErr;
- }
- k = ch;
- if(code < nelem(keycvt) && keycvt[code])
- k = keycvt[code];
- if(k == 0)
- return noErr;
- if(k > 0)
- keystroke(k);
- else{
- UniChar uc;
- OSStatus s;
-
- s = GetEventParameter(event, kEventParamKeyUnicodes,
- typeUnicodeText, nil, sizeof uc, nil, &uc);
- if(s == noErr)
- keystroke(uc);
- }
- break;
-
- case kEventRawKeyModifiersChanged:
- if(!osx.buttons && !osx.kbuttons){
- if(mod == optionKey) {
- osx.kalting = 1;
- keystroke(Kalt);
- }
- break;
- }
-
- // If the mouse button is being held down, treat
- // changes in the keyboard modifiers as changes
- // in the mouse buttons.
- osx.kbuttons = 0;
- if(mod & optionKey)
- osx.kbuttons |= 2;
- if(mod & cmdKey)
- osx.kbuttons |= 4;
- mousetrack(osx.xy.x, osx.xy.y, osx.buttons|osx.kbuttons, msec());
- break;
- }
- return noErr;
-}
-
-static void
-eresized(int new)
-{
- Memimage *m;
- OSXRect or;
- ulong chan;
- Rectangle r;
- int bpl;
- CGDataProviderRef provider;
- CGImageRef image;
- CGColorSpaceRef cspace;
-
- GetWindowBounds(osx.window, kWindowContentRgn, &or);
- r = Rect(or.left, or.top, or.right, or.bottom);
- if(Dx(r) == Dx(osx.screenr) && Dy(r) == Dy(osx.screenr) && !new){
- // No need to make new image.
- osx.screenr = r;
- return;
- }
-
- chan = XBGR32;
- m = allocmemimage(Rect(0, 0, Dx(r), Dy(r)), chan);
- if(m == nil)
- panic("allocmemimage: %r");
- if(m->data == nil)
- panic("m->data == nil");
- bpl = bytesperline(r, 32);
- provider = CGDataProviderCreateWithData(0,
- m->data->bdata, Dy(r)*bpl, 0);
- //cspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
- cspace = CGColorSpaceCreateDeviceRGB();
- image = CGImageCreate(Dx(r), Dy(r), 8, 32, bpl,
- cspace,
- kCGImageAlphaNoneSkipLast,
- provider, 0, 0, kCGRenderingIntentDefault);
- CGColorSpaceRelease(cspace);
- CGDataProviderRelease(provider); // CGImageCreate did incref
-
- mouserect = m->r;
- if(new){
- mouseresized = 1;
- mousetrack(osx.xy.x, osx.xy.y, osx.buttons|osx.kbuttons, msec());
- }
-// termreplacescreenimage(m);
- _drawreplacescreenimage(m); // frees old osx.screenimage if any
- if(osx.image)
- CGImageRelease(osx.image);
- osx.image = image;
- osx.screenimage = m;
- osx.screenr = r;
-
- if(new){
- qlock(&osx.flushlock);
- QDEndCGContext(GetWindowPort(osx.window), &osx.windowctx);
- osx.windowctx = nil;
- qunlock(&osx.flushlock);
- }
-}
-
-void
-flushproc(void *v)
-{
- for(;;){
- if(osx.needflush && osx.windowctx && canqlock(&osx.flushlock)){
- if(osx.windowctx){
- CGContextFlush(osx.windowctx);
- osx.needflush = 0;
- }
- qunlock(&osx.flushlock);
- }
- usleep(33333);
- }
-}
-
-void
-_flushmemscreen(Rectangle r)
-{
- CGRect cgr;
- CGImageRef subimg;
-
- qlock(&osx.flushlock);
- if(osx.windowctx == nil){
- QDBeginCGContext(GetWindowPort(osx.window), &osx.windowctx);
- if(!osx.flushing) {
- proccreate(flushproc, nil, 256*1024);
- osx.flushing = 1;
- }
- }
-
- cgr.origin.x = r.min.x;
- cgr.origin.y = r.min.y;
- cgr.size.width = Dx(r);
- cgr.size.height = Dy(r);
- subimg = CGImageCreateWithImageInRect(osx.image, cgr);
- cgr.origin.y = Dy(osx.screenr) - r.max.y; // XXX how does this make any sense?
- CGContextDrawImage(osx.windowctx, cgr, subimg);
- osx.needflush = 1;
- qunlock(&osx.flushlock);
- CGImageRelease(subimg);
-}
-
-void
-activated(int active)
-{
-#ifdef MULTITOUCH
- int i;
- if(active) {
- for(i = 0; i<[osx.devicelist count]; i++) { //iterate available devices
- MTDeviceStart([osx.devicelist objectAtIndex:i], 0); //start sending events
- }
- } else {
- osx.xy.x = -10000;
- for(i = 0; i<[osx.devicelist count]; i++) { //iterate available devices
- MTDeviceStop([osx.devicelist objectAtIndex:i]); //stop sending events
- }
- for(i = 0; igdRect;
- if(dr.top == 0 && dr.left == 0)
- HideMenuBar();
- GetWindowBounds(osx.window, kWindowContentRgn, &oldrect);
- ChangeWindowAttributes(osx.window,
- kWindowNoTitleBarAttribute,
- kWindowResizableAttribute);
- MoveWindow(osx.window, 0, 0, 1);
- MoveWindow(osx.window, dr.left, dr.top, 0);
- SizeWindow(osx.window,
- dr.right - dr.left,
- dr.bottom - dr.top, 0);
- osx.isfullscreen = 1;
- }else{
- ShowMenuBar();
- ChangeWindowAttributes(osx.window,
- kWindowResizableAttribute,
- kWindowNoTitleBarAttribute);
- SizeWindow(osx.window,
- oldrect.right - oldrect.left,
- oldrect.bottom - oldrect.top, 0);
- MoveWindow(osx.window, oldrect.left, oldrect.top, 0);
- osx.isfullscreen = 0;
- }
- eresized(1);
-}
-
-void
-setmouse(Point p)
-{
- CGPoint cgp;
-
- cgp.x = p.x + osx.screenr.min.x;
- cgp.y = p.y + osx.screenr.min.y;
- CGWarpMouseCursorPosition(cgp);
- osx.xy = p;
-}
-
-void
-setcursor(Cursor *c)
-{
- OSXCursor oc;
- int i;
-
- if(c == nil){
- InitCursor();
- return;
- }
-
- // SetCursor is deprecated, but what replaces it?
- for(i=0; i<16; i++){
- oc.data[i] = ((ushort*)c->set)[i];
- oc.mask[i] = oc.data[i] | ((ushort*)c->clr)[i];
- }
- oc.hotSpot.h = - c->offset.x;
- oc.hotSpot.v = - c->offset.y;
- SetCursor(&oc);
-}
-
-void
-getcolor(ulong i, ulong *r, ulong *g, ulong *b)
-{
- ulong v;
-
- v = 0;
- *r = (v>>16)&0xFF;
- *g = (v>>8)&0xFF;
- *b = v&0xFF;
-}
-
-int
-setcolor(ulong i, ulong r, ulong g, ulong b)
-{
- /* no-op */
- return 0;
-}
-
-
-int
-hwdraw(Memdrawparam *p)
-{
- return 0;
-}
-
-struct {
- QLock lk;
- char buf[SnarfSize];
- Rune rbuf[SnarfSize];
- PasteboardRef apple;
-} clip;
-
-char*
-getsnarf(void)
-{
- char *s;
- CFArrayRef flavors;
- CFDataRef data;
- CFIndex nflavor, ndata, j;
- CFStringRef type;
- ItemCount nitem;
- PasteboardItemID id;
- PasteboardSyncFlags flags;
- UInt32 i;
- u16int *u;
- Fmt fmt;
- Rune r;
-
-/* fprint(2, "applegetsnarf\n"); */
- qlock(&clip.lk);
- clip.apple = osx.snarf;
- if(clip.apple == nil){
- if(PasteboardCreate(kPasteboardClipboard, &clip.apple) != noErr){
- fprint(2, "apple pasteboard create failed\n");
- qunlock(&clip.lk);
- return nil;
- }
- }
- flags = PasteboardSynchronize(clip.apple);
- if(flags&kPasteboardClientIsOwner){
- s = strdup(clip.buf);
- qunlock(&clip.lk);
- return s;
- }
- if(PasteboardGetItemCount(clip.apple, &nitem) != noErr){
- fprint(2, "apple pasteboard get item count failed\n");
- qunlock(&clip.lk);
- return nil;
- }
- for(i=1; i<=nitem; i++){
- if(PasteboardGetItemIdentifier(clip.apple, i, &id) != noErr)
- continue;
- if(PasteboardCopyItemFlavors(clip.apple, id, &flavors) != noErr)
- continue;
- nflavor = CFArrayGetCount(flavors);
- for(j=0; j= SnarfSize)
- return;
- qlock(&clip.lk);
- strcpy(clip.buf, s);
- runesnprint(clip.rbuf, nelem(clip.rbuf), "%s", s);
- clip.apple = osx.snarf;
- if(PasteboardClear(clip.apple) != noErr){
- fprint(2, "apple pasteboard clear failed\n");
- qunlock(&clip.lk);
- return;
- }
- flags = PasteboardSynchronize(clip.apple);
- if((flags&kPasteboardModified) || !(flags&kPasteboardClientIsOwner)){
- fprint(2, "apple pasteboard cannot assert ownership\n");
- qunlock(&clip.lk);
- return;
- }
- u = malloc(runestrlen(clip.rbuf)*4);
- p = u;
- for(i=0; clip.rbuf[i]; i++) {
- r = clip.rbuf[i];
- // convert to utf-16
- if(0xd800 <= r && r < 0xe000)
- r = Runeerror;
- if(r >= 0x10000) {
- r -= 0x10000;
- *p++ = 0xd800 + (r>>10);
- *p++ = 0xdc00 + (r & ((1<<10)-1));
- } else
- *p++ = r;
- }
- cfdata = CFDataCreate(kCFAllocatorDefault,
- (uchar*)u, (p-u)*2);
- free(u);
- if(cfdata == nil){
- fprint(2, "apple pasteboard cfdatacreate failed\n");
- qunlock(&clip.lk);
- return;
- }
- if(PasteboardPutItemFlavor(clip.apple, (PasteboardItemID)1,
- CFSTR("public.utf16-plain-text"), cfdata, 0) != noErr){
- fprint(2, "apple pasteboard putitem failed\n");
- CFRelease(cfdata);
- qunlock(&clip.lk);
- return;
- }
- CFRelease(cfdata);
- qunlock(&clip.lk);
-}
-
-void
-setlabel(char *label)
-{
- CFStringRef cs;
-
- cs = CFStringCreateWithBytes(nil, (uchar*)label, strlen(label), kCFStringEncodingUTF8, false);
- SetWindowTitleWithCFString(osx.window, cs);
- CFRelease(cs);
-}
-
-void
-kicklabel(char *label)
-{
- char *p;
- EventRef e;
-
- p = strdup(label);
- if(p == nil)
- return;
- qlock(&osx.labellock);
- free(osx.label);
- osx.label = p;
- qunlock(&osx.labellock);
-
- CreateEvent(nil, 'P9PE', P9PEventLabelUpdate, 0, kEventAttributeUserEvent, &e);
- PostEventToQueue(GetMainEventQueue(), e, kEventPriorityStandard);
-
-}
-
-static void
-seticon(void)
-{
- CGImageRef im;
- CGDataProviderRef d;
-
- d = CGDataProviderCreateWithData(nil, glenda_png, sizeof glenda_png, nil);
- im = CGImageCreateWithPNGDataProvider(d, nil, true, kCGRenderingIntentDefault);
- if(im)
- SetApplicationDockTileImage(im);
- CGImageRelease(im);
- CGDataProviderRelease(d);
-}
-
diff --git a/src/cmd/devdraw/osx-screen.h b/src/cmd/devdraw/osx-screen.h
deleted file mode 100644
index f50d8dfe7..000000000
--- a/src/cmd/devdraw/osx-screen.h
+++ /dev/null
@@ -1,18 +0,0 @@
-void zlock(void);
-void zunlock(void);
-
-#define setcursor dsetcursor
-
-Memimage *attachscreen(char*, char*);
-void setmouse(Point);
-void setcursor(Cursor*);
-void setlabel(char*);
-char* getsnarf(void);
-void putsnarf(char*);
-
-void mousetrack(int, int, int, int);
-void keystroke(int);
-void kicklabel(char*);
-
-extern Rectangle mouserect;
-extern int mouseresized;
diff --git a/src/cmd/devdraw/osx-srv.c b/src/cmd/devdraw/osx-srv.c
deleted file mode 100644
index 6cbb52359..000000000
--- a/src/cmd/devdraw/osx-srv.c
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
- * Window system protocol server.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "osx-screen.h"
-#include "devdraw.h"
-
-#undef time
-
-#define MouseMask (\
- ButtonPressMask|\
- ButtonReleaseMask|\
- PointerMotionMask|\
- Button1MotionMask|\
- Button2MotionMask|\
- Button3MotionMask)
-
-#define Mask MouseMask|ExposureMask|StructureNotifyMask|KeyPressMask|EnterWindowMask|LeaveWindowMask
-
-typedef struct Kbdbuf Kbdbuf;
-typedef struct Mousebuf Mousebuf;
-typedef struct Fdbuf Fdbuf;
-typedef struct Tagbuf Tagbuf;
-
-struct Kbdbuf
-{
- Rune r[32];
- int ri;
- int wi;
- int stall;
-};
-
-struct Mousebuf
-{
- Mouse m[32];
- Mouse last;
- int ri;
- int wi;
- int stall;
-};
-
-struct Tagbuf
-{
- int t[32];
- int ri;
- int wi;
-};
-
-Kbdbuf kbd;
-Mousebuf mouse;
-Tagbuf kbdtags;
-Tagbuf mousetags;
-
-void fdslide(Fdbuf*);
-void runmsg(Wsysmsg*);
-void replymsg(Wsysmsg*);
-void matchkbd(void);
-void matchmouse(void);
-int fdnoblock(int);
-Rectangle mouserect;
-int mouseresized;
-
-
-QLock lk;
-void
-zlock(void)
-{
- qlock(&lk);
-}
-
-void
-zunlock(void)
-{
- qunlock(&lk);
-}
-
-int chatty;
-int drawsleep;
-int trace;
-int multitouch = 1;
-
-void
-usage(void)
-{
- fprint(2, "usage: devdraw (don't run directly)\n");
- threadexitsall("usage");
-}
-
-void
-bell(void *v, char *msg)
-{
- if(strcmp(msg, "alarm") == 0)
- drawsleep = drawsleep ? 0 : 1000;
- noted(NCONT);
-}
-
-void
-threadmain(int argc, char **argv)
-{
- uchar buf[4], *mbuf;
- int nmbuf, n, nn;
- Wsysmsg m;
-
- /*
- * Move the protocol off stdin/stdout so that
- * any inadvertent prints don't screw things up.
- */
- dup(0, 3);
- dup(1, 4);
- close(0);
- close(1);
- open("/dev/null", OREAD);
- open("/dev/null", OWRITE);
-
-//trace = 1;
- fmtinstall('W', drawfcallfmt);
-
- ARGBEGIN{
- case 'D':
- chatty++;
- break;
- case 'M':
- multitouch = 0;
- break;
- default:
- usage();
- }ARGEND
-
- /*
- * Ignore arguments. They're only for good ps -a listings.
- */
-
- notify(bell);
-
- mbuf = nil;
- nmbuf = 0;
- while((n = read(3, buf, 4)) == 4){
- GET(buf, n);
- if(n > nmbuf){
- free(mbuf);
- mbuf = malloc(4+n);
- if(mbuf == nil)
- sysfatal("malloc: %r");
- nmbuf = n;
- }
- memmove(mbuf, buf, 4);
- nn = readn(3, mbuf+4, n-4);
- if(nn != n-4)
- sysfatal("eof during message");
-
- /* pick off messages one by one */
- if(convM2W(mbuf, nn+4, &m) <= 0)
- sysfatal("cannot convert message");
- if(trace) fprint(2, "<- %W\n", &m);
- runmsg(&m);
- }
- threadexitsall(0);
-}
-
-void
-replyerror(Wsysmsg *m)
-{
- char err[256];
-
- rerrstr(err, sizeof err);
- m->type = Rerror;
- m->error = err;
- replymsg(m);
-}
-
-/*
- * Handle a single wsysmsg.
- * Might queue for later (kbd, mouse read)
- */
-void
-runmsg(Wsysmsg *m)
-{
- static uchar buf[65536];
- int n;
- Memimage *i;
-
- switch(m->type){
- case Tinit:
- memimageinit();
- i = attachscreen(m->label, m->winsize);
- _initdisplaymemimage(i);
- replymsg(m);
- break;
-
- case Trdmouse:
- zlock();
- mousetags.t[mousetags.wi++] = m->tag;
- if(mousetags.wi == nelem(mousetags.t))
- mousetags.wi = 0;
- if(mousetags.wi == mousetags.ri)
- sysfatal("too many queued mouse reads");
- mouse.stall = 0;
- matchmouse();
- zunlock();
- break;
-
- case Trdkbd:
- zlock();
- kbdtags.t[kbdtags.wi++] = m->tag;
- if(kbdtags.wi == nelem(kbdtags.t))
- kbdtags.wi = 0;
- if(kbdtags.wi == kbdtags.ri)
- sysfatal("too many queued keyboard reads");
- kbd.stall = 0;
- matchkbd();
- zunlock();
- break;
-
- case Tmoveto:
- setmouse(m->mouse.xy);
- replymsg(m);
- break;
-
- case Tcursor:
- if(m->arrowcursor)
- setcursor(nil);
- else
- setcursor(&m->cursor);
- replymsg(m);
- break;
-
- case Tbouncemouse:
- // _xbouncemouse(&m->mouse);
- replymsg(m);
- break;
-
- case Tlabel:
- kicklabel(m->label);
- replymsg(m);
- break;
-
- case Trdsnarf:
- m->snarf = getsnarf();
- replymsg(m);
- free(m->snarf);
- break;
-
- case Twrsnarf:
- putsnarf(m->snarf);
- replymsg(m);
- break;
-
- case Trddraw:
- n = m->count;
- if(n > sizeof buf)
- n = sizeof buf;
- n = _drawmsgread(buf, n);
- if(n < 0)
- replyerror(m);
- else{
- m->count = n;
- m->data = buf;
- replymsg(m);
- }
- break;
-
- case Twrdraw:
- if(_drawmsgwrite(m->data, m->count) < 0)
- replyerror(m);
- else
- replymsg(m);
- break;
-
- case Ttop:
- // _xtopwindow();
- replymsg(m);
- break;
-
- case Tresize:
- // _xresizewindow(m->rect);
- replymsg(m);
- break;
- }
-}
-
-/*
- * Reply to m.
- */
-QLock replylock;
-void
-replymsg(Wsysmsg *m)
-{
- int n;
- static uchar *mbuf;
- static int nmbuf;
-
- /* T -> R msg */
- if(m->type%2 == 0)
- m->type++;
-
- if(trace) fprint(2, "-> %W\n", m);
- /* copy to output buffer */
- n = sizeW2M(m);
-
- qlock(&replylock);
- if(n > nmbuf){
- free(mbuf);
- mbuf = malloc(n);
- if(mbuf == nil)
- sysfatal("out of memory");
- nmbuf = n;
- }
- convW2M(m, mbuf, n);
- if(write(4, mbuf, n) != n)
- sysfatal("write: %r");
- qunlock(&replylock);
-}
-
-/*
- * Match queued kbd reads with queued kbd characters.
- */
-void
-matchkbd(void)
-{
- Wsysmsg m;
-
- if(kbd.stall)
- return;
- while(kbd.ri != kbd.wi && kbdtags.ri != kbdtags.wi){
- m.type = Rrdkbd;
- m.tag = kbdtags.t[kbdtags.ri++];
- if(kbdtags.ri == nelem(kbdtags.t))
- kbdtags.ri = 0;
- m.rune = kbd.r[kbd.ri++];
- if(kbd.ri == nelem(kbd.r))
- kbd.ri = 0;
- replymsg(&m);
- }
-}
-
-/*
- * Match queued mouse reads with queued mouse events.
- */
-void
-matchmouse(void)
-{
- Wsysmsg m;
-
- while(mouse.ri != mouse.wi && mousetags.ri != mousetags.wi){
- m.type = Rrdmouse;
- m.tag = mousetags.t[mousetags.ri++];
- if(mousetags.ri == nelem(mousetags.t))
- mousetags.ri = 0;
- m.mouse = mouse.m[mouse.ri];
- m.resized = mouseresized;
- /*
- if(m.resized)
- fprint(2, "sending resize\n");
- */
- mouseresized = 0;
- mouse.ri++;
- if(mouse.ri == nelem(mouse.m))
- mouse.ri = 0;
- replymsg(&m);
- }
-}
-
-void
-mousetrack(int x, int y, int b, int ms)
-{
- Mouse *m;
-
- if(x < mouserect.min.x)
- x = mouserect.min.x;
- if(x > mouserect.max.x)
- x = mouserect.max.x;
- if(y < mouserect.min.y)
- y = mouserect.min.y;
- if(y > mouserect.max.y)
- y = mouserect.max.y;
-
- zlock();
- // If reader has stopped reading, don't bother.
- // If reader is completely caught up, definitely queue.
- // Otherwise, queue only button change events.
- if(!mouse.stall)
- if(mouse.wi == mouse.ri || mouse.last.buttons != b){
- m = &mouse.last;
- m->xy.x = x;
- m->xy.y = y;
- m->buttons = b;
- m->msec = ms;
-
- mouse.m[mouse.wi] = *m;
- if(++mouse.wi == nelem(mouse.m))
- mouse.wi = 0;
- if(mouse.wi == mouse.ri){
- mouse.stall = 1;
- mouse.ri = 0;
- mouse.wi = 1;
- mouse.m[0] = *m;
- }
- matchmouse();
- }
- zunlock();
-}
-
-void
-kputc(int c)
-{
- zlock();
- kbd.r[kbd.wi++] = c;
- if(kbd.wi == nelem(kbd.r))
- kbd.wi = 0;
- if(kbd.ri == kbd.wi)
- kbd.stall = 1;
- matchkbd();
- zunlock();
-}
-
-void
-keystroke(int c)
-{
- static Rune k[10];
- static int alting, nk;
- int i;
-
- if(c == Kalt){
- alting = !alting;
- return;
- }
- if(!alting){
- kputc(c);
- return;
- }
- if(nk >= nelem(k)) // should not happen
- nk = 0;
- k[nk++] = c;
- c = _latin1(k, nk);
- if(c > 0){
- alting = 0;
- kputc(c);
- nk = 0;
- return;
- }
- if(c == -1){
- alting = 0;
- for(i=0; i
-#include
-#include
-#include "x11-inc.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "x11-memdraw.h"
-#include "devdraw.h"
-
-#undef time
-
-#define MouseMask (\
- ButtonPressMask|\
- ButtonReleaseMask|\
- PointerMotionMask|\
- Button1MotionMask|\
- Button2MotionMask|\
- Button3MotionMask)
-
-#define Mask MouseMask|ExposureMask|StructureNotifyMask|KeyPressMask|EnterWindowMask|LeaveWindowMask
-
-void runxevent(XEvent*);
-
-void
-usage(void)
-{
- fprint(2, "usage: snarf [-a] [-o | text]\n");
- exits("usage");
-}
-
-void
-main(int argc, char **argv)
-{
- int apple;
- int out;
-
- apple = 0;
- out = 0;
-
- ARGBEGIN{
- case 'a':
- apple = 1;
- break;
- case 'o':
- out = 1;
- break;
- default:
- usage();
- }ARGEND
-
- if(out && argc != 0)
- usage();
- if(!out && argc != 1)
- usage();
-
- _x.fd = -1;
-
- memimageinit();
- _xattach("snarf", "20x20");
-
- XSelectInput(_x.display, _x.drawable, Mask);
- XFlush(_x.display);
-
- if(out){
- char *s;
- if(apple)
- s = _applegetsnarf();
- else
- s = _xgetsnarf();
- write(1, s, strlen(s));
- write(1, "\n", 1);
- exits(0);
- }else{
- _xputsnarf(argv[0]);
- for(;;){
- XEvent event;
- XNextEvent(_x.display, &event);
- runxevent(&event);
- }
- }
-}
-
-/*
- * Handle an incoming X event.
- */
-void
-runxevent(XEvent *xev)
-{
- switch(xev->type){
- case Expose:
- _xexpose(xev);
- break;
-
- case DestroyNotify:
- if(_xdestroy(xev))
- exits(0);
- break;
-
- case SelectionRequest:
- _xselect(xev);
- break;
- }
-}
-
diff --git a/src/cmd/devdraw/srv.c b/src/cmd/devdraw/srv.c
new file mode 100644
index 000000000..479e41e0f
--- /dev/null
+++ b/src/cmd/devdraw/srv.c
@@ -0,0 +1,559 @@
+/*
+ * Window system protocol server.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "devdraw.h"
+
+static void runmsg(Client*, Wsysmsg*);
+static void replymsg(Client*, Wsysmsg*);
+static void matchkbd(Client*);
+static void matchmouse(Client*);
+static void serveproc(void*);
+static void listenproc(void*);
+Client *client0;
+
+int trace = 0;
+static char *srvname;
+static int afd;
+static char adir[40];
+
+static void
+usage(void)
+{
+ fprint(2, "usage: devdraw (don't run directly)\n");
+ threadexitsall("usage");
+}
+
+void
+threadmain(int argc, char **argv)
+{
+ char *p;
+
+ ARGBEGIN{
+ case 'D': /* for good ps -a listings */
+ break;
+ case 'f': /* fall through for backward compatibility */
+ case 'g':
+ case 'b':
+ break;
+ case 's':
+ // TODO: Update usage, man page.
+ srvname = EARGF(usage());
+ break;
+ default:
+ usage();
+ }ARGEND
+
+ memimageinit();
+ fmtinstall('H', encodefmt);
+ if((p = getenv("DEVDRAWTRACE")) != nil)
+ trace = atoi(p);
+
+ if(srvname == nil) {
+ client0 = mallocz(sizeof(Client), 1);
+ if(client0 == nil){
+ fprint(2, "initdraw: allocating client0: out of memory");
+ abort();
+ }
+ client0->displaydpi = 100;
+ client0->rfd = 3;
+ client0->wfd = 4;
+
+ /*
+ * Move the protocol off stdin/stdout so that
+ * any inadvertent prints don't screw things up.
+ */
+ dup(0,3);
+ dup(1,4);
+ close(0);
+ close(1);
+ open("/dev/null", OREAD);
+ open("/dev/null", OWRITE);
+ }
+
+ fmtinstall('W', drawfcallfmt);
+ gfx_main();
+}
+
+void
+gfx_started(void)
+{
+ char *ns, *addr;
+
+ if(srvname == nil) {
+ // Legacy mode: serving single client on pipes.
+ proccreate(serveproc, client0, 0);
+ return;
+ }
+
+ // Server mode.
+ if((ns = getns()) == nil)
+ sysfatal("out of memory");
+
+ addr = smprint("unix!%s/%s", ns, srvname);
+ free(ns);
+ if(addr == nil)
+ sysfatal("out of memory");
+
+ if((afd = announce(addr, adir)) < 0)
+ sysfatal("announce %s: %r", addr);
+
+ proccreate(listenproc, nil, 0);
+}
+
+static void
+listenproc(void *v)
+{
+ Client *c;
+ int fd;
+ char dir[40];
+
+ USED(v);
+
+ for(;;) {
+ fd = listen(adir, dir);
+ if(fd < 0)
+ sysfatal("listen: %r");
+ c = mallocz(sizeof(Client), 1);
+ if(c == nil){
+ fprint(2, "initdraw: allocating client0: out of memory");
+ abort();
+ }
+ c->displaydpi = 100;
+ c->rfd = fd;
+ c->wfd = fd;
+ proccreate(serveproc, c, 0);
+ }
+}
+
+static void
+serveproc(void *v)
+{
+ Client *c;
+ uchar buf[4], *mbuf;
+ int nmbuf, n, nn;
+ Wsysmsg m;
+
+ c = v;
+ mbuf = nil;
+ nmbuf = 0;
+ while((n = read(c->rfd, buf, 4)) == 4){
+ GET(buf, n);
+ if(n > nmbuf){
+ free(mbuf);
+ mbuf = malloc(4+n);
+ if(mbuf == nil)
+ sysfatal("out of memory");
+ nmbuf = n;
+ }
+ memmove(mbuf, buf, 4);
+ nn = readn(c->rfd, mbuf+4, n-4);
+ if(nn != n-4) {
+ fprint(2, "serveproc: eof during message\n");
+ break;
+ }
+
+ /* pick off messages one by one */
+ if(convM2W(mbuf, nn+4, &m) <= 0) {
+ fprint(2, "serveproc: cannot convert message\n");
+ break;
+ }
+ if(trace) fprint(2, "%ud [%d] <- %W\n", nsec()/1000000, threadid(), &m);
+ runmsg(c, &m);
+ }
+
+ if(c == client0) {
+ rpc_shutdown();
+ threadexitsall(nil);
+ }
+}
+
+static void
+replyerror(Client *c, Wsysmsg *m)
+{
+ char err[256];
+
+ rerrstr(err, sizeof err);
+ m->type = Rerror;
+ m->error = err;
+ replymsg(c, m);
+}
+
+/*
+ * Handle a single wsysmsg.
+ * Might queue for later (kbd, mouse read)
+ */
+static void
+runmsg(Client *c, Wsysmsg *m)
+{
+ static uchar buf[65536];
+ int n;
+ Memimage *i;
+
+ switch(m->type){
+ case Tctxt:
+ c->wsysid = strdup(m->id);
+ replymsg(c, m);
+ break;
+
+ case Tinit:
+ i = rpc_attach(c, m->label, m->winsize);
+ if(i == nil) {
+ replyerror(c, m);
+ break;
+ }
+ draw_initdisplaymemimage(c, i);
+ replymsg(c, m);
+ break;
+
+ case Trdmouse:
+ qlock(&c->eventlk);
+ if((c->mousetags.wi+1)%nelem(c->mousetags.t) == c->mousetags.ri) {
+ qunlock(&c->eventlk);
+ werrstr("too many queued mouse reads");
+ replyerror(c, m);
+ break;
+ }
+ c->mousetags.t[c->mousetags.wi++] = m->tag;
+ if(c->mousetags.wi == nelem(c->mousetags.t))
+ c->mousetags.wi = 0;
+ c->mouse.stall = 0;
+ matchmouse(c);
+ qunlock(&c->eventlk);
+ break;
+
+ case Trdkbd:
+ case Trdkbd4:
+ qlock(&c->eventlk);
+ if((c->kbdtags.wi+1)%nelem(c->kbdtags.t) == c->kbdtags.ri) {
+ qunlock(&c->eventlk);
+ werrstr("too many queued keyboard reads");
+ replyerror(c, m);
+ break;
+ }
+ c->kbdtags.t[c->kbdtags.wi++] = (m->tag<<1) | (m->type==Trdkbd4);
+ if(c->kbdtags.wi == nelem(c->kbdtags.t))
+ c->kbdtags.wi = 0;
+ c->kbd.stall = 0;
+ matchkbd(c);
+ qunlock(&c->eventlk);
+ break;
+
+ case Tmoveto:
+ c->impl->rpc_setmouse(c, m->mouse.xy);
+ replymsg(c, m);
+ break;
+
+ case Tcursor:
+ if(m->arrowcursor)
+ c->impl->rpc_setcursor(c, nil, nil);
+ else {
+ scalecursor(&m->cursor2, &m->cursor);
+ c->impl->rpc_setcursor(c, &m->cursor, &m->cursor2);
+ }
+ replymsg(c, m);
+ break;
+
+ case Tcursor2:
+ if(m->arrowcursor)
+ c->impl->rpc_setcursor(c, nil, nil);
+ else
+ c->impl->rpc_setcursor(c, &m->cursor, &m->cursor2);
+ replymsg(c, m);
+ break;
+
+ case Tbouncemouse:
+ c->impl->rpc_bouncemouse(c, m->mouse);
+ replymsg(c, m);
+ break;
+
+ case Tlabel:
+ c->impl->rpc_setlabel(c, m->label);
+ replymsg(c, m);
+ break;
+
+ case Trdsnarf:
+ m->snarf = rpc_getsnarf();
+ replymsg(c, m);
+ free(m->snarf);
+ break;
+
+ case Twrsnarf:
+ rpc_putsnarf(m->snarf);
+ replymsg(c, m);
+ break;
+
+ case Trddraw:
+ n = m->count;
+ if(n > sizeof buf)
+ n = sizeof buf;
+ n = draw_dataread(c, buf, n);
+ if(n < 0)
+ replyerror(c, m);
+ else{
+ m->count = n;
+ m->data = buf;
+ replymsg(c, m);
+ }
+ break;
+
+ case Twrdraw:
+ if(draw_datawrite(c, m->data, m->count) < 0)
+ replyerror(c, m);
+ else
+ replymsg(c, m);
+ break;
+
+ case Ttop:
+ c->impl->rpc_topwin(c);
+ replymsg(c, m);
+ break;
+
+ case Tresize:
+ c->impl->rpc_resizewindow(c, m->rect);
+ replymsg(c, m);
+ break;
+ }
+}
+
+/*
+ * Reply to m.
+ */
+static void
+replymsg(Client *c, Wsysmsg *m)
+{
+ int n;
+
+ /* T -> R msg */
+ if(m->type%2 == 0)
+ m->type++;
+
+ if(trace) fprint(2, "%ud [%d] -> %W\n", nsec()/1000000, threadid(), m);
+ /* copy to output buffer */
+ n = sizeW2M(m);
+
+ qlock(&c->wfdlk);
+ if(n > c->nmbuf){
+ free(c->mbuf);
+ c->mbuf = malloc(n);
+ if(c->mbuf == nil)
+ sysfatal("out of memory");
+ c->nmbuf = n;
+ }
+ convW2M(m, c->mbuf, n);
+ if(write(c->wfd, c->mbuf, n) != n)
+ fprint(2, "client write: %r\n");
+ qunlock(&c->wfdlk);
+}
+
+/*
+ * Match queued kbd reads with queued kbd characters.
+ */
+static void
+matchkbd(Client *c)
+{
+ int tag;
+ Wsysmsg m;
+
+ if(c->kbd.stall)
+ return;
+ while(c->kbd.ri != c->kbd.wi && c->kbdtags.ri != c->kbdtags.wi){
+ tag = c->kbdtags.t[c->kbdtags.ri++];
+ m.type = Rrdkbd;
+ if(tag&1)
+ m.type = Rrdkbd4;
+ m.tag = tag>>1;
+ if(c->kbdtags.ri == nelem(c->kbdtags.t))
+ c->kbdtags.ri = 0;
+ m.rune = c->kbd.r[c->kbd.ri++];
+ if(c->kbd.ri == nelem(c->kbd.r))
+ c->kbd.ri = 0;
+ replymsg(c, &m);
+ }
+}
+
+// matchmouse matches queued mouse reads with queued mouse events.
+// It must be called with c->eventlk held.
+static void
+matchmouse(Client *c)
+{
+ Wsysmsg m;
+
+ if(canqlock(&c->eventlk)) {
+ fprint(2, "misuse of matchmouse\n");
+ abort();
+ }
+
+ while(c->mouse.ri != c->mouse.wi && c->mousetags.ri != c->mousetags.wi){
+ m.type = Rrdmouse;
+ m.tag = c->mousetags.t[c->mousetags.ri++];
+ if(c->mousetags.ri == nelem(c->mousetags.t))
+ c->mousetags.ri = 0;
+ m.mouse = c->mouse.m[c->mouse.ri];
+ m.resized = c->mouse.resized;
+ c->mouse.resized = 0;
+ /*
+ if(m.resized)
+ fprint(2, "sending resize\n");
+ */
+ c->mouse.ri++;
+ if(c->mouse.ri == nelem(c->mouse.m))
+ c->mouse.ri = 0;
+ replymsg(c, &m);
+ }
+}
+
+void
+gfx_mouseresized(Client *c)
+{
+ gfx_mousetrack(c, -1, -1, -1, -1);
+}
+
+void
+gfx_mousetrack(Client *c, int x, int y, int b, uint ms)
+{
+ Mouse *m;
+
+ qlock(&c->eventlk);
+ if(x == -1 && y == -1 && b == -1 && ms == -1) {
+ Mouse *copy;
+ // repeat last mouse event for resize
+ if(c->mouse.ri == 0)
+ copy = &c->mouse.m[nelem(c->mouse.m)-1];
+ else
+ copy = &c->mouse.m[c->mouse.ri-1];
+ x = copy->xy.x;
+ y = copy->xy.y;
+ b = copy->buttons;
+ ms = copy->msec;
+ c->mouse.resized = 1;
+ }
+ if(x < c->mouserect.min.x)
+ x = c->mouserect.min.x;
+ if(x > c->mouserect.max.x)
+ x = c->mouserect.max.x;
+ if(y < c->mouserect.min.y)
+ y = c->mouserect.min.y;
+ if(y > c->mouserect.max.y)
+ y = c->mouserect.max.y;
+
+ // If reader has stopped reading, don't bother.
+ // If reader is completely caught up, definitely queue.
+ // Otherwise, queue only button change events.
+ if(!c->mouse.stall)
+ if(c->mouse.wi == c->mouse.ri || c->mouse.last.buttons != b){
+ m = &c->mouse.last;
+ m->xy.x = x;
+ m->xy.y = y;
+ m->buttons = b;
+ m->msec = ms;
+
+ c->mouse.m[c->mouse.wi] = *m;
+ if(++c->mouse.wi == nelem(c->mouse.m))
+ c->mouse.wi = 0;
+ if(c->mouse.wi == c->mouse.ri){
+ c->mouse.stall = 1;
+ c->mouse.ri = 0;
+ c->mouse.wi = 1;
+ c->mouse.m[0] = *m;
+ }
+ matchmouse(c);
+ }
+ qunlock(&c->eventlk);
+}
+
+// kputc adds ch to the keyboard buffer.
+// It must be called with c->eventlk held.
+static void
+kputc(Client *c, int ch)
+{
+ if(canqlock(&c->eventlk)) {
+ fprint(2, "misuse of kputc\n");
+ abort();
+ }
+
+ c->kbd.r[c->kbd.wi++] = ch;
+ if(c->kbd.wi == nelem(c->kbd.r))
+ c->kbd.wi = 0;
+ if(c->kbd.ri == c->kbd.wi)
+ c->kbd.stall = 1;
+ matchkbd(c);
+}
+
+// gfx_abortcompose stops any pending compose sequence,
+// because a mouse button has been clicked.
+// It is called from the graphics thread with no locks held.
+void
+gfx_abortcompose(Client *c)
+{
+ qlock(&c->eventlk);
+ if(c->kbd.alting) {
+ c->kbd.alting = 0;
+ c->kbd.nk = 0;
+ }
+ qunlock(&c->eventlk);
+}
+
+// gfx_keystroke records a single-rune keystroke.
+// It is called from the graphics thread with no locks held.
+void
+gfx_keystroke(Client *c, int ch)
+{
+ int i;
+
+ qlock(&c->eventlk);
+ if(ch == Kalt){
+ c->kbd.alting = !c->kbd.alting;
+ c->kbd.nk = 0;
+ qunlock(&c->eventlk);
+ return;
+ }
+ if(ch == Kcmd+'r') {
+ if(c->forcedpi)
+ c->forcedpi = 0;
+ else if(c->displaydpi >= 200)
+ c->forcedpi = 100;
+ else
+ c->forcedpi = 225;
+ qunlock(&c->eventlk);
+ c->impl->rpc_resizeimg(c);
+ return;
+ }
+ if(!c->kbd.alting){
+ kputc(c, ch);
+ qunlock(&c->eventlk);
+ return;
+ }
+ if(c->kbd.nk >= nelem(c->kbd.k)) // should not happen
+ c->kbd.nk = 0;
+ c->kbd.k[c->kbd.nk++] = ch;
+ ch = latin1(c->kbd.k, c->kbd.nk);
+ if(ch > 0){
+ c->kbd.alting = 0;
+ kputc(c, ch);
+ c->kbd.nk = 0;
+ qunlock(&c->eventlk);
+ return;
+ }
+ if(ch == -1){
+ c->kbd.alting = 0;
+ for(i=0; ikbd.nk; i++)
+ kputc(c, c->kbd.k[i]);
+ c->kbd.nk = 0;
+ qunlock(&c->eventlk);
+ return;
+ }
+ // need more input
+ qunlock(&c->eventlk);
+ return;
+}
diff --git a/src/cmd/devdraw/winsize.c b/src/cmd/devdraw/winsize.c
index 375401bf0..7d0a7b70b 100644
--- a/src/cmd/devdraw/winsize.c
+++ b/src/cmd/devdraw/winsize.c
@@ -2,6 +2,11 @@
#include
#include
#include
+#include
+#include
+#include
+#include
+#include
#include "devdraw.h"
int
diff --git a/src/cmd/devdraw/x11-alloc.c b/src/cmd/devdraw/x11-alloc.c
index a465f998b..cee930647 100644
--- a/src/cmd/devdraw/x11-alloc.c
+++ b/src/cmd/devdraw/x11-alloc.c
@@ -21,7 +21,7 @@ _xallocmemimage(Rectangle r, u32int chan, int pixmap)
m = _allocmemimage(r, chan);
if(chan != GREY1 && chan != _x.chan)
return m;
- if(_x.display == 0)
+ if(_x.display == 0 || _x.windows == nil)
return m;
/*
@@ -49,7 +49,7 @@ _xallocmemimage(Rectangle r, u32int chan, int pixmap)
if(pixmap != PMundef)
xm->pixmap = pixmap;
else
- xm->pixmap = XCreatePixmap(_x.display, _x.drawable, Dx(r), Dy(r), d);
+ xm->pixmap = XCreatePixmap(_x.display, _x.windows->drawable, Dx(r), Dy(r), d);
/*
* We want to align pixels on word boundaries.
@@ -121,4 +121,3 @@ freememimage(Memimage *m)
}
_freememimage(m);
}
-
diff --git a/src/cmd/devdraw/x11-cload.c b/src/cmd/devdraw/x11-cload.c
index 33e3170a5..1666ecede 100644
--- a/src/cmd/devdraw/x11-cload.c
+++ b/src/cmd/devdraw/x11-cload.c
@@ -15,4 +15,3 @@ cloadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
_xputxdata(i, r);
return n;
}
-
diff --git a/src/cmd/devdraw/x11-draw.c b/src/cmd/devdraw/x11-draw.c
index 685ad88a7..f3b6a6897 100644
--- a/src/cmd/devdraw/x11-draw.c
+++ b/src/cmd/devdraw/x11-draw.c
@@ -147,4 +147,3 @@ xdraw(Memdrawparam *par)
*/
return 0;
}
-
diff --git a/src/cmd/devdraw/x11-fill.c b/src/cmd/devdraw/x11-fill.c
index fc43a684f..adead1ead 100644
--- a/src/cmd/devdraw/x11-fill.c
+++ b/src/cmd/devdraw/x11-fill.c
@@ -23,7 +23,7 @@ _xfillcolor(Memimage *m, Rectangle r, u32int v)
Point p;
Xmem *xm;
XGC gc;
-
+
xm = m->X;
assert(xm != nil);
@@ -52,5 +52,3 @@ _xfillcolor(Memimage *m, Rectangle r, u32int v)
p = subpt(r.min, m->r.min);
XFillRectangle(_x.display, xm->pixmap, gc, p.x, p.y, Dx(r), Dy(r));
}
-
-
diff --git a/src/cmd/devdraw/x11-get.c b/src/cmd/devdraw/x11-get.c
index 1a47be01d..61913f184 100644
--- a/src/cmd/devdraw/x11-get.c
+++ b/src/cmd/devdraw/x11-get.c
@@ -21,7 +21,7 @@ _xgetxdata(Memimage *m, Rectangle r)
uchar *p;
Point tp, xdelta, delta;
Xmem *xm;
-
+
xm = m->X;
if(xm == nil)
return nil;
@@ -83,7 +83,7 @@ _xputxdata(Memimage *m, Rectangle r)
XPutImage(_x.display, xm->pixmap, gc, xi, xdelta.x, xdelta.y, delta.x, delta.y,
Dx(r), Dy(r));
-
+
if(_x.usetable && m->chan==CMAP8){
for(y=r.min.y; ydirty = 1;
addrect(&xm->dirtyr, r);
}
-
-
-
diff --git a/src/cmd/devdraw/x11-inc.h b/src/cmd/devdraw/x11-inc.h
index 1ac27d657..ab4c25053 100644
--- a/src/cmd/devdraw/x11-inc.h
+++ b/src/cmd/devdraw/x11-inc.h
@@ -17,6 +17,7 @@
#include
#include
#ifdef SHOWEVENT
+#include
#include "../rio/showevent/ShowEvent.c"
#endif
@@ -31,5 +32,3 @@
#undef Screen
#undef Visual
#undef Window
-
-void sendalt(void);
diff --git a/src/cmd/devdraw/x11-init.c b/src/cmd/devdraw/x11-init.c
deleted file mode 100644
index 04b13a038..000000000
--- a/src/cmd/devdraw/x11-init.c
+++ /dev/null
@@ -1,730 +0,0 @@
-/*
- * Some of the stuff in this file is not X-dependent and should be elsewhere.
- */
-#include
-#include "x11-inc.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include "x11-memdraw.h"
-#include "devdraw.h"
-
-static void plan9cmap(void);
-static int setupcmap(XWindow);
-static XGC xgc(XDrawable, int, int);
-
-Xprivate _x;
-
-static int
-xerror(XDisplay *d, XErrorEvent *e)
-{
- char buf[200];
-
- if(e->request_code == 42) /* XSetInputFocus */
- return 0;
- if(e->request_code == 18) /* XChangeProperty */
- return 0;
- /*
- * BadDrawable happens in apps that get resized a LOT,
- * e.g. when KDE is configured to resize continuously
- * during a window drag.
- */
- if(e->error_code == 9) /* BadDrawable */
- return 0;
-
- fprint(2, "X error: error_code=%d, request_code=%d, minor=%d disp=%p\n",
- e->error_code, e->request_code, e->minor_code, d);
- XGetErrorText(d, e->error_code, buf, sizeof buf);
- fprint(2, "%s\n", buf);
- return 0;
-}
-
-static int
-xioerror(XDisplay *d)
-{
- /*print("X I/O error\n"); */
- exit(0);
- /*sysfatal("X I/O error\n");*/
- abort();
- return -1;
-}
-
-
-Memimage*
-_xattach(char *label, char *winsize)
-{
- char *argv[2], *disp;
- int i, havemin, height, mask, n, width, x, xrootid, y;
- Rectangle r;
- XClassHint classhint;
- XDrawable pmid;
- XPixmapFormatValues *pfmt;
- XScreen *xscreen;
- XSetWindowAttributes attr;
- XSizeHints normalhint;
- XTextProperty name;
- XVisualInfo xvi;
- XWindow xrootwin;
- XWindowAttributes wattr;
- XWMHints hint;
- Atom atoms[2];
-
- /*
- if(XInitThreads() == 0){
- fprint(2, "XInitThreads failed\n");
- abort();
- }
- */
-
- /*
- * Connect to X server.
- */
- _x.display = XOpenDisplay(NULL);
- if(_x.display == nil){
- disp = getenv("DISPLAY");
- werrstr("XOpenDisplay %s: %r", disp ? disp : ":0");
- free(disp);
- return nil;
- }
- _x.fd = ConnectionNumber(_x.display);
- XSetErrorHandler(xerror);
- XSetIOErrorHandler(xioerror);
- xrootid = DefaultScreen(_x.display);
- xrootwin = DefaultRootWindow(_x.display);
-
- /*
- * Figure out underlying screen format.
- */
- if(XMatchVisualInfo(_x.display, xrootid, 24, TrueColor, &xvi)
- || XMatchVisualInfo(_x.display, xrootid, 24, DirectColor, &xvi)){
- _x.vis = xvi.visual;
- _x.depth = 24;
- }
- else
- if(XMatchVisualInfo(_x.display, xrootid, 16, TrueColor, &xvi)
- || XMatchVisualInfo(_x.display, xrootid, 16, DirectColor, &xvi)){
- _x.vis = xvi.visual;
- _x.depth = 16;
- }
- else
- if(XMatchVisualInfo(_x.display, xrootid, 15, TrueColor, &xvi)
- || XMatchVisualInfo(_x.display, xrootid, 15, DirectColor, &xvi)){
- _x.vis = xvi.visual;
- _x.depth = 15;
- }
- else
- if(XMatchVisualInfo(_x.display, xrootid, 8, PseudoColor, &xvi)
- || XMatchVisualInfo(_x.display, xrootid, 8, StaticColor, &xvi)){
- if(_x.depth > 8){
- werrstr("can't deal with colormapped depth %d screens",
- _x.depth);
- goto err0;
- }
- _x.vis = xvi.visual;
- _x.depth = 8;
- }
- else{
- _x.depth = DefaultDepth(_x.display, xrootid);
- if(_x.depth != 8){
- werrstr("can't understand depth %d screen", _x.depth);
- goto err0;
- }
- _x.vis = DefaultVisual(_x.display, xrootid);
- }
-
- if(DefaultDepth(_x.display, xrootid) == _x.depth)
- _x.usetable = 1;
-
- /*
- * _x.depth is only the number of significant pixel bits,
- * not the total number of pixel bits. We need to walk the
- * display list to find how many actual bits are used
- * per pixel.
- */
- _x.chan = 0;
- pfmt = XListPixmapFormats(_x.display, &n);
- for(i=0; iclass != StaticColor){
- plan9cmap();
- setupcmap(xrootwin);
- }
-
- /*
- * We get to choose the initial rectangle size.
- * This is arbitrary. In theory we should read the
- * command line and allow the traditional X options.
- */
- mask = 0;
- x = 0;
- y = 0;
- if(winsize && winsize[0]){
- if(parsewinsize(winsize, &r, &havemin) < 0)
- sysfatal("%r");
- }else{
- /*
- * Parse the various X resources. Thanks to Peter Canning.
- */
- char *screen_resources, *display_resources, *geom,
- *geomrestype, *home, *file;
- XrmDatabase database;
- XrmValue geomres;
-
- database = XrmGetDatabase(_x.display);
- screen_resources = XScreenResourceString(xscreen);
- if(screen_resources != nil){
- XrmCombineDatabase(XrmGetStringDatabase(screen_resources), &database, False);
- XFree(screen_resources);
- }
-
- display_resources = XResourceManagerString(_x.display);
- if(display_resources == nil){
- home = getenv("HOME");
- if(home!=nil && (file=smprint("%s/.Xdefaults", home)) != nil){
- XrmCombineFileDatabase(file, &database, False);
- free(file);
- }
- free(home);
- }else
- XrmCombineDatabase(XrmGetStringDatabase(display_resources), &database, False);
-
- geom = smprint("%s.geometry", label);
- if(geom && XrmGetResource(database, geom, nil, &geomrestype, &geomres))
- mask = XParseGeometry(geomres.addr, &x, &y, (uint*)&width, (uint*)&height);
- free(geom);
-
- if((mask & WidthValue) && (mask & HeightValue)){
- r = Rect(0, 0, width, height);
- }else{
- r = Rect(0, 0, WidthOfScreen(xscreen)*3/4,
- HeightOfScreen(xscreen)*3/4);
- if(Dx(r) > Dy(r)*3/2)
- r.max.x = r.min.x + Dy(r)*3/2;
- if(Dy(r) > Dx(r)*3/2)
- r.max.y = r.min.y + Dx(r)*3/2;
- }
- if(mask & XNegative){
- x += WidthOfScreen(xscreen);
- }
- if(mask & YNegative){
- y += HeightOfScreen(xscreen);
- }
- havemin = 0;
- }
- screenrect = Rect(0, 0, WidthOfScreen(xscreen), HeightOfScreen(xscreen));
- windowrect = r;
-
- memset(&attr, 0, sizeof attr);
- attr.colormap = _x.cmap;
- attr.background_pixel = ~0;
- attr.border_pixel = 0;
- _x.drawable = XCreateWindow(
- _x.display, /* display */
- xrootwin, /* parent */
- x, /* x */
- y, /* y */
- Dx(r), /* width */
- Dy(r), /* height */
- 0, /* border width */
- _x.depth, /* depth */
- InputOutput, /* class */
- _x.vis, /* visual */
- /* valuemask */
- CWBackPixel|CWBorderPixel|CWColormap,
- &attr /* attributes (the above aren't?!) */
- );
-
- /*
- * Label and other properties required by ICCCCM.
- */
- memset(&name, 0, sizeof name);
- if(label == nil)
- label = "pjw-face-here";
- name.value = (uchar*)label;
- name.encoding = XA_STRING;
- name.format = 8;
- name.nitems = strlen((char*)name.value);
-
- memset(&normalhint, 0, sizeof normalhint);
- normalhint.flags = PSize|PMaxSize;
- if(winsize && winsize[0]){
- normalhint.flags &= ~PSize;
- normalhint.flags |= USSize;
- normalhint.width = Dx(r);
- normalhint.height = Dy(r);
- }else{
- if((mask & WidthValue) && (mask & HeightValue)){
- normalhint.flags &= ~PSize;
- normalhint.flags |= USSize;
- normalhint.width = width;
- normalhint.height = height;
- }
- if((mask & WidthValue) && (mask & HeightValue)){
- normalhint.flags |= USPosition;
- normalhint.x = x;
- normalhint.y = y;
- }
- }
-
- normalhint.max_width = WidthOfScreen(xscreen);
- normalhint.max_height = HeightOfScreen(xscreen);
-
- memset(&hint, 0, sizeof hint);
- hint.flags = InputHint|StateHint;
- hint.input = 1;
- hint.initial_state = NormalState;
-
- memset(&classhint, 0, sizeof classhint);
- classhint.res_name = label;
- classhint.res_class = label;
-
- argv[0] = label;
- argv[1] = nil;
-
- XSetWMProperties(
- _x.display, /* display */
- _x.drawable, /* window */
- &name, /* XA_WM_NAME property */
- &name, /* XA_WM_ICON_NAME property */
- argv, /* XA_WM_COMMAND */
- 1, /* argc */
- &normalhint, /* XA_WM_NORMAL_HINTS */
- &hint, /* XA_WM_HINTS */
- &classhint /* XA_WM_CLASSHINTS */
- );
- XFlush(_x.display);
-
- if(havemin){
- XWindowChanges ch;
-
- memset(&ch, 0, sizeof ch);
- ch.x = r.min.x;
- ch.y = r.min.y;
- XConfigureWindow(_x.display, _x.drawable, CWX|CWY, &ch);
- /*
- * Must pretend origin is 0,0 for X.
- */
- r = Rect(0,0,Dx(r),Dy(r));
- }
- /*
- * Look up clipboard atom.
- */
- _x.clipboard = XInternAtom(_x.display, "CLIPBOARD", False);
- _x.utf8string = XInternAtom(_x.display, "UTF8_STRING", False);
- _x.targets = XInternAtom(_x.display, "TARGETS", False);
- _x.text = XInternAtom(_x.display, "TEXT", False);
- _x.compoundtext = XInternAtom(_x.display, "COMPOUND_TEXT", False);
- _x.takefocus = XInternAtom(_x.display, "WM_TAKE_FOCUS", False);
- _x.losefocus = XInternAtom(_x.display, "_9WM_LOSE_FOCUS", False);
- _x.wmprotos = XInternAtom(_x.display, "WM_PROTOCOLS", False);
-
- atoms[0] = _x.takefocus;
- atoms[1] = _x.losefocus;
- XChangeProperty(_x.display, _x.drawable, _x.wmprotos, XA_ATOM, 32,
- PropModeReplace, (uchar*)atoms, 2);
-
- /*
- * Put the window on the screen, check to see what size we actually got.
- */
- XMapWindow(_x.display, _x.drawable);
- XSync(_x.display, False);
-
- if(!XGetWindowAttributes(_x.display, _x.drawable, &wattr))
- fprint(2, "XGetWindowAttributes failed\n");
- else if(wattr.width && wattr.height){
- if(wattr.width != Dx(r) || wattr.height != Dy(r)){
- r.max.x = wattr.width;
- r.max.y = wattr.height;
- }
- }else
- fprint(2, "XGetWindowAttributes: bad attrs\n");
-
- /*
- * Allocate our local backing store.
- */
- _x.screenr = r;
- _x.screenpm = XCreatePixmap(_x.display, _x.drawable, Dx(r), Dy(r), _x.depth);
- _x.nextscreenpm = _x.screenpm;
- _x.screenimage = _xallocmemimage(r, _x.chan, _x.screenpm);
-
- /*
- * Allocate some useful graphics contexts for the future.
- */
- _x.gcfill = xgc(_x.screenpm, FillSolid, -1);
- _x.gccopy = xgc(_x.screenpm, -1, -1);
- _x.gcsimplesrc = xgc(_x.screenpm, FillStippled, -1);
- _x.gczero = xgc(_x.screenpm, -1, -1);
- _x.gcreplsrc = xgc(_x.screenpm, FillTiled, -1);
-
- pmid = XCreatePixmap(_x.display, _x.drawable, 1, 1, 1);
- _x.gcfill0 = xgc(pmid, FillSolid, 0);
- _x.gccopy0 = xgc(pmid, -1, -1);
- _x.gcsimplesrc0 = xgc(pmid, FillStippled, -1);
- _x.gczero0 = xgc(pmid, -1, -1);
- _x.gcreplsrc0 = xgc(pmid, FillTiled, -1);
- XFreePixmap(_x.display, pmid);
-
- return _x.screenimage;
-
-err0:
- /*
- * Should do a better job of cleaning up here.
- */
- XCloseDisplay(_x.display);
- return nil;
-}
-
-int
-_xsetlabel(char *label)
-{
- XTextProperty name;
-
- /*
- * Label and other properties required by ICCCCM.
- */
- memset(&name, 0, sizeof name);
- if(label == nil)
- label = "pjw-face-here";
- name.value = (uchar*)label;
- name.encoding = XA_STRING;
- name.format = 8;
- name.nitems = strlen((char*)name.value);
-
- XSetWMProperties(
- _x.display, /* display */
- _x.drawable, /* window */
- &name, /* XA_WM_NAME property */
- &name, /* XA_WM_ICON_NAME property */
- nil, /* XA_WM_COMMAND */
- 0, /* argc */
- nil, /* XA_WM_NORMAL_HINTS */
- nil, /* XA_WM_HINTS */
- nil /* XA_WM_CLASSHINTS */
- );
- XFlush(_x.display);
- return 0;
-}
-
-/*
- * Create a GC with a particular fill style and XXX.
- * Disable generation of GraphicsExpose/NoExpose events in the GC.
- */
-static XGC
-xgc(XDrawable d, int fillstyle, int foreground)
-{
- XGC gc;
- XGCValues v;
-
- memset(&v, 0, sizeof v);
- v.function = GXcopy;
- v.graphics_exposures = False;
- gc = XCreateGC(_x.display, d, GCFunction|GCGraphicsExposures, &v);
- if(fillstyle != -1)
- XSetFillStyle(_x.display, gc, fillstyle);
- if(foreground != -1)
- XSetForeground(_x.display, gc, 0);
- return gc;
-}
-
-
-/*
- * Initialize map with the Plan 9 rgbv color map.
- */
-static void
-plan9cmap(void)
-{
- int r, g, b, cr, cg, cb, v, num, den, idx, v7, idx7;
- static int once;
-
- if(once)
- return;
- once = 1;
-
- for(r=0; r!=4; r++)
- for(g = 0; g != 4; g++)
- for(b = 0; b!=4; b++)
- for(v = 0; v!=4; v++){
- den=r;
- if(g > den)
- den=g;
- if(b > den)
- den=b;
- /* divide check -- pick grey shades */
- if(den==0)
- cr=cg=cb=v*17;
- else {
- num=17*(4*den+v);
- cr=r*num/den;
- cg=g*num/den;
- cb=b*num/den;
- }
- idx = r*64 + v*16 + ((g*4 + b + v - r) & 15);
- _x.map[idx].red = cr*0x0101;
- _x.map[idx].green = cg*0x0101;
- _x.map[idx].blue = cb*0x0101;
- _x.map[idx].pixel = idx;
- _x.map[idx].flags = DoRed|DoGreen|DoBlue;
-
- v7 = v >> 1;
- idx7 = r*32 + v7*16 + g*4 + b;
- if((v & 1) == v7){
- _x.map7to8[idx7][0] = idx;
- if(den == 0) { /* divide check -- pick grey shades */
- cr = ((255.0/7.0)*v7)+0.5;
- cg = cr;
- cb = cr;
- }
- else {
- num=17*15*(4*den+v7*2)/14;
- cr=r*num/den;
- cg=g*num/den;
- cb=b*num/den;
- }
- _x.map7[idx7].red = cr*0x0101;
- _x.map7[idx7].green = cg*0x0101;
- _x.map7[idx7].blue = cb*0x0101;
- _x.map7[idx7].pixel = idx7;
- _x.map7[idx7].flags = DoRed|DoGreen|DoBlue;
- }
- else
- _x.map7to8[idx7][1] = idx;
- }
-}
-
-/*
- * Initialize and install the rgbv color map as a private color map
- * for this application. It gets the best colors when it has the
- * cursor focus.
- *
- * We always choose the best depth possible, but that might not
- * be the default depth. On such "suboptimal" systems, we have to allocate an
- * empty color map anyway, according to Axel Belinfante.
- */
-static int
-setupcmap(XWindow w)
-{
- char buf[30];
- int i;
- u32int p, pp;
- XColor c;
-
- if(_x.depth <= 1)
- return 0;
-
- if(_x.depth >= 24) {
- if(_x.usetable == 0)
- _x.cmap = XCreateColormap(_x.display, w, _x.vis, AllocNone);
-
- /*
- * The pixel value returned from XGetPixel needs to
- * be converted to RGB so we can call rgb2cmap()
- * to translate between 24 bit X and our color. Unfortunately,
- * the return value appears to be display server endian
- * dependant. Therefore, we run some heuristics to later
- * determine how to mask the int value correctly.
- * Yeah, I know we can look at _x.vis->byte_order but
- * some displays say MSB even though they run on LSB.
- * Besides, this is more anal.
- */
- c = _x.map[19]; /* known to have different R, G, B values */
- if(!XAllocColor(_x.display, _x.cmap, &c)){
- werrstr("XAllocColor: %r");
- return -1;
- }
- p = c.pixel;
- pp = rgb2cmap((p>>16)&0xff,(p>>8)&0xff,p&0xff);
- if(pp != _x.map[19].pixel) {
- /* check if endian is other way */
- pp = rgb2cmap(p&0xff,(p>>8)&0xff,(p>>16)&0xff);
- if(pp != _x.map[19].pixel){
- werrstr("cannot detect X server byte order");
- return -1;
- }
-
- switch(_x.chan){
- case RGB24:
- _x.chan = BGR24;
- break;
- case XRGB32:
- _x.chan = XBGR32;
- break;
- default:
- werrstr("cannot byteswap channel %s",
- chantostr(buf, _x.chan));
- break;
- }
- }
- }else if(_x.vis->class == TrueColor || _x.vis->class == DirectColor){
- /*
- * Do nothing. We have no way to express a
- * mixed-endian 16-bit screen, so pretend they don't exist.
- */
- if(_x.usetable == 0)
- _x.cmap = XCreateColormap(_x.display, w, _x.vis, AllocNone);
- }else if(_x.vis->class == PseudoColor){
- if(_x.usetable == 0){
- _x.cmap = XCreateColormap(_x.display, w, _x.vis, AllocAll);
- XStoreColors(_x.display, _x.cmap, _x.map, 256);
- for(i = 0; i < 256; i++){
- _x.tox11[i] = i;
- _x.toplan9[i] = i;
- }
- }else{
- for(i = 0; i < 128; i++){
- c = _x.map7[i];
- if(!XAllocColor(_x.display, _x.cmap, &c)){
- werrstr("can't allocate colors in 7-bit map");
- return -1;
- }
- _x.tox11[_x.map7to8[i][0]] = c.pixel;
- _x.tox11[_x.map7to8[i][1]] = c.pixel;
- _x.toplan9[c.pixel] = _x.map7to8[i][0];
- }
- }
- }else{
- werrstr("unsupported visual class %d", _x.vis->class);
- return -1;
- }
- return 0;
-}
-
-void
-_flushmemscreen(Rectangle r)
-{
- if(_x.nextscreenpm != _x.screenpm){
- qlock(&_x.screenlock);
- XSync(_x.display, False);
- XFreePixmap(_x.display, _x.screenpm);
- _x.screenpm = _x.nextscreenpm;
- qunlock(&_x.screenlock);
- }
-
- if(r.min.x >= r.max.x || r.min.y >= r.max.y)
- return;
- XCopyArea(_x.display, _x.screenpm, _x.drawable, _x.gccopy, r.min.x, r.min.y,
- Dx(r), Dy(r), r.min.x, r.min.y);
- XFlush(_x.display);
-}
-
-void
-_xexpose(XEvent *e)
-{
- XExposeEvent *xe;
- Rectangle r;
-
- qlock(&_x.screenlock);
- if(_x.screenpm != _x.nextscreenpm){
- qunlock(&_x.screenlock);
- return;
- }
- xe = (XExposeEvent*)e;
- r.min.x = xe->x;
- r.min.y = xe->y;
- r.max.x = xe->x+xe->width;
- r.max.y = xe->y+xe->height;
- XCopyArea(_x.display, _x.screenpm, _x.drawable, _x.gccopy, r.min.x, r.min.y,
- Dx(r), Dy(r), r.min.x, r.min.y);
- XSync(_x.display, False);
- qunlock(&_x.screenlock);
-}
-
-int
-_xdestroy(XEvent *e)
-{
- XDestroyWindowEvent *xe;
-
- xe = (XDestroyWindowEvent*)e;
- if(xe->window == _x.drawable){
- _x.destroyed = 1;
- return 1;
- }
- return 0;
-}
-
-int
-_xconfigure(XEvent *e)
-{
- Rectangle r;
- XConfigureEvent *xe = (XConfigureEvent*)e;
-
- if(!fullscreen){
- int rx, ry;
- XWindow w;
- if(XTranslateCoordinates(_x.display, _x.drawable, DefaultRootWindow(_x.display), 0, 0, &rx, &ry, &w))
- windowrect = Rect(rx, ry, rx+xe->width, ry+xe->height);
- }
-
- if(xe->width == Dx(_x.screenr) && xe->height == Dy(_x.screenr))
- return 0;
- r = Rect(0, 0, xe->width, xe->height);
-
- qlock(&_x.screenlock);
- if(_x.screenpm != _x.nextscreenpm){
- XCopyArea(_x.display, _x.screenpm, _x.drawable, _x.gccopy, r.min.x, r.min.y,
- Dx(r), Dy(r), r.min.x, r.min.y);
- XSync(_x.display, False);
- }
- qunlock(&_x.screenlock);
- _x.newscreenr = r;
- return 1;
-}
-
-int
-_xreplacescreenimage(void)
-{
- Memimage *m;
- XDrawable pixmap;
- Rectangle r;
-
- r = _x.newscreenr;
-
- pixmap = XCreatePixmap(_x.display, _x.drawable, Dx(r), Dy(r), _x.depth);
- m = _xallocmemimage(r, _x.chan, pixmap);
- if(_x.nextscreenpm != _x.screenpm)
- XFreePixmap(_x.display, _x.nextscreenpm);
- _x.nextscreenpm = pixmap;
- _x.screenr = r;
- _drawreplacescreenimage(m);
- return 1;
-}
diff --git a/src/cmd/devdraw/x11-itrans.c b/src/cmd/devdraw/x11-itrans.c
deleted file mode 100644
index d84cdc8f9..000000000
--- a/src/cmd/devdraw/x11-itrans.c
+++ /dev/null
@@ -1,739 +0,0 @@
-/* input event and data structure translation */
-
-#include |