about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnselm R Garbe <garbeam@gmail.com>2009-09-22 09:53:11 +0100
committerAnselm R Garbe <garbeam@gmail.com>2009-09-22 09:53:11 +0100
commitc45d46ad9a44b9897c8c12eacb60b5cbdd31be7c (patch)
tree61a25bd1a0752ef8494f0a9522d04dc1dc212abe
parent6f55de83100547e6f78ebc276dfdbca5ee2581d9 (diff)
downloaddwm-c45d46ad9a44b9897c8c12eacb60b5cbdd31be7c.tar.gz
use buffer instead of pointer for mon->ltsymbol
-rw-r--r--dwm.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/dwm.c b/dwm.c
index 0d2f670..48f50da 100644
--- a/dwm.c
+++ b/dwm.c
@@ -121,7 +121,7 @@ typedef struct {
 } Layout;
 
 struct Monitor {
-	const char *ltsymbol;
+	char ltsymbol[16];
 	float mfact;
 	int num;
 	int by;               /* bar geometry */
@@ -386,7 +386,7 @@ arrange(void) {
 		showhide(m->stack);
 	focus(NULL);
 	for(m = mons; m; m = m->next) {
-		m->ltsymbol = m->lt[m->sellt]->symbol;
+		strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
 		if(m->lt[m->sellt]->arrange)
 			m->lt[m->sellt]->arrange(m);
 		restack(m);
@@ -605,7 +605,7 @@ createmon(void) {
 	m->topbar = topbar;
 	m->lt[0] = &layouts[0];
 	m->lt[1] = &layouts[1 % LENGTH(layouts)];
-	m->ltsymbol = layouts[0].symbol;
+	strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
 	return m;
 }
 
@@ -1163,17 +1163,14 @@ maprequest(XEvent *e) {
 
 void
 monocle(Monitor *m) {
-	static char ntext[8];
 	unsigned int n = 0;
 	Client *c;
 
 	for(c = m->clients; c; c = c->next)
 		if(ISVISIBLE(c))
 			n++;
-	if(n > 0) { /* override layout symbol */
-		snprintf(ntext, sizeof ntext, "[%d]", n);
-		m->ltsymbol = ntext;
-	}
+	if(n > 0) /* override layout symbol */
+		snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
 	for(c = nexttiled(m->clients); c; c = nexttiled(c->next))
 		resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False);
 }
ex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
NAME = ranger
VERSION = 1.0.4
PYTHON ?= python
DOCDIR ?= doc/pydoc
PREFIX ?= /usr/local
PYTHONOPTIMIZE ?= 2
CWD = $(shell pwd)
EDITOR ?= vim
DEST ?= $(shell $(PYTHON) -c 'import sys; sys.stdout.write( \
	[p for p in sys.path if "site" in p][0])' 2> /dev/null)/ranger

.PHONY: all compile clean doc cleandoc edit push test commit \
	install uninstall info snapshot minimal_snapshot

info:
	@echo 'This makefile provides shortcuts for common tasks.'
	@echo 'make clean: Remove all unnecessary files (.pyc, .pyo)'
	@echo 'make cleandoc: Remove the pydoc documentation'
	@echo 'make doc: Create the pydoc documentation'
	@echo 'make install: Install ranger'
	@echo 'make snapshot: Create a tar.gz of the current git revision'
	@echo
	@echo 'For developers:'
	@echo 'make commit: Test and commit the changes'
	@echo 'make test: Run all unittests.'
	@echo 'make push: push the changes via git'
	@echo 'make edit: open all relevant files in your editor'

all: test install

compile: clean
	@echo 'Compiling...'
	python -m compileall -q ranger
	PYTHONOPTIMIZE=$(PYTHONOPTIMIZE) python -m compileall -q ranger

doc: cleandoc
	mkdir -p $(DOCDIR)
	cd $(DOCDIR); \
		$(PYTHON) -c 'import pydoc, sys; \
		sys.path[0] = "$(CWD)"; \
		pydoc.writedocs("$(CWD)")'

uninstall:
	@echo 'To uninstall ranger, please remove these files:'
	@echo $(DEST)'/*'
	@echo $(PREFIX)'/bin/ranger'
	@echo 'and optionally the config files at:'
	@echo '~/.ranger'

install: compile
	@if [ '$(DEST)' == '/ranger' ]; then \
		echo 'Cannot find a suitable destination for the files.'; \
		false; \
	fi
	@echo "Installing..."
	cp ranger.py $(PREFIX)/bin/ranger
	cp -ruT ranger $(DEST)
	chmod 755 $(PREFIX)/bin/ranger
	chmod -R +rX $(DEST)
	@echo '--------------------------------------'
	@echo 'Finished.'
	@echo 'If you use BASH or ZSH, you can activate an extra feature now:'
	@echo 'When you exit ranger, the directory of the current shell can be'
	@echo 'changed to the last visited directory in ranger.  To do so, add'
	@echo 'this alias to your shell rc file (like ~/.bashrc):'
	@echo 'alias rng="source ranger ranger"'
	@echo 'And run ranger by typing rng.'


cleandoc:
	test -d $(DOCDIR) && rm -f -- $(DOCDIR)/*.html

clean:
	find . -regex .\*.py[co]\$$ -exec rm -f -- {} \;

test:
	./all_tests.py 1

edit:
	@$(EDITOR) ranger.py Makefile README COPYING HACKING INSTALL $(shell find ranger test -regex .\*py$ )

push:
	@for repo in $(shell git remote); do \
		echo "Pushing to $$repo..."; \
		git push $$repo master; \
	done

commit: test
	@git citool

snapshot:
	git archive HEAD | gzip > $(NAME)-$(VERSION)-$(shell git rev-parse HEAD | cut -b 1-8).tar.gz