Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Menu completion fix



If one tries menu completion for example after ~/foo the tilde will be
quoted in the newly insered word.  The patch also change prefizes/suffizes
to prefixes/suffixes.  Or is prefizes a correct plural form of prefix?  I
know that some nouns have irregular plural like matrix -> matrices but I
did not know that that prefix/suffix is also irregular.

Zoltan

*** Src/zle_tricky.c	1996/07/09 17:07:40	2.59
--- Src/zle_tricky.c	1996/07/10 00:46:56
***************
*** 2381,2390 ****
  
      /* Compute line prefix/suffix. */
  
!     sav = s[offs];
!     s[offs] = '\0';
!     p = quotename(s, NULL, NULL, NULL);
!     if (strcmp(p, s) && !strpfx(p, qword)) {
  	int l1, l2;
  
  	backdel(l1 = cs - wb);
--- 2381,2392 ----
  
      /* Compute line prefix/suffix. */
  
!     lpl = offs + 1;
!     lpre = zalloc(lpl + 1);
!     memcpy(lpre, s, lpl);
!     lpre[lpl] = '\0';
!     p = quotename(lpre, NULL, NULL, NULL);
!     if (strcmp(p, lpre) && !strpfx(p, qword)) {
  	int l1, l2;
  
  	backdel(l1 = cs - wb);
***************
*** 2392,2402 ****
  	inststrlen(p, 1, l2 = strlen(p));
  	we += l2 - l1;
      }
!     lpre = ztrdup(s);
!     s[offs] = sav;
!     if (s[offs] &&
! 	(p = quotename(s + offs, NULL, NULL, NULL)) &&
! 	(strcmp(p, s + offs) && !strsfx(p, qword))) {
  	int l1, l2;
  
  	foredel(l1 = strlen(s + offs));
--- 2394,2403 ----
  	inststrlen(p, 1, l2 = strlen(p));
  	we += l2 - l1;
      }
!     lsuf = ztrdup(s + offs);
!     lsl = strlen(lsuf);
!     if (lsl && (p = quotename(lsuf, NULL, NULL, NULL)) &&
! 	(strcmp(p, lsuf) && !strsfx(p, qword))) {
  	int l1, l2;
  
  	foredel(l1 = strlen(s + offs));
***************
*** 2404,2414 ****
  	inststrlen(p, 0, l2 = strlen(p));
  	we += l2 - l1;
      }
-     lsuf = ztrdup(s + offs);
  
      /* First check for ~.../... */
      if (ic == Tilde) {
! 	for (p = lpre + strlen(lpre); p > lpre; p--)
  	    if (*p == '/')
  		break;
  
--- 2405,2414 ----
  	inststrlen(p, 0, l2 = strlen(p));
  	we += l2 - l1;
      }
  
      /* First check for ~.../... */
      if (ic == Tilde) {
! 	for (p = lpre + lpl; p > lpre; p--)
  	    if (*p == '/')
  		break;
  
***************
*** 2475,2483 ****
      untokenize(lpre);
      untokenize(lsuf);
  
-     lpl = strlen(lpre);
-     lsl = strlen(lsuf);
- 
      /* Handle completion of files specially (of course). */
  
      if ((cc->mask & (CC_FILES | CC_COMMPATH)) || cc->glob) {
--- 2475,2480 ----
***************
*** 2946,2954 ****
      makearray(matches);
      PERMALLOC {
  	amatches = arrdup(amatches);
! 	/* And quote the prefizes/suffize. */
! 	quotepresuf(&lpre);
! 	quotepresuf(&lsuf);
  	quotepresuf(&fpre);
  	quotepresuf(&fsuf);
  	quotepresuf(&ppre);
--- 2943,2961 ----
      makearray(matches);
      PERMALLOC {
  	amatches = arrdup(amatches);
! 	/* And quote the prefixes/suffixes. */
! 	if (hasspecial(s)) {
! 	    zfree(lpre, lpl);
! 	    zfree(lsuf, lsl);
! 	    lpre = zalloc(lpl + 1);
! 	    memcpy(lpre, s, lpl);
! 	    lpre[lpl] = '\0';
! 	    lsuf = ztrdup(s + offs);
! 	    quotepresuf(&lpre);
! 	    quotepresuf(&lsuf);
! 	    untokenize(lpre);
! 	    untokenize(lsuf);
! 	}
  	quotepresuf(&fpre);
  	quotepresuf(&fsuf);
  	quotepresuf(&ppre);
***************
*** 3515,3521 ****
      nlpl = lpre ? niceztrlen(lpre) : 0;
      nlsl = lsuf ? niceztrlen(lsuf) : 0;
  
!     /* Calculate the lengths of the prefizes/suffizes we have to ignore
         during printing. */
      off = ispattern && ppre && *ppre &&
  	!(haswhat & (HAS_MISC | HAS_PATHPAT)) ? strlen(ppre) : 0;
--- 3522,3528 ----
      nlpl = lpre ? niceztrlen(lpre) : 0;
      nlsl = lsuf ? niceztrlen(lsuf) : 0;
  
!     /* Calculate the lengths of the prefixes/suffixes we have to ignore
         during printing. */
      off = ispattern && ppre && *ppre &&
  	!(haswhat & (HAS_MISC | HAS_PATHPAT)) ? strlen(ppre) : 0;
*** Src/utils.c	1996/07/09 17:05:37	2.42
--- Src/utils.c	1996/07/10 00:05:07
***************
*** 3142,3169 ****
      return l;
  }
  
  /* Unmetafy and output a string, quoted if it contains special characters. */
  
  /**/
  int
  quotedzputs(char const *s, FILE *stream)
  {
-     char const *p;
      int inquote = 0, c;
  
      /* check for empty string */
      if(!*s)
  	return fputs("''", stream);
  
!     /* check for special characters in the string */
!     for (p = s; *p; p++)
! 	if (ispecial(*p == Meta ? *++p ^ 32 : *p))
! 	    goto hasspecial;
! 
!     /* no special characters at all */
!     return zputs(s, stream);
  
-     hasspecial:
      if (isset(RCQUOTES)) {
  	/* use rc-style quotes-within-quotes for the whole string */
  	if(fputc('\'', stream) < 0)
--- 3142,3174 ----
      return l;
  }
  
+ /* check for special characters in the string */
+ 
+ /**/
+ int
+ hasspecial(char const *s)
+ {
+     for (; *s; s++)
+ 	if (ispecial(*s == Meta ? *++s ^ 32 : *s))
+ 	    return 1;
+     return 0;
+ }
+ 
  /* Unmetafy and output a string, quoted if it contains special characters. */
  
  /**/
  int
  quotedzputs(char const *s, FILE *stream)
  {
      int inquote = 0, c;
  
      /* check for empty string */
      if(!*s)
  	return fputs("''", stream);
  
!     if (!hasspecial(s))
! 	return zputs(s, stream);
  
      if (isset(RCQUOTES)) {
  	/* use rc-style quotes-within-quotes for the whole string */
  	if(fputc('\'', stream) < 0)




Messages sorted by: Reverse Date, Date, Thread, Author