Kaydet (Commit) 12104026 authored tarafından Enrico Tröger's avatar Enrico Tröger

Backport changes from CTags SVN to fix parse problems in the Ruby parser.

Add filetype extension "*.ruby".


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1563 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst bd205a73
...@@ -4,6 +4,11 @@ ...@@ -4,6 +4,11 @@
* geany.glade, src/dialogs.c, src/geany.h, src/interface.c, * geany.glade, src/dialogs.c, src/geany.h, src/interface.c,
src/keyfile.c, src/main.c, src/prefs.c: src/keyfile.c, src/main.c, src/prefs.c:
Add default startup directory option (closes #1704988). Add default startup directory option (closes #1704988).
* tagmanager/ruby.c, tagmanager/strlist.c, tagmanager/strlist.h:
Backport changes from CTags SVN to fix parse problems in the Ruby
parser.
* data/filetype_extensions.conf, src/filetypes.c:
Add filetype extension "*.ruby".
2007-05-23 Nick Treleaven <nick.treleaven@btinternet.com> 2007-05-23 Nick Treleaven <nick.treleaven@btinternet.com>
......
...@@ -14,7 +14,7 @@ Perl=*.pl;*.perl;*.pm;*.agi;*.pod; ...@@ -14,7 +14,7 @@ Perl=*.pl;*.perl;*.pm;*.agi;*.pod;
PHP=*.php;*.php3;*.php4;*.php5;*.phtml; PHP=*.php;*.php3;*.php4;*.php5;*.phtml;
Javascript=*.js; Javascript=*.js;
Python=*.py;*.pyw; Python=*.py;*.pyw;
Ruby=*.rb;*.rhtml; Ruby=*.rb;*.rhtml;*.ruby;
Tcl=*.tcl;*.tk;*.wish; Tcl=*.tcl;*.tk;*.wish;
Lua=*.lua; Lua=*.lua;
Ferite=*.fe; Ferite=*.fe;
......
...@@ -301,7 +301,7 @@ void filetypes_init_types() ...@@ -301,7 +301,7 @@ void filetypes_init_types()
filetypes[GEANY_FILETYPES_RUBY]->has_tags = TRUE; filetypes[GEANY_FILETYPES_RUBY]->has_tags = TRUE;
filetypes[GEANY_FILETYPES_RUBY]->title = g_strdup(_("Ruby source file")); filetypes[GEANY_FILETYPES_RUBY]->title = g_strdup(_("Ruby source file"));
filetypes[GEANY_FILETYPES_RUBY]->extension = g_strdup("rb"); filetypes[GEANY_FILETYPES_RUBY]->extension = g_strdup("rb");
filetypes[GEANY_FILETYPES_RUBY]->pattern = utils_strv_new("*.rb", "*.rhtml", NULL); filetypes[GEANY_FILETYPES_RUBY]->pattern = utils_strv_new("*.rb", "*.rhtml", "*.ruby", NULL);
filetypes[GEANY_FILETYPES_RUBY]->style_func_ptr = styleset_ruby; filetypes[GEANY_FILETYPES_RUBY]->style_func_ptr = styleset_ruby;
filetypes[GEANY_FILETYPES_RUBY]->comment_open = g_strdup("#"); filetypes[GEANY_FILETYPES_RUBY]->comment_open = g_strdup("#");
filetypes[GEANY_FILETYPES_RUBY]->comment_close = NULL; filetypes[GEANY_FILETYPES_RUBY]->comment_close = NULL;
......
This diff is collapsed.
/* /*
* $Id$
* *
* Copyright (c) 1999-2001, Darren Hiebert * Copyright (c) 1999-2002, Darren Hiebert
* *
* This source code is released for free distribution under the terms of the * This source code is released for free distribution under the terms of the
* GNU General Public License. * GNU General Public License.
...@@ -18,7 +19,6 @@ ...@@ -18,7 +19,6 @@
# include <fnmatch.h> # include <fnmatch.h>
#endif #endif
#include "main.h" #include "main.h"
#include "read.h" #include "read.h"
#include "strlist.h" #include "strlist.h"
...@@ -55,8 +55,17 @@ extern void stringListAdd (stringList *const current, vString *string) ...@@ -55,8 +55,17 @@ extern void stringListAdd (stringList *const current, vString *string)
current->list [current->count++] = string; current->list [current->count++] = string;
} }
extern void stringListRemoveLast (stringList *const current)
{
Assert (current != NULL);
Assert (current->count > 0);
--current->count;
current->list [current->count] = NULL;
}
/* Combine list `from' into `current', deleting `from' */ /* Combine list `from' into `current', deleting `from' */
extern void stringListCombine (stringList *const current, stringList *const from) extern void stringListCombine (
stringList *const current, stringList *const from)
{ {
unsigned int i; unsigned int i;
Assert (current != NULL); Assert (current != NULL);
...@@ -83,9 +92,7 @@ extern stringList* stringListNewFromFile (const char* const fileName) ...@@ -83,9 +92,7 @@ extern stringList* stringListNewFromFile (const char* const fileName)
{ {
stringList* result = NULL; stringList* result = NULL;
FILE* const fp = fopen (fileName, "r"); FILE* const fp = fopen (fileName, "r");
if (fp == NULL) if (fp != NULL)
error (FATAL | PERROR, "cannot open \"%s\"", fileName);
else
{ {
result = stringListNew (); result = stringListNew ();
while (! feof (fp)) while (! feof (fp))
...@@ -108,13 +115,20 @@ extern unsigned int stringListCount (const stringList *const current) ...@@ -108,13 +115,20 @@ extern unsigned int stringListCount (const stringList *const current)
return current->count; return current->count;
} }
extern vString* stringListItem (const stringList *const current, extern vString* stringListItem (
const unsigned int indx) const stringList *const current, const unsigned int indx)
{ {
Assert (current != NULL); Assert (current != NULL);
return current->list [indx]; return current->list [indx];
} }
extern vString* stringListLast (const stringList *const current)
{
Assert (current != NULL);
Assert (current->count > 0);
return current->list [current->count - 1];
}
extern void stringListClear (stringList *const current) extern void stringListClear (stringList *const current)
{ {
unsigned int i; unsigned int i;
...@@ -143,69 +157,115 @@ extern void stringListDelete (stringList *const current) ...@@ -143,69 +157,115 @@ extern void stringListDelete (stringList *const current)
} }
} }
extern boolean stringListHas (const stringList *const current, static boolean compareString (
const char *const str) const char *const string, vString *const itm)
{ {
boolean result = FALSE; return (boolean) (strcmp (string, vStringValue (itm)) == 0);
}
static boolean compareStringInsensitive (
const char *const string, vString *const itm)
{
return (boolean) (strcasecmp (string, vStringValue (itm)) == 0);
}
static int stringListIndex (
const stringList *const current,
const char *const string,
boolean (*test)(const char *s, vString *const vs))
{
int result = -1;
unsigned int i; unsigned int i;
Assert (current != NULL); Assert (current != NULL);
for (i = 0 ; ! result && i < current->count ; ++i) Assert (string != NULL);
result = (boolean) (strcmp (str, vStringValue (current->list [i]))==0); Assert (test != NULL);
for (i = 0 ; result == -1 && i < current->count ; ++i)
if ((*test)(string, current->list [i]))
result = i;
return result; return result;
} }
extern boolean stringListHasInsensitive (const stringList *const current, extern boolean stringListHas (
const char *const str) const stringList *const current, const char *const string)
{ {
boolean result = FALSE; boolean result = FALSE;
unsigned int i;
Assert (current != NULL); Assert (current != NULL);
for (i = 0 ; ! result && i < current->count ; ++i) result = stringListIndex (current, string, compareString) != -1;
result = (boolean) (stricmp (str, vStringValue (current->list [i]))==0);
return result; return result;
} }
extern boolean stringListHasFile (const stringList *const current, extern boolean stringListHasInsensitive (
const char *const file) const stringList *const current, const char *const string)
{
boolean result = FALSE;
Assert (current != NULL);
Assert (string != NULL);
result = stringListIndex (current, string, compareStringInsensitive) != -1;
return result;
}
extern boolean stringListHasTest (
const stringList *const current, boolean (*test)(const char *s))
{ {
boolean result = FALSE; boolean result = FALSE;
unsigned int i; unsigned int i;
Assert (current != NULL); Assert (current != NULL);
for (i = 0 ; ! result && i < current->count ; ++i) for (i = 0 ; ! result && i < current->count ; ++i)
result = (boolean) (isSameFile (file, vStringValue (current->list [i]))); result = (*test)(vStringValue (current->list [i]));
return result;
}
extern boolean stringListRemoveExtension (
stringList* const current, const char* const extension)
{
boolean result = FALSE;
int where;
#ifdef CASE_INSENSITIVE_FILENAMES
where = stringListIndex (current, extension, compareStringInsensitive);
#else
where = stringListIndex (current, extension, compareString);
#endif
if (where != -1)
{
memmove (current->list + where, current->list + where + 1,
(current->count - where) * sizeof (*current->list));
current->list [current->count - 1] = NULL;
--current->count;
result = TRUE;
}
return result; return result;
} }
extern boolean stringListExtensionMatched (const stringList* const list, extern boolean stringListExtensionMatched (
const char* const extension) const stringList* const current, const char* const extension)
{ {
#ifdef CASE_INSENSITIVE_FILENAMES #ifdef CASE_INSENSITIVE_FILENAMES
return stringListHasInsensitive (list, extension); return stringListHasInsensitive (current, extension);
#else #else
return stringListHas (list, extension); return stringListHas (current, extension);
#endif #endif
} }
static boolean fileNameMatched (const vString* const vpattern, static boolean fileNameMatched (
const char* const fileName) const vString* const vpattern, const char* const fileName)
{ {
const char* const pattern = vStringValue (vpattern); const char* const pattern = vStringValue (vpattern);
#if defined (HAVE_FNMATCH) #if defined (HAVE_FNMATCH)
return (boolean) (fnmatch (pattern, fileName, 0) == 0); return (boolean) (fnmatch (pattern, fileName, 0) == 0);
#elif defined (CASE_INSENSITIVE_FILENAMES) #elif defined (CASE_INSENSITIVE_FILENAMES)
return (boolean) (stricmp (pattern, fileName) == 0); return (boolean) (strcasecmp (pattern, fileName) == 0);
#else #else
return (boolean) (strcmp (pattern, fileName) == 0); return (boolean) (strcmp (pattern, fileName) == 0);
#endif #endif
} }
extern boolean stringListFileMatched (const stringList* const list, extern boolean stringListFileMatched (
const char* const fileName) const stringList* const current, const char* const fileName)
{ {
boolean result = FALSE; boolean result = FALSE;
unsigned int i; unsigned int i;
for (i = 0 ; ! result && i < stringListCount (list) ; ++i) for (i = 0 ; ! result && i < stringListCount (current) ; ++i)
result = fileNameMatched (stringListItem (list, i), fileName); result = fileNameMatched (stringListItem (current, i), fileName);
return result; return result;
} }
...@@ -217,4 +277,4 @@ extern void stringListPrint (const stringList *const current) ...@@ -217,4 +277,4 @@ extern void stringListPrint (const stringList *const current)
printf ("%s%s", (i > 0) ? ", " : "", vStringValue (current->list [i])); printf ("%s%s", (i > 0) ? ", " : "", vStringValue (current->list [i]));
} }
/* vi:set tabstop=8 shiftwidth=4: */ /* vi:set tabstop=4 shiftwidth=4: */
/* /*
* $Id$
* *
* Copyright (c) 1999-2001, Darren Hiebert * Copyright (c) 1999-2002, Darren Hiebert
* *
* This source code is released for free distribution under the terms of the * This source code is released for free distribution under the terms of the
* GNU General Public License. * GNU General Public License.
...@@ -31,20 +32,23 @@ typedef struct sStringList { ...@@ -31,20 +32,23 @@ typedef struct sStringList {
*/ */
extern stringList *stringListNew (void); extern stringList *stringListNew (void);
extern void stringListAdd (stringList *const current, vString *string); extern void stringListAdd (stringList *const current, vString *string);
extern void stringListRemoveLast (stringList *const current);
extern void stringListCombine (stringList *const current, stringList *const from); extern void stringListCombine (stringList *const current, stringList *const from);
extern stringList* stringListNewFromArgv (const char* const* const list); extern stringList* stringListNewFromArgv (const char* const* const list);
extern stringList* stringListNewFromFile (const char* const fileName); extern stringList* stringListNewFromFile (const char* const fileName);
extern void stringListClear (stringList *const current); extern void stringListClear (stringList *const current);
extern unsigned int stringListCount (const stringList *const current); extern unsigned int stringListCount (const stringList *const current);
extern vString* stringListItem (const stringList *const current, const unsigned int indx); extern vString* stringListItem (const stringList *const current, const unsigned int indx);
extern vString* stringListLast (const stringList *const current);
extern void stringListDelete (stringList *const current); extern void stringListDelete (stringList *const current);
extern boolean stringListHasInsensitive (const stringList *const current, const char *const string); extern boolean stringListHasInsensitive (const stringList *const current, const char *const string);
extern boolean stringListHas (const stringList *const current, const char *const string); extern boolean stringListHas (const stringList *const current, const char *const string);
extern boolean stringListHasFile (const stringList *const current, const char *const file); extern boolean stringListHasTest (const stringList *const current, boolean (*test)(const char *s));
extern boolean stringListRemoveExtension (stringList* const current, const char* const extension);
extern boolean stringListExtensionMatched (const stringList* const list, const char* const extension); extern boolean stringListExtensionMatched (const stringList* const list, const char* const extension);
extern boolean stringListFileMatched (const stringList* const list, const char* const str); extern boolean stringListFileMatched (const stringList* const list, const char* const str);
extern void stringListPrint (const stringList *const current); extern void stringListPrint (const stringList *const current);
#endif /* _STRLIST_H */ #endif /* _STRLIST_H */
/* vi:set tabstop=8 shiftwidth=4: */ /* vi:set tabstop=4 shiftwidth=4: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment