99#define ESC CONTROL('[')
1010
1111extern void lesskey_parse_error (char * s );
12+ extern char * homefile (char * filename );
1213
1314static int linenum ;
1415static int errors ;
16+ static char * lesskey_file ;
1517
1618static struct lesskey_cmdname cmdnames [] =
1719{
@@ -107,7 +109,7 @@ static struct lesskey_cmdname editnames[] =
107109 { NULL , 0 }
108110};
109111
110- void
112+ static void
111113xbuf_init (xbuf )
112114 struct xbuffer * xbuf ;
113115{
@@ -116,7 +118,7 @@ xbuf_init(xbuf)
116118 xbuf -> end = 0 ;
117119}
118120
119- void
121+ static void
120122xbuf_add (xbuf , ch )
121123 struct xbuffer * xbuf ;
122124 char ch ;
@@ -136,50 +138,12 @@ xbuf_add(xbuf, ch)
136138parse_error (msg )
137139 char * msg ;
138140{
139- char buf [128 ];
141+ char buf [1024 ];
140142 ++ errors ;
141- snprintf (buf , sizeof (buf ), "line %d: %s" , linenum , msg );
143+ snprintf (buf , sizeof (buf ), "%s, line %d: %s" , lesskey_file , linenum , msg );
142144 lesskey_parse_error (buf );
143145}
144146
145- static char *
146- mkpathname (dirname , filename )
147- char * dirname ;
148- char * filename ;
149- {
150- char * pathname ;
151-
152- pathname = calloc (strlen (dirname ) + strlen (filename ) + 2 , sizeof (char ));
153- strcpy (pathname , dirname );
154- strcat (pathname , PATHNAME_SEP );
155- strcat (pathname , filename );
156- return (pathname );
157- }
158-
159- /*
160- * Figure out the name of a default file (in the user's HOME directory).
161- */
162- char *
163- homefile (filename )
164- char * filename ;
165- {
166- char * p ;
167- char * pathname ;
168-
169- if ((p = getenv ("HOME" )) != NULL && * p != '\0' )
170- pathname = mkpathname (p , filename );
171- #if OS2
172- else if ((p = getenv ("INIT" )) != NULL && * p != '\0' )
173- pathname = mkpathname (p , filename );
174- #endif
175- else
176- {
177- fprintf (stderr , "cannot find $HOME - using current directory\n" );
178- pathname = mkpathname ("." , filename );
179- }
180- return (pathname );
181- }
182-
183147/*
184148 * Initialize data structures.
185149 */
@@ -573,10 +537,10 @@ parse_lesskey(infile, tables)
573537{
574538 FILE * desc ;
575539 char line [1024 ];
576- int linenum ;
577540
578541 if (infile == NULL )
579542 infile = homefile (DEF_LESSKEYINFILE );
543+ lesskey_file = infile ;
580544
581545 init_tables (tables );
582546
0 commit comments