Index: global/global.c
===================================================================
RCS file: /sources/global/global/global/global.c,v
retrieving revision 1.200
diff -u -p -r1.200 global.c
--- global/global.c	12 Nov 2009 12:36:43 -0000	1.200
+++ global/global.c	20 Nov 2009 15:09:11 -0000
@@ -87,6 +87,7 @@ int nosource;				/* undocumented command
 int debug;
 int format;
 int type;				/* path conversion type */
+int two_pass_mode;
 char cwd[MAXPATHLEN+1];			/* current directory	*/
 char root[MAXPATHLEN+1];		/* root of source tree	*/
 char dbpath[MAXPATHLEN+1];		/* dbpath directory	*/
@@ -359,10 +360,12 @@ main(int argc, char **argv)
 
 	if (show_version)
 		version(av, vflag);
+	if (getconfb("use_2pass_parser"))
+		two_pass_mode = 1;
 	/*
 	 * invalid options.
 	 */
-	if (sflag && rflag)
+	if (sflag && rflag && !(fflag && two_pass_mode))
 		die_with_code(2, "both of -s and -r are not allowed.");
 	/*
 	 * only -c, -u, -P and -p allows no argument.
@@ -864,6 +867,8 @@ pathlist(const char *pattern, const char
  *	i)	dbpath	dbpath
  *	i)	db	type of parse
  */
+#define FLAG_DEFINED	1
+#define FLAG_UNDEFINED	2
 void
 parsefile(int argc, char *const *argv, const char *cwd, const char *root, const char *dbpath, int db)
 {
@@ -874,15 +879,17 @@ parsefile(int argc, char *const *argv, c
 	STRBUF *path_list = strbuf_open(MAXPATHLEN);
 	XARGS *xp;
 	char *ctags_x;
-	int skip_defined = 0, skip_undefined = 0;
+	int skipflags = 0;
 
-	if (getconfb("use_2pass_parser")) {
+	if (two_pass_mode) {
 		if (db == GRTAGS) {
-			skip_undefined = 1;
+			skipflags = FLAG_UNDEFINED;
 		} else if (db == GSYMS) {
-			skip_defined = 1;
+			skipflags = FLAG_DEFINED;
 			db = GRTAGS;
 		}
+		if (context_file == NULL && rflag && sflag)
+			skipflags = 0;
 	}
 	/*
 	 * teach parser where is dbpath.
@@ -959,8 +966,9 @@ parsefile(int argc, char *const *argv, c
 					recover(&ptable);
 					die("too small number of parts.\n'%s'", ctags_x);
 				}
-				if (skip_defined || skip_undefined) {
-					if (defined(ptable.part[PART_TAG].start) ? skip_defined : skip_undefined)
+				if (skipflags) {
+					if ((defined(ptable.part[PART_TAG].start)
+						? FLAG_DEFINED : FLAG_UNDEFINED) & skipflags)
 						continue;
 				}
 				if (strcmp(curpath, ptable.part[PART_PATH].start)) {
@@ -971,14 +979,15 @@ parsefile(int argc, char *const *argv, c
 			}
 		} else {
 			while ((ctags_x = xargs_read(xp)) != NULL) {
-				if (skip_defined || skip_undefined) {
+				if (skipflags) {
 					SPLIT ptable;
 
 					if (split((char *)ctags_x, 4, &ptable) < 4) {
 						recover(&ptable);
 						die("too small number of parts.\n'%s'", ctags_x);
 					}
-					if (defined(ptable.part[PART_TAG].start) ? skip_defined : skip_undefined)
+					if ((defined(ptable.part[PART_TAG].start)
+						? FLAG_DEFINED : FLAG_UNDEFINED) & skipflags)
 						continue;
 					recover(&ptable);
 				}
