GLOBAL-6.6.3 DOS/Windows patches

Jason Hood <[email protected]> Tue, 18 Dec 2018 22:00:43 +1000
Newsgroups gmane.comp.gnu.global.bugs
Message-ID <[email protected]>
> gtags: New --skip-symlink option.

Made this work with MinGW; ignore it with djgpp.

> gtags-cscope: 'Find assignments to this symbol:' was implemented.

Implemented for DOS & Windows (via sed).  Should it support compound
assignment ('+=' and the like)?

-- 
Jason.

_______________________________________________
Bug-global mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-global
global-6.6.3.txt (text/plain, 2.6 KB)
diff -urp global-6.6.3/gtags-cscope/find.c global-6.6-3/gtags-cscope/find.c
--- global-6.6.3/gtags-cscope/find.c	2018-12-17 12:54:33 +1000
+++ global-6.6-3/gtags-cscope/find.c	2018-12-18 15:57:10 +1000
@@ -247,13 +247,27 @@ findinclude(char *pattern)
 /*
  * [display.c]
  *
- * {"Find", "assignments to this symbol (N/A)",    findassign},
+ * {"Find", "assignments to this symbol",    findassign},
  */
 char *
 findassign(char *pattern)
 {
-	/* Since this function has not yet been implemented, it always returns an error. */
-	return FAILED;
+	int status;
+	STATIC_STRBUF(sb);
+	strbuf_clear(sb);
+
+	strbuf_puts(sb, common());
+	strbuf_sprintf(sb, " -d %s | sed -n /\\b%s\\b\"[ \t]*=[^=]\"/p > %s", quote_shell(pattern), quote_shell(pattern), temp1);
+	status = mysystem("findassign_1", strbuf_value(sb));
+	if (status != 0)
+		return FAILED;
+	strbuf_reset(sb);
+	strbuf_puts(sb, common());
+	strbuf_sprintf(sb, " -rs %s | sed -n /\\b%s\\b\"[ \t]*=[^=]\"/p >> %s", quote_shell(pattern), quote_shell(pattern), temp1);
+	status = mysystem("findassign_2", strbuf_value(sb));
+	if (status != 0)
+		return FAILED;
+	return NULL;
 }
 #else /* UNIX */
 /*
diff -urp global-6.6.3/libutil/find.c global-6.6-3/libutil/find.c
--- global-6.6.3/libutil/find.c	2018-12-17 12:54:34 +1000
+++ global-6.6-3/libutil/find.c	2018-12-18 12:52:01 +1000
@@ -44,6 +44,11 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#undef SLIST_ENTRY
+#endif
 
 #include "gparam.h"
 #include "regex.h"
@@ -615,24 +620,32 @@ getdirs(const char *dir, STRBUF *sb)
 			warning("cannot read '%s'. ignored.", trimpath(dp->d_name));
 			continue;
 		}
+#ifndef __DJGPP__
 		if (skip_symlink > 0) {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+			DWORD attr = GetFileAttributes(makepath(dir, dp->d_name, NULL));
+			if (attr != -1 && (attr & FILE_ATTRIBUTE_REPARSE_POINT))
+#else
 			struct stat st2;
 
 			if (lstat(makepath(dir, dp->d_name, NULL), &st2) < 0) {
 				warning("cannot lstat '%s'. ignored.", trimpath(dp->d_name));
 				continue;
 			}
-			if (S_ISLNK(st2.st_mode)) {
+			if (S_ISLNK(st2.st_mode))
+#endif
+			{
 				if (((skip_symlink & SKIP_SYMLINK_FOR_DIR) && S_ISDIR(st.st_mode)) ||
 				    ((skip_symlink & SKIP_SYMLINK_FOR_FILE) && S_ISREG(st.st_mode)))
 				{
 					if (find_explain)
-						fprintf(stderr, " - Symbolik link '%s' is skipped.\n",
+						fprintf(stderr, " - Symbolic link '%s' is skipped.\n",
 							trimpath(makepath(dir, dp->d_name, NULL)));
 					continue;
 				}
 			}
 		}
+#endif
 		if (S_ISDIR(st.st_mode))
 			strbuf_putc(sb, 'd');
 		else if (S_ISREG(st.st_mode))