[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Global-commit] global Makefile.am configure.ac reconf.sh gtags...
From: |
Shigio YAMAGUCHI |
Subject: |
[Global-commit] global Makefile.am configure.ac reconf.sh gtags... |
Date: |
Thu, 08 Jun 2006 00:28:22 +0000 |
CVSROOT: /sources/global
Module name: global
Changes by: Shigio YAMAGUCHI <shigio> 06/06/08 00:28:22
Modified files:
. : Makefile.am configure.ac reconf.sh
Added files:
gtags-cscope : .cvsignore Makefile.am gtags-cscope.c manual.in
Log message:
Added gtags-cscope.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/global/Makefile.am?cvsroot=global&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/global/configure.ac?cvsroot=global&r1=1.66&r2=1.67
http://cvs.savannah.gnu.org/viewcvs/global/reconf.sh?cvsroot=global&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/global/gtags-cscope/.cvsignore?cvsroot=global&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/global/gtags-cscope/Makefile.am?cvsroot=global&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/global/gtags-cscope/gtags-cscope.c?cvsroot=global&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/global/gtags-cscope/manual.in?cvsroot=global&rev=1.1
Patches:
Index: Makefile.am
===================================================================
RCS file: /sources/global/global/Makefile.am,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- Makefile.am 27 Jan 2006 23:42:30 -0000 1.29
+++ Makefile.am 8 Jun 2006 00:28:22 -0000 1.30
@@ -14,7 +14,7 @@
if !USE_DB185_COMPAT
SUBDIRS += libdb
endif
-SUBDIRS += gtags-parser global gozilla gtags htags doc
+SUBDIRS += gtags-parser global gozilla gtags htags gtags-cscope doc
EXTRA_DIST = FAQ LICENSE \
gtags.conf gtags.el nvi-1.79-gtags.diff reconf.sh globash.rc \
Index: configure.ac
===================================================================
RCS file: /sources/global/global/configure.ac,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- configure.ac 21 Apr 2006 02:36:11 -0000 1.66
+++ configure.ac 8 Jun 2006 00:28:22 -0000 1.67
@@ -190,6 +190,7 @@
libdb/Makefile
global/Makefile
gozilla/Makefile
+ gtags-cscope/Makefile
libglibc/Makefile
doc/Makefile
])
Index: reconf.sh
===================================================================
RCS file: /sources/global/global/reconf.sh,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- reconf.sh 4 Jun 2006 00:49:08 -0000 1.33
+++ reconf.sh 8 Jun 2006 00:28:22 -0000 1.34
@@ -87,7 +87,7 @@
)
echo "- Collecting reference manuals ..."
-commands="global gtags htags gtags-parser gozilla";
+commands="global gtags htags gtags-parser gozilla gtags-cscope";
perl ./convert.pl --menu $commands > doc/reference.texi
for d in `echo $commands`; do
perl ./convert.pl --info $d/manual.in > doc/$d.ref
Index: gtags-cscope/.cvsignore
===================================================================
RCS file: gtags-cscope/.cvsignore
diff -N gtags-cscope/.cvsignore
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gtags-cscope/.cvsignore 8 Jun 2006 00:28:22 -0000 1.1
@@ -0,0 +1,6 @@
+.deps
+Makefile
+Makefile.in
+const.h
+gtags-cscope
+gtags-cscope.1
Index: gtags-cscope/Makefile.am
===================================================================
RCS file: gtags-cscope/Makefile.am
diff -N gtags-cscope/Makefile.am
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gtags-cscope/Makefile.am 8 Jun 2006 00:28:22 -0000 1.1
@@ -0,0 +1,23 @@
+## Process this file with automake to create Makefile.in
+#
+# Copyright (c) 2006 Tama Communications Corporation
+#
+# This file is free software; as a special exception the author gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+bin_PROGRAMS= gtags-cscope
+
+INCLUDES = @INCLUDES@
+
+LDADD = @LDADD@
+
+gtags_cscope_DEPENDENCIES = $(LDADD)
+
+man_MANS = gtags-cscope.1
+
+EXTRA_DIST = $(man_MANS) const.h manual.in
Index: gtags-cscope/gtags-cscope.c
===================================================================
RCS file: gtags-cscope/gtags-cscope.c
diff -N gtags-cscope/gtags-cscope.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gtags-cscope/gtags-cscope.c 8 Jun 2006 00:28:22 -0000 1.1
@@ -0,0 +1,419 @@
+/*
+ * Copyright (c) 2006
+ * Tama Communications Corporation
+ *
+ * This file is part of GNU GLOBAL.
+ *
+ * GNU GLOBAL is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * GNU GLOBAL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#include <strings.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include "getopt.h"
+
+#include "global.h"
+#include "const.h"
+
+static void usage(void);
+static void help(void);
+static void check_dbpath(void);
+static void get_global_path(void);
+int main(int, char **);
+static char *getline(void);
+static void update(void);
+static void command_help(void);
+static void command_loop(void);
+static int execute_command(STRBUF *, const int, const int, const char *);
+static void search(int, const char *);
+
+int show_version;
+int show_help;
+int vflag;
+int qflag;
+
+#define NA -1
+
+static void
+usage(void)
+{
+ if (!qflag)
+ fputs(usage_const, stderr);
+ exit(2);
+}
+static void
+help(void)
+{
+ fputs(usage_const, stdout);
+ fputs(help_const, stdout);
+ exit(0);
+}
+
+static struct option const long_options[] = {
+ {"ignore-case", no_argument, NULL, 'C'},
+ {"quiet", no_argument, NULL, 'q'},
+ {"verbose", no_argument, NULL, 'v'},
+ {"version", no_argument, &show_version, 1},
+ {"help", no_argument, &show_help, 1},
+ { 0 }
+};
+
+char global_path[MAXFILLEN];
+
+int ignore_case;
+
+void
+check_dbpath()
+{
+ char cwd[MAXPATHLEN+1];
+ char root[MAXPATHLEN+1];
+ char dbpath[MAXPATHLEN+1];
+
+ getdbpath(cwd, root, dbpath, vflag);
+}
+void
+get_global_path()
+{
+ char command[MAXFILLEN];
+ const char *p;
+
+ if (!(p = usable("global")))
+ die("global command required but not found.");
+ strlimcpy(global_path, p, sizeof(global_path));
+}
+
+int
+main(int argc, char **argv)
+{
+ const char *av = NULL;
+ int optchar;
+ int option_index = 0;
+
+ while ((optchar = getopt_long(argc, argv, "Cqv", long_options,
&option_index)) != EOF) {
+ switch (optchar) {
+ case 0:
+ break;
+ case 'C':
+ ignore_case = 1;
+ break;
+ case 'q':
+ qflag++;
+ break;
+ case 'v':
+ vflag++;
+ break;
+ default:
+ usage();
+ break;
+ }
+ }
+ if (qflag)
+ vflag = 0;
+ if (show_help)
+ help();
+ argc -= optind;
+ argv += optind;
+ if (!av)
+ av = (argc > 0) ? *argv : NULL;
+ if (show_version)
+ version(av, vflag);
+ /*
+ * Get global(1)'s path. If not found, abort with a message.
+ */
+ get_global_path();
+ /*
+ * Check dbpath. If dbpath not found, abort with a message.
+ */
+ check_dbpath();
+ /*
+ * Command loop
+ */
+ command_loop();
+ return 0;
+}
+char *
+getline()
+{
+ STATIC_STRBUF(sb);
+ char *p;
+
+ /* Prompt */
+ fputs(">> ", stdout);
+ fflush(stdout);
+ if (strbuf_fgets(sb, stdin, STRBUF_NOCRLF) == NULL)
+ return NULL;
+ return strbuf_value(sb);
+}
+void
+update()
+{
+ STATIC_STRBUF(command);
+
+ strbuf_clear(command);
+ strbuf_sprintf(command, "%s -u", global_path);
+ if (vflag) {
+ strbuf_putc(command, 'v');
+ fprintf(stderr, "gscope: %s\n", strbuf_value(command));
+ }
+ system(strbuf_value(command));
+}
+void
+print_case_distinction()
+{
+ if (vflag) {
+ const char *msg = ignore_case ?
+ "ignore letter case when searching" :
+ "use letter case when searching";
+ fprintf(stderr, "gscope: %s\n", msg);
+ }
+}
+static void
+command_help()
+{
+ fprintf(stdout, "0<arg>: Find this C symbol\n");
+ fprintf(stdout, "1<arg>: Find this definition\n");
+ fprintf(stdout, "2<arg>: Find functions called by this function\n");
+ fprintf(stdout, " (Not implemented yet.)\n");
+ fprintf(stdout, "3<arg>: Find functions calling this function\n");
+ fprintf(stdout, "4<arg>: Find this text string\n");
+ fprintf(stdout, "6<arg>: Find this egrep pattern\n");
+ fprintf(stdout, "7<arg>: Find this file\n");
+ fprintf(stdout, "8<arg>: Find files #including this file\n");
+ fprintf(stdout, "c: Toggle ignore/use letter case\n");
+ fprintf(stdout, "r: Rebuild the database\n");
+ fprintf(stdout, "q: Quit the session\n");
+ fprintf(stdout, "h: Show help\n");
+}
+FILE *log;
+void
+command_loop()
+{
+ int com = 0;
+ char *line, *opt = "";
+
+ print_case_distinction();
+ while ((line = getline()) != NULL) {
+ switch (com = *line++) {
+ /*
+ * Control command
+ */
+ case 'c': /* c: ignore case or not */
+ ignore_case ^= 1;
+ print_case_distinction();
+ break;
+ case 'q': /* q: quit */
+ return;
+ case 'r': /* r: update tag file */
+ update();
+ break;
+ case 'h': /* h: show help */
+ command_help();
+ break;
+ /*
+ * Search command
+ */
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '6':
+ case '7':
+ case '8':
+ search(com, line);
+ break;
+ default:
+ fputs("cscope: 0 lines\n", stdout);
+ fflush(stdout);
+ break;
+ }
+ }
+}
+/*
+ * Execute global(1) and write the output to the 'sb' string buffer.
+ *
+ * o) sb output
+ * i) com cscope command (0-8)
+ * i) opt option for global(1)
+ * i) arg argument for global(1)
+ * r) number of output
+ */
+static int
+execute_command(STRBUF *sb, const int com, const int opt, const char *arg)
+{
+ STATIC_STRBUF(command);
+ STATIC_STRBUF(ib);
+ FILE *ip;
+ int count = 0;
+
+ strbuf_clear(command);
+ strbuf_puts(command, global_path);
+ strbuf_puts(command, " --result=cscope");
+ if (opt || ignore_case) {
+ strbuf_putc(command, ' ');
+ strbuf_putc(command, '-');
+ if (opt)
+ strbuf_putc(command, opt);
+ if (ignore_case)
+ strbuf_putc(command, 'i');
+ }
+ strbuf_putc(command, ' ');
+ strbuf_putc(command, '\'');
+ strbuf_puts(command, arg);
+ strbuf_putc(command, '\'');
+ if (!(ip = popen(strbuf_value(command), "r")))
+ die("cannot execute '%s'.", strbuf_value(command));
+ if (vflag)
+ fprintf(stderr, "gscope: %s\n", strbuf_value(command));
+ /*
+ * Copy records with little modification.
+ */
+ strbuf_clear(ib);
+ while (strbuf_fgets(ib, ip, 0)) {
+ count++;
+ if (opt == 0) {
+ strbuf_puts(sb, strbuf_value(ib));
+ } else {
+ char *p = strbuf_value(ib);
+
+ /* path name */
+ while (*p && *p != ' ')
+ strbuf_putc(sb, *p++);
+ if (*p != ' ')
+ die("illegal cscope format. (%s)",
strbuf_value(ib));
+ strbuf_putc(sb, *p++);
+
+ /* replace pattern with "<unknown>" or "<global>" */
+ while (*p && *p != ' ')
+ p++;
+ if (*p != ' ')
+ die("illegal cscope format. (%s)",
strbuf_value(ib));
+ if (com == '8')
+ strbuf_puts(sb, "<global>");
+ else
+ strbuf_puts(sb, "<unknown>");
+ strbuf_putc(sb, *p++);
+
+ /* line number */
+ while (*p && *p != ' ')
+ strbuf_putc(sb, *p++);
+ if (*p != ' ')
+ die("illegal cscope format. (%s)",
strbuf_value(ib));
+ strbuf_putc(sb, *p++);
+
+ /* line image */
+ if (*p == '\n')
+ strbuf_puts(sb, "<unknown>\n");
+ else
+ strbuf_puts(sb, p);
+ }
+ }
+ if (pclose(ip) < 0)
+ die("terminated abnormally.");
+ return count;
+}
+static void
+search(int com, const char *arg)
+{
+ static STRBUF *sb;
+ char buf[1024];
+ int count = 0, opt = 0;
+
+ if (sb == NULL)
+ sb = strbuf_open(1024 * 1024);
+ else
+ strbuf_reset(sb);
+ /*
+ * Convert from cscope command to global command.
+ */
+ switch (com) {
+ case '0': /* Find this C symbol */
+ case '1': /* Find this definition */
+ break;
+ case '2': /* Find functions called by this function */
+ opt = NA;
+ break;
+ case '3': /* Find functions calling this function */
+ opt = 'r';
+ break;
+ case '4': /* Find this text string */
+ opt = 'g';
+ strlimcpy(buf, quote_string(arg), sizeof(buf));
+ arg = buf;
+ break;
+ case '5': /* Change this text string */
+ opt = NA;
+ break;
+ case '6': /* Find this egrep pattern */
+ opt = 'g';
+ break;
+ case '7': /* Find this file */
+ opt = 'P';
+ break;
+ case '8': /* Find files #including this file */
+ opt = 'g';
+ snprintf(buf, sizeof(buf), "^[ \t]*#[ \t]*include[
\t].*[\"</]%s[\">]", quote_string(arg));
+ arg = buf;
+ break;
+ }
+ /*
+ * Execute global(1).
+ */
+ if (opt == NA) {
+ fprintf(stdout, "cscope: 0 lines\n");
+ return;
+ }
+ if (com == '0') {
+ count += execute_command(sb, com, 0, arg);
+ count += execute_command(sb, com, (count > 0) ? 'r' : 's', arg);
+ } else {
+ count += execute_command(sb, com, opt, arg);
+ }
+ /*
+ * Output format:
+ * cscope: <n> lines
+ * ****************** ... 1
+ * ****************** ... 2
+ * ...
+ * ****************** ... n
+ *
+ * Example:
+ * cscope: 3 lines
+ * global/global.c main 158 main(int argc, char **argv)
+ * gozilla/gozilla.c main 155 main(int argc, char **argv)
+ * gscope/gscope.c main 108 main(int argc, char **argv)
+ */
+ fprintf(stdout, "cscope: %d lines\n", count);
+ if (count > 0)
+ fwrite(strbuf_value(sb), 1, strbuf_getlen(sb), stdout);
+ fflush(stdout);
+}
Index: gtags-cscope/manual.in
===================================================================
RCS file: gtags-cscope/manual.in
diff -N gtags-cscope/manual.in
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gtags-cscope/manual.in 8 Jun 2006 00:28:22 -0000 1.1
@@ -0,0 +1,95 @@
+#
+# Copyright (c) 2006
+# Tama Communications Corporation
+#
+# This file is part of GNU GLOBAL.
+#
+# GNU GLOBAL is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU GLOBAL is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# This file is converted to the following files:
+# o command source file(for usage and help).
+# o man format reference manual.
+# o texinfo format reference manual.
+#
address@hidden GTAGS-CSCOPE,1,May 2006,GNU Project
address@hidden gtags-cscope - pseudo cscope which implements the line-oriented
interface
address@hidden
+ @name{gtags-cscope} [-Cqv]
address@hidden
+ @name{Gtags-cscope} is a pseudo cscope which implements the
+ line-oriented interface.
+ You can use this command for various clients instead of true cscope.
+
+ Since @name{gtags-cscope} is intended to make GLOBAL available
+ through cscope interface, the output is not necessarily the same
+ as cscope.
address@hidden
+ The following options are available:
+ @begin_itemize
+ @address@hidden, @option{--ignore-case}}
+ Ignore letter case when searching.
+ @address@hidden, @option{--quiet}}
+ Quiet mode.
+ @address@hidden, @option{--verbose}}
+ Verbose mode.
+ @end_itemize
address@hidden
+ $ gtags-cscope
+ >> help
+ 0<arg>: Find this C symbol
+ 1<arg>: Find this definition
+ 2<arg>: Find functions called by this function
+ (Not implemented yet.)
+ 3<arg>: Find functions calling this function
+ 4<arg>: Find this text string
+ 6<arg>: Find this egrep pattern
+ 7<arg>: Find this file
+ 8<arg>: Find files #including this file
+ c: Toggle ignore/use letter case
+ r: Rebuild the database
+ q: Quit the session
+ h: Show help
+ >> 1main
+ cscope: 9 lines
+ global/global.c main 158 main(int argc, char **argv)
+ gozilla/gozilla.c main 155 main(int argc, char **argv)
+ gtags-parser/gctags.c main 158 main(int argc, char **argv)
+ gtags-cscope/gtags-cscope.c main 115 main(int argc, char **argv)
+ gtags/gtags.c main 150 main(int argc, char **argv)
+ htags-refkit/htags_path2url.c main 281 main(int argc, char **argv)
+ htags/htags.c main 1400 main(int argc, char **argv)
+ libglibc/getopt.c main 704 main (argc, argv)
+ libglibc/getopt1.c main 93 main (argc, argv)
+ >> q
+ $ _
address@hidden
+ @name{Gtags-cscope} exits with a non 0 value if an error occurred, 0
otherwise.
address@hidden ALSO
+ @xref{cscope,1},
+ @xref{gtags-parser,1},
+ @xref{gtags,1},
+ @xref{global,1},
+ @xref{htags,1}.
+
+ GNU GLOBAL source code tag address@hidden
+ (http://www.gnu.org/software/global/).
address@hidden
+ The second field of the output is almost <unknown> since
+ GLOBAL doesn't recognize it.
+ Command 2 (Find functions called by this function) is not implemented.
address@hidden
+ Tama Communications Corporation.
address@hidden
+ The @name{gtags-cscope} command appeared in 2006.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Global-commit] global Makefile.am configure.ac reconf.sh gtags...,
Shigio YAMAGUCHI <=