Re: symbolic links, unreadable files, skip

Jason Hood <[email protected]>
Newsgroups gmane.comp.gnu.global.bugs
Message-ID <[email protected]>
On 27/08/2015 21:33, Shigio YAMAGUCHI wrote:

> Isn't there a way to decide whether it is a dead link?

Sure, test if fopen fails. :)

> It is not opentoken() but parsers that call die().

Yeah, that's what I meant.

> It might be difficult to force plug-in parsers not to die.

Plug-in parsers can do what they want, that's not the issue.

You ignore files when stat fails, why not ignore files when
fopen fails?  That's what the attached patch does.  Oh, I
was also able to successfully use skip on the broken link,
so I don't know what went wrong there.

-- 
Jason.

_______________________________________________
Bug-global mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-global
open.txt (text/plain, 2.8 KB)
diff -urp global-6.5/libparser/asm_parse.y global-6-5/libparser/asm_parse.y
--- global-6.5/libparser/asm_parse.y	2015-06-10 11:45:09 +1000
+++ global-6-5/libparser/asm_parse.y	2015-06-10 11:45:09 +1000
@@ -147,8 +147,10 @@ line:	ASM_ENTRY '(' ASM_SYMBOL ')' error
 void
 assembly(const struct parser_param *param)
 {
-	if (linetable_open(param->file) == -1)
-		die("'%s' cannot open.", param->file);
+	if (linetable_open(param->file) == -1) {
+		warning("cannot open '%s'. ignored.", param->file);
+		return;
+	}
 
 	asm_symtable = strbuf_open(0);
 	asm_initscan();
diff -urp global-6.5/libparser/C.c global-6-5/libparser/C.c
--- global-6.5/libparser/C.c	2015-06-10 11:45:09 +1000
+++ global-6-5/libparser/C.c	2015-08-27 22:09:28 +1000
@@ -110,8 +110,10 @@ C_family(const struct parser_param *para
 	savelevel = -1;
 	startmacro = startsharp = 0;
 
-	if (!opentoken(param->file))
-		die("'%s' cannot open.", param->file);
+	if (!opentoken(param->file)) {
+		warning("cannot open '%s'. ignored.", param->file);
+		return;
+	}
 	cmode = 1;			/* allow token like '#xxx' */
 	crflag = 1;			/* require '\n' as a token */
 	if (type == TYPE_YACC)
diff -urp global-6.5/libparser/Cpp.c global-6-5/libparser/Cpp.c
--- global-6.5/libparser/Cpp.c	2015-06-10 11:45:09 +1000
+++ global-6-5/libparser/Cpp.c	2015-08-27 22:09:27 +1000
@@ -90,8 +90,10 @@ Cpp(const struct parser_param *param)
 	savelevel = -1;
 	startclass = startthrow = startmacro = startsharp = startequal = 0;
 
-	if (!opentoken(param->file))
-		die("'%s' cannot open.", param->file);
+	if (!opentoken(param->file)) {
+		warning("cannot open '%s'. ignored.", param->file);
+		return;
+	}
 	cmode = 1;			/* allow token like '#xxx' */
 	crflag = 1;			/* require '\n' as a token */
 	cppmode = 1;			/* treat '::' as a token */
diff -urp global-6.5/libparser/java.c global-6-5/libparser/java.c
--- global-6.5/libparser/java.c	2015-06-10 11:45:09 +1000
+++ global-6-5/libparser/java.c	2015-08-27 22:09:29 +1000
@@ -62,8 +62,10 @@ java(const struct parser_param *param)
 	level = classlevel = 0;
 	startclass = startthrows = startequal = 0;
 
-	if (!opentoken(param->file))
-		die("'%s' cannot open.", param->file);
+	if (!opentoken(param->file)) {
+		warning("cannot open '%s'. ignored.", param->file);
+		return;
+	}
 	while ((c = nexttoken(interested, java_reserved_word)) != EOF) {
 		switch (c) {
 		case SYMBOL:					/* symbol */
diff -urp global-6.5/libparser/php.l global-6-5/libparser/php.l
--- global-6.5/libparser/php.l	2015-06-10 11:45:09 +1000
+++ global-6-5/libparser/php.l	2015-06-10 11:45:09 +1000
@@ -285,8 +285,10 @@ php(const struct parser_param *param)
 
 	level = 0;
 	string = strbuf_open(0);
-	if (linetable_open(param->file) == -1)
-		die("'%s' cannot open.", param->file);
+	if (linetable_open(param->file) == -1) {
+		warning("cannot open '%s'. ignored.", param->file);
+		return;
+	}
 
 	LEXRESTART(NULL);
 	LEXLINENO = 1;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.