I've noticed that trailing spaces are not ignored when a filename is input.
For example:
$ touch a.txt
$ ed
e a.txt <------------------- trailing space here
a.txt : No such file or directory
?
This has become an annoyance because I'm often wrapping ed in rlfe, which
appends a space to the filename upon tab completion. The following patch
ignores trailing space without breaking any tests. I considered adding a
test to confirm the new behavior but couldn't figure out the testsuite. :)
Feedback on the patch would be appreciated -- I have little experience in C
programming.
--- main_loop.c-orig 2014-12-11 02:44:53.239668678 -0500
+++ main_loop.c 2014-12-11 04:22:23.826563905 -0500
@@ -184,7 +184,8 @@
{ set_error_msg( "No current filename" ); return 0; }
if( !resize_buffer( &buf, &bufsz, pmax + 1 ) ) return 0;
for( n = 0; **ibufpp != '\n'; ++n, ++*ibufpp ) buf[n] = **ibufpp;
- buf[n] = 0;
+ while( isspace( buf[--n] ) ); /* drop trailing space */
+ buf[++n] = 0;
while( **ibufpp == '\n' ) ++*ibufpp; /* skip newline */
return ( may_access_filename( buf ) ? buf : 0 );
}
_______________________________________________
bug-ed mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-ed