aboutsummaryrefslogtreecommitdiffhomepage
path: root/uzbl.c
diff options
context:
space:
mode:
authorGravatar Robert Manea <gotmor@gmail.com>2009-06-17 12:13:03 +0200
committerGravatar Robert Manea <gotmor@gmail.com>2009-06-17 12:13:03 +0200
commit2f190e06ba4f408ac862bff902f169703d38da85 (patch)
treee054ebee5dbe29ab35ece1ce68d73840bb9b7249 /uzbl.c
parent3b12d5330806dce75f0fe69dc8a853607efee360 (diff)
command expansion uses @(command)@ / js expansion @<java script>@
Diffstat (limited to 'uzbl.c')
-rw-r--r--uzbl.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/uzbl.c b/uzbl.c
index 60f06ec..1f2a9e8 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -209,13 +209,14 @@ return EXP_ERR;
}
/* setting 'recurse = 1' will prevent expand() from
- * expanding '@(command)'
+ * expanding '@(command)@' and '@<js>@'
*/
static gchar *
expand(char *s, gboolean recurse) {
uzbl_cmdprop *c;
guint etype;
char upto = ' ';
+ char str_end[2];
char ret[4096];
char *vend;
GError *err = NULL;
@@ -233,28 +234,46 @@ expand(char *s, gboolean recurse) {
case '@':
etype = get_exp_type(s);
+ s++;
switch(etype) {
case EXP_SIMPLE_VAR:
upto = ' ';
+ if( (vend = strchr(s, upto)) ||
+ (vend = strchr(s, '\0')) ) {
+ strncpy(ret, s, vend-s);
+ ret[vend-s] = '\0';
+ }
break;
case EXP_BRACED_VAR:
s++; upto = '}';
+ if( (vend = strchr(s, upto)) ||
+ (vend = strchr(s, '\0')) ) {
+ strncpy(ret, s, vend-s);
+ ret[vend-s] = '\0';
+ }
break;
case EXP_EXPR:
- s++; upto = ')';
+ s++;
+ strcpy(str_end, ")@");
+ str_end[2] = '\0';
+ if( (vend = strstr(s, str_end)) ||
+ (vend = strchr(s, '\0')) ) {
+ strncpy(ret, s, vend-s);
+ ret[vend-s] = '\0';
+ }
break;
case EXP_JS:
- s++; upto = '>';
+ s++;
+ strcpy(str_end, ">@");
+ str_end[2] = '\0';
+ if( (vend = strstr(s, str_end)) ||
+ (vend = strchr(s, '\0')) ) {
+ strncpy(ret, s, vend-s);
+ ret[vend-s] = '\0';
+ }
break;
}
- s++;
-
- if( (vend = strchr(s, upto)) ||
- (vend = strchr(s, '\0')) ) {
- strncpy(ret, s, vend-s);
- ret[vend-s] = '\0';
- }
if(etype == EXP_SIMPLE_VAR ||
etype == EXP_BRACED_VAR) {
@@ -284,7 +303,7 @@ expand(char *s, gboolean recurse) {
g_string_append(buf, cmd_stdout);
g_free(cmd_stdout);
}
- s = vend+1;
+ s = vend+2;
}
else if(!recurse &&
etype == EXP_JS) {
@@ -296,7 +315,7 @@ expand(char *s, gboolean recurse) {
g_string_append(buf, js_ret->str);
g_string_free(js_ret, 1);
}
- s = vend+1;
+ s = vend+2;
}
break;