Skip to content

Commit d133daa

Browse files
authored
Merge pull request #1 from ghfbsd/master
Added ForTran 77 and R language definitions, with expanded capabilities and documentation to support them.
2 parents a8c64b4 + 23ab11c commit d133daa

File tree

8 files changed

+61
-9
lines changed

8 files changed

+61
-9
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ install_manifest.txt
99
compile_commands.json
1010
CTestTestfile.cmake
1111
_deps
12+
*.o
13+
vgrind.sh
14+
vfontedpr
15+
Makefile

extern.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ extern char *l_prcbeg; /* regular expr for procedure begin */
5050
extern char *l_strbeg; /* delimiter for string constant */
5151
extern char *l_strend; /* delimiter for string constant */
5252
extern bool l_toplex; /* procedures only defined at top lex level */
53+
extern bool l_dotaln; /* dot is alphanumeric in this lang */
5354
extern const char *language; /* the language indicator */
5455

5556
#include <sys/cdefs.h>

regexp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,10 @@ expmatch(
467467
/* not optional and we still matched */
468468
return NULL;
469469
}
470-
if (!isalnum((unsigned char)*s1) && *s1 != '_')
471-
return NULL;
470+
if (!isalnum((unsigned char)*s1)){
471+
if (!(*s1 == '_' || (l_dotaln && *s1 == '.')))
472+
return NULL;
473+
}
472474
if (*s1 == '\\')
473475
x_escaped = x_escaped ? false : true;
474476
else

vfontedpr.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static bool pass = false; /*
9797

9898
static int blklevel; /* current nesting level */
9999
static int comtype; /* type of comment */
100-
static const char *defsfile[2] = { _PATH_VGRINDEFS, 0 };
100+
static char *defsfile[2] = { _PATH_VGRINDEFS, 0 };
101101
/* name of language definitions file */
102102
static int margin;
103103
static int plstack[PSMAX]; /* the procedure nesting level stack */
@@ -124,6 +124,7 @@ char *l_prcbeg; /* regular expr for procedure begin */
124124
char *l_strbeg; /* delimiter for string constant */
125125
char *l_strend; /* delimiter for string constant */
126126
bool l_toplex; /* procedures only defined at top lex level */
127+
bool l_dotaln; /* dot is alphanumeric in this lang */
127128
const char *language = "c"; /* the language indicator */
128129

129130
#define ps(x) printf("%s", x)
@@ -280,6 +281,7 @@ main(int argc, char *argv[])
280281
l_escape = '\\';
281282
l_onecase = (cgetcap(defs, "oc", ':') != NULL);
282283
l_toplex = (cgetcap(defs, "tl", ':') != NULL);
284+
l_dotaln = (cgetcap(defs, "da", ':') != NULL);
283285

284286
/* initialize the program */
285287

@@ -347,7 +349,7 @@ main(int argc, char *argv[])
347349
exit(0);
348350
}
349351

350-
#define isidchr(c) (isalnum((unsigned char)(c)) || (c) == '_')
352+
#define isidchr(c) (isalnum((unsigned char)(c)) || (c) == '_' || (l_dotaln && (c) == '.'))
351353

352354
static void
353355
putScp(char *os)
@@ -657,6 +659,9 @@ putcp(int c)
657659
ps("\\fI\\h'\\w' 'u-\\w'/'u'/\\fP");
658660
break;
659661

662+
case 015: /* Ignore cr - most compilers don't care */
663+
break;
664+
660665
default:
661666
if (c < 040)
662667
putchar('^'), c |= '@';

vgrind.1

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ There need be no particular ordering with
9292
.Xr eqn 1
9393
or
9494
.Xr tbl 1 .
95+
Function and procedure labels may be suppressed in filter mode by making the
96+
.Xr troff
97+
.Em y
98+
register nonzero; the lines
99+
.Bl -tag -width XXXXXXXXXX
100+
.It \&.vS
101+
starts processing
102+
.It \&.nr\ y\ 1
103+
suppress labeling
104+
.It ...
105+
program text
106+
.It \&.vE
107+
ends processing
108+
.El
109+
will achieve this.
95110
.Pp
96111
In regular mode
97112
.Nm
@@ -134,6 +149,10 @@ or the default),
134149
.Pq Fl l Ns Ar sh ,
135150
.Tn RATFOR
136151
.Pq Fl l Ns Ar r ,
152+
.Tn "Fortran 77"
153+
.Pq Fl l Ns Ar f77 ,
154+
.Tn R
155+
.Pq Fl l Ns Ar R ,
137156
.Tn MODULA2
138157
.Pq Fl l Ns Ar mod2 ,
139158
.Tn YACC
@@ -245,7 +264,9 @@ The mechanism of
245264
.Xr ctags 1
246265
in recognizing functions should be used here.
247266
.Pp
248-
Filter mode does not work in documents using the
267+
Filter mode must be the last option if used.
268+
.Pp
269+
Filter mode might interfere with formatting of documents using the
249270
.Fl me
250271
or
251272
.Fl ms

vgrind.tmac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
'ne 3
5454
..
5555
'de FN
56-
\f2\s(14\h'\\n(.lu-\w'\\$1'u'\\$1\fP\s0\h'|0u'\c
56+
.if !\\ny \f2\s(14\h'\\n(.lu-\w'\\$1'u'\\$1\fP\s0\h'|0u'\c
5757
.if \\nx .tm \\$1 \\*(=F \\n%
5858
'ds =f \&...\\$1
5959
..

vgrindefs.5

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,27 @@ The following table names and describes each field.
5656
.It "be str regular expression for the end of a lexical block"
5757
.It "cb str regular expression for the start of a comment"
5858
.It "ce str regular expression for the end of a comment"
59+
.It "ab str regular expression for the alternate start of a comment"
60+
.It "ae str regular expression for the alternate end of a comment"
5961
.It "sb str regular expression for the start of a string"
6062
.It "se str regular expression for the end of a string"
6163
.It "lb str regular expression for the start of a character constant"
6264
.It "le str regular expression for the end of a character constant"
6365
.It "tl bool present means procedures are only defined at the top lexical level"
6466
.It "oc bool present means upper and lower case are equivalent"
67+
.It "da bool present means dot is considered alphanumeric in identifiers"
6568
.It "kw str a list of keywords separated by spaces"
6669
.El
6770
.Sh FILES
6871
.Bl -tag -width /usr/share/misc/vgrindefs -compact
69-
.It Pa /usr/share/misc/vgrindefs
72+
.It Pa $(PREFIX)/share/vgrind/vgrindefs
7073
File containing terminal descriptions.
7174
.El
7275
.Sh EXAMPLES
7376
The following entry, which describes the C language, is
7477
typical of a language entry.
7578
.Bd -literal
76-
C|c:\
79+
C|c:\e
7780
:pb=^\ed?*?\ed?\ep\ed?\e(\ea?\e):bb={:be=}:cb=/*:ce=*/:sb=":se=\ee":\e
7881
:lb=':le=\ee':tl:\e
7982
:kw=asm auto break case char continue default do double else enum\e

vgrindefs.src

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
C|c:\
3838
:pb=^\d?*?\d?\p\d?\(\a?\)(\d|{):bb={:be=}:cb=/*:ce=*/:sb=":se=\e":lb=':\
3939
:le=\e':tl:\
40-
:kw=asm auto break case char continue default do double else enum\
40+
:kw=asm auto break case char const continue default do double else enum\
4141
extern float for fortran goto if int long register return short\
4242
sizeof static struct switch typedef union unsigned void while #define\
4343
#else #endif #if #ifdef #ifndef #include #undef # define else endif\
@@ -146,3 +146,19 @@ C++|c++:\
146146
ifdef ifndef include undef defined\
147147
class const delete friend inline new operator overload private\
148148
protected public virtual:
149+
f77|F77:\
150+
:pb=(program|subroutine|function)\d\p\d?\(\a?\):\
151+
:bb=(program|subroutine|function)\d\p\d?\(\a?\):be=^\d?end:\
152+
:cb=^c:ce=$:\
153+
:ab=^*:ae=$:\
154+
:sb=("|'):se=(\e"|\e'):oc:\
155+
:kw=character complex double integer implicit logical real precision \
156+
external common \
157+
call cycle exit data do else elseif end endif format function goto if \
158+
include parameter pause print read return save stop subroutine then \
159+
write:
160+
R:\
161+
:pb=\p\d<-\d(function):bb={:be=}:\
162+
:cb=#:ce=$:ab=#:ae=$:da:\
163+
:sb=("|'):se=(\e"|\e'):\
164+
:kw=function for while repeat if else break next stop switch:

0 commit comments

Comments
 (0)