summaryrefslogtreecommitdiff
path: root/filter.c
diff options
context:
space:
mode:
authorSergiu Ivanov <unlimitedscolobb@gmail.com>2008-10-31 21:38:54 +0200
committerSergiu Ivanov <unlimitedscolobb@gmail.com>2008-10-31 21:38:54 +0200
commit4e81430d26eef24f5bb8464c8c54a11b042f1842 (patch)
tree96974bf67aef8bab9ad5e1a69cf7fa49d213701c /filter.c
parent2ae0853fb2def22b8554d2bc26db8bcf35413415 (diff)
Made the filter fit for symlink style of functioning.
If the filter is now invoked with no command line arguments, it takes argv[0] as the name of the translator to filter out.
Diffstat (limited to 'filter.c')
-rw-r--r--filter.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/filter.c b/filter.c
index 95a0f65e8..b78c16ba9 100644
--- a/filter.c
+++ b/filter.c
@@ -658,7 +658,28 @@ main
/*Parse the command line arguments*/
argp_parse(&argp_startup, argc, argv, ARGP_IN_ORDER, 0, 0);
if(target_name == NULL)
- ;
+ {
+ char * p = *argv + strlen(*argv);
+
+ /*find where the name of this executable starts (it should match \-.*)*/
+ for(; p >= *argv; --p)
+ if(*p == '/')
+ {
+ if((p > *argv) && (p[-1] == '\\'))
+ continue; /*this is an escaped '/'*/
+ /*we've reached the beginning of the name*/
+ break;
+ }
+
+ if(*p == '/')
+ ++p;
+
+ if(*p == '-') /*actually, any filter translator must have a name starting
+ with '-'*/
+ ++p;
+
+ target_name = p;
+ }
LOG_MSG("Command line arguments parsed. Target name: '%s'.", target_name);
/*Try to create the root node*/