Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
spectrwm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Simplify limit retrieving.
[spectrwm.git]
/
spectrwm.c
diff --git
a/spectrwm.c
b/spectrwm.c
index
666fa0f
..
bc3e1fd
100644
(file)
--- a/
spectrwm.c
+++ b/
spectrwm.c
@@
-1539,46
+1539,44
@@
bar_fmt(const char *fmtexp, char *fmtnew, struct swm_region *r, size_t sz)
strlcat(fmtnew, "+4<+A+4<+V", sz);
}
strlcat(fmtnew, "+4<+A+4<+V", sz);
}
+void
+bar_replace_pad(char *tmp, int *limit, size_t sz)
+{
+ /* special case; no limit given, pad one space, instead */
+ if (*limit == sz - 1)
+ *limit = 1;
+ snprintf(tmp, sz, "%*s", *limit, " ");
+}
+
/* replaces the bar format character sequences (like in tmux(1)) */
char *
bar_replace_seq(char *fmt, char *fmtrep, struct swm_region *r, size_t *offrep,
size_t sz)
{
char *ptr;
/* replaces the bar format character sequences (like in tmux(1)) */
char *
bar_replace_seq(char *fmt, char *fmtrep, struct swm_region *r, size_t *offrep,
size_t sz)
{
char *ptr;
- char num[8], tmp[SWM_BAR_MAX];
- int limit;
- size_t len, numoff = 0;
+ char tmp[SWM_BAR_MAX];
+ int limit, size;
+ size_t len;
/* reset strlcat(3) buffer */
*tmp = '\0';
/* get number, if any */
fmt++;
/* reset strlcat(3) buffer */
*tmp = '\0';
/* get number, if any */
fmt++;
- while (*fmt != '\0' && isdigit((unsigned char) *fmt)) {
- if (numoff >= sizeof num - 1)
- break;
- num[numoff++] = *fmt++;
- }
- num[numoff] = '\0';
-
- if ((limit = strtonum(num, 1, sizeof tmp - 1, NULL)) == 0)
+ size = 0;
+ if (sscanf(fmt, "%d%n", &limit, &size) != 1)
+ limit = sizeof tmp - 1;
+ if (limit <= 0 || limit >= sizeof tmp)
limit = sizeof tmp - 1;
limit = sizeof tmp - 1;
- /* if number is too big, skip to the first non-digit */
- if (numoff >= sizeof num - 1) {
- while (*fmt != '\0' && isdigit((unsigned char) *fmt))
- fmt++;
- }
/* there is nothing to replace (ie EOL) */
/* there is nothing to replace (ie EOL) */
+ fmt += size;
if (*fmt == '\0')
return (fmt);
switch (*fmt) {
case '<':
if (*fmt == '\0')
return (fmt);
switch (*fmt) {
case '<':
- /* special case; no limit given, pad one space, instead */
- if (limit == sizeof tmp - 1)
- limit = 1;
- snprintf(tmp, sizeof tmp, "%*s", limit, " ");
+ bar_replace_pad(tmp, &limit, sizeof tmp);
break;
case 'A':
snprintf(tmp, sizeof tmp, "%s", bar_ext);
break;
case 'A':
snprintf(tmp, sizeof tmp, "%s", bar_ext);
@@
-4957,6
+4955,7
@@
void
setup_spawn(void)
{
setconfspawn("term", "xterm", 0);
setup_spawn(void)
{
setconfspawn("term", "xterm", 0);
+ setconfspawn("spawn_term", "xterm", 0);
setconfspawn("screenshot_all", "screenshot.sh full", 0);
setconfspawn("screenshot_wind", "screenshot.sh window", 0);
setconfspawn("lock", "xlock", 0);
setconfspawn("screenshot_all", "screenshot.sh full", 0);
setconfspawn("screenshot_wind", "screenshot.sh window", 0);
setconfspawn("lock", "xlock", 0);
@@
-5699,6
+5698,7
@@
setconfvalue(char *selector, char *value, int flags)
break;
case SWM_S_SPAWN_TERM:
setconfspawn("term", value, 0);
break;
case SWM_S_SPAWN_TERM:
setconfspawn("term", value, 0);
+ setconfspawn("spawn_term", value, 0);
break;
case SWM_S_SS_APP:
break;
break;
case SWM_S_SS_APP:
break;