delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/05/19/15:24:46

From: condict AT opengroup DOT org (Michael Condict)
Subject: Fix to readline for case-insensitive file-name completion
19 May 1997 15:24:46 -0700 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <9705191749.AA22998.cygnus.gnu-win32@hare.osf.org>
Original-To: noer AT cygnus DOT com
Original-Cc: condict AT opengroup DOT org, gnu-win32 AT cygnus DOT com
Original-Sender: owner-gnu-win32 AT cygnus DOT com

Geoffrey,

I found the case-sensitive file-name completion in bash unuseable in
Windows, because one often doesn't know the case of names in advance.
So I changed it to case-insensitive by adding a few lines to

		bash/lib/readline/complete.c

I'd like to propose that this feature be integrated into the next
release of Cygnus Win32.

I suppose I should have put the change inside an "#ifdef MSDO" or something,
but you can do that when integrating it.  The changes are very
small so I've appended it as a context diff to the end of this message.

Please let me know if you want this contribution in a different format.
Thanks.

Michael Condict			m DOT condict AT opengroup DOT org
The Open Group Research Inst.	(617) 621-7349
11 Cambridge Center
Cambridge, MA 02142

--------- changes to src/user-tools/bash/lib/readline/complete.c ----------

*** complete.c	Mon May 19 13:34:16 1997
--- complete.c.ORIG	Mon May 19 13:32:04 1997
***************
*** 1077,1083 ****
  /* **************************************************************** */
  
  /* Non-zero means that case is not significant in completion. */
! int completion_case_fold = 1;
  
  /* Return an array of (char *) which is a list of completions for TEXT.
     If there are no completions, return a NULL pointer.
--- 1077,1083 ----
  /* **************************************************************** */
  
  /* Non-zero means that case is not significant in completion. */
! int completion_case_fold = 0;
  
  /* Return an array of (char *) which is a list of completions for TEXT.
     If there are no completions, return a NULL pointer.
***************
*** 1265,1293 ****
  	{
  	  /* Otherwise, if these match up to the length of filename, then
  	     it is a match. */
! 	  if (completion_case_fold)
! 	    {
! 	      if (((int)D_NAMLEN (entry)) >= filename_len)
! 		{
! 		  register int c1, c2, si;
! 
! 		  for (si = 0; si < filename_len; si++)
! 		    {
! 		      c1 = to_lower(entry->d_name[si]);
! 		      c2 = to_lower(filename[si]);
! 		      if (c1 != c2) break;
! 		    }
! 		  if (si == filename_len)
! 		    break;
! 		}
! 	    }
! 	  else
! 	    {
! 	      if ((entry->d_name[0] == filename[0]) &&
! 		  (((int)D_NAMLEN (entry)) >= filename_len) &&
! 		  (strncmp (filename, entry->d_name, filename_len) == 0))
! 		break;
! 	    }
  	}
      }
  
--- 1265,1274 ----
  	{
  	  /* Otherwise, if these match up to the length of filename, then
  	     it is a match. */
! 	    if ((entry->d_name[0] == filename[0]) &&
! 		(((int)D_NAMLEN (entry)) >= filename_len) &&
! 		(strncmp (filename, entry->d_name, filename_len) == 0))
! 	      break;
  	}
      }
  
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019