Hello,

The following patch would strip leading blank characters (instead of
tabs only) from the lines in the document when <<- redirection is
used (and should be useful when indentation is done with spaces):

--- tree.h.orig Mon Mar 28 23:28:22 2005
+++ tree.h      Sun Sep 13 08:23:01 2015
@@ -92,7 +92,7 @@
 #define        IOCAT   0x5             /* >> */
 #define        IODUP   0x6             /* <&/>& */
 #define        IOEVAL  BIT(4)          /* expand in << */
-#define        IOSKIP  BIT(5)          /* <<-, skip ^\t* */
+#define        IOSKIP  BIT(5)          /* <<-, skip ^[ \t]* */
 #define        IOCLOB  BIT(6)          /* >|, override -o noclobber */
 #define IORDUP BIT(7)          /* x<&y (as opposed to x>&y) */
 #define IONAMEXP BIT(8)                /* name has been expanded */

--- lex.c.orig  Sun Sep 13 07:50:06 2015
+++ lex.c       Sun Sep 13 08:08:29 2015
@@ -843,7 +843,7 @@
        int c;
        char *volatile eof;
        char *eofp;
-       int skiptabs;
+       int skipblanks;
        XString xs;
        char *xp;
        int xpos;
@@ -857,13 +857,13 @@
 
        for (;;) {
                eofp = eof;
-               skiptabs = iop->flag & IOSKIP;
+               skipblanks = iop->flag & IOSKIP;
                xpos = Xsavepos(xs, xp);
                while ((c = getsc()) != 0) {
-                       if (skiptabs) {
-                               if (c == '\t')
+                       if (skipblanks) {
+                               if (isblank(c))
                                        continue;
-                               skiptabs = 0;
+                               skipblanks = 0;
                        }
                        if (c != *eofp)
                                break;

--- ksh.1.orig  Fri Jul 17 08:39:57 2015
+++ ksh.1       Sun Sep 13 08:11:05 2015
@@ -2085,7 +2085,8 @@
 .It \*(Lt\*(Lt- Ar marker
 Same as
 .Ic \*(Lt\*(Lt ,
-except leading tabs are stripped from lines in the here document.
+except leading blank characters (tabs and spaces) are stripped from lines in
+the here document.
 .It \*(Lt& Ar fd
 Standard input is duplicated from file descriptor
 .Ar fd .

--- sh.1.orig   Wed Jun 17 07:47:43 2015
+++ sh.1        Sun Sep 13 08:13:20 2015
@@ -1554,7 +1554,7 @@
 .It Oo Ar n Oc Ns <<-
 Same as
 .Ic << ,
-except leading tabs are stripped from lines in
+except leading blank characters (spaces or tabs) are stripped from lines in
 .Ar block .
 .It Oo Ar n Oc Ns <& Ns Ar file
 Make file descriptor

I don't know if isblank(3) is acceptable here (since I do not understand
from the man page if it could return true for characters different from
spaces and tabs when locales other than C are used); if not, a simple
or operator between '\t' and ' ' could be used instead.

All the best

-- 
Alessandro DE LAURENZIS
[mailto:just22....@gmail.com]
LinkedIn: http://it.linkedin.com/in/delaurenzis

Reply via email to