ctags.rb 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -0
- data/Rakefile +23 -0
- data/ctags.rb.gemspec +23 -0
- data/ext/.gitignore +3 -0
- data/ext/extconf.rb +15 -0
- data/ext/vendor/exuberant-ctags/.gitignore +6 -0
- data/ext/vendor/exuberant-ctags/.indent.pro +31 -0
- data/ext/vendor/exuberant-ctags/COPYING +340 -0
- data/ext/vendor/exuberant-ctags/EXTENDING.html +386 -0
- data/ext/vendor/exuberant-ctags/FAQ +371 -0
- data/ext/vendor/exuberant-ctags/INSTALL +215 -0
- data/ext/vendor/exuberant-ctags/INSTALL.oth +73 -0
- data/ext/vendor/exuberant-ctags/MAINTAINERS +88 -0
- data/ext/vendor/exuberant-ctags/Makefile.in +222 -0
- data/ext/vendor/exuberant-ctags/NEWS +871 -0
- data/ext/vendor/exuberant-ctags/README +73 -0
- data/ext/vendor/exuberant-ctags/ant.c +42 -0
- data/ext/vendor/exuberant-ctags/argproc.c +505 -0
- data/ext/vendor/exuberant-ctags/args.c +274 -0
- data/ext/vendor/exuberant-ctags/args.h +63 -0
- data/ext/vendor/exuberant-ctags/asm.c +387 -0
- data/ext/vendor/exuberant-ctags/asp.c +328 -0
- data/ext/vendor/exuberant-ctags/awk.c +81 -0
- data/ext/vendor/exuberant-ctags/basic.c +203 -0
- data/ext/vendor/exuberant-ctags/beta.c +321 -0
- data/ext/vendor/exuberant-ctags/c.c +2932 -0
- data/ext/vendor/exuberant-ctags/cobol.c +50 -0
- data/ext/vendor/exuberant-ctags/config.h.in +277 -0
- data/ext/vendor/exuberant-ctags/configure +7704 -0
- data/ext/vendor/exuberant-ctags/configure.ac +532 -0
- data/ext/vendor/exuberant-ctags/ctags.1 +1186 -0
- data/ext/vendor/exuberant-ctags/ctags.h +28 -0
- data/ext/vendor/exuberant-ctags/ctags.html +2087 -0
- data/ext/vendor/exuberant-ctags/ctags.spec +40 -0
- data/ext/vendor/exuberant-ctags/debug.c +113 -0
- data/ext/vendor/exuberant-ctags/debug.h +70 -0
- data/ext/vendor/exuberant-ctags/descrip.mms +68 -0
- data/ext/vendor/exuberant-ctags/dosbatch.c +42 -0
- data/ext/vendor/exuberant-ctags/e_amiga.h +24 -0
- data/ext/vendor/exuberant-ctags/e_djgpp.h +47 -0
- data/ext/vendor/exuberant-ctags/e_mac.h +143 -0
- data/ext/vendor/exuberant-ctags/e_msoft.h +76 -0
- data/ext/vendor/exuberant-ctags/e_os2.h +37 -0
- data/ext/vendor/exuberant-ctags/e_qdos.h +34 -0
- data/ext/vendor/exuberant-ctags/e_riscos.h +58 -0
- data/ext/vendor/exuberant-ctags/e_vms.h +31 -0
- data/ext/vendor/exuberant-ctags/eiffel.c +1352 -0
- data/ext/vendor/exuberant-ctags/entry.c +847 -0
- data/ext/vendor/exuberant-ctags/entry.h +103 -0
- data/ext/vendor/exuberant-ctags/erlang.c +189 -0
- data/ext/vendor/exuberant-ctags/flex.c +2243 -0
- data/ext/vendor/exuberant-ctags/fortran.c +2197 -0
- data/ext/vendor/exuberant-ctags/general.h +127 -0
- data/ext/vendor/exuberant-ctags/get.c +669 -0
- data/ext/vendor/exuberant-ctags/get.h +50 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/all-wcprops +47 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/entries +112 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/README.txt.svn-base +5 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regcomp.c.svn-base +3818 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regex.c.svn-base +74 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regex.h.svn-base +575 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regex_internal.c.svn-base +1713 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regex_internal.h.svn-base +773 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/.svn/text-base/regexec.c.svn-base +4338 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/README.txt +5 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/regcomp.c +3818 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/regex.c +74 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/regex.h +575 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/regex_internal.c +1713 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/regex_internal.h +773 -0
- data/ext/vendor/exuberant-ctags/gnu_regex/regexec.c +4338 -0
- data/ext/vendor/exuberant-ctags/html.c +49 -0
- data/ext/vendor/exuberant-ctags/jscript.c +1572 -0
- data/ext/vendor/exuberant-ctags/keyword.c +258 -0
- data/ext/vendor/exuberant-ctags/keyword.h +34 -0
- data/ext/vendor/exuberant-ctags/lisp.c +139 -0
- data/ext/vendor/exuberant-ctags/lregex.c +704 -0
- data/ext/vendor/exuberant-ctags/lua.c +133 -0
- data/ext/vendor/exuberant-ctags/mac.c +273 -0
- data/ext/vendor/exuberant-ctags/magic.diff +21 -0
- data/ext/vendor/exuberant-ctags/main.c +584 -0
- data/ext/vendor/exuberant-ctags/main.h +32 -0
- data/ext/vendor/exuberant-ctags/maintainer.mak +476 -0
- data/ext/vendor/exuberant-ctags/make.c +217 -0
- data/ext/vendor/exuberant-ctags/matlab.c +44 -0
- data/ext/vendor/exuberant-ctags/mk_bc3.mak +46 -0
- data/ext/vendor/exuberant-ctags/mk_bc5.mak +49 -0
- data/ext/vendor/exuberant-ctags/mk_djg.mak +18 -0
- data/ext/vendor/exuberant-ctags/mk_manx.mak +65 -0
- data/ext/vendor/exuberant-ctags/mk_mingw.mak +31 -0
- data/ext/vendor/exuberant-ctags/mk_mpw.mak +130 -0
- data/ext/vendor/exuberant-ctags/mk_mvc.mak +40 -0
- data/ext/vendor/exuberant-ctags/mk_os2.mak +104 -0
- data/ext/vendor/exuberant-ctags/mk_qdos.mak +100 -0
- data/ext/vendor/exuberant-ctags/mk_sas.mak +63 -0
- data/ext/vendor/exuberant-ctags/mkinstalldirs +40 -0
- data/ext/vendor/exuberant-ctags/ocaml.c +1842 -0
- data/ext/vendor/exuberant-ctags/options.c +1842 -0
- data/ext/vendor/exuberant-ctags/options.h +155 -0
- data/ext/vendor/exuberant-ctags/parse.c +677 -0
- data/ext/vendor/exuberant-ctags/parse.h +129 -0
- data/ext/vendor/exuberant-ctags/parsers.h +63 -0
- data/ext/vendor/exuberant-ctags/pascal.c +267 -0
- data/ext/vendor/exuberant-ctags/perl.c +382 -0
- data/ext/vendor/exuberant-ctags/php.c +237 -0
- data/ext/vendor/exuberant-ctags/python.c +771 -0
- data/ext/vendor/exuberant-ctags/qdos.c +106 -0
- data/ext/vendor/exuberant-ctags/read.c +569 -0
- data/ext/vendor/exuberant-ctags/read.h +116 -0
- data/ext/vendor/exuberant-ctags/readtags.c +959 -0
- data/ext/vendor/exuberant-ctags/readtags.h +252 -0
- data/ext/vendor/exuberant-ctags/rexx.c +39 -0
- data/ext/vendor/exuberant-ctags/routines.c +891 -0
- data/ext/vendor/exuberant-ctags/routines.h +134 -0
- data/ext/vendor/exuberant-ctags/ruby.c +408 -0
- data/ext/vendor/exuberant-ctags/scheme.c +111 -0
- data/ext/vendor/exuberant-ctags/sh.c +115 -0
- data/ext/vendor/exuberant-ctags/slang.c +41 -0
- data/ext/vendor/exuberant-ctags/sml.c +212 -0
- data/ext/vendor/exuberant-ctags/sort.c +230 -0
- data/ext/vendor/exuberant-ctags/sort.h +32 -0
- data/ext/vendor/exuberant-ctags/source.mak +122 -0
- data/ext/vendor/exuberant-ctags/sql.c +2112 -0
- data/ext/vendor/exuberant-ctags/strlist.c +281 -0
- data/ext/vendor/exuberant-ctags/strlist.h +54 -0
- data/ext/vendor/exuberant-ctags/tcl.c +116 -0
- data/ext/vendor/exuberant-ctags/tex.c +524 -0
- data/ext/vendor/exuberant-ctags/verilog.c +340 -0
- data/ext/vendor/exuberant-ctags/vhdl.c +835 -0
- data/ext/vendor/exuberant-ctags/vim.c +636 -0
- data/ext/vendor/exuberant-ctags/vstring.c +232 -0
- data/ext/vendor/exuberant-ctags/vstring.h +85 -0
- data/ext/vendor/exuberant-ctags/yacc.c +40 -0
- data/lib/ctags/exuberant.rb +45 -0
- data/lib/ctags/version.rb +3 -0
- data/lib/ctags.rb +6 -0
- data/test/test_ctags.rb +24 -0
- metadata +233 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* $Id: lua.c 443 2006-05-30 04:37:13Z darren $
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2000-2001, Max Ischenko <mfi@ukr.net>.
|
|
5
|
+
*
|
|
6
|
+
* This source code is released for free distribution under the terms of the
|
|
7
|
+
* GNU General Public License.
|
|
8
|
+
*
|
|
9
|
+
* This module contains functions for generating tags for Lua language.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* INCLUDE FILES
|
|
14
|
+
*/
|
|
15
|
+
#include "general.h" /* must always come first */
|
|
16
|
+
|
|
17
|
+
#include <string.h>
|
|
18
|
+
|
|
19
|
+
#include "options.h"
|
|
20
|
+
#include "parse.h"
|
|
21
|
+
#include "read.h"
|
|
22
|
+
#include "vstring.h"
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* DATA DEFINITIONS
|
|
26
|
+
*/
|
|
27
|
+
typedef enum {
|
|
28
|
+
K_FUNCTION
|
|
29
|
+
} luaKind;
|
|
30
|
+
|
|
31
|
+
static kindOption LuaKinds [] = {
|
|
32
|
+
{ TRUE, 'f', "function", "functions" }
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/*
|
|
36
|
+
* FUNCTION DEFINITIONS
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/* for debugging purposes */
|
|
40
|
+
static void __unused__ print_string (char *p, char *q)
|
|
41
|
+
{
|
|
42
|
+
for ( ; p != q; p++)
|
|
43
|
+
fprintf (errout, "%c", *p);
|
|
44
|
+
fprintf (errout, "\n");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
* Helper function.
|
|
49
|
+
* Returns 1 if line looks like a line of Lua code.
|
|
50
|
+
*
|
|
51
|
+
* TODO: Recognize UNIX bang notation.
|
|
52
|
+
* (Lua treat first line as a comment if it starts with #!)
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
static boolean is_a_code_line (const unsigned char *line)
|
|
56
|
+
{
|
|
57
|
+
boolean result;
|
|
58
|
+
const unsigned char *p = line;
|
|
59
|
+
while (isspace ((int) *p))
|
|
60
|
+
p++;
|
|
61
|
+
if (p [0] == '\0')
|
|
62
|
+
result = FALSE;
|
|
63
|
+
else if (p [0] == '-' && p [1] == '-')
|
|
64
|
+
result = FALSE;
|
|
65
|
+
else
|
|
66
|
+
result = TRUE;
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static void extract_name (const char *begin, const char *end, vString *name)
|
|
71
|
+
{
|
|
72
|
+
if (begin != NULL && end != NULL && begin < end)
|
|
73
|
+
{
|
|
74
|
+
const char *cp;
|
|
75
|
+
|
|
76
|
+
while (isspace ((int) *begin))
|
|
77
|
+
begin++;
|
|
78
|
+
while (isspace ((int) *end))
|
|
79
|
+
end--;
|
|
80
|
+
if (begin < end)
|
|
81
|
+
{
|
|
82
|
+
for (cp = begin ; cp != end; cp++)
|
|
83
|
+
vStringPut (name, (int) *cp);
|
|
84
|
+
vStringTerminate (name);
|
|
85
|
+
|
|
86
|
+
makeSimpleTag (name, LuaKinds, K_FUNCTION);
|
|
87
|
+
vStringClear (name);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static void findLuaTags (void)
|
|
93
|
+
{
|
|
94
|
+
vString *name = vStringNew ();
|
|
95
|
+
const unsigned char *line;
|
|
96
|
+
|
|
97
|
+
while ((line = fileReadLine ()) != NULL)
|
|
98
|
+
{
|
|
99
|
+
const char *p, *q;
|
|
100
|
+
|
|
101
|
+
if (! is_a_code_line (line))
|
|
102
|
+
continue;
|
|
103
|
+
|
|
104
|
+
p = (const char*) strstr ((const char*) line, "function");
|
|
105
|
+
if (p == NULL)
|
|
106
|
+
continue;
|
|
107
|
+
|
|
108
|
+
q = strchr ((const char*) line, '=');
|
|
109
|
+
|
|
110
|
+
if (q == NULL) {
|
|
111
|
+
p = p + 9; /* skip the `function' word */
|
|
112
|
+
q = strchr ((const char*) p, '(');
|
|
113
|
+
extract_name (p, q, name);
|
|
114
|
+
} else {
|
|
115
|
+
p = (const char*) &line[0];
|
|
116
|
+
extract_name (p, q, name);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
vStringDelete (name);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
extern parserDefinition* LuaParser (void)
|
|
123
|
+
{
|
|
124
|
+
static const char* const extensions [] = { "lua", NULL };
|
|
125
|
+
parserDefinition* def = parserNew ("Lua");
|
|
126
|
+
def->kinds = LuaKinds;
|
|
127
|
+
def->kindCount = KIND_COUNT (LuaKinds);
|
|
128
|
+
def->extensions = extensions;
|
|
129
|
+
def->parser = findLuaTags;
|
|
130
|
+
return def;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* vi:set tabstop=4 shiftwidth=4: */
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* $Id: mac.c 443 2006-05-30 04:37:13Z darren $
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2001, Maarten L. Hekkelman
|
|
5
|
+
*
|
|
6
|
+
* Author: Maarten L. Hekkelman <maarten@hekkelman.com>
|
|
7
|
+
* http://www.hekkelman.com
|
|
8
|
+
*
|
|
9
|
+
* This source code is released for free distribution under the terms of the
|
|
10
|
+
* GNU General Public License. It is provided on an as-is basis and no
|
|
11
|
+
* responsibility is accepted for its failure to perform as expected.
|
|
12
|
+
*
|
|
13
|
+
* This module contains support functions for Exuberant Ctags on Macintosh.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* INCLUDE FILES
|
|
18
|
+
*/
|
|
19
|
+
#include "general.h"
|
|
20
|
+
|
|
21
|
+
#include <Files.h>
|
|
22
|
+
#include <TextUtils.h>
|
|
23
|
+
#include <stdlib.h>
|
|
24
|
+
#include <string.h>
|
|
25
|
+
#include <stdio.h>
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
* FUNCTION DEFINITIONS
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
static int get_path(const char* in_unix_path, unsigned char* out_mac_path)
|
|
32
|
+
{
|
|
33
|
+
int l = strlen(in_unix_path);
|
|
34
|
+
int result = 0;
|
|
35
|
+
|
|
36
|
+
if (l > 254)
|
|
37
|
+
result = -1;
|
|
38
|
+
else
|
|
39
|
+
{
|
|
40
|
+
const char* s = in_unix_path;
|
|
41
|
+
char *d = (char*)out_mac_path + 1;
|
|
42
|
+
|
|
43
|
+
if (*s != '/')
|
|
44
|
+
*d++ = ':';
|
|
45
|
+
else
|
|
46
|
+
++s;
|
|
47
|
+
|
|
48
|
+
while (*s)
|
|
49
|
+
{
|
|
50
|
+
if (s[0] == '.' && s[1] == '.' && s[2] == '/')
|
|
51
|
+
{
|
|
52
|
+
s += 3;
|
|
53
|
+
*d++ = ':';
|
|
54
|
+
}
|
|
55
|
+
else if (s[0] == '.' && s[1] == '/')
|
|
56
|
+
s += 2;
|
|
57
|
+
else if (s[0] == '/')
|
|
58
|
+
{
|
|
59
|
+
*d++ = ':';
|
|
60
|
+
|
|
61
|
+
++s;
|
|
62
|
+
while (*s == '/')
|
|
63
|
+
++s;
|
|
64
|
+
}
|
|
65
|
+
else
|
|
66
|
+
*d++ = *s++;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
out_mac_path[0] = (d - (char*)out_mac_path) - 1;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
DIR *opendir(const char *dirname)
|
|
76
|
+
{
|
|
77
|
+
DIR* dirp = (DIR*)calloc(1, sizeof(DIR));
|
|
78
|
+
|
|
79
|
+
if (dirp != NULL)
|
|
80
|
+
{
|
|
81
|
+
OSErr err;
|
|
82
|
+
Str255 s;
|
|
83
|
+
CInfoPBRec pb = { 0 };
|
|
84
|
+
|
|
85
|
+
if (strcmp(dirname, "."))
|
|
86
|
+
{
|
|
87
|
+
get_path(dirname, s);
|
|
88
|
+
pb.hFileInfo.ioNamePtr = s;
|
|
89
|
+
}
|
|
90
|
+
else
|
|
91
|
+
pb.hFileInfo.ioNamePtr = NULL;
|
|
92
|
+
|
|
93
|
+
err = PBGetCatInfoSync(&pb);
|
|
94
|
+
if (err != noErr || (pb.hFileInfo.ioFlAttrib & ioDirMask) == 0)
|
|
95
|
+
{
|
|
96
|
+
free(dirp);
|
|
97
|
+
dirp = NULL;
|
|
98
|
+
}
|
|
99
|
+
else
|
|
100
|
+
{
|
|
101
|
+
dirp->file.vRefNum = pb.hFileInfo.ioVRefNum;
|
|
102
|
+
dirp->file.parID = pb.hFileInfo.ioDirID;
|
|
103
|
+
dirp->file.name[0] = '\0';
|
|
104
|
+
dirp->index = 1;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return dirp;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
struct dirent *readdir(DIR *dirp)
|
|
112
|
+
{
|
|
113
|
+
if (dirp)
|
|
114
|
+
{
|
|
115
|
+
CInfoPBRec pb = { 0 };
|
|
116
|
+
|
|
117
|
+
pb.hFileInfo.ioVRefNum = dirp->file.vRefNum;
|
|
118
|
+
pb.hFileInfo.ioDirID = dirp->file.parID;
|
|
119
|
+
pb.hFileInfo.ioFDirIndex = dirp->index++;
|
|
120
|
+
pb.hFileInfo.ioNamePtr = dirp->file.name;
|
|
121
|
+
|
|
122
|
+
if (PBGetCatInfoSync(&pb) != noErr)
|
|
123
|
+
return NULL;
|
|
124
|
+
|
|
125
|
+
memcpy(dirp->ent.d_name, dirp->file.name + 1, dirp->file.name[0]);
|
|
126
|
+
dirp->ent.d_name[dirp->file.name[0]] = 0;
|
|
127
|
+
return &dirp->ent;
|
|
128
|
+
}
|
|
129
|
+
return NULL;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
int closedir(DIR *dirp)
|
|
133
|
+
{
|
|
134
|
+
if (dirp)
|
|
135
|
+
free(dirp);
|
|
136
|
+
return 0;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
void rewinddir(DIR *dirp)
|
|
140
|
+
{
|
|
141
|
+
if (dirp)
|
|
142
|
+
dirp->index = 1;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
int mstat(const char* file, struct stat* st)
|
|
146
|
+
{
|
|
147
|
+
CInfoPBRec pb;
|
|
148
|
+
unsigned char path[256];
|
|
149
|
+
int result = 0;
|
|
150
|
+
|
|
151
|
+
memset(&pb, 0, sizeof(CInfoPBRec));
|
|
152
|
+
|
|
153
|
+
if (strcmp(file, ".") == 0)
|
|
154
|
+
{
|
|
155
|
+
memset(st, 0, sizeof(struct stat));
|
|
156
|
+
st->st_mode = S_IFDIR;
|
|
157
|
+
st->st_ino = -1;
|
|
158
|
+
}
|
|
159
|
+
else
|
|
160
|
+
{
|
|
161
|
+
result = get_path(file, path);
|
|
162
|
+
|
|
163
|
+
if (result == 0)
|
|
164
|
+
{
|
|
165
|
+
pb.hFileInfo.ioNamePtr = path;
|
|
166
|
+
|
|
167
|
+
if (PBGetCatInfoSync(&pb) != noErr)
|
|
168
|
+
result = -1;
|
|
169
|
+
else
|
|
170
|
+
{
|
|
171
|
+
memset(st, 0, sizeof(struct stat));
|
|
172
|
+
|
|
173
|
+
if (pb.hFileInfo.ioFlAttrib & ioDirMask)
|
|
174
|
+
st->st_mode = S_IFDIR;
|
|
175
|
+
else
|
|
176
|
+
st->st_mode = S_IFREG;
|
|
177
|
+
|
|
178
|
+
st->st_ino = pb.hFileInfo.ioFlStBlk;
|
|
179
|
+
st->st_dev = pb.hFileInfo.ioVRefNum;
|
|
180
|
+
st->st_nlink = 1;
|
|
181
|
+
st->st_size = pb.hFileInfo.ioFlLgLen;
|
|
182
|
+
st->st_atime = pb.hFileInfo.ioFlMdDat;
|
|
183
|
+
st->st_mtime = pb.hFileInfo.ioFlMdDat;
|
|
184
|
+
st->st_ctime = pb.hFileInfo.ioFlCrDat;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
#undef fopen
|
|
193
|
+
|
|
194
|
+
FILE* mfopen(const char* file, const char* mode)
|
|
195
|
+
{
|
|
196
|
+
unsigned char path[256];
|
|
197
|
+
|
|
198
|
+
if (get_path(file, path) == 0)
|
|
199
|
+
{
|
|
200
|
+
int l = path[0];
|
|
201
|
+
memmove(path, path + 1, l);
|
|
202
|
+
path[l] = 0;
|
|
203
|
+
return fopen((char*)path, mode);
|
|
204
|
+
}
|
|
205
|
+
else
|
|
206
|
+
return NULL;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
char* getcwd(char* out_path, int out_path_len)
|
|
210
|
+
{
|
|
211
|
+
OSErr err = noErr;
|
|
212
|
+
CInfoPBRec pb;
|
|
213
|
+
FSSpec cwd;
|
|
214
|
+
|
|
215
|
+
if (out_path == NULL)
|
|
216
|
+
{
|
|
217
|
+
if (out_path_len < PATH_MAX)
|
|
218
|
+
out_path_len = PATH_MAX;
|
|
219
|
+
out_path = (char*)malloc(out_path_len);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
err = FSMakeFSSpec(0, 0, "\p:", &cwd);
|
|
223
|
+
|
|
224
|
+
if (cwd.parID == fsRtParID)
|
|
225
|
+
{
|
|
226
|
+
*out_path = '/';
|
|
227
|
+
memcpy(out_path + 1, cwd.name + 1, cwd.name[0]);
|
|
228
|
+
out_path[1 + cwd.name[0]] = 0;
|
|
229
|
+
}
|
|
230
|
+
else
|
|
231
|
+
{
|
|
232
|
+
/* The object isn't a volume */
|
|
233
|
+
|
|
234
|
+
/* Is the object a file or a directory? */
|
|
235
|
+
|
|
236
|
+
char t[PATH_MAX];
|
|
237
|
+
char* s;
|
|
238
|
+
|
|
239
|
+
s = t + PATH_MAX - cwd.name[0] - 1;
|
|
240
|
+
memcpy(s, cwd.name + 1, cwd.name[0]);
|
|
241
|
+
s[cwd.name[0]] = 0;
|
|
242
|
+
|
|
243
|
+
/* Get the ancestor directory names */
|
|
244
|
+
pb.dirInfo.ioNamePtr = cwd.name;
|
|
245
|
+
pb.dirInfo.ioVRefNum = cwd.vRefNum;
|
|
246
|
+
pb.dirInfo.ioDrParID = cwd.parID;
|
|
247
|
+
do /* loop until we have an error or find the root directory */
|
|
248
|
+
{
|
|
249
|
+
pb.dirInfo.ioFDirIndex = -1;
|
|
250
|
+
pb.dirInfo.ioDrDirID = pb.dirInfo.ioDrParID;
|
|
251
|
+
err = PBGetCatInfoSync(&pb);
|
|
252
|
+
if ( err == noErr )
|
|
253
|
+
{
|
|
254
|
+
*--s = '/';
|
|
255
|
+
s -= cwd.name[0];
|
|
256
|
+
memcpy(s, cwd.name + 1, cwd.name[0]);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
while (err == noErr && pb.dirInfo.ioDrDirID != fsRtDirID && s > t + 1);
|
|
260
|
+
|
|
261
|
+
if (s > t + 1)
|
|
262
|
+
{
|
|
263
|
+
*--s = '/';
|
|
264
|
+
strcpy(out_path, s);
|
|
265
|
+
}
|
|
266
|
+
else
|
|
267
|
+
strcpy(out_path, ".");
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return out_path;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/* vi:set tabstop=4 shiftwidth=4: */
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
This file contains a patch to the Linux file /usr/share/magic which will
|
|
2
|
+
allow the "file" command to properly identify tags file producted by
|
|
3
|
+
Exuberant Ctags. To apply the patch, issue the following command as root:
|
|
4
|
+
|
|
5
|
+
patch -p0 < magic.diff
|
|
6
|
+
|
|
7
|
+
*** /usr/share/magic.orig Wed Feb 16 19:04:09 2000
|
|
8
|
+
--- /usr/share/magic Mon Aug 14 20:27:01 2000
|
|
9
|
+
***************
|
|
10
|
+
*** 1155,1160 ****
|
|
11
|
+
--- 1155,1164 ----
|
|
12
|
+
>84 belong&0x18000000 =0x18000000 undefined fpmode
|
|
13
|
+
|
|
14
|
+
#------------------------------------------------------------------------------
|
|
15
|
+
+ # ctags: file (1) magic for Exuberant Ctags files
|
|
16
|
+
+ 0 string !_TAG Exuberant Ctags tag file
|
|
17
|
+
+
|
|
18
|
+
+ #------------------------------------------------------------------------------
|
|
19
|
+
# database: file(1) magic for various databases
|
|
20
|
+
#
|
|
21
|
+
# extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk)
|