Compare commits

...

31 Commits
4.8 ... 5.1

Author SHA1 Message Date
308fe78b83 bump version to 5.1 2022-02-11 12:26:35 +01:00
c4b656e0da code-style: rm newline (oops) 2022-02-08 21:45:28 +01:00
3e39c526d2 revert using strcasestr and use a more optimized portable version
... compared to the old cistrstr().

Thanks for the feedback!
2022-02-08 19:38:23 +01:00
a9a3836861 follow-up fix: add -D_GNU_SOURCE for strcasestr for some systems 2022-02-07 10:36:13 +01:00
eb96af27f4 improve performance of case-insensitive matching 2022-02-07 00:21:12 +01:00
d78ff08d99 Revert "Improve speed of drw_text when provided with large strings"
This reverts commit c585e8e498ec6f9c423ab8ea07cf853ee5b05fbe.

It causes issues with truncation of characters when the text does not fit and
so on.  The patch should be reworked and properly tested.
2021-08-20 23:05:53 +02:00
cd2133a5f6 add support for more keypad keys
The keypad Enter key was already supported. On some keyboard layouts like my
laptop the page-up and page-down key is more comfortable to use.
This adds a few lines but no complexity.
2021-08-09 18:39:25 +02:00
c585e8e498 Improve speed of drw_text when provided with large strings
Calculates len & ew in drw_font_getexts loop by incrementing instead of
decrementing; as such avoids proportional increase in time spent in loop
based on provided strings size.
2021-08-09 18:20:51 +02:00
523aa08f51 remove always true condition in if statement 2021-07-25 10:55:45 +02:00
1a13d0465d bump version to 5.0
... and bump LICENSE year.
2020-09-02 18:31:23 +02:00
9b38fda6fe Fix memory leaks in drw
Synced from dwm.
Patch by Alex Flierl <shad0w73@freenet.de>, thanks.
2020-06-11 18:45:33 +02:00
db6093f6ec revert IME support
dmenu will not handle IME support (st will, atleast for now).

revert parts of commit 377bd37e212b1ec4c03a481245603c6560d0be22
this commit also broke input focus.
2019-03-03 13:08:54 +01:00
a9b1de384a improve xopenim error message
die() already prints a newline.
2019-02-12 22:58:35 +01:00
43b0c2c3dd make dmenu_path script executable
(as dmenu_run is)
2019-02-12 22:13:58 +01:00
f5036b90ef fix crash when XOpenIM returns NULL
for example when IME variables are set, but the program is not started (yet).
2019-02-12 19:10:43 +01:00
153aaf88bf Close when the embedding window is destroyed 2019-02-04 19:49:34 +01:00
65be875f5a Prepared 4.9 release. 2019-02-02 04:54:15 -08:00
7d19b2055d dmenu.1: document improved fastgrab behaviour from previous patch 2019-01-27 15:28:02 +01:00
dok
11a65377da Use slow path if stdin is a tty
If stdin is a tty and dmenu is ran with the fast option then it's
impossible to close stdin because the keyboard is already grabbed.
2019-01-27 15:26:04 +01:00
bbc464dc80 dmenu_path: always use the cachedir 2018-07-21 12:49:00 +02:00
a314412f4b Makefile: just show the compiler output
Don't be fancy and just show the actual output so debugging is simpler.
2018-06-02 17:09:01 +02:00
a9eae39e93 Do not strip at link stage
Building with debug symbols is worthless unless LDFLAGS are manually adjusted
as well.
2018-06-02 17:01:24 +02:00
851b73d178 code-style for pledge: check the return code -1, not < 0
this is the proper idiom
2018-05-25 13:07:17 +02:00
05c138f5b8 code-style for pledge(2)
feedback from Klemens, thanks
2018-05-25 13:03:25 +02:00
cd132c8d5b Pledge on OpenBSD 2018-05-25 12:04:22 +02:00
e75494b730 Use bold for keyboard shortcuts in dmenu.1
Like dwm, use the same syntax for all keyboard shortcuts for
consistency.
2018-05-12 19:12:25 +02:00
0f76dd2fb8 Fix cursor drawn position with wide glyphs 2018-04-22 14:19:20 +02:00
0b57480218 Makefile: bikesheddingly replace ${} with $() 2018-04-22 14:09:05 +02:00
377bd37e21 Handle IME input
Thanks to nzl <uruabi@gmail.com> for the patch!
2018-04-22 14:09:05 +02:00
b6d2cc9aea Fix handling of input strings 2018-04-22 14:09:05 +02:00
2f398981fe Update LICENSE
Only "meaningful" commits and contributors who made changes over the
years have been added.
2018-03-15 18:29:32 +01:00
8 changed files with 165 additions and 119 deletions

12
LICENSE
View File

@ -1,13 +1,15 @@
MIT/X Consortium License
© 2006-2014 Anselm R Garbe <anselm@garbe.us>
© 2010-2012 Connor Lane Smith <cls@lubutu.com>
© 2006-2019 Anselm R Garbe <anselm@garbe.ca>
© 2006-2008 Sander van Dijk <a.h.vandijk@gmail.com>
© 2006-2007 Michał Janeczek <janeczek@gmail.com>
© 2007 Kris Maglione <jg@suckless.org>
© 2009 Gottox <gottox@s01.de>
© 2009 Markus Schnalke <meillo@marmaro.de>
© 2009 Evan Gates <evan.gates@gmail.com>
© 2006-2008 Sander van Dijk <a dot h dot vandijk at gmail dot com>
© 2006-2007 Michał Janeczek <janeczek at gmail dot com>
© 2014-2015 Hiltjo Posthuma <hiltjo@codemadness.org>
© 2010-2012 Connor Lane Smith <cls@lubutu.com>
© 2014-2022 Hiltjo Posthuma <hiltjo@codemadness.org>
© 2015-2019 Quentin Rameau <quinq@fifth.space>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),

View File

@ -4,71 +4,61 @@
include config.mk
SRC = drw.c dmenu.c stest.c util.c
OBJ = ${SRC:.c=.o}
OBJ = $(SRC:.c=.o)
all: options dmenu stest
options:
@echo dmenu build options:
@echo "CFLAGS = ${CFLAGS}"
@echo "LDFLAGS = ${LDFLAGS}"
@echo "CC = ${CC}"
@echo "CFLAGS = $(CFLAGS)"
@echo "LDFLAGS = $(LDFLAGS)"
@echo "CC = $(CC)"
.c.o:
@echo CC $<
@${CC} -c ${CFLAGS} $<
$(CC) -c $(CFLAGS) $<
config.h:
@echo creating $@ from config.def.h
@cp config.def.h $@
cp config.def.h $@
${OBJ}: arg.h config.h config.mk drw.h
$(OBJ): arg.h config.h config.mk drw.h
dmenu: dmenu.o drw.o util.o
@echo CC -o $@
@${CC} -o $@ dmenu.o drw.o util.o ${LDFLAGS}
$(CC) -o $@ dmenu.o drw.o util.o $(LDFLAGS)
stest: stest.o
@echo CC -o $@
@${CC} -o $@ stest.o ${LDFLAGS}
$(CC) -o $@ stest.o $(LDFLAGS)
clean:
@echo cleaning
@rm -f dmenu stest ${OBJ} dmenu-${VERSION}.tar.gz
rm -f dmenu stest $(OBJ) dmenu-$(VERSION).tar.gz
dist: clean
@echo creating dist tarball
@mkdir -p dmenu-${VERSION}
@cp LICENSE Makefile README arg.h config.def.h config.mk dmenu.1 \
drw.h util.h dmenu_path dmenu_run stest.1 ${SRC} \
dmenu-${VERSION}
@tar -cf dmenu-${VERSION}.tar dmenu-${VERSION}
@gzip dmenu-${VERSION}.tar
@rm -rf dmenu-${VERSION}
mkdir -p dmenu-$(VERSION)
cp LICENSE Makefile README arg.h config.def.h config.mk dmenu.1\
drw.h util.h dmenu_path dmenu_run stest.1 $(SRC)\
dmenu-$(VERSION)
tar -cf dmenu-$(VERSION).tar dmenu-$(VERSION)
gzip dmenu-$(VERSION).tar
rm -rf dmenu-$(VERSION)
install: all
@echo installing executables to ${DESTDIR}${PREFIX}/bin
@mkdir -p ${DESTDIR}${PREFIX}/bin
@cp -f dmenu dmenu_path dmenu_run stest ${DESTDIR}${PREFIX}/bin
@chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu
@chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu_path
@chmod 755 ${DESTDIR}${PREFIX}/bin/dmenu_run
@chmod 755 ${DESTDIR}${PREFIX}/bin/stest
@echo installing manual pages to ${DESTDIR}${MANPREFIX}/man1
@mkdir -p ${DESTDIR}${MANPREFIX}/man1
@sed "s/VERSION/${VERSION}/g" < dmenu.1 > ${DESTDIR}${MANPREFIX}/man1/dmenu.1
@sed "s/VERSION/${VERSION}/g" < stest.1 > ${DESTDIR}${MANPREFIX}/man1/stest.1
@chmod 644 ${DESTDIR}${MANPREFIX}/man1/dmenu.1
@chmod 644 ${DESTDIR}${MANPREFIX}/man1/stest.1
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f dmenu dmenu_path dmenu_run stest $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu
chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_path
chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run
chmod 755 $(DESTDIR)$(PREFIX)/bin/stest
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
sed "s/VERSION/$(VERSION)/g" < dmenu.1 > $(DESTDIR)$(MANPREFIX)/man1/dmenu.1
sed "s/VERSION/$(VERSION)/g" < stest.1 > $(DESTDIR)$(MANPREFIX)/man1/stest.1
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/dmenu.1
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/stest.1
uninstall:
@echo removing executables from ${DESTDIR}${PREFIX}/bin
@rm -f ${DESTDIR}${PREFIX}/bin/dmenu
@rm -f ${DESTDIR}${PREFIX}/bin/dmenu_path
@rm -f ${DESTDIR}${PREFIX}/bin/dmenu_run
@rm -f ${DESTDIR}${PREFIX}/bin/stest
@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
@rm -f ${DESTDIR}${MANPREFIX}/man1/dmenu.1
@rm -f ${DESTDIR}${MANPREFIX}/man1/stest.1
rm -f $(DESTDIR)$(PREFIX)/bin/dmenu\
$(DESTDIR)$(PREFIX)/bin/dmenu_path\
$(DESTDIR)$(PREFIX)/bin/dmenu_run\
$(DESTDIR)$(PREFIX)/bin/stest\
$(DESTDIR)$(MANPREFIX)/man1/dmenu.1\
$(DESTDIR)$(MANPREFIX)/man1/stest.1
.PHONY: all options clean dist install uninstall

View File

@ -1,9 +1,9 @@
# dmenu version
VERSION = 4.8
VERSION = 5.1
# paths
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
MANPREFIX = $(PREFIX)/share/man
X11INC = /usr/X11R6/include
X11LIB = /usr/X11R6/lib
@ -16,16 +16,16 @@ XINERAMAFLAGS = -DXINERAMA
FREETYPELIBS = -lfontconfig -lXft
FREETYPEINC = /usr/include/freetype2
# OpenBSD (uncomment)
#FREETYPEINC = ${X11INC}/freetype2
#FREETYPEINC = $(X11INC)/freetype2
# includes and libs
INCS = -I${X11INC} -I${FREETYPEINC}
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
INCS = -I$(X11INC) -I$(FREETYPEINC)
LIBS = -L$(X11LIB) -lX11 $(XINERAMALIBS) $(FREETYPELIBS)
# flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
LDFLAGS = -s ${LIBS}
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS)
CFLAGS = -std=c99 -pedantic -Wall -Os $(INCS) $(CPPFLAGS)
LDFLAGS = $(LIBS)
# compiler and linker
CC = cc

60
dmenu.1
View File

@ -41,8 +41,8 @@ which lists programs in the user's $PATH and runs the result in their $SHELL.
dmenu appears at the bottom of the screen.
.TP
.B \-f
dmenu grabs the keyboard before reading stdin. This is faster, but will lock up
X until stdin reaches end\-of\-file.
dmenu grabs the keyboard before reading stdin if not reading from a tty. This
is faster, but will lock up X until stdin reaches end\-of\-file.
.TP
.B \-i
dmenu matches menu items case insensitively.
@ -106,88 +106,88 @@ Move cursor to the start of the current word
.B Ctrl-Right
Move cursor to the end of the current word
.TP
C\-a
.B C\-a
Home
.TP
C\-b
.B C\-b
Left
.TP
C\-c
.B C\-c
Escape
.TP
C\-d
.B C\-d
Delete
.TP
C\-e
.B C\-e
End
.TP
C\-f
.B C\-f
Right
.TP
C\-g
.B C\-g
Escape
.TP
C\-h
.B C\-h
Backspace
.TP
C\-i
.B C\-i
Tab
.TP
C\-j
.B C\-j
Return
.TP
C\-J
.B C\-J
Shift-Return
.TP
C\-k
.B C\-k
Delete line right
.TP
C\-m
.B C\-m
Return
.TP
C\-M
.B C\-M
Shift-Return
.TP
C\-n
.B C\-n
Down
.TP
C\-p
.B C\-p
Up
.TP
C\-u
.B C\-u
Delete line left
.TP
C\-w
.B C\-w
Delete word left
.TP
C\-y
.B C\-y
Paste from primary X selection
.TP
C\-Y
.B C\-Y
Paste from X clipboard
.TP
M\-b
.B M\-b
Move cursor to the start of the current word
.TP
M\-f
.B M\-f
Move cursor to the end of the current word
.TP
M\-g
.B M\-g
Home
.TP
M\-G
.B M\-G
End
.TP
M\-h
.B M\-h
Up
.TP
M\-j
.B M\-j
Page down
.TP
M\-k
.B M\-k
Page up
.TP
M\-l
.B M\-l
Down
.SH SEE ALSO
.IR dwm (1),

87
dmenu.c
View File

@ -6,6 +6,7 @@
#include <string.h>
#include <strings.h>
#include <time.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
@ -102,13 +103,20 @@ cleanup(void)
}
static char *
cistrstr(const char *s, const char *sub)
cistrstr(const char *h, const char *n)
{
size_t len;
size_t i;
for (len = strlen(sub); *s; s++)
if (!strncasecmp(s, sub, len))
return (char *)s;
if (!n[0])
return (char *)h;
for (; *h; ++h) {
for (i = 0; n[i] && tolower((unsigned char)n[i]) ==
tolower((unsigned char)h[i]); ++i)
;
if (n[i] == '\0')
return (char *)h;
}
return NULL;
}
@ -144,7 +152,7 @@ drawmenu(void)
drw_setscheme(drw, scheme[SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
drw_font_getexts(drw->fonts, text, cursor, &curpos, NULL);
curpos = TEXTW(text) - TEXTW(&text[cursor]);
if ((curpos += lrpad / 2 - 1) < w) {
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
@ -308,13 +316,21 @@ keypress(XKeyEvent *ev)
{
char buf[32];
int len;
KeySym ksym = NoSymbol;
KeySym ksym;
Status status;
len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status);
if (status == XBufferOverflow)
switch (status) {
default: /* XLookupNone, XBufferOverflow */
return;
if (ev->state & ControlMask)
case XLookupChars:
goto insert;
case XLookupKeySym:
case XLookupBoth:
break;
}
if (ev->state & ControlMask) {
switch(ksym) {
case XK_a: ksym = XK_Home; break;
case XK_b: ksym = XK_Left; break;
@ -351,13 +367,13 @@ keypress(XKeyEvent *ev)
utf8, utf8, win, CurrentTime);
return;
case XK_Left:
case XK_KP_Left:
movewordedge(-1);
ksym = NoSymbol;
break;
goto draw;
case XK_Right:
case XK_KP_Right:
movewordedge(+1);
ksym = NoSymbol;
break;
goto draw;
case XK_Return:
case XK_KP_Enter:
break;
@ -367,16 +383,14 @@ keypress(XKeyEvent *ev)
default:
return;
}
else if (ev->state & Mod1Mask)
} else if (ev->state & Mod1Mask) {
switch(ksym) {
case XK_b:
movewordedge(-1);
ksym = NoSymbol;
break;
goto draw;
case XK_f:
movewordedge(+1);
ksym = NoSymbol;
break;
goto draw;
case XK_g: ksym = XK_Home; break;
case XK_G: ksym = XK_End; break;
case XK_h: ksym = XK_Up; break;
@ -386,14 +400,16 @@ keypress(XKeyEvent *ev)
default:
return;
}
}
switch(ksym) {
default:
insert:
if (!iscntrl(*buf))
insert(buf, len);
break;
case NoSymbol:
break;
case XK_Delete:
case XK_KP_Delete:
if (text[cursor] == '\0')
return;
cursor = nextrune(+1);
@ -404,6 +420,7 @@ keypress(XKeyEvent *ev)
insert(NULL, nextrune(-1) - cursor);
break;
case XK_End:
case XK_KP_End:
if (text[cursor] != '\0') {
cursor = strlen(text);
break;
@ -423,6 +440,7 @@ keypress(XKeyEvent *ev)
cleanup();
exit(1);
case XK_Home:
case XK_KP_Home:
if (sel == matches) {
cursor = 0;
break;
@ -431,6 +449,7 @@ keypress(XKeyEvent *ev)
calcoffsets();
break;
case XK_Left:
case XK_KP_Left:
if (cursor > 0 && (!sel || !sel->left || lines > 0)) {
cursor = nextrune(-1);
break;
@ -439,18 +458,21 @@ keypress(XKeyEvent *ev)
return;
/* fallthrough */
case XK_Up:
case XK_KP_Up:
if (sel && sel->left && (sel = sel->left)->right == curr) {
curr = prev;
calcoffsets();
}
break;
case XK_Next:
case XK_KP_Next:
if (!next)
return;
sel = curr = next;
calcoffsets();
break;
case XK_Prior:
case XK_KP_Prior:
if (!prev)
return;
sel = curr = prev;
@ -467,6 +489,7 @@ keypress(XKeyEvent *ev)
sel->out = 1;
break;
case XK_Right:
case XK_KP_Right:
if (text[cursor] != '\0') {
cursor = nextrune(+1);
break;
@ -475,6 +498,7 @@ keypress(XKeyEvent *ev)
return;
/* fallthrough */
case XK_Down:
case XK_KP_Down:
if (sel && sel->right && (sel = sel->right) == next) {
curr = next;
calcoffsets();
@ -489,6 +513,8 @@ keypress(XKeyEvent *ev)
match();
break;
}
draw:
drawmenu();
}
@ -548,6 +574,11 @@ run(void)
if (XFilterEvent(&ev, win))
continue;
switch(ev.type) {
case DestroyNotify:
if (ev.xdestroywindow.window != win)
break;
cleanup();
exit(1);
case Expose:
if (ev.xexpose.count == 0)
drw_map(drw, win, 0, 0, mw, mh);
@ -651,14 +682,17 @@ setup(void)
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
XSetClassHint(dpy, win, &ch);
/* open input methods */
xim = XOpenIM(dpy, NULL, NULL, NULL);
/* input methods */
if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
die("XOpenIM failed: could not open input device");
xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
XNClientWindow, win, XNFocusWindow, win, NULL);
XMapRaised(dpy, win);
if (embed) {
XSelectInput(dpy, parentwin, FocusChangeMask);
XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
for (i = 0; i < du && dws[i] != win; ++i)
XSelectInput(dpy, dws[i], FocusChangeMask);
@ -736,7 +770,12 @@ main(int argc, char *argv[])
die("no fonts could be loaded.");
lrpad = drw->fonts->h;
if (fast) {
#ifdef __OpenBSD__
if (pledge("stdio rpath", NULL) == -1)
die("pledge");
#endif
if (fast && !isatty(0)) {
grabkeyboard();
readstdin();
} else {

12
dmenu_path Normal file → Executable file
View File

@ -1,10 +1,10 @@
#!/bin/sh
cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
if [ -d "$cachedir" ]; then
cache=$cachedir/dmenu_run
else
cache=$HOME/.dmenu_cache # if no xdg dir, fall back to dotfile in ~
fi
cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}"
cache="$cachedir/dmenu_run"
[ ! -e "$cachedir" ] && mkdir -p "$cachedir"
IFS=:
if stest -dqr -n "$cache" $PATH; then
stest -flx $PATH | sort -u | tee "$cache"

17
drw.c
View File

@ -95,6 +95,7 @@ drw_free(Drw *drw)
{
XFreePixmap(drw->dpy, drw->drawable);
XFreeGC(drw->dpy, drw->gc);
drw_fontset_free(drw->fonts);
free(drw);
}
@ -132,6 +133,19 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
die("no font specified.");
}
/* Do not allow using color fonts. This is a workaround for a BadLength
* error from Xft with color glyphs. Modelled on the Xterm workaround. See
* https://bugzilla.redhat.com/show_bug.cgi?id=1498269
* https://lists.suckless.org/dev/1701/30932.html
* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349
* and lots more all over the internet.
*/
FcBool iscol;
if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
XftFontClose(drw->dpy, xfont);
return NULL;
}
font = ecalloc(1, sizeof(Fnt));
font->xfont = xfont;
font->pattern = pattern;
@ -200,7 +214,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
Clr *ret;
/* need at least two colors for a scheme */
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(Clr))))
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
return NULL;
for (i = 0; i < clrcount; i++)
@ -337,6 +351,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
fcpattern = FcPatternDuplicate(drw->fonts->pattern);
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
FcPatternAddBool(fcpattern, FC_COLOR, FcFalse);
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
FcDefaultSubstitute(fcpattern);

View File

@ -84,7 +84,7 @@ main(int argc, char *argv[])
if (!argc) {
/* read list from stdin */
while ((n = getline(&line, &linesiz, stdin)) > 0) {
if (n && line[n - 1] == '\n')
if (line[n - 1] == '\n')
line[n - 1] = '\0';
test(line, line);
}