[Pkg-mozext-commits] [adblock-plus] 39/464: add --arg command

David Prévot taffit at moszumanska.debian.org
Tue Jul 22 20:44:00 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus.

commit b919f6f664249715c170297fc82c32c7152b2de3
Author: Andrew Sutherland <asutherland at asutherland.org>
Date:   Mon Jun 22 02:23:17 2009 -0700

    add --arg command
    
    --HG--
    extra : transplant_source : %DD%BE%A5%7BL%01K%16%C3%AD%3Az%27%40S%801%60%B5%EA
---
 jshydra.cpp | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/jshydra.cpp b/jshydra.cpp
index 895e838..f0f235d 100644
--- a/jshydra.cpp
+++ b/jshydra.cpp
@@ -232,7 +232,7 @@ JSObject *makeNode(JSParseNode *node) {
 	return object;
 }
 
-void parseFile(FILE *file, char *filename) {
+void parseFile(FILE *file, char *filename, char *argstr) {
 	JSCompiler compiler(cx, NULL, NULL);
 	if (!compiler.init(NULL, 0, file, filename, 1))
 		return;
@@ -244,11 +244,13 @@ void parseFile(FILE *file, char *filename) {
 		fprintf(stderr, "No function process_js!\n");
 		return;
 	}
-	jsval rval, argv[2];
+	jsval rval, argv[3];
 	argv[0] = OBJECT_TO_JSVAL(ast);
 	JSString *newfname = JS_NewStringCopyZ(cx, filename);
 	argv[1] = STRING_TO_JSVAL(newfname);
-	JS_CallFunctionValue(cx, globalObj, func, 2, argv, &rval);
+	JSString *jsArgStr = JS_NewStringCopyZ(cx, argstr);
+	argv[2] = STRING_TO_JSVAL(jsArgStr);
+	JS_CallFunctionValue(cx, globalObj, func, 3, argv, &rval);
 }
 
 int main(int argc, char **argv) {
@@ -260,15 +262,22 @@ int main(int argc, char **argv) {
 	jshydra_includeScript(cx, argv[1]);
 	argc--;
 	argv++;
+	char *argstr = NULL;
 	do {
 		argc--;
 		argv++;
+		if (!strcmp(argv[0], "--arg")) {
+			argc--;
+			argv++;
+			argstr = argv[0];
+			continue;
+		}
 		FILE *input = fopen(argv[0], "r");
 		if (!input) {
 			fprintf(stderr, "No such file %s\n", argv[0]);
 			continue;
 		}
-		parseFile(input, argv[0]);
+		parseFile(input, argv[0], argstr);
 	} while (argc > 1);
 
 	return 0;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git



More information about the Pkg-mozext-commits mailing list