From 3c1a49c48514ff324689c358acdd2af32ca395f6 Mon Sep 17 00:00:00 2001 From: Pascal Obry Date: Sat, 2 Aug 2008 16:19:21 +0200 Subject: [PATCH] Add support for makefile. --- ...ported_languages.ads => languages-makefile.adb} | 34 +++++++++++++++------- ...ported_languages.ads => languages-makefile.ads} | 18 +++++------- src/languages.adb | 14 +++++++-- src/supported_languages.ads | 5 ++-- 4 files changed, 46 insertions(+), 25 deletions(-) copy src/{supported_languages.ads => languages-makefile.adb} (73%) copy src/{supported_languages.ads => languages-makefile.ads} (83%) diff --git a/src/supported_languages.ads b/src/languages-makefile.adb similarity index 73% copy from src/supported_languages.ads copy to src/languages-makefile.adb index 4cc4457..c688cd6 100644 --- a/src/supported_languages.ads +++ b/src/languages-makefile.adb @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ -- Style Checker -- -- -- --- Copyright (C) 2006, Pascal Obry -- +-- Copyright (C) 2006-2008, Pascal Obry -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- @@ -19,14 +19,28 @@ -- -- ------------------------------------------------------------------------------ -with Languages.Ada; -with Languages.C; -with Languages.Python; -with Languages.Text; -with Languages.Script; -with Languages.Unknown; -with Languages.XML; +package body Languages.Makefile is -package Supported_Languages is + Handler : Lang; -end Supported_Languages; + ------------- + -- Comment -- + ------------- + + function Comment (L : in Lang) return String is + begin + return "#"; + end Comment; + + ------------------ + -- Is_Extension -- + ------------------ + + function Is_Extension (L : in Lang; Ext : in String) return Boolean is + begin + return Ext = "make" or else Ext = "makefile"; + end Is_Extension; + +begin + Register (Handler, "Makefile"); +end Languages.Makefile; diff --git a/src/supported_languages.ads b/src/languages-makefile.ads similarity index 83% copy from src/supported_languages.ads copy to src/languages-makefile.ads index 4cc4457..ea432de 100644 --- a/src/supported_languages.ads +++ b/src/languages-makefile.ads @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ -- Style Checker -- -- -- --- Copyright (C) 2006, Pascal Obry -- +-- Copyright (C) 2006-2008, Pascal Obry -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- @@ -19,14 +19,12 @@ -- -- ------------------------------------------------------------------------------ -with Languages.Ada; -with Languages.C; -with Languages.Python; -with Languages.Text; -with Languages.Script; -with Languages.Unknown; -with Languages.XML; +package Languages.Makefile is -package Supported_Languages is + type Lang is new Languages.Lang with null record; -end Supported_Languages; + function Comment (L : in Lang) return String; + + function Is_Extension (L : in Lang; Ext : in String) return Boolean; + +end Languages.Makefile; diff --git a/src/languages.adb b/src/languages.adb index a9e23ad..c3c1ec4 100644 --- a/src/languages.adb +++ b/src/languages.adb @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ -- Style Checker -- -- -- --- Copyright (C) 2006, Pascal Obry -- +-- Copyright (C) 2006-2008, Pascal Obry -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- @@ -82,10 +82,18 @@ package body Languages is --------- function Get (Filename : in String) return Lang'Class is - Ext : constant String := Directories.Extension (Filename); + Ext : aliased constant String := Directories.Extension (Filename); + Base : aliased constant String := Directories.Base_Name (Filename); + Check : access constant String; begin + if Ext = "" then + Check := Base'Access; + else + Check := Ext'Access; + end if; + for K in 1 .. Index loop - if Is_Extension (Lang_Set (K).all, Ext) then + if Is_Extension (Lang_Set (K).all, Check.all) then return Lang_Set (K).all; end if; end loop; diff --git a/src/supported_languages.ads b/src/supported_languages.ads index 4cc4457..a595dba 100644 --- a/src/supported_languages.ads +++ b/src/supported_languages.ads @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ -- Style Checker -- -- -- --- Copyright (C) 2006, Pascal Obry -- +-- Copyright (C) 2006-2008, Pascal Obry -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- @@ -21,9 +21,10 @@ with Languages.Ada; with Languages.C; +with Languages.Makefile; with Languages.Python; -with Languages.Text; with Languages.Script; +with Languages.Text; with Languages.Unknown; with Languages.XML; -- 2.11.4.GIT