bug-global
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GLOBAL 5.2 DOS/Win patch


From: Jason Hood
Subject: GLOBAL 5.2 DOS/Win patch
Date: Wed, 16 Aug 2006 15:53:00 +1000 (EST)

I have attached a patch for the djgpp/MinGW versions of GLOBAL 5.2.
This patch does the following:

gozilla.c:
* removes a Win32 redefinition;
* unconsts htmldir in order to change ':' to '|'.

gtags-cscope.c:
* Win32: CMD.EXE doesn't recognise apostrophe as a quote character,
  so I've had to use the normal double quote;
* add backslash to the include header expression;
* restores 'q' to quit.

htags.c:
* copyfile uses O_BINARY to open the files.

general:
* htags.c, getdbpath.c: "becase" should be "because";
* snprintf.c: use done instead of strlen;
              "shoule" -> "should";
* strlimcpy.h: add prototype for snprintf (still misses a couple, though).

BTW, I also noticed the htags datadir info description had "templete",
which should be "template".

Jason.
-- 


                
____________________________________________________ 
On Yahoo!7 
360°: Your own space to share what you want with who you want! 
http://www.yahoo7.com.au/360
diff -ur global-5.2.orig/gozilla/gozilla.c global-5.2/gozilla/gozilla.c
--- global-5.2.orig/gozilla/gozilla.c   2006-08-08 23:39:56 +1000
+++ global-5.2/gozilla/gozilla.c        2006-08-09 22:26:14 +1000
@@ -28,6 +28,9 @@
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <shellapi.h>
+#ifdef SLIST_ENTRY
+#undef SLIST_ENTRY
+#endif
 #endif
 
 #include "global.h"
@@ -353,8 +356,10 @@
         * c:/dir/a.html => file://c|/dir/a.html
         */
 #if _WIN32 || __DJGPP__
-       if (htmldir[1] == ':')
-               htmldir[1] = '|';
+       if (htmldir[1] == ':') {
+               char* h = (char*)htmldir;
+               h[1] = '|';
+       }
 #endif
        strbuf_sprintf(URL, "file://%s/%s", htmldir, ptable.part[1].start);
        recover(&ptable);
diff -ur global-5.2.orig/gtags-cscope/gtags-cscope.c 
global-5.2/gtags-cscope/gtags-cscope.c
--- global-5.2.orig/gtags-cscope/gtags-cscope.c 2006-08-08 23:39:56 +1000
+++ global-5.2/gtags-cscope/gtags-cscope.c      2006-08-10 11:39:26 +1000
@@ -44,6 +44,20 @@
 #include "global.h"
 #include "const.h"
 
+#ifdef _WIN32
+#define QUOTE '"'
+#else
+#define QUOTE '\''
+#endif
+
+#if defined(_WIN32)
+#define INCLUDE "^[ \t]*#[ \t]*include[ \t].*[\\\"\"</\\]%s[\\\"\">]"
+#elif defined(__DJGPP__)
+#define INCLUDE "^[ \t]*#[ \t]*include[ \t].*[\"</\\]%s[\">]"
+#else
+#define INCLUDE "^[ \t]*#[ \t]*include[ \t].*[\"</]%s[\">]"
+#endif
+
 /* static void usage(void); */
 static void help(void);
 static void check_dbpath(void);
@@ -221,6 +235,8 @@
                        ignore_case ^= 1;
                        print_case_distinction();
                        break;
+               case 'q':               /* q: quit */
+                       return;
                case 'r':               /* r: update tag file */
                        update();
                        break;
@@ -276,9 +292,9 @@
                        strbuf_putc(command, 'i');
        }
        strbuf_putc(command, ' ');
-       strbuf_putc(command, '\'');
+       strbuf_putc(command, QUOTE);
        strbuf_puts(command, arg);
-       strbuf_putc(command, '\'');
+       strbuf_putc(command, QUOTE);
        if (!(ip = popen(strbuf_value(command), "r")))
                die("cannot execute '%s'.", strbuf_value(command));
        if (vflag)
@@ -370,7 +386,7 @@
                break;
        case '8':               /* Find files #including this file */
                opt = 'g';
-               snprintf(buf, sizeof(buf), "^[ \t]*#[ \t]*include[ 
\t].*[\"</]%s[\">]", quote_string(arg));
+               snprintf(buf, sizeof(buf), INCLUDE, quote_string(arg));
                arg = buf;
                break;
        }
diff -ur global-5.2.orig/htags/htags.c global-5.2/htags/htags.c
--- global-5.2.orig/htags/htags.c       2006-08-08 23:39:54 +1000
+++ global-5.2/htags/htags.c    2006-08-10 11:23:52 +1000
@@ -832,10 +832,13 @@
        int ip, op, size;
        char buf[8192];
 
-       ip = open(from, O_RDONLY);
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+       ip = open(from, O_RDONLY|O_BINARY);
        if (ip < 0)
                die("cannot open input file '%s'.", from);
-       op = open(to, O_WRONLY|O_CREAT|O_TRUNC, 0775);
+       op = open(to, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0775);
        if (op < 0)
                die("cannot create output file '%s'.", to);
        while ((size = read(ip, buf, sizeof(buf))) != 0) {
@@ -1045,19 +1048,19 @@
        strlimcpy(datadir, strbuf_value(sb), sizeof(datadir));
        if (getconfn("ncol", &n)) {
                if (n < 1 || n > 10)
-                       warning("parameter 'ncol' ignored becase the value 
(=%d) is too large or too small.", n);
+                       warning("parameter 'ncol' ignored because the value 
(=%d) is too large or too small.", n);
                else
                        ncol = n;
        }
        if (getconfn("tabs", &n)) {
                if (n < 1 || n > 32)
-                       warning("parameter 'tabs' ignored becase the value 
(=%d) is too large or too small.", n);
+                       warning("parameter 'tabs' ignored because the value 
(=%d) is too large or too small.", n);
                else
                        tabs = n;
        }
        if (getconfn("flist_fields", &n)) {
                if (n < 1)
-                       warning("parameter 'flist_fields' ignored becase the 
value (=%d) is too large or too small.", n);
+                       warning("parameter 'flist_fields' ignored because the 
value (=%d) is too large or too small.", n);
                else
                        flist_fields = n;
        }
diff -ur global-5.2.orig/libglibc/snprintf.c global-5.2/libglibc/snprintf.c
--- global-5.2.orig/libglibc/snprintf.c 2006-08-08 23:39:54 +1000
+++ global-5.2/libglibc/snprintf.c      2006-08-10 12:37:14 +1000
@@ -43,9 +43,9 @@
   va_start (arg, format);
 /*  done = __vsnprintf (s, maxlen, format, arg); */
   done = vsprintf (s, format, arg);
-  if (strlen(s) >= maxlen) {
+  if (done >= maxlen) {
     fprintf(stderr, "This program exit because vsprintf(3) destroy memory.\n");
-    fprintf(stderr, "You shoule install snprintf(3) instead.\n");
+    fprintf(stderr, "You should install snprintf(3) instead.\n");
     exit(1);
   }
   va_end (arg);
diff -ur global-5.2.orig/libutil/getdbpath.c global-5.2/libutil/getdbpath.c
--- global-5.2.orig/libutil/getdbpath.c 2006-08-08 23:39:56 +1000
+++ global-5.2/libutil/getdbpath.c      2006-08-10 11:17:48 +1000
@@ -183,7 +183,7 @@
                }
        } else {
                if (verbose && getenv("GTAGSDBPATH"))
-                       fprintf(stderr, "warning: GTAGSDBPATH is ignored becase 
GTAGSROOT is not set.\n");
+                       fprintf(stderr, "warning: GTAGSDBPATH is ignored 
because GTAGSROOT is not set.\n");
                /*
                 * start from current directory to '/' directory.
                 */
diff -ur global-5.2.orig/libutil/strlimcpy.h global-5.2/libutil/strlimcpy.h
--- global-5.2.orig/libutil/strlimcpy.h 2006-08-08 23:39:56 +1000
+++ global-5.2/libutil/strlimcpy.h      2006-08-10 11:53:20 +1000
@@ -23,4 +23,9 @@
 
 void strlimcpy(char *, const char *, const int);
 
+#ifndef HAVE_SNPRINTF
+#include <stdlib.h>
+int snprintf(char*, size_t, const char*, ...);
+#endif
+
 #endif /* ! _STRLIMCPY_H_ */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]