Don't add progress ticks to the statusbar when creating progress data.
[anjuta-git-plugin.git] / tagmanager / sh.c
blob81d1074b572a0e863bd6cde5d8d1965f5d8cdb97
1 /*
2 * $Id$
4 * Copyright (c) 2000-2002, Darren Hiebert
6 * This source code is released for free distribution under the terms of the
7 * GNU General Public License.
9 * This module contains functions for generating tags for scripts for the
10 * Bourne shell (and its derivatives, the Korn and Z shells).
14 * INCLUDE FILES
16 #include "general.h" /* must always come first */
18 #include <string.h>
20 #include "parse.h"
21 #include "read.h"
22 #include "routines.h"
23 #include "vstring.h"
26 * DATA DEFINITIONS
28 typedef enum {
29 K_FUNCTION
30 } shKind;
32 static kindOption ShKinds [] = {
33 { TRUE, 'f', "function", "functions"}
37 * FUNCTION DEFINITIONS
40 /* Reject any tag "main" from a file named "configure". These appear in
41 * here-documents in GNU autoconf scripts and will add a haystack to the
42 * needle.
44 static boolean hackReject (const vString* const tagName)
46 const char *const scriptName = baseFilename (vStringValue (File.name));
47 boolean result = (boolean) (
48 strcmp (scriptName, "configure") == 0 &&
49 strcmp (vStringValue (tagName), "main") == 0);
50 return result;
53 static void findShTags (void)
55 vString *name = vStringNew ();
56 const unsigned char *line;
58 while ((line = fileReadLine ()) != NULL)
60 const unsigned char* cp = line;
61 boolean functionFound = FALSE;
63 if (line [0] == '#')
64 continue;
66 while (isspace (*cp))
67 cp++;
68 if (strncmp ((const char*) cp, "function", (size_t) 8) == 0 &&
69 isspace ((int) cp [8]))
71 functionFound = TRUE;
72 cp += 8;
73 if (! isspace ((int) *cp))
74 continue;
75 while (isspace ((int) *cp))
76 ++cp;
78 if (! (isalnum ((int) *cp) || *cp == '_'))
79 continue;
80 while (isalnum ((int) *cp) || *cp == '_')
82 vStringPut (name, (int) *cp);
83 ++cp;
85 vStringTerminate (name);
86 while (isspace ((int) *cp))
87 ++cp;
88 if (*cp++ == '(')
90 while (isspace ((int) *cp))
91 ++cp;
92 if (*cp == ')' && ! hackReject (name))
93 functionFound = TRUE;
95 if (functionFound)
96 makeSimpleTag (name, ShKinds, K_FUNCTION);
97 vStringClear (name);
99 vStringDelete (name);
102 extern parserDefinition* ShParser (void)
104 static const char *const extensions [] = {
105 "sh", "SH", "bsh", "bash", "ksh", "zsh", NULL
107 parserDefinition* def = parserNew ("Sh");
108 def->kinds = ShKinds;
109 def->kindCount = KIND_COUNT (ShKinds);
110 def->extensions = extensions;
111 def->parser = findShTags;
112 return def;
115 /* vi:set tabstop=4 shiftwidth=4: */