diff --git a/.gitignore b/.gitignore index 0a8110b..4353753 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.o spmenu *zst* +a.out diff --git a/Makefile b/Makefile index c82d01a..cd4031d 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,6 @@ install: all chmod 755 $(DESTDIR)$(PREFIX)/bin/spmenu* rm -f *.o rm -f spmenu - rm -f a.out compat: rm -f $(DESTDIR)$(PREFIX)/bin/dmenu diff --git a/README.md b/README.md index 6eef634..286bc7a 100644 --- a/README.md +++ b/README.md @@ -90,15 +90,4 @@ This build allows you to define .Xresources values to load on startup. See docs/ ### Scripts -This build of spmenu should work with all spmenu/dmenu scripts. [Here](https://codeberg.org/speedie/speedwm-extras) are a few I've written/use: - -### Notes for users of Arch who manually compile - -This fork of spmenu is compiled using tcc for speed however tcc from the Arch repositories seems to be broken. I'm sure there's a better way to fix this but I just fix it by installing [this package](https://aur.archlinux.org/packages/tcc-ziyao) from the AUR. - -### Notes for GCC users - -If you're compiling with GCC, chances are you're seeing a lot of warnings. -This is because we're compiling with -Ofast. I can't seem to find any issues -with using -Ofast but if it bothers you, you can compile -with -Os or -O2 which don't spit out these warnings. +This build of spmenu should work with all spmenu/dmenu scripts. [Here](https://codeberg.org/speedie/speedwm-extras) are a few I've written/use. diff --git a/host.mk b/host.mk index 2e85243..a1ce2d3 100644 --- a/host.mk +++ b/host.mk @@ -44,7 +44,7 @@ OPENSSL_CONF = openssl #X11LIB = /opt/X11/lib CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS) -CFLAGS = -std=c99 -pedantic -Wall -Ofast $(INCS) $(CPPFLAGS) +CFLAGS = -std=c99 -pedantic -Wall -O2 $(INCS) $(CPPFLAGS) LDFLAGS = $(LIBS) -INCS = -I$(X11INC) -I$(FREETYPEINC) `pkg-config --cflags $(XFT_CONF) $(PANGO_CONF) $(PANGOXFT_CONF) $(OPENSSL_CONF)` $(BDINC) +INCS = -I$(X11INC) -I$(FREETYPEINC) -I$(BDINC) `pkg-config --cflags $(XFT_CONF) $(PANGO_CONF) $(PANGOXFT_CONF) $(OPENSSL_CONF)` LIBS = -L$(X11LIB) $(X11LIBS) $(XINERAMALIBS) $(FREETYPELIBS) $(XRENDERLIBS) -lm `pkg-config --libs $(XFT_CONF) $(PANGO_CONF) $(PANGOXFT_CONF) $(OPENSSL_CONF)` $(BDLIBS) $(IMLIB2LIBS) diff --git a/libs/arg.c b/libs/arg.c index 8772788..02851ef 100644 --- a/libs/arg.c +++ b/libs/arg.c @@ -306,7 +306,7 @@ setimgsize(const Arg *arg) #endif /* this makes sure we cannot scale down the image too much */ - if (!image && imageheight + arg->i < imageheight || hideimage) return; + if ((!image && imageheight + arg->i < imageheight) || hideimage) return; cleanupimage(); diff --git a/libs/draw.c b/libs/draw.c index 02c6b00..03975d1 100644 --- a/libs/draw.c +++ b/libs/draw.c @@ -33,7 +33,7 @@ drawitem(struct item *item, int x, int y, int w) Clr scm[3]; int lp = lrpad / 2; /* padding */ int wr, rd; - int rw; /* width of text */ + int rw = 0; /* width of text */ int fg = 7; int bg = 0; int bgfg = 0; @@ -130,7 +130,7 @@ drawitem(struct item *item, int x, int y, int w) void drawmenu(void) { - unsigned int curpos; + unsigned int curpos = 0; struct item *item; int x = 0, y = 0, fh = drw->font->h, w; int ox = 0; diff --git a/libs/img.c b/libs/img.c index 57e304c..c155fe6 100644 --- a/libs/img.c +++ b/libs/img.c @@ -178,7 +178,7 @@ loadimagecache(const char *file, int *width, int *height) int slen = 0, i; unsigned char digest[MD5_DIGEST_LENGTH]; char md5[MD5_DIGEST_LENGTH*2+1]; - char *xdg_cache, *home = NULL, *dsize, *buf; + char *xdg_cache, *home = NULL, *dsize, *buf = NULL; struct passwd *pw = NULL; /* just load and don't store or try cache */ diff --git a/libs/rtl.c b/libs/rtl.c index ab6f960..36ae42c 100644 --- a/libs/rtl.c +++ b/libs/rtl.c @@ -12,11 +12,15 @@ apply_fribidi(char *str) fribidi_boolean result; fribidi_text[0] = 0; - if (len>0) - { + if (len>0) { charset = fribidi_parse_charset("UTF-8"); len = fribidi_charset_to_unicode(charset, str, len, logical); result = fribidi_log2vis(logical, len, &base, visual, NULL, NULL, NULL); len = fribidi_unicode_to_charset(charset, visual, len, fribidi_text); } + + if (result) + return; + else + return; } diff --git a/libs/schemes.c b/libs/schemes.c index cb00019..6cc6cc6 100644 --- a/libs/schemes.c +++ b/libs/schemes.c @@ -7,7 +7,7 @@ sixd_to_8bit(int x) void init_appearance(void) { - int x, y, i, j; + int i, j; char cbuf[8]; diff --git a/spmenu.c b/spmenu.c index cfc5959..3483d41 100644 --- a/spmenu.c +++ b/spmenu.c @@ -145,7 +145,6 @@ static int lrpad; /* sum of left and right padding */ static int vp; /* vertical padding for bar */ static int sp; /* side padding for bar */ static size_t cursor; -static unsigned int selected = 0; static struct item *items = NULL, *backup_items; static struct item *matches, *matchend; static struct item *prev, *curr, *next, *sel; @@ -651,7 +650,7 @@ navigatehistfile(int dir) } len = MIN(strlen(p), BUFSIZ - 1); - strncpy(text, p, len); + strcpy(text, p); text[len] = '\0'; cursor = len; match(); @@ -682,7 +681,6 @@ keypress(XEvent *e) KeySym keysym; XKeyEvent *ev; char buf[64]; - char keyArray; KeySym ksym = NoSymbol; Status status; @@ -692,11 +690,9 @@ keypress(XEvent *e) keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0, 0); - int iscont = 0; - for (i = 0; i < LENGTH(keys); i++) { - if (keysym == keys[i].keysym && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state) && keys[i].func) - if (keys[i].mode && curMode || keys[i].mode == -1) { + if (keysym == keys[i].keysym && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state) && keys[i].func) { + if ((keys[i].mode && curMode) || keys[i].mode == -1) { keys[i].func(&(keys[i].arg)); return; } else if (!keys[i].mode && !curMode) { @@ -704,6 +700,7 @@ keypress(XEvent *e) } else { continue; } + } } if (!iscntrl(*buf) && type && curMode ) { @@ -927,8 +924,6 @@ readstdin(void) if(!(items[i].image = malloc(strlen(items[i].text)+1))) fprintf(stderr, "spmenu: cannot malloc %lu bytes\n", strlen(items[i].text)); if(sscanf(items[i].text, "IMG:%[^\t]", items[i].image)) { - if(!(items[i].image = realloc(items[i].image, strlen(items[i].image)+1))) - fprintf(stderr, "spmenu: cannot realloc %lu bytes\n", strlen(items[i].image)+1); items[i].text += strlen("IMG:")+strlen(items[i].image)+1; } else { free(items[i].image); @@ -1042,7 +1037,6 @@ setup(void) int a, di, n, area = 0; #endif XWindowAttributes wa; - char cbuf[8]; /* init appearance */ init_appearance();