Commit Diff


commit - a556718a24d003523b7fb0406061e7f89291b14e
commit + f3966209e5941ee3139425c5e375d373c1026923
blob - a6de66631daec139532bb4bf1a110c001d9a0ce6
blob + ecc1ea926a22eb27e66672c71084d4c17bf899b5
--- .gitignore
+++ .gitignore
@@ -1,9 +1,11 @@
+*~
 *.pem
 TAGS
 gmid
 !contrib/gmid
 gg
 *.o
+*.swp
 compat/*.o
 docs
 y.tab.*
@@ -14,6 +16,7 @@ config.h.old
 config.log
 config.log.old
 configure.local
+!contrib/vim/syntax_checkers/gmid
 regress/testdata
 regress/*.pem
 regress/*.key
blob - c57932c8a7cdb432f314bb2f0209434f67a37aa4
blob + ab45f9bd8c051602da9e2eb481d16d3450005e46
--- contrib/README
+++ contrib/README
@@ -16,4 +16,8 @@ gmid.service
 vim
 
 	Syntax highlighting of gmid configuration for vim, to be
-	placed into ~/.vim/ or /usr/share/vim/vimfiles.
+	placed into ~/.vim/ or /usr/share/vim/vimfiles/.
+
+	To enable Syntastic checker, put this line in your vimrc:
+
+	let g:syntastic_gmid_checkers = ['gmid']
blob - /dev/null
blob + d3187ee1ff26b97cd8581b7e7ff56682bcfcf282 (mode 644)
--- /dev/null
+++ contrib/vim/syntax_checkers/gmid/gmid.vim
@@ -0,0 +1,36 @@
+" Syntax checking plugin for syntastic
+" Language: gmid(1) configuration file
+" Licence: ISC
+
+if exists('g:loaded_syntastic_gmid_gmid_checker')
+    finish
+endif
+let g:loaded_syntastic_gmid_gmid_checker = 1
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+function! SyntaxCheckers_gmid_gmid_GetLocList() dict
+    let makeprg = self.makeprgBuild({ 'args': '-nc' })
+
+    let errorformat =
+        \ '%-Gconfig OK,' .
+        \ '%f:%l %tarning: %m,' .
+        \ '%f:%l %trror: %m'
+
+    return SyntasticMake({
+        \ 'makeprg': makeprg,
+        \ 'errorformat': errorformat,
+        \ 'defaults': {'type': 'E'},
+        \ 'returns': [0, 1] })
+endfunction
+
+call g:SyntasticRegistry.CreateAndRegisterChecker({
+    \ 'filetype': 'gmid',
+    \ 'name': 'gmid',
+    \ 'exec': 'gmid'})
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
+
+" vim: set sw=4 sts=4 et fdm=marker:
blob - 35a918a70de6d82089057c1cfd41193faadf5d8d
blob + bf95d40ceca9bad555e7e748f902bf56e94b509f
--- parse.y
+++ parse.y
@@ -52,6 +52,9 @@ int		 yylex(void);
 void		 yyerror(const char *, ...)
     __attribute__((__format__ (printf, 1, 2)))
     __attribute__((__nonnull__ (1)));
+void		 yywarn(const char *, ...)
+    __attribute__((__format__ (printf, 1, 2)))
+    __attribute__((__nonnull__ (1)));
 int		 kw_cmp(const void *, const void *);
 int		 lookup(char *);
 int		 igetc(void);
@@ -183,10 +186,9 @@ varset		: STRING '=' string		{
 option		: TCHROOT string	{ conf.chroot = $2; }
 		| TIPV6 bool		{ conf.ipv6 = $2; }
 		| TMIME STRING string	{
-			fprintf(stderr, "%s:%d: `mime MIME EXT' is deprecated and "
-			    "will be removed in a future version, "
-			    "please use the new syntax: `map MIME to-ext EXT'\n",
-			    config_path, yylval.lineno+1);
+			yywarn("`mime MIME EXT' is deprecated and will be "
+			    "removed in a future version, please use the new "
+			    "syntax: `map MIME to-ext EXT'");
 			add_mime(&conf.mime, $2, $3);
 		}
 		| TMAP string TTOEXT string { add_mime(&conf.mime, $2, $4); }
@@ -210,15 +212,14 @@ vhost		: TSERVER string {
 			host->domain = $2;
 
 			if (strstr($2, "xn--") != NULL) {
-				warnx("%s:%d \"%s\" looks like punycode: "
-				    "you should use the decoded hostname.",
-				    config_path, yylval.lineno+1, $2);
+				yywarn("\"%s\" looks like punycode: you "
+				    "should use the decoded hostname", $2);
 			}
 		} '{' optnl servopts locations '}' {
 			if (host->cert == NULL || host->key == NULL)
 				yyerror("invalid vhost definition: %s", $2);
 		}
-		| error '}'		{ yyerror("error in server directive"); }
+		| error '}'		{ yyerror("bad server directive"); }
 		;
 
 servopts	: /* empty */
@@ -411,7 +412,19 @@ yyerror(const char *msg, ...)
 	file->errors++;
 
 	va_start(ap, msg);
-	fprintf(stderr, "%s:%d: ", config_path, yylval.lineno);
+	fprintf(stderr, "%s:%d error: ", config_path, yylval.lineno);
+	vfprintf(stderr, msg, ap);
+	fprintf(stderr, "\n");
+	va_end(ap);
+}
+
+void
+yywarn(const char *msg, ...)
+{
+	va_list ap;
+
+	va_start(ap, msg);
+	fprintf(stderr, "%s:%d warning: ", config_path, yylval.lineno);
 	vfprintf(stderr, msg, ap);
 	fprintf(stderr, "\n");
 	va_end(ap);
@@ -640,7 +653,7 @@ top:
 				*p = '\0';
 				break;
 			} else if (c == '\0') {
-				yyerror("syntax error");
+				yyerror("invalid syntax");
 				return findeol();
 			}
 			if (p + 1 >= buf + sizeof(buf) - 1) {