Commit graph

2761 commits

Author SHA1 Message Date
jvd23
d96e9e5dc3 lib9: fix memory leak in dial of regular file (#284) 2020-01-13 11:38:17 -05:00
Xiao-Yong
cc48e73a96 fontsrv: allow x11 hinting and disable autohint only (#254)
Some truetype fonts have good manual hinting.
Ignoring hinting makes the font render badly on low resolution screens.
This commit only disables the freetype autohinter, and allows hinting.
2020-01-13 11:02:13 -05:00
Edouard Klein
185fd7db05 Make venti's doc more accurate 2020-01-13 10:10:31 -05:00
Neven Sajko
386bd9cae4 cmd/venti/srv: split memory allocation call
This splits a certain vtmallocz call in mkihash into two vtmallocz
calls. The first issue this fixes is that the C aliasing rules were not
respected in the code before this commit. The other thing is that this
enables better memory alignment guarantees.

Updates #313

Change-Id: Ia4f3e0fc85facc778193f5e977d4f99a1a9abd23
2020-01-13 10:08:01 -05:00
Russ Cox
0b6b451b71 libdraw: fix "mk"
Should default to building the library, not getsubfont.o.
2020-01-12 15:08:28 -05:00
Russ Cox
0158bceec7 libthread: run first thread in proc on system stack
For pthread systems that are fussy about which stack is used,
this makes sure that threadmain runs on a system stack.
If you only use proccreate (never threadcreate), all threads run
on system stacks.
2020-01-12 15:08:28 -05:00
Russ Cox
e0c4896ed4 lib9: make a p9frexp function wrapping system frexp
Under certain conditions it looks like frexp gets #defined
to something else on macOS during system headers,
which then breaks the declaration in libc.h.
2020-01-12 15:07:42 -05:00
Russ Cox
fafa622a5b all: fix or silence various gcc warnings
As usual, gcc finds some real problems but also reports a ton
of noise. Fix the problems and quiet the noise.
2020-01-12 15:07:42 -05:00
Dan Cross
fa325e9b42 Trivial changes: whitespace and modes.
Remote whitespace at the ends of lines.
Remove blank lines from the ends of files.
Change modes on source files so that they
are not executable.

Signed-off-by: Dan Cross <cross@gajendra.net>
2020-01-10 14:54:30 +00:00
Russ Cox
77a0a5b519 src: mv ../buildEnvironmentVariables mkhdr
Also note that the file must be valid shell and mk input.
For #321.
2020-01-09 20:08:10 -05:00
Russ Cox
5aad8f3d6d mkfile, mkmk.sh: update for new asm-free getcallerpc 2020-01-09 19:57:56 -05:00
Russ Cox
323e1a8fac lib9: add getcallerpc.c (fixes build) 2020-01-08 22:27:51 -05:00
Neven Sajko
a18741729c libhtml: plug a memory leak in addtext
Change-Id: I9b8a4430e7d26008ba9508095f8eb4b124a93b9b
2020-01-08 08:50:01 -05:00
Neven Sajko
8241eca986 libhtml: plug quite a few memory leaks
Change-Id: I45bd62a590373669e90183cc2b2ee56570c007f5
2020-01-08 08:50:01 -05:00
Dan Cross
2738cc3cfc mk: plan9 style.
In general, no space after `if` etc, and no
braces for a single statement inside of a loop
or conditional.

Signed-off-by: Dan Cross <cross@gajendra.net>
2020-01-08 01:37:44 +00:00
Neven Sajko
c65d179354 mk: fix out of bounds access
A loop is added for each structure field instead of accessing the other
fields through the first one in one loop.

Updates #313

Change-Id: I0e27e15feacb77391bc1decee7cf720d64d14586
2020-01-07 20:25:18 -05:00
Neven Sajko
e6ed10f25e lib9, libndb: exclude terminating null from strncpy bound
GCC pointed this out with some "warning: ‘strncpy’ specified bound NUM
equals destination size [-Wstringop-truncation]" warnings.

Change-Id: Id8408b165f6e4ae82c96a77599d89f658d979b32
2020-01-07 16:23:40 -05:00
Russ Cox
540caa5873 lib9: remove getcallerpc implementations
These make no sense and are not really needed at all.
Add a best-effort attempt to get at the gcc/clang macro
in lib9.h, but if it fails, no big deal.

Fixes #324.
2020-01-07 15:31:51 -05:00
Neven Sajko
2897735523 libmach: plug another memory leak
Change-Id: Ia5c888db1f0ded2aa92238d994239e46bf52667a
2020-01-07 15:27:58 -05:00
Neven Sajko
2c97de1a26 libmach: plug memory leak
Change-Id: I08cb7227c071c7fc2e30f43e07bcf599fc1d174a
2020-01-07 15:27:58 -05:00
Fazlul Shahriar
a4e59b3702 9term: add a "look" menu item (#299)
Add a menu item which functions similar to acme's `Look` command.

This is copied from 9front. See:
https://code.9front.org/hg/plan9front/rev/1f1596dbca51
https://code.9front.org/hg/plan9front/rev/d2de1d2f7b48
2020-01-07 15:02:01 -05:00
Neven Sajko
6f5bd96ed8 all: sync and dedup the creation of the SYSNAME and OBJTYPE env vars (#321)
This should prevent the issues of dist/buildmk and src/mkhdr getting out
of synchronization yet again.

I also add a rule for arm64 to the OBJTYPE sed command.

Fixes #243
Fixes #320

Change-Id: I60f69a1f32b5ed5ae5ac8a1659c38e29debed005
2020-01-07 14:49:26 -05:00
Neven Sajko
d9057521e6 cmd/htmlroff: fix buffer overflow in t2.c getqarg
This is actually from 2016:
https://plan9port-review.googlesource.com/c/plan9/+/1590

Change-Id: I6f2a3d71a9dd589eff7ab15b3c1d3997254b3c35
2020-01-02 22:04:42 +01:00
Neven Sajko
8cd46ae7bc ls: check that pointer is not nil before calling qsort
Passing a null pointer to qsort is an error in C (GCC and Clang agree
with the standards there, so this is no joke).

Change-Id: Ia2b015793a75ea4e85ae8f47da6beead9c4290e6
2020-01-02 21:47:32 +01:00
Neven Sajko
d6f8c236b8 acme: do not pass null pointers where disallowed
The C standards disallow passing null pointers to memmove and memcmp.

Change-Id: I1c88c2adbc32a23ef742f206038b8f7c4e0540c7
2020-01-02 21:47:07 +01:00
Neven Sajko
f77d12f8d8 cmd/rc: fix declarations of some externally linked variables
Change-Id: If8fe1afecb9fe55f85e8e5af37521b83e787d718
2020-01-02 16:22:53 +01:00
Neven Sajko
ab6f1aeac7 cb: fix a null pointer dereference
Just added a pair of parentheses. I also ran cb on cb.c to beautify the
code.

This is actually on Gerrit from 2016:
https://plan9port-review.googlesource.com/c/plan9/+/1574

Change-Id: I5e234adba0f95c13d6eecb121bf11bba4bf54566
2020-01-02 16:16:41 +01:00
Russ Cox
a1ead676e6 sam: report close error 2019-12-19 15:00:58 -05:00
Russ Cox
0b349f6f34 acme: report close failure during Put 2019-12-19 14:51:49 -05:00
Russ Cox
4af8158b53 libbio: report Bflush/close error from Bterm 2019-12-19 14:49:35 -05:00
Marc Simpson
f7f0512875 ed: formatting tweak (remove redundant tab). (#301) 2019-12-10 22:06:05 +05:30
Fazlul Shahriar
01a29ffe9d page: fix pdf prolog for ghostscript >= 9.27 (#296)
Ghostscript 9.27 removed GS_PDF_ProcSet and pdfdict due to a security
issue (see https://security-tracker.debian.org/tracker/CVE-2019-3839).

This fix was contributed by @onyxperidot (see #279).

Fixes #279
2019-12-08 20:20:22 -05:00
Marc Simpson
3d08a066b1 ed: replace magic number (077776, i.e. 32766) with NBLK-1. (#300)
Temp file size is now declared in an enum; changing it from the
default introduces a subtle bug in putline(), which expects it to
be 32767.

Mask with NBLK-1 instead.
2019-12-08 20:19:17 -05:00
Fazlul Shahriar
46606276c3 page: fix hang for forward-only postscript files
Page was hanging because ghostscript never closes the fd from which
we're reading BMP data. We close our end of the pipe so that ghostscript
will close its end.

Tested with ghostscript version 9.50.

Fixes #124
2019-11-14 01:26:39 -05:00
Jason Felice
b0aecb4ba5 plumber: add -f (foreground) option (#288)
In MacOS, services run by launchd must run in the foreground, since
launchd manages forking and other resources.
2019-10-29 10:07:10 -04:00
Fazlul Shahriar
1309450668 awk: split record into runes for empty FS (#292)
awk was splitting records into bytes instead of runes for empty FS.
For example, this was printing only the first byte of the utf-8 encoding
of é:

	echo é | awk 'BEGIN{FS=""}{print $1}'

The change just copies how the `split` function handles runes.

Originally reported by kris on twitter:
https://twitter.com/p9luv/status/1180436083433201665
2019-10-29 10:04:06 -04:00
deepcube
f1dd3f065a hoc: don't nest calls to follow() when lexing ++/+= and --/-= (#287)
The code had a nested use of the follow() function that could cause +=+
and -=- to register as ++ and --.  The first follow() to execute could
consume a character and match and then the second follow() could consume
another character and match.  For example i-=-10 would result in a syntax
error and i-=- would decrement i.
2019-09-19 13:10:28 -04:00
telephil
9389de63d7 upas/nfs: fix null date when message is sent to plumber (#263)
When fetching, messages are sent to plumber as soon as the ENVELOPE part is read.
    The date field of the message is sent when the INTERNALDATE part is read and
    there is no guarantee that this will be read before the ENVELOPE.
    This bug can be observed when using faces(1) which will retrieve messages with
    a null date and then always display a 'Jan 1' date instead of the correct one.
    The fix is to simply send the message to plumber after having read all parts,
    thus ensuring the message is complete.
2019-09-19 13:10:09 -04:00
Fazlul Shahriar
b9424f640a plumber: fix EOF detection on writes to rules file (#257)
Instead of checking Fcall.data==nil, check Fcall.count==0.
The former check always fails after `gcc -O2` optimizations
(gcc version 8.3.0).

Also fix an out-of-bound read detected by valgrind:
```
==31162== Invalid read of size 1
==31162==    at 0x11005E: morerules (rules.c:739)
==31162==    by 0x110254: writerules (rules.c:775)
==31162==    by 0x10D2FE: fsyswrite (fsys.c:848)
==31162==    by 0x10C304: fsysproc (fsys.c:248)
==31162==    by 0x112E8C: threadstart (thread.c:96)
==31162==    by 0x4A682BF: ??? (in /usr/lib/libc-2.29.so)
==31162==  Address 0x4ea984a is 0 bytes after a block of size 250 alloc'd
==31162==    at 0x483AD7B: realloc (vg_replace_malloc.c:826)
==31162==    by 0x1196F3: p9realloc (malloc.c:53)
==31162==    by 0x10BDFD: erealloc (plumber.c:124)
==31162==    by 0x10FCD9: concat (rules.c:642)
==31162==    by 0x10FCD9: concat (rules.c:635)
==31162==    by 0x110230: writerules (rules.c:773)
==31162==    by 0x10D2FE: fsyswrite (fsys.c:848)
==31162==    by 0x10C304: fsysproc (fsys.c:248)
==31162==    by 0x112E8C: threadstart (thread.c:96)
==31162==    by 0x4A682BF: ??? (in /usr/lib/libc-2.29.so)
```

Fixes #256
2019-09-19 13:08:54 -04:00
Zach Scott
7d827b5cca auxstats: replace /proc ACPI calls with /sys ones (#245)
According to <https://askubuntu.com/a/309146>, use of `/proc/acpi` to
get battery usage is deprecated. This commit replaces the two files from
this API with the single file `/sys/class/power_supply/BAT0/capacity`,
simultaneously removing the need to calculate battery percentage.
2019-09-19 13:08:36 -04:00
Xiao-Yong
e995a0c101 devdraw: cocoa metal screen adds a delayed update (#270)
The immediate display of the screen sometimes miss the update from
the CPU side memory.  No obvious synchronization mechanism is available.
In order to make sure the screen updates properly, we set needsDisplay
again after 16ms delay to ensure a second screen update.
2019-06-19 14:32:57 -04:00
Pocket7878
d4e16c838a devdraw: handle windowDidResize on macOS (#212)
This supports non-live window resize.
2019-06-11 12:56:42 -04:00
Russ Cox
7a241631b2 acme: accept expanded URLs in look
Just as look expands a click in /etc/passwd to the full name
(provided that file exists), it now expands a click in https://9fans.net/
to the full URL (provided the prefix is http:// or https://).
Probably more adjustment is needed.
2019-06-10 16:01:10 -04:00
Russ Cox
161742770e acme: delete trailing spaces during Put in autoindent mode
Autoident mode is the leading cause of trailing spaces on lines.
Remove them during Put to make various picky tools happier.
The changes during Put are added as a separate entry to the
file history, so that the first Undo after Put restores the spaces.
2019-05-17 23:18:06 -04:00
Xiao-Yong
cc9ecfbee7 devdraw: cocoa metal screen updates (#215)
* devdraw: cocoa metal screen uses a dirty hack to make everything smooth

* devdraw: cocoa metal screen uses a layer to make fullscreen applications behave

* devdraw: macOS cocoa metal fix resizeimg without img

* devdraw: macOS cocoa metal uses blit instead of render

We directly use the blit command encoder to copy texture to the
framebuffer.  We no longer need to compile the metal shader every
time the application starts just for rendering a flat 2D surface.

* travis: add osx images covering 10.13 and 10.14
2019-05-17 23:17:44 -04:00
Russ Cox
3197719090 acme: do not trim spaces during Put
The commit that introduced this was pushed accidentally.
It is not a good idea to do this.
(It breaks programs that think that a clean window
means the body matches the on-disk file.)
2019-04-19 22:24:53 -04:00
Pocket7878
9179fdaaf4 samterm: stop ignoring all keys >= Kcmd 2019-04-05 15:12:41 -04:00
Xiao-Yong
317c3cdb76 devdraw: stop redirecting ^H in cocoa-metal (#209) 2019-04-05 15:11:11 -04:00
Fazlul Shahriar
7bb69ba88b libdraw,devdraw: fix compatibility with old 16x16 cursor protocol (#217)
Some libraries that depend on devdraw don't know about
32x32 cursor -- mainly 9fans.net/go/draw.
2019-04-05 15:09:35 -04:00
Chris Schultz
6160158729 devdraw: prefer low-power GPU for macOS metal rendering (#231) 2019-04-05 15:08:20 -04:00
Russ Cox
26c6b25795 devdraw: avoid deadlock on pre-Mojave macOS 2019-04-05 15:04:10 -04:00
Martin Kühl
dfac95269a acme: Update tag after receiving menu/nomenu control event (#251) 2019-04-05 14:45:56 -04:00
Xiao-Yong
0308e1f010 devdraw: fix cocoa metal _flushmemscreen for invalid rectangles (#240)
It is possible to receive multiple screen resize events, and resizeimg
would be called for different sizes, before _flushmemscreen actually
gets called with rectangle sizes different from the most recent
resizeimg call.  The size mismatch would trigger illegal memory
access inside _flushmemscreen.

This commit protects _flushmemscreen by returning early if the requested
rectangle is outside of the current texture rectangle.
2019-04-05 14:44:47 -04:00
Jacob Vosmaer
4d3c36cce4 devdraw: respond to windowDidBecomeKey on darwin (#239)
Fixes bug where devdraw does not "notice" mouse position after task
switch. Fixes https://github.com/9fans/plan9port/issues/232.
2019-04-05 14:43:21 -04:00
Russ Cox
047fd92174 page: handle EPS without showpage 2019-02-25 09:45:53 -05:00
Russ Cox
3ad4afbe82 rio: delete ancient Imakefile (use mk instead)
Fixes #235.
2019-02-01 13:20:49 -05:00
Russ Cox
43f1873709 acme: drop trailing spaces during Put of auto-indent window
Auto-indent mode leaves trailing spaces on blank lines
as you type past them, so silently elide them from the
window content as it gets written back to disk.

Another option would be to remove them from the
window entirely during Put, but they're actually nice
to have while editing, and to date Put has never
modified the window content.
2019-02-01 13:20:46 -05:00
Russ Cox
16d0081989 libdraw: redo default font construction to be hidpi-safe
If $font is not set, the default font is constructed from
font data linked into every libdraw binary. That process
was different from the usual openfont code, and so it was
not hidpi-aware, resulting in very tiny fonts out of the box
on hidpi systems, until users set $font.

Fix this by using openfont to construct the default font,
by recognizing the name *default* when looking for
font and subfont file contents. Then all the hidpi scaling
applies automatically.

As a side effect, the concept of a 'default subfont' is gone,
as are display->defaultsubfont, getdefont, and memgetdefont.
2018-11-16 00:03:24 -05:00
Martin Kühl
3ebbb99ce3 file: recognize Mach-O binaries and Java class files 2018-11-15 22:12:48 -05:00
Martin Kühl
3ae09bee86 file: add missing newlines to file types 2018-11-15 22:11:47 -05:00
Tobias Heinicke
a309537fdc paint: add drawing program from 9front (#112)
Paint first appeared in 9front. The 9front license is reproduced
in the related source files - the original repository is located at
https://code.9front.org/hg/plan9front.
2018-11-15 22:10:26 -05:00
Russ Cox
c63d31a8c1 rio: make 'mk all' explain why it does nothing on non-x11 systems
Fixes #98.
2018-11-15 22:05:53 -05:00
Jacob Vosmaer
3d6fc088f0 devdraw: remove os x 10.5 compatibility code 2018-11-15 22:03:27 -05:00
Russ Cox
43b0d532bd acme: add 32x32 boxcursor
The only difference from the upscaled 16x16
is a one-pixel adjustment in the offset position,
but this at least exercises setcursor2.
2018-11-15 20:52:18 -05:00
Russ Cox
7d43dde539 devdraw: add Cursor2 support on macOS 10.14 Mojave
This replaces the pixel-art scaling algorithm used for upscaling before.
The results were not crisp enough to serve as everyday cursors.
2018-11-15 20:39:35 -05:00
Russ Cox
be0a15c47b tweak: add support for Cursor2 2018-11-15 20:39:35 -05:00
Russ Cox
8581c2b567 libdraw: add Cursor2, a 32x32 high-res cursor
Also add setcursor2, esetcursor2, and draw protocol encoding.
Calls to the old setcursor, esetcursor create a 32x32 by
pixel doubling when needed.
2018-11-15 20:39:35 -05:00
Xiao-Yong Jin
9af9ceca26 devdraw: rewrite the Cocoa screen using Metal
Add a new macOS cocoa screen, cocoa-screen-metal.m.
Rewrite the macOS cocoa drawing code to use the builtin runloop,
and use Metal to push pixels with CAMetalLayer.

Remove all of the deprecated code, and simplify some of the logic.
Modify mkwsysrules.sh such that the new code is used only when
the system version is equal or higher than 10.14.

Allow touch events to simulate mouse clicks:
three finger tap for the middle mouse button;
four finger tap for the 2-1 chord.

Support Tresize.

Scale 16x16 Cursor up to 32x32 with an EPX algorithm.

Support macOS input sources including the basic dead keys and the
advanced CJK input methods.

Increase the communication buffers in cocoa-srv.c to allow more
input, especially for long sentences prepared by the macOS input
souces.
2018-11-15 20:39:35 -05:00
Zach Scott
de43b1629d upas/smtp: fix TLS connections (#163)
Both `upas/nfs` and `upas/smtp` call the currently broken `tlsClient()`
from libsec. This commit copies a fix from upas/nfs into upas/smtp.

In `imapdial()`, upas/nfs replaces a process call for tlsClient with
`stunnel3` when not on Plan 9. upas/smtp calls tlsClient directly
as a function, so imapdial was copied into mxdial.c as `smtpdial()`,
and tlsClient+dial replaced with a call to smtpdial.
2018-11-14 00:24:07 -05:00
Gabriel Díaz
000c1a3b19 devdraw: set displaydpi on devdraw x11 attach (#178)
See https://plan9port-review.googlesource.com/c/plan9/+/1470
for discussion of the approach, especially Michael Stapleberg's comment:

Note that chromium, firefox and others have tried this and then switched to using the Xft.dpi X resource, see e.g. https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/ui/libgtk2ui/gtk2_ui.cc and especially http://sources.debian.net/src/gnome-settings-daemon/3.18.2-1/plugins/xsettings/gsd-xsettings-manager.c/?hl=824#L80 for some anecdata about why this approach doesn’t work out.

The Xft.dpi resource is being set accurately by desktop environments (GNOME, KDE, …) and can easily be changed by users of niche window managers by editing ~/.Xresources.

I suggest we check only Xft.dpi, without considering the DPI environment variable or the monitor width/height.
2018-11-14 00:19:29 -05:00
Russ Cox
d3f21b709e 9term: make 9term -l invoke $SHELL with -l 2018-11-14 00:13:01 -05:00
iru-
ed959cfba3 fontsrv: increase x11 font height scale (#111) 2018-11-14 00:01:04 -05:00
Xiao-Yong
a9e66ffa4e devdraw: make ctrl generate 1-click while mouse down (#119)
This makes 2-1 chords possible with touchpad on a mac laptop.
2018-11-13 23:57:56 -05:00
Xiao-Yong
c82e11b24e fontsrv: x11 uses FC_POSTSCRIPT_NAME (#174)
This makes fontsrv use the PostScript font names on X11.
The PostScript font names contains only alphanumeric and
hyphens.  This allows us to use the Font command in acme.
It also matches the font names used by fontsrv on macOS,
which has been using PostScript font names.
2018-11-13 23:13:15 -05:00
Fazlul Shahriar
76b9347a5f acme: avoid division by zero when resizing col (#189)
To reproduce, create a column with at least two windows and resize
acme to have almost zero height.
2018-11-13 23:11:31 -05:00
Xiao-Yong
2419c93438 fontsrv: disable font smoothing on osx (#196)
macOS Mojave version 10.14 starts to disable font smoothing.
We disable font smoothing for OSX_VERSION >= 101400 to match the
system default font rendering.
It also makes the font rendering on macOS similar to that on X11.
2018-11-13 23:09:59 -05:00
Xiao-Yong
014fd65a5c 9term: fix getpts on FreeBSD 11.2 (#199)
Opening /dev/ptyXX files fails on recent
FreeBSD versions.

Following the same fix being applied to
Linux, OpenBSD, and Darwin, we use openpty
to open a pseudoterminal in openpts.
2018-11-13 23:09:10 -05:00
Fazlul Shahriar
48da9bd71d fontsrv: copy some fixes from OS X to X11
* Avoid allocating empty images by adding 1 to width/height. This was
  crashing fontsrv. The total width of the subfont image can be zero
  even if the characters are present in the font. For example, all the
  characters in x0300.bit (part of "Combining Diacritical Marks" Unicode
  block) have zero width.
* Make sure U+0000 is always present in the font, otherwise libdraw
  complains with: "stringwidth: bad character set for rune 0x0000 in ..."
* Use the same fallback glyph (pjw face) as OS X. This also fixes a bug
  where advance was set to the total width of subfont instead of the
  character.

Update #125 (most likely fixes the crash if in X11)

Change-Id: Icdc2b641b8b0c08644569006e91cf613b4d5477f
2018-10-05 23:38:31 +02:00
Charles Collicutt
db27122d39 upas/nfs: correctly quote IMAP LOGIN arguments
According to RFC 3501 the arguments to the LOGIN command should be
quoted strings (or length prefixed string literals). Without quoting,
authentication to some IMAP servers (e.g. Dovecot) will fail.
2018-10-05 18:15:28 +02:00
David du Colombier
93c75d2bad grep: update from Plan 9
This change fixes a segfault in grep -e when no argument
has been provided. Thanks to Sean Hinchee for reporting
this issue.

Fixes #186.
2018-10-01 17:20:35 +02:00
David du Colombier
de3b6d5848 libregexp: include stddef.h in lib9.std.h
Commit 2d82ef9d98 added ptrdiff_t in regcomp.c.
However, this change broke the build of the Unix
package because ptrdiff_t is defined in stddef.h.
2018-09-29 15:59:31 +02:00
Martin Kühl
a82a8b6368 acme: Apply each -/+ only once (#156)
When plumbing an address like `3-`, Acme selects line 1,
and similarly `3+` selects line 5.
The same problem can be observed for character addresses (`#123+`)
but _not_ for ones like `+`, `.+` or `/foo/+`:
The problem only occurs when a number is followed by a direction (`-`/`+`).

Following along with the example `3-` through `address` (in addr.c):
We read `3` into `c` and match the `case` on line 239.
The `while` loop on line 242ff reads additional digits into `c`
and puts the first non-digit back by decrementing the index `q`.
Then we find the range for line 3 on line 251 and continue.

On the next iteration, we set `prevc` to the last `c`,
but since that part read ahead _into `c`_,
`c` is currently the _next_ character we will read, `-`,
and now `prevc` is too.

Then in the case block (line 210) the condition on line 211 holds
and Acme believes that it has read two `-` in sequence
and modifies the range to account for the “first” `-`.
The “second” `-` gets applied after the loop is done, on line 292.

So the general problem is:
While reading numbers, Acme reads the next character after the number into `c`.
It decrements the counter to ensure it will read it again on the next iteration,
but it still uses it to update `prevc`.

This change solves the problem by reading digits into `nc` instead.
This variable is used to similar effect in the block for directions (line 212)
and fills the role of “local `c` that we can safely use to read ahead” nicely.
2018-09-19 23:19:36 +10:00
Igor Burago
df2d9ec9d1 fontsrv: omit box-drawing characters from line struts on macOS
For some fonts, using box-drawing characters in the representative
text for computing the line height results in it being uncomfortably
high. Replace them with accented capitals and tall lower-case letters
which lead to a more conservative increase in the line height.

Fixes #162.
2018-06-26 23:24:22 +02:00
Xiao-Yong Jin
03a8ec739a libdraw: fix error in the previous commit 2018-03-27 18:11:37 +02:00
Xiao-Yong Jin
96025b1ec8 mc: fix crash in acme with hidpi display 2018-03-27 15:16:10 +02:00
Xiao-Yong Jin
75ea8515a5 samterm: free some getenv results 2018-03-27 15:03:12 +02:00
Xiao-Yong Jin
edfe3c016f sam: freetmpstr instead of free 2018-03-27 15:03:12 +02:00
Xiao-Yong Jin
dc2a17b95c libdraw: fix some memory leaks in font handling 2018-03-27 15:03:12 +02:00
Xiao-Yong Jin
a3ec102dc7 fontsrv: fix some memory leaks 2018-03-27 15:03:12 +02:00
Xiao-Yong Jin
b2f6769830 devdraw: fix some memory leaks in x11 2018-03-27 15:03:12 +02:00
Xiao-Yong Jin
7ca1c90109 acme: fix some memory leaks 2018-03-27 15:03:12 +02:00
Xiao-Yong Jin
96dc233091 fontsrv: enlarge drawing buffer for subfonts on macOS
Double the width returned by CTFontGetBoundingBox when drawing.
Add box drawing characters for determining the line height.
Call freememimage(1) for the character memimage.

Fixes #18.
Fixes #120.
Fixes #146.
2018-03-27 15:02:33 +02:00
Xiao-Yong Jin
a5b24c22a8 mount, 9pfuse: detect macports installed osxfuse
MacPorts installs osxfuse under /opt/local.
2018-03-27 15:01:46 +02:00
Mechiel Lukkien
4ebaf18e92 fontsrv: skip only the surrogate pairs
fontsrv wasn't rendering fontawesome icons,
which uses the private use area around 0xf000.
2018-03-23 12:05:33 +01:00
Ray Lai
d579124682 9pserve: fix memory leak in warning 2018-03-23 11:55:19 +01:00
Martin Kühl
cfa9a6dfa1 9term: Set TERM_PROGRAM to termprog
TERM_PROGRAM is the customary way to identify which kind of terminal
emulator program one uses on macOS.
This change sets TERM_PROGRAM to termprog since both variables are used
for the same purpose.
2018-03-23 10:41:43 +01:00
Xiao-Yong Jin
112744e54b 9pfuse: retries read(3) upon EINTR
read(3) sometimes errors with EINTR on macOS over slow connections.
9pfuse(1) now retries read(3) instead of sysfatal(3)ing.
2018-03-23 10:36:08 +01:00
David du Colombier
4798a8a556 9pfuse: fix handling of access mode (thanks Kenji Arisawa)
Fixes #81.
2018-02-05 21:14:32 +01:00
Bakul Shah
da8a485fc1 auxstats: get network stats in a portable manner on FreeBSD
as the old grody way doesn't work any more on FreeBSD-10 and later.
2018-01-23 09:00:53 +01:00
Ray Lai
019be4481f rc: use proper type for storing ulimit values
rc on amd64 stores ulimit values as 32-bit int, but the limits on
OpenBSD amd64 can exceed 2^31, so "ulimit -a" shows some values as
negative. This is a problem when I want to increase my ulimit but
the hard ulimit values are printed as negative.
2018-01-17 17:49:47 +01:00